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