mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-19 06:43:45 +01:00
Merge pull request #4985
bc470c4Changed mixed indentation to four spaces (Eric Shaw)31d6390Fixed setaccount accepting foreign address (Eric Shaw)
This commit is contained in:
@@ -230,15 +230,20 @@ Value setaccount(const Array& params, bool fHelp)
|
||||
if (params.size() > 1)
|
||||
strAccount = AccountFromValue(params[1]);
|
||||
|
||||
// Detect when changing the account of an address that is the 'unused current key' of another account:
|
||||
if (pwalletMain->mapAddressBook.count(address.Get()))
|
||||
// Only add the account if the address is yours.
|
||||
if (IsMine(*pwalletMain, address.Get()))
|
||||
{
|
||||
string strOldAccount = pwalletMain->mapAddressBook[address.Get()].name;
|
||||
if (address == GetAccountAddress(strOldAccount))
|
||||
GetAccountAddress(strOldAccount, true);
|
||||
// Detect when changing the account of an address that is the 'unused current key' of another account:
|
||||
if (pwalletMain->mapAddressBook.count(address.Get()))
|
||||
{
|
||||
string strOldAccount = pwalletMain->mapAddressBook[address.Get()].name;
|
||||
if (address == GetAccountAddress(strOldAccount))
|
||||
GetAccountAddress(strOldAccount, true);
|
||||
}
|
||||
pwalletMain->SetAddressBook(address.Get(), strAccount, "receive");
|
||||
}
|
||||
|
||||
pwalletMain->SetAddressBook(address.Get(), strAccount, "receive");
|
||||
else
|
||||
throw JSONRPCError(RPC_MISC_ERROR, "setaccount can only be used with own address");
|
||||
|
||||
return Value::null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user