Client
使用 Bitcoin Core v0.10.0 bitcoin-tx / createrawtransaction 創建原始交易
我正在嘗試使用 Bitcoin Core v0.10.0(在 Windows 7 x64 上,並選擇 txindex=1)創建原始交易。
Bitcoin Core v0.10.0 帶有一個新的Bitcoin-tx可執行實用程序。幫助菜單如下(Windows 7 x64 下):
Bitcoin Core bitcoin-tx utility version v0.10.0 Usage: bitcoin-tx [options] <hex-tx> [commands] Update hex-encoded bitcoin transaction bitcoin-tx [options] -create [commands] Create hex-encoded bitcoin transaction Options: -? This help message -create Create new, empty TX. -json Select JSON output -txid Output only the hex-encoded transaction id of the resultant transaction. -regtest Enter regression test mode, which uses a special chain in which blocks can be solved instantly. -testnet Use the test network Commands: delin=N Delete input N from TX delout=N Delete output N from TX in=TXID:VOUT Add input to TX locktime=N Set TX lock time to N nversion=N Set TX version to N outaddr=VALUE:ADDRESS Add address-based output to TX outscript=VALUE:SCRIPT Add raw script output to TX sign=SIGHASH-FLAGS Add zero or more signatures to transaction This command requires JSON registers: prevtxs=JSON object privatekeys=JSON object See signrawtransaction docs for format of sighash flags, JSON objects. Register Commands: load=NAME:FILENAME Load JSON file FILENAME into register NAME set=NAME:JSON-STRING Set register NAME to given JSON-STRING
使用 Windows CLI,我遇到了createrawtransaction的問題,因為它沒有像在 Bitcoin-QT 控制台視窗中那樣解析命令。
bitcoin-cli createrawtransaction [{"txid":"dbdc2e2c7f143af70c5e7e8725f55d226b3c058d7bf34a303091b3c6a514848c","vout":1}] {"1BCi1L25GC9hUSvtSyGjmEvSyywoYubk4P":0.00011}
給
error: Error parsing JSON:[{txid:dbdc2e2c7f143af70c5e7e8725f55d226b3c058d7bf34a303091b3c6a514848c,vout:1}]
同樣,該
bitcoin-tx
實用程序不適用於此:bitcoin-tx.exe -create in=dbdc2e2c7f143af70c5e7e8725f55d226b3c058d7bf34a303091b3c6a514848c:1 locktime=0 nversion=1 outaddr=2000:1BCi1L25GC9hUSvtSyGjmEvSyywoYubk4P outscript=0:687474703a2f2f676f6f2e676c2f7869556243555
如何使用Bitcoin-cli和bitcoin-tx創建原始交易?
對於第一個命令,您需要將 JSON 包含在單引號中,如下所示:
$ bitcoin-cli createrawtransaction '[{"txid":"dbdc2e2c7f143af70c5e7e8725f55d226b3c058d7bf34a303091b3c6a514848c","vout":1}]' '{"1BCi1L25GC9hUSvtSyGjmEvSyywoYubk4P":0.00011}' 01000000018c8414a5c6b39130304af37b8d053c6b225df525877e5e0cf73a147f2c2edcdb0100000000ffffffff01f82a0000000000001976a9146fe8102ebe0fccb56de43ec82601ba16c68496af88ac00000000
該
bitcoin-tx
實用程序使用部署在比特幣單元測試中的速記。此範例可能會幫助您使用此命令:$ ./bitcoin-tx -create in=0fb9df5614be8b33be0434ce4062750d83f1b7ce05cc1296604f82eb9abf802b:0 outscript=0.00159999:"DUP HASH160 0x14 0x6793a38f79b8cd51dbb6face6dc75a4af5c1bf29 EQUALVERIFY CHECKSIG" 01000000012b80bf9aeb824f609612cc05ceb7f1830d756240ce3404be338bbe1456dfb90f0000000000ffffffff01ff700200000000001976a9146793a38f79b8cd51dbb6face6dc75a4af5c1bf2988ac00000000