Skip to content

XMLRPC: setaccount moves label to the other, unused address #1231

@sgaltsev

Description

@sgaltsev

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.

Value setaccount(const Array& params, bool fHelp)
{
if (fHelp || params.size() < 1 || params.size() > 2)
    throw runtime_error(
        "setaccount <bitcoinaddress> <account>\n"
        "Sets the account associated with the given address.");

CBitcoinAddress address(params[0].get_str());
if (!address.IsValid())
    throw JSONRPCError(-5, "Invalid bitcoin address");


string strAccount;
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))
//{
//    string strOldAccount = pwalletMain->mapAddressBook[address];
//    if (address == GetAccountAddress(strOldAccount))
//        GetAccountAddress(strOldAccount, true);
//}

pwalletMain->SetAddressBookName(address, strAccount);

return Value::null;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions