Merge branch 'spentpertxout' of https://github.com/sipa/bitcoin
authorGavin Andresen <gavinandresen@gmail.com>
Tue, 12 Apr 2011 21:27:15 +0000 (17:27 -0400)
committerGavin Andresen <gavinandresen@gmail.com>
Tue, 12 Apr 2011 21:27:15 +0000 (17:27 -0400)
1  2 
main.cpp

diff --combined main.cpp
+++ b/main.cpp
@@@ -65,14 -65,6 +65,14 @@@ int fLimitProcessors = false
  int nLimitProcessors = 1;
  int fMinimizeToTray = true;
  int fMinimizeOnClose = true;
 +#ifdef USE_UPNP
 +#if USE_UPNP
 +int fUseUPnP = true;
 +#else
 +int fUseUPnP = false;
 +#endif
 +#endif
 +
  
  
  
@@@ -958,6 -950,8 +958,8 @@@ void ReacceptWalletTransactions(
                  }
                  for (int i = 0; i < txindex.vSpent.size(); i++)
                  {
+                     if (wtx.IsSpent(i))
+                         continue;
                      if (!txindex.vSpent[i].IsNull() && wtx.vout[i].IsMine())
                      {
                          wtx.MarkSpent(i);
@@@ -4068,35 -4062,35 +4070,35 @@@ bool CommitTransaction(CWalletTx& wtxNe
  
  
  
 +// requires cs_main lock
  string SendMoney(CScript scriptPubKey, int64 nValue, CWalletTx& wtxNew, bool fAskFee)
  {
 -    CRITICAL_BLOCK(cs_main)
 +    CReserveKey reservekey;
 +    int64 nFeeRequired;
 +    if (!CreateTransaction(scriptPubKey, nValue, wtxNew, reservekey, nFeeRequired))
      {
 -        CReserveKey reservekey;
 -        int64 nFeeRequired;
 -        if (!CreateTransaction(scriptPubKey, nValue, wtxNew, reservekey, nFeeRequired))
 -        {
 -            string strError;
 -            if (nValue + nFeeRequired > GetBalance())
 -                strError = strprintf(_("Error: This is an oversized transaction that requires a transaction fee of %s  "), FormatMoney(nFeeRequired).c_str());
 -            else
 -                strError = _("Error: Transaction creation failed  ");
 -            printf("SendMoney() : %s", strError.c_str());
 -            return strError;
 -        }
 +        string strError;
 +        if (nValue + nFeeRequired > GetBalance())
 +            strError = strprintf(_("Error: This is an oversized transaction that requires a transaction fee of %s  "), FormatMoney(nFeeRequired).c_str());
 +        else
 +            strError = _("Error: Transaction creation failed  ");
 +        printf("SendMoney() : %s", strError.c_str());
 +        return strError;
 +    }
  
 -        if (fAskFee && !ThreadSafeAskFee(nFeeRequired, _("Sending..."), NULL))
 -            return "ABORTED";
 +    if (fAskFee && !ThreadSafeAskFee(nFeeRequired, _("Sending..."), NULL))
 +        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.");
  
 -        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 "";
  }
  
  
  
 +// requires cs_main lock
  string SendMoneyToBitcoinAddress(string strAddress, int64 nValue, CWalletTx& wtxNew, bool fAskFee)
  {
      // Check amount