Skip to content

feat(bitcoin): add getMaxSendableAmount client request method - #587

Open
ulissesferreira wants to merge 1 commit into
mainfrom
WPN-2442-bitcoin-get-max-sendable-amount
Open

ulissesferreira wants to merge 1 commit into
mainfrom
WPN-2442-bitcoin-get-max-sendable-amount

Conversation

@ulissesferreira

@ulissesferreira ulissesferreira commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Explanation

Adds the getMaxSendableAmount client request method to the Bitcoin Snap. It returns only { amount }: the maximum amount that can be entered so onAmountInput passes, or 0 when no amount can pass. Fees, balances, and validation errors are intentionally not returned.

The value is found with a binary search over the spendable balance. Each candidate is priced through buildProbePsbt, which uses the same targetBlocksConfirmation and fallbackFeeRate config as onAmountInput, so the result accounts for the real fee at that amount instead of assuming a fixed fee. When no amount is fundable, the result is below the account's dust limit, or every probe reports dust/insufficient funds, it returns 0. An invalid toAddress is a bad request and throws a validation error. The probe is never signed or broadcast.

References

Ticket: WPN-2442

Checklist

  • I have updated the test suite for new or updated code as appropriate
  • I have communicated my changes to consumers by updating changelogs for packages I have changed
  • I have updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I have introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

@ulissesferreira
ulissesferreira force-pushed the WPN-2442-bitcoin-get-max-sendable-amount branch 2 times, most recently from 394ab8a to ace0c75 Compare November 10, 2026 13:16
@ulissesferreira
ulissesferreira force-pushed the WPN-2442-bitcoin-get-max-sendable-amount branch from ace0c75 to da3b581 Compare November 10, 2026 13:29
@ulissesferreira
ulissesferreira marked this pull request as ready for review November 10, 2026 13:36
@ulissesferreira
ulissesferreira requested review from a team as code owners November 10, 2026 13:36
@ulissesferreira ulissesferreira changed the title feat(bitcoin): add getMaxSendableAmount client request method feat(bitcoin): add getMaxSendableAmount client request method Nov 10, 2026
@ulissesferreira
ulissesferreira force-pushed the WPN-2442-bitcoin-get-max-sendable-amount branch from da3b581 to e27e402 Compare November 11, 2026 10:18
Base automatically changed from WPN-2437-bitcoin-onamountinput-fee-aware to main November 12, 2026 12:22
@ulissesferreira
ulissesferreira force-pushed the WPN-2442-bitcoin-get-max-sendable-amount branch from e27e402 to d4265e3 Compare November 12, 2026 15:01
@ulissesferreira
ulissesferreira marked this pull request as draft November 12, 2026 16:07
@ulissesferreira
ulissesferreira force-pushed the WPN-2442-bitcoin-get-max-sendable-amount branch from f81e9a6 to 48b7cd6 Compare November 17, 2026 16:25
@sonarqubecloud

Copy link
Copy Markdown

This branch was successfully deployed

1 active (outdated) deployment
default-branch — d4265e38 Deployed Nov 17, 2026 by ulissesferreira via Determine whether this PR is a release PR #2453
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