根据其他问题的清单,建立一个我需要的原始交易:
listunspent
- 您将获得所有未使用的交易清单createrawtransaction
创建输入/输出
txid和vout来自您拥有的交易列表
玩,以及构成“钱”的交易清单
为你“供给。”。signrawtransaction
签署创建的交易sendrawtransaction
发送已签名的交易但是有一个大问题 - listunspent
显示实际已花费的未支出金额,因此,我将来会有足够的资金错误或负余额......
E.g:
创建地址15d8uY8uubNFnn3DXaoGN123ZCRkm3HJK9。
发送给它0.01 BTC
后来从这个地址0.00400000发送,费用为0.00010714:
[
{
"account": "login_67",
"address": "15d8uY8uubNFnn3DXaoGN123ZCRkm3HJK9",
------> "category": "receive",
"amount": 0.01000000,
"label": "login_67",
"vout": 0,
"confirmations": 628,
"blockhash": "0000000000000000006bf20ac85a50d3e014a636b51231c78c6b27fe0a8e9223",
"blockindex": 2,
"blocktime": 1463753010,
"txid": "f37679b68c8ee3cd362b5bb15b2d8007af4eab173eee2d6269a132b9491a55ad",
"walletconflicts": [
],
"time": 1463752690,
"timereceived": 1463752690,
"bip125-replaceable": "no"
},
{
"account": "login_67",
"address": "1BeqRNunznfwuFHnufXLFRhaCDm1mrvMS6",
------> "category": "send",
"amount": -0.00400000,
"vout": 1,
"fee": -0.00010714,
"confirmations": 609,
"blockhash": "000000000000000000699cd44c4aed1eeb9c66181f6260bfe41473e66e1ece06",
"blockindex": 1614,
"blocktime": 1463767099,
"txid": "9a39b070d8f21ddf9bd16e641c4b252c2da701336fd36b707ca072fd1ca11d58",
"walletconflicts": [
],
"time": 1463766747,
"timereceived": 1463766747,
"bip125-replaceable": "no",
"abandoned": false
}
]
Getbalance显示 0.00589286
的正确平衡listunnspent显示有关可用资金的错误信息:
[
{
"txid": "f37679b68c8ee3cd362b5bb15b2d8007af4eab173eee2d6269a132b9491a55ad",
"vout": 0,
"address": "15d8uY8uubNFnn3DXaoGN123ZCRkm3HJK9",
"account": "login_67",
"scriptPubKey": "76a91432b613c311d4c9c72f3ed1ba5e2c1d96645bd2da88ac",
"amount": 0.01000000,
"confirmations": 628,
"spendable": true
}
]
就像没有任何发送交易一样。
那么如何从TX收集所有未花费的资金呢?
感谢您的回答。
答案 0 :(得分:7)
迈克尔从Pablo获得了0.05000000 BTC,另外还获得了0.01亿BTC 来自Kuradang。迈克尔还希望向贝腾发送0.02500000 BTC。 迈克尔收到的每笔金额都有相应的T和其他金额 细节。让我们使用listunspent
命令检查,然后创建一个 使用createrawtransaction
之后的原始交易signrawtransaction
并使用发送原始事务sendrawtransaction
。
listunspent
格式:
$ bitcoin-cli listunspent [misconf=1] [max_number_confirmation=99999999] '''["<wallet_address>"]'''
让我们使用他的地址检查迈克尔未花费的名单。
执行:
$ bitcoin-cli listunspent 1 99999999 '''["mkrzDhhZtzQm8zgckSs4fMNrvtNJ66zaFe"]'''
结果:
[{
"txid": "12b8e7ede4992f4d30f93idj3085746951d945e39f40becebd7c290af8c2e7ad",
"vout": 1,
"address": "mkrzDhhZtzQm8zgckSs4fMNrvtNJ66zaFe",
"account": "micz",
"scriptPubKey": "76a9143aa28e1740a6a5a2190975b6e7f1ad67aaec9a3988ac",
"amount": 0.05000000,
"confirmations": 94,
"spendable": true
}, {
"txid": "8443bc63b65d569ff9ekwm37sy3b67b9c7c6f8f386c3cdf372b260961b64ec9fc",
"vout": 1,
"address": "mkrzDhhZtzQm8zgckSs4fMNrvtNJ66zaFe",
"account": "micz",
"scriptPubKey": "76a9143aa28e1740a6a5a2190975b6e7f1ad67aaec9a3988ac",
"amount": 0.01000000,
"confirmations": 93,
"spendable": true
}]
我们在这里看到的是为我们分配50和10 mBTC的结果 地址mkrz ....要花费此输出,我们将创建一个新事务。
createrawtransaction
我们需要从
listunspent
的结果中选择一些具有足够金额的块。由于我们只需要发送0.02500000 mBTC,我认为第一个块有足够的金额来进行交易。
格式:
$ bitcoin-cli createrawtransaction
'[{
"txid" : "<txid_of_selected_block>",
"vout" : <vout>
}]'
'{"<recipient_address>": <amount_to_send>, "<sender_address>": <amount_change>}'
要支付费用,我们会将变化输出减少0.5毫米 你可以在下面看到。
执行:
$ bitcoin-cli createrawtransaction
'[{
"txid" : "12b8e7ede4992f4d30f93idj3085746951d945e39f40becebd7c290af8c2e7ad",
"vout" : 0
}]'
'{"mxh3H416KCRoBDiweSESew5YJyAk1nxLrN": 0.025, "mkrzDhhZtzQm8zgckSs4fMNrvtNJ66zaFe": 0.0245}'
结果
0100000001e34ac1e2baac09c366fce1c2245536bda8f7db0f6685862aecf53ebd69f9a89c0000000000ffffffff02a0252600000000001976a914d90d36e98f62968d2bc9bbd68107564a156a9bcf88ac50622500000000001976a91407bdb518fa2e6089fd810235cf1100c9c13d1fd288ac00000000
createrawtransaction
命令生成一个原始十六进制字符串 对我们提供的交易详情进行编码。如果要解码十六进制,只需使用decoderawtransaction
命令。
signrawtransaction
使用序列化事务格式签署事务 存储在钱包中或在通话中提供的私钥。
格式:
$ bitcoin-cli signrawtransaction <hex_createrawtransaction>
执行:
$ bitcoin-cli signrawtransaction 0100000001e34ac1e2baac09c366fce1c2245536bda8f7db0f6685862aecf53ebd69f9a89c0000000000ffffffff02a0252600000000001976a914d90d36e98f62968d2bc9bbd68107564a156a9bcf88ac50622500000000001976a91407bdb518fa2e6089fd810235cf1100c9c13d1fd288ac00000000
结果:
{
"hex" : "0100000001e34ac1e2baac09c366fce1c2245536bda8f7db0f6685862aecf53ebd69f9a89c000000006a47304402203e8a16522da80cef66bacfbc0c800c6d52c4a26d1d86a54e0a1b76d661f020c9022010397f00149f2a8fb2bc5bca52f2d7a7f87e3897a273ef54b277e4af52051a06012103c9700559f690c4a9182faa8bed88ad8a0c563777ac1d3f00fd44ea6c71dc5127ffffffff02a0252600000000001976a914d90d36e98f62968d2bc9bbd68107564a156a9bcf88ac50622500000000001976a91407bdb518fa2e6089fd810235cf1100c9c13d1fd288ac00000000",
"complete" : true
}
现在
signrawtransaction
命令返回另一个十六进制编码的raw 事务。
sendrawtransaction
RPC验证事务并将其广播到点对点 网络
格式:
$ bitcoin-cli sendrawtransaction <hex_signrawtransaction>
执行:
$ bitcoin-cli sendrawtransaction 0100000001e34ac1e2baac09c366fce1c2245536bda8f7db0f6685862aecf53ebd69f9a89c000000006a47304402203e8a16522da80cef66bacfbc0c800c6d52c4a26d1d86a54e0a1b76d661f020c9022010397f00149f2a8fb2bc5bca52f2d7a7f87e3897a273ef54b277e4af52051a06012103c9700559f690c4a9182faa8bed88ad8a0c563777ac1d3f00fd44ea6c71dc5127ffffffff02a0252600000000001976a914d90d36e98f62968d2bc9bbd68107564a156a9bcf88ac50622500000000001976a91407bdb518fa2e6089fd810235cf1100c9c13d1fd288ac00000000
结果:
ae74538baa914f3799081ba78429d5d84f36a0127438e9f721dff584ac17b346
命令
sendrawtransaction
返回事务哈希(TXID) 在网络上提交交易。要检查事务哈希,您可以转到blockchain.info或testnet.blockchain.info以获取Testnet网络。