Example transaction updates (P2SH tx)

This commit is contained in:
thephez 2017-12-12 16:19:03 -05:00
parent 1c6f8b06c9
commit 1e3bb6bb43

View file

@ -917,15 +917,15 @@ called m-of-n, and in this case we'll be using 2-of-3.
{% highlight bash %} {% highlight bash %}
> dash-cli -regtest getnewaddress > dash-cli -regtest getnewaddress
mhAXF4Eq7iRyvbYk1mpDVBiGdLP3YbY6Dm yYtWtpW7akCc2a5En8NsXeTGENyYbNgv9q
> dash-cli -regtest getnewaddress > dash-cli -regtest getnewaddress
moaCrnRfP5zzyhW8k65f6Rf2z5QpvJzSKe yarm2x9eDFd9dKCycyPigwwj1vfJcYFxsH
> dash-cli -regtest getnewaddress > dash-cli -regtest getnewaddress
mk2QpYatsKicvFVuTAQLBryyccRXMUaGHP yLknHbtnjJRVWQr78aTfCPfNB42jfNkDWK
> NEW_ADDRESS1=mhAXF4Eq7iRyvbYk1mpDVBiGdLP3YbY6Dm > NEW_ADDRESS1=yYtWtpW7akCc2a5En8NsXeTGENyYbNgv9q
> NEW_ADDRESS2=moaCrnRfP5zzyhW8k65f6Rf2z5QpvJzSKe > NEW_ADDRESS2=yarm2x9eDFd9dKCycyPigwwj1vfJcYFxsH
> NEW_ADDRESS3=mk2QpYatsKicvFVuTAQLBryyccRXMUaGHP > NEW_ADDRESS3=yLknHbtnjJRVWQr78aTfCPfNB42jfNkDWK
{% endhighlight %} {% endhighlight %}
Generate three new P2PKH addresses. P2PKH addresses cannot be used with Generate three new P2PKH addresses. P2PKH addresses cannot be used with
@ -947,21 +947,22 @@ redeem script. You must give them a full public key.
{% endhighlight %} {% endhighlight %}
{% highlight json %} {% highlight json %}
{ {
"isvalid" : true, "isvalid": true,
"address" : "mk2QpYatsKicvFVuTAQLBryyccRXMUaGHP", "address": "yLknHbtnjJRVWQr78aTfCPfNB42jfNkDWK",
"scriptPubKey" : "76a9143172b5654f6683c8fb146959d347ce303cae4ca788ac", "scriptPubKey": "76a91404caa000366b99780f8e606ccc818883ca7f48f888ac",
"ismine" : true, "ismine": true,
"iswatchonly" : false, "iswatchonly": false,
"isscript" : false, "isscript": false,
"pubkey" : "029e03a901b85534ff1e92c43c74431f7ce72046060fcf7a\ "pubkey": "038007ef6fd812d73da054271b68a42dae06672cff2a30b2814935537e593\
95c37e148f78c77255", 0ebf6",
"iscompressed" : true, "iscompressed": true,
"account" : "" "account": ""
} }
{% endhighlight %} {% endhighlight %}
{% highlight bash %} {% highlight bash %}
> NEW_ADDRESS3_PUBLIC_KEY=029e03a901b85534ff1e92c43c74431f7ce720[...] > NEW_ADDRESS3_PUBLIC_KEY=038007ef6fd812d73da054271b68a42dae0667[...]
{% endhighlight %} {% endhighlight %}
</div> </div>
@ -984,17 +985,17 @@ We save the address returned to a shell variable.
{% endhighlight %} {% endhighlight %}
{% highlight json %} {% highlight json %}
{ {
"address" : "2N7NaqSKYQUeM8VNgBy8D9xQQbiA8yiJayk", "address": "8meEZF54K7GxhHhdLCCeNwFQjHENv4CK86",
"redeemScript" : "522103310188e911026cf18c3ce274e0ebb5f95b00\ "redeemScript": "522103fa8866cccae3c975a72884443a351801a0ea9721cbe721558\
7f230d8cb7d09879d96dbeab1aff210243930746e6ed6552e03359db521b\ 6ddd6fab5f39f262103b2259f42a241f4870e794521594f2af7aadf0\
088134652905bd2d1541fa9124303a41e95621029e03a901b85534ff1e92\ e4c580a43582e58630e4618634621038007ef6fd812d73da054271b6\
c43c74431f7ce72046060fcf7a95c37e148f78c7725553ae" 8a42dae06672cff2a30b2814935537e5930ebf653ae"
} }
{% endhighlight %} {% endhighlight %}
{% highlight bash %} {% highlight bash %}
> P2SH_ADDRESS=2N7NaqSKYQUeM8VNgBy8D9xQQbiA8yiJayk > P2SH_ADDRESS=8meEZF54K7GxhHhdLCCeNwFQjHENv4CK86
> P2SH_REDEEM_SCRIPT=522103310188e911026cf18c3ce274e0ebb5f95b007[...] > P2SH_REDEEM_SCRIPT=522103fa8866cccae3c975a72884443a351801a0ea9[...]
{% endhighlight %} {% endhighlight %}
</div> </div>
@ -1026,9 +1027,9 @@ you should also make a new backup.
{% highlight bash %} {% highlight bash %}
> dash-cli -regtest sendtoaddress $P2SH_ADDRESS 10.00 > dash-cli -regtest sendtoaddress $P2SH_ADDRESS 10.00
7278d7d030f042ebe633732b512bcb31fff14a697675a1fe1884db139876e175 ddb2a2eb2402a9ae61d7db93a9a48c0747859d899e704b10f5b72145779f9c52
> UTXO_TXID=7278d7d030f042ebe633732b512bcb31fff14a697675a1fe1884[...] > UTXO_TXID=ddb2a2eb2402a9ae61d7db93a9a48c0747859d899e704b10f5b7[...]
{% endhighlight %} {% endhighlight %}
Paying the P2SH multisig address with Dash Core is as simple as Paying the P2SH multisig address with Dash Core is as simple as
@ -1046,66 +1047,72 @@ We save that txid to a shell variable as the txid of the UTXO we plan to spend n
{% endhighlight %} {% endhighlight %}
{% highlight json %} {% highlight json %}
{ {
"hex" : "0100000001f0ede03d75050f20801d50358829ae02c058e8677\ "hex": "010000000130d100f7762956100a2396403c60e13e7a13520167acc6d38978ec\
d2cc74df51f738285013c26010000006a47304402203c375959\ 33ada44cf8010000006b48304502210084effe3132550e6ba43a7f4cc54ad30d\
2bf608ab79c01596c4a417f3110dd6eb776270337e575cdafc6\ 001c0dbc3ea66d638e5f3d6039a28c2b022044c8cd89cf455b8650fe259306eb\
99af20220317ef140d596cc255a4067df8125db7f349ad94521\ 2a30b0112969717e469a722bca0263e0975d01210324c2226564b19f0948306b\
2e9264a87fa8d777151937012102a92913b70f9fb15a7ea5c42\ b7160a735c28001bbd046cd46059df9f8434f41254feffffff0200ca9a3b0000\
df44637f0de26e2dad97d6d54957690b94cf2cd05ffffffff01\ 000017a9144f334f26e350c8903c92ff25b733670902cfad5a8700e0052d0b00\
00ca9a3b0000000017a9149af61346ce0aa2dffcf697352b4b7\ 00001976a91479165c2155b8fec5c702ec7f251d0982f27b402988ac67000000",
04c84dcbaff8700000000", "txid": "ddb2a2eb2402a9ae61d7db93a9a48c0747859d899e704b10f5b72145779f9c52",
"txid" : "7278d7d030f042ebe633732b512bcb31fff14a697675a1fe18\ "size": 224,
84db139876e175", "version": 1,
"hash" : "7278d7d030f042ebe633732b512bcb31fff14a697675a1fe1884db139876e175", "locktime": 103,
"size" : 189, "vin": [
"vsize" : 189, {
"version" : 1, "txid": "f84ca4ad33ec7889d3c6ac670152137a3ee1603c4096230a10562976f70\
"locktime" : 0, 0d130",
"vin" : [ "vout": 1,
{ "scriptSig": {
"txid" : "263c018582731ff54dc72c7d67e858c002ae298835\ "asm": "304502210084effe3132550e6ba43a7f4cc54ad30d001c0dbc3ea66d63\
501d80200f05753de0edf0", 8e5f3d6039a28c2b022044c8cd89cf455b8650fe259306eb2a30b01129\
"vout" : 1, 69717e469a722bca0263e0975d[ALL] 0324c2226564b19f0948306bb7\
"scriptSig" : { 160a735c28001bbd046cd46059df9f8434f41254",
"asm" : "304402203c3759592bf608ab79c01596c4a417f\ "hex": "48304502210084effe3132550e6ba43a7f4cc54ad30d001c0dbc3ea66d\
3110dd6eb776270337e575cdafc699af2022031\ 638e5f3d6039a28c2b022044c8cd89cf455b8650fe259306eb2a30b011\
7ef140d596cc255a4067df8125db7f349ad9452\ 2969717e469a722bca0263e0975d01210324c2226564b19f0948306bb7\
12e9264a87fa8d77715193701 160a735c28001bbd046cd46059df9f8434f41254"
02a92913b70f9fb15a7ea5c42df44637f0de26e\ },
2dad97d6d54957690b94cf2cd05", "sequence": 4294967294
"hex" : "47304402203c3759592bf608ab79c01596c4a41\ }
7f3110dd6eb776270337e575cdafc699af20220\ ],
317ef140d596cc255a4067df8125db7f349ad94\ "vout": [
5212e9264a87fa8d777151937012102a92913b7\ {
0f9fb15a7ea5c42df44637f0de26e2dad97d6d5\ "value": 10.00000000,
4957690b94cf2cd05" "valueSat": 1000000000,
}, "n": 0,
"sequence" : 4294967295 "scriptPubKey": {
} "asm": "OP_HASH160 4f334f26e350c8903c92ff25b733670902cfad5a OP_EQUAL",
], "hex": "a9144f334f26e350c8903c92ff25b733670902cfad5a87",
"vout" : [ "reqSigs": 1,
{ "type": "scripthash",
"value" : 10.00000000, "addresses": [
"n" : 0, "8meEZF54K7GxhHhdLCCeNwFQjHENv4CK86"
"scriptPubKey" : { ]
"asm" : "OP_HASH160 9af61346ce0aa2dffcf697352b4b\ }
704c84dcbaff OP_EQUAL", },
"hex" : "a9149af61346ce0aa2dffcf697352b4b704c84d\ {
cbaff87", "value": 480.00000000,
"reqSigs" : 1, "valueSat": 48000000000,
"type" : "scripthash", "n": 1,
"addresses" : [ "scriptPubKey": {
"2N7NaqSKYQUeM8VNgBy8D9xQQbiA8yiJayk" "asm": "OP_DUP OP_HASH160 79165c2155b8fec5c702ec7f251d0982f27b4029\
] OP_EQUALVERIFY OP_CHECKSIG",
} "hex": "76a91479165c2155b8fec5c702ec7f251d0982f27b402988ac",
} "reqSigs": 1,
] "type": "pubkeyhash",
"addresses": [
"yXMhQ1L5q3PcnJgEhyAFztQPPRaEr8Mh8s"
]
}
}
]
} }
{% endhighlight %} {% endhighlight %}
{% highlight bash %} {% highlight bash %}
> UTXO_VOUT=0 > UTXO_VOUT=0
> UTXO_OUTPUT_SCRIPT=a9149af61346ce0aa2dffcf697352b4b704c84dcbaff87 > UTXO_OUTPUT_SCRIPT=a9144f334f26e350c8903c92ff25b733670902cfad5a87
{% endhighlight %} {% endhighlight %}
</div> </div>
@ -1116,9 +1123,9 @@ its output index number (vout) and pubkey script (scriptPubKey).
{% highlight bash %} {% highlight bash %}
> dash-cli -regtest getnewaddress > dash-cli -regtest getnewaddress
mxCNLtKxzgjg8yyNHeuFSXvxCvagkWdfGU yZSxAakpoWGG3vcsvpk9qNtsYREhump4Cr
> NEW_ADDRESS4=mxCNLtKxzgjg8yyNHeuFSXvxCvagkWdfGU > NEW_ADDRESS4=yZSxAakpoWGG3vcsvpk9qNtsYREhump4Cr
{% endhighlight %} {% endhighlight %}
We generate a new P2PKH address to use in the output we're about to We generate a new P2PKH address to use in the output we're about to
@ -1138,11 +1145,15 @@ create.
"'$NEW_ADDRESS4'": 9.998 "'$NEW_ADDRESS4'": 9.998
}''' }'''
0100000001529c9f774521b7f5104b709e899d8547078ca4a993dbd761aea902\
24eba2b2dd0000000000ffffffff01c0bc973b000000001976a914900504f96c\
55d6ebe1c33581ba9430ca05b12a1488ac00000000
010000000175e1769813db8418fea17576694af1ff31cb2b512b7333e6eb42f0\ 010000000175e1769813db8418fea17576694af1ff31cb2b512b7333e6eb42f0\
30d0d778720000000000ffffffff01c0bc973b000000001976a914b6f64f5bf3\ 30d0d778720000000000ffffffff01c0bc973b000000001976a914b6f64f5bf3\
e38f25ead28817df7929c06fe847ee88ac00000000 e38f25ead28817df7929c06fe847ee88ac00000000
> RAW_TX=010000000175e1769813db8418fea17576694af1ff31cb2b512b733[...] > RAW_TX=0100000001529c9f774521b7f5104b709e899d8547078ca4a993dbd[...]
{% endhighlight %} {% endhighlight %}
We generate the raw transaction the same way we did in the Simple Raw We generate the raw transaction the same way we did in the Simple Raw
@ -1150,12 +1161,12 @@ Transaction subsection.
{% highlight bash %} {% highlight bash %}
> dash-cli -regtest dumpprivkey $NEW_ADDRESS1 > dash-cli -regtest dumpprivkey $NEW_ADDRESS1
cVinshabsALz5Wg4tGDiBuqEGq4i6WCKWXRQdM8RFxLbALvNSHw7 cThhxbQUtBDzHZbZrW6XAR4XkXfaQf4Abo7BQaTK2zVp7sVrHdmv
> dash-cli -regtest dumpprivkey $NEW_ADDRESS3 > dash-cli -regtest dumpprivkey $NEW_ADDRESS3
cNmbnwwGzEghMMe1vBwH34DFHShEj5bcXD1QpFRPHgG9Mj1xc5hq cUbYymPeHhRszTn64Xg7dzYKez8YC83M39ZTPJDiBDu8dRD3EjzF
> NEW_ADDRESS1_PRIVATE_KEY=cVinshabsALz5Wg4tGDiBuqEGq4i6WCKWXRQd[...] > NEW_ADDRESS1_PRIVATE_KEY=cThhxbQUtBDzHZbZrW6XAR4XkXfaQf4Abo7BQ[...]
> NEW_ADDRESS3_PRIVATE_KEY=cNmbnwwGzEghMMe1vBwH34DFHShEj5bcXD1Qp[...] > NEW_ADDRESS3_PRIVATE_KEY=cUbYymPeHhRszTn64Xg7dzYKez8YC83M39ZTP[...]
{% endhighlight %} {% endhighlight %}
We get the private keys for two of the public keys we used to create the We get the private keys for two of the public keys we used to create the
@ -1186,18 +1197,32 @@ complex raw transaction].
{% endhighlight %} {% endhighlight %}
{% highlight json %} {% highlight json %}
{ {
"hex" : "010000000175e1769813db8418fea17576694af1ff31cb2b512\ "hex": "0100000001529c9f774521b7f5104b709e899d8547078ca4a993dbd761aea902\
b7333e6eb42f030d0d7787200000000b5004830450221008d5e\ 24eba2b2dd00000000b40047304402201cc50eac6d2db04dabd8ccd68b3116c0\
c57d362ff6ef6602e4e756ef1bdeee12bd5c5c72697ef1455b3\ a8d37e7e41335e0d0ab441a5aa08cdcd02204011d184dca2489758c05e01556f\
79c90531002202ef3ea04dfbeda043395e5bc701e4878c15baa\ f2ff9c48c39ff434fdfb1d9e0284fbde7701014c69522103fa8866cccae3c975\
b9c6ba5808eb3d04c91f641a0c014c69522103310188e911026\ a72884443a351801a0ea9721cbe7215586ddd6fab5f39f262103b2259f42a241\
cf18c3ce274e0ebb5f95b007f230d8cb7d09879d96dbeab1aff\ f4870e794521594f2af7aadf0e4c580a43582e58630e4618634621038007ef6f\
210243930746e6ed6552e03359db521b088134652905bd2d154\ d812d73da054271b68a42dae06672cff2a30b2814935537e5930ebf653aeffff\
1fa9124303a41e95621029e03a901b85534ff1e92c43c74431f\ ffff01c0bc973b000000001976a914900504f96c55d6ebe1c33581ba9430ca05\
7ce72046060fcf7a95c37e148f78c7725553aeffffffff01c0b\ b12a1488ac00000000",
c973b000000001976a914b6f64f5bf3e38f25ead28817df7929\ "complete": false,
c06fe847ee88ac00000000", "errors": [
"complete" : false {
"txid": "ddb2a2eb2402a9ae61d7db93a9a48c0747859d899e704b10f5b72145779\
f9c52",
"vout": 0,
"scriptSig": "0047304402201cc50eac6d2db04dabd8ccd68b3116c0a8d37e7e41\
335e0d0ab441a5aa08cdcd02204011d184dca2489758c05e01556f\
f2ff9c48c39ff434fdfb1d9e0284fbde7701014c69522103fa8866\
cccae3c975a72884443a351801a0ea9721cbe7215586ddd6fab5f3\
9f262103b2259f42a241f4870e794521594f2af7aadf0e4c580a43\
582e58630e4618634621038007ef6fd812d73da054271b68a42dae\
06672cff2a30b2814935537e5930ebf653ae",
"sequence": 4294967295,
"error": "Operation not valid with the current stack size"
}
]
} }
{% endhighlight %} {% endhighlight %}
{% highlight bash %} {% highlight bash %}
@ -1228,26 +1253,23 @@ to the signature script after the two signatures.
{% endhighlight %} {% endhighlight %}
{% highlight json %} {% highlight json %}
{ {
"hex" : "010000000175e1769813db8418fea17576694af1ff31cb2b512\ "hex": "0100000001529c9f774521b7f5104b709e899d8547078ca4a993dbd761aea902\
b7333e6eb42f030d0d7787200000000fdfd0000483045022100\ 24eba2b2dd00000000fdfd000047304402201cc50eac6d2db04dabd8ccd68b31\
8d5ec57d362ff6ef6602e4e756ef1bdeee12bd5c5c72697ef14\ 16c0a8d37e7e41335e0d0ab441a5aa08cdcd02204011d184dca2489758c05e01\
55b379c90531002202ef3ea04dfbeda043395e5bc701e4878c1\ 556ff2ff9c48c39ff434fdfb1d9e0284fbde770101483045022100e0e1f95f1a\
5baab9c6ba5808eb3d04c91f641a0c0147304402200bd8c62b9\ b85814ee0920d5bd28c6831086e838af4bec344fd8654a0b58525f022075989f\
38e02094021e481b149fd5e366a212cb823187149799a68cfa7\ d3a677e1522aa85d45c41720aec9e7c127acadb6c14338c3b1a768ab28014c69\
652002203b52120c5cf25ceab5f0a6b5cdb8eca0fd2f386316c\ 522103fa8866cccae3c975a72884443a351801a0ea9721cbe7215586ddd6fab5\
9721177b75ddca82a4ae8014c69522103310188e911026cf18c\ f39f262103b2259f42a241f4870e794521594f2af7aadf0e4c580a43582e5863\
3ce274e0ebb5f95b007f230d8cb7d09879d96dbeab1aff21024\ 0e4618634621038007ef6fd812d73da054271b68a42dae06672cff2a30b28149\
3930746e6ed6552e03359db521b088134652905bd2d1541fa91\ 35537e5930ebf653aeffffffff01c0bc973b000000001976a914900504f96c55\
24303a41e95621029e03a901b85534ff1e92c43c74431f7ce72\ d6ebe1c33581ba9430ca05b12a1488ac00000000",
046060fcf7a95c37e148f78c7725553aeffffffff01c0bc973b\ "complete": true
000000001976a914b6f64f5bf3e38f25ead28817df7929c06fe\
847ee88ac00000000",
"complete" : true
} }
{% endhighlight %} {% endhighlight %}
{% highlight bash %} {% highlight bash %}
> SIGNED_RAW_TX=010000000175e1769813db8418fea17576694af1ff31cb2b[...] > SIGNED_RAW_TX=0100000001529c9f774521b7f5104b709e899d8547078ca4[...]
{% endhighlight %} {% endhighlight %}
</div> </div>
@ -1258,7 +1280,7 @@ complete.
{% highlight bash %} {% highlight bash %}
> dash-cli -regtest sendrawtransaction $SIGNED_RAW_TX > dash-cli -regtest sendrawtransaction $SIGNED_RAW_TX
430a4cee3a55efb04cbb8718713cab18dea7f2521039aa660ffb5aae14ff3f50 483061b32894aacf6c4050291252a480c2a4c869eb85bd45082fb87d6b175ae8
{% endhighlight %} {% endhighlight %}
We send the transaction spending the P2SH multisig output to the local We send the transaction spending the P2SH multisig output to the local