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

Node RPC: check for more than one pubkey when signing multisig #555

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

pinheadmz
Copy link
Member

fixes #554

thanks to @nodar-chkuaselidze for finding the bug.

I wrote the test in http-test.js but I'd like to move it to rpc-test.js once #550 gets merged

@codecov-io
Copy link

codecov-io commented Aug 2, 2018

Codecov Report

Merging #555 into master will increase coverage by 0.45%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #555      +/-   ##
==========================================
+ Coverage   52.88%   53.34%   +0.45%     
==========================================
  Files         104      104              
  Lines       27700    27699       -1     
  Branches     4748     4748              
==========================================
+ Hits        14649    14775     +126     
+ Misses      13051    12924     -127
Impacted Files Coverage Δ
lib/node/rpc.js 29.43% <ø> (+6.12%) ⬆️
lib/script/script.js 76.99% <0%> (+0.12%) ⬆️
lib/primitives/tx.js 82.93% <0%> (+0.28%) ⬆️
lib/mempool/mempool.js 43.71% <0%> (+0.45%) ⬆️
lib/primitives/mtx.js 62.23% <0%> (+1.74%) ⬆️
lib/primitives/keyring.js 73.55% <0%> (+2.47%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f24a9b6...ad12709. Read the comment docs.

@@ -1960,7 +1960,6 @@ class RPC extends RPCBase {
key.script = redeem;
key.witness = script.isWitnessScripthash();
key.refresh();
break;
Copy link

@sandu-c sandu-c Aug 3, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you might want to keep this break if you want to apply a different SIGHASH flag per input. (currently there seems to be only one SIGHASH type supported being applied to all inputs signatures per signature request, per input).

If you do want different SIGHASH types per input then you'll need this break in place and you'll need to resend the tx to be signed as many times as the nr. of inputs to be signed.

If we remove the break line, we can atomically sign multiple inputs with the same SIGASH type, but we loose the flexibility of allowing multiple distinct SIGHASH signatures per input

Copy link
Member Author

@pinheadmz pinheadmz Aug 3, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at Bitcoin Core signrawtransaction, only one SIGHASH parameter is accepted by the RPC call which, I assume, applies to all inputs in the tx. In our function, SIGHASH is handled here: https://github.com/bcoin-org/bcoin/blob/master/lib/node/rpc.js#L1969-L1986 So I think that we are OK for those.

However you are right that removing the break means a private key can only be used with one scriptand witness type in a transaction because of the map. I'm not sure how Bitcoin Core would handle that case but here it would fail if the same private key was used differently in two different inputs of the same transaction:

Failure case with different script's:
input 0: Multisig Alice + Bob
input 1: Multisig Alice + Charlie

Failure case with different witness's:
input 0: P2SH Alice (legacy BIP16 script hash, multisig or not)
input 1: P2WSH Alice (SegWit BIP141 script hash, mutisig or not)

@haxwell
Copy link

haxwell commented Jan 15, 2023

What is the expected behavior here? Should we allow the same private key [to be] used differently in two different inputs of the same transaction? That seems to be the outstanding question on this PR.

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

Successfully merging this pull request may close these issues.

Problems with RPC signrawtransaction
5 participants