src/qt/qvalidatedlineedit.h \
src/qt/bitcoinunits.h \
src/qt/qvaluecombobox.h \
- src/qt/askpassphrasedialog.h
+ src/qt/askpassphrasedialog.h \
+ src/protocol.h
+
SOURCES += src/qt/bitcoin.cpp src/qt/bitcoingui.cpp \
src/qt/transactiontablemodel.cpp \
src/qt/addresstablemodel.cpp \
src/qt/qvalidatedlineedit.cpp \
src/qt/bitcoinunits.cpp \
src/qt/qvaluecombobox.cpp \
- src/qt/askpassphrasedialog.cpp
+ src/qt/askpassphrasedialog.cpp \
+ src/protocol.cpp
RESOURCES += \
src/qt/bitcoin.qrc
uint256 hashGenesisBlock("0x000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f");
static CBigNum bnProofOfWorkLimit(~uint256(0) >> 32);
const int nTotalBlocksEstimate = 140700; // Conservative estimate of total nr of blocks on main chain
+int nMaxBlocksOfOtherNodes = 0; // Maximum amount of blocks that other nodes claim to have
const int nInitialBlockThreshold = 120; // Regard blocks up until N-threshold as "initial download"
CBlockIndex* pindexGenesisBlock = NULL;
int nBestHeight = -1;
}
}
+// Return maximum amount of blocks that other nodes claim to have
+int GetMaxBlocksOfOtherNodes()
+{
+ return nMaxBlocksOfOtherNodes;
+}
+
bool IsInitialBlockDownload()
{
if (pindexBest == NULL || nBestHeight < (GetTotalBlocksEstimate()-nInitialBlockThreshold))
pfrom->fSuccessfullyConnected = true;
printf("version message: version %d, blocks=%d\n", pfrom->nVersion, pfrom->nStartingHeight);
- if(pfrom->nStartingHeight > nTotalBlocksEstimate)
+ if(pfrom->nStartingHeight > nMaxBlocksOfOtherNodes)
{
- nTotalBlocksEstimate = pfrom->nStartingHeight;
+ nMaxBlocksOfOtherNodes = pfrom->nStartingHeight;
}
}
bool CheckWork(CBlock* pblock, CWallet& wallet, CReserveKey& reservekey);
bool CheckProofOfWork(uint256 hash, unsigned int nBits);
int GetTotalBlocksEstimate();
+int GetMaxBlocksOfOtherNodes();
bool IsInitialBlockDownload();
std::string GetWarnings(std::string strFor);
{
cachedAddressTable.clear();
- CRITICAL_BLOCK(wallet->cs_KeyStore)
- CRITICAL_BLOCK(wallet->cs_mapAddressBook)
+ CRITICAL_BLOCK(wallet->cs_wallet)
{
BOOST_FOREACH(const PAIRTYPE(CBitcoinAddress, std::string)& item, wallet->mapAddressBook)
{
// Double-check that we're not overwriting a receiving address
if(rec->type == AddressTableEntry::Sending)
{
- CRITICAL_BLOCK(wallet->cs_mapAddressBook)
+ CRITICAL_BLOCK(wallet->cs_wallet)
{
// Remove old entry
wallet->DelAddressBookName(rec->address.toStdString());
return QString();
}
// Check for duplicate addresses
- CRITICAL_BLOCK(wallet->cs_mapAddressBook)
+ CRITICAL_BLOCK(wallet->cs_wallet)
{
if(wallet->mapAddressBook.count(strAddress))
{
editStatus = WALLET_UNLOCK_FAILURE;
return QString();
}
-
- strAddress = CBitcoinAddress(wallet->GetOrReuseKeyFromPool()).ToString();
+ std::vector<unsigned char> newKey;
+ if(!wallet->GetKeyFromPool(newKey, true))
+ {
+ editStatus = KEY_GENERATION_FAILURE;
+ return QString();
+ }
+ strAddress = CBitcoinAddress(newKey).ToString();
}
else
{
return QString();
}
// Add entry and update list
- CRITICAL_BLOCK(wallet->cs_mapAddressBook)
+ CRITICAL_BLOCK(wallet->cs_wallet)
wallet->SetAddressBookName(strAddress, strLabel);
updateList();
return QString::fromStdString(strAddress);
// Also refuse to remove receiving addresses.
return false;
}
- CRITICAL_BLOCK(wallet->cs_mapAddressBook)
+ CRITICAL_BLOCK(wallet->cs_wallet)
{
wallet->DelAddressBookName(rec->address.toStdString());
}
*/
QString AddressTableModel::labelForAddress(const QString &address) const
{
- CRITICAL_BLOCK(wallet->cs_mapAddressBook)
+ CRITICAL_BLOCK(wallet->cs_wallet)
{
CBitcoinAddress address_parsed(address.toStdString());
std::map<CBitcoinAddress, std::string>::iterator mi = wallet->mapAddressBook.find(address_parsed);
OK,
INVALID_ADDRESS,
DUPLICATE_ADDRESS,
- WALLET_UNLOCK_FAILURE
+ WALLET_UNLOCK_FAILURE,
+ KEY_GENERATION_FAILURE
};
static const QString Send; /* Send addres */
int ClientModel::getTotalBlocksEstimate() const
{
- return GetTotalBlocksEstimate();
+ return GetMaxBlocksOfOtherNodes();
}
OptionsModel *ClientModel::getOptionsModel()
tr("Could not unlock wallet."),
QMessageBox::Ok, QMessageBox::Ok);
return;
+ case AddressTableModel::KEY_GENERATION_FAILURE:
+ QMessageBox::critical(this, windowTitle(),
+ tr("New key generation failed."),
+ QMessageBox::Ok, QMessageBox::Ok);
+ return;
}
return;
QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx)
{
QString strHTML;
- CRITICAL_BLOCK(wallet->cs_mapAddressBook)
+ CRITICAL_BLOCK(wallet->cs_wallet)
{
strHTML.reserve(4000);
strHTML += "<html><font face='verdana, arial, helvetica, sans-serif'>";
strHTML += "<br><b>Inputs:</b>";
strHTML += "<ul>";
- CRITICAL_BLOCK(wallet->cs_mapWallet)
+ CRITICAL_BLOCK(wallet->cs_wallet)
{
BOOST_FOREACH(const CTxIn& txin, wtx.vin)
{
qDebug() << "refreshWallet";
#endif
cachedWallet.clear();
- CRITICAL_BLOCK(wallet->cs_mapWallet)
+ CRITICAL_BLOCK(wallet->cs_wallet)
{
for(std::map<uint256, CWalletTx>::iterator it = wallet->mapWallet.begin(); it != wallet->mapWallet.end(); ++it)
{
QList<uint256> updated_sorted = updated;
qSort(updated_sorted);
- CRITICAL_BLOCK(wallet->cs_mapWallet)
+ CRITICAL_BLOCK(wallet->cs_wallet)
{
for(int update_idx = updated_sorted.size()-1; update_idx >= 0; --update_idx)
{
// simply re-use the cached status.
if(rec->statusUpdateNeeded())
{
- CRITICAL_BLOCK(wallet->cs_mapWallet)
+ CRITICAL_BLOCK(wallet->cs_wallet)
{
std::map<uint256, CWalletTx>::iterator mi = wallet->mapWallet.find(rec->hash);
QString describe(TransactionRecord *rec)
{
- CRITICAL_BLOCK(wallet->cs_mapWallet)
+ CRITICAL_BLOCK(wallet->cs_wallet)
{
std::map<uint256, CWalletTx>::iterator mi = wallet->mapWallet.find(rec->hash);
if(mi != wallet->mapWallet.end())
QList<uint256> updated;
// Check if there are changes to wallet map
- TRY_CRITICAL_BLOCK(wallet->cs_mapWallet)
+ TRY_CRITICAL_BLOCK(wallet->cs_wallet)
{
if(!wallet->vWalletUpdated.empty())
{
int WalletModel::getNumTransactions() const
{
int numTransactions = 0;
- CRITICAL_BLOCK(wallet->cs_mapWallet)
+ CRITICAL_BLOCK(wallet->cs_wallet)
{
numTransactions = wallet->mapWallet.size();
}
}
CRITICAL_BLOCK(cs_main)
- CRITICAL_BLOCK(wallet->cs_mapWallet)
+ CRITICAL_BLOCK(wallet->cs_wallet)
{
// Sendmany
std::vector<std::pair<CScript, int64> > vecSend;
foreach(const SendCoinsRecipient &rcp, recipients)
{
std::string strAddress = rcp.address.toStdString();
- CRITICAL_BLOCK(wallet->cs_mapAddressBook)
+ CRITICAL_BLOCK(wallet->cs_wallet)
{
if (!wallet->mapAddressBook.count(strAddress))
wallet->SetAddressBookName(strAddress, rcp.label.toStdString());
bool WalletModel::changePassphrase(const std::string &oldPass, const std::string &newPass)
{
bool retval;
- CRITICAL_BLOCK(wallet->cs_vMasterKey)
+ CRITICAL_BLOCK(wallet->cs_wallet)
{
wallet->Lock(); // Make sure wallet is locked before attempting pass change
retval = wallet->ChangeWalletPassphrase(oldPass, newPass);
int64 CWallet::GetUnconfirmedBalance() const
{
int64 nTotal = 0;
- CRITICAL_BLOCK(cs_mapWallet)
+ CRITICAL_BLOCK(cs_wallet)
{
for (map<uint256, CWalletTx>::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it)
{