Add initial destination-aware max_sendable #22
Open
amackillop wants to merge 2 commits into
Open
Conversation
Reshape MdkClient::max_sendable to accept Option<&PaymentInstructions> so the follow-up can wire destination-aware per-hop fee inversion (MDK-865) without churning the signature again. The None branch keeps the v0 buffer behaviour; Some(_) trips a debug_assert until the real implementation lands with the ldk-node bump that exposes Node::find_route. The daemon /getbalance handler now passes None. The JSON field max_withdrawable_sat is unchanged.
Bump ldk-node to the rev that lets find_route take a fully-built
RouteParameters and use it from the Some(_) branch of
MdkClient::max_sendable. The reported fee budget is built from
route.get_total_fees(), which is what LDK itself would charge for
a send of that size. Slightly conservative: total_fees is computed
from the full balance so with the sent amount they will be less.
This provides a buffer and could be tweaked by iterating the estimate.
On top of total_fees the budget applies a multiplier. The chosen route
can fail at send time and LDK retries along a more expensive path. A
multiplier scales with the original route's cost so retries can
actually reach those alternatives. Exposed as
route_retry_fee_multiplier_bps so operators can trade reported max
sendable for payment success rate. Starting low to minimise headroom
left on the table; bump up if production retries surface
"insufficient fee budget" failures too often.
FixedAmount returns Err(FixedAmount { amount_msat }) because there's
nothing to estimate when the payee dictates the amount; the variant
carries the amount so callers don't re-extract it.
BOLT12 offers, LNURL-pay, and HRN destinations fall back to the
simple buffer for now. BOLT12 needs the invoice (not the offer) for
from_bolt12_invoice, which depends on the invoice fetch deferred
upstream. LNURL-pay and HRN need to resolve into a concrete invoice
first; that resolution will move into this module shortly.
BOLT11 round-trips through its bech32 string: bitcoin-payment-
instructions pins upstream rust-lightning's Bolt11Invoice while
ldk-node pulls the moneydevkit fork. Wire-compatible, distinct types.
A re-parse failure falls back to Buffer rather than panicking.
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.
Bump ldk-node to the rev that lets find_route take a fully-built
RouteParameters and use it from the Some(_) branch of
MdkClient::max_sendable. The reported fee budget is built from
route.get_total_fees(), which is what LDK itself would charge for
a send of that size. Slightly conservative:
total_feesis computedfrom the full balance so with the sent amount they will be less.
This provides a buffer and could be tweaked by iterating the estimate.
On top of
total_feesthe budget applies a multiplier. The chosen routecan fail at send time and LDK retries along a more expensive path. A
multiplier scales with the original route's cost so retries can
actually reach those alternatives. Exposed as
route_retry_fee_multiplier_bpsso operators can trade reported maxsendable for payment success rate. Starting low to minimise headroom
left on the table; bump up if production retries surface
"insufficient fee budget" failures too often.
FixedAmount returns Err(FixedAmount { amount_msat }) because there's
nothing to estimate when the payee dictates the amount; the variant
carries the amount so callers don't re-extract it.
BOLT12 offers, LNURL-pay, and HRN destinations fall back to the
simple buffer for now. BOLT12 needs the invoice (not the offer) for
from_bolt12_invoice, which depends on the invoice fetch deferred
upstream. LNURL-pay and HRN need to resolve into a concrete invoice
first; that resolution will move into this module shortly.
BOLT11 round-trips through its bech32 string: bitcoin-payment-
instructions pins upstream rust-lightning's Bolt11Invoice while
ldk-node pulls the moneydevkit fork. Wire-compatible, distinct types.
A re-parse failure falls back to Buffer rather than panicking.