EDIT: based on OPs request, I put examples in here:

there are a lot of examples for different tx types on bitcoin.org, in the developer examples. Basically you will need three steps. Assuming you are on OpenBSD/MacOS/Linux, you can go this way:

1.) createrawtransaction – this is what you have already, and it looks ok. I don’t know if the previous tx ID or v_out is correct, assuming you know the details, your string is ok (otherwise check with “bitcoin-cli -regtest listunspent”, and adopt TX_ID and V_OUT accordingly). I also assume, that the address is one which is in your wallet. Otherwise you might just create an address, and proceed afterwards like this:

bitcoin-cli -regtest createrawtransaction '''
        "txid": "'$UTXO_TXID'",
        "vout": '$UTXO_VOUT'
    ''' '''
      "'$NEW_ADDRESS'": 1

you provide this returned hex string to another variable:


2.) signrawtransaction – the previous command returns a hex string, that you will use to sign the transaction – again, see the docs. First I verify my created tx, and then sign:

bitcoin-cli -regtest decoderawtransaction $RAW_TX
bitcoin-cli -regtest signrawtransaction $RAW_TX

again you assign the result to a variable:


3.) sendrawtransaction – again you take the hexstring of the previous command as parameter, and/or see the docs.

bitcoin-cli -regtest sendrawtransaction $SIGNED_RAW_TX

and maybe a verification as step 4:

bitcoin-cli -regtest generate 1

this generates a block, and you can see on the $NEW_ADDRESS, if funds have been transferred.

I just entered the two keywords here in the search function, and also found a lot of answers.

Article First Published here