Skip to content
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

Skip the extra tx.Copy() when calculating the signature hash #126

Closed
cjepson opened this issue Apr 19, 2016 · 0 comments · Fixed by #171
Closed

Skip the extra tx.Copy() when calculating the signature hash #126

cjepson opened this issue Apr 19, 2016 · 0 comments · Fixed by #171

Comments

@cjepson
Copy link
Contributor

cjepson commented Apr 19, 2016

Signatures sign H(prefixHash || witnessHash), but prefixHash never changes for sigHashAll. The Copy() call in calcSignatureHash can then be easily avoided if the transaction hash is simply reused and the transaction witness, or the hash of the referenced pkScript in this case, calculated on the fly.

alexlyp pushed a commit that referenced this issue May 16, 2016
Legacy transaction deep copy code mandated by the Bitcoin protocol
caused large amounts of data to be copied needlessly. If the
optimization for SigHashAll is set in chaincfg/params.go, these
extra copies are avoided by directly writing the pkScript and
decorations to a buffer and then hashing to get a witness hash,
while using the cached hash for the prefix.

Fixes #126.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants