-
Notifications
You must be signed in to change notification settings - Fork 831
PSBT taproot spending signature type #671
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
Conversation
containing both signature and SigHash, serializing according to the consensus (for witness field) and PSBT (for taproot signature keys) rules
pub fn sighash_byte(self) -> u8 { | ||
self.sighash_type as u8 | ||
} | ||
|
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.
Why do these consume self
?
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.
Because self
is Copy
- and, according to rust API guidelines, copy-types should consume self, rather than taking it by ref.
The rationale is quite simple: Self
here is 8 bit, reference is 64 bit.
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.
Because self is Copy - and, according to rust API guidelines, copy-types should consume self, rather than taking it by ref.
Interesting, thanks I did not know that.
The rationale is quite simple: Self here is 8 bit, reference is 64 bit.
self
here is SpendingSignature
not 8 bit, but it is Copy
:)
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 right. We had this discussion before, that pushing 32 bytes to stack in function call may be still cheaper than 64-bit pointer + memory access
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.
More importantly, the compiler can do these optimizations better than all of us combined. Passing via value or reference should be mostly semantics, not an optimization.
Should be rebased in top of #681 |
I will open a PR to address #670 first that should address this |
No description provided.