1
This question is a continuation of the my post yesterday.
Today I have a question on P2SH execution so, an example of the script should be this
OP_0 <A Signature> <B Signature> OP_2 <Public key A> <Public key B>
<Public key C> OP_3 OP_CHECKMULTISIG
OP_HASH160 <ScriptSig Hash> OP_EQUAL
or if used the P2SH key should be is this (I think in this script left-hand something to convert the hash160 inside the P2SH key, right?)
OP_0 <A Signature> <B Signature> OP_2 <Public key A> <Public key B>
<Public key C> OP_3 OP_CHECKMULTISIG
OP_HASH160 <P2SH key> OP_EQUAL
Now if I have understood well the simulation of the execution is divided into two phases
- The hash
scriptSigis equal to hash inside thescriptPubKey
Simulation
- Put on the
scriptSigon the stack, so the stack now is<A sig> <B sig> <A pubkey> <B pubkey> <C pubkey> - Calculate the
hash160with the data inside the stack, so now the stack status is<scriptSig hash> - Put on the
scriptSighash expected, now the stack status is<hash scriptsig> <hash scriptsigexpected> - return the result of the operator
OP_EQUAL(true or false)
- the
scriptSigwill execute such as the script multi-signature
Simulation
- put on the stack the
scriptSig, the stack status is<A Signature> <B Signature> - push the public keys, that stack status is
<A Signature> <B Signature> <Public key A> <Public key B> <Public key C> - apply the
OP_CHECKMULTISIGoperator and get the result
My questions are:
- With the P2SH key, the execution is the same? if not, what is the form of the P2SH with the P2SH key?
Also, I read this post but I don't think contains this answer.
If my example script is wrong, I'm sorry to give me a corrections
Thanks for your answer, I have a question, exist some operator inside bitcoin script for calculate the Base58Check? – vincenzopalazzo – 2019-09-18T08:16:54.703
@vincenzopalazzo Base58check encoding is for human readability. It is for humans to distinguish whether the address generated/being sent to is P2PKH or P2SH. It does not have any meaning inside the software. – Ugam Kamat – 2019-09-18T08:58:39.520
My fault, I have jump this note "Note: If you just insert the address starting with 3, the software will automatically calculate the scriptPubKey as above." – vincenzopalazzo – 2019-09-18T09:31:25.750
1@vincenzopalazzo What I meant was, as a user you just enter an address starting with 3. The wallet software then transitions it to the scriptPubKey. – Ugam Kamat – 2019-09-18T09:37:39.793
1@vincenzopalazzo as further clarification, addresses are not sent over the wire nor stored in the blockchain. Addresses are only for human readability. So when a user enters an address starting with 3.., the wallet software decodes the base58check, extracts the redeem_script_hash and uses
OP_HASH160 <redeem_scripthash> OP_EQUALas the scriptPubKey. If your address began with 1, the wallet software will useOP_DUP OP_HASH160 <redeem_scripthash> OP_EQUALVERIFY OP_CHECKSIGas scriptPubKey. – Ugam Kamat – 2019-09-18T09:46:28.657Yes thanks for your clarification, you have help me :) – vincenzopalazzo – 2019-09-18T09:49:43.103