Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/rpcwallet.cpp
Show First 20 Lines • Show All 332 Lines • ▼ Show 20 Lines | static UniValue setlabel(const Config &config, const JSONRPCRequest &request) { | ||||
std::string label = LabelFromValue(request.params[1]); | std::string label = LabelFromValue(request.params[1]); | ||||
if (IsMine(*pwallet, dest)) { | if (IsMine(*pwallet, dest)) { | ||||
pwallet->SetAddressBook(dest, label, "receive"); | pwallet->SetAddressBook(dest, label, "receive"); | ||||
} else { | } else { | ||||
pwallet->SetAddressBook(dest, label, "send"); | pwallet->SetAddressBook(dest, label, "send"); | ||||
} | } | ||||
// Detect when there are no addresses using this label. | |||||
// If so, delete the account record for it. Labels, unlike addresses, can be | |||||
// deleted, and if we wouldn't do this, the record would stick around | |||||
// forever. | |||||
bool found_address = false; | |||||
for (const std::pair<const CTxDestination, CAddressBookData> &item : | |||||
pwallet->mapAddressBook) { | |||||
if (item.second.name == label) { | |||||
found_address = true; | |||||
break; | |||||
} | |||||
} | |||||
if (!found_address) { | |||||
pwallet->DeleteLabel(old_label); | |||||
} | |||||
return NullUniValue; | return NullUniValue; | ||||
} | } | ||||
static CTransactionRef SendMoney(interfaces::Chain::Lock &locked_chain, | static CTransactionRef SendMoney(interfaces::Chain::Lock &locked_chain, | ||||
CWallet *const pwallet, | CWallet *const pwallet, | ||||
const CTxDestination &address, Amount nValue, | const CTxDestination &address, Amount nValue, | ||||
bool fSubtractFeeFromAmount, | bool fSubtractFeeFromAmount, | ||||
mapValue_t mapValue) { | mapValue_t mapValue) { | ||||
▲ Show 20 Lines • Show All 4,370 Lines • Show Last 20 Lines |