diff --git a/.github/workflows/regtest.yml b/.github/workflows/regtest.yml index 46e2d8ed..ed052a4f 100644 --- a/.github/workflows/regtest.yml +++ b/.github/workflows/regtest.yml @@ -63,7 +63,7 @@ jobs: MINT_PORT: 3337 MINT_TEST_DATABASE: ${{ inputs.mint-database }} TOR: false - MINT_LIGHTNING_BACKEND: ${{ inputs.backend-wallet-class }} + MINT_BACKEND_BOLT11_SAT: ${{ inputs.backend-wallet-class }} MINT_LNBITS_ENDPOINT: http://localhost:5001 MINT_LNBITS_KEY: d08a3313322a4514af75d488bcc27eee MINT_LND_REST_ENDPOINT: https://localhost:8081/ diff --git a/cashu/lightning/blink.py b/cashu/lightning/blink.py index 0e12fb1b..5c9f0dc4 100644 --- a/cashu/lightning/blink.py +++ b/cashu/lightning/blink.py @@ -444,7 +444,11 @@ async def get_payment_quote(self, bolt11: str) -> PaymentQuoteResponse: fees = Amount(unit=Unit.msat, amount=fees_msat) amount = Amount(unit=Unit.msat, amount=amount_msat) - return PaymentQuoteResponse(checking_id=bolt11, fee=fees, amount=amount) + return PaymentQuoteResponse( + checking_id=bolt11, + fee=fees.to(self.unit, round="up"), + amount=amount.to(self.unit, round="up"), + ) async def main(): diff --git a/cashu/lightning/corelightningrest.py b/cashu/lightning/corelightningrest.py index dff61a41..da36cdc1 100644 --- a/cashu/lightning/corelightningrest.py +++ b/cashu/lightning/corelightningrest.py @@ -320,5 +320,7 @@ async def get_payment_quote(self, bolt11: str) -> PaymentQuoteResponse: fees = Amount(unit=Unit.msat, amount=fees_msat) amount = Amount(unit=Unit.msat, amount=amount_msat) return PaymentQuoteResponse( - checking_id=invoice_obj.payment_hash, fee=fees, amount=amount + checking_id=invoice_obj.payment_hash, + fee=fees.to(self.unit, round="up"), + amount=amount.to(self.unit, round="up"), ) diff --git a/cashu/lightning/fake.py b/cashu/lightning/fake.py index 111eae1b..97834ee6 100644 --- a/cashu/lightning/fake.py +++ b/cashu/lightning/fake.py @@ -169,5 +169,7 @@ async def get_payment_quote(self, bolt11: str) -> PaymentQuoteResponse: raise NotImplementedError() return PaymentQuoteResponse( - checking_id=invoice_obj.payment_hash, fee=fees, amount=amount + checking_id=invoice_obj.payment_hash, + fee=fees.to(self.unit, round="up"), + amount=amount.to(self.unit, round="up"), ) diff --git a/cashu/lightning/lnbits.py b/cashu/lightning/lnbits.py index 916cb710..96dff6bb 100644 --- a/cashu/lightning/lnbits.py +++ b/cashu/lightning/lnbits.py @@ -165,5 +165,7 @@ async def get_payment_quote(self, bolt11: str) -> PaymentQuoteResponse: fees = Amount(unit=Unit.msat, amount=fees_msat) amount = Amount(unit=Unit.msat, amount=amount_msat) return PaymentQuoteResponse( - checking_id=invoice_obj.payment_hash, fee=fees, amount=amount + checking_id=invoice_obj.payment_hash, + fee=fees.to(self.unit, round="up"), + amount=amount.to(self.unit, round="up"), ) diff --git a/cashu/lightning/lndrest.py b/cashu/lightning/lndrest.py index dd47ea0e..29197325 100644 --- a/cashu/lightning/lndrest.py +++ b/cashu/lightning/lndrest.py @@ -272,5 +272,7 @@ async def get_payment_quote(self, bolt11: str) -> PaymentQuoteResponse: fees = Amount(unit=Unit.msat, amount=fees_msat) amount = Amount(unit=Unit.msat, amount=amount_msat) return PaymentQuoteResponse( - checking_id=invoice_obj.payment_hash, fee=fees, amount=amount + checking_id=invoice_obj.payment_hash, + fee=fees.to(self.unit, round="up"), + amount=amount.to(self.unit, round="up"), ) diff --git a/cashu/lightning/strike.py b/cashu/lightning/strike.py index 5abd5fb6..1824c790 100644 --- a/cashu/lightning/strike.py +++ b/cashu/lightning/strike.py @@ -195,27 +195,3 @@ async def get_payment_status(self, checking_id: str) -> PaymentStatus: fee_msat=data["details"]["fee"], preimage=data["preimage"], ) - - # async def paid_invoices_stream(self) -> AsyncGenerator[str, None]: - # url = f"{self.endpoint}/api/v1/payments/sse" - - # while True: - # try: - # async with requests.stream("GET", url) as r: - # async for line in r.aiter_lines(): - # if line.startswith("data:"): - # try: - # data = json.loads(line[5:]) - # except json.decoder.JSONDecodeError: - # continue - - # if type(data) is not dict: - # continue - - # yield data["payment_hash"] # payment_hash - - # except: - # pass - - # print("lost connection to lnbits /payments/sse, retrying in 5 seconds") - # await asyncio.sleep(5) diff --git a/cashu/mint/ledger.py b/cashu/mint/ledger.py index ffdf070c..255a61bc 100644 --- a/cashu/mint/ledger.py +++ b/cashu/mint/ledger.py @@ -516,7 +516,8 @@ async def melt_quote( payment_quote.fee.unit == unit ), "payment quote fee units do not match" - # Lightning bolt11 idiosyncrasy below + # We assume that the request is a bolt11 invoice, this works since we + # support only the bol11 method for now. invoice_obj = bolt11.decode(melt_quote.request) assert invoice_obj.amount_msat, "invoice has no amount." # we set the expiry of this quote to the expiry of the bolt11 invoice