@@ -319,20 +319,26 @@ For a Signer to only produce valid signatures for what it expects to sign, it mu
319
319
* If a witness UTXO is provided, no non-witness signature may be created
320
320
* If a redeemScript is provided, the scriptPubKey must be for that redeemScript
321
321
* 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.
322
324
323
325
=====Simple Signer Algorithm =====
324
326
325
327
A simple signer can use the following algorithm to determine what and how to sign
326
328
327
329
<pre>
328
330
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):
331
335
sign(witness_sighash(script_code, i, input))
332
336
333
337
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):
336
342
sign(non_witness_sighash(script_code, i, input))
337
343
338
344
for input,i in enumerate(psbt.inputs):
0 commit comments