Bitcoin Core  22.99.0
P2P Digital Currency
wallet.cpp
Go to the documentation of this file.
1 // Copyright (c) 2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2021 The Bitcoin Core developers
3 // Distributed under the MIT software license, see the accompanying
4 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 
6 #include <core_io.h>
7 #include <key_io.h>
8 #include <rpc/server.h>
9 #include <rpc/util.h>
10 #include <util/translation.h>
11 #include <wallet/receive.h>
12 #include <wallet/rpc/wallet.h>
13 #include <wallet/rpc/util.h>
14 #include <wallet/wallet.h>
15 
16 #include <optional>
17 
18 #include <univalue.h>
19 
20 
21 namespace wallet {
23 bool HaveKey(const SigningProvider& wallet, const CKey& key)
24 {
25  CKey key2;
26  key2.Set(key.begin(), key.end(), !key.IsCompressed());
27  return wallet.HaveKey(key.GetPubKey().GetID()) || wallet.HaveKey(key2.GetPubKey().GetID());
28 }
29 
31 {
32  return RPCHelpMan{"getwalletinfo",
33  "Returns an object containing various wallet state info.\n",
34  {},
35  RPCResult{
36  RPCResult::Type::OBJ, "", "",
37  {
38  {
39  {RPCResult::Type::STR, "walletname", "the wallet name"},
40  {RPCResult::Type::NUM, "walletversion", "the wallet version"},
41  {RPCResult::Type::STR, "format", "the database format (bdb or sqlite)"},
42  {RPCResult::Type::STR_AMOUNT, "balance", "DEPRECATED. Identical to getbalances().mine.trusted"},
43  {RPCResult::Type::STR_AMOUNT, "unconfirmed_balance", "DEPRECATED. Identical to getbalances().mine.untrusted_pending"},
44  {RPCResult::Type::STR_AMOUNT, "immature_balance", "DEPRECATED. Identical to getbalances().mine.immature"},
45  {RPCResult::Type::NUM, "txcount", "the total number of transactions in the wallet"},
46  {RPCResult::Type::NUM_TIME, "keypoololdest", /*optional=*/true, "the " + UNIX_EPOCH_TIME + " of the oldest pre-generated key in the key pool. Legacy wallets only."},
47  {RPCResult::Type::NUM, "keypoolsize", "how many new keys are pre-generated (only counts external keys)"},
48  {RPCResult::Type::NUM, "keypoolsize_hd_internal", /*optional=*/true, "how many new keys are pre-generated for internal use (used for change outputs, only appears if the wallet is using this feature, otherwise external keys are used)"},
49  {RPCResult::Type::NUM_TIME, "unlocked_until", /*optional=*/true, "the " + UNIX_EPOCH_TIME + " until which the wallet is unlocked for transfers, or 0 if the wallet is locked (only present for passphrase-encrypted wallets)"},
50  {RPCResult::Type::STR_AMOUNT, "paytxfee", "the transaction fee configuration, set in " + CURRENCY_UNIT + "/kvB"},
51  {RPCResult::Type::STR_HEX, "hdseedid", /*optional=*/true, "the Hash160 of the HD seed (only present when HD is enabled)"},
52  {RPCResult::Type::BOOL, "private_keys_enabled", "false if privatekeys are disabled for this wallet (enforced watch-only wallet)"},
53  {RPCResult::Type::BOOL, "avoid_reuse", "whether this wallet tracks clean/dirty coins in terms of reuse"},
54  {RPCResult::Type::OBJ, "scanning", "current scanning details, or false if no scan is in progress",
55  {
56  {RPCResult::Type::NUM, "duration", "elapsed seconds since scan start"},
57  {RPCResult::Type::NUM, "progress", "scanning progress percentage [0.0, 1.0]"},
58  }},
59  {RPCResult::Type::BOOL, "descriptors", "whether this wallet uses descriptors for scriptPubKey management"},
60  }},
61  },
63  HelpExampleCli("getwalletinfo", "")
64  + HelpExampleRpc("getwalletinfo", "")
65  },
66  [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
67 {
68  const std::shared_ptr<const CWallet> pwallet = GetWalletForJSONRPCRequest(request);
69  if (!pwallet) return NullUniValue;
70 
71  // Make sure the results are valid at least up to the most recent block
72  // the user could have gotten from another RPC command prior to now
73  pwallet->BlockUntilSyncedToCurrentChain();
74 
75  LOCK(pwallet->cs_wallet);
76 
78 
79  size_t kpExternalSize = pwallet->KeypoolCountExternalKeys();
80  const auto bal = GetBalance(*pwallet);
81  obj.pushKV("walletname", pwallet->GetName());
82  obj.pushKV("walletversion", pwallet->GetVersion());
83  obj.pushKV("format", pwallet->GetDatabase().Format());
84  obj.pushKV("balance", ValueFromAmount(bal.m_mine_trusted));
85  obj.pushKV("unconfirmed_balance", ValueFromAmount(bal.m_mine_untrusted_pending));
86  obj.pushKV("immature_balance", ValueFromAmount(bal.m_mine_immature));
87  obj.pushKV("txcount", (int)pwallet->mapWallet.size());
88  const auto kp_oldest = pwallet->GetOldestKeyPoolTime();
89  if (kp_oldest.has_value()) {
90  obj.pushKV("keypoololdest", kp_oldest.value());
91  }
92  obj.pushKV("keypoolsize", (int64_t)kpExternalSize);
93 
94  LegacyScriptPubKeyMan* spk_man = pwallet->GetLegacyScriptPubKeyMan();
95  if (spk_man) {
96  CKeyID seed_id = spk_man->GetHDChain().seed_id;
97  if (!seed_id.IsNull()) {
98  obj.pushKV("hdseedid", seed_id.GetHex());
99  }
100  }
101 
102  if (pwallet->CanSupportFeature(FEATURE_HD_SPLIT)) {
103  obj.pushKV("keypoolsize_hd_internal", (int64_t)(pwallet->GetKeyPoolSize() - kpExternalSize));
104  }
105  if (pwallet->IsCrypted()) {
106  obj.pushKV("unlocked_until", pwallet->nRelockTime);
107  }
108  obj.pushKV("paytxfee", ValueFromAmount(pwallet->m_pay_tx_fee.GetFeePerK()));
109  obj.pushKV("private_keys_enabled", !pwallet->IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS));
110  obj.pushKV("avoid_reuse", pwallet->IsWalletFlagSet(WALLET_FLAG_AVOID_REUSE));
111  if (pwallet->IsScanning()) {
112  UniValue scanning(UniValue::VOBJ);
113  scanning.pushKV("duration", pwallet->ScanningDuration() / 1000);
114  scanning.pushKV("progress", pwallet->ScanningProgress());
115  obj.pushKV("scanning", scanning);
116  } else {
117  obj.pushKV("scanning", false);
118  }
119  obj.pushKV("descriptors", pwallet->IsWalletFlagSet(WALLET_FLAG_DESCRIPTORS));
120  return obj;
121 },
122  };
123 }
124 
126 {
127  return RPCHelpMan{"listwalletdir",
128  "Returns a list of wallets in the wallet directory.\n",
129  {},
130  RPCResult{
131  RPCResult::Type::OBJ, "", "",
132  {
133  {RPCResult::Type::ARR, "wallets", "",
134  {
135  {RPCResult::Type::OBJ, "", "",
136  {
137  {RPCResult::Type::STR, "name", "The wallet name"},
138  }},
139  }},
140  }
141  },
142  RPCExamples{
143  HelpExampleCli("listwalletdir", "")
144  + HelpExampleRpc("listwalletdir", "")
145  },
146  [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
147 {
148  UniValue wallets(UniValue::VARR);
149  for (const auto& path : ListDatabases(GetWalletDir())) {
151  wallet.pushKV("name", path.u8string());
152  wallets.push_back(wallet);
153  }
154 
155  UniValue result(UniValue::VOBJ);
156  result.pushKV("wallets", wallets);
157  return result;
158 },
159  };
160 }
161 
163 {
164  return RPCHelpMan{"listwallets",
165  "Returns a list of currently loaded wallets.\n"
166  "For full information on the wallet, use \"getwalletinfo\"\n",
167  {},
168  RPCResult{
169  RPCResult::Type::ARR, "", "",
170  {
171  {RPCResult::Type::STR, "walletname", "the wallet name"},
172  }
173  },
174  RPCExamples{
175  HelpExampleCli("listwallets", "")
176  + HelpExampleRpc("listwallets", "")
177  },
178  [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
179 {
181 
182  WalletContext& context = EnsureWalletContext(request.context);
183  for (const std::shared_ptr<CWallet>& wallet : GetWallets(context)) {
184  LOCK(wallet->cs_wallet);
185  obj.push_back(wallet->GetName());
186  }
187 
188  return obj;
189 },
190  };
191 }
192 
194 {
195  return RPCHelpMan{"loadwallet",
196  "\nLoads a wallet from a wallet file or directory."
197  "\nNote that all wallet command-line options used when starting bitcoind will be"
198  "\napplied to the new wallet.\n",
199  {
200  {"filename", RPCArg::Type::STR, RPCArg::Optional::NO, "The wallet directory or .dat file."},
201  {"load_on_startup", RPCArg::Type::BOOL, RPCArg::Optional::OMITTED_NAMED_ARG, "Save wallet name to persistent settings and load on startup. True to add wallet to startup list, false to remove, null to leave unchanged."},
202  },
203  RPCResult{
204  RPCResult::Type::OBJ, "", "",
205  {
206  {RPCResult::Type::STR, "name", "The wallet name if loaded successfully."},
207  {RPCResult::Type::STR, "warning", "Warning message if wallet was not loaded cleanly."},
208  }
209  },
210  RPCExamples{
211  HelpExampleCli("loadwallet", "\"test.dat\"")
212  + HelpExampleRpc("loadwallet", "\"test.dat\"")
213  },
214  [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
215 {
216  WalletContext& context = EnsureWalletContext(request.context);
217  const std::string name(request.params[0].get_str());
218 
219  DatabaseOptions options;
220  DatabaseStatus status;
221  options.require_existing = true;
223  std::vector<bilingual_str> warnings;
224  std::optional<bool> load_on_start = request.params[1].isNull() ? std::nullopt : std::optional<bool>(request.params[1].get_bool());
225  std::shared_ptr<CWallet> const wallet = LoadWallet(context, name, load_on_start, options, status, error, warnings);
226 
227  HandleWalletError(wallet, status, error);
228 
230  obj.pushKV("name", wallet->GetName());
231  obj.pushKV("warning", Join(warnings, Untranslated("\n")).original);
232 
233  return obj;
234 },
235  };
236 }
237 
239 {
240  std::string flags = "";
241  for (auto& it : WALLET_FLAG_MAP)
242  if (it.second & MUTABLE_WALLET_FLAGS)
243  flags += (flags == "" ? "" : ", ") + it.first;
244 
245  return RPCHelpMan{"setwalletflag",
246  "\nChange the state of the given wallet flag for a wallet.\n",
247  {
248  {"flag", RPCArg::Type::STR, RPCArg::Optional::NO, "The name of the flag to change. Current available flags: " + flags},
249  {"value", RPCArg::Type::BOOL, RPCArg::Default{true}, "The new state."},
250  },
251  RPCResult{
252  RPCResult::Type::OBJ, "", "",
253  {
254  {RPCResult::Type::STR, "flag_name", "The name of the flag that was modified"},
255  {RPCResult::Type::BOOL, "flag_state", "The new state of the flag"},
256  {RPCResult::Type::STR, "warnings", "Any warnings associated with the change"},
257  }
258  },
259  RPCExamples{
260  HelpExampleCli("setwalletflag", "avoid_reuse")
261  + HelpExampleRpc("setwalletflag", "\"avoid_reuse\"")
262  },
263  [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
264 {
265  std::shared_ptr<CWallet> const pwallet = GetWalletForJSONRPCRequest(request);
266  if (!pwallet) return NullUniValue;
267 
268  std::string flag_str = request.params[0].get_str();
269  bool value = request.params[1].isNull() || request.params[1].get_bool();
270 
271  if (!WALLET_FLAG_MAP.count(flag_str)) {
272  throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Unknown wallet flag: %s", flag_str));
273  }
274 
275  auto flag = WALLET_FLAG_MAP.at(flag_str);
276 
277  if (!(flag & MUTABLE_WALLET_FLAGS)) {
278  throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Wallet flag is immutable: %s", flag_str));
279  }
280 
282 
283  if (pwallet->IsWalletFlagSet(flag) == value) {
284  throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Wallet flag is already set to %s: %s", value ? "true" : "false", flag_str));
285  }
286 
287  res.pushKV("flag_name", flag_str);
288  res.pushKV("flag_state", value);
289 
290  if (value) {
291  pwallet->SetWalletFlag(flag);
292  } else {
293  pwallet->UnsetWalletFlag(flag);
294  }
295 
296  if (flag && value && WALLET_FLAG_CAVEATS.count(flag)) {
297  res.pushKV("warnings", WALLET_FLAG_CAVEATS.at(flag));
298  }
299 
300  return res;
301 },
302  };
303 }
304 
306 {
307  return RPCHelpMan{
308  "createwallet",
309  "\nCreates and loads a new wallet.\n",
310  {
311  {"wallet_name", RPCArg::Type::STR, RPCArg::Optional::NO, "The name for the new wallet. If this is a path, the wallet will be created at the path location."},
312  {"disable_private_keys", RPCArg::Type::BOOL, RPCArg::Default{false}, "Disable the possibility of private keys (only watchonlys are possible in this mode)."},
313  {"blank", RPCArg::Type::BOOL, RPCArg::Default{false}, "Create a blank wallet. A blank wallet has no keys or HD seed. One can be set using sethdseed."},
314  {"passphrase", RPCArg::Type::STR, RPCArg::Optional::OMITTED_NAMED_ARG, "Encrypt the wallet with this passphrase."},
315  {"avoid_reuse", RPCArg::Type::BOOL, RPCArg::Default{false}, "Keep track of coin reuse, and treat dirty and clean coins differently with privacy considerations in mind."},
316  {"descriptors", RPCArg::Type::BOOL, RPCArg::Default{true}, "Create a native descriptor wallet. The wallet will use descriptors internally to handle address creation"},
317  {"load_on_startup", RPCArg::Type::BOOL, RPCArg::Optional::OMITTED_NAMED_ARG, "Save wallet name to persistent settings and load on startup. True to add wallet to startup list, false to remove, null to leave unchanged."},
318  {"external_signer", RPCArg::Type::BOOL, RPCArg::Default{false}, "Use an external signer such as a hardware wallet. Requires -signer to be configured. Wallet creation will fail if keys cannot be fetched. Requires disable_private_keys and descriptors set to true."},
319  },
320  RPCResult{
321  RPCResult::Type::OBJ, "", "",
322  {
323  {RPCResult::Type::STR, "name", "The wallet name if created successfully. If the wallet was created using a full path, the wallet_name will be the full path."},
324  {RPCResult::Type::STR, "warning", "Warning message if wallet was not loaded cleanly."},
325  }
326  },
327  RPCExamples{
328  HelpExampleCli("createwallet", "\"testwallet\"")
329  + HelpExampleRpc("createwallet", "\"testwallet\"")
330  + HelpExampleCliNamed("createwallet", {{"wallet_name", "descriptors"}, {"avoid_reuse", true}, {"descriptors", true}, {"load_on_startup", true}})
331  + HelpExampleRpcNamed("createwallet", {{"wallet_name", "descriptors"}, {"avoid_reuse", true}, {"descriptors", true}, {"load_on_startup", true}})
332  },
333  [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
334 {
335  WalletContext& context = EnsureWalletContext(request.context);
336  uint64_t flags = 0;
337  if (!request.params[1].isNull() && request.params[1].get_bool()) {
339  }
340 
341  if (!request.params[2].isNull() && request.params[2].get_bool()) {
343  }
344  SecureString passphrase;
345  passphrase.reserve(100);
346  std::vector<bilingual_str> warnings;
347  if (!request.params[3].isNull()) {
348  passphrase = request.params[3].get_str().c_str();
349  if (passphrase.empty()) {
350  // Empty string means unencrypted
351  warnings.emplace_back(Untranslated("Empty string given as passphrase, wallet will not be encrypted."));
352  }
353  }
354 
355  if (!request.params[4].isNull() && request.params[4].get_bool()) {
357  }
358  if (request.params[5].isNull() || request.params[5].get_bool()) {
359 #ifndef USE_SQLITE
360  throw JSONRPCError(RPC_WALLET_ERROR, "Compiled without sqlite support (required for descriptor wallets)");
361 #endif
363  }
364  if (!request.params[7].isNull() && request.params[7].get_bool()) {
365 #ifdef ENABLE_EXTERNAL_SIGNER
367 #else
368  throw JSONRPCError(RPC_WALLET_ERROR, "Compiled without external signing support (required for external signing)");
369 #endif
370  }
371 
372 #ifndef USE_BDB
373  if (!(flags & WALLET_FLAG_DESCRIPTORS)) {
374  throw JSONRPCError(RPC_WALLET_ERROR, "Compiled without bdb support (required for legacy wallets)");
375  }
376 #endif
377 
378  DatabaseOptions options;
379  DatabaseStatus status;
380  options.require_create = true;
381  options.create_flags = flags;
382  options.create_passphrase = passphrase;
384  std::optional<bool> load_on_start = request.params[6].isNull() ? std::nullopt : std::optional<bool>(request.params[6].get_bool());
385  const std::shared_ptr<CWallet> wallet = CreateWallet(context, request.params[0].get_str(), load_on_start, options, status, error, warnings);
386  if (!wallet) {
387  RPCErrorCode code = status == DatabaseStatus::FAILED_ENCRYPT ? RPC_WALLET_ENCRYPTION_FAILED : RPC_WALLET_ERROR;
388  throw JSONRPCError(code, error.original);
389  }
390 
392  obj.pushKV("name", wallet->GetName());
393  obj.pushKV("warning", Join(warnings, Untranslated("\n")).original);
394 
395  return obj;
396 },
397  };
398 }
399 
401 {
402  return RPCHelpMan{"unloadwallet",
403  "Unloads the wallet referenced by the request endpoint otherwise unloads the wallet specified in the argument.\n"
404  "Specifying the wallet name on a wallet endpoint is invalid.",
405  {
406  {"wallet_name", RPCArg::Type::STR, RPCArg::DefaultHint{"the wallet name from the RPC endpoint"}, "The name of the wallet to unload. If provided both here and in the RPC endpoint, the two must be identical."},
407  {"load_on_startup", RPCArg::Type::BOOL, RPCArg::Optional::OMITTED_NAMED_ARG, "Save wallet name to persistent settings and load on startup. True to add wallet to startup list, false to remove, null to leave unchanged."},
408  },
410  {RPCResult::Type::STR, "warning", "Warning message if wallet was not unloaded cleanly."},
411  }},
412  RPCExamples{
413  HelpExampleCli("unloadwallet", "wallet_name")
414  + HelpExampleRpc("unloadwallet", "wallet_name")
415  },
416  [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
417 {
418  std::string wallet_name;
419  if (GetWalletNameFromJSONRPCRequest(request, wallet_name)) {
420  if (!(request.params[0].isNull() || request.params[0].get_str() == wallet_name)) {
421  throw JSONRPCError(RPC_INVALID_PARAMETER, "RPC endpoint wallet and wallet_name parameter specify different wallets");
422  }
423  } else {
424  wallet_name = request.params[0].get_str();
425  }
426 
427  WalletContext& context = EnsureWalletContext(request.context);
428  std::shared_ptr<CWallet> wallet = GetWallet(context, wallet_name);
429  if (!wallet) {
430  throw JSONRPCError(RPC_WALLET_NOT_FOUND, "Requested wallet does not exist or is not loaded");
431  }
432 
433  // Release the "main" shared pointer and prevent further notifications.
434  // Note that any attempt to load the same wallet would fail until the wallet
435  // is destroyed (see CheckUniqueFileid).
436  std::vector<bilingual_str> warnings;
437  std::optional<bool> load_on_start = request.params[1].isNull() ? std::nullopt : std::optional<bool>(request.params[1].get_bool());
438  if (!RemoveWallet(context, wallet, load_on_start, warnings)) {
439  throw JSONRPCError(RPC_MISC_ERROR, "Requested wallet already unloaded");
440  }
441 
442  UnloadWallet(std::move(wallet));
443 
444  UniValue result(UniValue::VOBJ);
445  result.pushKV("warning", Join(warnings, Untranslated("\n")).original);
446  return result;
447 },
448  };
449 }
450 
452 {
453  return RPCHelpMan{"sethdseed",
454  "\nSet or generate a new HD wallet seed. Non-HD wallets will not be upgraded to being a HD wallet. Wallets that are already\n"
455  "HD will have a new HD seed set so that new keys added to the keypool will be derived from this new seed.\n"
456  "\nNote that you will need to MAKE A NEW BACKUP of your wallet after setting the HD wallet seed." +
458  {
459  {"newkeypool", RPCArg::Type::BOOL, RPCArg::Default{true}, "Whether to flush old unused addresses, including change addresses, from the keypool and regenerate it.\n"
460  "If true, the next address from getnewaddress and change address from getrawchangeaddress will be from this new seed.\n"
461  "If false, addresses (including change addresses if the wallet already had HD Chain Split enabled) from the existing\n"
462  "keypool will be used until it has been depleted."},
463  {"seed", RPCArg::Type::STR, RPCArg::DefaultHint{"random seed"}, "The WIF private key to use as the new HD seed.\n"
464  "The seed value can be retrieved using the dumpwallet command. It is the private key marked hdseed=1"},
465  },
467  RPCExamples{
468  HelpExampleCli("sethdseed", "")
469  + HelpExampleCli("sethdseed", "false")
470  + HelpExampleCli("sethdseed", "true \"wifkey\"")
471  + HelpExampleRpc("sethdseed", "true, \"wifkey\"")
472  },
473  [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
474 {
475  std::shared_ptr<CWallet> const pwallet = GetWalletForJSONRPCRequest(request);
476  if (!pwallet) return NullUniValue;
477 
478  LegacyScriptPubKeyMan& spk_man = EnsureLegacyScriptPubKeyMan(*pwallet, true);
479 
480  if (pwallet->IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS)) {
481  throw JSONRPCError(RPC_WALLET_ERROR, "Cannot set a HD seed to a wallet with private keys disabled");
482  }
483 
484  LOCK2(pwallet->cs_wallet, spk_man.cs_KeyStore);
485 
486  // Do not do anything to non-HD wallets
487  if (!pwallet->CanSupportFeature(FEATURE_HD)) {
488  throw JSONRPCError(RPC_WALLET_ERROR, "Cannot set an HD seed on a non-HD wallet. Use the upgradewallet RPC in order to upgrade a non-HD wallet to HD");
489  }
490 
491  EnsureWalletIsUnlocked(*pwallet);
492 
493  bool flush_key_pool = true;
494  if (!request.params[0].isNull()) {
495  flush_key_pool = request.params[0].get_bool();
496  }
497 
498  CPubKey master_pub_key;
499  if (request.params[1].isNull()) {
500  master_pub_key = spk_man.GenerateNewSeed();
501  } else {
502  CKey key = DecodeSecret(request.params[1].get_str());
503  if (!key.IsValid()) {
504  throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid private key");
505  }
506 
507  if (HaveKey(spk_man, key)) {
508  throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Already have this key (either as an HD seed or as a loose private key)");
509  }
510 
511  master_pub_key = spk_man.DeriveNewSeed(key);
512  }
513 
514  spk_man.SetHDSeed(master_pub_key);
515  if (flush_key_pool) spk_man.NewKeyPool();
516 
517  return NullUniValue;
518 },
519  };
520 }
521 
523 {
524  return RPCHelpMan{"upgradewallet",
525  "\nUpgrade the wallet. Upgrades to the latest version if no version number is specified.\n"
526  "New keys may be generated and a new wallet backup will need to be made.",
527  {
528  {"version", RPCArg::Type::NUM, RPCArg::Default{FEATURE_LATEST}, "The version number to upgrade to. Default is the latest wallet version."}
529  },
530  RPCResult{
531  RPCResult::Type::OBJ, "", "",
532  {
533  {RPCResult::Type::STR, "wallet_name", "Name of wallet this operation was performed on"},
534  {RPCResult::Type::NUM, "previous_version", "Version of wallet before this operation"},
535  {RPCResult::Type::NUM, "current_version", "Version of wallet after this operation"},
536  {RPCResult::Type::STR, "result", /*optional=*/true, "Description of result, if no error"},
537  {RPCResult::Type::STR, "error", /*optional=*/true, "Error message (if there is one)"}
538  },
539  },
540  RPCExamples{
541  HelpExampleCli("upgradewallet", "169900")
542  + HelpExampleRpc("upgradewallet", "169900")
543  },
544  [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
545 {
546  std::shared_ptr<CWallet> const pwallet = GetWalletForJSONRPCRequest(request);
547  if (!pwallet) return NullUniValue;
548 
549  RPCTypeCheck(request.params, {UniValue::VNUM}, true);
550 
551  EnsureWalletIsUnlocked(*pwallet);
552 
553  int version = 0;
554  if (!request.params[0].isNull()) {
555  version = request.params[0].get_int();
556  }
558  const int previous_version{pwallet->GetVersion()};
559  const bool wallet_upgraded{pwallet->UpgradeWallet(version, error)};
560  const int current_version{pwallet->GetVersion()};
561  std::string result;
562 
563  if (wallet_upgraded) {
564  if (previous_version == current_version) {
565  result = "Already at latest version. Wallet version unchanged.";
566  } else {
567  result = strprintf("Wallet upgraded successfully from version %i to version %i.", previous_version, current_version);
568  }
569  }
570 
572  obj.pushKV("wallet_name", pwallet->GetName());
573  obj.pushKV("previous_version", previous_version);
574  obj.pushKV("current_version", current_version);
575  if (!result.empty()) {
576  obj.pushKV("result", result);
577  } else {
578  CHECK_NONFATAL(!error.empty());
579  obj.pushKV("error", error.original);
580  }
581  return obj;
582 },
583  };
584 }
585 
586 // addresses
597 #ifdef ENABLE_EXTERNAL_SIGNER
599 #endif // ENABLE_EXTERNAL_SIGNER
600 
601 // backup
615 
616 // coins
625 
626 // encryption
631 
632 // spend
639 RPCHelpMan send();
643 
644 // signmessage
646 
647 // transactions
656 
658 {
659 // clang-format off
660 static const CRPCCommand commands[] =
661 { // category actor (function)
662  // ------------------ ------------------------
663  { "rawtransactions", &fundrawtransaction, },
664  { "wallet", &abandontransaction, },
665  { "wallet", &abortrescan, },
666  { "wallet", &addmultisigaddress, },
667  { "wallet", &backupwallet, },
668  { "wallet", &bumpfee, },
669  { "wallet", &psbtbumpfee, },
670  { "wallet", &createwallet, },
671  { "wallet", &restorewallet, },
672  { "wallet", &dumpprivkey, },
673  { "wallet", &dumpwallet, },
674  { "wallet", &encryptwallet, },
675  { "wallet", &getaddressesbylabel, },
676  { "wallet", &getaddressinfo, },
677  { "wallet", &getbalance, },
678  { "wallet", &getnewaddress, },
679  { "wallet", &getrawchangeaddress, },
680  { "wallet", &getreceivedbyaddress, },
681  { "wallet", &getreceivedbylabel, },
682  { "wallet", &gettransaction, },
683  { "wallet", &getunconfirmedbalance, },
684  { "wallet", &getbalances, },
685  { "wallet", &getwalletinfo, },
686  { "wallet", &importaddress, },
687  { "wallet", &importdescriptors, },
688  { "wallet", &importmulti, },
689  { "wallet", &importprivkey, },
690  { "wallet", &importprunedfunds, },
691  { "wallet", &importpubkey, },
692  { "wallet", &importwallet, },
693  { "wallet", &keypoolrefill, },
694  { "wallet", &listaddressgroupings, },
695  { "wallet", &listdescriptors, },
696  { "wallet", &listlabels, },
697  { "wallet", &listlockunspent, },
698  { "wallet", &listreceivedbyaddress, },
699  { "wallet", &listreceivedbylabel, },
700  { "wallet", &listsinceblock, },
701  { "wallet", &listtransactions, },
702  { "wallet", &listunspent, },
703  { "wallet", &listwalletdir, },
704  { "wallet", &listwallets, },
705  { "wallet", &loadwallet, },
706  { "wallet", &lockunspent, },
707  { "wallet", &newkeypool, },
708  { "wallet", &removeprunedfunds, },
709  { "wallet", &rescanblockchain, },
710  { "wallet", &send, },
711  { "wallet", &sendmany, },
712  { "wallet", &sendtoaddress, },
713  { "wallet", &sethdseed, },
714  { "wallet", &setlabel, },
715  { "wallet", &settxfee, },
716  { "wallet", &setwalletflag, },
717  { "wallet", &signmessage, },
718  { "wallet", &signrawtransactionwithwallet, },
719  { "wallet", &unloadwallet, },
720  { "wallet", &upgradewallet, },
721  { "wallet", &walletcreatefundedpsbt, },
722 #ifdef ENABLE_EXTERNAL_SIGNER
723  { "wallet", &walletdisplayaddress, },
724 #endif // ENABLE_EXTERNAL_SIGNER
725  { "wallet", &walletlock, },
726  { "wallet", &walletpassphrase, },
727  { "wallet", &walletpassphrasechange, },
728  { "wallet", &walletprocesspsbt, },
729 };
730 // clang-format on
731  return commands;
732 }
733 } // namespace wallet
CKey::IsCompressed
bool IsCompressed() const
Check whether the public key corresponding to this private key is (to be) compressed.
Definition: key.h:96
RPC_MISC_ERROR
@ RPC_MISC_ERROR
General application defined errors.
Definition: protocol.h:39
LOCK2
#define LOCK2(cs1, cs2)
Definition: sync.h:227
wallet::listtransactions
RPCHelpMan listtransactions()
Definition: transactions.cpp:449
wallet::walletcreatefundedpsbt
RPCHelpMan walletcreatefundedpsbt()
Definition: spend.cpp:1238
wallet::backupwallet
RPCHelpMan backupwallet()
Definition: backup.cpp:1819
wallet::sethdseed
static RPCHelpMan sethdseed()
Definition: wallet.cpp:451
HelpExampleCli
std::string HelpExampleCli(const std::string &methodname, const std::string &args)
Definition: util.cpp:156
UniValue::VOBJ
@ VOBJ
Definition: univalue.h:19
wallet::keypoolrefill
RPCHelpMan keypoolrefill()
Definition: addresses.cpp:316
wallet.h
CHECK_NONFATAL
#define CHECK_NONFATAL(condition)
Throw a NonFatalCheckError when the condition evaluates to false.
Definition: check.h:32
wallet::ListDatabases
std::vector< fs::path > ListDatabases(const fs::path &wallet_dir)
Recursively list database paths in directory.
Definition: db.cpp:14
wallet::encryptwallet
RPCHelpMan encryptwallet()
Definition: encrypt.cpp:193
wallet::getbalance
RPCHelpMan getbalance()
Definition: coins.cpp:162
flags
int flags
Definition: bitcoin-tx.cpp:525
key_io.h
wallet::getaddressesbylabel
RPCHelpMan getaddressesbylabel()
Definition: addresses.cpp:651
wallet::DatabaseStatus
DatabaseStatus
Definition: db.h:213
RPCHelpMan
Definition: util.h:345
NullUniValue
const UniValue NullUniValue
Definition: univalue.cpp:13
wallet::fundrawtransaction
RPCHelpMan fundrawtransaction()
Definition: spend.cpp:588
bilingual_str
Bilingual messages:
Definition: translation.h:16
RPC_INVALID_PARAMETER
@ RPC_INVALID_PARAMETER
Invalid, missing or duplicate parameter.
Definition: protocol.h:43
CKey::Set
void Set(const T pbegin, const T pend, bool fCompressedIn)
Initialize using begin and end iterators to byte data.
Definition: key.h:73
RPCArg::Optional::NO
@ NO
Required arg.
wallet::listsinceblock
RPCHelpMan listsinceblock()
Definition: transactions.cpp:560
wallet::getreceivedbyaddress
RPCHelpMan getreceivedbyaddress()
Definition: coins.cpp:80
RPCArg::Type::STR
@ STR
wallet::rescanblockchain
RPCHelpMan rescanblockchain()
Definition: transactions.cpp:851
wallet::dumpwallet
RPCHelpMan dumpwallet()
Definition: backup.cpp:684
wallet::walletdisplayaddress
RPCHelpMan walletdisplayaddress()
Definition: addresses.cpp:765
wallet::LegacyScriptPubKeyMan::DeriveNewSeed
CPubKey DeriveNewSeed(const CKey &key)
Definition: scriptpubkeyman.cpp:1176
wallet::WALLET_FLAG_DESCRIPTORS
@ WALLET_FLAG_DESCRIPTORS
Indicate that this wallet supports DescriptorScriptPubKeyMan.
Definition: walletutil.h:66
SigningProvider
An interface to be implemented by keystores that support signing.
Definition: signingprovider.h:17
wallet::createwallet
static RPCHelpMan createwallet()
Definition: wallet.cpp:305
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::LegacyScriptPubKeyMan::GenerateNewSeed
CPubKey GenerateNewSeed()
Definition: scriptpubkeyman.cpp:1168
RPCResult::Type::NUM
@ NUM
wallet::bumpfee
RPCHelpMan bumpfee()
Definition: spend.cpp:961
wallet::walletpassphrasechange
RPCHelpMan walletpassphrasechange()
Definition: encrypt.cpp:107
wallet::HaveKey
bool HaveKey(const SigningProvider &wallet, const CKey &key)
Checks if a CKey is in the given CWallet compressed or otherwise.
Definition: wallet.cpp:23
wallet
Definition: node.h:38
wallet::importmulti
RPCHelpMan importmulti()
Definition: backup.cpp:1244
wallet::abortrescan
RPCHelpMan abortrescan()
Definition: transactions.cpp:936
wallet::listunspent
RPCHelpMan listunspent()
Definition: coins.cpp:500
CKeyID
A reference to a CKey: the Hash160 of its serialized public key.
Definition: pubkey.h:23
wallet::DatabaseOptions::require_existing
bool require_existing
Definition: db.h:205
core_io.h
wallet
std::shared_ptr< CWallet > wallet
Definition: notifications.cpp:38
UniValue::pushKV
bool pushKV(const std::string &key, const UniValue &val)
Definition: univalue.cpp:133
wallet::walletpassphrase
RPCHelpMan walletpassphrase()
Definition: encrypt.cpp:11
ValueFromAmount
UniValue ValueFromAmount(const CAmount amount)
Definition: core_write.cpp:21
wallet::importpubkey
RPCHelpMan importpubkey()
Definition: backup.cpp:395
UniValue
Definition: univalue.h:17
CKey::end
const unsigned char * end() const
Definition: key.h:90
wallet::WALLET_FLAG_MAP
static const std::map< std::string, WalletFlags > WALLET_FLAG_MAP
Definition: wallet.h:134
wallet::LegacyScriptPubKeyMan::NewKeyPool
bool NewKeyPool()
Mark old keypool keys as used, and generate all new keys.
Definition: scriptpubkeyman.cpp:1223
RPCArg::Type::NUM
@ NUM
wallet::GetWallets
std::vector< std::shared_ptr< CWallet > > GetWallets(WalletContext &context)
Definition: wallet.cpp:148
wallet::abandontransaction
RPCHelpMan abandontransaction()
Definition: transactions.cpp:810
wallet::HELP_REQUIRING_PASSPHRASE
const std::string HELP_REQUIRING_PASSPHRASE
Definition: util.cpp:17
wallet::WALLET_FLAG_EXTERNAL_SIGNER
@ WALLET_FLAG_EXTERNAL_SIGNER
Indicates that the wallet needs an external signer.
Definition: walletutil.h:69
Span
A Span is an object that can refer to a contiguous sequence of objects.
Definition: span.h:96
wallet::DatabaseOptions::require_create
bool require_create
Definition: db.h:206
UniValue::get_str
const std::string & get_str() const
Definition: univalue_get.cpp:98
wallet::walletlock
RPCHelpMan walletlock()
Definition: encrypt.cpp:155
wallet::listreceivedbyaddress
RPCHelpMan listreceivedbyaddress()
Definition: transactions.cpp:228
CKey::begin
const unsigned char * begin() const
Definition: key.h:89
wallet::listlabels
RPCHelpMan listlabels()
Definition: addresses.cpp:709
wallet::importdescriptors
RPCHelpMan importdescriptors()
Definition: backup.cpp:1576
SecureString
std::basic_string< char, std::char_traits< char >, secure_allocator< char > > SecureString
Definition: secure.h:59
getnewaddress
std::string getnewaddress(wallet::CWallet &w)
Returns a new address from the wallet.
wallet::FEATURE_LATEST
@ FEATURE_LATEST
Definition: walletutil.h:30
CURRENCY_UNIT
const std::string CURRENCY_UNIT
Definition: feerate.h:14
util.h
wallet::listaddressgroupings
RPCHelpMan listaddressgroupings()
Definition: addresses.cpp:158
Untranslated
bilingual_str Untranslated(std::string original)
Mark a bilingual_str as untranslated.
Definition: translation.h:46
RPCArg::DefaultHint
std::string DefaultHint
Definition: util.h:155
RPCArg::Optional::OMITTED_NAMED_ARG
@ OMITTED_NAMED_ARG
Optional arg that is a named argument and has a default value of null.
wallet::FEATURE_HD_SPLIT
@ FEATURE_HD_SPLIT
Definition: walletutil.h:24
RPCResult::Type::OBJ
@ OBJ
CRPCCommand
Definition: server.h:89
RPCResult::Type::NONE
@ NONE
wallet::LegacyScriptPubKeyMan
Definition: scriptpubkeyman.h:264
RPC_WALLET_NOT_FOUND
@ RPC_WALLET_NOT_FOUND
Invalid wallet specified.
Definition: protocol.h:80
wallet::WALLET_FLAG_BLANK_WALLET
@ WALLET_FLAG_BLANK_WALLET
Flag set when a wallet contains no HD seed and no private keys, scripts, addresses,...
Definition: walletutil.h:63
wallet::WALLET_FLAG_DISABLE_PRIVATE_KEYS
@ WALLET_FLAG_DISABLE_PRIVATE_KEYS
Definition: walletutil.h:51
univalue.h
RPCResult::Type::STR_HEX
@ STR_HEX
Special string with only hex chars.
CKey::IsValid
bool IsValid() const
Check whether this private key is valid.
Definition: key.h:93
wallet::GetWallet
std::shared_ptr< CWallet > GetWallet(WalletContext &context, const std::string &name)
Definition: wallet.cpp:154
wallet::GetWalletRPCCommands
Span< const CRPCCommand > GetWalletRPCCommands()
Definition: wallet.cpp:657
wallet::listwalletdir
static RPCHelpMan listwalletdir()
Definition: wallet.cpp:125
RPC_WALLET_ENCRYPTION_FAILED
@ RPC_WALLET_ENCRYPTION_FAILED
Failed to encrypt the wallet.
Definition: protocol.h:78
base_blob::GetHex
std::string GetHex() const
Definition: uint256.cpp:20
RPCExamples
Definition: util.h:335
context
WalletContext context
Definition: notifications.cpp:37
wallet::getaddressinfo
RPCHelpMan getaddressinfo()
Definition: addresses.cpp:496
wallet::WALLET_FLAG_AVOID_REUSE
@ WALLET_FLAG_AVOID_REUSE
Definition: walletutil.h:42
wallet::CreateWallet
std::shared_ptr< CWallet > CreateWallet(WalletContext &context, const std::string &name, std::optional< bool > load_on_start, DatabaseOptions &options, DatabaseStatus &status, bilingual_str &error, std::vector< bilingual_str > &warnings)
Definition: wallet.cpp:263
wallet::HandleWalletError
void HandleWalletError(const std::shared_ptr< CWallet > wallet, DatabaseStatus &status, bilingual_str &error)
Definition: util.cpp:126
RPC_WALLET_ERROR
@ RPC_WALLET_ERROR
Wallet errors.
Definition: protocol.h:71
wallet::getbalances
RPCHelpMan getbalances()
Definition: coins.cpp:433
RPCResult::Type::STR
@ STR
DecodeSecret
CKey DecodeSecret(const std::string &str)
Definition: key_io.cpp:198
wallet::importprunedfunds
RPCHelpMan importprunedfunds()
Definition: backup.cpp:301
RPCResult::Type::NUM_TIME
@ NUM_TIME
Special numeric to denote unix epoch time.
wallet::restorewallet
RPCHelpMan restorewallet()
Definition: backup.cpp:1853
RPCResult::Type::ARR
@ ARR
wallet::CHDChain::seed_id
CKeyID seed_id
seed hash160
Definition: walletdb.h:94
CKey::GetPubKey
CPubKey GetPubKey() const
Compute the public key from a private key.
Definition: key.cpp:187
wallet::gettransaction
RPCHelpMan gettransaction()
Definition: transactions.cpp:699
HelpExampleRpc
std::string HelpExampleRpc(const std::string &methodname, const std::string &args)
Definition: util.cpp:174
wallet::listlockunspent
RPCHelpMan listlockunspent()
Definition: coins.cpp:380
HelpExampleRpcNamed
std::string HelpExampleRpcNamed(const std::string &methodname, const RPCArgList &args)
Definition: util.cpp:180
wallet::signrawtransactionwithwallet
RPCHelpMan signrawtransactionwithwallet()
Definition: spend.cpp:690
wallet::sendtoaddress
RPCHelpMan sendtoaddress()
Definition: spend.cpp:124
wallet::getreceivedbylabel
RPCHelpMan getreceivedbylabel()
Definition: coins.cpp:121
importaddress
void importaddress(wallet::CWallet &wallet, const std::string &address)
Import the address to the wallet.
wallet::walletprocesspsbt
RPCHelpMan walletprocesspsbt()
Definition: spend.cpp:1162
wallet::FEATURE_HD
@ FEATURE_HD
Definition: walletutil.h:22
RPC_INVALID_ADDRESS_OR_KEY
@ RPC_INVALID_ADDRESS_OR_KEY
Invalid address or key.
Definition: protocol.h:41
wallet::LegacyScriptPubKeyMan::GetHDChain
const CHDChain & GetHDChain() const
Definition: scriptpubkeyman.h:435
name
const char * name
Definition: rest.cpp:52
strprintf
#define strprintf
Format arguments and return the string or write to given std::ostream (see tinyformat::format doc for...
Definition: tinyformat.h:1164
Join
auto Join(const std::vector< T > &list, const BaseType &separator, UnaryOp unary_op) -> decltype(unary_op(list.at(0)))
Join a list of items.
Definition: string.h:44
wallet::loadwallet
static RPCHelpMan loadwallet()
Definition: wallet.cpp:193
CPubKey
An encapsulated public key.
Definition: pubkey.h:33
base_blob::IsNull
bool IsNull() const
Definition: uint256.h:31
wallet::removeprunedfunds
RPCHelpMan removeprunedfunds()
Definition: backup.cpp:357
wallet::upgradewallet
static RPCHelpMan upgradewallet()
Definition: wallet.cpp:522
wallet::unloadwallet
static RPCHelpMan unloadwallet()
Definition: wallet.cpp:400
wallet::MUTABLE_WALLET_FLAGS
static constexpr uint64_t MUTABLE_WALLET_FLAGS
Definition: wallet.h:131
RPCResult::Type::BOOL
@ BOOL
CKey
An encapsulated private key.
Definition: key.h:26
wallet::setwalletflag
static RPCHelpMan setwalletflag()
Definition: wallet.cpp:238
translation.h
RPCTypeCheck
void RPCTypeCheck(const UniValue &params, const std::list< UniValueType > &typesExpected, bool fAllowNull)
Type-check arguments; throws JSONRPCError if wrong type given.
Definition: util.cpp:24
wallet::LoadWallet
std::shared_ptr< CWallet > LoadWallet(WalletContext &context, const std::string &name, std::optional< bool > load_on_start, const DatabaseOptions &options, DatabaseStatus &status, bilingual_str &error, std::vector< bilingual_str > &warnings)
Definition: wallet.cpp:250
JSONRPCError
UniValue JSONRPCError(int code, const std::string &message)
Definition: request.cpp:51
LOCK
#define LOCK(cs)
Definition: sync.h:226
RPCErrorCode
RPCErrorCode
Bitcoin RPC error codes.
Definition: protocol.h:23
wallet::listwallets
static RPCHelpMan listwallets()
Definition: wallet.cpp:162
wallet::GetWalletDir
fs::path GetWalletDir()
Get the path of the wallet directory.
Definition: walletutil.cpp:11
RPCArg::Type::BOOL
@ BOOL
wallet::importwallet
RPCHelpMan importwallet()
Definition: backup.cpp:481
UniValue::push_back
bool push_back(const UniValue &val)
Definition: univalue.cpp:108
wallet::getrawchangeaddress
RPCHelpMan getrawchangeaddress()
Definition: addresses.cpp:72
wallet::GetWalletNameFromJSONRPCRequest
bool GetWalletNameFromJSONRPCRequest(const JSONRPCRequest &request, std::string &wallet_name)
Definition: util.cpp:45
wallet::GetBalance
Balance GetBalance(const CWallet &wallet, const int min_depth, bool avoid_reuse)
Definition: receive.cpp:318
wallet::addmultisigaddress
RPCHelpMan addmultisigaddress()
Definition: addresses.cpp:218
wallet::LegacyScriptPubKeyMan::SetHDSeed
void SetHDSeed(const CPubKey &key)
Definition: scriptpubkeyman.cpp:1204
wallet::settxfee
RPCHelpMan settxfee()
Definition: spend.cpp:319
receive.h
wallet::send
RPCHelpMan send()
Definition: spend.cpp:964
JSONRPCRequest
Definition: request.h:28
wallet::psbtbumpfee
RPCHelpMan psbtbumpfee()
Definition: spend.cpp:962
RPCResult
Definition: util.h:231
wallet::lockunspent
RPCHelpMan lockunspent()
Definition: coins.cpp:240
HelpExampleCliNamed
std::string HelpExampleCliNamed(const std::string &methodname, const RPCArgList &args)
Definition: util.cpp:161
wallet::listreceivedbylabel
RPCHelpMan listreceivedbylabel()
Definition: transactions.cpp:281
wallet::WalletContext
WalletContext struct containing references to state shared between CWallet instances,...
Definition: context.h:35
wallet::getunconfirmedbalance
RPCHelpMan getunconfirmedbalance()
Definition: coins.cpp:217
FillableSigningProvider::cs_KeyStore
RecursiveMutex cs_KeyStore
Definition: signingprovider.h:148
wallet::WALLET_FLAG_CAVEATS
const std::map< uint64_t, std::string > WALLET_FLAG_CAVEATS
Definition: wallet.cpp:52
wallet::UnloadWallet
void UnloadWallet(std::shared_ptr< CWallet > &&wallet)
Explicitly unload and delete the wallet.
Definition: wallet.cpp:194
error
bool error(const char *fmt, const Args &... args)
Definition: system.h:49
wallet::dumpprivkey
RPCHelpMan dumpprivkey()
Definition: backup.cpp:638
wallet::newkeypool
RPCHelpMan newkeypool()
Definition: addresses.cpp:360
RPCResult::Type::STR_AMOUNT
@ STR_AMOUNT
Special string to represent a floating point amount.
UniValue::VARR
@ VARR
Definition: univalue.h:19
wallet::listdescriptors
RPCHelpMan listdescriptors()
Definition: backup.cpp:1733
wallet::DatabaseOptions::create_passphrase
SecureString create_passphrase
Definition: db.h:209
wallet::getwalletinfo
static RPCHelpMan getwalletinfo()
Definition: wallet.cpp:30
server.h
wallet::EnsureLegacyScriptPubKeyMan
LegacyScriptPubKeyMan & EnsureLegacyScriptPubKeyMan(CWallet &wallet, bool also_create)
Definition: util.cpp:97
wallet::DatabaseOptions
Definition: db.h:204
wallet::signmessage
RPCHelpMan signmessage()
Definition: signmessage.cpp:14
wallet::sendmany
RPCHelpMan sendmany()
Definition: spend.cpp:226
wallet::DatabaseOptions::create_flags
uint64_t create_flags
Definition: db.h:208
wallet::importprivkey
RPCHelpMan importprivkey()
Definition: backup.cpp:95
wallet.h
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
CPubKey::GetID
CKeyID GetID() const
Get the KeyID of this public key (hash of its serialization)
Definition: pubkey.h:164
wallet::EnsureWalletIsUnlocked
void EnsureWalletIsUnlocked(const CWallet &wallet)
Definition: util.cpp:80
wallet::EnsureWalletContext
WalletContext & EnsureWalletContext(const std::any &context)
Definition: util.cpp:87
wallet::setlabel
RPCHelpMan setlabel()
Definition: addresses.cpp:120
wallet::RemoveWallet
bool RemoveWallet(WalletContext &context, const std::shared_ptr< CWallet > &wallet, std::optional< bool > load_on_start)
Definition: wallet.cpp:142