Hello.
I'm here again to ask for help. This time is about a raw transaction I created an that I can't broadcast to the network.
OS and other info:
I'm using Debian Buster
Bitcoin Core RPC client version v0.20.1 (online full node)
Bitcoin Core RPC client version v0.18.1 (offline node)
I use an online node to create the transaction and to broadcast it. And I use one other node, this one offline, to sign the transaction.
The command used to create the transaction was:
bitcoin-cli createrawtransaction "[{\"txid\":\"xxxxxxxxxxxxxxxxxx11111111111111111111111xxxxxxxxxxxxxxxxxxxxxx\", \"vout\":0}]" "[{\"xxxxxxxxdestination_address_herexxxxxxxx\":0.11223344}, {\"xxxxxxxxchange_address_herexxxxxxxx\":0.55667788}]"
Note: hashes, addresses an amounts are fictional, of course. If this info is really necessary I may provide it. Also, the hashes that repeat over commands, I meant to make them the same here so that people know that I used
this info here
AND there. Like in the case of
xxxxxxxxxxxxxxxxxx11111111111111111111111xxxxxxxxxxxxxxxxxxxxxx that was used in these two first commands.
The command returned an hash. No errors here, so I proceeded for the signing.
In the first place, I copied the hash from the command
signrawtransactionwithwallet, from the online node, to the offline node.
Then I used
signrawtransactionwithwallet to sign the transaction.
bitcoin-cli signrawtransactionwithwallet "xxxxxxxxxxxxxxx_hash_of_the_createrawtransaction_command_here_xxxxxxxxxxxxxxx" "[{\"txid\":\"xxxxxxxxxxxxxxxxxx11111111111111111111111xxxxxxxxxxxxxxxxxxxxxx\", \"vout\":0, \"scriptPubKey\":\"scriptPubKey_obtained_from_the_source_address\", \"amount\":0.99001122}]"
This command also returned an hash. I copied it to the online node and tried to broadcast it to the network with the following command:
bitcoin-cli sendrawtransaction "xxxxxxxxxxxxx_hash_returned_from_the_signrawtransactionwithwallet_command_xxxxxxxxxxxxx"
The return message was an error:
error code: -26
error message:
non-mandatory-script-verify-flag (Witness program hash mismatch)
I though this was due to the fact that I signed the transaction with
signrawtransactionwithwallet command, so I went again to the offline node to try to sign it using
signrawtransactionwithkey.
The command I used was:
bitcoin-cli signrawtransactionwithkey "xxxxxxxxxxxxxxx_hash_of_the_createrawtransaction_command_here_xxxxxxxxxxxxxxx" "[\"xxxxxxxxxxxxx_source_address_private_key_here_xxxxxxxxxxxxx\"]"
This time I got this JSON object, returning another error:
{
"hex": "xxxxxxxxxxxxxxx_hash_of_the_createrawtransaction_command_here_xxxxxxxxxxxxxxx",
"complete": false,
"errors": [
{
"txid": "xxxxxxxxxxxxxxxxxx11111111111111111111111xxxxxxxxxxxxxxxxxxxxxx",
"vout": 0,
"witness": [
],
"scriptSig": "",
"sequence": 1122334455,
"error": "Input not found or already spent"
}
]
}
So, what did I do wrong and what do I need to do to make this work?