Bitcoin Forum
December 04, 2016, 08:24:48 PM *
News: To be able to use the next phase of the beta forum software, please ensure that your email address is correct/functional.
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: Help! I keep getting "Error: Transaction creation failed"  (Read 3769 times)
seriouscoin
Hero Member
*****
Offline Offline

Activity: 658


View Profile
June 24, 2012, 01:38:40 AM
 #1

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.

1480883088
Hero Member
*
Offline Offline

Posts: 1480883088

View Profile Personal Message (Offline)

Ignore
1480883088
Reply with quote  #2

1480883088
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1480883088
Hero Member
*
Offline Offline

Posts: 1480883088

View Profile Personal Message (Offline)

Ignore
1480883088
Reply with quote  #2

1480883088
Report to moderator
deepceleron
Legendary
*
Offline Offline

Activity: 1470



View Profile WWW
June 24, 2012, 07:11:13 PM
 #2

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<pair<CScript, int64> >& 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<pair<const CWalletTx*,unsigned int> > 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<unsigned char> 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<CTxOut>::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.

gmaxwell
Moderator
Legendary
*
qt
Offline Offline

Activity: 2016



View Profile
June 24, 2012, 11:30:43 PM
 #3

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.

deepceleron
Legendary
*
Offline Offline

Activity: 1470



View Profile WWW
June 25, 2012, 12:25:15 AM
 #4

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...


hanti
Full Member
***
Offline Offline

Activity: 126


View Profile
May 04, 2013, 05:07:03 PM
 #5

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

cdnbcguy
Full Member
***
Offline Offline

Activity: 128


View Profile WWW
September 04, 2013, 04:35:54 AM
 #6

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

Annona ad! Please keep in mind that there is nothing wrong with Bitcoin itself. All it's scandals are caused by wonky websites and sleazy people exploiting it. The light attracts bugs.

When all this bullshit drys up and blows away, Bitcoin will be stronger than ever.
gmaxwell
Moderator
Legendary
*
qt
Offline Offline

Activity: 2016



View Profile
September 04, 2013, 04:57:03 AM
 #7

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)
Pages: [1]
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!