-
Notifications
You must be signed in to change notification settings - Fork 141
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
Fix max_satisfaction_weight
calculations for taproot.
#473
Fix max_satisfaction_weight
calculations for taproot.
#473
Conversation
This work is based on my understanding of BIP-0141 and BIP-0341. I'm not sure what is the best way to test this, any ideas will be appreciated. |
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 fa2e4e2
let tree = match self.taptree() { | ||
// key spend path: | ||
// scriptSigLen(4) + stackLen(1) + stack[Sig]Len(1) + stack[Sig](65) | ||
None => return Ok(4 + 1 + 1 + 65), |
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.
nit: the 65 here is implicitly taking into account an optional sighash flag (because we're doing max I guess this strictly correct). Maybe worth doing a 64 + 1
to indicate this.
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.
@LLFourn Thank you for the review.
However, at the same time, the sig+sigHash is a single stack item? Maybe a comment would be more appropriate?
I think you need to update some tests:
for me locally. |
Sorry, but could you squash these commitst so the tests pass on every commit? |
* Key spend path should take into consideration the scriptSigLen, stackLen and itemLen (for the one and only stack item). * Script spend path should consider `control_block` and `script` to be items on the stack. I also restructured the function to improve readability.
edc583c
to
8834b7f
Compare
@apoelstra All done :) |
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.
utACK 8834b7f. Thanks for the significant code improvement.
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 8834b7f
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 8834b7f
I'd like to cut a release today. Should we revert this for now? |
@apoelstra I don't think this fix conflicts with the conversation we were having in regards to what would be the definition of "max satisfaction weight". I think we should continue discussing whether we should merge #474 or go with #476 instead. Let me know your thoughts on those PRs. |
…022_10 22ac742 Merge rust-bitcoin/rust-miniscript#473: Fix `max_satisfaction_weight` calculations for taproot.
control_block
andscript
to be items on the stack.I also restructured the function to improve readability.