NIP-47 max fee on pay_invoice - #2444
Open
frnandu wants to merge 3 commits into
Open
Conversation
Adds an optional `max_fee` parameter (in msats) to the `pay_invoice` command. Wallet services honoring the parameter must not send a payment whose total routing fee exceeds the budget and must return `FEE_LIMIT_EXCEEDED` instead. Also adds the corresponding error code to the global error list and clarifies client-side reconciliation expectations via `fees_paid`.
This was referenced Aug 21, 2026
Contributor
Author
|
Would you consider implementing this on coinos wallet @asoltys ? |
Contributor
Author
|
@MegalithicBTC and on rizful ? |
|
Yes, this looks reasonable to me. |
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.
NIP-47: add optional
max_feetopay_invoiceSummary
Adds an optional
max_feeparameter (in msats) to thepay_invoicecommand and a correspondingFEE_LIMIT_EXCEEDEDerror code, letting clients cap the routing fees a wallet service may pay on top of an invoice amount.Motivation
Today, NIP-47 provides no way for a client to bound routing fees. A
pay_invoicerequest grants the wallet service implicit authority to pay arbitrary Lightning routing fees on top of the invoice amount. This creates real-world risks for payment coordinators, market makers, and automated services:fees_paidin the response is optional and there's no way to signal a budget.Lightning node implementations (LND, CLN, Eclair) all expose fee-limit controls in their native RPCs. NIP-47 currently provides no equivalent for wallets serving remote clients.
Changes
pay_invoiceparams: new optionalmax_fee(integer, msats). Wallet services honoring it MUST NOT send a payment whose total routing cost exceedsamount + max_fee, and MUST returnFEE_LIMIT_EXCEEDEDinstead.FEE_LIMIT_EXCEEDEDadded to the global error list; defined as "no payment attempted" so the semantics are atomic with no ambiguous partial state.fees_paidfield in the response as a signal that themax_feebudget may not have been enforced — supporting wallets MUST includefees_paidso clients can audit.Compatibility
Fully backward compatible:
max_feesee no behavior change.Design notes
amountandfees_paidelsewhere in the spec.max_feecovers routing fees only: invoice amount is separately explicit; budget is the delta between debited amount and invoice amount.FEE_LIMIT_EXCEEDEDmeans "no debit occurred": removes any ambiguity about partial attempts or stuck HTLCs.