Bitcoin Core  22.99.0
P2P Digital Currency
addresses.cpp
Go to the documentation of this file.
1 // Copyright (c) 2011-2021 The Bitcoin Core developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 
5 #include <core_io.h>
6 #include <key_io.h>
7 #include <rpc/util.h>
8 #include <util/bip32.h>
9 #include <util/translation.h>
10 #include <wallet/receive.h>
11 #include <wallet/rpc/util.h>
12 #include <wallet/wallet.h>
13 
14 #include <univalue.h>
15 
16 namespace wallet {
18 {
19  return RPCHelpMan{"getnewaddress",
20  "\nReturns a new Bitcoin address for receiving payments.\n"
21  "If 'label' is specified, it is added to the address book \n"
22  "so payments received with the address will be associated with 'label'.\n",
23  {
24  {"label", RPCArg::Type::STR, RPCArg::Default{""}, "The label name for the address to be linked to. It can also be set to the empty string \"\" to represent the default label. The label does not need to exist, it will be created if there is no label by the given name."},
25  {"address_type", RPCArg::Type::STR, RPCArg::DefaultHint{"set by -addresstype"}, "The address type to use. Options are \"legacy\", \"p2sh-segwit\", \"bech32\", and \"bech32m\"."},
26  },
27  RPCResult{
28  RPCResult::Type::STR, "address", "The new bitcoin address"
29  },
31  HelpExampleCli("getnewaddress", "")
32  + HelpExampleRpc("getnewaddress", "")
33  },
34  [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
35 {
36  std::shared_ptr<CWallet> const pwallet = GetWalletForJSONRPCRequest(request);
37  if (!pwallet) return NullUniValue;
38 
39  LOCK(pwallet->cs_wallet);
40 
41  if (!pwallet->CanGetAddresses()) {
42  throw JSONRPCError(RPC_WALLET_ERROR, "Error: This wallet has no available keys");
43  }
44 
45  // Parse the label first so we don't generate a key if there's an error
46  std::string label;
47  if (!request.params[0].isNull())
48  label = LabelFromValue(request.params[0]);
49 
50  OutputType output_type = pwallet->m_default_address_type;
51  if (!request.params[1].isNull()) {
52  std::optional<OutputType> parsed = ParseOutputType(request.params[1].get_str());
53  if (!parsed) {
54  throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, strprintf("Unknown address type '%s'", request.params[1].get_str()));
55  } else if (parsed.value() == OutputType::BECH32M && pwallet->GetLegacyScriptPubKeyMan()) {
56  throw JSONRPCError(RPC_INVALID_PARAMETER, "Legacy wallets cannot provide bech32m addresses");
57  }
58  output_type = parsed.value();
59  }
60 
61  CTxDestination dest;
63  if (!pwallet->GetNewDestination(output_type, label, dest, error)) {
65  }
66 
67  return EncodeDestination(dest);
68 },
69  };
70 }
71 
73 {
74  return RPCHelpMan{"getrawchangeaddress",
75  "\nReturns a new Bitcoin address, for receiving change.\n"
76  "This is for use with raw transactions, NOT normal use.\n",
77  {
78  {"address_type", RPCArg::Type::STR, RPCArg::DefaultHint{"set by -changetype"}, "The address type to use. Options are \"legacy\", \"p2sh-segwit\", \"bech32\", and \"bech32m\"."},
79  },
80  RPCResult{
81  RPCResult::Type::STR, "address", "The address"
82  },
84  HelpExampleCli("getrawchangeaddress", "")
85  + HelpExampleRpc("getrawchangeaddress", "")
86  },
87  [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
88 {
89  std::shared_ptr<CWallet> const pwallet = GetWalletForJSONRPCRequest(request);
90  if (!pwallet) return NullUniValue;
91 
92  LOCK(pwallet->cs_wallet);
93 
94  if (!pwallet->CanGetAddresses(true)) {
95  throw JSONRPCError(RPC_WALLET_ERROR, "Error: This wallet has no available keys");
96  }
97 
98  OutputType output_type = pwallet->m_default_change_type.value_or(pwallet->m_default_address_type);
99  if (!request.params[0].isNull()) {
100  std::optional<OutputType> parsed = ParseOutputType(request.params[0].get_str());
101  if (!parsed) {
102  throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, strprintf("Unknown address type '%s'", request.params[0].get_str()));
103  } else if (parsed.value() == OutputType::BECH32M && pwallet->GetLegacyScriptPubKeyMan()) {
104  throw JSONRPCError(RPC_INVALID_PARAMETER, "Legacy wallets cannot provide bech32m addresses");
105  }
106  output_type = parsed.value();
107  }
108 
109  CTxDestination dest;
111  if (!pwallet->GetNewChangeDestination(output_type, dest, error)) {
113  }
114  return EncodeDestination(dest);
115 },
116  };
117 }
118 
119 
121 {
122  return RPCHelpMan{"setlabel",
123  "\nSets the label associated with the given address.\n",
124  {
125  {"address", RPCArg::Type::STR, RPCArg::Optional::NO, "The bitcoin address to be associated with a label."},
126  {"label", RPCArg::Type::STR, RPCArg::Optional::NO, "The label to assign to the address."},
127  },
129  RPCExamples{
130  HelpExampleCli("setlabel", "\"" + EXAMPLE_ADDRESS[0] + "\" \"tabby\"")
131  + HelpExampleRpc("setlabel", "\"" + EXAMPLE_ADDRESS[0] + "\", \"tabby\"")
132  },
133  [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
134 {
135  std::shared_ptr<CWallet> const pwallet = GetWalletForJSONRPCRequest(request);
136  if (!pwallet) return NullUniValue;
137 
138  LOCK(pwallet->cs_wallet);
139 
140  CTxDestination dest = DecodeDestination(request.params[0].get_str());
141  if (!IsValidDestination(dest)) {
142  throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid Bitcoin address");
143  }
144 
145  std::string label = LabelFromValue(request.params[1]);
146 
147  if (pwallet->IsMine(dest)) {
148  pwallet->SetAddressBook(dest, label, "receive");
149  } else {
150  pwallet->SetAddressBook(dest, label, "send");
151  }
152 
153  return NullUniValue;
154 },
155  };
156 }
157 
159 {
160  return RPCHelpMan{"listaddressgroupings",
161  "\nLists groups of addresses which have had their common ownership\n"
162  "made public by common use as inputs or as the resulting change\n"
163  "in past transactions\n",
164  {},
165  RPCResult{
166  RPCResult::Type::ARR, "", "",
167  {
168  {RPCResult::Type::ARR, "", "",
169  {
171  {
172  {RPCResult::Type::STR, "address", "The bitcoin address"},
173  {RPCResult::Type::STR_AMOUNT, "amount", "The amount in " + CURRENCY_UNIT},
174  {RPCResult::Type::STR, "label", /*optional=*/true, "The label"},
175  }},
176  }},
177  }
178  },
179  RPCExamples{
180  HelpExampleCli("listaddressgroupings", "")
181  + HelpExampleRpc("listaddressgroupings", "")
182  },
183  [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
184 {
185  const std::shared_ptr<const CWallet> pwallet = GetWalletForJSONRPCRequest(request);
186  if (!pwallet) return NullUniValue;
187 
188  // Make sure the results are valid at least up to the most recent block
189  // the user could have gotten from another RPC command prior to now
190  pwallet->BlockUntilSyncedToCurrentChain();
191 
192  LOCK(pwallet->cs_wallet);
193 
194  UniValue jsonGroupings(UniValue::VARR);
195  std::map<CTxDestination, CAmount> balances = GetAddressBalances(*pwallet);
196  for (const std::set<CTxDestination>& grouping : GetAddressGroupings(*pwallet)) {
197  UniValue jsonGrouping(UniValue::VARR);
198  for (const CTxDestination& address : grouping)
199  {
200  UniValue addressInfo(UniValue::VARR);
201  addressInfo.push_back(EncodeDestination(address));
202  addressInfo.push_back(ValueFromAmount(balances[address]));
203  {
204  const auto* address_book_entry = pwallet->FindAddressBookEntry(address);
205  if (address_book_entry) {
206  addressInfo.push_back(address_book_entry->GetLabel());
207  }
208  }
209  jsonGrouping.push_back(addressInfo);
210  }
211  jsonGroupings.push_back(jsonGrouping);
212  }
213  return jsonGroupings;
214 },
215  };
216 }
217 
219 {
220  return RPCHelpMan{"addmultisigaddress",
221  "\nAdd an nrequired-to-sign multisignature address to the wallet. Requires a new wallet backup.\n"
222  "Each key is a Bitcoin address or hex-encoded public key.\n"
223  "This functionality is only intended for use with non-watchonly addresses.\n"
224  "See `importaddress` for watchonly p2sh address support.\n"
225  "If 'label' is specified, assign address to that label.\n",
226  {
227  {"nrequired", RPCArg::Type::NUM, RPCArg::Optional::NO, "The number of required signatures out of the n keys or addresses."},
228  {"keys", RPCArg::Type::ARR, RPCArg::Optional::NO, "The bitcoin addresses or hex-encoded public keys",
229  {
230  {"key", RPCArg::Type::STR, RPCArg::Optional::OMITTED, "bitcoin address or hex-encoded public key"},
231  },
232  },
233  {"label", RPCArg::Type::STR, RPCArg::Optional::OMITTED_NAMED_ARG, "A label to assign the addresses to."},
234  {"address_type", RPCArg::Type::STR, RPCArg::DefaultHint{"set by -addresstype"}, "The address type to use. Options are \"legacy\", \"p2sh-segwit\", and \"bech32\"."},
235  },
236  RPCResult{
237  RPCResult::Type::OBJ, "", "",
238  {
239  {RPCResult::Type::STR, "address", "The value of the new multisig address"},
240  {RPCResult::Type::STR_HEX, "redeemScript", "The string value of the hex-encoded redemption script"},
241  {RPCResult::Type::STR, "descriptor", "The descriptor for this multisig"},
242  {RPCResult::Type::ARR, "warnings", /* optional */ true, "Any warnings resulting from the creation of this multisig",
243  {
244  {RPCResult::Type::STR, "", ""},
245  }},
246  }
247  },
248  RPCExamples{
249  "\nAdd a multisig address from 2 addresses\n"
250  + HelpExampleCli("addmultisigaddress", "2 \"[\\\"" + EXAMPLE_ADDRESS[0] + "\\\",\\\"" + EXAMPLE_ADDRESS[1] + "\\\"]\"") +
251  "\nAs a JSON-RPC call\n"
252  + HelpExampleRpc("addmultisigaddress", "2, \"[\\\"" + EXAMPLE_ADDRESS[0] + "\\\",\\\"" + EXAMPLE_ADDRESS[1] + "\\\"]\"")
253  },
254  [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
255 {
256  std::shared_ptr<CWallet> const pwallet = GetWalletForJSONRPCRequest(request);
257  if (!pwallet) return NullUniValue;
258 
260 
261  LOCK2(pwallet->cs_wallet, spk_man.cs_KeyStore);
262 
263  std::string label;
264  if (!request.params[2].isNull())
265  label = LabelFromValue(request.params[2]);
266 
267  int required = request.params[0].get_int();
268 
269  // Get the public keys
270  const UniValue& keys_or_addrs = request.params[1].get_array();
271  std::vector<CPubKey> pubkeys;
272  for (unsigned int i = 0; i < keys_or_addrs.size(); ++i) {
273  if (IsHex(keys_or_addrs[i].get_str()) && (keys_or_addrs[i].get_str().length() == 66 || keys_or_addrs[i].get_str().length() == 130)) {
274  pubkeys.push_back(HexToPubKey(keys_or_addrs[i].get_str()));
275  } else {
276  pubkeys.push_back(AddrToPubKey(spk_man, keys_or_addrs[i].get_str()));
277  }
278  }
279 
280  OutputType output_type = pwallet->m_default_address_type;
281  if (!request.params[3].isNull()) {
282  std::optional<OutputType> parsed = ParseOutputType(request.params[3].get_str());
283  if (!parsed) {
284  throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, strprintf("Unknown address type '%s'", request.params[3].get_str()));
285  } else if (parsed.value() == OutputType::BECH32M) {
286  throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Bech32m multisig addresses cannot be created with legacy wallets");
287  }
288  output_type = parsed.value();
289  }
290 
291  // Construct using pay-to-script-hash:
292  CScript inner;
293  CTxDestination dest = AddAndGetMultisigDestination(required, pubkeys, output_type, spk_man, inner);
294  pwallet->SetAddressBook(dest, label, "send");
295 
296  // Make the descriptor
297  std::unique_ptr<Descriptor> descriptor = InferDescriptor(GetScriptForDestination(dest), spk_man);
298 
299  UniValue result(UniValue::VOBJ);
300  result.pushKV("address", EncodeDestination(dest));
301  result.pushKV("redeemScript", HexStr(inner));
302  result.pushKV("descriptor", descriptor->ToString());
303 
304  UniValue warnings(UniValue::VARR);
305  if (!request.params[3].isNull() && OutputTypeFromDestination(dest) != output_type) {
306  // Only warns if the user has explicitly chosen an address type we cannot generate
307  warnings.push_back("Unable to make chosen address type, please ensure no uncompressed public keys are present.");
308  }
309  if (warnings.size()) result.pushKV("warnings", warnings);
310 
311  return result;
312 },
313  };
314 }
315 
317 {
318  return RPCHelpMan{"keypoolrefill",
319  "\nFills the keypool."+
321  {
322  {"newsize", RPCArg::Type::NUM, RPCArg::DefaultHint{strprintf("%u, or as set by -keypool", DEFAULT_KEYPOOL_SIZE)}, "The new keypool size"},
323  },
325  RPCExamples{
326  HelpExampleCli("keypoolrefill", "")
327  + HelpExampleRpc("keypoolrefill", "")
328  },
329  [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
330 {
331  std::shared_ptr<CWallet> const pwallet = GetWalletForJSONRPCRequest(request);
332  if (!pwallet) return NullUniValue;
333 
334  if (pwallet->IsLegacy() && pwallet->IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS)) {
335  throw JSONRPCError(RPC_WALLET_ERROR, "Error: Private keys are disabled for this wallet");
336  }
337 
338  LOCK(pwallet->cs_wallet);
339 
340  // 0 is interpreted by TopUpKeyPool() as the default keypool size given by -keypool
341  unsigned int kpSize = 0;
342  if (!request.params[0].isNull()) {
343  if (request.params[0].get_int() < 0)
344  throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, expected valid size.");
345  kpSize = (unsigned int)request.params[0].get_int();
346  }
347 
348  EnsureWalletIsUnlocked(*pwallet);
349  pwallet->TopUpKeyPool(kpSize);
350 
351  if (pwallet->GetKeyPoolSize() < kpSize) {
352  throw JSONRPCError(RPC_WALLET_ERROR, "Error refreshing keypool.");
353  }
354 
355  return NullUniValue;
356 },
357  };
358 }
359 
361 {
362  return RPCHelpMan{"newkeypool",
363  "\nEntirely clears and refills the keypool.\n"
364  "WARNING: On non-HD wallets, this will require a new backup immediately, to include the new keys.\n"
365  "When restoring a backup of an HD wallet created before the newkeypool command is run, funds received to\n"
366  "new addresses may not appear automatically. They have not been lost, but the wallet may not find them.\n"
367  "This can be fixed by running the newkeypool command on the backup and then rescanning, so the wallet\n"
368  "re-generates the required keys." +
370  {},
372  RPCExamples{
373  HelpExampleCli("newkeypool", "")
374  + HelpExampleRpc("newkeypool", "")
375  },
376  [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
377 {
378  std::shared_ptr<CWallet> const pwallet = GetWalletForJSONRPCRequest(request);
379  if (!pwallet) return NullUniValue;
380 
381  LOCK(pwallet->cs_wallet);
382 
383  LegacyScriptPubKeyMan& spk_man = EnsureLegacyScriptPubKeyMan(*pwallet, true);
384  spk_man.NewKeyPool();
385 
386  return NullUniValue;
387 },
388  };
389 }
390 
391 
393 {
394 public:
395  const SigningProvider * const provider;
396 
397  void ProcessSubScript(const CScript& subscript, UniValue& obj) const
398  {
399  // Always present: script type and redeemscript
400  std::vector<std::vector<unsigned char>> solutions_data;
401  TxoutType which_type = Solver(subscript, solutions_data);
402  obj.pushKV("script", GetTxnOutputType(which_type));
403  obj.pushKV("hex", HexStr(subscript));
404 
405  CTxDestination embedded;
406  if (ExtractDestination(subscript, embedded)) {
407  // Only when the script corresponds to an address.
408  UniValue subobj(UniValue::VOBJ);
409  UniValue detail = DescribeAddress(embedded);
410  subobj.pushKVs(detail);
411  UniValue wallet_detail = std::visit(*this, embedded);
412  subobj.pushKVs(wallet_detail);
413  subobj.pushKV("address", EncodeDestination(embedded));
414  subobj.pushKV("scriptPubKey", HexStr(subscript));
415  // Always report the pubkey at the top level, so that `getnewaddress()['pubkey']` always works.
416  if (subobj.exists("pubkey")) obj.pushKV("pubkey", subobj["pubkey"]);
417  obj.pushKV("embedded", std::move(subobj));
418  } else if (which_type == TxoutType::MULTISIG) {
419  // Also report some information on multisig scripts (which do not have a corresponding address).
420  obj.pushKV("sigsrequired", solutions_data[0][0]);
421  UniValue pubkeys(UniValue::VARR);
422  for (size_t i = 1; i < solutions_data.size() - 1; ++i) {
423  CPubKey key(solutions_data[i].begin(), solutions_data[i].end());
424  pubkeys.push_back(HexStr(key));
425  }
426  obj.pushKV("pubkeys", std::move(pubkeys));
427  }
428  }
429 
430  explicit DescribeWalletAddressVisitor(const SigningProvider* _provider) : provider(_provider) {}
431 
432  UniValue operator()(const CNoDestination& dest) const { return UniValue(UniValue::VOBJ); }
433 
434  UniValue operator()(const PKHash& pkhash) const
435  {
436  CKeyID keyID{ToKeyID(pkhash)};
438  CPubKey vchPubKey;
439  if (provider && provider->GetPubKey(keyID, vchPubKey)) {
440  obj.pushKV("pubkey", HexStr(vchPubKey));
441  obj.pushKV("iscompressed", vchPubKey.IsCompressed());
442  }
443  return obj;
444  }
445 
446  UniValue operator()(const ScriptHash& scripthash) const
447  {
448  CScriptID scriptID(scripthash);
450  CScript subscript;
451  if (provider && provider->GetCScript(scriptID, subscript)) {
452  ProcessSubScript(subscript, obj);
453  }
454  return obj;
455  }
456 
458  {
460  CPubKey pubkey;
461  if (provider && provider->GetPubKey(ToKeyID(id), pubkey)) {
462  obj.pushKV("pubkey", HexStr(pubkey));
463  }
464  return obj;
465  }
466 
468  {
470  CScript subscript;
471  CRIPEMD160 hasher;
472  uint160 hash;
473  hasher.Write(id.begin(), 32).Finalize(hash.begin());
474  if (provider && provider->GetCScript(CScriptID(hash), subscript)) {
475  ProcessSubScript(subscript, obj);
476  }
477  return obj;
478  }
479 
482 };
483 
485 {
487  UniValue detail = DescribeAddress(dest);
488  CScript script = GetScriptForDestination(dest);
489  std::unique_ptr<SigningProvider> provider = nullptr;
490  provider = wallet.GetSolvingProvider(script);
491  ret.pushKVs(detail);
492  ret.pushKVs(std::visit(DescribeWalletAddressVisitor(provider.get()), dest));
493  return ret;
494 }
495 
497 {
498  return RPCHelpMan{"getaddressinfo",
499  "\nReturn information about the given bitcoin address.\n"
500  "Some of the information will only be present if the address is in the active wallet.\n",
501  {
502  {"address", RPCArg::Type::STR, RPCArg::Optional::NO, "The bitcoin address for which to get information."},
503  },
504  RPCResult{
505  RPCResult::Type::OBJ, "", "",
506  {
507  {RPCResult::Type::STR, "address", "The bitcoin address validated."},
508  {RPCResult::Type::STR_HEX, "scriptPubKey", "The hex-encoded scriptPubKey generated by the address."},
509  {RPCResult::Type::BOOL, "ismine", "If the address is yours."},
510  {RPCResult::Type::BOOL, "iswatchonly", "If the address is watchonly."},
511  {RPCResult::Type::BOOL, "solvable", "If we know how to spend coins sent to this address, ignoring the possible lack of private keys."},
512  {RPCResult::Type::STR, "desc", /*optional=*/true, "A descriptor for spending coins sent to this address (only when solvable)."},
513  {RPCResult::Type::STR, "parent_desc", /*optional=*/true, "The descriptor used to derive this address if this is a descriptor wallet"},
514  {RPCResult::Type::BOOL, "isscript", "If the key is a script."},
515  {RPCResult::Type::BOOL, "ischange", "If the address was used for change output."},
516  {RPCResult::Type::BOOL, "iswitness", "If the address is a witness address."},
517  {RPCResult::Type::NUM, "witness_version", /*optional=*/true, "The version number of the witness program."},
518  {RPCResult::Type::STR_HEX, "witness_program", /*optional=*/true, "The hex value of the witness program."},
519  {RPCResult::Type::STR, "script", /*optional=*/true, "The output script type. Only if isscript is true and the redeemscript is known. Possible\n"
520  "types: nonstandard, pubkey, pubkeyhash, scripthash, multisig, nulldata, witness_v0_keyhash,\n"
521  "witness_v0_scripthash, witness_unknown."},
522  {RPCResult::Type::STR_HEX, "hex", /*optional=*/true, "The redeemscript for the p2sh address."},
523  {RPCResult::Type::ARR, "pubkeys", /*optional=*/true, "Array of pubkeys associated with the known redeemscript (only if script is multisig).",
524  {
525  {RPCResult::Type::STR, "pubkey", ""},
526  }},
527  {RPCResult::Type::NUM, "sigsrequired", /*optional=*/true, "The number of signatures required to spend multisig output (only if script is multisig)."},
528  {RPCResult::Type::STR_HEX, "pubkey", /*optional=*/true, "The hex value of the raw public key for single-key addresses (possibly embedded in P2SH or P2WSH)."},
529  {RPCResult::Type::OBJ, "embedded", /*optional=*/true, "Information about the address embedded in P2SH or P2WSH, if relevant and known.",
530  {
531  {RPCResult::Type::ELISION, "", "Includes all getaddressinfo output fields for the embedded address, excluding metadata (timestamp, hdkeypath, hdseedid)\n"
532  "and relation to the wallet (ismine, iswatchonly)."},
533  }},
534  {RPCResult::Type::BOOL, "iscompressed", /*optional=*/true, "If the pubkey is compressed."},
535  {RPCResult::Type::NUM_TIME, "timestamp", /*optional=*/true, "The creation time of the key, if available, expressed in " + UNIX_EPOCH_TIME + "."},
536  {RPCResult::Type::STR, "hdkeypath", /*optional=*/true, "The HD keypath, if the key is HD and available."},
537  {RPCResult::Type::STR_HEX, "hdseedid", /*optional=*/true, "The Hash160 of the HD seed."},
538  {RPCResult::Type::STR_HEX, "hdmasterfingerprint", /*optional=*/true, "The fingerprint of the master key."},
539  {RPCResult::Type::ARR, "labels", "Array of labels associated with the address. Currently limited to one label but returned\n"
540  "as an array to keep the API stable if multiple labels are enabled in the future.",
541  {
542  {RPCResult::Type::STR, "label name", "Label name (defaults to \"\")."},
543  }},
544  }
545  },
546  RPCExamples{
547  HelpExampleCli("getaddressinfo", "\"" + EXAMPLE_ADDRESS[0] + "\"") +
548  HelpExampleRpc("getaddressinfo", "\"" + EXAMPLE_ADDRESS[0] + "\"")
549  },
550  [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
551 {
552  const std::shared_ptr<const CWallet> pwallet = GetWalletForJSONRPCRequest(request);
553  if (!pwallet) return NullUniValue;
554 
555  LOCK(pwallet->cs_wallet);
556 
557  std::string error_msg;
558  CTxDestination dest = DecodeDestination(request.params[0].get_str(), error_msg);
559 
560  // Make sure the destination is valid
561  if (!IsValidDestination(dest)) {
562  // Set generic error message in case 'DecodeDestination' didn't set it
563  if (error_msg.empty()) error_msg = "Invalid address";
564 
565  throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, error_msg);
566  }
567 
569 
570  std::string currentAddress = EncodeDestination(dest);
571  ret.pushKV("address", currentAddress);
572 
573  CScript scriptPubKey = GetScriptForDestination(dest);
574  ret.pushKV("scriptPubKey", HexStr(scriptPubKey));
575 
576  std::unique_ptr<SigningProvider> provider = pwallet->GetSolvingProvider(scriptPubKey);
577 
578  isminetype mine = pwallet->IsMine(dest);
579  ret.pushKV("ismine", bool(mine & ISMINE_SPENDABLE));
580 
581  if (provider) {
582  auto inferred = InferDescriptor(scriptPubKey, *provider);
583  bool solvable = inferred->IsSolvable() || IsSolvable(*provider, scriptPubKey);
584  ret.pushKV("solvable", solvable);
585  if (solvable) {
586  ret.pushKV("desc", inferred->ToString());
587  }
588  } else {
589  ret.pushKV("solvable", false);
590  }
591 
592  const auto& spk_mans = pwallet->GetScriptPubKeyMans(scriptPubKey);
593  // In most cases there is only one matching ScriptPubKey manager and we can't resolve ambiguity in a better way
594  ScriptPubKeyMan* spk_man{nullptr};
595  if (spk_mans.size()) spk_man = *spk_mans.begin();
596 
597  DescriptorScriptPubKeyMan* desc_spk_man = dynamic_cast<DescriptorScriptPubKeyMan*>(spk_man);
598  if (desc_spk_man) {
599  std::string desc_str;
600  if (desc_spk_man->GetDescriptorString(desc_str, /* priv */ false)) {
601  ret.pushKV("parent_desc", desc_str);
602  }
603  }
604 
605  ret.pushKV("iswatchonly", bool(mine & ISMINE_WATCH_ONLY));
606 
607  UniValue detail = DescribeWalletAddress(*pwallet, dest);
608  ret.pushKVs(detail);
609 
610  ret.pushKV("ischange", ScriptIsChange(*pwallet, scriptPubKey));
611 
612  if (spk_man) {
613  if (const std::unique_ptr<CKeyMetadata> meta = spk_man->GetMetadata(dest)) {
614  ret.pushKV("timestamp", meta->nCreateTime);
615  if (meta->has_key_origin) {
616  ret.pushKV("hdkeypath", WriteHDKeypath(meta->key_origin.path));
617  ret.pushKV("hdseedid", meta->hd_seed_id.GetHex());
618  ret.pushKV("hdmasterfingerprint", HexStr(meta->key_origin.fingerprint));
619  }
620  }
621  }
622 
623  // Return a `labels` array containing the label associated with the address,
624  // equivalent to the `label` field above. Currently only one label can be
625  // associated with an address, but we return an array so the API remains
626  // stable if we allow multiple labels to be associated with an address in
627  // the future.
628  UniValue labels(UniValue::VARR);
629  const auto* address_book_entry = pwallet->FindAddressBookEntry(dest);
630  if (address_book_entry) {
631  labels.push_back(address_book_entry->GetLabel());
632  }
633  ret.pushKV("labels", std::move(labels));
634 
635  return ret;
636 },
637  };
638 }
639 
641 static UniValue AddressBookDataToJSON(const CAddressBookData& data, const bool verbose)
642 {
644  if (verbose) {
645  ret.pushKV("name", data.GetLabel());
646  }
647  ret.pushKV("purpose", data.purpose);
648  return ret;
649 }
650 
652 {
653  return RPCHelpMan{"getaddressesbylabel",
654  "\nReturns the list of addresses assigned the specified label.\n",
655  {
656  {"label", RPCArg::Type::STR, RPCArg::Optional::NO, "The label."},
657  },
658  RPCResult{
659  RPCResult::Type::OBJ_DYN, "", "json object with addresses as keys",
660  {
661  {RPCResult::Type::OBJ, "address", "json object with information about address",
662  {
663  {RPCResult::Type::STR, "purpose", "Purpose of address (\"send\" for sending address, \"receive\" for receiving address)"},
664  }},
665  }
666  },
667  RPCExamples{
668  HelpExampleCli("getaddressesbylabel", "\"tabby\"")
669  + HelpExampleRpc("getaddressesbylabel", "\"tabby\"")
670  },
671  [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
672 {
673  const std::shared_ptr<const CWallet> pwallet = GetWalletForJSONRPCRequest(request);
674  if (!pwallet) return NullUniValue;
675 
676  LOCK(pwallet->cs_wallet);
677 
678  std::string label = LabelFromValue(request.params[0]);
679 
680  // Find all addresses that have the given label
682  std::set<std::string> addresses;
683  for (const std::pair<const CTxDestination, CAddressBookData>& item : pwallet->m_address_book) {
684  if (item.second.IsChange()) continue;
685  if (item.second.GetLabel() == label) {
686  std::string address = EncodeDestination(item.first);
687  // CWallet::m_address_book is not expected to contain duplicate
688  // address strings, but build a separate set as a precaution just in
689  // case it does.
690  bool unique = addresses.emplace(address).second;
691  CHECK_NONFATAL(unique);
692  // UniValue::pushKV checks if the key exists in O(N)
693  // and since duplicate addresses are unexpected (checked with
694  // std::set in O(log(N))), UniValue::__pushKV is used instead,
695  // which currently is O(1).
696  ret.__pushKV(address, AddressBookDataToJSON(item.second, false));
697  }
698  }
699 
700  if (ret.empty()) {
701  throw JSONRPCError(RPC_WALLET_INVALID_LABEL_NAME, std::string("No addresses with label " + label));
702  }
703 
704  return ret;
705 },
706  };
707 }
708 
710 {
711  return RPCHelpMan{"listlabels",
712  "\nReturns the list of all labels, or labels that are assigned to addresses with a specific purpose.\n",
713  {
714  {"purpose", RPCArg::Type::STR, RPCArg::Optional::OMITTED_NAMED_ARG, "Address purpose to list labels for ('send','receive'). An empty string is the same as not providing this argument."},
715  },
716  RPCResult{
717  RPCResult::Type::ARR, "", "",
718  {
719  {RPCResult::Type::STR, "label", "Label name"},
720  }
721  },
722  RPCExamples{
723  "\nList all labels\n"
724  + HelpExampleCli("listlabels", "") +
725  "\nList labels that have receiving addresses\n"
726  + HelpExampleCli("listlabels", "receive") +
727  "\nList labels that have sending addresses\n"
728  + HelpExampleCli("listlabels", "send") +
729  "\nAs a JSON-RPC call\n"
730  + HelpExampleRpc("listlabels", "receive")
731  },
732  [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
733 {
734  const std::shared_ptr<const CWallet> pwallet = GetWalletForJSONRPCRequest(request);
735  if (!pwallet) return NullUniValue;
736 
737  LOCK(pwallet->cs_wallet);
738 
739  std::string purpose;
740  if (!request.params[0].isNull()) {
741  purpose = request.params[0].get_str();
742  }
743 
744  // Add to a set to sort by label name, then insert into Univalue array
745  std::set<std::string> label_set;
746  for (const std::pair<const CTxDestination, CAddressBookData>& entry : pwallet->m_address_book) {
747  if (entry.second.IsChange()) continue;
748  if (purpose.empty() || entry.second.purpose == purpose) {
749  label_set.insert(entry.second.GetLabel());
750  }
751  }
752 
754  for (const std::string& name : label_set) {
755  ret.push_back(name);
756  }
757 
758  return ret;
759 },
760  };
761 }
762 
763 
764 #ifdef ENABLE_EXTERNAL_SIGNER
766 {
767  return RPCHelpMan{
768  "walletdisplayaddress",
769  "Display address on an external signer for verification.",
770  {
771  {"address", RPCArg::Type::STR, RPCArg::Optional::NO, "bitcoin address to display"},
772  },
773  RPCResult{
774  RPCResult::Type::OBJ,"","",
775  {
776  {RPCResult::Type::STR, "address", "The address as confirmed by the signer"},
777  }
778  },
779  RPCExamples{""},
780  [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
781  {
782  std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(request);
783  if (!wallet) return NullUniValue;
784  CWallet* const pwallet = wallet.get();
785 
786  LOCK(pwallet->cs_wallet);
787 
788  CTxDestination dest = DecodeDestination(request.params[0].get_str());
789 
790  // Make sure the destination is valid
791  if (!IsValidDestination(dest)) {
792  throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid address");
793  }
794 
795  if (!pwallet->DisplayAddress(dest)) {
796  throw JSONRPCError(RPC_MISC_ERROR, "Failed to display address");
797  }
798 
799  UniValue result(UniValue::VOBJ);
800  result.pushKV("address", request.params[0].get_str());
801  return result;
802  }
803  };
804 }
805 #endif // ENABLE_EXTERNAL_SIGNER
806 } // namespace wallet
WriteHDKeypath
std::string WriteHDKeypath(const std::vector< uint32_t > &keypath)
Write HD keypaths as strings.
Definition: bip32.cpp:63
RPC_MISC_ERROR
@ RPC_MISC_ERROR
General application defined errors.
Definition: protocol.h:39
LOCK2
#define LOCK2(cs1, cs2)
Definition: sync.h:227
RPCResult::Type::ELISION
@ ELISION
Special type to denote elision (...)
bip32.h
HelpExampleCli
std::string HelpExampleCli(const std::string &methodname, const std::string &args)
Definition: util.cpp:156
OutputType
OutputType
Definition: outputtype.h:18
wallet::isminetype
isminetype
IsMine() return codes, which depend on ScriptPubKeyMan implementation.
Definition: ismine.h:41
wallet::ISMINE_WATCH_ONLY
@ ISMINE_WATCH_ONLY
Definition: ismine.h:43
WitnessUnknown
CTxDestination subtype to encode any future Witness version.
Definition: standard.h:125
UniValue::VOBJ
@ VOBJ
Definition: univalue.h:19
Solver
TxoutType Solver(const CScript &scriptPubKey, std::vector< std::vector< unsigned char >> &vSolutionsRet)
Parse a scriptPubKey and identify script type for standard scripts.
Definition: standard.cpp:144
wallet::keypoolrefill
RPCHelpMan keypoolrefill()
Definition: addresses.cpp:316
CRIPEMD160
A hasher class for RIPEMD-160.
Definition: ripemd160.h:12
wallet.h
CHECK_NONFATAL
#define CHECK_NONFATAL(condition)
Throw a NonFatalCheckError when the condition evaluates to false.
Definition: check.h:32
wallet::ScriptIsChange
bool ScriptIsChange(const CWallet &wallet, const CScript &script)
Definition: receive.cpp:66
wallet::DescriptorScriptPubKeyMan::GetDescriptorString
bool GetDescriptorString(std::string &out, const bool priv) const
Definition: scriptpubkeyman.cpp:2284
wallet::DescriptorScriptPubKeyMan
Definition: scriptpubkeyman.h:526
wallet::CAddressBookData
Address book data.
Definition: wallet.h:200
TxoutType
TxoutType
Definition: standard.h:59
key_io.h
wallet::getaddressesbylabel
RPCHelpMan getaddressesbylabel()
Definition: addresses.cpp:651
RPCHelpMan
Definition: util.h:345
wallet::DescribeWalletAddressVisitor
Definition: addresses.cpp:392
CRIPEMD160::Finalize
void Finalize(unsigned char hash[OUTPUT_SIZE])
Definition: ripemd160.cpp:273
NullUniValue
const UniValue NullUniValue
Definition: univalue.cpp:13
GetScriptForDestination
CScript GetScriptForDestination(const CTxDestination &dest)
Generate a Bitcoin scriptPubKey for the given CTxDestination.
Definition: standard.cpp:310
wallet::GetAddressGroupings
std::set< std::set< CTxDestination > > GetAddressGroupings(const CWallet &wallet)
Definition: receive.cpp:385
bilingual_str
Bilingual messages:
Definition: translation.h:16
RPC_INVALID_PARAMETER
@ RPC_INVALID_PARAMETER
Invalid, missing or duplicate parameter.
Definition: protocol.h:43
IsHex
bool IsHex(const std::string &str)
Definition: strencodings.cpp:61
RPCArg::Optional::NO
@ NO
Required arg.
RPCArg::Type::STR
@ STR
RPCArg::Type::ARR
@ ARR
wallet::walletdisplayaddress
RPCHelpMan walletdisplayaddress()
Definition: addresses.cpp:765
SigningProvider
An interface to be implemented by keystores that support signing.
Definition: signingprovider.h:17
wallet::GetWalletForJSONRPCRequest
std::shared_ptr< CWallet > GetWalletForJSONRPCRequest(const JSONRPCRequest &request)
Figures out what wallet, if any, to use for a JSONRPCRequest.
Definition: util.cpp:55
wallet::DescribeWalletAddressVisitor::operator()
UniValue operator()(const WitnessV0KeyHash &id) const
Definition: addresses.cpp:457
RPCResult::Type::NUM
@ NUM
RPC_WALLET_KEYPOOL_RAN_OUT
@ RPC_WALLET_KEYPOOL_RAN_OUT
Keypool ran out, call keypoolrefill first.
Definition: protocol.h:74
HexToPubKey
CPubKey HexToPubKey(const std::string &hex_in)
Definition: util.cpp:192
wallet
Definition: node.h:38
CKeyID
A reference to a CKey: the Hash160 of its serialized public key.
Definition: pubkey.h:23
SigningProvider::GetPubKey
virtual bool GetPubKey(const CKeyID &address, CPubKey &pubkey) const
Definition: signingprovider.h:23
core_io.h
UniValue::pushKV
bool pushKV(const std::string &key, const UniValue &val)
Definition: univalue.cpp:133
ValueFromAmount
UniValue ValueFromAmount(const CAmount amount)
Definition: core_write.cpp:21
wallet::DescribeWalletAddressVisitor::operator()
UniValue operator()(const WitnessV1Taproot &id) const
Definition: addresses.cpp:480
UniValue
Definition: univalue.h:17
wallet::CWallet::DisplayAddress
bool DisplayAddress(const CTxDestination &dest) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Display address on an external signer.
Definition: wallet.cpp:2331
wallet::LegacyScriptPubKeyMan::NewKeyPool
bool NewKeyPool()
Mark old keypool keys as used, and generate all new keys.
Definition: scriptpubkeyman.cpp:1223
WitnessV0KeyHash
Definition: standard.h:109
RPCResult::Type::ARR_FIXED
@ ARR_FIXED
Special array that has a fixed number of entries.
RPCArg::Type::NUM
@ NUM
OutputType::BECH32M
@ BECH32M
wallet::HELP_REQUIRING_PASSPHRASE
const std::string HELP_REQUIRING_PASSPHRASE
Definition: util.cpp:17
wallet::listlabels
RPCHelpMan listlabels()
Definition: addresses.cpp:709
wallet::DescribeWalletAddressVisitor::operator()
UniValue operator()(const WitnessV0ScriptHash &id) const
Definition: addresses.cpp:467
wallet::DescribeWalletAddressVisitor::DescribeWalletAddressVisitor
DescribeWalletAddressVisitor(const SigningProvider *_provider)
Definition: addresses.cpp:430
wallet::GetAddressBalances
std::map< CTxDestination, CAmount > GetAddressBalances(const CWallet &wallet)
Definition: receive.cpp:347
CURRENCY_UNIT
const std::string CURRENCY_UNIT
Definition: feerate.h:14
wallet::DescribeWalletAddressVisitor::operator()
UniValue operator()(const WitnessUnknown &id) const
Definition: addresses.cpp:481
util.h
UniValue::pushKVs
bool pushKVs(const UniValue &obj)
Definition: univalue.cpp:146
CTxDestination
std::variant< CNoDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, WitnessUnknown > CTxDestination
A txout script template with a specific destination.
Definition: standard.h:157
wallet::listaddressgroupings
RPCHelpMan listaddressgroupings()
Definition: addresses.cpp:158
RPCArg::DefaultHint
std::string DefaultHint
Definition: util.h:155
IsValidDestination
bool IsValidDestination(const CTxDestination &dest)
Check whether a CTxDestination is a CNoDestination.
Definition: standard.cpp:332
RPCArg::Optional::OMITTED_NAMED_ARG
@ OMITTED_NAMED_ARG
Optional arg that is a named argument and has a default value of null.
RPCResult::Type::OBJ
@ OBJ
OutputTypeFromDestination
std::optional< OutputType > OutputTypeFromDestination(const CTxDestination &dest)
Get the OutputType for a CTxDestination.
Definition: outputtype.cpp:109
RPCResult::Type::NONE
@ NONE
wallet::LegacyScriptPubKeyMan
Definition: scriptpubkeyman.h:264
wallet::CWallet
A CWallet maintains a set of transactions and balances, and provides the ability to create new transa...
Definition: wallet.h:232
RPC_WALLET_INVALID_LABEL_NAME
@ RPC_WALLET_INVALID_LABEL_NAME
Invalid label name.
Definition: protocol.h:73
UniValue::exists
bool exists(const std::string &key) const
Definition: univalue.h:73
wallet::WALLET_FLAG_DISABLE_PRIVATE_KEYS
@ WALLET_FLAG_DISABLE_PRIVATE_KEYS
Definition: walletutil.h:51
univalue.h
wallet::DEFAULT_KEYPOOL_SIZE
static const unsigned int DEFAULT_KEYPOOL_SIZE
Default for -keypool.
Definition: scriptpubkeyman.h:50
CRIPEMD160::Write
CRIPEMD160 & Write(const unsigned char *data, size_t len)
Definition: ripemd160.cpp:247
RPCResult::Type::STR_HEX
@ STR_HEX
Special string with only hex chars.
AddAndGetMultisigDestination
CTxDestination AddAndGetMultisigDestination(const int required, const std::vector< CPubKey > &pubkeys, OutputType type, FillableSigningProvider &keystore, CScript &script_out)
Definition: util.cpp:226
DescribeAddress
UniValue DescribeAddress(const CTxDestination &dest)
Definition: util.cpp:325
RPCExamples
Definition: util.h:335
wallet::getaddressinfo
RPCHelpMan getaddressinfo()
Definition: addresses.cpp:496
UniValue::__pushKV
void __pushKV(const std::string &key, const UniValue &val)
Definition: univalue.cpp:127
RPC_WALLET_ERROR
@ RPC_WALLET_ERROR
Wallet errors.
Definition: protocol.h:71
RPCResult::Type::STR
@ STR
RPCResult::Type::NUM_TIME
@ NUM_TIME
Special numeric to denote unix epoch time.
RPCResult::Type::ARR
@ ARR
SigningProvider::GetCScript
virtual bool GetCScript(const CScriptID &scriptid, CScript &script) const
Definition: signingprovider.h:21
CScript
Serialized script, used inside transaction inputs and outputs.
Definition: script.h:405
HelpExampleRpc
std::string HelpExampleRpc(const std::string &methodname, const std::string &args)
Definition: util.cpp:174
ExtractDestination
bool ExtractDestination(const CScript &scriptPubKey, CTxDestination &addressRet)
Parse a standard scriptPubKey for the destination address.
Definition: standard.cpp:213
CNoDestination
Definition: standard.h:73
wallet::CWallet::cs_wallet
RecursiveMutex cs_wallet
Main wallet lock.
Definition: wallet.h:352
wallet::ISMINE_SPENDABLE
@ ISMINE_SPENDABLE
Definition: ismine.h:44
RPC_INVALID_ADDRESS_OR_KEY
@ RPC_INVALID_ADDRESS_OR_KEY
Invalid address or key.
Definition: protocol.h:41
name
const char * name
Definition: rest.cpp:52
wallet::getnewaddress
RPCHelpMan getnewaddress()
Definition: addresses.cpp:17
CPubKey::IsCompressed
bool IsCompressed() const
Check whether this is a compressed public key.
Definition: pubkey.h:198
PKHash
Definition: standard.h:79
ToKeyID
CKeyID ToKeyID(const PKHash &key_hash)
Definition: standard.cpp:34
strprintf
#define strprintf
Format arguments and return the string or write to given std::ostream (see tinyformat::format doc for...
Definition: tinyformat.h:1164
GetTxnOutputType
std::string GetTxnOutputType(TxoutType t)
Get the name of a TxoutType as a string.
Definition: standard.cpp:49
uint160
160-bit opaque blob.
Definition: uint256.h:113
wallet::CAddressBookData::purpose
std::string purpose
Definition: wallet.h:206
CPubKey
An encapsulated public key.
Definition: pubkey.h:33
wallet::DescribeWalletAddressVisitor::operator()
UniValue operator()(const ScriptHash &scripthash) const
Definition: addresses.cpp:446
RPCResult::Type::BOOL
@ BOOL
wallet::DescribeWalletAddressVisitor::operator()
UniValue operator()(const PKHash &pkhash) const
Definition: addresses.cpp:434
translation.h
IsSolvable
bool IsSolvable(const SigningProvider &provider, const CScript &script)
Definition: sign.cpp:583
wallet::DescribeWalletAddressVisitor::operator()
UniValue operator()(const CNoDestination &dest) const
Definition: addresses.cpp:432
JSONRPCError
UniValue JSONRPCError(int code, const std::string &message)
Definition: request.cpp:51
LOCK
#define LOCK(cs)
Definition: sync.h:226
RPCArg::Optional::OMITTED
@ OMITTED
Optional argument with default value omitted because they are implicitly clear.
DecodeDestination
CTxDestination DecodeDestination(const std::string &str, std::string &error_msg, std::vector< int > *error_locations)
Definition: key_io.cpp:281
wallet::DescribeWalletAddressVisitor::ProcessSubScript
void ProcessSubScript(const CScript &subscript, UniValue &obj) const
Definition: addresses.cpp:397
TxoutType::MULTISIG
@ MULTISIG
UniValue::push_back
bool push_back(const UniValue &val)
Definition: univalue.cpp:108
wallet::getrawchangeaddress
RPCHelpMan getrawchangeaddress()
Definition: addresses.cpp:72
wallet::AddressBookDataToJSON
static UniValue AddressBookDataToJSON(const CAddressBookData &data, const bool verbose)
Convert CAddressBookData to JSON record.
Definition: addresses.cpp:641
wallet::DescribeWalletAddress
static UniValue DescribeWalletAddress(const CWallet &wallet, const CTxDestination &dest)
Definition: addresses.cpp:484
EXAMPLE_ADDRESS
const std::string EXAMPLE_ADDRESS[2]
Example bech32 addresses for the RPCExamples help documentation.
Definition: util.cpp:22
UniValue::empty
bool empty() const
Definition: univalue.h:64
wallet::DescribeWalletAddressVisitor::provider
const SigningProvider *const provider
Definition: addresses.cpp:395
wallet::addmultisigaddress
RPCHelpMan addmultisigaddress()
Definition: addresses.cpp:218
RPCResult::Type::OBJ_DYN
@ OBJ_DYN
Special dictionary with keys that are not literals.
receive.h
UniValue::size
size_t size() const
Definition: univalue.h:66
JSONRPCRequest
Definition: request.h:28
RPCResult
Definition: util.h:231
FillableSigningProvider::cs_KeyStore
RecursiveMutex cs_KeyStore
Definition: signingprovider.h:148
error
bool error(const char *fmt, const Args &... args)
Definition: system.h:49
wallet::newkeypool
RPCHelpMan newkeypool()
Definition: addresses.cpp:360
RPCResult::Type::STR_AMOUNT
@ STR_AMOUNT
Special string to represent a floating point amount.
UniValue::get_array
const UniValue & get_array() const
Definition: univalue_get.cpp:142
UniValue::VARR
@ VARR
Definition: univalue.h:19
wallet::ScriptPubKeyMan
Definition: scriptpubkeyman.h:166
WitnessV0ScriptHash
Definition: standard.h:102
InferDescriptor
std::unique_ptr< Descriptor > InferDescriptor(const CScript &script, const SigningProvider &provider)
Find a descriptor for the specified script, using information from provider where possible.
Definition: descriptor.cpp:1413
wallet::EnsureLegacyScriptPubKeyMan
LegacyScriptPubKeyMan & EnsureLegacyScriptPubKeyMan(CWallet &wallet, bool also_create)
Definition: util.cpp:97
CScriptID
A reference to a CScript: the Hash160 of its serialization (see script.h)
Definition: standard.h:25
HexStr
std::string HexStr(const Span< const uint8_t > s)
Convert a span of bytes to a lower-case hexadecimal string.
Definition: strencodings.cpp:510
AddrToPubKey
CPubKey AddrToPubKey(const FillableSigningProvider &keystore, const std::string &addr_in)
Definition: util.cpp:205
wallet::CAddressBookData::GetLabel
const std::string & GetLabel() const
Definition: wallet.h:214
ScriptHash
Definition: standard.h:89
ParseOutputType
std::optional< OutputType > ParseOutputType(const std::string &type)
Definition: outputtype.cpp:24
base_blob::begin
unsigned char * begin()
Definition: uint256.h:58
EncodeDestination
std::string EncodeDestination(const CTxDestination &dest)
Definition: key_io.cpp:276
UNIX_EPOCH_TIME
const std::string UNIX_EPOCH_TIME
String used to describe UNIX epoch time in documentation, factored out to a constant for consistency.
Definition: util.cpp:21
wallet::EnsureWalletIsUnlocked
void EnsureWalletIsUnlocked(const CWallet &wallet)
Definition: util.cpp:80
wallet::setlabel
RPCHelpMan setlabel()
Definition: addresses.cpp:120
WitnessV1Taproot
Definition: standard.h:118
wallet::LabelFromValue
std::string LabelFromValue(const UniValue &value)
Definition: util.cpp:118