<p>I think you can. You definitely can do it from bitcoind (and it was possible with wxbitcoin), and I don't see any extra code that would prevent it. There's no reason for it to be prevented. I haven't tried it, though.</p>

CC BY-SA 3.0
2012-08-01T18:36:37.420Z
2012-08-01T18:36:37.420Z
theymos
<p>Yes.  Unlike other transactions you don't need to wait for the confirmations.</p>

<p>From the code which selects which coins to use to fund a transaction in <code>src/wallet.cpp</code>:</p>

<pre><code>bool CWallet::SelectCoins(int64 nTargetValue, [...])
{
    vector&lt;COutput&gt; vCoins;
    AvailableCoins(vCoins);

    return (SelectCoinsMinConf(nTargetValue, 1, 6, vCoins, setCoinsRet, nValueRet) ||
            SelectCoinsMinConf(nTargetValue, 1, 1, vCoins, setCoinsRet, nValueRet) ||
            SelectCoinsMinConf(nTargetValue, 0, 1, vCoins, setCoinsRet, nValueRet));
}
</code></pre>

<p>where <code>SelectCoinsMinConf</code>'s 2nd and 3rd arguments are "number of confirmations a coin needs if it's from me" and "number of confirmations a coin needs if it's from someone else" respectively:</p>

<pre><code>bool CWallet::SelectCoinsMinConf(int64 nTargetValue, int nConfMine, int nConfTheirs, [...])
{
    [...]
}
</code></pre>

<p>So what's happening is the code first tries to fund the transaction using only coins you sent to yourself which have at least 1 confirmation and coins from others with at least 6 confirmations.  If it can't find enough that way, it tries again but only requiring 1 confirmation on the coins no matter where they came from.  And if that also fails, it relaxes the requirement for confirmations on coins you sent to yourself.</p>

CC BY-SA 3.0
2012-08-01T18:39:48.260Z
2012-08-01T18:39:48.260Z
Chris Moore
<p>If I spend the entire balance in my wallet to another address in my own wallet, do I need to wait until it gets one confirmation in order to spend it, or does the client know it is my own funds and that it can be spent?</p>

<p>This can be <a href="http://bitcointalk.org/index.php?topic=96885.0">done via RPC</a>, but this question is specifically referring to using the bitcoin-qt client for this.</p>

<transactions><client><confirmations><zero-confirmation><funds>
Can I spend a coin sent to myself before it confirms?
Stephen Gornick
# Can I spend a coin sent to myself before it confirms?

(Asked by: username_0 on 2012-07-31)

If I spend the entire balance in my wallet to another address in my own wallet, do I need to wait until it gets one confirmation in order to spend it, or does the client know it is my own funds and that it can be spent?

This can be [done via RPC](http://bitcointalk.org/index.php?topic=96885.0), but this question is specifically referring to using the bitcoin-qt client for this.

**Tags:** transactions, client, confirmations, zero-confirmation, funds


---

## 2 answers

### Answer by username_2 on 2012-08-01. Score: 9 | Accepted answer

Yes. Unlike other transactions you don't need to wait for the confirmations.

From the code which selects which coins to use to fund a transaction in `src/wallet.cpp`:

```
bool CWallet::SelectCoins(int64 nTargetValue, [...])
{
    vector<COutput> vCoins;
    AvailableCoins(vCoins);

    return (SelectCoinsMinConf(nTargetValue, 1, 6, vCoins, setCoinsRet, nValueRet) ||
            SelectCoinsMinConf(nTargetValue, 1, 1, vCoins, setCoinsRet, nValueRet) ||
            SelectCoinsMinConf(nTargetValue, 0, 1, vCoins, setCoinsRet, nValueRet));
}

```

where `SelectCoinsMinConf`'s 2nd and 3rd arguments are "number of confirmations a coin needs if it's from me" and "number of confirmations a coin needs if it's from someone else" respectively:

```
bool CWallet::SelectCoinsMinConf(int64 nTargetValue, int nConfMine, int nConfTheirs, [...])
{
    [...]
}

```

So what's happening is the code first tries to fund the transaction using only coins you sent to yourself which have at least 1 confirmation and coins from others with at least 6 confirmations. If it can't find enough that way, it tries again but only requiring 1 confirmation on the coins no matter where they came from. And if that also fails, it relaxes the requirement for confirmations on coins you sent to yourself.


---

### Answer by username_1 on 2012-08-01. Score: 1

I think you can. You definitely can do it from bitcoind (and it was possible with wxbitcoin), and I don't see any extra code that would prevent it. There's no reason for it to be prevented. I haven't tried it, though.


---

