Skip to content

feat(tx_builder): expand TxBuilder with hardware wallet PSBT options, OP_RETURN data, and sequence control#45

Draft
darioAnongba wants to merge 1 commit intomainfrom
feat/txbuilder-options
Draft

feat(tx_builder): expand TxBuilder with hardware wallet PSBT options, OP_RETURN data, and sequence control#45
darioAnongba wants to merge 1 commit intomainfrom
feat/txbuilder-options

Conversation

@darioAnongba
Copy link
Copy Markdown
Collaborator

Summary

Expand the TxBuilder API surface with options important for hardware wallet workflows and advanced transaction construction. This continues the work on #21 (expand API surface coverage), focusing on the TxBuilder area.

Changes

New TxBuilder options

Method Purpose
add_data(data) Embed OP_RETURN data (up to 80 bytes) for timestamping, protocol anchoring, metadata
only_witness_utxo() Reduce PSBT size for segwit-only wallets (hardware wallet preference)
include_output_redeem_witness_script() ColdCard/BitBox hardware wallet compatibility
add_global_xpubs() Fill PSBT_GLOBAL_XPUB for multisig hardware wallet workflows
current_height(height) Coinbase maturity checks and anti-fee-sniping locktime
set_exact_sequence(n_sequence) Fine-grained nSequence control for RBF/CSV
only_spend_change() Shorthand for ChangeSpendPolicy::OnlyChange

New type accessors

Type Accessor Purpose
TxIn sequence (getter) Read nSequence value of transaction inputs

Fee bump support

The PSBT-related options (only_witness_utxo, include_output_redeem_witness_script, add_global_xpubs) are also forwarded to the fee-bump builder path.

Tests

  • Unit tests (wallet.test.ts): All new options tested for correct chaining, add_data validation (rejects >80 bytes, accepts empty/valid data), combined options chain test
  • Integration tests (esplora.test.ts): Real funded wallet tests in regtest covering add_data OP_RETURN verification, only_witness_utxo signing, include_output_redeem_witness_script, add_global_xpubs, current_height, set_exact_sequence verification, and a combined multi-option test

CHANGELOG

Entry added under [Unreleased].

Partially closes #21

@darioAnongba darioAnongba force-pushed the feat/txbuilder-options branch from bfe03c0 to 7a96f81 Compare March 31, 2026 10:19
…nd sequence control

Expand the TxBuilder API with options important for hardware wallet
workflows and advanced transaction construction:

- add_data: embed OP_RETURN data (up to 80 bytes) for timestamping,
  protocol anchoring, and metadata
- only_witness_utxo: reduce PSBT size for segwit-only wallets
- include_output_redeem_witness_script: ColdCard/BitBox compatibility
- add_global_xpubs: multisig hardware wallet support (PSBT_GLOBAL_XPUB)
- current_height: coinbase maturity checks and anti-fee-sniping
- set_exact_sequence: fine-grained nSequence control for RBF/CSV
- only_spend_change: shorthand for OnlyChange spend policy

Also adds TxIn::sequence getter for reading input nSequence values,
enabling callers to verify sequence values on built transactions.

All new options are applied in both regular and fee-bump builder paths
where applicable. The PSBT-related options (only_witness_utxo,
include_output_redeem_witness_script, add_global_xpubs) are forwarded
to the fee-bump builder as well.

Includes unit tests (wallet.test.ts) for all new options including
chaining verification and add_data validation, plus integration tests
(esplora.test.ts) that exercise the options with real funded wallets
in regtest.

Closes #21 (partial — TxBuilder area)
@darioAnongba darioAnongba force-pushed the feat/txbuilder-options branch from 7a96f81 to 9908d0b Compare March 31, 2026 10:24
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.

feat: expand API surface coverage

1 participant