Author

Topic: Help! I keep getting "Error: Transaction creation failed" (Read 4208 times)

staff
Activity: 4284
Merit: 8808
edit: Problem solved
export privkeys and import to new wallet helpd
If you are abandoning the dust in your old wallet, can I please have your old wallet so that I can clean up the data from the network so the network doesn't have to store that junk forever? (I'd also like to try fixing it so that this doesn't happen so easily)
full member
Activity: 128
Merit: 100
i know this topic is old Wink but i have same problem "Error: Transaction creation failed"

edit: Problem solved

export privkeys and import to new wallet helpd

How did you do it? I have the same problem now with client 8.3
full member
Activity: 126
Merit: 100
i know this topic is old Wink but i have same problem "Error: Transaction creation failed"

Seriouscoin did u menaged to solve this ?

i want to send 0.5 BTC to someone and i cant, bcoz im getting this error
i was trying to set diferent provisions - 0.00025, 0.0005, 0.001, 0.01, and even 0.1 (lol)

im using bitcoin-qt 0.8.1

pls help

ofc client is synchronized etc

i was trying with -keypool 1000 but still doesnt work
i was also trying to send btc to 2 diferent adresses


edit: Problem solved

export privkeys and import to new wallet helpd
legendary
Activity: 1512
Merit: 1036
Another possibility is that there is a larger fee required due to the current block size

Code misunderstanding detected:  The fees used in the generation of a txn have absolutely nothing to do with the current block size.
Wiki correction demanded then...

staff
Activity: 4284
Merit: 8808
Another possibility is that there is a larger fee required due to the current block size

Code misunderstanding detected:  The fees used in the generation of a txn have absolutely nothing to do with the current block size.

The most common cause of this kind of failure I've seen in the past is when a wallet is contaminated by zillions of very small inputs and ends up selecting so many the the resulting txn is >100KB, which it refuses to issue.

Litecoin carries a patch the sets a minimum value for inputs to be considered in coin selection.

legendary
Activity: 1512
Merit: 1036
Has an error been written to debug.log?

I would close and re-launch Bitcoin with the -rescan command line option so you can be sure your balances are correct (they may be in wrong change addresses etc, you may not see a balance problem in Bitcoin-qt.

Here is the code that seems to generate the error, the function SendMoney:

wallet.cpp
Code:
string CWallet::SendMoney(CScript scriptPubKey, int64 nValue, CWalletTx& wtxNew, bool fAskFee)
{
    CReserveKey reservekey(this);
    int64 nFeeRequired;

    if (IsLocked())
    {
        string strError = _("Error: Wallet locked, unable to create transaction  ");
        printf("SendMoney() : %s", strError.c_str());
        return strError;
    }
    if (!CreateTransaction(scriptPubKey, nValue, wtxNew, reservekey, nFeeRequired))
    {
        string strError;
        if (nValue + nFeeRequired > GetBalance())
            strError = strprintf(_("Error: This transaction requires a transaction fee of at least %s because of its amount, complexity, or use of recently received funds  "), FormatMoney(nFeeRequired).c_str());
        else
            strError = _("Error: Transaction creation failed  ");
        printf("SendMoney() : %s", strError.c_str());
        return strError;
    }

    if (fAskFee && !ThreadSafeAskFee(nFeeRequired, _("Sending...")))
        return "ABORTED";

    if (!CommitTransaction(wtxNew, reservekey))
        return _("Error: The transaction was rejected.  This might happen if some of the coins in your wallet were already spent, such as if you used a copy of wallet.dat and coins were spent in the copy but not marked as spent here.");

    MainFrameRepaint();
    return "";
}

This seems to an error-catchall that the function CreateTransaction() failed, but not due to balance, fee, or file lock issues.

Something went wrong in here and it didn't return a true:

Code:

bool CWallet::CreateTransaction(const vector >& vecSend, CWalletTx& wtxNew, CReserveKey& reservekey, int64& nFeeRet)
{
    int64 nValue = 0;
    BOOST_FOREACH (const PAIRTYPE(CScript, int64)& s, vecSend)
    {
        if (nValue < 0)
            return false;
        nValue += s.second;
    }
    if (vecSend.empty() || nValue < 0)
        return false;

    wtxNew.BindWallet(this);

    {
        LOCK2(cs_main, cs_wallet);
        // txdb must be opened before the mapWallet lock
        CTxDB txdb("r");
        {
            nFeeRet = nTransactionFee;
            loop
            {
                wtxNew.vin.clear();
                wtxNew.vout.clear();
                wtxNew.fFromMe = true;

                int64 nTotalValue = nValue + nFeeRet;
                double dPriority = 0;
                // vouts to the payees
                BOOST_FOREACH (const PAIRTYPE(CScript, int64)& s, vecSend)
                    wtxNew.vout.push_back(CTxOut(s.second, s.first));

                // Choose coins to use
                set > setCoins;
                int64 nValueIn = 0;
                if (!SelectCoins(nTotalValue, setCoins, nValueIn))
                    return false;
                BOOST_FOREACH(PAIRTYPE(const CWalletTx*, unsigned int) pcoin, setCoins)
                {
                    int64 nCredit = pcoin.first->vout[pcoin.second].nValue;
                    dPriority += (double)nCredit * pcoin.first->GetDepthInMainChain();
                }

                int64 nChange = nValueIn - nValue - nFeeRet;
                // if sub-cent change is required, the fee must be raised to at least MIN_TX_FEE
                // or until nChange becomes zero
                // NOTE: this depends on the exact behaviour of GetMinFee
                if (nFeeRet < MIN_TX_FEE && nChange > 0 && nChange < CENT)
                {
                    int64 nMoveToFee = min(nChange, MIN_TX_FEE - nFeeRet);
                    nChange -= nMoveToFee;
                    nFeeRet += nMoveToFee;
                }

                if (nChange > 0)
                {
                    // Note: We use a new key here to keep it from being obvious which side is the change.
                    //  The drawback is that by not reusing a previous key, the change may be lost if a
                    //  backup is restored, if the backup doesn't have the new private key for the change.
                    //  If we reused the old key, it would be possible to add code to look for and
                    //  rediscover unknown transactions that were written with keys of ours to recover
                    //  post-backup change.

                    // Reserve a new key pair from key pool
                    vector vchPubKey = reservekey.GetReservedKey();
                    // assert(mapKeys.count(vchPubKey));

                    // Fill a vout to ourself
                    // TODO: pass in scriptChange instead of reservekey so
                    // change transaction isn't always pay-to-bitcoin-address
                    CScript scriptChange;
                    scriptChange.SetBitcoinAddress(vchPubKey);

                    // Insert change txn at random position:
                    vector::iterator position = wtxNew.vout.begin()+GetRandInt(wtxNew.vout.size());
                    wtxNew.vout.insert(position, CTxOut(nChange, scriptChange));
                }
                else
                    reservekey.ReturnKey();

                // Fill vin
                BOOST_FOREACH(const PAIRTYPE(const CWalletTx*,unsigned int)& coin, setCoins)
                    wtxNew.vin.push_back(CTxIn(coin.first->GetHash(),coin.second));

                // Sign
                int nIn = 0;
                BOOST_FOREACH(const PAIRTYPE(const CWalletTx*,unsigned int)& coin, setCoins)
                    if (!SignSignature(*this, *coin.first, wtxNew, nIn++))
                        return false;

                // Limit size
                unsigned int nBytes = ::GetSerializeSize(*(CTransaction*)&wtxNew, SER_NETWORK, PROTOCOL_VERSION);
                if (nBytes >= MAX_BLOCK_SIZE_GEN/5)
                    return false;
                dPriority /= nBytes;

                // Check that enough fee is included
                int64 nPayFee = nTransactionFee * (1 + (int64)nBytes / 1000);
                bool fAllowFree = CTransaction::AllowFree(dPriority);
                int64 nMinFee = wtxNew.GetMinFee(1, fAllowFree, GMF_SEND);
                if (nFeeRet < max(nPayFee, nMinFee))
                {
                    nFeeRet = max(nPayFee, nMinFee);
                    continue;
                }

                // Fill vtxPrev by copying from previous transactions vtxPrev
                wtxNew.AddSupportingTransactions(txdb);
                wtxNew.fTimeReceivedIsTxTime = true;

                break;
            }
        }
    }
    return true;
}

I would look at all the "return false" cases above and figure out if something about your transaction (balances, etc) might set off one of them. Another thing you can do to throw random ideas at the problem is create more reserve addresses starting Bitcoin with the command-line option bitcoin.exe -keypool=150.

Another possibility is that there is a larger fee required due to the current block size or size of inputs you are using, but a bug in the client isn't prompting for that, you could bump up the voluntary fee in the client to .01 and see if it goes.
hero member
Activity: 658
Merit: 500
I test with tiny amount (0.1 BTC) and the transaction created fine.

When i try to make the full payment amount, i got this error.

I'm using BitcoinQT0.6.2

Someone please explain what could be the problem.

Jump to: