fix(wallet): fail early for unregistered foreign prevouts in add_foreign_utxo#423
Open
noahjoeris wants to merge 3 commits intobitcoindevkit:masterfrom
Open
fix(wallet): fail early for unregistered foreign prevouts in add_foreign_utxo#423noahjoeris wants to merge 3 commits intobitcoindevkit:masterfrom
noahjoeris wants to merge 3 commits intobitcoindevkit:masterfrom
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #423 +/- ##
==========================================
+ Coverage 80.04% 80.30% +0.26%
==========================================
Files 24 24
Lines 5336 5352 +16
Branches 242 247 +5
==========================================
+ Hits 4271 4298 +27
+ Misses 987 976 -11
Partials 78 78
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:
|
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.
Description
This PR makes
TxBuilder::add_foreign_utxofail early when the txout/tx required by the PSBT input has not been inserted into the wallet.Wallet::insert_txoutforwitness_utxoinputsWallet::insert_txfornon_witness_utxoinputsThis avoids building transactions that later fail during fee bumping because the wallet cannot reconstruct the required PSBT input metadata from its tx graph.
This PR also adds
Wallet::insert_tx, introduces new registration errors inadd_foreign_utxo, and updates the tests.Fixes #345
Notes to the reviewers
The main issue here is fee bumping for transactions funded with foreign inputs.
build_fee_bumpreconstructs PSBT input metadata from the wallet tx graph. That works if the required foreign data is already in the graph, but it can fail for foreign inputs when the wallet was not informed about the parent transaction or txout ahead of time.This is relevant for foreign inputs that rely on
non_witness_utxo, where the full parent transaction must be available.insert_txoutalone is not enough in that case, which is why this PR addsWallet::insert_tx.I chose to make
add_foreign_utxofail early if the transaction or txout has not been inserted into the wallet. This follows the direction discussed in Inform wallet about foreign transactions/txouts before using them to fund new transactions #345.This is my first PR to the codebase 🔥 I’d appreciate any feedback on the approach and I’m happy to make follow-up changes.
Changelog notice
TxBuilder::add_foreign_utxonow fails early if the transaction or txout required by the provided PSBT input has not already been inserted into the wallet. UseWallet::insert_txoutforwitness_utxoinputs andWallet::insert_txfornon_witness_utxoinputs.Checklists
All Submissions:
just pbefore pushingBugfixes: