mirror of
https://github.com/kvazar-network/kevacoin.git
synced 2025-03-10 12:41:15 +00:00
Merge pull request #3413
d31ad26 qt: Add missing lock in WalletModel::listCoins (Wladimir J. van der Laan) 28352af qt: protect SetAddressBook with cs_wallet lock everywhere (Wladimir J. van der Laan) aaf8d15 qt: Add missing LOCKs for locked coin functions (Wladimir J. van der Laan) 4757e92 qt: add missing cs_wallet lock in AddressTableModel::setData (Wladimir J. van der Laan)
This commit is contained in:
commit
37d30ec3cf
@ -244,33 +244,34 @@ bool AddressTableModel::setData(const QModelIndex &index, const QVariant &value,
|
|||||||
|
|
||||||
if(role == Qt::EditRole)
|
if(role == Qt::EditRole)
|
||||||
{
|
{
|
||||||
switch(index.column())
|
LOCK(wallet->cs_wallet); /* For SetAddressBook / DelAddressBook */
|
||||||
|
CTxDestination curAddress = CBitcoinAddress(rec->address.toStdString()).Get();
|
||||||
|
if(index.column() == Label)
|
||||||
{
|
{
|
||||||
case Label:
|
|
||||||
// Do nothing, if old label == new label
|
// Do nothing, if old label == new label
|
||||||
if(rec->label == value.toString())
|
if(rec->label == value.toString())
|
||||||
{
|
{
|
||||||
editStatus = NO_CHANGES;
|
editStatus = NO_CHANGES;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
wallet->SetAddressBook(CBitcoinAddress(rec->address.toStdString()).Get(), value.toString().toStdString(), strPurpose);
|
wallet->SetAddressBook(curAddress, value.toString().toStdString(), strPurpose);
|
||||||
break;
|
} else if(index.column() == Address) {
|
||||||
case Address:
|
CTxDestination newAddress = CBitcoinAddress(value.toString().toStdString()).Get();
|
||||||
// Do nothing, if old address == new address
|
|
||||||
if(CBitcoinAddress(rec->address.toStdString()) == CBitcoinAddress(value.toString().toStdString()))
|
|
||||||
{
|
|
||||||
editStatus = NO_CHANGES;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
// Refuse to set invalid address, set error status and return false
|
// Refuse to set invalid address, set error status and return false
|
||||||
else if(!walletModel->validateAddress(value.toString()))
|
if(boost::get<CNoDestination>(&newAddress))
|
||||||
{
|
{
|
||||||
editStatus = INVALID_ADDRESS;
|
editStatus = INVALID_ADDRESS;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
// Do nothing, if old address == new address
|
||||||
|
else if(newAddress == curAddress)
|
||||||
|
{
|
||||||
|
editStatus = NO_CHANGES;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
// Check for duplicate addresses to prevent accidental deletion of addresses, if you try
|
// Check for duplicate addresses to prevent accidental deletion of addresses, if you try
|
||||||
// to paste an existing address over another address (with a different label)
|
// to paste an existing address over another address (with a different label)
|
||||||
else if(wallet->mapAddressBook.count(CBitcoinAddress(value.toString().toStdString()).Get()))
|
else if(wallet->mapAddressBook.count(newAddress))
|
||||||
{
|
{
|
||||||
editStatus = DUPLICATE_ADDRESS;
|
editStatus = DUPLICATE_ADDRESS;
|
||||||
return false;
|
return false;
|
||||||
@ -278,15 +279,11 @@ bool AddressTableModel::setData(const QModelIndex &index, const QVariant &value,
|
|||||||
// Double-check that we're not overwriting a receiving address
|
// Double-check that we're not overwriting a receiving address
|
||||||
else if(rec->type == AddressTableEntry::Sending)
|
else if(rec->type == AddressTableEntry::Sending)
|
||||||
{
|
{
|
||||||
{
|
// Remove old entry
|
||||||
LOCK(wallet->cs_wallet);
|
wallet->DelAddressBook(curAddress);
|
||||||
// Remove old entry
|
// Add new entry with new address
|
||||||
wallet->DelAddressBook(CBitcoinAddress(rec->address.toStdString()).Get());
|
wallet->SetAddressBook(newAddress, rec->label.toStdString(), strPurpose);
|
||||||
// Add new entry with new address
|
|
||||||
wallet->SetAddressBook(CBitcoinAddress(value.toString().toStdString()).Get(), rec->label.toStdString(), strPurpose);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -548,6 +548,7 @@ void PaymentServer::fetchPaymentACK(CWallet* wallet, SendCoinsRecipient recipien
|
|||||||
else {
|
else {
|
||||||
CPubKey newKey;
|
CPubKey newKey;
|
||||||
if (wallet->GetKeyFromPool(newKey)) {
|
if (wallet->GetKeyFromPool(newKey)) {
|
||||||
|
LOCK(wallet->cs_wallet); // SetAddressBook
|
||||||
CKeyID keyID = newKey.GetID();
|
CKeyID keyID = newKey.GetID();
|
||||||
wallet->SetAddressBook(keyID, strAccount, "refund");
|
wallet->SetAddressBook(keyID, strAccount, "refund");
|
||||||
|
|
||||||
|
@ -502,6 +502,7 @@ void WalletModel::listCoins(std::map<QString, std::vector<COutput> >& mapCoins)
|
|||||||
std::vector<COutput> vCoins;
|
std::vector<COutput> vCoins;
|
||||||
wallet->AvailableCoins(vCoins);
|
wallet->AvailableCoins(vCoins);
|
||||||
|
|
||||||
|
LOCK(wallet->cs_wallet); // ListLockedCoins, mapWallet
|
||||||
std::vector<COutPoint> vLockedCoins;
|
std::vector<COutPoint> vLockedCoins;
|
||||||
wallet->ListLockedCoins(vLockedCoins);
|
wallet->ListLockedCoins(vLockedCoins);
|
||||||
|
|
||||||
@ -531,20 +532,24 @@ void WalletModel::listCoins(std::map<QString, std::vector<COutput> >& mapCoins)
|
|||||||
|
|
||||||
bool WalletModel::isLockedCoin(uint256 hash, unsigned int n) const
|
bool WalletModel::isLockedCoin(uint256 hash, unsigned int n) const
|
||||||
{
|
{
|
||||||
|
LOCK(wallet->cs_wallet);
|
||||||
return wallet->IsLockedCoin(hash, n);
|
return wallet->IsLockedCoin(hash, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WalletModel::lockCoin(COutPoint& output)
|
void WalletModel::lockCoin(COutPoint& output)
|
||||||
{
|
{
|
||||||
|
LOCK(wallet->cs_wallet);
|
||||||
wallet->LockCoin(output);
|
wallet->LockCoin(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WalletModel::unlockCoin(COutPoint& output)
|
void WalletModel::unlockCoin(COutPoint& output)
|
||||||
{
|
{
|
||||||
|
LOCK(wallet->cs_wallet);
|
||||||
wallet->UnlockCoin(output);
|
wallet->UnlockCoin(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WalletModel::listLockedCoins(std::vector<COutPoint>& vOutpts)
|
void WalletModel::listLockedCoins(std::vector<COutPoint>& vOutpts)
|
||||||
{
|
{
|
||||||
|
LOCK(wallet->cs_wallet);
|
||||||
wallet->ListLockedCoins(vOutpts);
|
wallet->ListLockedCoins(vOutpts);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user