Sorry if this has already been asked; Stack Exchange didn't have this exact question in the "related" field.

Let's say I have two bitcoin wallets. Somebody sends wallet 1 a transaction of 0.5 BTC.

What I am wondering is if I can take that transaction and create a new one, where I'm sending 0.4 BTC to that same address in wallet 1 with the original 0.5 BTC (the one listed in the "receive" data in the UTXO), and sending the 0.1 BTC change to an address in wallet 2.

I would think this is possible since the address in wallet 2 referenced as part of the second transaction would then have the funds available once the transaction confirms in the block chain.

I just don't know enough about Bitcoin's code to know for sure if this won't cause some sort of hiccup, as my general conception of "transaction change" is that an address local to the wallet, in this case wallet 1, is generated for capturing the change from the transaction to avoid overspending in transaction fees.

Using a separate wallet's address as the change may well break something in the code that accounts for the total balance of the first wallet.

This is why I need an expert to help me out here. Too many unknown outcomes for me!

1 Answer 1


I answered my own question.

I used the following PHP code...

$savings = 0.001;
$txfee = 0.0001;
$amount = floatval(($bitcoind->getbalance() - $savings) - $txfee); // getbalance() returns 0.005
$outputAddr = [
    '1GAnaq3atnKkxFsUC4Vky8Ysb751LbxHSC' => $amount, // wallet 1 address
    '122ExHr92bEgJbepSHmQCruCRR3YRR6dx5' => $savings // wallet 2 address

$rawtxUnspent = [];
$unspent = $bitcoind->listunspent();
foreach($unspent as $tx) {
    array_push($rawtxUnspent, [
        'txid' => $tx['txid'],
        'vout' => $tx['vout']

$rawtx = $bitcoind->createrawtransaction($rawtxUnspent, $outputAddr);
$signedtx = $bitcoind->signrawtransaction($rawtx);
$senttx = $bitcoind->sendrawtransaction($signedtx['hex']);

$senttx === false ? print $bitcoind->error : var_dump($senttx);

and got this output...

string(64) "bae6d6978da7a50422a943ac42017c64478169ce87a264d7cedbaa5a869558b4"

The transaction is confirmed and worked exactly as I hoped. :)


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.