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
wallet: allow psbtbumpfee to work with txs with external inputs #23202
Conversation
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
c2d2948
to
11880ff
Compare
a6f2dc9
to
8dbfdc5
Compare
Concept ACK |
8dbfdc5
to
61ae973
Compare
61ae973
to
709e433
Compare
709e433
to
1689110
Compare
Compiling this branch now as its ready for review. Not sure if I will be able to test everything but this is an interesting feature which should exist in Core. Hoping other devs review this without any club. |
I would really love to see this land. I can test this end-to-end with eclair whenever it's ready and verify that it lets us bump lightning transactions (I can add tests with various kinds of inputs, confirmed / unconfirmed / unsafe). How does it impact @xekyo's work on ancestor aware funding (https://github.com/Xekyo/bitcoin/commits/ancestor-aware-funding)? Ideally the feerate computed here should take into account all unconfirmed ancestors, but maybe Xekyo's work would just land after this PR and fix its feerate computation? |
I believe that work will require some mempool changes that have not been implemented yet, so it is probable that it will still be some time before that is ready for review. |
Thanks for the quick answer, so I guess @xekyo's work will simply improve |
@t-bast @ishaanam @instagibbs @xekyo Re-review? |
There seems to be an issue when I provide the
I was calling
Its second input is a wallet input and the second output is the change output, and the amount should allow bumping to the feerate I'm expecting. |
04970f2
to
b14e652
Compare
Good catch. I've added a fix for that and a test case. |
ffd6935
to
bea4313
Compare
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.
ACK bea4313, I tried to bump lightning htlc transactions and everything seems to work fine 👍
ACK bea4313 |
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.
Instead of calculating the fee by using what is stored in the wallet, calculate it by looking up the UTXOs.
When bumping the fee of a transaction containing external inputs, determine the weights of those inputs. Because signatures can have a variable size, the script is executed with a special SignatureChecker which will compute the total weight of the signatures in the transaction and the weight if they were all maximum size signatures. This allows us to compute the maximum weight of the input for use during coin selection.
The max size calculation expects some inputs to have empty scriptSigs and witnesses, so we need to clear these before doing that calculation.
In some cases, notably psbtbumpfee, it is okay, and potentially desired, to be able to bump the fee of a transaction which contains external inputs.
bea4313
to
b1f8fa3
Compare
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.
reACK b1f8fa3
b1f8fa3
to
c3b099a
Compare
reACK c3b099a |
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.
Re-ran my tests agains c3b099a, ACK
This PR allows
psbtbumpfee
to return a PSBT for transactions that contain external inputs. This does not work for bumping in the GUI norbumpfee
because these need private keys available to sign and send the transaction. Butpsbtbumpfee
returns a psbt, so it is fine to not be able to sign.In order to correctly estimate the size of the inputs for coin selection, the fee bumper will use the size of the inputs of the transaction being bumped. Because the sizes of signatures are not guaranteed, for external inputs, the fee bumper will verify the scripts with a special SignatureChecker which will compute the weight of all of the signatures in that input, and compute their weights if those signatures were maximally sized. This allows the fee bumper to obtain a max size estimate for each external input.
Builds on #23201 as it relies on the ability to pass weights in to coin selection.
Closes #23189