-
Notifications
You must be signed in to change notification settings - Fork 2.2k
TransactionBuilder P2SH Multisig order of signatures #348
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
… order than the order of the pubKeys in the redeemScript
|
test failure seems to be a failure of the faucet? |
|
@rubensayshi granted the PR size of #329 is larger, it also does serve a slightly larger purpose in ensuring less information is thrown away in For the best comparison, I'd read through each of the commits individually. |
|
@dcousens cool, I'll close this PR and await the 2.0.0 release (and in the meantime use my own patch) |
|
@rubensayshi cheers mate, I'd appreciate another pair of eyes for review if you have the time. These PRs were great to see another approach to problem (even if it was very similar). |
|
@dcousens I'll take a close look at it. PS. how stable is the 2.0.0 branch? maybe I could already run on the 2.0.0 branch to test it a bit? |
|
The |
|
okay, I'll keep an eye out :) |
|
@dcousens in my alternative implementation (which isn't doing it in if you agree, I can do a PR to change your code to do the same? |
When building a transaction the order of the signatures of a P2SH multisig should be the same as the order of their respective pubKey.
This PR fixes that by looping over the pubKeys in the
__buildand finding the signature that belongs to the pubKey (and 2 changes to make sure that theinput.pubKeysis actually the correct list of pubKeys).A problem however that I'm using
pubKey.verifycalls to figure out which signature belongs to which pubKey, and thepubKey.verifycalls are reletively heavy on performance, making the__buildtake ~0.12 instead of the old ~0.03 (testing with the 2of2 from the test case).Alternatively I could move the resposibility to put the signatures in the right order to
txb.signandTransactionBuilder.fromTransaction, prefilling theinput.signatureswith NULL values for missing signatures, in which casefromTransactionwould be doing thepubKey.verifycalls instead of__build.To compare I did another PR with that version of the code; <gimme a sec to make the PR ;-)>
The 2nd solution is probably better since it involves less
pubKey.verifycalls and they're only intxb.sign, which is where you would expect the 'heavy lifting'