Skip to content

Add initial destination-aware max_sendable #22

Open
amackillop wants to merge 2 commits into
austin_mdk-863_vo-max-withrawablefrom
austin_mdk-865_v1-max-withdrawable
Open

Add initial destination-aware max_sendable #22
amackillop wants to merge 2 commits into
austin_mdk-863_vo-max-withrawablefrom
austin_mdk-865_v1-max-withdrawable

Conversation

@amackillop
Copy link
Copy Markdown
Contributor

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.

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.
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.

1 participant