don't touch addressbook when using secure payment-requests

- fixes #3006 by preventing addressbook changes when using
  secure payment-requests

sq
This commit is contained in:
Philip Kaufmann 2013-10-08 14:23:57 +02:00
parent 56c0ba7a0f
commit 48c011489b
1 changed files with 18 additions and 14 deletions

View File

@ -258,22 +258,26 @@ WalletModel::SendCoinsReturn WalletModel::sendCoins(WalletModelTransaction &tran
// and emit coinsSent signal for each recipient // and emit coinsSent signal for each recipient
foreach(const SendCoinsRecipient &rcp, transaction.getRecipients()) foreach(const SendCoinsRecipient &rcp, transaction.getRecipients())
{ {
std::string strAddress = rcp.address.toStdString(); // Don't touch the address book when we have a secure payment-request
CTxDestination dest = CBitcoinAddress(strAddress).Get(); if (rcp.authenticatedMerchant.isEmpty())
std::string strLabel = rcp.label.toStdString();
{ {
LOCK(wallet->cs_wallet); std::string strAddress = rcp.address.toStdString();
CTxDestination dest = CBitcoinAddress(strAddress).Get();
std::map<CTxDestination, CAddressBookData>::iterator mi = wallet->mapAddressBook.find(dest); std::string strLabel = rcp.label.toStdString();
// Check if we have a new address or an updated label
if (mi == wallet->mapAddressBook.end())
{ {
wallet->SetAddressBook(dest, strLabel, "send"); LOCK(wallet->cs_wallet);
}
else if (mi->second.name != strLabel) std::map<CTxDestination, CAddressBookData>::iterator mi = wallet->mapAddressBook.find(dest);
{
wallet->SetAddressBook(dest, strLabel, ""); // "" means don't change purpose // Check if we have a new address or an updated label
if (mi == wallet->mapAddressBook.end())
{
wallet->SetAddressBook(dest, strLabel, "send");
}
else if (mi->second.name != strLabel)
{
wallet->SetAddressBook(dest, strLabel, ""); // "" means don't change purpose
}
} }
} }
emit coinsSent(wallet, rcp, transaction_array); emit coinsSent(wallet, rcp, transaction_array);