fix: return fees_paid_msat from NWC pay_invoice uniffi binding#154
Merged
fix: return fees_paid_msat from NWC pay_invoice uniffi binding#154
Conversation
The portal-app uniffi binding for NwcWallet.pay_invoice was returning
only the preimage string, discarding the fees_paid field from the NIP-47
response.
This meant that portal-app could not surface NWC payment fees to the
UI — the TypeScript NwcService.sendPayment always returned
{ preimage } with no feeSats, causing 'N/A' to be shown in the
activity detail screen.
The fix introduces a PayInvoiceResult record (uniffi does not support
tuple return types) containing both the preimage and fees_paid_msat.
fees_paid is optional in NIP-47, so we default to 0 when absent.
Note: the internal portal-wallet NwcWallet trait was already updated in
the pay-invoice-return-fees-paid PR — this change closes the gap at the
uniffi binding layer so portal-app can consume the fees.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The
portal-appuniffi binding forNWC.pay_invoicewas returning only the preimage string, silently discarding thefees_paidfield from the NIP-47 response:This meant
NwcService.sendPaymentin portal-app had no way to surface NWC payment fees — it always returned{ preimage }with nofeeSats, so the activity detail screen always showed "N/A" for fees on NWC payments.Root Cause
The internal
portal-walletNwcWallettrait was already updated in #149 to return(preimage, fees_paid_msat)— but that change lives in theportal-restwebsocket server path. Theportal-appuniffi binding (crates/portal-app/src/nwc.rs) is a separate code path used by the React Native client directly, and was not updated.Fix
Introduce a
PayInvoiceResultrecord (uniffi does not support tuple return types) containing bothpreimageandfees_paid_msat, and return it from the uniffi-exportedpay_invoice:fees_paidisOption<u64>in the NIP-47 response, so we default to0when absent.Portal-app side
After this lib version is published,
NwcService.sendPaymentin portal-app can be updated to: