-
Notifications
You must be signed in to change notification settings - Fork 813
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
base: master
Are you sure you want to change the base?
Conversation
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
@@ -1960,7 +1960,6 @@ class RPC extends RPCBase { | |||
key.script = redeem; | |||
key.witness = script.isWitnessScripthash(); | |||
key.refresh(); | |||
break; |
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.
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
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.
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 script
and 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)
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. |
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 torpc-test.js
once #550 gets merged