I'm using bitcoind and would like to understand how to create transactions that send inputs from many specifically selected addresses (from my wallet) to one destination address. I want to do manually what the sendtoaddress command does automatically.

If this operation requires me to create a raw transaction could you please provide a working example? I already read bitcoin.it:raw_transactions, but it is hard to understand without an example and unfortunately the wiki article doesn't provide any.

I would appreciate help greatly.

  • 1
    Please be careful, I have seen many people accidently mess up with raw transactions. Such as sending hundreads of BTC as a miners fee or the likes.
    – MaxSan
    Commented Sep 16, 2013 at 14:44
  • I will plan to test dipply with small amounts first.
    – Arsenius
    Commented Sep 16, 2013 at 15:28
  • There is also the "testnet" which is made for testing
    – RentFree
    Commented Nov 17, 2013 at 5:36
  • Look this, you have a example: bitcoin.stackexchange.com/questions/68820/…
    – user49749
    Commented Jan 17, 2018 at 18:38
  • Please check rpc documentation before use it (developer.bitcoin.org/reference/rpc).
    – Peter Lai
    Commented Aug 30, 2023 at 8:56

3 Answers 3


When you have a bitcoin balance, that balance is actually unspent outputs from transactions your addresses have already received.

So when you want to send a raw transaction, what you include in that is the transactions and unspent outputs from those transactions... these can be from any address in your wallet.

The basic idea is;

createrawtransaction signrawtransaction sendrawtransaction

If you google around, you'll find plenty of examples of their use.

  • Coinbin seem to require internet/blockchain access in order to create a raw transaction. Is this true with all methods of creating raw transactions? Commented May 29, 2015 at 21:51
If this operation requires me to create a raw transaction, here's a working example assuming you have UTXOs:

UTXO 1: "txid1", Index 0, Amount 0.01 BTC
UTXO 2: "txid2", Index 1, Amount 0.02 BTC
Destination: "your_destination_address"

# Calculate transaction fee estimate (adjust the fee rate as needed)
TRANSACTION_FEE=$(bitcoin-cli estimatesmartfee 6 "CONSERVATIVE")

# Calculate total input amount from UTXOs

# Calculate the desired output amount

# Calculate the change amount

# Create the raw transaction with change output
RAW_TRANSACTION_HEX=$(bitcoin-cli createrawtransaction '[
   {"txid":"txid1", "vout":0},
   {"txid":"txid2", "vout":1}
]' '{
   "your_destination_address": '$OUTPUT_AMOUNT',
   "your_change_address": '$CHANGE_AMOUNT'

# Sign the raw transaction
SIGNED_TRANSACTION_HEX=$(bitcoin-cli signrawtransactionwithwallet "$RAW_TRANSACTION_HEX")

# Broadcast the transaction
bitcoin-cli sendrawtransaction "$SIGNED_TRANSACTION_HEX"

Please correct me if I was wrong.

  • This might work, because estimatesmartfee returns a feerate in sat/kvB, and your transaction likely is less than 1 kvB. You are however deducting a feerate from an amount, and for a larger transaction that might be too little to achieve a confirmation. Why did you post a second answer instead of editing your first?
    – Murch
    Commented Sep 12, 2023 at 20:34

Assuming you have UTXOs:

  • UTXO 1: "txid1", Index 0, Amount 0.01 BTC
  • UTXO 2: "txid2", Index 1, Amount 0.02 BTC
  • Destination: "your_destination_address"
# Create raw transaction
raw_tx=$(bitcoin-cli createrawtransaction '[{"txid":"txid1","vout":0}, {"txid":"txid2","vout":1}]' '{"your_destination_address": 0.03}')

# Sign raw transaction
signed_tx=$(bitcoin-cli signrawtransactionwithwallet "$raw_tx")

# Broadcast signed transaction
bitcoin-cli sendrawtransaction "${signed_tx["hex"]}"

Replace "your_destination_address" with your actual destination address. Run these commands in your terminal with your Bitcoin Core node running.

Maybe test on Bitcoin testnet before using real funds.

  • 1
    Hi Mani, this is on the way to be a much better answer than the one from ten years ago, but could you please expand on two issues: 1) createrawtransaction does not automatically create a change output. Could you please include a warning to that effect and add some instructions on how to send change back to yourself. 2) The transaction in your example does not pay any fees, so it will not propagate on the network or get mined. Do you have an idea how to fix that? :)
    – Murch
    Commented Aug 28, 2023 at 13:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.