Bitcoin Forum
April 25, 2024, 12:51:46 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Help! I keep getting "Error: Transaction creation failed"  (Read 4182 times)
seriouscoin (OP)
Hero Member
*****
Offline Offline

Activity: 658
Merit: 500


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.

1714049507
Hero Member
*
Offline Offline

Posts: 1714049507

View Profile Personal Message (Offline)

Ignore
1714049507
Reply with quote  #2

1714049507
Report to moderator
1714049507
Hero Member
*
Offline Offline

Posts: 1714049507

View Profile Personal Message (Offline)

Ignore
1714049507
Reply with quote  #2

1714049507
Report to moderator
There are several different types of Bitcoin clients. The most secure are full nodes like Bitcoin Core, which will follow the rules of the network no matter what miners do. Even if every miner decided to create 1000 bitcoins per block, full nodes would stick to the rules and reject those blocks.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1714049507
Hero Member
*
Offline Offline

Posts: 1714049507

View Profile Personal Message (Offline)

Ignore
1714049507
Reply with quote  #2

1714049507
Report to moderator
1714049507
Hero Member
*
Offline Offline

Posts: 1714049507

View Profile Personal Message (Offline)

Ignore
1714049507
Reply with quote  #2

1714049507
Report to moderator
1714049507
Hero Member
*
Offline Offline

Posts: 1714049507

View Profile Personal Message (Offline)

Ignore
1714049507
Reply with quote  #2

1714049507
Report to moderator
deepceleron
Legendary
*
Offline Offline

Activity: 1512
Merit: 1025



View Profile WWW
June 24, 2012, 07:11:13 PM
Last edit: June 24, 2012, 07:23:03 PM by deepceleron
 #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
*
expert
Offline Offline

Activity: 4158
Merit: 8382



View Profile WWW
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: 1512
Merit: 1025



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
Merit: 100


View Profile
May 04, 2013, 05:07:03 PM
Last edit: May 04, 2013, 10:37:15 PM by hanti
 #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
Merit: 100


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
*
expert
Offline Offline

Activity: 4158
Merit: 8382



View Profile WWW
September 04, 2013, 04:57:03 AM
Last edit: September 04, 2013, 05:18:07 AM by gmaxwell
 #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:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!