mirror of
https://github.com/bitcoin/bips.git
synced 2025-05-12 12:03:29 +00:00
Merge pull request #800 from junderw/junderw-patch-1
BIP174: Include suggested sighash check
This commit is contained in:
commit
6a25c1478f
@ -325,6 +325,8 @@ For a Signer to only produce valid signatures for what it expects to sign, it mu
|
|||||||
* If a witness UTXO is provided, no non-witness signature may be created
|
* If a witness UTXO is provided, no non-witness signature may be created
|
||||||
* If a redeemScript is provided, the scriptPubKey must be for that redeemScript
|
* If a redeemScript is provided, the scriptPubKey must be for that redeemScript
|
||||||
* If a witnessScript is provided, the scriptPubKey or the redeemScript must be for that witnessScript
|
* If a witnessScript is provided, the scriptPubKey or the redeemScript must be for that witnessScript
|
||||||
|
* If a sighash type is provided, the signer must check that the sighash is acceptable. If unacceptable, they must fail.
|
||||||
|
* If a sighash type is not provided, the signer should sign using SIGHASH_ALL, but may use any sighash type they wish.
|
||||||
|
|
||||||
=====Simple Signer Algorithm=====
|
=====Simple Signer Algorithm=====
|
||||||
|
|
||||||
@ -332,13 +334,17 @@ A simple signer can use the following algorithm to determine what and how to sig
|
|||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
sign_witness(script_code, i):
|
sign_witness(script_code, i):
|
||||||
for key in psbt.inputs[i].keys:
|
for key, sighash_type in psbt.inputs[i].items:
|
||||||
if IsMine(key):
|
if sighash_type == None:
|
||||||
|
sighash_type = SIGHASH_ALL
|
||||||
|
if IsMine(key) and IsAcceptable(sighash_type):
|
||||||
sign(witness_sighash(script_code, i, input))
|
sign(witness_sighash(script_code, i, input))
|
||||||
|
|
||||||
sign_non_witness(script_code, i):
|
sign_non_witness(script_code, i):
|
||||||
for key in psbt.inputs[i].keys:
|
for key, sighash_type in psbt.inputs[i].items:
|
||||||
if IsMine(key):
|
if sighash_type == None:
|
||||||
|
sighash_type = SIGHASH_ALL
|
||||||
|
if IsMine(key) and IsAcceptable(sighash_type):
|
||||||
sign(non_witness_sighash(script_code, i, input))
|
sign(non_witness_sighash(script_code, i, input))
|
||||||
|
|
||||||
for input,i in enumerate(psbt.inputs):
|
for input,i in enumerate(psbt.inputs):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user