Clone and prepare shagate repo:
$ npm install -g ts-node
$ npm install -g cashc
$ git clone https://github.com/smartbch/shagate.git
$ cd shagate
$ npm install
Open cc_covenant_v1_testnet.ts, change rootSeet's mnemonic words to get a set of clean testing accounts:
...
const rootSeed = bitbox.Mnemonic.toSeed('cc_covenant_v1_testnet_xxx');
...
Note, for testing purpose, the covenant was modified in following places:
- for voting, coinbase tx check is disabled
//require(hash160(coinbaseTx.split(4)[1].split(37)[0]) == 0x282711cb97968c8674a46b5564ce3549f5782ea4);
require(hash160(coinbaseTx.split(4)[1].split(37)[0]) != 0x282711cb97968c8674a46b5564ce3549f5782ea4);
- for finish unlock, waiting time is shortened
//require(tx.age >= 150);
require(tx.age >= 2);
Show address of contract that hold funds:
$ ts-node cc_covenant_v1_testnet.ts contract-info \
--receiver=hash160:0000000000000000000000000000000000000000 \
--yes-vote=0 \
--no-vote=0
0) opAddrsHash: 8fc28a31ce851e2e9d3819b0e5d064ce67d4ddaa
1) receiverPkh: 0000000000000000000000000000000000000000
2) yesNoBytes : 00000000
contract address: bchtest:pq2033lfnl2wse7rfj74j68r246l6kge5s9q26mxpv
contract balance: 0
contract UTXOs : []
Send some BCH to above address (e.g. 20000satoshi):
$ ts-node p2pkh.ts bchtest:pq2033lfnl2wse7rfj74j68r246l6kge5s9q26mxpv 20000
Now our contract has one UTXO:
$ ts-node cc_covenant_v1_testnet.ts contract-info \
--receiver=hash160:0000000000000000000000000000000000000000 \
--yes-vote=0 \
--no-vote=0
>> init cc_covenant, args:
0) opAddrsHash: 8fc28a31ce851e2e9d3819b0e5d064ce67d4ddaa
1) receiverPkh: 0000000000000000000000000000000000000000
2) yesNoBytes : 00000000
contract address: bchtest:pq2033lfnl2wse7rfj74j68r246l6kge5s9q26mxpv
contract balance: 20000
contract UTXOs : [
{
txid: '0166d62e9476a01bc2e02f5c9bdc86892eb817fda20a267e65d9d51338ca10ac',
vout: 0,
satoshis: 20000,
height: 0
}
]
The UTXO that hold the value is '0166d62e9476a01bc2e02f5c9bdc86892eb817fda20a267e65d9d51338ca10ac:0', we will unlock it soon.
Lets see who is Alice:
$ ts-node cc_covenant_v1_testnet.ts alice-info
cash addr: bchtest:qp0yar50xunn7wyazdsyqcfwwf2uqkcghsy8ngukht
utxos: []
Her unlocking contract address is:
$ ts-node cc_covenant_v1_testnet.ts contract-info \
--receiver=bchtest:qp0yar50xunn7wyazdsyqcfwwf2uqkcghsy8ngukht \
--yes-vote=0 \
--no-vote=0
>> init cc_covenant, args:
0) opAddrsHash: 8fc28a31ce851e2e9d3819b0e5d064ce67d4ddaa
1) receiverPkh: 5e4e8e8f37273f389d136040612e7255c05b08bc
2) yesNoBytes : 00000000
contract address: bchtest:pq6qpkj2zsx2aatlfanr0hh6hguds0dc0sae590z3c
contract balance: 0
contract UTXOs : []
Let operator0 init unlock for Alice:
$ ts-node cc_covenant_v1_testnet.ts init-unlock \
--receiver=bchtest:qp0yar50xunn7wyazdsyqcfwwf2uqkcghsy8ngukht \
--utxo=0166d62e9476a01bc2e02f5c9bdc86892eb817fda20a267e65d9d51338ca10ac:0
>> init cc_covenant, args:
0) opAddrsHash: 8fc28a31ce851e2e9d3819b0e5d064ce67d4ddaa
1) receiverPkh: 0000000000000000000000000000000000000000
2) yesNoBytes : 00000000
fromContract address: bchtest:pq2033lfnl2wse7rfj74j68r246l6kge5s9q26mxpv
fromContract balance: 20000
>> init cc_covenant, args:
0) opAddrsHash: 8fc28a31ce851e2e9d3819b0e5d064ce67d4ddaa
1) receiverPkh: 5e4e8e8f37273f389d136040612e7255c05b08bc
2) yesNoBytes : 00000000
toContract address : bchtest:pq6qpkj2zsx2aatlfanr0hh6hguds0dc0sae590z3c
toContract balance : 0
fromContract UTXOs : [
{
txid: '0166d62e9476a01bc2e02f5c9bdc86892eb817fda20a267e65d9d51338ca10ac',
vout: 0,
satoshis: 20000,
height: 0
}
]
transaction details: {
"inputs": [
{
"outpointIndex": 0,
"outpointTransactionHash": "<Uint8Array: 0x0166d62e9476a01bc2e02f5c9bdc86892eb817fda20a267e65d9d51338ca10ac>",
"sequenceNumber": 4294967294,
"unlockingBytecode": "<Uint8Array: 0x00000004000000000014dd03b54ba1f42ac7c449adec13fb2b3dcfa12a21145a98671aaaeb7447adfcd62eba636457379673c014bc3991702a53462789215923e87901971c17bc88145e4e8e8f37273f389d136040612e7255c05b08bc21036332cabae714ed0e960b5c2a9e67d03ab445e82efb3eb29661ce039276d9177841ad2602f54acbdebd7793ca5fe0ff8f16934c7cae5c71bc85f64d841fa21bb0b1eb4635b23526edea96421e40b2a96612698e6f0540e33b645b16842b8300fb1e414de60102000000e022baee25ceea1f20346ea6edd0cee02e04436ed664e003f3fb4317e6d7d6c618606b350cd8bf565266bc352f0caddcf01e8fa789dd8a15386327cf8cabe198ac10ca3813d5d9657e260aa2fd17b82e8986dc9b5c2fe0c21ba076942ed6660100000000fd47010400000000140000000000000000000000000000000000000000148fc28a31ce851e2e9d3819b0e5d064ce67d4ddaa5379547f7701207f01207f7701247f537f77820134947f587f547f7701207f75597a5a796e7c828c7f755c7aa87bbbad060400000000145a7a7e5379011a7f777e587a8101117a635979a959798852b2757603e09304967802307597a269675f79009c635979a95b795d797e5e797ea9597988765c7987785e79879b785f79879b697803e09304965279023075979f63022c01b2756875675d79547f7701257f75a914282711cb97968c8674a46b5564ce3549f5782ea487916955795e79aa7e5f797eaa5779885d7960797f7701247f7556798860796376023075937767768b7768547854807e5579557f777e7b757c6853798102b80b945880760317a9147e5379a97e01877e76aa5579886d686d6d6d6d6d6d6d6d7551204e000000000000feffffffa44c410863b36e71b77221fd7768c45001fe00396899cddcb420ce1e954baf67754b1600410000004d47010400000000140000000000000000000000000000000000000000148fc28a31ce851e2e9d3819b0e5d064ce67d4ddaa5379547f7701207f01207f7701247f537f77820134947f587f547f7701207f75597a5a796e7c828c7f755c7aa87bbbad060400000000145a7a7e5379011a7f777e587a8101117a635979a959798852b2757603e09304967802307597a269675f79009c635979a95b795d797e5e797ea9597988765c7987785e79879b785f79879b697803e09304965279023075979f63022c01b2756875675d79547f7701257f75a914282711cb97968c8674a46b5564ce3549f5782ea487916955795e79aa7e5f797eaa5779885d7960797f7701247f7556798860796376023075937767768b7768547854807e5579557f777e7b757c6853798102b80b945880760317a9147e5379a97e01877e76aa5579886d686d6d6d6d6d6d6d6d7551>"
}
],
"locktime": 1461109,
"outputs": [
{
"lockingBytecode": "<Uint8Array: 0xa9143400da4a140caef57f4f6637defaba38d83db87c87>",
"satoshis": "<Uint8Array: 0x6842000000000000>"
}
],
"version": 2,
"txid": "20c2474bd07bdf7fb67ef309737c41ff208b16a08f098850393d95aaaf3d1b3b",
"hex": "0200000001ac10ca3813d5d9657e260aa2fd17b82e8986dc9b5c2fe0c21ba076942ed6660100000000fdf40300000004000000000014dd03b54ba1f42ac7c449adec13fb2b3dcfa12a21145a98671aaaeb7447adfcd62eba636457379673c014bc3991702a53462789215923e87901971c17bc88145e4e8e8f37273f389d136040612e7255c05b08bc21036332cabae714ed0e960b5c2a9e67d03ab445e82efb3eb29661ce039276d9177841ad2602f54acbdebd7793ca5fe0ff8f16934c7cae5c71bc85f64d841fa21bb0b1eb4635b23526edea96421e40b2a96612698e6f0540e33b645b16842b8300fb1e414de60102000000e022baee25ceea1f20346ea6edd0cee02e04436ed664e003f3fb4317e6d7d6c618606b350cd8bf565266bc352f0caddcf01e8fa789dd8a15386327cf8cabe198ac10ca3813d5d9657e260aa2fd17b82e8986dc9b5c2fe0c21ba076942ed6660100000000fd47010400000000140000000000000000000000000000000000000000148fc28a31ce851e2e9d3819b0e5d064ce67d4ddaa5379547f7701207f01207f7701247f537f77820134947f587f547f7701207f75597a5a796e7c828c7f755c7aa87bbbad060400000000145a7a7e5379011a7f777e587a8101117a635979a959798852b2757603e09304967802307597a269675f79009c635979a95b795d797e5e797ea9597988765c7987785e79879b785f79879b697803e09304965279023075979f63022c01b2756875675d79547f7701257f75a914282711cb97968c8674a46b5564ce3549f5782ea487916955795e79aa7e5f797eaa5779885d7960797f7701247f7556798860796376023075937767768b7768547854807e5579557f777e7b757c6853798102b80b945880760317a9147e5379a97e01877e76aa5579886d686d6d6d6d6d6d6d6d7551204e000000000000feffffffa44c410863b36e71b77221fd7768c45001fe00396899cddcb420ce1e954baf67754b1600410000004d47010400000000140000000000000000000000000000000000000000148fc28a31ce851e2e9d3819b0e5d064ce67d4ddaa5379547f7701207f01207f7701247f537f77820134947f587f547f7701207f75597a5a796e7c828c7f755c7aa87bbbad060400000000145a7a7e5379011a7f777e587a8101117a635979a959798852b2757603e09304967802307597a269675f79009c635979a95b795d797e5e797ea9597988765c7987785e79879b785f79879b697803e09304965279023075979f63022c01b2756875675d79547f7701257f75a914282711cb97968c8674a46b5564ce3549f5782ea487916955795e79aa7e5f797eaa5779885d7960797f7701247f7556798860796376023075937767768b7768547854807e5579557f777e7b757c6853798102b80b945880760317a9147e5379a97e01877e76aa5579886d686d6d6d6d6d6d6d6d7551feffffff01684200000000000017a9143400da4a140caef57f4f6637defaba38d83db87c87754b1600"
}
Now the unlocking contract is waiting to be voted:
$ ts-node cc_covenant_v1_testnet.ts contract-info \
--receiver=bchtest:qp0yar50xunn7wyazdsyqcfwwf2uqkcghsy8ngukht \
--yes-vote=0 \
--no-vote=0
>> init cc_covenant, args:
0) opAddrsHash: 8fc28a31ce851e2e9d3819b0e5d064ce67d4ddaa
1) receiverPkh: 5e4e8e8f37273f389d136040612e7255c05b08bc
2) yesNoBytes : 00000000
contract address: bchtest:pq6qpkj2zsx2aatlfanr0hh6hguds0dc0sae590z3c
contract balance: 17000
contract UTXOs : [
{
txid: '20c2474bd07bdf7fb67ef309737c41ff208b16a08f098850393d95aaaf3d1b3b',
vout: 0,
satoshis: 17000,
height: 1461110
}
]
Now, the UTXO that hold the value (3000 is used as tx fee) is '20c2474bd07bdf7fb67ef309737c41ff208b16a08f098850393d95aaaf3d1b3b:0'.
Let miner0 vote Yes for above unlock, his address is:
$ ts-node cc_covenant_v1_testnet.ts miner-info
cash addr: bchtest:qrtuuggp4qy3nvugjctlnnwcu4u87g3elu47xfz6kf
utxos: []
Give him a fake coinbase UTXO:
$ ts-node cc_covenant_v1_testnet.ts encode-tx-outpoint \
20c2474bd07bdf7fb67ef309737c41ff208b16a08f098850393d95aaaf3d1b3b 0
3b1b3dafaa953d395088098fa0168b20ff417c7309f37eb67fdf7bd04b47c22000000000
$ ts-node p2pkh.ts bchtest:qrtuuggp4qy3nvugjctlnnwcu4u87g3elu47xfz6kf 1000 \
0x3b1b3dafaa953d395088098fa0168b20ff417c7309f37eb67fdf7bd04b47c22000000000 # note the 0x prefix
transaction details:
transaction details: {
"inputs": [
{
"outpointIndex": 2,
"outpointTransactionHash": "<Uint8Array: 0xba49ce3c66ecba4b7100a035ddb6feff66a4b98ae6653b4c8fa2d3c81c7a8e67>",
"sequenceNumber": 4294967294,
"unlockingBytecode": "<Uint8Array: 0x41c197ed3bd646f4ed2aa70cf08635993850aee353d481d5e8115d79035a1c5c8a57f03aac3ed4a84b933205c6d60ad7a75c2d570c41ec13ba7f24c23b35b4a41141210380690473f0f8dcd6f3196e044d4fc160c44597315ccd6a42117f1d6f56cc960819143ed2b14d2418fdf1b384abbf9bbe4a9b9524ca6178a988ac>"
}
],
"locktime": 1461112,
"outputs": [
{
"lockingBytecode": "<Uint8Array: 0x76a914d7ce2101a80919b3889617f9cdd8e5787f2239ff88ac>",
"satoshis": "<Uint8Array: 0xe803000000000000>"
},
{
"lockingBytecode": "<Uint8Array: 0x6a243b1b3dafaa953d395088098fa0168b20ff417c7309f37eb67fdf7bd04b47c22000000000>",
"satoshis": "<Uint8Array: 0x0000000000000000>"
},
{
"lockingBytecode": "<Uint8Array: 0xa91483eb112ad5945d4463cd4a8cd4881fcad8478c7e87>",
"satoshis": "<Uint8Array: 0x66be260400000000>"
}
],
"version": 2,
"txid": "c6c8a79a5d1640bcbded68515902e5d6232c0c118e70079854a9d41e968cda34",
"hex": "0200000001678e7a1cc8d3a28f4c3b65e68ab9a466fffeb6dd35a000714bbaec663cce49ba020000007e41c197ed3bd646f4ed2aa70cf08635993850aee353d481d5e8115d79035a1c5c8a57f03aac3ed4a84b933205c6d60ad7a75c2d570c41ec13ba7f24c23b35b4a41141210380690473f0f8dcd6f3196e044d4fc160c44597315ccd6a42117f1d6f56cc960819143ed2b14d2418fdf1b384abbf9bbe4a9b9524ca6178a988acfeffffff03e8030000000000001976a914d7ce2101a80919b3889617f9cdd8e5787f2239ff88ac0000000000000000266a243b1b3dafaa953d395088098fa0168b20ff417c7309f37eb67fdf7bd04b47c2200000000066be26040000000017a91483eb112ad5945d4463cd4a8cd4881fcad8478c7e87784b1600"
}
Let‘s show miner0's info again:
$ ts-node cc_covenant_v1_testnet.ts miner-info
cash addr: bchtest:qrtuuggp4qy3nvugjctlnnwcu4u87g3elu47xfz6kf
utxos: [
{
txid: 'c6c8a79a5d1640bcbded68515902e5d6232c0c118e70079854a9d41e968cda34',
vout: 0,
satoshis: 1000,
height: 0
}
]
We need txid and vout, which is:
6cfe58d0764eea39555acb6170e078b115307894ead613dced901113b8b5e5a1:0
and raw tx, which is:
0200000001678e7a1cc8d3a28f4c3b65e68ab9a466fffeb6dd35a000714bbaec663cce49ba020000007e41c197ed3bd646f4ed2aa70cf08635993850aee353d481d5e8115d79035a1c5c8a57f03aac3ed4a84b933205c6d60ad7a75c2d570c41ec13ba7f24c23b35b4a41141210380690473f0f8dcd6f3196e044d4fc160c44597315ccd6a42117f1d6f56cc960819143ed2b14d2418fdf1b384abbf9bbe4a9b9524ca6178a988acfeffffff03e8030000000000001976a914d7ce2101a80919b3889617f9cdd8e5787f2239ff88ac0000000000000000266a243b1b3dafaa953d395088098fa0168b20ff417c7309f37eb67fdf7bd04b47c2200000000066be26040000000017a91483eb112ad5945d4463cd4a8cd4881fcad8478c7e87784b1600
and the index of '3b1b3dafaa953d395088098fa0168b20ff417c7309f37eb67fdf7bd04b47c22000000000', which is: 218.
Now miner0 is ready to vote Yes:
$ ts-node cc_covenant_v1_testnet.ts vote \
--receiver=bchtest:qp0yar50xunn7wyazdsyqcfwwf2uqkcghsy8ngukht \
--oldYes=0 \
--oldNo=0 \
--agreed=true \
--votingUtxo=20c2474bd07bdf7fb67ef309737c41ff208b16a08f098850393d95aaaf3d1b3b:0 \
--coinbaseUtxo=c6c8a79a5d1640bcbded68515902e5d6232c0c118e70079854a9d41e968cda34:0 \
--coinbaseRawTx=0200000001678e7a1cc8d3a28f4c3b65e68ab9a466fffeb6dd35a000714bbaec663cce49ba020000007e41c197ed3bd646f4ed2aa70cf08635993850aee353d481d5e8115d79035a1c5c8a57f03aac3ed4a84b933205c6d60ad7a75c2d570c41ec13ba7f24c23b35b4a41141210380690473f0f8dcd6f3196e044d4fc160c44597315ccd6a42117f1d6f56cc960819143ed2b14d2418fdf1b384abbf9bbe4a9b9524ca6178a988acfeffffff03e8030000000000001976a914d7ce2101a80919b3889617f9cdd8e5787f2239ff88ac0000000000000000266a243b1b3dafaa953d395088098fa0168b20ff417c7309f37eb67fdf7bd04b47c2200000000066be26040000000017a91483eb112ad5945d4463cd4a8cd4881fcad8478c7e87784b1600 \
--coinbaseVout=0 \
--opReturnPos=218
We got long output:
vote...
receiverPkh : 5e4e8e8f37273f389d136040612e7255c05b08bc
oldYes : 0
oldNo : 0
agreed : true
votingUtxo : 20c2474bd07bdf7fb67ef309737c41ff208b16a08f098850393d95aaaf3d1b3b:0
coinbaseUtxo: c6c8a79a5d1640bcbded68515902e5d6232c0c118e70079854a9d41e968cda34:0
cbRawTx : 0200000001678e7a1cc8d3a28f4c3b65e68ab9a466fffeb6dd35a000714bbaec663cce49ba020000007e41c197ed3bd646f4ed2aa70cf08635993850aee353d481d5e8115d79035a1c5c8a57f03aac3ed4a84b933205c6d60ad7a75c2d570c41ec13ba7f24c23b35b4a41141210380690473f0f8dcd6f3196e044d4fc160c44597315ccd6a42117f1d6f56cc960819143ed2b14d2418fdf1b384abbf9bbe4a9b9524ca6178a988acfeffffff03e8030000000000001976a914d7ce2101a80919b3889617f9cdd8e5787f2239ff88ac0000000000000000266a243b1b3dafaa953d395088098fa0168b20ff417c7309f37eb67fdf7bd04b47c2200000000066be26040000000017a91483eb112ad5945d4463cd4a8cd4881fcad8478c7e87784b1600
cbVout : 0
opRetPos : 218
>> init cc_covenant, args:
0) opAddrsHash: 8fc28a31ce851e2e9d3819b0e5d064ce67d4ddaa
1) receiverPkh: 5e4e8e8f37273f389d136040612e7255c05b08bc
2) yesNoBytes : 00000000
>> init cc_covenant, args:
0) opAddrsHash: 8fc28a31ce851e2e9d3819b0e5d064ce67d4ddaa
1) receiverPkh: 5e4e8e8f37273f389d136040612e7255c05b08bc
2) yesNoBytes : 30750000
fromContract UTXOs : [
{
txid: '20c2474bd07bdf7fb67ef309737c41ff208b16a08f098850393d95aaaf3d1b3b',
vout: 0,
satoshis: 17000,
height: 1461110
}
]
miner UTXOs : [
{
txid: 'c6c8a79a5d1640bcbded68515902e5d6232c0c118e70079854a9d41e968cda34',
vout: 0,
satoshis: 1000,
height: 1461113
}
]
transaction details: {
"inputs": [
{
"outpointIndex": 0,
"outpointTransactionHash": "<Uint8Array: 0x20c2474bd07bdf7fb67ef309737c41ff208b16a08f098850393d95aaaf3d1b3b>",
"sequenceNumber": 4294967294,
"unlockingBytecode": "<Uint8Array: 0x005102da0004000000004d22010200000001678e7a1cc8d3a28f4c3b65e68ab9a466fffeb6dd35a000714bbaec663cce49ba020000007e41c197ed3bd646f4ed2aa70cf08635993850aee353d481d5e8115d79035a1c5c8a57f03aac3ed4a84b933205c6d60ad7a75c2d570c41ec13ba7f24c23b35b4a41141210380690473f0f8dcd6f3196e044d4fc160c44597315ccd6a42117f1d6f56cc960819143ed2b14d2418fdf1b384abbf9bbe4a9b9524ca6178a988acfeffffff03e8030000000000001976a914d7ce2101a80919b3889617f9cdd8e5787f2239ff88ac0000000000000000266a243b1b3dafaa953d395088098fa0168b20ff417c7309f37eb67fdf7bd04b47c2200000000066be26040000000017a91483eb112ad5945d4463cd4a8cd4881fcad8478c7e87784b160014dd03b54ba1f42ac7c449adec13fb2b3dcfa12a21145a98671aaaeb7447adfcd62eba636457379673c014bc3991702a53462789215923e87901971c17bc88145e4e8e8f37273f389d136040612e7255c05b08bc210290e339ea14f6c9aea9471436fe31fe443c9a1eab5e89693d7e55f206ba917a08413273efda8edeea2ad13ff36adf6833d25c5fd4fff8bbcd61b768b8ecdeb4238ec601fd776f516c1a78d3448ec54313830b57790651958ee04547b222716e7529414de60102000000f7489a93c8f8356f2e10110d427ba1b18c1d87db9deef4ca9881a5c6105f6718c992651ac89a97aecd0811c1761915a8e2c8f5153d1bdd994a789e6bd86ab7173b1b3dafaa953d395088098fa0168b20ff417c7309f37eb67fdf7bd04b47c22000000000fd47010400000000145e4e8e8f37273f389d136040612e7255c05b08bc148fc28a31ce851e2e9d3819b0e5d064ce67d4ddaa5379547f7701207f01207f7701247f537f77820134947f587f547f7701207f75597a5a796e7c828c7f755c7aa87bbbad060400000000145a7a7e5379011a7f777e587a8101117a635979a959798852b2757603e09304967802307597a269675f79009c635979a95b795d797e5e797ea9597988765c7987785e79879b785f79879b697803e09304965279023075979f63022c01b2756875675d79547f7701257f75a914282711cb97968c8674a46b5564ce3549f5782ea487916955795e79aa7e5f797eaa5779885d7960797f7701247f7556798860796376023075937767768b7768547854807e5579557f777e7b757c6853798102b80b945880760317a9147e5379a97e01877e76aa5579886d686d6d6d6d6d6d6d6d75516842000000000000feffffffeade4f593bd75a8e89494166393d16f3af650dbacabe3770b927aa71e25a0528794b1600410000004d47010400000000145e4e8e8f37273f389d136040612e7255c05b08bc148fc28a31ce851e2e9d3819b0e5d064ce67d4ddaa5379547f7701207f01207f7701247f537f77820134947f587f547f7701207f75597a5a796e7c828c7f755c7aa87bbbad060400000000145a7a7e5379011a7f777e587a8101117a635979a959798852b2757603e09304967802307597a269675f79009c635979a95b795d797e5e797ea9597988765c7987785e79879b785f79879b697803e09304965279023075979f63022c01b2756875675d79547f7701257f75a914282711cb97968c8674a46b5564ce3549f5782ea487916955795e79aa7e5f797eaa5779885d7960797f7701247f7556798860796376023075937767768b7768547854807e5579557f777e7b757c6853798102b80b945880760317a9147e5379a97e01877e76aa5579886d686d6d6d6d6d6d6d6d7551>"
},
{
"outpointIndex": 0,
"outpointTransactionHash": "<Uint8Array: 0xc6c8a79a5d1640bcbded68515902e5d6232c0c118e70079854a9d41e968cda34>",
"sequenceNumber": 4294967294,
"unlockingBytecode": "<Uint8Array: 0x414d372bf4a354a0280710d40d0bf80ccf34717fe8c3f122c04779b3eec3020df086805ccbc041503f5852c2f542c851ed2cd62a86152a0735c48accc5107ed9ab41210290e339ea14f6c9aea9471436fe31fe443c9a1eab5e89693d7e55f206ba917a08>"
}
],
"locktime": 1461113,
"outputs": [
{
"lockingBytecode": "<Uint8Array: 0xa914e5e9d4d37f2918fa73ca6dc5e760c303f49f551587>",
"satoshis": "<Uint8Array: 0xb036000000000000>"
}
],
"version": 2,
"txid": "7003c8e5c4f30720676a8f6b239a6e6edfbc507b3f8a69bcf96eb812d06383c4",
"hex": "02000000023b1b3dafaa953d395088098fa0168b20ff417c7309f37eb67fdf7bd04b47c22000000000fd1a05005102da0004000000004d22010200000001678e7a1cc8d3a28f4c3b65e68ab9a466fffeb6dd35a000714bbaec663cce49ba020000007e41c197ed3bd646f4ed2aa70cf08635993850aee353d481d5e8115d79035a1c5c8a57f03aac3ed4a84b933205c6d60ad7a75c2d570c41ec13ba7f24c23b35b4a41141210380690473f0f8dcd6f3196e044d4fc160c44597315ccd6a42117f1d6f56cc960819143ed2b14d2418fdf1b384abbf9bbe4a9b9524ca6178a988acfeffffff03e8030000000000001976a914d7ce2101a80919b3889617f9cdd8e5787f2239ff88ac0000000000000000266a243b1b3dafaa953d395088098fa0168b20ff417c7309f37eb67fdf7bd04b47c2200000000066be26040000000017a91483eb112ad5945d4463cd4a8cd4881fcad8478c7e87784b160014dd03b54ba1f42ac7c449adec13fb2b3dcfa12a21145a98671aaaeb7447adfcd62eba636457379673c014bc3991702a53462789215923e87901971c17bc88145e4e8e8f37273f389d136040612e7255c05b08bc210290e339ea14f6c9aea9471436fe31fe443c9a1eab5e89693d7e55f206ba917a08413273efda8edeea2ad13ff36adf6833d25c5fd4fff8bbcd61b768b8ecdeb4238ec601fd776f516c1a78d3448ec54313830b57790651958ee04547b222716e7529414de60102000000f7489a93c8f8356f2e10110d427ba1b18c1d87db9deef4ca9881a5c6105f6718c992651ac89a97aecd0811c1761915a8e2c8f5153d1bdd994a789e6bd86ab7173b1b3dafaa953d395088098fa0168b20ff417c7309f37eb67fdf7bd04b47c22000000000fd47010400000000145e4e8e8f37273f389d136040612e7255c05b08bc148fc28a31ce851e2e9d3819b0e5d064ce67d4ddaa5379547f7701207f01207f7701247f537f77820134947f587f547f7701207f75597a5a796e7c828c7f755c7aa87bbbad060400000000145a7a7e5379011a7f777e587a8101117a635979a959798852b2757603e09304967802307597a269675f79009c635979a95b795d797e5e797ea9597988765c7987785e79879b785f79879b697803e09304965279023075979f63022c01b2756875675d79547f7701257f75a914282711cb97968c8674a46b5564ce3549f5782ea487916955795e79aa7e5f797eaa5779885d7960797f7701247f7556798860796376023075937767768b7768547854807e5579557f777e7b757c6853798102b80b945880760317a9147e5379a97e01877e76aa5579886d686d6d6d6d6d6d6d6d75516842000000000000feffffffeade4f593bd75a8e89494166393d16f3af650dbacabe3770b927aa71e25a0528794b1600410000004d47010400000000145e4e8e8f37273f389d136040612e7255c05b08bc148fc28a31ce851e2e9d3819b0e5d064ce67d4ddaa5379547f7701207f01207f7701247f537f77820134947f587f547f7701207f75597a5a796e7c828c7f755c7aa87bbbad060400000000145a7a7e5379011a7f777e587a8101117a635979a959798852b2757603e09304967802307597a269675f79009c635979a95b795d797e5e797ea9597988765c7987785e79879b785f79879b697803e09304965279023075979f63022c01b2756875675d79547f7701257f75a914282711cb97968c8674a46b5564ce3549f5782ea487916955795e79aa7e5f797eaa5779885d7960797f7701247f7556798860796376023075937767768b7768547854807e5579557f777e7b757c6853798102b80b945880760317a9147e5379a97e01877e76aa5579886d686d6d6d6d6d6d6d6d7551feffffff34da8c961ed4a9549807708e110c2c23d6e502595168edbdbc40165d9aa7c8c60000000064414d372bf4a354a0280710d40d0bf80ccf34717fe8c3f122c04779b3eec3020df086805ccbc041503f5852c2f542c851ed2cd62a86152a0735c48accc5107ed9ab41210290e339ea14f6c9aea9471436fe31fe443c9a1eab5e89693d7e55f206ba917a08feffffff01b03600000000000017a914e5e9d4d37f2918fa73ca6dc5e760c303f49f551587794b1600"
}
Now, the value (minus tx gas fee, which is 3000) is in new UTXO:
$ ts-node cc_covenant_v1_testnet.ts contract-info \
--receiver=bchtest:qp0yar50xunn7wyazdsyqcfwwf2uqkcghsy8ngukht \
--yes-vote=1 \
--no-vote=0
>> init cc_covenant, args:
0) opAddrsHash: 8fc28a31ce851e2e9d3819b0e5d064ce67d4ddaa
1) receiverPkh: 5e4e8e8f37273f389d136040612e7255c05b08bc
2) yesNoBytes : 30750000
contract address: bchtest:prj7n4xn0u5337nnefkutemqcvplf864z5dkhmusjg
contract balance: 14000
contract UTXOs : [
{
txid: '7003c8e5c4f30720676a8f6b239a6e6edfbc507b3f8a69bcf96eb812d06383c4',
vout: 0,
satoshis: 14000,
height: 0
}
]
Wait 2 blocks, and Alice can get her BCH:
$ ts-node cc_covenant_v1_testnet.ts finish-unlock \
--receiver-key-pair=alice \
--yes-vote=1 \
--no-vote=0 \
--utxo=7003c8e5c4f30720676a8f6b239a6e6edfbc507b3f8a69bcf96eb812d06383c4:0
>> init cc_covenant, args:
0) opAddrsHash: 8fc28a31ce851e2e9d3819b0e5d064ce67d4ddaa
1) receiverPkh: 5e4e8e8f37273f389d136040612e7255c05b08bc
2) yesNoBytes : 30750000
fromContract address: bchtest:prj7n4xn0u5337nnefkutemqcvplf864z5dkhmusjg
fromContract UTXOs : [
{
txid: '7003c8e5c4f30720676a8f6b239a6e6edfbc507b3f8a69bcf96eb812d06383c4',
vout: 0,
satoshis: 14000,
height: 0
}
]
...