Implement create_psbt for Wallet#297
Conversation
673d602 to
77e1d20
Compare
Pull Request Test Coverage Report for Build 19016316365Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
|
I like the What do you envision the API for replace-by-fee transactions look like in this new bdk-tx world? I'm picturing something like |
2c54be1 to
6f525d1
Compare
6f525d1 to
4493cbd
Compare
create_psbt for Walletcreate_psbt for Wallet
thunderbiscuit
left a comment
There was a problem hiding this comment.
So this is more of a conceptual review/question set, as I'm getting acquainted with the PR, and it also requires knowledge and understanding of the bdk-tx crate/workflow.
One general question I have is do you think is missing in functionality between this and the current TxBuilder? Can we make a todo list that compares functionality with the current TxBuilder to better visualize how close of a replacement this is, or if it only provides part of the functionality for now (and if so which parts)?
I haven't had time to look/test the examples and my day is over, but I'll come back to this on Monday.
oleonardolima
left a comment
There was a problem hiding this comment.
I did an initial review, with simple comments/questions. Still need to take a deeper look into bdk-tx and do a more thorough review here.
| /// No Bnb solution. | ||
| Bnb(bdk_coin_select::NoBnbSolution), | ||
| /// Non-sufficient funds | ||
| InsufficientFunds(bdk_coin_select::InsufficientFunds), |
There was a problem hiding this comment.
Can't we have a generic CS error instead ?
There was a problem hiding this comment.
Can you elaborate on what you mean by generic CS error?
|
Thank you for the quick review @thunderbiscuit @oleonardolima. |
TxBuilder vs PsbtParams feature comparisonsubject to change
N/A: |
4493cbd to
a7afecb
Compare
|
3d7bd2e to
5285937
Compare
I think a straightforward approach is to set a target feerate of I can see it being relevant to CPFP, since there we're less concerned about the feerate of an individual tx and more so with the fee needed to bump a package to a target feerate. |
Bridge between bdk_wallet and bdk_tx, exposed as a `WalletTxExt` extension trait on `bdk_wallet::Wallet`. Keeping it in its own crate means neither base crate depends on the other: `bdk_wallet` stays stable, `bdk_tx` stays free to move, and the bridge absorbs the coupling (the decoupling argument from bitcoindevkit/bdk_wallet#297). Three-stage pipeline: - `candidates`/`candidates_with`/`rbf_candidates` -> `CandidateSet` (stage 1). - `select`/`select_with_rng` -> `(TxTemplate, Option<AddressInfo>)` (stage 2): a pure read that peeks the auto-derived change address; commit it with `commit_change` (reveal + mark used) when you use the tx, or ignore it on abandon. Emit the PSBT directly via `bdk_tx::TxTemplate::build_psbt`. - `add_global_xpubs` fills the PSBT's global xpubs (the only emission step that needs the wallet). Ported from the bdk_wallet#502 PoC, re-expressed over the integrated bdk_tx API and the wallet's public accessors. MTP is faked from the confirmation block time; UTXO locking is honored; `longterm_feerate` lives on `SelectParams` and feeds the waste-aware change policy for every strategy. End-to-end tests cover the pipeline, RBF-free candidate filtering, change commit, and error paths. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Bridge between bdk_wallet and bdk_tx, exposed as a `WalletTxExt` extension trait on `bdk_wallet::Wallet`. Keeping it in its own crate means neither base crate depends on the other: `bdk_wallet` stays stable, `bdk_tx` stays free to move, and the bridge absorbs the coupling (the decoupling argument from bitcoindevkit/bdk_wallet#297). Three-stage pipeline: - `candidates`/`candidates_with`/`rbf_candidates` -> `CandidateSet` (stage 1). - `select`/`select_with_rng` -> `(TxTemplate, Option<AddressInfo>)` (stage 2): a pure read that peeks the auto-derived change address; commit it with `commit_change` (reveal + mark used) when you use the tx, or ignore it on abandon. Emit the PSBT directly via `bdk_tx::TxTemplate::build_psbt`. - `add_global_xpubs` fills the PSBT's global xpubs (the only emission step that needs the wallet). Ported from the bdk_wallet#502 PoC, re-expressed over the integrated bdk_tx API and the wallet's public accessors. MTP is faked from the confirmation block time; UTXO locking is honored; `longterm_feerate` lives on `SelectParams` and feeds the waste-aware change policy for every strategy. End-to-end tests cover the pipeline, RBF-free candidate filtering, change commit, and error paths. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Bridge between bdk_wallet and bdk_tx, exposed as a `WalletTxExt` extension trait on `bdk_wallet::Wallet`. Keeping it in its own crate means neither base crate depends on the other: `bdk_wallet` stays stable, `bdk_tx` stays free to move, and the bridge absorbs the coupling (the decoupling argument from bitcoindevkit/bdk_wallet#297). Three-stage pipeline: - `candidates`/`candidates_with`/`rbf_candidates` -> `CandidateSet` (stage 1). - `select` -> `(TxTemplate, Option<AddressInfo>)` (stage 2): a pure read over a borrowed `&CandidateSet` (re-runnable) that peeks the auto-derived change address; commit it with `commit_change` (reveal + mark used) when you use the tx, or ignore it on abandon. The caller supplies the RNG. Emit the PSBT directly via `bdk_tx::TxTemplate::build_psbt`. - `add_global_xpubs` fills the PSBT's global xpubs (the only emission step that needs the wallet). Ported from the bdk_wallet#502 PoC, re-expressed over the integrated bdk_tx API and the wallet's public accessors. MTP is faked from the confirmation block time; UTXO locking is honored; `longterm_feerate` lives on `SelectParams` and feeds the waste-aware change policy for every strategy. End-to-end tests cover the pipeline, candidate filtering, change commit, and error paths. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Bridge between bdk_wallet and bdk_tx, exposed as a `WalletTxExt` extension trait on `bdk_wallet::Wallet`. Keeping it in its own crate means neither base crate depends on the other: `bdk_wallet` stays stable, `bdk_tx` stays free to move, and the bridge absorbs the coupling (the decoupling argument from bitcoindevkit/bdk_wallet#297). Three-stage pipeline: - `candidates`/`candidates_with`/`rbf_candidates` -> `CandidateSet` (stage 1). - `select` -> `(TxTemplate, Option<AddressInfo>)` (stage 2): a pure read over a borrowed `&CandidateSet` (re-runnable) that peeks the auto-derived change address; commit it with `commit_change` (reveal + mark used) when you use the tx, or ignore it on abandon. The caller supplies the RNG. Emit the PSBT directly via `bdk_tx::TxTemplate::build_psbt`. - `add_global_xpubs` fills the PSBT's global xpubs (the only emission step that needs the wallet). Ported from the bdk_wallet#502 PoC, re-expressed over the integrated bdk_tx API and the wallet's public accessors. MTP is faked from the confirmation block time; UTXO locking is honored; `longterm_feerate` lives on `SelectParams` and feeds the waste-aware change policy for every strategy. End-to-end tests cover the pipeline, candidate filtering, change commit, and error paths. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Bridge between bdk_wallet and bdk_tx, exposed as a `WalletTxExt` extension trait on `bdk_wallet::Wallet`. Keeping it in its own crate means neither base crate depends on the other: `bdk_wallet` stays stable, `bdk_tx` stays free to move, and the bridge absorbs the coupling (the decoupling argument from bitcoindevkit/bdk_wallet#297). Three-stage pipeline: - `candidates`/`candidates_with`/`rbf_candidates` -> `CandidateSet` (stage 1). - `select` -> `(TxTemplate, Option<AddressInfo>)` (stage 2): a pure read over a borrowed `&CandidateSet` (re-runnable) that peeks the auto-derived change address; commit it with `commit_change` (reveal + mark used) when you use the tx, or ignore it on abandon. The caller supplies the RNG. Emit the PSBT directly via `bdk_tx::TxTemplate::build_psbt`. - `add_global_xpubs` fills the PSBT's global xpubs (the only emission step that needs the wallet). Ported from the bdk_wallet#502 PoC, re-expressed over the integrated bdk_tx API and the wallet's public accessors. MTP is faked from the confirmation block time; UTXO locking is honored; `longterm_feerate` lives on `SelectParams` and feeds the waste-aware change policy for every strategy. End-to-end tests cover the pipeline, candidate filtering, change commit, and error paths. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Bridge between bdk_wallet and bdk_tx, exposed as a `WalletTxExt` extension trait on `bdk_wallet::Wallet`. Keeping it in its own crate means neither base crate depends on the other: `bdk_wallet` stays stable, `bdk_tx` stays free to move, and the bridge absorbs the coupling (the decoupling argument from bitcoindevkit/bdk_wallet#297). Three-stage pipeline: - `candidates`/`candidates_with`/`rbf_candidates` -> `CandidateSet` (stage 1). - `select` -> `(TxTemplate, Option<AddressInfo>)` (stage 2): a pure read over a borrowed `&CandidateSet` (re-runnable) that peeks the auto-derived change address; commit it with `commit_change` (reveal + mark used) when you use the tx, or ignore it on abandon. The caller supplies the RNG. Emit the PSBT directly via `bdk_tx::TxTemplate::build_psbt`. - `add_global_xpubs` fills the PSBT's global xpubs (the only emission step that needs the wallet). Ported from the bdk_wallet#502 PoC, re-expressed over the integrated bdk_tx API and the wallet's public accessors. MTP is faked from the confirmation block time; UTXO locking is honored; `longterm_feerate` lives on `SelectParams` and feeds the waste-aware change policy for every strategy. End-to-end tests cover the pipeline, candidate filtering, change commit, and error paths. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Bridge between bdk_wallet and bdk_tx, exposed as a `WalletTxExt` extension trait on `bdk_wallet::Wallet`. Keeping it in its own crate means neither base crate depends on the other: `bdk_wallet` stays stable, `bdk_tx` stays free to move, and the bridge absorbs the coupling (the decoupling argument from bitcoindevkit/bdk_wallet#297). Three-stage pipeline: - `candidates`/`candidates_with`/`rbf_candidates` -> `CandidateSet` (stage 1). - `select` -> `(TxTemplate, Option<AddressInfo>)` (stage 2): a pure read over a borrowed `&CandidateSet` (re-runnable) that peeks the auto-derived change address; commit it with `commit_change` (reveal + mark used) when you use the tx, or ignore it on abandon. The caller supplies the RNG. Emit the PSBT directly via `bdk_tx::TxTemplate::build_psbt`. - `add_global_xpubs` fills the PSBT's global xpubs (the only emission step that needs the wallet). Ported from the bdk_wallet#502 PoC, re-expressed over the integrated bdk_tx API and the wallet's public accessors. MTP is faked from the confirmation block time; UTXO locking is honored; `longterm_feerate` lives on `SelectParams` and feeds the waste-aware change policy for every strategy. End-to-end tests cover the pipeline, candidate filtering, change commit, and error paths. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Bridge between bdk_wallet and bdk_tx, exposed as a `WalletTxExt` extension trait on `bdk_wallet::Wallet`. Keeping it in its own crate means neither base crate depends on the other: `bdk_wallet` stays stable, `bdk_tx` stays free to move, and the bridge absorbs the coupling (the decoupling argument from bitcoindevkit/bdk_wallet#297). Three-stage pipeline: - `candidates`/`candidates_with`/`rbf_candidates` -> `CandidateSet` (stage 1). - `select` -> `(TxTemplate, Option<AddressInfo>)` (stage 2): a pure read over a borrowed `&CandidateSet` (re-runnable) that peeks the auto-derived change address; commit it with `commit_change` (reveal + mark used) when you use the tx, or ignore it on abandon. The caller supplies the RNG. Emit the PSBT directly via `bdk_tx::TxTemplate::build_psbt`. - `add_global_xpubs` fills the PSBT's global xpubs (the only emission step that needs the wallet). Ported from the bdk_wallet#502 PoC, re-expressed over the integrated bdk_tx API and the wallet's public accessors. MTP is faked from the confirmation block time; UTXO locking is honored; `longterm_feerate` lives on `SelectParams` and feeds the waste-aware change policy for every strategy. End-to-end tests cover the pipeline, candidate filtering, change commit, and error paths. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Bridge between bdk_wallet and bdk_tx, exposed as a `WalletTxExt` extension trait on `bdk_wallet::Wallet`. Keeping it in its own crate means neither base crate depends on the other: `bdk_wallet` stays stable, `bdk_tx` stays free to move, and the bridge absorbs the coupling (the decoupling argument from bitcoindevkit/bdk_wallet#297). Three-stage pipeline: - `candidates`/`candidates_with`/`rbf_candidates` -> `CandidateSet` (stage 1). - `select` -> `(TxTemplate, Option<AddressInfo>)` (stage 2): a pure read over a borrowed `&CandidateSet` (re-runnable) that peeks the auto-derived change address; commit it with `commit_change` (reveal + mark used) when you use the tx, or ignore it on abandon. The caller supplies the RNG. Emit the PSBT directly via `bdk_tx::TxTemplate::build_psbt`. - `add_global_xpubs` fills the PSBT's global xpubs (the only emission step that needs the wallet). Ported from the bdk_wallet#502 PoC, re-expressed over the integrated bdk_tx API and the wallet's public accessors. MTP is faked from the confirmation block time; UTXO locking is honored; `longterm_feerate` lives on `SelectParams` and feeds the waste-aware change policy for every strategy. End-to-end tests cover the pipeline, candidate filtering, change commit, and error paths. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Bridge between bdk_wallet and bdk_tx, exposed as a `WalletTxExt` extension trait on `bdk_wallet::Wallet`. Keeping it in its own crate means neither base crate depends on the other: `bdk_wallet` stays stable, `bdk_tx` stays free to move, and the bridge absorbs the coupling (the decoupling argument from bitcoindevkit/bdk_wallet#297). Three-stage pipeline: - `candidates`/`candidates_with`/`rbf_candidates` -> `CandidateSet` (stage 1). - `select` -> `(TxTemplate, Option<AddressInfo>)` (stage 2): a pure read over a borrowed `&CandidateSet` (re-runnable) that peeks the auto-derived change address; commit it with `commit_change` (reveal + mark used) when you use the tx, or ignore it on abandon. The caller supplies the RNG. Emit the PSBT directly via `bdk_tx::TxTemplate::build_psbt`. - `add_global_xpubs` fills the PSBT's global xpubs (the only emission step that needs the wallet). Ported from the bdk_wallet#502 PoC, re-expressed over the integrated bdk_tx API and the wallet's public accessors. MTP is faked from the confirmation block time; UTXO locking is honored; `longterm_feerate` lives on `SelectParams` and feeds the waste-aware change policy for every strategy. End-to-end tests cover the pipeline, candidate filtering, change commit, and error paths. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Bridge between bdk_wallet and bdk_tx, exposed as a `WalletTxExt` extension trait on `bdk_wallet::Wallet`. Keeping it in its own crate means neither base crate depends on the other: `bdk_wallet` stays stable, `bdk_tx` stays free to move, and the bridge absorbs the coupling (the decoupling argument from bitcoindevkit/bdk_wallet#297). Three-stage pipeline: - `candidates`/`candidates_with`/`rbf_candidates` -> `CandidateSet` (stage 1). - `select` -> `(TxTemplate, Option<AddressInfo>)` (stage 2): a pure read over a borrowed `&CandidateSet` (re-runnable) that peeks the auto-derived change address; commit it with `commit_change` (reveal + mark used) when you use the tx, or ignore it on abandon. The caller supplies the RNG. Emit the PSBT directly via `bdk_tx::TxTemplate::build_psbt`. - `add_global_xpubs` fills the PSBT's global xpubs (the only emission step that needs the wallet). Ported from the bdk_wallet#502 PoC, re-expressed over the integrated bdk_tx API and the wallet's public accessors. MTP is faked from the confirmation block time; UTXO locking is honored; `longterm_feerate` lives on `SelectParams` and feeds the waste-aware change policy for every strategy. End-to-end tests cover the pipeline, candidate filtering, change commit, and error paths. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Bridge between bdk_wallet and bdk_tx, exposed as a `WalletTxExt` extension trait on `bdk_wallet::Wallet`. Keeping it in its own crate means neither base crate depends on the other: `bdk_wallet` stays stable, `bdk_tx` stays free to move, and the bridge absorbs the coupling (the decoupling argument from bitcoindevkit/bdk_wallet#297). Three-stage pipeline: - `candidates`/`candidates_with`/`rbf_candidates` -> `CandidateSet` (stage 1). - `select` -> `(TxTemplate, Option<AddressInfo>)` (stage 2): a pure read over a borrowed `&CandidateSet` (re-runnable) that peeks the auto-derived change address; commit it with `commit_change` (reveal + mark used) when you use the tx, or ignore it on abandon. The caller supplies the RNG. Emit the PSBT directly via `bdk_tx::TxTemplate::build_psbt`. - `add_global_xpubs` fills the PSBT's global xpubs (the only emission step that needs the wallet). Ported from the bdk_wallet#502 PoC, re-expressed over the integrated bdk_tx API and the wallet's public accessors. MTP is faked from the confirmation block time; UTXO locking is honored; `longterm_feerate` lives on `SelectParams` and feeds the waste-aware change policy for every strategy. End-to-end tests cover the pipeline, candidate filtering, change commit, and error paths. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Bridge between bdk_wallet and bdk_tx, exposed as a `WalletTxExt` extension trait on `bdk_wallet::Wallet`. Keeping it in its own crate means neither base crate depends on the other: `bdk_wallet` stays stable, `bdk_tx` stays free to move, and the bridge absorbs the coupling (the decoupling argument from bitcoindevkit/bdk_wallet#297). Three-stage pipeline: - `candidates`/`candidates_with`/`rbf_candidates` -> `CandidateSet` (stage 1). - `select` -> `(TxTemplate, Option<AddressInfo>)` (stage 2): a pure read over a borrowed `&CandidateSet` (re-runnable) that peeks the auto-derived change address; commit it with `commit_change` (reveal + mark used) when you use the tx, or ignore it on abandon. The caller supplies the RNG. Emit the PSBT directly via `bdk_tx::TxTemplate::build_psbt`. - `add_global_xpubs` fills the PSBT's global xpubs (the only emission step that needs the wallet). Ported from the bdk_wallet#502 PoC, re-expressed over the integrated bdk_tx API and the wallet's public accessors. MTP is faked from the confirmation block time; UTXO locking is honored; `longterm_feerate` lives on `SelectParams` and feeds the waste-aware change policy for every strategy. End-to-end tests cover the pipeline, candidate filtering, change commit, and error paths. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Bridge between bdk_wallet and bdk_tx, exposed as a `WalletTxExt` extension trait on `bdk_wallet::Wallet`. Keeping it in its own crate means neither base crate depends on the other: `bdk_wallet` stays stable, `bdk_tx` stays free to move, and the bridge absorbs the coupling (the decoupling argument from bitcoindevkit/bdk_wallet#297). Three-stage pipeline: - `candidates`/`candidates_with`/`rbf_candidates` -> `CandidateSet` (stage 1). - `select` -> `(TxTemplate, Option<AddressInfo>)` (stage 2): a pure read over a borrowed `&CandidateSet` (re-runnable) that peeks the auto-derived change address; commit it with `commit_change` (reveal + mark used) when you use the tx, or ignore it on abandon. The caller supplies the RNG. Emit the PSBT directly via `bdk_tx::TxTemplate::build_psbt`. - `add_global_xpubs` fills the PSBT's global xpubs (the only emission step that needs the wallet). Ported from the bdk_wallet#502 PoC, re-expressed over the integrated bdk_tx API and the wallet's public accessors. MTP is faked from the confirmation block time; UTXO locking is honored; `longterm_feerate` lives on `SelectParams` and feeds the waste-aware change policy for every strategy. End-to-end tests cover the pipeline, candidate filtering, change commit, and error paths. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Bridge between bdk_wallet and bdk_tx, exposed as a `WalletTxExt` extension trait on `bdk_wallet::Wallet`. Keeping it in its own crate means neither base crate depends on the other: `bdk_wallet` stays stable, `bdk_tx` stays free to move, and the bridge absorbs the coupling (the decoupling argument from bitcoindevkit/bdk_wallet#297). Three-stage pipeline: - `candidates`/`candidates_with`/`rbf_candidates` -> `CandidateSet` (stage 1). - `select` -> `(TxTemplate, Option<AddressInfo>)` (stage 2): a pure read over a borrowed `&CandidateSet` (re-runnable) that peeks the auto-derived change address; commit it with `commit_change` (reveal + mark used) when you use the tx, or ignore it on abandon. The caller supplies the RNG. Emit the PSBT directly via `bdk_tx::TxTemplate::build_psbt`. - `add_global_xpubs` fills the PSBT's global xpubs (the only emission step that needs the wallet). Ported from the bdk_wallet#502 PoC, re-expressed over the integrated bdk_tx API and the wallet's public accessors. MTP is faked from the confirmation block time; UTXO locking is honored; `longterm_feerate` lives on `SelectParams` and feeds the waste-aware change policy for every strategy. End-to-end tests cover the pipeline, candidate filtering, change commit, and error paths. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Bridge between bdk_wallet and bdk_tx, exposed as a `WalletTxExt` extension trait on `bdk_wallet::Wallet`. Keeping it in its own crate means neither base crate depends on the other: `bdk_wallet` stays stable, `bdk_tx` stays free to move, and the bridge absorbs the coupling (the decoupling argument from bitcoindevkit/bdk_wallet#297). Three-stage pipeline: - `candidates`/`candidates_with`/`rbf_candidates` -> `CandidateSet` (stage 1). - `select` -> `(TxTemplate, Option<AddressInfo>)` (stage 2): a pure read over a borrowed `&CandidateSet` (re-runnable) that peeks the auto-derived change address; commit it with `commit_change` (reveal + mark used) when you use the tx, or ignore it on abandon. The caller supplies the RNG. Emit the PSBT directly via `bdk_tx::TxTemplate::build_psbt`. - `add_global_xpubs` fills the PSBT's global xpubs (the only emission step that needs the wallet). Ported from the bdk_wallet#502 PoC, re-expressed over the integrated bdk_tx API and the wallet's public accessors. MTP is faked from the confirmation block time; UTXO locking is honored; `longterm_feerate` lives on `SelectParams` and feeds the waste-aware change policy for every strategy. End-to-end tests cover the pipeline, candidate filtering, change commit, and error paths. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Bridge between bdk_wallet and bdk_tx, exposed as a `WalletTxExt` extension trait on `bdk_wallet::Wallet`. Keeping it in its own crate means neither base crate depends on the other: `bdk_wallet` stays stable, `bdk_tx` stays free to move, and the bridge absorbs the coupling (the decoupling argument from bitcoindevkit/bdk_wallet#297). Three-stage pipeline: - `candidates`/`candidates_with`/`rbf_candidates` -> `CandidateSet` (stage 1). - `select` -> `(TxTemplate, Option<AddressInfo>)` (stage 2): a pure read over a borrowed `&CandidateSet` (re-runnable) that peeks the auto-derived change address; commit it with `commit_change` (reveal + mark used) when you use the tx, or ignore it on abandon. The caller supplies the RNG. Emit the PSBT directly via `bdk_tx::TxTemplate::build_psbt`. - `add_global_xpubs` fills the PSBT's global xpubs (the only emission step that needs the wallet). Ported from the bdk_wallet#502 PoC, re-expressed over the integrated bdk_tx API and the wallet's public accessors. MTP is faked from the confirmation block time; UTXO locking is honored; `longterm_feerate` lives on `SelectParams` and feeds the waste-aware change policy for every strategy. End-to-end tests cover the pipeline, candidate filtering, change commit, and error paths. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Bridge between bdk_wallet and bdk_tx, exposed as a `WalletTxExt` extension trait on `bdk_wallet::Wallet`. Keeping it in its own crate means neither base crate depends on the other: `bdk_wallet` stays stable, `bdk_tx` stays free to move, and the bridge absorbs the coupling (the decoupling argument from bitcoindevkit/bdk_wallet#297). Three-stage pipeline: - `candidates`/`candidates_with`/`rbf_candidates` -> `CandidateSet` (stage 1). - `select` -> `(TxTemplate, Option<AddressInfo>)` (stage 2): a pure read over a borrowed `&CandidateSet` (re-runnable) that peeks the auto-derived change address; commit it with `commit_change` (reveal + mark used) when you use the tx, or ignore it on abandon. The caller supplies the RNG. Emit the PSBT directly via `bdk_tx::TxTemplate::build_psbt`. - `add_global_xpubs` fills the PSBT's global xpubs (the only emission step that needs the wallet). Ported from the bdk_wallet#502 PoC, re-expressed over the integrated bdk_tx API and the wallet's public accessors. MTP is faked from the confirmation block time; UTXO locking is honored; `longterm_feerate` lives on `SelectParams` and feeds the waste-aware change policy for every strategy. End-to-end tests cover the pipeline, candidate filtering, change commit, and error paths. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Bridge between bdk_wallet and bdk_tx, exposed as a `WalletTxExt` extension trait on `bdk_wallet::Wallet`. Keeping it in its own crate means neither base crate depends on the other: `bdk_wallet` stays stable, `bdk_tx` stays free to move, and the bridge absorbs the coupling (the decoupling argument from bitcoindevkit/bdk_wallet#297). Three-stage pipeline: - `candidates`/`candidates_with`/`rbf_candidates` -> `CandidateSet` (stage 1). - `select` -> `(TxTemplate, Option<AddressInfo>)` (stage 2): a pure read over a borrowed `&CandidateSet` (re-runnable) that peeks the auto-derived change address; commit it with `commit_change` (reveal + mark used) when you use the tx, or ignore it on abandon. The caller supplies the RNG. Emit the PSBT directly via `bdk_tx::TxTemplate::build_psbt`. - `add_global_xpubs` fills the PSBT's global xpubs (the only emission step that needs the wallet). Ported from the bdk_wallet#502 PoC, re-expressed over the integrated bdk_tx API and the wallet's public accessors. MTP is faked from the confirmation block time; UTXO locking is honored; `longterm_feerate` lives on `SelectParams` and feeds the waste-aware change policy for every strategy. End-to-end tests cover the pipeline, candidate filtering, change commit, and error paths. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Bridge between bdk_wallet and bdk_tx, exposed as a `WalletTxExt` extension trait on `bdk_wallet::Wallet`. Keeping it in its own crate means neither base crate depends on the other: `bdk_wallet` stays stable, `bdk_tx` stays free to move, and the bridge absorbs the coupling (the decoupling argument from bitcoindevkit/bdk_wallet#297). Three-stage pipeline: - `candidates`/`candidates_with`/`rbf_candidates` -> `CandidateSet` (stage 1). - `select` -> `(TxTemplate, Option<AddressInfo>)` (stage 2): a pure read over a borrowed `&CandidateSet` (re-runnable) that peeks the auto-derived change address; commit it with `commit_change` (reveal + mark used) when you use the tx, or ignore it on abandon. The caller supplies the RNG. Emit the PSBT directly via `bdk_tx::TxTemplate::build_psbt`. - `add_global_xpubs` fills the PSBT's global xpubs (the only emission step that needs the wallet). Ported from the bdk_wallet#502 PoC, re-expressed over the integrated bdk_tx API and the wallet's public accessors. MTP is faked from the confirmation block time; UTXO locking is honored; `longterm_feerate` lives on `SelectParams` and feeds the waste-aware change policy for every strategy. End-to-end tests cover the pipeline, candidate filtering, change commit, and error paths. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Bridge between bdk_wallet and bdk_tx, exposed as a `WalletTxExt` extension trait on `bdk_wallet::Wallet`. Keeping it in its own crate means neither base crate depends on the other: `bdk_wallet` stays stable, `bdk_tx` stays free to move, and the bridge absorbs the coupling (the decoupling argument from bitcoindevkit/bdk_wallet#297). Three-stage pipeline: - `candidates`/`candidates_with`/`rbf_candidates` -> `CandidateSet` (stage 1). - `select` -> `(TxTemplate, Option<AddressInfo>)` (stage 2): a pure read over a borrowed `&CandidateSet` (re-runnable) that peeks the auto-derived change address; commit it with `commit_change` (reveal + mark used) when you use the tx, or ignore it on abandon. The caller supplies the RNG. Emit the PSBT directly via `bdk_tx::TxTemplate::build_psbt`. - `add_global_xpubs` fills the PSBT's global xpubs (the only emission step that needs the wallet). Ported from the bdk_wallet#502 PoC, re-expressed over the integrated bdk_tx API and the wallet's public accessors. MTP is faked from the confirmation block time; UTXO locking is honored; `longterm_feerate` lives on `SelectParams` and feeds the waste-aware change policy for every strategy. End-to-end tests cover the pipeline, candidate filtering, change commit, and error paths. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
| /// One of the transactions to be replaced is already confirmed | ||
| TransactionConfirmed(Txid), |
There was a problem hiding this comment.
I don't think this error variant earns it's keep.
-
Most callers would want to check whether the transaction is still unconfirmed before trying to replace it. A caller that doesn't do that obviously wants to create a transaction that conflicts with a confirmed one.
-
The guard is partial. It only catches "already confirmed at build time". The original transaction can be confirmed before the replacement is ready to broadcast.
Bridge between bdk_wallet and bdk_tx, exposed as a `WalletTxExt` extension trait on `bdk_wallet::Wallet`. Keeping it in its own crate means neither base crate depends on the other: `bdk_wallet` stays stable, `bdk_tx` stays free to move, and the bridge absorbs the coupling (the decoupling argument from bitcoindevkit/bdk_wallet#297). Three-stage pipeline: - `candidates`/`candidates_with`/`rbf_candidates` -> `CandidateSet` (stage 1). - `select` -> `(TxTemplate, Option<AddressInfo>)` (stage 2): a pure read over a borrowed `&CandidateSet` (re-runnable) that peeks the auto-derived change address; commit it with `commit_change` (reveal + mark used) when you use the tx, or ignore it on abandon. The caller supplies the RNG. Emit the PSBT directly via `bdk_tx::TxTemplate::build_psbt`. - `add_global_xpubs` fills the PSBT's global xpubs (the only emission step that needs the wallet). Ported from the bdk_wallet#502 PoC, re-expressed over the integrated bdk_tx API and the wallet's public accessors. MTP is faked from the confirmation block time; UTXO locking is honored; `longterm_feerate` lives on `SelectParams` and feeds the waste-aware change policy for every strategy. End-to-end tests cover the pipeline, candidate filtering, change commit, and error paths. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Bridge between bdk_wallet and bdk_tx, exposed as a `WalletTxExt` extension trait on `bdk_wallet::Wallet`. Keeping it in its own crate means neither base crate depends on the other: `bdk_wallet` stays stable, `bdk_tx` stays free to move, and the bridge absorbs the coupling (the decoupling argument from bitcoindevkit/bdk_wallet#297). Three-stage pipeline: - `candidates`/`candidates_with`/`rbf_candidates` -> `CandidateSet` (stage 1). - `select` -> `(TxTemplate, Option<AddressInfo>)` (stage 2): a pure read over a borrowed `&CandidateSet` (re-runnable) that peeks the auto-derived change address; commit it with `commit_change` (reveal + mark used) when you use the tx, or ignore it on abandon. The caller supplies the RNG. Emit the PSBT directly via `bdk_tx::TxTemplate::build_psbt`. - `add_global_xpubs` fills the PSBT's global xpubs (the only emission step that needs the wallet). Ported from the bdk_wallet#502 PoC, re-expressed over the integrated bdk_tx API and the wallet's public accessors. MTP is faked from the confirmation block time; UTXO locking is honored; `longterm_feerate` lives on `SelectParams` and feeds the waste-aware change policy for every strategy. End-to-end tests cover the pipeline, candidate filtering, change commit, and error paths. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Bridge between bdk_wallet and bdk_tx, exposed as a `WalletTxExt` extension trait on `bdk_wallet::Wallet`. Keeping it in its own crate means neither base crate depends on the other: `bdk_wallet` stays stable, `bdk_tx` stays free to move, and the bridge absorbs the coupling (the decoupling argument from bitcoindevkit/bdk_wallet#297). Three-stage pipeline: - `candidates`/`candidates_with`/`rbf_candidates` -> `CandidateSet` (stage 1). - `select` -> `(TxTemplate, Option<AddressInfo>)` (stage 2): a pure read over a borrowed `&CandidateSet` (re-runnable) that peeks the auto-derived change address; commit it with `commit_change` (reveal + mark used) when you use the tx, or ignore it on abandon. The caller supplies the RNG. Emit the PSBT directly via `bdk_tx::TxTemplate::build_psbt`. - `add_global_xpubs` fills the PSBT's global xpubs (the only emission step that needs the wallet). Ported from the bdk_wallet#502 PoC, re-expressed over the integrated bdk_tx API and the wallet's public accessors. MTP is faked from the confirmation block time; UTXO locking is honored; `longterm_feerate` lives on `SelectParams` and feeds the waste-aware change policy for every strategy. End-to-end tests cover the pipeline, candidate filtering, change commit, and error paths. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Bridge between bdk_wallet and bdk_tx, exposed as a `WalletTxExt` extension trait on `bdk_wallet::Wallet`. Keeping it in its own crate means neither base crate depends on the other: `bdk_wallet` stays stable, `bdk_tx` stays free to move, and the bridge absorbs the coupling (the decoupling argument from bitcoindevkit/bdk_wallet#297). Three-stage pipeline: - `candidates`/`candidates_with`/`rbf_candidates` -> `CandidateSet` (stage 1). - `select` -> `(TxTemplate, Option<AddressInfo>)` (stage 2): a pure read over a borrowed `&CandidateSet` (re-runnable) that peeks the auto-derived change address; commit it with `commit_change` (reveal + mark used) when you use the tx, or ignore it on abandon. The caller supplies the RNG. Emit the PSBT directly via `bdk_tx::TxTemplate::build_psbt`. - `add_global_xpubs` fills the PSBT's global xpubs (the only emission step that needs the wallet). Ported from the bdk_wallet#502 PoC, re-expressed over the integrated bdk_tx API and the wallet's public accessors. MTP is faked from the confirmation block time; UTXO locking is honored; `longterm_feerate` lives on `SelectParams` and feeds the waste-aware change policy for every strategy. End-to-end tests cover the pipeline, candidate filtering, change commit, and error paths. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Bridge between bdk_wallet and bdk_tx, exposed as a `WalletTxExt` extension trait on `bdk_wallet::Wallet`. Keeping it in its own crate means neither base crate depends on the other: `bdk_wallet` stays stable, `bdk_tx` stays free to move, and the bridge absorbs the coupling (the decoupling argument from bitcoindevkit/bdk_wallet#297). Three-stage pipeline: - `candidates`/`candidates_with`/`rbf_candidates` -> `CandidateSet` (stage 1). - `select` -> `(TxTemplate, Option<AddressInfo>)` (stage 2): a pure read over a borrowed `&CandidateSet` (re-runnable) that peeks the auto-derived change address; commit it with `commit_change` (reveal + mark used) when you use the tx, or ignore it on abandon. The caller supplies the RNG. Emit the PSBT directly via `bdk_tx::TxTemplate::build_psbt`. - `add_global_xpubs` fills the PSBT's global xpubs (the only emission step that needs the wallet). Ported from the bdk_wallet#502 PoC, re-expressed over the integrated bdk_tx API and the wallet's public accessors. MTP is faked from the confirmation block time; UTXO locking is honored; `longterm_feerate` lives on `SelectParams` and feeds the waste-aware change policy for every strategy. End-to-end tests cover the pipeline, candidate filtering, change commit, and error paths. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Bridge between bdk_wallet and bdk_tx, exposed as a `WalletTxExt` extension trait on `bdk_wallet::Wallet`. Keeping it in its own crate means neither base crate depends on the other: `bdk_wallet` stays stable, `bdk_tx` stays free to move, and the bridge absorbs the coupling (the decoupling argument from bitcoindevkit/bdk_wallet#297). Three-stage pipeline: - `candidates`/`candidates_with`/`rbf_candidates` -> `CandidateSet` (stage 1). - `select` -> `(TxTemplate, Option<AddressInfo>)` (stage 2): a pure read over a borrowed `&CandidateSet` (re-runnable) that peeks the auto-derived change address; commit it with `commit_change` (reveal + mark used) when you use the tx, or ignore it on abandon. The caller supplies the RNG. Emit the PSBT directly via `bdk_tx::TxTemplate::build_psbt`. - `add_global_xpubs` fills the PSBT's global xpubs (the only emission step that needs the wallet). Ported from the bdk_wallet#502 PoC, re-expressed over the integrated bdk_tx API and the wallet's public accessors. MTP is faked from the confirmation block time; UTXO locking is honored; `longterm_feerate` lives on `SelectParams` and feeds the waste-aware change policy for every strategy. End-to-end tests cover the pipeline, candidate filtering, change commit, and error paths. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Bridge between bdk_wallet and bdk_tx, exposed as a `WalletTxExt` extension trait on `bdk_wallet::Wallet`. Keeping it in its own crate means neither base crate depends on the other: `bdk_wallet` stays stable, `bdk_tx` stays free to move, and the bridge absorbs the coupling (the decoupling argument from bitcoindevkit/bdk_wallet#297). Three-stage pipeline: - `candidates`/`candidates_with`/`rbf_candidates` -> `CandidateSet` (stage 1). - `select` -> `(TxTemplate, Option<AddressInfo>)` (stage 2): a pure read over a borrowed `&CandidateSet` (re-runnable) that peeks the auto-derived change address; commit it with `commit_change` (reveal + mark used) when you use the tx, or ignore it on abandon. The caller supplies the RNG. Emit the PSBT directly via `bdk_tx::TxTemplate::build_psbt`. - `add_global_xpubs` fills the PSBT's global xpubs (the only emission step that needs the wallet). Ported from the bdk_wallet#502 PoC, re-expressed over the integrated bdk_tx API and the wallet's public accessors. MTP is faked from the confirmation block time; UTXO locking is honored; `longterm_feerate` lives on `SelectParams` and feeds the waste-aware change policy for every strategy. End-to-end tests cover the pipeline, candidate filtering, change commit, and error paths. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Description
This PR introduces a new PSBT construction flow and associated wallet APIs.
Primary additions:
PsbtParams<Ctx>API with typed contexts (CreateTxandReplaceTx) for transaction creation and replacement.Wallet::create_psbtandWallet::create_psbt_with_rngWallet::replace_by_fee,Wallet::replace_by_fee_with_rng, andWallet::replace_by_fee_and_recipientsTxOrdering<In, Out>updates used by the new selection/PSBT pathThis work is part of the broader migration of transaction construction to
bdk_tx, which uses miniscript'splanmodule under the hood. A key long-term goal is the move away from legacy policy-based transaction construction internals (#4).fix #204
Notes to the reviewers
Suggested review order for this PR:
examples/psbt.rsandexamples/replace_by_fee.rsfor a high-level API walkthrough.src/psbt/params.rsin detail (types, state transitions, params semantics, and so on).src/wallet/mod.rs(create-PSBT and RBF execution paths plus shared helpers).tests/psbt.rs,tests/wallet.rsto ensure expected behavior and edge cases are covered.Changelog notice
Changed
TxOrdering::Customis generic over the input and output types.Added
psbt::paramsmodulePsbtParamsstructCoinSelectionStrategyenumUtxoFilterstructAdded
pubmethods onWalletWallet::create_psbt{_with_rng}Wallet::replace_by_fee{_with_rng}Wallet::replace_by_fee_and_recipientsAdded examples
examples/psbt.rsexamples/replace_by_fee.rsChecklists
This pull request breaks the existing API