| 136 | |
| 137 | |
| 138 | RPCHelpMan 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 | |
| 176 | RPCHelpMan listaddressgroupings() |
| 177 | { |
nothing calls this directly
no test coverage detected