7

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, but this question is specifically referring to using the bitcoin-qt client for this.

2 Answers 2

9

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.

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.

Your Answer

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

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