Skip to content

Commit 6a25c14

Browse files
authored
Merge pull request bitcoin#800 from junderw/junderw-patch-1
BIP174: Include suggested sighash check
2 parents 095087b + 97447f9 commit 6a25c14

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

bip-0174.mediawiki

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -325,20 +325,26 @@ For a Signer to only produce valid signatures for what it expects to sign, it mu
325325
* If a witness UTXO is provided, no non-witness signature may be created
326326
* If a redeemScript is provided, the scriptPubKey must be for that redeemScript
327327
* If a witnessScript is provided, the scriptPubKey or the redeemScript must be for that witnessScript
328+
* If a sighash type is provided, the signer must check that the sighash is acceptable. If unacceptable, they must fail.
329+
* If a sighash type is not provided, the signer should sign using SIGHASH_ALL, but may use any sighash type they wish.
328330
329331
=====Simple Signer Algorithm=====
330332

331333
A simple signer can use the following algorithm to determine what and how to sign
332334

333335
<pre>
334336
sign_witness(script_code, i):
335-
for key in psbt.inputs[i].keys:
336-
if IsMine(key):
337+
for key, sighash_type in psbt.inputs[i].items:
338+
if sighash_type == None:
339+
sighash_type = SIGHASH_ALL
340+
if IsMine(key) and IsAcceptable(sighash_type):
337341
sign(witness_sighash(script_code, i, input))
338342

339343
sign_non_witness(script_code, i):
340-
for key in psbt.inputs[i].keys:
341-
if IsMine(key):
344+
for key, sighash_type in psbt.inputs[i].items:
345+
if sighash_type == None:
346+
sighash_type = SIGHASH_ALL
347+
if IsMine(key) and IsAcceptable(sighash_type):
342348
sign(non_witness_sighash(script_code, i, input))
343349

344350
for input,i in enumerate(psbt.inputs):

0 commit comments

Comments
 (0)