aboutsummaryrefslogtreecommitdiff
path: root/src/rpcwallet.cpp
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2014-10-02 19:31:48 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2014-10-02 19:31:50 +0200
commit20a4b69360246c85700cab90df4de99b83eb368a (patch)
tree70504f1055da53acc5166a54585db8377789384b /src/rpcwallet.cpp
parent4b73b758a388dae63aa68a5aabaa7ff493d64bc2 (diff)
parentbc470c43eecd40057a54fbfe4f34eb6fbda7134d (diff)
Merge pull request #4985
bc470c4 Changed mixed indentation to four spaces (Eric Shaw) 31d6390 Fixed setaccount accepting foreign address (Eric Shaw)
Diffstat (limited to 'src/rpcwallet.cpp')
-rw-r--r--src/rpcwallet.cpp19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/rpcwallet.cpp b/src/rpcwallet.cpp
index 632c46acd5..d7c0c0ef5c 100644
--- a/src/rpcwallet.cpp
+++ b/src/rpcwallet.cpp
@@ -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;
}