Conversation
|
I was meaning to mention this on the previous PRs. Is there any point to including the base64 encoding as well? The translation from hex is pretty straightforward. Just thinking it would cut down on the verbosity a bit. |
The point was to effectively provide the two forms that a PSBT would be found in: as a binary file or as a Base64 string. It helps those who are writing tests to know exactly what to expect especially since there are (apparently) multiple ways of doing Base 64. |
https://en.wikipedia.org/wiki/Base64#Variants_summary_table so it seems... seems reasonable to include it in that case, or alternatively an explicit mention of which variant is used. |
|
@luke-jr This is ready. |
|
I updated this with some parts that specify what signers should look out for and an algorithm for a simple signer. Also more tests for those. |
bip-0174.mediawiki
Outdated
|
|
||
| For a Signer to only produce valid signatures for what it expects to sign, it must check that the following conditions are true: | ||
|
|
||
| * If a non-witness UTXO is provided, it's hash must match the hash specified in the prevout |
bip-0174.mediawiki
Outdated
|
|
||
| for input,i in enumerate(psbt.inputs): | ||
| if non_witness_utxo.exists: | ||
| assert(sha256d(non_witness_utxo) == prevhash) |
There was a problem hiding this comment.
write prevhash as psbt.tx.input[i].prevout.hash?
bip-0174.mediawiki
Outdated
| if non_witness_utxo.exists: | ||
| assert(sha256d(non_witness_utxo) == prevhash) | ||
| if redeemScript.exists: | ||
| assert(non_witness_utxo.scriptPubKey == P2SH(redeemScript)) |
There was a problem hiding this comment.
Write as non_witness_utxo.vout[psbt.tx.input[i].prevout.n].scriptPubKey ?
bip-0174.mediawiki
Outdated
| For a Signer to only produce valid signatures for what it expects to sign, it must check that the following conditions are true: | ||
|
|
||
| * If a non-witness UTXO is provided, it's hash must match the hash specified in the prevout | ||
| * If a witness UTXO is provided, a witness signature is being produced |
There was a problem hiding this comment.
Perhaps write this as "If a witness UTXO is provided, no non-witness signature may be created"? The current language sounds like a signature must be created.
bip-0174.mediawiki
Outdated
| sign_non_witness(non_witness_utxo.scriptPubKey) | ||
| else if witness_utxo.exists: | ||
| if redeemScript.exists: | ||
| assert(witness_utxos.scriptPubKey == P2SH(redeemScript)) |
bip-0174.mediawiki
Outdated
| else: | ||
| script = witness_utxo.scriptPubKey | ||
| if IsP2WPKH(script): | ||
| sign_witness(P2PKH(script)) |
There was a problem hiding this comment.
You can't really convert a script to P2PKH. What about P2PKH(script[2:])?
Test cases for what signers should check for
No description provided.