haoqian (OP)
Newbie
Offline
Activity: 20
Merit: 0
|
|
May 03, 2018, 02:32:40 PM |
|
Hi, I am trying to use createrawtransaction. When I use following code: op_return_data="4d79206e616d65" utxo_txid=$(~/bitcoin/src/bitcoin-cli listunspent | jq -r '.[0] | .txid') utxo_vout=$(~/bitcoin/src/bitcoin-cli listunspent | jq -r '.[0] | .vout') utxo_balance=$(~/bitcoin/src/bitcoin-cli listunspent | jq -r '.[0] | .amount') new_balance=$(echo "$utxo_balance - 0.0001" | bc | awk '{printf "%f", $0}') changeaddress=$(~/bitcoin/src/bitcoin-cli getrawchangeaddress) rawtxhex=$(~/bitcoin/src/bitcoin-cli -named createrawtransaction inputs='''[ { "txid": "'$utxo_txid'", "vout": '$utxo_vout' } ]''' outputs='''{ "data": "'$op_return_data'", "'$changeaddress'": "'$new_balance'" }''') signedhex=$(~/bitcoin/src/bitcoin-cli signrawtransaction $rawtxhex | jq -r .hex) ~/bitcoin/src/bitcoin-cli sendrawtransaction $signedhex
It will get : error code: -26 error message: 64: no-witness-yet
I do not know why. How to solve it? Could you help me? Thanks!
|
|
|
|
achow101
Moderator
Legendary
Offline
Activity: 3542
Merit: 6886
Just writing some code
|
|
May 03, 2018, 03:08:43 PM |
|
This error means that you are trying to spend from or create segwit outputs without segwit being activated yet. Is your node fully synced?
|
|
|
|
achow101
Moderator
Legendary
Offline
Activity: 3542
Merit: 6886
Just writing some code
|
|
May 03, 2018, 03:24:12 PM |
|
I did not include any Segwit in any transaction. why does it show here?
Are you sure? If you forked from the latest Bitcoin Core, it uses segwit by default. Can you post what the changeaddress looks like and what the output of listunspent looks like?
|
|
|
|
haoqian (OP)
Newbie
Offline
Activity: 20
Merit: 0
|
|
May 03, 2018, 03:29:30 PM |
|
I did not include any Segwit in any transaction. why does it show here?
Are you sure? If you forked from the latest Bitcoin Core, it uses segwit by default. Can you post what the changeaddress looks like and what the output of listunspent looks like? Thank you for your reply. I forked 0.16 bitcoin core. getrawchangeaddress shows this: 3PgBJaR5fCw9nBtij7THqfHbbENdCdFEuv
listunspent shows this: { "txid": "4bffb171833ca3fe5fe5f272a482161809be371131f89f6c116d695096c60afe", "vout": 0, "address": "1A6csP8jrpyruyW4a9tX9Nonv4R8AviB1y", "account": "", "scriptPubKey": "76a91463c9274bf6297bd724ad66eafab4fd94f7c9714488ac", "amount": 50.00000000, "confirmations": 21, "spendable": true, "solvable": true, "safe": true }, { "txid": "efd172501ea2760738987a3d4865dc41aae2cc988d02e08860f939166ad97bff", "vout": 0, "address": "1A6csP8jrpyruyW4a9tX9Nonv4R8AviB1y", "account": "", "scriptPubKey": "76a91463c9274bf6297bd724ad66eafab4fd94f7c9714488ac", "amount": 50.00000000, "confirmations": 46, "spendable": true, "solvable": true, "safe": true }
|
|
|
|
achow101
Moderator
Legendary
Offline
Activity: 3542
Merit: 6886
Just writing some code
|
|
May 03, 2018, 03:35:16 PM |
|
Can you also post what your final signed transaction looks like? getrawchangeaddress shows this: 3PgBJaR5fCw9nBtij7THqfHbbENdCdFEuv
This will be a problem for you later because that is a segwit address and you do not have segwit enabled.
|
|
|
|
haoqian (OP)
Newbie
Offline
Activity: 20
Merit: 0
|
|
May 03, 2018, 03:40:21 PM |
|
Can you also post what your final signed transaction looks like? getrawchangeaddress shows this: 3PgBJaR5fCw9nBtij7THqfHbbENdCdFEuv
This will be a problem for you later because that is a segwit address and you do not have segwit enabled. Thank you for your reply. It looks like this: { "txid": "391c0428614cb7f966bba368c3b83050d81f17190125b686e1434562bb82edd4", "hash": "6dc00133fa2043cda29d610f087c739fcc65f4a4efc4f0bc5058bcd003bd7f61", "version": 2, "size": 251, "vsize": 169, "locktime": 0, "vin": [ { "txid": "551ba4bde3460bca6a6cae7da57ffd8b3f1baf18ad7a2e6d50f8d4f5b0a94e14", "vout": 1, "scriptSig": { "asm": "0014620cfaeb631c99d45490cc6560a7258835c260f8", "hex": "160014620cfaeb631c99d45490cc6560a7258835c260f8" }, "txinwitness": [ "3045022100a1e4403c6327fb787ef498cfaf6c54f8372f2792c06a7156cad6cf15c729de2802201eb1b48e2443b04688091897caf0fc9afbfc002227c05441a5f1723be9a532e401", "02533dc7b0e2d8f359fb235fd52bcda6135cfb0e39c6d9d93a10704457ff30e6ff" ], "sequence": 4294967295 } ], "vout": [ { "value": 0.00000000, "n": 0, "scriptPubKey": { "asm": "OP_RETURN 4d79206e616d65206973205a68616e672048616f7169616e", "hex": "6a184d79206e616d65206973205a68616e672048616f7169616e", "type": "nulldata" } }, { "value": 48.99984900, "n": 1, "scriptPubKey": { "asm": "OP_HASH160 360ba84dc5961b64e67d75dd623a26c31d98beb9 OP_EQUAL", "hex": "a914360ba84dc5961b64e67d75dd623a26c31d98beb987", "reqSigs": 1, "type": "scripthash", "addresses": [ "36cnNsjRuaP6cLGPFRXycaetmvmog5Wnyn" ] } } ] }
|
|
|
|
achow101
Moderator
Legendary
Offline
Activity: 3542
Merit: 6886
Just writing some code
|
|
May 03, 2018, 04:22:52 PM |
|
"txid": "551ba4bde3460bca6a6cae7da57ffd8b3f1baf18ad7a2e6d50f8d4f5b0a94e14", "vout": 1, "scriptSig": { "asm": "0014620cfaeb631c99d45490cc6560a7258835c260f8", "hex": "160014620cfaeb631c99d45490cc6560a7258835c260f8" }, "txinwitness": [ "3045022100a1e4403c6327fb787ef498cfaf6c54f8372f2792c06a7156cad6cf15c729de2802201eb1b48e2443b04688091897caf0fc9afbfc002227c05441a5f1723be9a532e401", "02533dc7b0e2d8f359fb235fd52bcda6135cfb0e39c6d9d93a10704457ff30e6ff" ], "sequence": 4294967295 }
This is your problem, the input you are spending is a segwit input. You will need to figure out how to prevent your fork from creating segwit outputs that can be spent as inputs.
|
|
|
|
haoqian (OP)
Newbie
Offline
Activity: 20
Merit: 0
|
|
May 03, 2018, 04:27:06 PM |
|
"txid": "551ba4bde3460bca6a6cae7da57ffd8b3f1baf18ad7a2e6d50f8d4f5b0a94e14", "vout": 1, "scriptSig": { "asm": "0014620cfaeb631c99d45490cc6560a7258835c260f8", "hex": "160014620cfaeb631c99d45490cc6560a7258835c260f8" }, "txinwitness": [ "3045022100a1e4403c6327fb787ef498cfaf6c54f8372f2792c06a7156cad6cf15c729de2802201eb1b48e2443b04688091897caf0fc9afbfc002227c05441a5f1723be9a532e401", "02533dc7b0e2d8f359fb235fd52bcda6135cfb0e39c6d9d93a10704457ff30e6ff" ], "sequence": 4294967295 }
This is your problem, the input you are spending is a segwit input. You will need to figure out how to prevent your fork from creating segwit outputs that can be spent as inputs. Thank you very much for your reply. How can I spend money using createrawtransaction? I am not familiar with Segwit...
|
|
|
|
achow101
Moderator
Legendary
Offline
Activity: 3542
Merit: 6886
Just writing some code
|
|
May 03, 2018, 08:49:13 PM |
|
How can I spend money using createrawtransaction? I am not familiar with Segwit...
createrawtransaction is unrelated to this or to segwit. The problem is that the wallet assumes segwit is enabled by default, but segwit is not enabled according to your network rules. So you either have to enable segwit in the network rules, or change the wallet to assume segwit is disabled. How you do that you will need to figure out yourself.
|
|
|
|
haoqian (OP)
Newbie
Offline
Activity: 20
Merit: 0
|
|
May 04, 2018, 02:46:53 PM |
|
How can I spend money using createrawtransaction? I am not familiar with Segwit...
createrawtransaction is unrelated to this or to segwit. The problem is that the wallet assumes segwit is enabled by default, but segwit is not enabled according to your network rules. So you either have to enable segwit in the network rules, or change the wallet to assume segwit is disabled. How you do that you will need to figure out yourself. Thank you. You gave me a helpful info.
|
|
|
|
|