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  {RPCResult::Type::BOOL, "external_signer", "whether this wallet is configured to use an external signer such as a hardware wallet"},
61  }},
62  },
64  HelpExampleCli("getwalletinfo", "")
65  + HelpExampleRpc("getwalletinfo", "")
66  },
67  [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
68 {
69  const std::shared_ptr<const CWallet> pwallet = GetWalletForJSONRPCRequest(request);
70  if (!pwallet) return NullUniValue;
71 
72  // Make sure the results are valid at least up to the most recent block
73  // the user could have gotten from another RPC command prior to now
74  pwallet->BlockUntilSyncedToCurrentChain();
75 
76  LOCK(pwallet->cs_wallet);
77 
79 
80  size_t kpExternalSize = pwallet->KeypoolCountExternalKeys();
81  const auto bal = GetBalance(*pwallet);
82  obj.pushKV("walletname", pwallet->GetName());
83  obj.pushKV("walletversion", pwallet->GetVersion());
84  obj.pushKV("format", pwallet->GetDatabase().Format());
85  obj.pushKV("balance", ValueFromAmount(bal.m_mine_trusted));
86  obj.pushKV("unconfirmed_balance", ValueFromAmount(bal.m_mine_untrusted_pending));
87  obj.pushKV("immature_balance", ValueFromAmount(bal.m_mine_immature));
88  obj.pushKV("txcount", (int)pwallet->mapWallet.size());
89  const auto kp_oldest = pwallet->GetOldestKeyPoolTime();
90  if (kp_oldest.has_value()) {
91  obj.pushKV("keypoololdest", kp_oldest.value());
92  }
93  obj.pushKV("keypoolsize", (int64_t)kpExternalSize);
94 
95  LegacyScriptPubKeyMan* spk_man = pwallet->GetLegacyScriptPubKeyMan();
96  if (spk_man) {
97  CKeyID seed_id = spk_man->GetHDChain().seed_id;
98  if (!seed_id.IsNull()) {
99  obj.pushKV("hdseedid", seed_id.GetHex());
100  }
101  }
102 
103  if (pwallet->CanSupportFeature(FEATURE_HD_SPLIT)) {
104  obj.pushKV("keypoolsize_hd_internal", (int64_t)(pwallet->GetKeyPoolSize() - kpExternalSize));
105  }
106  if (pwallet->IsCrypted()) {
107  obj.pushKV("unlocked_until", pwallet->nRelockTime);
108  }
109  obj.pushKV("paytxfee", ValueFromAmount(pwallet->m_pay_tx_fee.GetFeePerK()));
110  obj.pushKV("private_keys_enabled", !pwallet->IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS));
111  obj.pushKV("avoid_reuse", pwallet->IsWalletFlagSet(WALLET_FLAG_AVOID_REUSE));
112  if (pwallet->IsScanning()) {
113  UniValue scanning(UniValue::VOBJ);
114  scanning.pushKV("duration", pwallet->ScanningDuration() / 1000);
115  scanning.pushKV("progress", pwallet->ScanningProgress());
116  obj.pushKV("scanning", scanning);
117  } else {
118  obj.pushKV("scanning", false);
119  }
120  obj.pushKV("descriptors", pwallet->IsWalletFlagSet(WALLET_FLAG_DESCRIPTORS));
121  obj.pushKV("external_signer", pwallet->IsWalletFlagSet(WALLET_FLAG_EXTERNAL_SIGNER));
122  return obj;
123 },
124  };
125 }
126 
128 {
129  return RPCHelpMan{"listwalletdir",
130  "Returns a list of wallets in the wallet directory.\n",
131  {},
132  RPCResult{
133  RPCResult::Type::OBJ, "", "",
134  {
135  {RPCResult::Type::ARR, "wallets", "",
136  {
137  {RPCResult::Type::OBJ, "", "",
138  {
139  {RPCResult::Type::STR, "name", "The wallet name"},
140  }},
141  }},
142  }
143  },
144  RPCExamples{
145  HelpExampleCli("listwalletdir", "")
146  + HelpExampleRpc("listwalletdir", "")
147  },
148  [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
149 {
150  UniValue wallets(UniValue::VARR);
151  for (const auto& path : ListDatabases(GetWalletDir())) {
153  wallet.pushKV("name", path.u8string());
154  wallets.push_back(wallet);
155  }
156 
157  UniValue result(UniValue::VOBJ);
158  result.pushKV("wallets", wallets);
159  return result;
160 },
161  };
162 }
163 
165 {
166  return RPCHelpMan{"listwallets",
167  "Returns a list of currently loaded wallets.\n"
168  "For full information on the wallet, use \"getwalletinfo\"\n",
169  {},
170  RPCResult{
171  RPCResult::Type::ARR, "", "",
172  {
173  {RPCResult::Type::STR, "walletname", "the wallet name"},
174  }
175  },
176  RPCExamples{
177  HelpExampleCli("listwallets", "")
178  + HelpExampleRpc("listwallets", "")
179  },
180  [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
181 {
183 
184  WalletContext& context = EnsureWalletContext(request.context);
185  for (const std::shared_ptr<CWallet>& wallet : GetWallets(context)) {
186  LOCK(wallet->cs_wallet);
187  obj.push_back(wallet->GetName());
188  }
189 
190  return obj;
191 },
192  };
193 }
194 
196 {
197  return RPCHelpMan{"loadwallet",
198  "\nLoads a wallet from a wallet file or directory."
199  "\nNote that all wallet command-line options used when starting bitcoind will be"
200  "\napplied to the new wallet.\n",
201  {
202  {"filename", RPCArg::Type::STR, RPCArg::Optional::NO, "The wallet directory or .dat file."},
203  {"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."},
204  },
205  RPCResult{
206  RPCResult::Type::OBJ, "", "",
207  {
208  {RPCResult::Type::STR, "name", "The wallet name if loaded successfully."},
209  {RPCResult::Type::STR, "warning", "Warning message if wallet was not loaded cleanly."},
210  }
211  },
212  RPCExamples{
213  HelpExampleCli("loadwallet", "\"test.dat\"")
214  + HelpExampleRpc("loadwallet", "\"test.dat\"")
215  },
216  [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
217 {
218  WalletContext& context = EnsureWalletContext(request.context);
219  const std::string name(request.params[0].get_str());
220 
221  DatabaseOptions options;
222  DatabaseStatus status;
223  options.require_existing = true;
225  std::vector<bilingual_str> warnings;
226  std::optional<bool> load_on_start = request.params[1].isNull() ? std::nullopt : std::optional<bool>(request.params[1].get_bool());
227  std::shared_ptr<CWallet> const wallet = LoadWallet(context, name, load_on_start, options, status, error, warnings);
228 
229  HandleWalletError(wallet, status, error);
230 
232  obj.pushKV("name", wallet->GetName());
233  obj.pushKV("warning", Join(warnings, Untranslated("\n")).original);
234 
235  return obj;
236 },
237  };
238 }
239 
241 {
242  std::string flags = "";
243  for (auto& it : WALLET_FLAG_MAP)
244  if (it.second & MUTABLE_WALLET_FLAGS)
245  flags += (flags == "" ? "" : ", ") + it.first;
246 
247  return RPCHelpMan{"setwalletflag",
248  "\nChange the state of the given wallet flag for a wallet.\n",
249  {
250  {"flag", RPCArg::Type::STR, RPCArg::Optional::NO, "The name of the flag to change. Current available flags: " + flags},
251  {"value", RPCArg::Type::BOOL, RPCArg::Default{true}, "The new state."},
252  },
253  RPCResult{
254  RPCResult::Type::OBJ, "", "",
255  {
256  {RPCResult::Type::STR, "flag_name", "The name of the flag that was modified"},
257  {RPCResult::Type::BOOL, "flag_state", "The new state of the flag"},
258  {RPCResult::Type::STR, "warnings", "Any warnings associated with the change"},
259  }
260  },
261  RPCExamples{
262  HelpExampleCli("setwalletflag", "avoid_reuse")
263  + HelpExampleRpc("setwalletflag", "\"avoid_reuse\"")
264  },
265  [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
266 {
267  std::shared_ptr<CWallet> const pwallet = GetWalletForJSONRPCRequest(request);
268  if (!pwallet) return NullUniValue;
269 
270  std::string flag_str = request.params[0].get_str();
271  bool value = request.params[1].isNull() || request.params[1].get_bool();
272 
273  if (!WALLET_FLAG_MAP.count(flag_str)) {
274  throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Unknown wallet flag: %s", flag_str));
275  }
276 
277  auto flag = WALLET_FLAG_MAP.at(flag_str);
278 
279  if (!(flag & MUTABLE_WALLET_FLAGS)) {
280  throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Wallet flag is immutable: %s", flag_str));
281  }
282 
284 
285  if (pwallet->IsWalletFlagSet(flag) == value) {
286  throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Wallet flag is already set to %s: %s", value ? "true" : "false", flag_str));
287  }
288 
289  res.pushKV("flag_name", flag_str);
290  res.pushKV("flag_state", value);
291 
292  if (value) {
293  pwallet->SetWalletFlag(flag);
294  } else {
295  pwallet->UnsetWalletFlag(flag);
296  }
297 
298  if (flag && value && WALLET_FLAG_CAVEATS.count(flag)) {
299  res.pushKV("warnings", WALLET_FLAG_CAVEATS.at(flag));
300  }
301 
302  return res;
303 },
304  };
305 }
306 
308 {
309  return RPCHelpMan{
310  "createwallet",
311  "\nCreates and loads a new wallet.\n",
312  {
313  {"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."},
314  {"disable_private_keys", RPCArg::Type::BOOL, RPCArg::Default{false}, "Disable the possibility of private keys (only watchonlys are possible in this mode)."},
315  {"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."},
316  {"passphrase", RPCArg::Type::STR, RPCArg::Optional::OMITTED_NAMED_ARG, "Encrypt the wallet with this passphrase."},
317  {"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."},
318  {"descriptors", RPCArg::Type::BOOL, RPCArg::Default{true}, "Create a native descriptor wallet. The wallet will use descriptors internally to handle address creation"},
319  {"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."},
320  {"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."},
321  },
322  RPCResult{
323  RPCResult::Type::OBJ, "", "",
324  {
325  {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."},
326  {RPCResult::Type::STR, "warning", "Warning message if wallet was not loaded cleanly."},
327  }
328  },
329  RPCExamples{
330  HelpExampleCli("createwallet", "\"testwallet\"")
331  + HelpExampleRpc("createwallet", "\"testwallet\"")
332  + HelpExampleCliNamed("createwallet", {{"wallet_name", "descriptors"}, {"avoid_reuse", true}, {"descriptors", true}, {"load_on_startup", true}})
333  + HelpExampleRpcNamed("createwallet", {{"wallet_name", "descriptors"}, {"avoid_reuse", true}, {"descriptors", true}, {"load_on_startup", true}})
334  },
335  [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
336 {
337  WalletContext& context = EnsureWalletContext(request.context);
338  uint64_t flags = 0;
339  if (!request.params[1].isNull() && request.params[1].get_bool()) {
341  }
342 
343  if (!request.params[2].isNull() && request.params[2].get_bool()) {
345  }
346  SecureString passphrase;
347  passphrase.reserve(100);
348  std::vector<bilingual_str> warnings;
349  if (!request.params[3].isNull()) {
350  passphrase = request.params[3].get_str().c_str();
351  if (passphrase.empty()) {
352  // Empty string means unencrypted
353  warnings.emplace_back(Untranslated("Empty string given as passphrase, wallet will not be encrypted."));
354  }
355  }
356 
357  if (!request.params[4].isNull() && request.params[4].get_bool()) {
359  }
360  if (request.params[5].isNull() || request.params[5].get_bool()) {
361 #ifndef USE_SQLITE
362  throw JSONRPCError(RPC_WALLET_ERROR, "Compiled without sqlite support (required for descriptor wallets)");
363 #endif
365  }
366  if (!request.params[7].isNull() && request.params[7].get_bool()) {
367 #ifdef ENABLE_EXTERNAL_SIGNER
369 #else
370  throw JSONRPCError(RPC_WALLET_ERROR, "Compiled without external signing support (required for external signing)");
371 #endif
372  }
373 
374 #ifndef USE_BDB
375  if (!(flags & WALLET_FLAG_DESCRIPTORS)) {
376  throw JSONRPCError(RPC_WALLET_ERROR, "Compiled without bdb support (required for legacy wallets)");
377  }
378 #endif
379 
380  DatabaseOptions options;
381  DatabaseStatus status;
382  options.require_create = true;
383  options.create_flags = flags;
384  options.create_passphrase = passphrase;
386  std::optional<bool> load_on_start = request.params[6].isNull() ? std::nullopt : std::optional<bool>(request.params[6].get_bool());
387  const std::shared_ptr<CWallet> wallet = CreateWallet(context, request.params[0].get_str(), load_on_start, options, status, error, warnings);
388  if (!wallet) {
389  RPCErrorCode code = status == DatabaseStatus::FAILED_ENCRYPT ? RPC_WALLET_ENCRYPTION_FAILED : RPC_WALLET_ERROR;
390  throw JSONRPCError(code, error.original);
391  }
392 
394  obj.pushKV("name", wallet->GetName());
395  obj.pushKV("warning", Join(warnings, Untranslated("\n")).original);
396 
397  return obj;
398 },
399  };
400 }
401 
403 {
404  return RPCHelpMan{"unloadwallet",
405  "Unloads the wallet referenced by the request endpoint otherwise unloads the wallet specified in the argument.\n"
406  "Specifying the wallet name on a wallet endpoint is invalid.",
407  {
408  {"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."},
409  {"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."},
410  },
412  {RPCResult::Type::STR, "warning", "Warning message if wallet was not unloaded cleanly."},
413  }},
414  RPCExamples{
415  HelpExampleCli("unloadwallet", "wallet_name")
416  + HelpExampleRpc("unloadwallet", "wallet_name")
417  },
418  [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
419 {
420  std::string wallet_name;
421  if (GetWalletNameFromJSONRPCRequest(request, wallet_name)) {
422  if (!(request.params[0].isNull() || request.params[0].get_str() == wallet_name)) {
423  throw JSONRPCError(RPC_INVALID_PARAMETER, "RPC endpoint wallet and wallet_name parameter specify different wallets");
424  }
425  } else {
426  wallet_name = request.params[0].get_str();
427  }
428 
429  WalletContext& context = EnsureWalletContext(request.context);
430  std::shared_ptr<CWallet> wallet = GetWallet(context, wallet_name);
431  if (!wallet) {
432  throw JSONRPCError(RPC_WALLET_NOT_FOUND, "Requested wallet does not exist or is not loaded");
433  }
434 
435  // Release the "main" shared pointer and prevent further notifications.
436  // Note that any attempt to load the same wallet would fail until the wallet
437  // is destroyed (see CheckUniqueFileid).
438  std::vector<bilingual_str> warnings;
439  std::optional<bool> load_on_start = request.params[1].isNull() ? std::nullopt : std::optional<bool>(request.params[1].get_bool());
440  if (!RemoveWallet(context, wallet, load_on_start, warnings)) {
441  throw JSONRPCError(RPC_MISC_ERROR, "Requested wallet already unloaded");
442  }
443 
444  UnloadWallet(std::move(wallet));
445 
446  UniValue result(UniValue::VOBJ);
447  result.pushKV("warning", Join(warnings, Untranslated("\n")).original);
448  return result;
449 },
450  };
451 }
452 
454 {
455  return RPCHelpMan{"sethdseed",
456  "\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"
457  "HD will have a new HD seed set so that new keys added to the keypool will be derived from this new seed.\n"
458  "\nNote that you will need to MAKE A NEW BACKUP of your wallet after setting the HD wallet seed." +
460  {
461  {"newkeypool", RPCArg::Type::BOOL, RPCArg::Default{true}, "Whether to flush old unused addresses, including change addresses, from the keypool and regenerate it.\n"
462  "If true, the next address from getnewaddress and change address from getrawchangeaddress will be from this new seed.\n"
463  "If false, addresses (including change addresses if the wallet already had HD Chain Split enabled) from the existing\n"
464  "keypool will be used until it has been depleted."},
465  {"seed", RPCArg::Type::STR, RPCArg::DefaultHint{"random seed"}, "The WIF private key to use as the new HD seed.\n"
466  "The seed value can be retrieved using the dumpwallet command. It is the private key marked hdseed=1"},
467  },
469  RPCExamples{
470  HelpExampleCli("sethdseed", "")
471  + HelpExampleCli("sethdseed", "false")
472  + HelpExampleCli("sethdseed", "true \"wifkey\"")
473  + HelpExampleRpc("sethdseed", "true, \"wifkey\"")
474  },
475  [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
476 {
477  std::shared_ptr<CWallet> const pwallet = GetWalletForJSONRPCRequest(request);
478  if (!pwallet) return NullUniValue;
479 
480  LegacyScriptPubKeyMan& spk_man = EnsureLegacyScriptPubKeyMan(*pwallet, true);
481 
482  if (pwallet->IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS)) {
483  throw JSONRPCError(RPC_WALLET_ERROR, "Cannot set a HD seed to a wallet with private keys disabled");
484  }
485 
486  LOCK2(pwallet->cs_wallet, spk_man.cs_KeyStore);
487 
488  // Do not do anything to non-HD wallets
489  if (!pwallet->CanSupportFeature(FEATURE_HD)) {
490  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");
491  }
492 
493  EnsureWalletIsUnlocked(*pwallet);
494 
495  bool flush_key_pool = true;
496  if (!request.params[0].isNull()) {
497  flush_key_pool = request.params[0].get_bool();
498  }
499 
500  CPubKey master_pub_key;
501  if (request.params[1].isNull()) {
502  master_pub_key = spk_man.GenerateNewSeed();
503  } else {
504  CKey key = DecodeSecret(request.params[1].get_str());
505  if (!key.IsValid()) {
506  throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid private key");
507  }
508 
509  if (HaveKey(spk_man, key)) {
510  throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Already have this key (either as an HD seed or as a loose private key)");
511  }
512 
513  master_pub_key = spk_man.DeriveNewSeed(key);
514  }
515 
516  spk_man.SetHDSeed(master_pub_key);
517  if (flush_key_pool) spk_man.NewKeyPool();
518 
519  return NullUniValue;
520 },
521  };
522 }
523 
525 {
526  return RPCHelpMan{"upgradewallet",
527  "\nUpgrade the wallet. Upgrades to the latest version if no version number is specified.\n"
528  "New keys may be generated and a new wallet backup will need to be made.",
529  {
530  {"version", RPCArg::Type::NUM, RPCArg::Default{FEATURE_LATEST}, "The version number to upgrade to. Default is the latest wallet version."}
531  },
532  RPCResult{
533  RPCResult::Type::OBJ, "", "",
534  {
535  {RPCResult::Type::STR, "wallet_name", "Name of wallet this operation was performed on"},
536  {RPCResult::Type::NUM, "previous_version", "Version of wallet before this operation"},
537  {RPCResult::Type::NUM, "current_version", "Version of wallet after this operation"},
538  {RPCResult::Type::STR, "result", /*optional=*/true, "Description of result, if no error"},
539  {RPCResult::Type::STR, "error", /*optional=*/true, "Error message (if there is one)"}
540  },
541  },
542  RPCExamples{
543  HelpExampleCli("upgradewallet", "169900")
544  + HelpExampleRpc("upgradewallet", "169900")
545  },
546  [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
547 {
548  std::shared_ptr<CWallet> const pwallet = GetWalletForJSONRPCRequest(request);
549  if (!pwallet) return NullUniValue;
550 
551  RPCTypeCheck(request.params, {UniValue::VNUM}, true);
552 
553  EnsureWalletIsUnlocked(*pwallet);
554 
555  int version = 0;
556  if (!request.params[0].isNull()) {
557  version = request.params[0].get_int();
558  }
560  const int previous_version{pwallet->GetVersion()};
561  const bool wallet_upgraded{pwallet->UpgradeWallet(version, error)};
562  const int current_version{pwallet->GetVersion()};
563  std::string result;
564 
565  if (wallet_upgraded) {
566  if (previous_version == current_version) {
567  result = "Already at latest version. Wallet version unchanged.";
568  } else {
569  result = strprintf("Wallet upgraded successfully from version %i to version %i.", previous_version, current_version);
570  }
571  }
572 
574  obj.pushKV("wallet_name", pwallet->GetName());
575  obj.pushKV("previous_version", previous_version);
576  obj.pushKV("current_version", current_version);
577  if (!result.empty()) {
578  obj.pushKV("result", result);
579  } else {
580  CHECK_NONFATAL(!error.empty());
581  obj.pushKV("error", error.original);
582  }
583  return obj;
584 },
585  };
586 }
587 
588 // addresses
599 #ifdef ENABLE_EXTERNAL_SIGNER
601 #endif // ENABLE_EXTERNAL_SIGNER
602 
603 // backup
617 
618 // coins
627 
628 // encryption
633 
634 // spend
641 RPCHelpMan send();
645 
646 // signmessage
648 
649 // transactions
658 
660 {
661 // clang-format off
662 static const CRPCCommand commands[] =
663 { // category actor (function)
664  // ------------------ ------------------------
665  { "rawtransactions", &fundrawtransaction, },
666  { "wallet", &abandontransaction, },
667  { "wallet", &abortrescan, },
668  { "wallet", &addmultisigaddress, },
669  { "wallet", &backupwallet, },
670  { "wallet", &bumpfee, },
671  { "wallet", &psbtbumpfee, },
672  { "wallet", &createwallet, },
673  { "wallet", &restorewallet, },
674  { "wallet", &dumpprivkey, },
675  { "wallet", &dumpwallet, },
676  { "wallet", &encryptwallet, },
677  { "wallet", &getaddressesbylabel, },
678  { "wallet", &getaddressinfo, },
679  { "wallet", &getbalance, },
680  { "wallet", &getnewaddress, },
681  { "wallet", &getrawchangeaddress, },
682  { "wallet", &getreceivedbyaddress, },
683  { "wallet", &getreceivedbylabel, },
684  { "wallet", &gettransaction, },
685  { "wallet", &getunconfirmedbalance, },
686  { "wallet", &getbalances, },
687  { "wallet", &getwalletinfo, },
688  { "wallet", &importaddress, },
689  { "wallet", &importdescriptors, },
690  { "wallet", &importmulti, },
691  { "wallet", &importprivkey, },
692  { "wallet", &importprunedfunds, },
693  { "wallet", &importpubkey, },
694  { "wallet", &importwallet, },
695  { "wallet", &keypoolrefill, },
696  { "wallet", &listaddressgroupings, },
697  { "wallet", &listdescriptors, },
698  { "wallet", &listlabels, },
699  { "wallet", &listlockunspent, },
700  { "wallet", &listreceivedbyaddress, },
701  { "wallet", &listreceivedbylabel, },
702  { "wallet", &listsinceblock, },
703  { "wallet", &listtransactions, },
704  { "wallet", &listunspent, },
705  { "wallet", &listwalletdir, },
706  { "wallet", &listwallets, },
707  { "wallet", &loadwallet, },
708  { "wallet", &lockunspent, },
709  { "wallet", &newkeypool, },
710  { "wallet", &removeprunedfunds, },
711  { "wallet", &rescanblockchain, },
712  { "wallet", &send, },
713  { "wallet", &sendmany, },
714  { "wallet", &sendtoaddress, },
715  { "wallet", &sethdseed, },
716  { "wallet", &setlabel, },
717  { "wallet", &settxfee, },
718  { "wallet", &setwalletflag, },
719  { "wallet", &signmessage, },
720  { "wallet", &signrawtransactionwithwallet, },
721  { "wallet", &unloadwallet, },
722  { "wallet", &upgradewallet, },
723  { "wallet", &walletcreatefundedpsbt, },
724 #ifdef ENABLE_EXTERNAL_SIGNER
725  { "wallet", &walletdisplayaddress, },
726 #endif // ENABLE_EXTERNAL_SIGNER
727  { "wallet", &walletlock, },
728  { "wallet", &walletpassphrase, },
729  { "wallet", &walletpassphrasechange, },
730  { "wallet", &walletprocesspsbt, },
731 };
732 // clang-format on
733  return commands;
734 }
735 } // 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:1305
wallet::backupwallet
RPCHelpMan backupwallet()
Definition: backup.cpp:1822
wallet::sethdseed
static RPCHelpMan sethdseed()
Definition: wallet.cpp:453
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:18
wallet::encryptwallet
RPCHelpMan encryptwallet()
Definition: encrypt.cpp:193
wallet::getbalance
RPCHelpMan getbalance()
Definition: coins.cpp:162
flags
int flags
Definition: bitcoin-tx.cpp:529
key_io.h
wallet::getaddressesbylabel
RPCHelpMan getaddressesbylabel()
Definition: addresses.cpp:651
wallet::DatabaseStatus
DatabaseStatus
Definition: db.h:213
RPCHelpMan
Definition: util.h:346
NullUniValue
const UniValue NullUniValue
Definition: univalue.cpp:13
wallet::fundrawtransaction
RPCHelpMan fundrawtransaction()
Definition: spend.cpp:638
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:687
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:307
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:1022
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:1247
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:22
wallet::importpubkey
RPCHelpMan importpubkey()
Definition: backup.cpp:398
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:1579
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:659
wallet::listwalletdir
static RPCHelpMan listwalletdir()
Definition: wallet.cpp:127
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:336
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:304
RPCResult::Type::NUM_TIME
@ NUM_TIME
Special numeric to denote unix epoch time.
wallet::restorewallet
RPCHelpMan restorewallet()
Definition: backup.cpp:1856
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:751
wallet::sendtoaddress
RPCHelpMan sendtoaddress()
Definition: spend.cpp:125
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:1229
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:195
CPubKey
An encapsulated public key.
Definition: pubkey.h:33
base_blob::IsNull
bool IsNull() const
Definition: uint256.h:33
wallet::removeprunedfunds
RPCHelpMan removeprunedfunds()
Definition: backup.cpp:360
wallet::upgradewallet
static RPCHelpMan upgradewallet()
Definition: wallet.cpp:524
wallet::unloadwallet
static RPCHelpMan unloadwallet()
Definition: wallet.cpp:402
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:240
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:56
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:164
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:484
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:316
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:320
receive.h
wallet::send
RPCHelpMan send()
Definition: spend.cpp:1025
JSONRPCRequest
Definition: request.h:28
wallet::psbtbumpfee
RPCHelpMan psbtbumpfee()
Definition: spend.cpp:1023
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:641
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:1736
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:227
wallet::DatabaseOptions::create_flags
uint64_t create_flags
Definition: db.h:208
wallet::importprivkey
RPCHelpMan importprivkey()
Definition: backup.cpp:98
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