feat: expand TxBuilder and Wallet API surface#36
Merged
darioAnongba merged 6 commits intomainfrom Mar 3, 2026
Merged
Conversation
TxBuilder: - fee_absolute: set absolute fee amount - add_utxo/add_utxos: must-spend UTXOs - only_spend_from: restrict to manually added UTXOs - enable_rbf/enable_rbf_with_sequence: BIP 125 signaling - nlocktime: absolute locktime - version: transaction version - change_policy/do_not_spend_change: change output control - ChangeSpendPolicy enum Wallet: - build_fee_bump: RBF fee bumping via TxBuilder - create_single: single-descriptor wallet constructor - mark_used/unmark_used: address usage management - insert_txout: external TxOut for fee calculation Error types: - BuildFeeBumpError variants added to BdkErrorCode Ref #21
- Replace builder.only_spend_from() with builder.manually_selected_only() (method was renamed in bdk_wallet 2.x) - Remove enable_rbf/enable_rbf_with_sequence calls from finish() since RBF is enabled by default in BDK 2.x (nSequence = 0xFFFFFFFD) - Keep enable_rbf/enable_rbf_with_sequence wrapper methods as no-ops for API compatibility - Add From<AddUtxoError> impl for BdkError to support add_utxos error propagation - Remove unused enable_rbf and rbf_sequence fields from TxBuilder struct
AddUtxoError is at bdk_wallet::AddUtxoError, not bdk_wallet::error::AddUtxoError
- Test create_single for single-descriptor wallets - Test mark_used and unmark_used address management - Test fee_absolute, change_policy, do_not_spend_change - Test enable_rbf and enable_rbf_with_sequence chaining - Test nlocktime and version builder options - Test add_utxo, add_utxos, and only_spend_from - Test full fluent API chaining of all options - Test build_fee_bump with TransactionNotFound error - Test ChangeSpendPolicy enum variants
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.
Summary
First pass on expanding the WASM API surface (ref #21). Focuses on the most commonly needed TxBuilder options and Wallet methods.
TxBuilder — New Methods
fee_absolute(amount)add_utxo(outpoint)add_utxos(outpoints)only_spend_from()enable_rbf()enable_rbf_with_sequence(n)nlocktime(height)version(v)change_policy(policy)do_not_spend_change()ChangeForbiddenNew enum:
ChangeSpendPolicy(ChangeAllowed,OnlyChange,ChangeForbidden)Wallet — New Methods
create_single(network, descriptor)build_fee_bump(txid)mark_used(keychain, index)unmark_used(keychain, index)insert_txout(outpoint, txout)Error Types
Added
BuildFeeBumpErrorvariants toBdkErrorCode:TransactionNotFound,TransactionConfirmed,IrreplaceableTransaction,FeeRateUnavailable,InvalidOutputIndex.Design Notes
build_fee_bumpreturns aTxBuilderwith an internal flag. The actual BDKbuild_fee_bumpcall happens insidefinish()to avoid lifetime issues withwasm_bindgen.fee_rateandfee_absoluteare mutually exclusive (last one wins), matching BDK behavior.Not Yet Wrapped (future PRs)
add_foreign_utxo(experimental, complex types)policy_path(needs Map type bridging)coin_selection(needs trait bridging)sighash(needs EcdsaSighashType/TapSighashType bridging)Wallet::policies/ spending policy introspectionRef #21