Skip to content

Comments

Feature/pay invoice return fees paid#149

Merged
denmeh merged 3 commits intomasterfrom
feature/pay-invoice-return-fees-paid
Feb 19, 2026
Merged

Feature/pay invoice return fees paid#149
denmeh merged 3 commits intomasterfrom
feature/pay-invoice-return-fees-paid

Conversation

@Okazakee
Copy link
Contributor

No description provided.

- Fix double msat conversion bug in Breez wallet (remove *1000)
- Add fees_paid_msat to TypeScript pay_invoice response type
- Update TypeScript client payInvoice() to return fees_paid_msat
- Fix indentation in breez.rs
- fix issue #148
portal-wheatley

This comment was marked as duplicate.

Copy link
Contributor

@portal-wheatley portal-wheatley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review

The implementation looks correct overall. A few notes:

✅ What looks good

  • Trait signature change is clean: Result<(String, u64)> where u64 is fees in sats is a sensible contract
  • ws.rs correctly converts sats → msat (fees_paid_sats * 1000) for the wire format
  • TS client properly updated in both types.ts and client.ts
  • NWC: response.fees_paid.unwrap_or(0) / 1000 correctly normalizes NIP-47 millisats to sats

🟡 Minor points

breez.rs — non-Lightning payment methods always return 0 fees

fee_sats is initialized to 0 and only updated inside the PaymentMethod::Lightning { ... } branch. If a payment goes through a different method variant, fees will silently be reported as 0. Probably fine for now, but worth a comment noting the assumption:

let mut fee_sats = 0u64; // only set for Lightning; other payment methods report 0

nwc.rs — integer truncation on msat → sat conversion

fees_paid.unwrap_or(0) / 1000 truncates. E.g. a 999 msat fee becomes 0 sats. Acceptable given the scale of typical Lightning fees, but worth knowing.

lib.rs — doc comment not updated

The pay_invoice doc comment still says nothing about the return value. Minor, but since the signature is now a tuple it'd be helpful to add: /// Returns (preimage, fees_paid_sats) on success.

Empty PR description

Would be good to have a short description referencing issue #148.


None of the above are blockers — the core logic is sound. Good to merge after adding the PR description.

@denmeh
Copy link
Member

denmeh commented Feb 19, 2026

In the portal wallet trait definition, I would return to msat, because by default, we use msat in the protocol, not sat.

A future task I might assign myself could be to create a type like Amount in the protocol to avoid disambiguation.

@denmeh
Copy link
Member

denmeh commented Feb 19, 2026

LGTM

@denmeh denmeh merged commit a875572 into master Feb 19, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants