Skip to content

fix(wallets): subtract the estimated onchain fee from sendAll sweeps (#270) - #521

Closed
nul-quill wants to merge 1 commit into
lnflash:mainfrom
nul-quill:sendall-onchain-fee-270
Closed

nul-quill wants to merge 1 commit into
lnflash:mainfrom
nul-quill:sendall-onchain-fee-270

Conversation

@nul-quill

Copy link
Copy Markdown

onChainPaymentSendAll handed IBEX the entire wallet balance while the rail charges its on-chain fee on top of the forwarded amount, so full-balance sweeps failed or left dust. Adds getSendAllOnChainAmount (estimate via Ibex.estimateOnchainFee, return balance - fee) and wires it into the sendAll mutation. Every estimate failure mode (IbexError, missing/zero/non-numeric fee, fee >= balance) falls back to sweeping the full balance. Verified: tsc clean apart from two pre-existing Express/Application errors; jest 47 suites / 519 tests pass. Handle: nul-quill. Payout wallets: Solana USDC BdznDjc4xwt5Y6WJT5UnrFQzDptka8YnC9oqmmkKpwkd, TRC20 TNEHCVwR2aPMrj5AKfWCQ2rFL3bEDQmsg7.

…nflash#270)

`onChainPaymentSendAll` handed IBEX the entire wallet balance, but the rail
charges its on-chain fee on top of the amount it forwards, so a full-balance
sweep either failed at the rail or left dust behind.

Add `getSendAllOnChainAmount`, which asks IBEX for the fee on this payout and
returns `balance - fee`, and wire it into the sendAll mutation. Every failure
mode of the estimate (IbexError, missing/zero/non-numeric fee, a fee that eats
the whole balance) falls back to the previous behaviour of sweeping the full
balance, so a degraded estimate never blocks a payment.
@nul-quill

Copy link
Copy Markdown
Author

Submitted in this PR. New helper Wallets.getSendAllOnChainAmount asks IBEX for the on-chain fee for the payout address and sends balance - fee instead of the whole balance, so the sweep lands instead of being rejected for a fee charged on top. If the estimate is unavailable, empty, or covers the whole balance, it falls back to the previous full-balance behaviour. Covered by new unit tests (fee subtraction, fractional cents, all fallback branches) plus a resolver wiring test. jest: 47 suites / 519 tests pass. Handle: nul-quill. Payout wallets: Solana USDC BdznDjc4xwt5Y6WJT5UnrFQzDptka8YnC9oqmmkKpwkd, TRC20 TNEHCVwR2aPMrj5AKfWCQ2rFL3bEDQmsg7.

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.

2 participants