Skip to content

Commit 97447f9

Browse files
authored
BIP174: Include suggested sighash check
1 parent 8f92057 commit 97447f9

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
@@ -319,20 +319,26 @@ For a Signer to only produce valid signatures for what it expects to sign, it mu
319319
* If a witness UTXO is provided, no non-witness signature may be created
320320
* If a redeemScript is provided, the scriptPubKey must be for that redeemScript
321321
* If a witnessScript is provided, the scriptPubKey or the redeemScript must be for that witnessScript
322+
* If a sighash type is provided, the signer must check that the sighash is acceptable. If unacceptable, they must fail.
323+
* If a sighash type is not provided, the signer should sign using SIGHASH_ALL, but may use any sighash type they wish.
322324
323325
=====Simple Signer Algorithm=====
324326

325327
A simple signer can use the following algorithm to determine what and how to sign
326328

327329
<pre>
328330
sign_witness(script_code, i):
329-
for key in psbt.inputs[i].keys:
330-
if IsMine(key):
331+
for key, sighash_type in psbt.inputs[i].items:
332+
if sighash_type == None:
333+
sighash_type = SIGHASH_ALL
334+
if IsMine(key) and IsAcceptable(sighash_type):
331335
sign(witness_sighash(script_code, i, input))
332336

333337
sign_non_witness(script_code, i):
334-
for key in psbt.inputs[i].keys:
335-
if IsMine(key):
338+
for key, sighash_type in psbt.inputs[i].items:
339+
if sighash_type == None:
340+
sighash_type = SIGHASH_ALL
341+
if IsMine(key) and IsAcceptable(sighash_type):
336342
sign(non_witness_sighash(script_code, i, input))
337343

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

0 commit comments

Comments
 (0)