<p>When you use <code>importprivkey</code>, the new private key is added to your wallet, giving you the ability to send coins received by a corresponding Bitcoin address. Your <strong>"balance"</strong> will also reflect this, including the coins accessible by this key in the total balance.</p>

<p>Bitcoind low level API gives you a pretty fine-grained control over your coins. Since there is no notion of a <em>"source address"</em> in the Bitcoin protocol, you have to specify the exact <strong>transaction and</strong> its <strong>output</strong> that you want to spend. Instead of using the common high-level RPC like <code>sendtoaddress</code>, you need to manually create a <a href="https://en.bitcoin.it/wiki/Raw_Transactions" rel="nofollow">raw transaction</a>, which comes in a few steps:</p>

<ol>
<li>Prepare the transaction via <code>createrawtransaction</code> command, specifying outputs that you want to spend,</li>
<li>Sign the transaction using your imported private key via <code>signrawtransaction</code>,</li>
<li>Send it onto network using <code>sendrawtransaction</code>.</li>
</ol>

<p>Be careful when using this API as Bitcoind does not protect you from making fatal mistakes, rendering your coins unspendable. Make sure you test your code on the testnet thoroughly before going live.</p>

CC BY-SA 3.0
2014-09-21T18:40:03.580Z
2014-09-21T18:40:03.580Z
knaperek
<p>A good way to think of it is when you import a key to your wallet all of its inputs are added to the "input pool" as i like to call it. When a sendtoaddress or sendmany command is initiated it will pull what it thinks are the best inputs to make that transaction from the "input pool". Keys can be added/removed from accounts at any time taking their inputs with them. (although a rescan is required and done by default which takes some time)</p>

<p>This is the way its designed to work. But if you want to customize it to work with you it is possible. Just always be cautious of modifying and know what your doing. Mistakes with bitcoin transaction are irreversible and can be quite costly. You have a few options.</p>

<p>Accounts are usefull for this. A wallet can have multiple accounts. Think of accounts as a way to group keys together. You could make a new account for each user then use the sendfrom command to initiate all withdrawals from the wallet. </p>

<p>bitcoind sendfrom "fromaccount" "tobitcoinaddress" "amount" [minconf=1]</p>

<p>Where "fromaccount" is the account you want to send from. "tobitcoinaddress" is the destination. "amount" is the amount you want to send and [minconf=1] will not allow it to spend any input with less than 1 confirmation or any value you specify.</p>

<p>This will send only from the account you specify. Each account can have as many addresses as you like or just one.</p>

<p>Just be aware accounts should never be used for balance tracking. Only for groupings of keys. And if you ever use the sendto or sendmany commands they will pull the inputs from all accounts to make the withdrawal</p>

CC BY-SA 3.0
2014-12-21T04:37:15.730Z
2014-12-21T04:37:15.730Z
Mullick
<p>Yes, you can send from specific address using RPC. For sure you can send money from specific address using raw transactions.<br>I haven't used bitcoind for a while, but I hope they might already have added CoinControl.</p>

CC BY-SA 3.0
2014-08-22T06:59:41.227Z
2014-08-22T06:59:41.227Z
ripazha
<p>What's happening when I use importprivkey? Are the coins merged to my existing private key or is the new key added to my wallet?</p>

<p>I want to import a private key, receive funds on it, and send the same coins using this key, not the others present in my wallet, is it possible with RPC commands? (for my website, I want the user to be able to see where his money is going by tracking the blockchain).</p>

<transactions><private-key>
How do I spend Bitcoins from a specific address?
heyo
# How do I spend Bitcoins from a specific address?

(Asked by: username_0 on 2014-08-21)

What's happening when I use importprivkey? Are the coins merged to my existing private key or is the new key added to my wallet?

I want to import a private key, receive funds on it, and send the same coins using this key, not the others present in my wallet, is it possible with RPC commands? (for my website, I want the user to be able to see where his money is going by tracking the blockchain).

**Tags:** transactions, private-key


---

## 3 answers

### Answer by username_1 on 2014-09-21. Score: 3

When you use `importprivkey`, the new private key is added to your wallet, giving you the ability to send coins received by a corresponding Bitcoin address. Your **"balance"** will also reflect this, including the coins accessible by this key in the total balance.

Bitcoind low level API gives you a pretty fine-grained control over your coins. Since there is no notion of a *"source address"* in the Bitcoin protocol, you have to specify the exact **transaction and** its **output** that you want to spend. Instead of using the common high-level RPC like `sendtoaddress`, you need to manually create a [raw transaction](https://en.bitcoin.it/wiki/Raw_Transactions), which comes in a few steps:

1. Prepare the transaction via `createrawtransaction` command, specifying outputs that you want to spend,
2. Sign the transaction using your imported private key via `signrawtransaction`,
3. Send it onto network using `sendrawtransaction`.

Be careful when using this API as Bitcoind does not protect you from making fatal mistakes, rendering your coins unspendable. Make sure you test your code on the testnet thoroughly before going live.


---

### Answer by username_2 on 2014-12-21. Score: 0

A good way to think of it is when you import a key to your wallet all of its inputs are added to the "input pool" as i like to call it. When a sendtoaddress or sendmany command is initiated it will pull what it thinks are the best inputs to make that transaction from the "input pool". Keys can be added/removed from accounts at any time taking their inputs with them. (although a rescan is required and done by default which takes some time)

This is the way its designed to work. But if you want to customize it to work with you it is possible. Just always be cautious of modifying and know what your doing. Mistakes with bitcoin transaction are irreversible and can be quite costly. You have a few options.

Accounts are usefull for this. A wallet can have multiple accounts. Think of accounts as a way to group keys together. You could make a new account for each user then use the sendfrom command to initiate all withdrawals from the wallet.

bitcoind sendfrom "fromaccount" "tobitcoinaddress" "amount" [minconf=1]

Where "fromaccount" is the account you want to send from. "tobitcoinaddress" is the destination. "amount" is the amount you want to send and [minconf=1] will not allow it to spend any input with less than 1 confirmation or any value you specify.

This will send only from the account you specify. Each account can have as many addresses as you like or just one.

Just be aware accounts should never be used for balance tracking. Only for groupings of keys. And if you ever use the sendto or sendmany commands they will pull the inputs from all accounts to make the withdrawal


---

### Answer by username_3 on 2014-08-22. Score: 0

Yes, you can send from specific address using RPC. For sure you can send money from specific address using raw transactions.  
I haven't used bitcoind for a while, but I hope they might already have added CoinControl.


---

