Merge remote branch 'refs/remotes/svn/trunk' into svn

This commit is contained in:
Gavin Andresen 2010-09-30 14:28:23 -04:00
commit 369010406e
22 changed files with 187 additions and 130 deletions

2
db.cpp
View file

@ -465,7 +465,7 @@ bool CTxDB::LoadBlockIndex()
CBlockIndex* pindexFork = NULL; CBlockIndex* pindexFork = NULL;
for (CBlockIndex* pindex = pindexBest; pindex && pindex->pprev; pindex = pindex->pprev) for (CBlockIndex* pindex = pindexBest; pindex && pindex->pprev; pindex = pindex->pprev)
{ {
if (pindex->nHeight < 74000 && !mapArgs.count("-checkblocks")) if (pindex->nHeight < nBestHeight-2500 && !mapArgs.count("-checkblocks"))
break; break;
CBlock block; CBlock block;
if (!block.ReadFromDisk(pindex)) if (!block.ReadFromDisk(pindex))

View file

@ -203,7 +203,7 @@ bool AppInit2(int argc, char* argv[])
if (!fDebug && !pszSetDataDir[0]) if (!fDebug && !pszSetDataDir[0])
ShrinkDebugFile(); ShrinkDebugFile();
printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
printf("Bitcoin version %d.%d.%d%s beta\n", VERSION/10000, (VERSION/100)%100, VERSION%100, pszSubVer); printf("Bitcoin version %s%s beta\n", FormatVersion(VERSION).c_str(), pszSubVer);
#ifdef GUI #ifdef GUI
printf("OS version %s\n", ((string)wxGetOsDescription()).c_str()); printf("OS version %s\n", ((string)wxGetOsDescription()).c_str());
printf("System default language is %d %s\n", g_locale.GetSystemLanguage(), ((string)g_locale.GetSysName()).c_str()); printf("System default language is %d %s\n", g_locale.GetSystemLanguage(), ((string)g_locale.GetSysName()).c_str());

Binary file not shown.

View file

@ -321,8 +321,8 @@ msgstr "Beim schließen &Minimieren"
#: ../../../ui.cpp:1595 #: ../../../ui.cpp:1595
#, c-format #, c-format
msgid "version 0.%d.%d beta" msgid "version %s%s beta"
msgstr "Version 0.%d.%d Beta" msgstr "Version %s%s Beta"
#: ../../../ui.cpp:1681 #: ../../../ui.cpp:1681
msgid "Will appear as \"From: Unknown\"" msgid "Will appear as \"From: Unknown\""

Binary file not shown.

View file

@ -350,8 +350,8 @@ msgstr "&Minimizar al cerrar"
#: ../../../ui.cpp:1610 #: ../../../ui.cpp:1610
#, c-format #, c-format
msgid "version %d.%d.%d beta" msgid "version %s%s beta"
msgstr "version %d.%d.%d beta" msgstr "version %s%s beta"
#: ../../../ui.cpp:1696 #: ../../../ui.cpp:1696
msgid "Will appear as \"From: Unknown\"" msgid "Will appear as \"From: Unknown\""

Binary file not shown.

View file

@ -351,8 +351,8 @@ msgstr "&Réduire à la fermeture"
#: ../../../ui.cpp:1610 #: ../../../ui.cpp:1610
#, c-format #, c-format
msgid "version %d.%d.%d beta" msgid "version %s%s beta"
msgstr "version %d.%d.%d beta" msgstr "version %s%s beta"
#: ../../../ui.cpp:1696 #: ../../../ui.cpp:1696
msgid "Will appear as \"From: Unknown\"" msgid "Will appear as \"From: Unknown\""

Binary file not shown.

View file

@ -319,8 +319,8 @@ msgstr "&Minimizza se chiuso"
#: ../../../ui.cpp:1595 #: ../../../ui.cpp:1595
#, c-format #, c-format
msgid "version 0.%d.%d beta" msgid "version %s%s beta"
msgstr "versione 0.%d.%d beta" msgstr "versione %s%s beta"
#: ../../../ui.cpp:1681 #: ../../../ui.cpp:1681
msgid "Will appear as \"From: Unknown\"" msgid "Will appear as \"From: Unknown\""

Binary file not shown.

View file

@ -320,8 +320,8 @@ msgstr "&Minimalizeer bij sluiten"
#: ../../../ui.cpp:1595 #: ../../../ui.cpp:1595
#, c-format #, c-format
msgid "version 0.%d.%d beta" msgid "version %s%s beta"
msgstr "versie 0.%d.%d beta" msgstr "versie %s%s beta"
#: ../../../ui.cpp:1681 #: ../../../ui.cpp:1681
msgid "Will appear as \"From: Unknown\"" msgid "Will appear as \"From: Unknown\""

Binary file not shown.

View file

@ -319,8 +319,8 @@ msgstr "&Minimizar ao fechar"
#: ../../../ui.cpp:1595 #: ../../../ui.cpp:1595
#, c-format #, c-format
msgid "version 0.%d.%d beta" msgid "version %s%s beta"
msgstr "versão 0.%d.%d beta" msgstr "versão %s%s beta"
#: ../../../ui.cpp:1681 #: ../../../ui.cpp:1681
msgid "Will appear as \"From: Unknown\"" msgid "Will appear as \"From: Unknown\""

View file

@ -487,18 +487,56 @@ void CWalletTx::AddSupportingTransactions(CTxDB& txdb)
bool CTransaction::CheckTransaction() const
{
// Basic checks that don't depend on any context
if (vin.empty() || vout.empty())
return error("CTransaction::CheckTransaction() : vin or vout empty");
// Size limits
if (::GetSerializeSize(*this, SER_NETWORK) > MAX_BLOCK_SIZE)
return error("CTransaction::CheckTransaction() : size limits failed");
// Check for negative or overflow output values
int64 nValueOut = 0;
foreach(const CTxOut& txout, vout)
{
if (txout.nValue < 0)
return error("CTransaction::CheckTransaction() : txout.nValue negative");
if (txout.nValue > MAX_MONEY)
return error("CTransaction::CheckTransaction() : txout.nValue too high");
nValueOut += txout.nValue;
if (!MoneyRange(nValueOut))
return error("CTransaction::CheckTransaction() : txout total out of range");
}
if (IsCoinBase())
{
if (vin[0].scriptSig.size() < 2 || vin[0].scriptSig.size() > 100)
return error("CTransaction::CheckTransaction() : coinbase script size");
}
else
{
foreach(const CTxIn& txin, vin)
if (txin.prevout.IsNull())
return error("CTransaction::CheckTransaction() : prevout is null");
}
return true;
}
bool CTransaction::AcceptToMemoryPool(CTxDB& txdb, bool fCheckInputs, bool* pfMissingInputs) bool CTransaction::AcceptToMemoryPool(CTxDB& txdb, bool fCheckInputs, bool* pfMissingInputs)
{ {
if (pfMissingInputs) if (pfMissingInputs)
*pfMissingInputs = false; *pfMissingInputs = false;
if (!CheckTransaction())
return error("AcceptToMemoryPool() : CheckTransaction failed");
// Coinbase is only valid in a block, not as a loose transaction // Coinbase is only valid in a block, not as a loose transaction
if (IsCoinBase()) if (IsCoinBase())
return error("AcceptToMemoryPool() : coinbase as individual tx"); return error("AcceptToMemoryPool() : coinbase as individual tx");
if (!CheckTransaction())
return error("AcceptToMemoryPool() : CheckTransaction failed");
// To help v0.1.5 clients who would see it as a negative number // To help v0.1.5 clients who would see it as a negative number
if ((int64)nLockTime > INT_MAX) if ((int64)nLockTime > INT_MAX)
return error("AcceptToMemoryPool() : not accepting nLockTime beyond 2038 yet"); return error("AcceptToMemoryPool() : not accepting nLockTime beyond 2038 yet");
@ -815,7 +853,7 @@ uint256 GetOrphanRoot(const CBlock* pblock)
return pblock->GetHash(); return pblock->GetHash();
} }
int64 CBlock::GetBlockValue(int nHeight, int64 nFees) const int64 GetBlockValue(int nHeight, int64 nFees)
{ {
int64 nSubsidy = 50 * COIN; int64 nSubsidy = 50 * COIN;
@ -1024,6 +1062,11 @@ bool CTransaction::ConnectInputs(CTxDB& txdb, map<uint256, CTxIndex>& mapTestPoo
if (!txindex.vSpent[prevout.n].IsNull()) if (!txindex.vSpent[prevout.n].IsNull())
return fMiner ? false : error("ConnectInputs() : %s prev tx already used at %s", GetHash().ToString().substr(0,6).c_str(), txindex.vSpent[prevout.n].ToString().c_str()); return fMiner ? false : error("ConnectInputs() : %s prev tx already used at %s", GetHash().ToString().substr(0,6).c_str(), txindex.vSpent[prevout.n].ToString().c_str());
// Check for negative or overflow input values
nValueIn += txPrev.vout[prevout.n].nValue;
if (!MoneyRange(txPrev.vout[prevout.n].nValue) || !MoneyRange(nValueIn))
return error("ConnectInputs() : txin values out of range");
// Mark outpoints as spent // Mark outpoints as spent
txindex.vSpent[prevout.n] = posThisTx; txindex.vSpent[prevout.n] = posThisTx;
@ -1032,12 +1075,6 @@ bool CTransaction::ConnectInputs(CTxDB& txdb, map<uint256, CTxIndex>& mapTestPoo
txdb.UpdateTxIndex(prevout.hash, txindex); txdb.UpdateTxIndex(prevout.hash, txindex);
else if (fMiner) else if (fMiner)
mapTestPool[prevout.hash] = txindex; mapTestPool[prevout.hash] = txindex;
nValueIn += txPrev.vout[prevout.n].nValue;
// Check for negative or overflow input values
if (!MoneyRange(txPrev.vout[prevout.n].nValue) || !MoneyRange(nValueIn))
return error("ConnectInputs() : txin values out of range");
} }
if (nValueIn < GetValueOut()) if (nValueIn < GetValueOut())
@ -2967,7 +3004,7 @@ void BitcoinMiner()
} }
} }
pblock->nBits = nBits; pblock->nBits = nBits;
pblock->vtx[0].vout[0].nValue = pblock->GetBlockValue(pindexPrev->nHeight+1, nFees); pblock->vtx[0].vout[0].nValue = GetBlockValue(pindexPrev->nHeight+1, nFees);
printf("Running BitcoinMiner with %d transactions in block\n", pblock->vtx.size()); printf("Running BitcoinMiner with %d transactions in block\n", pblock->vtx.size());
@ -3169,6 +3206,8 @@ int64 GetBalance()
CWalletTx* pcoin = &(*it).second; CWalletTx* pcoin = &(*it).second;
if (!pcoin->IsFinal() || pcoin->fSpent) if (!pcoin->IsFinal() || pcoin->fSpent)
continue; continue;
if (pcoin->GetDepthInMainChain() < 1 && pcoin->GetDebit() <= 0)
continue;
nTotal += pcoin->GetCredit(true); nTotal += pcoin->GetCredit(true);
} }
} }
@ -3200,6 +3239,8 @@ bool SelectCoins(int64 nTargetValue, set<CWalletTx*>& setCoinsRet)
{ {
if (!pcoin->IsFinal() || pcoin->fSpent) if (!pcoin->IsFinal() || pcoin->fSpent)
continue; continue;
if (pcoin->GetDepthInMainChain() < 1 && pcoin->GetDebit() <= 0)
continue;
int64 n = pcoin->GetCredit(); int64 n = pcoin->GetCredit();
if (n <= 0) if (n <= 0)
continue; continue;

100
main.h
View file

@ -469,44 +469,6 @@ public:
return (vin.size() == 1 && vin[0].prevout.IsNull()); return (vin.size() == 1 && vin[0].prevout.IsNull());
} }
bool CheckTransaction() const
{
// Basic checks that don't depend on any context
if (vin.empty() || vout.empty())
return error("CTransaction::CheckTransaction() : vin or vout empty");
// Size limits
if (::GetSerializeSize(*this, SER_NETWORK) > MAX_BLOCK_SIZE)
return error("CTransaction::CheckTransaction() : size limits failed");
// Check for negative or overflow output values
int64 nValueOut = 0;
foreach(const CTxOut& txout, vout)
{
if (txout.nValue < 0)
return error("CTransaction::CheckTransaction() : txout.nValue negative");
if (txout.nValue > MAX_MONEY)
return error("CTransaction::CheckTransaction() : txout.nValue too high");
nValueOut += txout.nValue;
if (!MoneyRange(nValueOut))
return error("CTransaction::CheckTransaction() : txout total out of range");
}
if (IsCoinBase())
{
if (vin[0].scriptSig.size() < 2 || vin[0].scriptSig.size() > 100)
return error("CTransaction::CheckTransaction() : coinbase script size");
}
else
{
foreach(const CTxIn& txin, vin)
if (txin.prevout.IsNull())
return error("CTransaction::CheckTransaction() : prevout is null");
}
return true;
}
int GetSigOpCount() const int GetSigOpCount() const
{ {
int n = 0; int n = 0;
@ -655,20 +617,17 @@ public:
} }
bool DisconnectInputs(CTxDB& txdb); bool DisconnectInputs(CTxDB& txdb);
bool ConnectInputs(CTxDB& txdb, map<uint256, CTxIndex>& mapTestPool, CDiskTxPos posThisTx, bool ConnectInputs(CTxDB& txdb, map<uint256, CTxIndex>& mapTestPool, CDiskTxPos posThisTx,
CBlockIndex* pindexBlock, int64& nFees, bool fBlock, bool fMiner, int64 nMinFee=0); CBlockIndex* pindexBlock, int64& nFees, bool fBlock, bool fMiner, int64 nMinFee=0);
bool ClientConnectInputs(); bool ClientConnectInputs();
bool CheckTransaction() const;
bool AcceptToMemoryPool(CTxDB& txdb, bool fCheckInputs=true, bool* pfMissingInputs=NULL); bool AcceptToMemoryPool(CTxDB& txdb, bool fCheckInputs=true, bool* pfMissingInputs=NULL);
bool AcceptToMemoryPool(bool fCheckInputs=true, bool* pfMissingInputs=NULL) bool AcceptToMemoryPool(bool fCheckInputs=true, bool* pfMissingInputs=NULL)
{ {
CTxDB txdb("r"); CTxDB txdb("r");
return AcceptToMemoryPool(txdb, fCheckInputs, pfMissingInputs); return AcceptToMemoryPool(txdb, fCheckInputs, pfMissingInputs);
} }
protected: protected:
bool AddToMemoryPoolUnchecked(); bool AddToMemoryPoolUnchecked();
public: public:
@ -690,9 +649,7 @@ public:
int nIndex; int nIndex;
// memory only // memory only
mutable bool fMerkleVerified; mutable char fMerkleVerified;
mutable bool fGetCreditCached;
mutable int64 nGetCreditCached;
CMerkleTx() CMerkleTx()
@ -710,8 +667,6 @@ public:
hashBlock = 0; hashBlock = 0;
nIndex = -1; nIndex = -1;
fMerkleVerified = false; fMerkleVerified = false;
fGetCreditCached = false;
nGetCreditCached = 0;
} }
IMPLEMENT_SERIALIZE IMPLEMENT_SERIALIZE
@ -723,20 +678,6 @@ public:
READWRITE(nIndex); READWRITE(nIndex);
) )
int64 GetCredit(bool fUseCache=false) const
{
// Must wait until coinbase is safely deep enough in the chain before valuing it
if (IsCoinBase() && GetBlocksToMaturity() > 0)
return 0;
// GetBalance can assume transactions in mapWallet won't change
if (fUseCache && fGetCreditCached)
return nGetCreditCached;
nGetCreditCached = CTransaction::GetCredit();
fGetCreditCached = true;
return nGetCreditCached;
}
int SetMerkleBranch(const CBlock* pblock=NULL); int SetMerkleBranch(const CBlock* pblock=NULL);
int GetDepthInMainChain(int& nHeightRet) const; int GetDepthInMainChain(int& nHeightRet) const;
@ -767,9 +708,16 @@ public:
char fSpent; char fSpent;
//// probably need to sign the order info so know it came from payer //// probably need to sign the order info so know it came from payer
// memory only
mutable char fDebitCached;
mutable char fCreditCached;
mutable int64 nDebitCached;
mutable int64 nCreditCached;
// memory only UI hints // memory only UI hints
mutable unsigned int nTimeDisplayed; mutable unsigned int nTimeDisplayed;
mutable int nLinesDisplayed; mutable int nLinesDisplayed;
mutable char fConfirmedDisplayed;
CWalletTx() CWalletTx()
@ -793,6 +741,10 @@ public:
nTimeReceived = 0; nTimeReceived = 0;
fFromMe = false; fFromMe = false;
fSpent = false; fSpent = false;
fDebitCached = false;
fCreditCached = false;
nDebitCached = 0;
nCreditCached = 0;
nTimeDisplayed = 0; nTimeDisplayed = 0;
nLinesDisplayed = 0; nLinesDisplayed = 0;
} }
@ -810,6 +762,31 @@ public:
READWRITE(fSpent); READWRITE(fSpent);
) )
int64 GetDebit() const
{
if (vin.empty())
return 0;
if (fDebitCached)
return nDebitCached;
nDebitCached = CTransaction::GetDebit();
fDebitCached = true;
return nDebitCached;
}
int64 GetCredit(bool fUseCache=false) const
{
// Must wait until coinbase is safely deep enough in the chain before valuing it
if (IsCoinBase() && GetBlocksToMaturity() > 0)
return 0;
// GetBalance can assume transactions in mapWallet won't change
if (fUseCache && fCreditCached)
return nCreditCached;
nCreditCached = CTransaction::GetCredit();
fCreditCached = true;
return nCreditCached;
}
bool WriteToDisk() bool WriteToDisk()
{ {
return CWalletDB().WriteTx(GetHash(), *this); return CWalletDB().WriteTx(GetHash(), *this);
@ -1103,7 +1080,6 @@ public:
} }
int64 GetBlockValue(int nHeight, int64 nFees) const;
bool DisconnectBlock(CTxDB& txdb, CBlockIndex* pindex); bool DisconnectBlock(CTxDB& txdb, CBlockIndex* pindex);
bool ConnectBlock(CTxDB& txdb, CBlockIndex* pindex); bool ConnectBlock(CTxDB& txdb, CBlockIndex* pindex);
bool ReadFromDisk(const CBlockIndex* pindex, bool fReadTransactions=true); bool ReadFromDisk(const CBlockIndex* pindex, bool fReadTransactions=true);

View file

@ -778,6 +778,14 @@ bool EvalScript(vector<vector<unsigned char> >& stack, const CScript& script, co
int nKeysCount = CastToBigNum(stacktop(-i)).getint(); int nKeysCount = CastToBigNum(stacktop(-i)).getint();
if (nKeysCount < 0) if (nKeysCount < 0)
return false; return false;
if (nBestHeight > 84000)
{
if (nKeysCount > 20)
return false;
nOpCount += nKeysCount;
if (nOpCount > 201)
return false;
}
int ikey = ++i; int ikey = ++i;
i += nKeysCount; i += nKeysCount;
if (stack.size() < i) if (stack.size() < i)

View file

@ -22,8 +22,8 @@ class CDataStream;
class CAutoFile; class CAutoFile;
static const unsigned int MAX_SIZE = 0x02000000; static const unsigned int MAX_SIZE = 0x02000000;
static const int VERSION = 312; static const int VERSION = 31300;
static const char* pszSubVer = ".8"; static const char* pszSubVer = "";
@ -85,13 +85,6 @@ enum
#define READWRITE(obj) (nSerSize += ::SerReadWrite(s, (obj), nType, nVersion, ser_action)) #define READWRITE(obj) (nSerSize += ::SerReadWrite(s, (obj), nType, nVersion, ser_action))
#define READWRITEVER(obj) \
do { \
READWRITE((obj)); \
if ((obj) == 10300) \
(obj) = 300; \
} while (false)
@ -163,7 +156,7 @@ template<typename Stream> inline void Unserialize(Stream& s, bool& a, int, int=0
// //
inline unsigned int GetSizeOfCompactSize(uint64 nSize) inline unsigned int GetSizeOfCompactSize(uint64 nSize)
{ {
if (nSize < UCHAR_MAX-2) return sizeof(unsigned char); if (nSize < 253) return sizeof(unsigned char);
else if (nSize <= USHRT_MAX) return sizeof(unsigned char) + sizeof(unsigned short); else if (nSize <= USHRT_MAX) return sizeof(unsigned char) + sizeof(unsigned short);
else if (nSize <= UINT_MAX) return sizeof(unsigned char) + sizeof(unsigned int); else if (nSize <= UINT_MAX) return sizeof(unsigned char) + sizeof(unsigned int);
else return sizeof(unsigned char) + sizeof(uint64); else return sizeof(unsigned char) + sizeof(uint64);
@ -172,30 +165,31 @@ inline unsigned int GetSizeOfCompactSize(uint64 nSize)
template<typename Stream> template<typename Stream>
void WriteCompactSize(Stream& os, uint64 nSize) void WriteCompactSize(Stream& os, uint64 nSize)
{ {
if (nSize < UCHAR_MAX-2) if (nSize < 253)
{ {
unsigned char chSize = nSize; unsigned char chSize = nSize;
WRITEDATA(os, chSize); WRITEDATA(os, chSize);
} }
else if (nSize <= USHRT_MAX) else if (nSize <= USHRT_MAX)
{ {
unsigned char chSize = UCHAR_MAX-2; unsigned char chSize = 253;
unsigned short xSize = nSize; unsigned short xSize = nSize;
WRITEDATA(os, chSize); WRITEDATA(os, chSize);
WRITEDATA(os, xSize); WRITEDATA(os, xSize);
} }
else if (nSize <= UINT_MAX) else if (nSize <= UINT_MAX)
{ {
unsigned char chSize = UCHAR_MAX-1; unsigned char chSize = 254;
unsigned int xSize = nSize; unsigned int xSize = nSize;
WRITEDATA(os, chSize); WRITEDATA(os, chSize);
WRITEDATA(os, xSize); WRITEDATA(os, xSize);
} }
else else
{ {
unsigned char chSize = UCHAR_MAX; unsigned char chSize = 255;
uint64 xSize = nSize;
WRITEDATA(os, chSize); WRITEDATA(os, chSize);
WRITEDATA(os, nSize); WRITEDATA(os, xSize);
} }
return; return;
} }
@ -206,27 +200,27 @@ uint64 ReadCompactSize(Stream& is)
unsigned char chSize; unsigned char chSize;
READDATA(is, chSize); READDATA(is, chSize);
uint64 nSizeRet = 0; uint64 nSizeRet = 0;
if (chSize < UCHAR_MAX-2) if (chSize < 253)
{ {
nSizeRet = chSize; nSizeRet = chSize;
} }
else if (chSize == UCHAR_MAX-2) else if (chSize == 253)
{ {
unsigned short nSize; unsigned short xSize;
READDATA(is, nSize); READDATA(is, xSize);
nSizeRet = nSize; nSizeRet = xSize;
} }
else if (chSize == UCHAR_MAX-1) else if (chSize == 254)
{ {
unsigned int nSize; unsigned int xSize;
READDATA(is, nSize); READDATA(is, xSize);
nSizeRet = nSize; nSizeRet = xSize;
} }
else else
{ {
uint64 nSize; uint64 xSize;
READDATA(is, nSize); READDATA(is, xSize);
nSizeRet = nSize; nSizeRet = xSize;
} }
if (nSizeRet > (uint64)MAX_SIZE) if (nSizeRet > (uint64)MAX_SIZE)
throw std::ios_base::failure("ReadCompactSize() : size too large"); throw std::ios_base::failure("ReadCompactSize() : size too large");

View file

@ -7,7 +7,7 @@ RequestExecutionLevel highest
# General Symbol Definitions # General Symbol Definitions
!define REGKEY "SOFTWARE\$(^Name)" !define REGKEY "SOFTWARE\$(^Name)"
!define VERSION 0.3.12 !define VERSION 0.3.13
!define COMPANY "Bitcoin project" !define COMPANY "Bitcoin project"
!define URL http://www.bitcoin.org/ !define URL http://www.bitcoin.org/
@ -42,12 +42,12 @@ Var StartMenuGroup
!insertmacro MUI_LANGUAGE English !insertmacro MUI_LANGUAGE English
# Installer attributes # Installer attributes
OutFile bitcoin-0.3.12-win32-setup.exe OutFile bitcoin-0.3.13-win32-setup.exe
InstallDir $PROGRAMFILES\Bitcoin InstallDir $PROGRAMFILES\Bitcoin
CRCCheck on CRCCheck on
XPStyle on XPStyle on
ShowInstDetails show ShowInstDetails show
VIProductVersion 0.3.12.0 VIProductVersion 0.3.13.0
VIAddVersionKey ProductName Bitcoin VIAddVersionKey ProductName Bitcoin
VIAddVersionKey ProductVersion "${VERSION}" VIAddVersionKey ProductVersion "${VERSION}"
VIAddVersionKey CompanyName "${COMPANY}" VIAddVersionKey CompanyName "${COMPANY}"

53
ui.cpp
View file

@ -103,6 +103,16 @@ int InsertLine(wxListCtrl* listCtrl, void* pdata, const wxString& str0, const wx
return nIndex; return nIndex;
} }
void SetItemTextColour(wxListCtrl* listCtrl, int nIndex, const wxColour& colour)
{
// Repaint on Windows is more flickery if the colour has ever been set,
// so don't want to set it unless it's different. Default colour has
// alpha 0 transparent, so our colours don't match using operator==.
wxColour c1 = listCtrl->GetItemTextColour(nIndex);
if (colour.Red() != c1.Red() || colour.Green() != c1.Green() || colour.Blue() != c1.Blue())
listCtrl->SetItemTextColour(nIndex, colour);
}
void SetSelection(wxListCtrl* listCtrl, int nIndex) void SetSelection(wxListCtrl* listCtrl, int nIndex)
{ {
int nSize = listCtrl->GetItemCount(); int nSize = listCtrl->GetItemCount();
@ -434,7 +444,7 @@ int CMainFrame::GetSortIndex(const string& strSort)
#endif #endif
} }
void CMainFrame::InsertLine(bool fNew, int nIndex, uint256 hashKey, string strSort, const wxString& str2, const wxString& str3, const wxString& str4, const wxString& str5, const wxString& str6) void CMainFrame::InsertLine(bool fNew, int nIndex, uint256 hashKey, string strSort, const wxColour& colour, const wxString& str2, const wxString& str3, const wxString& str4, const wxString& str5, const wxString& str6)
{ {
strSort = " " + strSort; // leading space to workaround wx2.9.0 ubuntu 9.10 bug strSort = " " + strSort; // leading space to workaround wx2.9.0 ubuntu 9.10 bug
long nData = *(long*)&hashKey; // where first char of hidden column is displayed long nData = *(long*)&hashKey; // where first char of hidden column is displayed
@ -470,6 +480,7 @@ void CMainFrame::InsertLine(bool fNew, int nIndex, uint256 hashKey, string strSo
m_listCtrl->SetItem(nIndex, 5, str5); m_listCtrl->SetItem(nIndex, 5, str5);
m_listCtrl->SetItem(nIndex, 6, str6); m_listCtrl->SetItem(nIndex, 6, str6);
m_listCtrl->SetItemData(nIndex, nData); m_listCtrl->SetItemData(nIndex, nData);
SetItemTextColour(m_listCtrl, nIndex, colour);
} }
bool CMainFrame::DeleteLine(uint256 hashKey) bool CMainFrame::DeleteLine(uint256 hashKey)
@ -489,9 +500,10 @@ bool CMainFrame::DeleteLine(uint256 hashKey)
return nIndex != -1; return nIndex != -1;
} }
string FormatTxStatus(const CWalletTx& wtx) string FormatTxStatus(const CWalletTx& wtx, bool& fConfirmed)
{ {
// Status // Status
fConfirmed = false;
if (!wtx.IsFinal()) if (!wtx.IsFinal())
{ {
if (wtx.nLockTime < 500000000) if (wtx.nLockTime < 500000000)
@ -502,6 +514,8 @@ string FormatTxStatus(const CWalletTx& wtx)
else else
{ {
int nDepth = wtx.GetDepthInMainChain(); int nDepth = wtx.GetDepthInMainChain();
if (nDepth >= 1 || wtx.GetDebit() > 0)
fConfirmed = true;
if (GetAdjustedTime() - wtx.nTimeReceived > 2 * 60 && wtx.GetRequestCount() == 0) if (GetAdjustedTime() - wtx.nTimeReceived > 2 * 60 && wtx.GetRequestCount() == 0)
return strprintf(_("%d/offline?"), nDepth); return strprintf(_("%d/offline?"), nDepth);
else if (nDepth < 6) else if (nDepth < 6)
@ -511,6 +525,12 @@ string FormatTxStatus(const CWalletTx& wtx)
} }
} }
string FormatTxStatus(const CWalletTx& wtx)
{
bool fConfirmed;
return FormatTxStatus(wtx, fConfirmed);
}
string SingleLine(const string& strIn) string SingleLine(const string& strIn)
{ {
string strOut; string strOut;
@ -539,7 +559,10 @@ bool CMainFrame::InsertTransaction(const CWalletTx& wtx, bool fNew, int nIndex)
int64 nDebit = wtx.GetDebit(); int64 nDebit = wtx.GetDebit();
int64 nNet = nCredit - nDebit; int64 nNet = nCredit - nDebit;
uint256 hash = wtx.GetHash(); uint256 hash = wtx.GetHash();
string strStatus = FormatTxStatus(wtx); bool fConfirmed;
string strStatus = FormatTxStatus(wtx, fConfirmed);
wtx.fConfirmedDisplayed = fConfirmed;
wxColour colour = (fConfirmed ? wxColour(0,0,0) : wxColour(128,128,128));
map<string, string> mapValue = wtx.mapValue; map<string, string> mapValue = wtx.mapValue;
wtx.nLinesDisplayed = 1; wtx.nLinesDisplayed = 1;
nListViewUpdated++; nListViewUpdated++;
@ -658,12 +681,16 @@ bool CMainFrame::InsertTransaction(const CWalletTx& wtx, bool fNew, int nIndex)
} }
} }
InsertLine(fNew, nIndex, hash, strSort, string strCredit = FormatMoney(nNet, true);
if (!fConfirmed)
strCredit = "[" + strCredit + "]";
InsertLine(fNew, nIndex, hash, strSort, colour,
strStatus, strStatus,
nTime ? DateTimeStr(nTime) : "", nTime ? DateTimeStr(nTime) : "",
SingleLine(strDescription), SingleLine(strDescription),
"", "",
FormatMoney(nNet, true)); strCredit);
} }
else else
{ {
@ -679,7 +706,7 @@ bool CMainFrame::InsertTransaction(const CWalletTx& wtx, bool fNew, int nIndex)
{ {
// Payment to self // Payment to self
int64 nValue = wtx.vout[0].nValue; int64 nValue = wtx.vout[0].nValue;
InsertLine(fNew, nIndex, hash, strSort, InsertLine(fNew, nIndex, hash, strSort, colour,
strStatus, strStatus,
nTime ? DateTimeStr(nTime) : "", nTime ? DateTimeStr(nTime) : "",
_("Payment to yourself"), _("Payment to yourself"),
@ -738,7 +765,7 @@ bool CMainFrame::InsertTransaction(const CWalletTx& wtx, bool fNew, int nIndex)
nTxFee = 0; nTxFee = 0;
} }
InsertLine(fNew, nIndex, hash, strprintf("%s-%d", strSort.c_str(), nOut), InsertLine(fNew, nIndex, hash, strprintf("%s-%d", strSort.c_str(), nOut), colour,
strStatus, strStatus,
nTime ? DateTimeStr(nTime) : "", nTime ? DateTimeStr(nTime) : "",
SingleLine(strDescription), SingleLine(strDescription),
@ -758,7 +785,7 @@ bool CMainFrame::InsertTransaction(const CWalletTx& wtx, bool fNew, int nIndex)
foreach(const CTxIn& txin, wtx.vin) foreach(const CTxIn& txin, wtx.vin)
fAllMine = fAllMine && txin.IsMine(); fAllMine = fAllMine && txin.IsMine();
InsertLine(fNew, nIndex, hash, strSort, InsertLine(fNew, nIndex, hash, strSort, colour,
strStatus, strStatus,
nTime ? DateTimeStr(nTime) : "", nTime ? DateTimeStr(nTime) : "",
"", "",
@ -885,13 +912,17 @@ void CMainFrame::RefreshStatusColumn()
continue; continue;
} }
CWalletTx& wtx = (*mi).second; CWalletTx& wtx = (*mi).second;
if (wtx.IsCoinBase() || wtx.GetTxTime() != wtx.nTimeDisplayed) bool fConfirmed;
string strStatus = FormatTxStatus(wtx, fConfirmed);
if (wtx.IsCoinBase() || wtx.GetTxTime() != wtx.nTimeDisplayed || fConfirmed != wtx.fConfirmedDisplayed)
{ {
if (!InsertTransaction(wtx, false, nIndex)) if (!InsertTransaction(wtx, false, nIndex))
m_listCtrl->DeleteItem(nIndex--); m_listCtrl->DeleteItem(nIndex--);
} }
else else
m_listCtrl->SetItem(nIndex, 2, FormatTxStatus(wtx)); {
m_listCtrl->SetItem(nIndex, 2, strStatus);
}
} }
} }
} }
@ -1772,7 +1803,7 @@ void COptionsDialog::OnButtonApply(wxCommandEvent& event)
CAboutDialog::CAboutDialog(wxWindow* parent) : CAboutDialogBase(parent) CAboutDialog::CAboutDialog(wxWindow* parent) : CAboutDialogBase(parent)
{ {
m_staticTextVersion->SetLabel(strprintf(_("version %d.%d.%d%s beta"), VERSION/10000, (VERSION/100)%100, VERSION%100, pszSubVer)); m_staticTextVersion->SetLabel(strprintf(_("version %s%s beta"), FormatVersion(VERSION).c_str(), pszSubVer));
// Change (c) into UTF-8 or ANSI copyright symbol // Change (c) into UTF-8 or ANSI copyright symbol
wxString str = m_staticTextMain->GetLabel(); wxString str = m_staticTextMain->GetLabel();

3
ui.h
View file

@ -11,7 +11,6 @@ extern wxLocale g_locale;
void HandleCtrlA(wxKeyEvent& event); void HandleCtrlA(wxKeyEvent& event);
string FormatTxStatus(const CWalletTx& wtx);
void UIThreadCall(boost::function0<void>); void UIThreadCall(boost::function0<void>);
int ThreadSafeMessageBox(const string& message, const string& caption="Message", int style=wxOK, wxWindow* parent=NULL, int x=-1, int y=-1); int ThreadSafeMessageBox(const string& message, const string& caption="Message", int style=wxOK, wxWindow* parent=NULL, int x=-1, int y=-1);
bool ThreadSafeAskFee(int64 nFeeRequired, const string& strCaption, wxWindow* parent); bool ThreadSafeAskFee(int64 nFeeRequired, const string& strCaption, wxWindow* parent);
@ -96,7 +95,7 @@ public:
void OnUIThreadCall(wxCommandEvent& event); void OnUIThreadCall(wxCommandEvent& event);
int GetSortIndex(const string& strSort); int GetSortIndex(const string& strSort);
void InsertLine(bool fNew, int nIndex, uint256 hashKey, string strSort, const wxString& str1, const wxString& str2, const wxString& str3, const wxString& str4, const wxString& str5); void InsertLine(bool fNew, int nIndex, uint256 hashKey, string strSort, const wxColour& colour, const wxString& str1, const wxString& str2, const wxString& str3, const wxString& str4, const wxString& str5);
bool DeleteLine(uint256 hashKey); bool DeleteLine(uint256 hashKey);
bool InsertTransaction(const CWalletTx& wtx, bool fNew, int nIndex=-1); bool InsertTransaction(const CWalletTx& wtx, bool fNew, int nIndex=-1);
void RefreshListCtrl(); void RefreshListCtrl();

8
util.h
View file

@ -416,6 +416,14 @@ inline int64 GetArg(const string& strArg, int64 nDefault)
return nDefault; return nDefault;
} }
inline string FormatVersion(int nVersion)
{
if (nVersion%100 == 0)
return strprintf("%d.%d.%d", nVersion/1000000, (nVersion/10000)%100, (nVersion/100)%100);
else
return strprintf("%d.%d.%d.%d", nVersion/1000000, (nVersion/10000)%100, (nVersion/100)%100, nVersion%100);
}