<p>Given that you only want to spend outputs received to a specific address, you would start by retrieving all unspent transaction outputs received to that address with <a href="https://bitcoincore.org/en/doc/27.0.0/rpc/wallet/listunspent/" rel="nofollow noreferrer"><code>listunspent</code></a>.</p>
<blockquote>
<pre><code>bitcoin-cli listunspent 1 9999999 &quot;[\&quot;your_address\&quot;]&quot;
</code></pre>
</blockquote>
<p>Then you can use the output of the <code>listunspent</code> call as the inputs of <a href="https://bitcoincore.org/en/doc/27.0.0/rpc/wallet/send/" rel="nofollow noreferrer"><code>send</code></a>, set a feerate, specify the specific recipient and amount, and define a change address.</p>
<p>Let’s use the syntax with <em>named arguments</em> to skip the positional arguments we don’t care about.</p>
<blockquote>
<pre><code>bitcoin-cli -named send outputs='{&quot;specific_address&quot;: specific_amount[BTC]}' fee_rate=[sat/vB] inputs=[{&quot;txid&quot;:&quot;a08e6907dbbd3d809776dbfc5d82e371b764ed838b5655e72f463568df1aadf0&quot;, &quot;vout&quot;:1}, &quot;txid&quot;:&quot;d3d809776dbfc5da08e6907dbb82e371b764ed838b5655e72f463568df1aadf0&quot;, &quot;vout&quot;:2},…] change_address=&quot;your_change_address&quot;
</code></pre>
</blockquote>

CC BY-SA 4.0
2024-05-31T14:41:27.983Z
2024-05-31T14:41:27.983Z
Murch
<p>Let's say I generated some coins with a given address and I want to send a specific amount of coins to a specific addresses, and move the remaining balance to another specific address. I want to do it all using bitcoind and an RPC call. It would be easy if it wasn't for the variable fee, based on the size of the transaction; just calculate the difference between what is in the first address and what needs to be paid out, and send the rest to the other address.</p>

<p>Is there some way to set an address in bitcoind that is to receive all the change, or to get some information on what the fee for the given transaction should be?</p>

<transactions><bitcoind><bitcoin-core><json-rpc><transaction-fees>
Move all coins from an address via RPC
ThePiachu
# Move all coins from an address via RPC

(Asked by: username_0 on 2012-02-09)

Let's say I generated some coins with a given address and I want to send a specific amount of coins to a specific addresses, and move the remaining balance to another specific address. I want to do it all using bitcoind and an RPC call. It would be easy if it wasn't for the variable fee, based on the size of the transaction; just calculate the difference between what is in the first address and what needs to be paid out, and send the rest to the other address.

Is there some way to set an address in bitcoind that is to receive all the change, or to get some information on what the fee for the given transaction should be?

**Tags:** transactions, bitcoind, bitcoin-core, json-rpc, transaction-fees


---

## 1 answers

### Answer by username_1 on 2024-05-31. Score: 1 | Accepted answer

Given that you only want to spend outputs received to a specific address, you would start by retrieving all unspent transaction outputs received to that address with [`listunspent`](https://bitcoincore.org/en/doc/27.0.0/rpc/wallet/listunspent/).

> ```
> bitcoin-cli listunspent 1 9999999 "[\"your_address\"]"
>
> ```

Then you can use the output of the `listunspent` call as the inputs of [`send`](https://bitcoincore.org/en/doc/27.0.0/rpc/wallet/send/), set a feerate, specify the specific recipient and amount, and define a change address.

Let’s use the syntax with *named arguments* to skip the positional arguments we don’t care about.

> ```
> bitcoin-cli -named send outputs='{"specific_address": specific_amount[BTC]}' fee_rate=[sat/vB] inputs=[{"txid":"a08e6907dbbd3d809776dbfc5d82e371b764ed838b5655e72f463568df1aadf0", "vout":1}, "txid":"d3d809776dbfc5da08e6907dbb82e371b764ed838b5655e72f463568df1aadf0", "vout":2},…] change_address="your_change_address"
>
> ```


---

