Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
lollerfirst committed Jan 23, 2025
1 parent ea96fab commit 0a6bd28
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cashu/mint/ledger.py
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,10 @@ async def melt_quote(
# and therefore respond with internal transaction fees (0 for now)
mint_quote = await self.crud.get_mint_quote(request=request, db=self.db)
if mint_quote and mint_quote.unit == melt_quote.unit:
# check if the melt quote is partial and error if it is.
# it's just not possible to handle this case
if melt_quote.is_mpp:
raise TransactionError("multi-part internal payments are not possible. try with a regular payment.")
payment_quote = self.create_internal_melt_quote(mint_quote, melt_quote)
else:
# not internal
Expand Down
13 changes: 13 additions & 0 deletions tests/test_wallet_regtest_mpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from cashu.wallet.wallet import Wallet
from tests.conftest import SERVER_ENDPOINT
from tests.helpers import (
assert_err,
get_real_invoice,
is_fake,
partial_pay_real_invoice,
Expand Down Expand Up @@ -139,3 +140,15 @@ async def pay_mpp(amount: int, proofs: List[Proof], delay: float = 0.0):
await asyncio.sleep(2)

assert wallet.balance <= 384 - 64

@pytest.mark.asyncio
@pytest.mark.skipif(is_fake, reason="only regtest")
async def test_regtest_internal_mpp_melt_quotes(wallet: Wallet, ledger: Ledger):
# make sure wallet knows the backend supports mpp
assert wallet.mint_info.supports_mpp("bolt11", wallet.unit)

# create a mint quote
mint_quote = wallet.request_mint(128)

# try and create a multi-part melt quote
assert_err(wallet.melt_quote(mint_quote.request, 100), "multi-part internal payments are not possible. try with a regular payment.")

0 comments on commit 0a6bd28

Please sign in to comment.