bitcoin cash:基于比特币现金testnet的第一笔转账

准备工作

1.编辑配置文件

server=1
testnet=1
rpcuser=cynic
rpcpassword=123456
rpcallowip=127.0.0.1/1
rpcport=8884
txindex=1
datadir=/data/bch/data

2.准备测试链

./bitcoin-abc-0.20.6/bin/bitcoind -conf=/data/bch/bch.conf -testnet -listen=0

3.创建钱包

./bitcoin-abc-0.20.6/bin/bitcoin-cli -conf=/data/bch/bch.conf  -testnet createwallet testwallet

4.申请测试币

在网站https://developer.bitcoin.com/faucets/bch/申请测试币

bitcoin cash:基于比特币现金testnet的第一笔转账_第1张图片 

开始转账

1.调用createrawtransaction创建交易

./bitcoin-abc-0.20.6/bin/bitcoin-cli -conf=/data/bch/bch.conf  -testnet -rpcwallet=testwallet createrawtransaction '[]' '[{"qp24elecxtk7yngg0ahzlcvhq7x9p2fhwgp0rc3ckw":0.00040600}]'

020000000001989e0000000000001976a914555cff3832ede24d087f6e2fe197078c50a9377288ac00000000

2.调用fundrawtransaction

./bitcoin-abc-0.20.6/bin/bitcoin-cli -conf=/data/bch/bch.conf  -testnet -rpcwallet=testwallet fundrawtransaction 020000000001989e0000000000001976a914555cff3832ede24d087f6e2fe197078c50a9377288ac00000000 '{"changeAddress": "qpczw774rdgmek4ls3wxkds78lt0ug5rk5qjcgad29","changePosition":1}'

{
  "hex": "02000000019c03a63c0e6013fc9a1bf79f51f15c608c15c62b09db8a389004b40c00eee5c00100000000feffffff02989e0000000000001976a914555cff3832ede24d087f6e2fe197078c50a9377288ac06f79700000000001976a91470277bd51b51bcdabf845c6b361e3fd6fe2283b588ac00000000",
  "fee": 0.00000226,
  "changepos": 1
}

3.调用signrawtransactionwithwallet

./bitcoin-abc-0.20.6/bin/bitcoin-cli -conf=/data/bch/bch.conf  -testnet -rpcwallet=testwallet signrawtransactionwithwallet 02000000019c03a63c0e6013fc9a1bf79f51f15c608c15c62b09db8a389004b40c00eee5c00100000000feffffff02989e0000000000001976a914555cff3832ede24d087f6e2fe197078c50a9377288ac06f79700000000001976a91470277bd51b51bcdabf845c6b361e3fd6fe2283b588ac00000000

{
  "hex": "02000000019c03a63c0e6013fc9a1bf79f51f15c608c15c62b09db8a389004b40c00eee5c0010000006b483045022100ec4a51b8bfca7af48eaa1ee54b442bb310a52b890f9693bc225d922cf32ea9eb022030e36fc35ce03dd2fc8c9c87bda0c565418a68aac9105f14bf41ea7381543935412102a9679df6e4c0141e9c95baf7f0b5e9f5a48dee861242ce09b5a73da71acd9efdfeffffff02989e0000000000001976a914555cff3832ede24d087f6e2fe197078c50a9377288ac06f79700000000001976a91470277bd51b51bcdabf845c6b361e3fd6fe2283b588ac00000000",
  "complete": true
}

4.调用sendrawtransaction发送交易

./bitcoin-abc-0.20.6/bin/bitcoin-cli -conf=/data/bch/bch.conf  -testnet -rpcwallet=testwallet sendrawtransaction 02000000019c03a63c0e6013fc9a1bf79f51f15c608c15c62b09db8a389004b40c00eee5c0010000006b483045022100ec4a51b8bfca7af48eaa1ee54b442bb310a52b890f9693bc225d922cf32ea9eb022030e36fc35ce03dd2fc8c9c87bda0c565418a68aac9105f14bf41ea7381543935412102a9679df6e4c0141e9c95baf7f0b5e9f5a48dee861242ce09b5a73da71acd9efdfeffffff02989e0000000000001976a914555cff3832ede24d087f6e2fe197078c50a9377288ac06f79700000000001976a91470277bd51b51bcdabf845c6b361e3fd6fe2283b588ac00000000

824428e382511581c9597627e1ca9cace3a307fbfd2b28332f8074f41437d5e5

 

你可能感兴趣的:(区块链)