swap: fund explicit Lightning routing budgets#1047
Conversation
The total fee cap expresses willingness; it does not fund LND routing. Add explicit routing allowances and quote components. This preserves the funding distinction across both sides.
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
a601609 to
af47a2c
Compare
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
|
@claude review |
|
Claude finished @bhandras's task in 3m 12s —— View job PR Review — swap: fund explicit Lightning routing budgetsI read the full diff against
What looks good
Findings1. (medium) Server-returned In This is exactly the defense the "Review follow-up" bullet claims to add for persisted fee/routing-budget values — the guard just doesn't cover the create-response components. Since these are individually persisted (not derived from the already-validated 2. (minor) The restored session sets Non-issues I checked
|
Accepted in-swap terms must survive daemon restarts. Store the service fee and client-funded allowance with each pay session. Do not infer accepted terms from current policy.
Old callers retain the point-estimate compatibility path. New option calls carry a funded allowance through quote and create. The established interfaces remain source compatible.
A total fee cap does not describe the routing allowance a wallet funds. Carry both values through quote, start, and prepared-send RPCs.
One daemon fee cap blurred willingness and funding. Forward explicit allowances through quote and start. Expose accepted fee components in durable summaries.
A prepared send must use the routing allowance the user reviewed. Keep that value in the intent and expose an explicit CLI flag.
Mixed credit pays may resume after the prepared send has disappeared. Store their funded routing allowance with the durable credit operation.
Mixed pays cross a durable credit actor before swap creation. Carry the allowance through it so restarts cannot drop accepted terms.
af47a2c to
63d3dc2
Compare
|
Addressed both findings and folded the fixes into the original commits:
Validated with the full @claude review |
|
Claude finished @bhandras's task in 1m 14s —— View job PR Review — follow-up fixes verified ✅Both findings from the prior review are correctly resolved and folded into their original commits.
Finding 1 (medium) — server-returned components range-checked before
|
Drive the resumed funding reconciliation synchronously. Avoid a five millisecond SQLite timing assumption under race tests.
|
The remaining unit-race failure was a pre-existing timing assumption in |
What it does
Adds an explicit, client-funded Lightning routing allowance to Ark-to-Lightning swap quotes and creation.
The existing
max_fee_satremains the client's maximum accepted total fee. The newrouting_fee_budget_satis the amount the client actually authorizes the swap server to include in the vHTLC for Lightning routing. Keeping these values separate prevents a total acceptance cap from being mistaken for funded money.Why
The swap server currently escrows only the point-in-time route estimate, while its payment path may permit a larger routing fee. A client may have declared a larger total fee cap, but that declaration does not fund the difference. Conversely, limiting payment to the point estimate can cause avoidable failures when the route changes after creation.
The intended server-side invariant is:
This PR establishes the public client and wire contract needed to fund the first term explicitly.
Changes
InSwapOptionswhile preserving the existing SDK method signatures for compatibility.PrepareSendthroughSend.wavecli send --routing-fee-budgetfor an explicit caller-selected allowance.Commit structure
Generated protobuf and sqlc changes are kept with their corresponding schema contracts. Each behavior change has focused tests.
Compatibility
All fields are additive. Existing method signatures remain available and send a zero routing budget, which asks the server to use its compatibility policy. A non-zero explicit budget fails clearly when used through a connection implementation that cannot carry it instead of silently dropping the caller's funded terms.
Verification
go test ./swaprpc/...go test ./sdk/swaps/...go test ./db/...go test ./credit/...go test -tags=swapruntime ./swapclientservergo test -tags='wavewalletrpc swapruntime' ./swapwalletgo test ./cmd/wavecli/waveclicommandsmake lint-changed-localmake tidy-module-checkmake buildmake commitmsg-lint range='origin/main..HEAD'Follow-up
Server-side enforcement will consume these additive fields, persist a frozen payment limit, ensure operator caps apply only to server-funded subsidy, and reconcile routing-fee recovery against actual Lightning costs.
Review follow-up