-
Notifications
You must be signed in to change notification settings - Fork 56
Add CPFP Support #370
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Add CPFP Support #370
Conversation
`TxOrdering` is made generic by exposing the generic from `TxSort` function. The benefit is that we're no longer limited to ordering lists of only `TxIn` or `TxOut`. We use bitcoin `TxIn` and `TxOut` as the default type parameter to maintain backward compatibility. Add `sort_with_rng` for `TxOrdering<In, Out>` for sorting two generic mutable slices. This will be useful in a later commit by applying a `TxOrdering` to the Input/Output sets of a `Selection`.
We add the `psbt::params` module along with new types including `PsbtParams` and `SelectionStrategy`. `PsbtParams` is mostly inspired by `TxParams` from `tx_builder.rs`, except that we've removed support for `policy_path` in favor of `add_assets` API. Further enhancements include `.utxo_filter` and `.canonical_params` member fields. `PsbtParams<C>` contains a type parameter `C` indicating the context in which the parameters can be used. Methods related to PSBT creation exist within the `CreateTx` context, and methods related to replacements (RBF) exist within the `ReplaceTx` context. In `lib.rs` re-export everything under `psbt` module. - deps: Add `bdk_tx` 0.1.0 - deps: Add `bdk_coin_select` 0.4.1
We use the new `PsbtParams` to add methods on `Wallet` for creating PSBTs, including RBF transactions. `Wallet::create_psbt` and `Wallet::replace_by_fee` each have no-std counterparts that take an additional `impl RngCore` parameter. Also adds a high level convenience method `Wallet::replace_by_fee_and_recipients` that exposes the minimum information needed to create an RBF. This commit re-introduces the `Wallet::insert_tx` API for adding transaction data to the wallet that may or may not be canonical from the point of view of the TxGraph. Added `Wallet::transactions_with_params` that allows customizing the internal canonicalization logic. Added new errors to `wallet::errors` - `CreatePsbtError` - `ReplaceByFeeError`
Adds additional tests to exercise `PsbtParams` logic and PSBT creation. - test-utils: Add `insert_tx_anchor` test helper for adding a transaction to the wallet with associated anchor block.
- `examples/psbt.rs` - `examples/rbf.rs`
Made a number of API changes to `PsbtParams` - Add `PsbtParams::sighash_type` - psbt: Change `change_descriptor` to `change_script` - Add `PsbtParams::change_policy` - psbt: Change `feerate` to `fee` using `FeeStrategy` - Remove `longterm_feerate` TODO: - This should be updated to depend on `bdk_tx` version 0.2.0 which is still unreleased.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #370 +/- ##
==========================================
+ Coverage 85.33% 86.22% +0.88%
==========================================
Files 24 25 +1
Lines 8335 9318 +983
==========================================
+ Hits 7113 8034 +921
- Misses 1222 1284 +62
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
|
||
| // Create psbt | ||
| let mut psbt = selection | ||
| .create_psbt(bdk_tx::PsbtParams { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello, I am getting an error on this line.
error message:
missing field `enable_anti_fee_sniping` in initializer of `bdk_tx::PsbtParams`
missing `enable_anti_fee_sniping`
I was able to clear the error by adding enable_anti_fee_sniping: true, to the existing fields.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for pointing that out. We cannot outrightly set it to true, it's okay to give users the liberty to set the desired behaviour.
A dependency (bdk-tx) was updated after this PR was created, which introduced the new enable_anti_fee_sniping field, hence the build error.
It will be added as a configurable option in the PsbtParams struct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh that's great!
Description
This PR adds support for creating Child-Pays-For-Parent (CPFP) transactions to accelerate unconfirmed parent transactions by creating a child transaction that spends from an unconfirmed parent output with a higher fee rate.
Notes to the reviewers
Changelog notice
Added
CreateSweepErrorenumWallet::create_sweepWallet::create_sweep_with_rngexamples/cpfp.rsRebased on #297
Checklists
All Submissions:
just pbefore pushingNew Features:
Bugfixes:
This pull request breaks the existing APII've added tests to reproduce the issue which are now passingI'm linking the issue being fixed by this PR