This is the bug that has been in client and daemon since very beginning. Intention of setaccount command is essentially to rename existing account. For some reason, from very beginning, it was reallocating old label to some other address. Can we get rid of this?
There is no other means to rename the label using XMLRPC without creating artifacts.
Alternatively, is it possible to introduce another XMLRPC command designed to rename label on account? I need to be able to not keep existing one.
0Value setaccount(const Array& params, bool fHelp)
1{
2if (fHelp || params.size() < 1 || params.size() > 2)
3 throw runtime_error(
4 "setaccount <bitcoinaddress> <account>\n"
5 "Sets the account associated with the given address.");
6
7CBitcoinAddress address(params[0].get_str());
8if (!address.IsValid())
9 throw JSONRPCError(-5, "Invalid bitcoin address");
10
11
12string strAccount;
13if (params.size() > 1)
14 strAccount = AccountFromValue(params[1]);
15
16// Detect when changing the account of an address that is the 'unused current key' of another account:
17//if (pwalletMain->mapAddressBook.count(address))
18//{
19// string strOldAccount = pwalletMain->mapAddressBook[address];
20// if (address == GetAccountAddress(strOldAccount))
21// GetAccountAddress(strOldAccount, true);
22//}
23
24pwalletMain->SetAddressBookName(address, strAccount);
25
26return Value::null;
27}