I'm using createrawtransaction
to get a complex transaction of 2 inputs and two outputs as discussed here: https://developer.bitcoin.org/examples/transactions.html
bitcoin-cli -regtest createrawtransaction '''
[
{
"txid": "'$UTXO1_TXID'",
"vout": '$UTXO1_VOUT'
},
{
"txid": "'$UTXO2_TXID'",
"vout": '$UTXO2_VOUT'
}
]
''' '''
{
"'$NEW_ADDRESS1'": 79.9999,
"'$NEW_ADDRESS2'": 10
}'''
0200000002ea34a15b5c6b1ec4d3e9d2a1fdb8f80c29b0aa93d1762359b5ba30b63437973a0000000000ffffffff3d38a74c05e837f87b7a0eb0b7c688396972ffe670fda8b7ba689c76acca24300000000000ffffffff02f028d6dc01000000160014e38542852b468886d97748b4ca3786387e9e9cdc00ca9a3b00000000160014f8dd22acbd0867c5ad1edd3c3ca6e8768845cb1d00000000
I assign this value to RAW_TX as described:
RAW_TX=0200000002ea34a15b5c6b1ec4d3e9d2a1fdb8f80c29b0aa93d1762359b5ba30b63437973a0000000000ffffffff3d38a74c05e837f87b7a0eb0b7c688396972ffe670fda8b7ba689c76acca24300000000000ffffffff02f028d6dc01000000160014e38542852b468886d97748b4ca3786387e9e9cdc00ca9a3b00000000160014f8dd22acbd0867c5ad1edd3c3ca6e8768845cb1d00000000
But then I run into problems. When using the private key I get an error saying it's not a valid sighash parameter. Since signrawtransaction
is deprecated I'm using signrawtransactionwithwallet
:
bitcoin-cli -regtest signrawtransactionwithwallet $RAW_TX '[]' '''
> [
> "'$UTXO1_PRIVATE_KEY'"
> ]'''
error code: -1
error message:
[
"cUS7vndDv6nzJ3qEa5YG74dAzzEwTxRmbBFKXCn2fu2C4GSCbRKa"
] is not a valid sighash parameter.
I'm have no idea why it's not working. Please advise!
bitcoin-cli -regtest signrawtransactionwithwallet $RAW_TX ''' > [ > { > "txid": "'$UTXO1_TXID'", > "vout": '$UTXO1_VOUT', > "scriptPubKey": "'$UTXO1_OUTPUT_SCRIPT'", > "value": '$UTXO1_VALUE' > } > ]''' error code: -3 error message: Missing amount for CTxOut(nValue=21000000.00000000, scriptPubKey=001492718ece477c2053ebee50dc7e)