MCPcopy Create free account
hub / github.com/ElementsProject/elements / setlabel

Function setlabel

src/wallet/rpc/addresses.cpp:138–174  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

136
137
138RPCHelpMan setlabel()
139{
140 return RPCHelpMan{"setlabel",
141 "\nSets the label associated with the given address.\n",
142 {
143 {"address", RPCArg::Type::STR, RPCArg::Optional::NO, "The address to be associated with a label."},
144 {"label", RPCArg::Type::STR, RPCArg::Optional::NO, "The label to assign to the address."},
145 },
146 RPCResult{RPCResult::Type::NONE, "", ""},
147 RPCExamples{
148 HelpExampleCli("setlabel", "\"" + EXAMPLE_ADDRESS[0] + "\" \"tabby\"")
149 + HelpExampleRpc("setlabel", "\"" + EXAMPLE_ADDRESS[0] + "\", \"tabby\"")
150 },
151 [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
152{
153 std::shared_ptr<CWallet> const pwallet = GetWalletForJSONRPCRequest(request);
154 if (!pwallet) return NullUniValue;
155
156 LOCK(pwallet->cs_wallet);
157
158 CTxDestination dest = DecodeDestination(request.params[0].get_str());
159 if (!IsValidDestination(dest)) {
160 throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid Bitcoin address");
161 }
162
163 std::string label = LabelFromValue(request.params[1]);
164
165 if (pwallet->IsMine(dest)) {
166 pwallet->SetAddressBook(dest, label, "receive");
167 } else {
168 pwallet->SetAddressBook(dest, label, "send");
169 }
170
171 return NullUniValue;
172},
173 };
174}
175
176RPCHelpMan listaddressgroupings()
177{

Callers

nothing calls this directly

Calls 9

HelpExampleCliFunction · 0.85
HelpExampleRpcFunction · 0.85
DecodeDestinationFunction · 0.85
IsValidDestinationFunction · 0.85
JSONRPCErrorFunction · 0.85
LabelFromValueFunction · 0.85
SetAddressBookMethod · 0.80
IsMineMethod · 0.45

Tested by

no test coverage detected