fix: remove deprecated max_satisfaction_weight#1345
fix: remove deprecated max_satisfaction_weight#1345evanlinjin merged 1 commit intobitcoindevkit:masterfrom
Conversation
evanlinjin
left a comment
There was a problem hiding this comment.
Thank you for having a go at this, however the approach here is incorrect.
First off, it's incorrect to add 4WU to only segwit inputs.
Looking at the docs of max_weight_to_satisfy, we need to change the definition of our TX_IN_BASE_WEIGHT to be TxIn::default().segwit_weight().
After that, to make the tests pass, we need to change P2WPKH_SATISFACTION_SIZE to take in to account the scriptSigLen and witnessLen.
I think it's okay to assume all transactions are segwit transactions for now? Unless if someone can figure out how to take away the witness len elegantly (for non-segwit txs).
crates/bdk/src/wallet/mod.rs
Outdated
| let segwit_add = match is_segwit { | ||
| true => 4, | ||
| false => 0, | ||
| }; |
There was a problem hiding this comment.
Is the intention here to include the scriptSigLen weight? If so, please name the variable appropriately.
However, non-segwit inputs also have this field. Wouldn't it be correct to always have this addition?
There was a problem hiding this comment.
Ignore the comment above. Just remove this and add the extra weights to TX_IN_BASE_WEIGHT.
There was a problem hiding this comment.
Great, sorry for the missundestanding.
I think I've fixed this in 52d6283
e397896 to
8d6764d
Compare
|
Can I please have some input on my statement here? Thanks!
|
8e91886 to
52d6283
Compare
I agree. We currently don't test any non-segwit tx anyways... |
Because we already assume this: https://github.com/bitcoindevkit/bdk/blob/master/crates%2Fbdk%2Fsrc%2Fwallet%2Fmod.rs#L1505-L1513 So I think it is okay. |
|
@storopoli can we please rebase the two commits into one and I'll ACK it. |
52d6283 to
6d0f282
Compare
Done, thanks mate! |
crates/bdk/src/wallet/tx_builder.rs
Outdated
| let satisfaction_weight = { | ||
| let is_segwit = wallet | ||
| .get_descriptor_for_keychain(utxo.keychain) | ||
| .is_witness() | ||
| || wallet | ||
| .get_descriptor_for_keychain(utxo.keychain) | ||
| .is_taproot(); | ||
| let segwit_add = match is_segwit { | ||
| true => 4, | ||
| false => 0, | ||
| }; | ||
| descriptor.max_weight_to_satisfy().unwrap() + segwit_add | ||
| }; |
There was a problem hiding this comment.
Sorry about that. Should be good now.
6d0f282 to
482e16c
Compare
482e16c to
9078957
Compare
ValuedMammal
left a comment
There was a problem hiding this comment.
Approach ACK.
For simplicity I think it's fair to assume segwit weight everywhere. Unless someone is doing legacy transactions with hundreds of inputs (which is certainly possible), I don't think you'd notice a difference. We could consider carving out a special case for legacy-only transactions in a future iteration of tx building.
To the note on testing legacy descriptors I don't have an immediate comment on it.
a02230c to
9f05e63
Compare
|
@storopoli sorry can you do a rebase on master? thanks |
446acd2 to
73aacda
Compare
Don't worry man. Sure, rebased to master :) |
1bf5bcf to
d2b8e66
Compare
- Change deprecated `max_satisfaction_weight` to `max_weight_to_satisfy` - Remove `#[allow(deprecated)]` flags - updates the calculations in TXIN_BASE_WEIGHT and P2WPKH_SATISFACTION_SIZE Update crates/bdk/src/wallet/coin_selection.rs Co-authored-by: ValuedMammal <valuedmammal@protonmail.com>
d2b8e66 to
798ed8c
Compare
Description
Continuation of #1115.
Closes #1036.
max_satisfaction_weighttomax_weight_to_satisfy#[allow(deprecated)]flagsNotes to the reviewers
I've changed all
max_satisfaction_weight()tomax_weight_to_satisfy()inWallet.get_available_utxo()andWallet.build_fee_bump(). Checking the docs on theminiscriptcrate formax_weight_to_satisfyhas the following note:We are testing if the underlying descriptor
is.segwit()or.is_taproot,then adding 4WU if true or leaving as it is otherwise.
Another thing, we are not testing in BDK tests for legacy (pre-segwit) descriptors.
Should I also add them to this PR?
Changelog notice
Fixed
Replace the deprecated
max_satisfaction_weightfromrust-miniscripttomax_weight_to_satisfy.Checklists
All Submissions:
cargo fmtandcargo clippybefore committingBugfixes: