-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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 nhashtype not getting set by sighash.sign #1278
Conversation
LGTM. Good catch |
Cool, here's the actual usage example that led me to find this: https://github.com/mruddy/bip65-demos/blob/master/freeze.js Also, should we add an upper case alias for bitcore.Transaction.sighash and plan to remove the lower case later? The lower case seems inconsistent with the rest of the library: Line 70 in 1c8ebc0
|
LGTM |
This line I think can be removed, since this PR fixes it: https://github.com/bitpay/bitcore/blob/master/lib/transaction/input/multisigscripthash.js#L146 |
LGTM |
@braydonf I have the changes locally to remove the line in the file you mentioned as well as in https://github.com/bitpay/bitcore/blob/master/lib/transaction/input/input.js#L168 Should I add those two line removals to a re-based commit for this PR? Or should I do that in a separate PR? Just wondering since some others have already reviewed the existing commit. Either way is fine with me. Thanks! |
@mruddy yeah just go ahead and add it to this PR. |
LGTM, great catch @mruddy |
@braydonf @pnagurny @eordano @maraoz |
I think the fixme comments are not relevant anymore with the lines removed: https://github.com/bitpay/bitcore/pull/1278/files#diff-7541e8aa080e031cbd44309592b5b366L145 |
@braydonf I was wondering about whether to leave those or not. Latest commit removes the fixme comments too. |
@braydonf I was just going through and looking at lib/transaction/signature.js and lib/crypto/signature.js. There may be cases where people create TransactionSignature's with a sigtype, but the signature member gets populated from a buffer that does not set the nhashtype. So, it's probably safer to go back to my original commit that leaves in the couple of lines that I removed today. What do you think? |
You're probably right. The tests pass, however there is a case that nhashtype wouldn't be set, and sighash.verify expects it. |
…type. added unit tests. fixed an existing lint in a file that i touched.
@braydonf Exactly. I've reset back to the original commit. This should be good to go. |
fix nhashtype not getting set by sighash.sign
Thanks! Landed in release v0.12.11 |
I noticed that the SIGHASH value was not getting set while I was trying some code that did essentially this:
var sig = bitcore.Transaction.sighash.sign(tx, key, bitcore.crypto.Signature.SIGHASH_ALL, 0, script);
console.log(sig.toTxFormat().toString('hex'));
sighash.sign is correctly trying to set the nhashtype, but it's not being picked up in the setter method. looks like a simple oversight. i added in the setter and added some more unit tests. i also de-linted an easy double quote nit of an existing test case.