9#include <chainparams.h>
53 "You need to rescan the blockchain in order to correctly mark used "
54 "destinations in the past. Until this is done, some destinations may "
55 "be considered unused, even if the opposite is the case."},
59 const std::string &wallet_name) {
65 if (value.isStr() && value.get_str() == wallet_name) {
74 const std::string &wallet_name) {
81 if (!value.isStr() || value.get_str() != wallet_name) {
85 if (new_value.
size() == setting_value.
size()) {
92 const std::string &wallet_name,
93 std::optional<bool> load_on_startup,
94 std::vector<bilingual_str> &warnings) {
95 if (!load_on_startup) {
99 warnings.emplace_back(
100 Untranslated(
"Wallet load on startup setting could not be updated, "
101 "so wallet may not be loaded next node startup."));
102 }
else if (!load_on_startup.value() &&
104 warnings.emplace_back(
105 Untranslated(
"Wallet load on startup setting could not be updated, "
106 "so wallet may still be loaded next node startup."));
113 std::vector<std::shared_ptr<CWallet>>::const_iterator i =
114 std::find(context.wallets.begin(), context.wallets.end(),
wallet);
115 if (i != context.wallets.end()) {
118 context.wallets.push_back(
wallet);
119 wallet->ConnectScriptPubKeyManNotifiers();
120 wallet->NotifyCanGetAddressesChanged();
125 const std::shared_ptr<CWallet> &
wallet,
126 std::optional<bool> load_on_start,
127 std::vector<bilingual_str> &warnings) {
134 wallet->m_chain_notifications_handler.reset();
137 std::vector<std::shared_ptr<CWallet>>::iterator i =
138 std::find(context.wallets.begin(), context.wallets.end(),
wallet);
139 if (i == context.wallets.end()) {
142 context.wallets.erase(i);
154 const std::shared_ptr<CWallet> &
wallet,
155 std::optional<bool> load_on_start) {
156 std::vector<bilingual_str> warnings;
162 return context.wallets;
166 const std::string &
name) {
168 for (
const std::shared_ptr<CWallet> &
wallet : context.wallets) {
176std::unique_ptr<interfaces::Handler>
179 auto it = context.wallet_load_fns.emplace(context.wallet_load_fns.end(),
180 std::move(load_wallet));
183 context.wallet_load_fns.erase(it);
188 const std::shared_ptr<CWallet> &
wallet) {
190 for (
auto &load_wallet : context.wallet_load_fns) {
198static std::set<std::string>
200static std::set<std::string>
206 wallet->WalletLogPrintf(
"Releasing wallet %s..\n",
name);
212 if (g_unloading_wallet_set.erase(
name) == 0) {
225 g_unloading_wallet_set.insert(
name);
234 while (g_unloading_wallet_set.count(
name) == 1) {
241std::shared_ptr<CWallet>
243 std::optional<bool> load_on_start,
245 bilingual_str &error, std::vector<bilingual_str> &warnings) {
247 std::unique_ptr<WalletDatabase> database =
250 error =
Untranslated(
"Wallet file verification failed.") +
256 std::shared_ptr<CWallet>
wallet =
268 wallet->postInitProcess();
274 }
catch (
const std::runtime_error &e) {
282std::shared_ptr<CWallet>
286 std::vector<bilingual_str> &warnings) {
288 return g_loading_wallet_set.insert(
name));
289 if (!result.second) {
294 auto wallet = LoadWalletInternal(context,
name, load_on_start, options,
295 status, error, warnings);
300std::shared_ptr<CWallet>
304 std::vector<bilingual_str> &warnings) {
313 if (!passphrase.empty()) {
319 std::unique_ptr<WalletDatabase> database =
322 error =
Untranslated(
"Wallet file verification failed.") +
329 if (!passphrase.empty() &&
332 "Passphrase provided but private keys are disabled. A passphrase "
333 "is only used to encrypt private keys, so cannot be used for "
334 "wallets with private keys disabled.");
341 std::shared_ptr<CWallet>
wallet =
343 wallet_creation_flags, error, warnings);
352 if (!passphrase.empty() &&
354 if (!
wallet->EncryptWallet(passphrase)) {
356 Untranslated(
"Error: Wallet created but failed to encrypt.");
362 if (!
wallet->Unlock(passphrase)) {
364 "Error: Wallet was encrypted but could not be unlocked");
373 wallet->SetupDescriptorScriptPubKeyMans();
375 for (
auto spk_man :
wallet->GetActiveScriptPubKeyMans()) {
376 if (!spk_man->SetupGeneration()) {
393 wallet->postInitProcess();
402std::shared_ptr<CWallet>
404 const std::string &wallet_name, std::optional<bool> load_on_start,
406 std::vector<bilingual_str> &warnings) {
412 auto wallet_file = wallet_path /
"wallet.dat";
413 std::shared_ptr<CWallet>
wallet;
424 "Failed to create database path '%s'. Database already exists.",
430 fs::copy_file(backup_file, wallet_file, fs::copy_options::none);
433 status, error, warnings);
434 }
catch (
const std::exception &e) {
436 if (!error.
empty()) {
442 fs::remove_all(wallet_path);
461 std::map<TxId, CWalletTx>::const_iterator it = mapWallet.find(txid);
462 if (it == mapWallet.end()) {
466 return &(it->second);
479 spk_man->UpgradeKeyMetadata();
484 bool accept_no_keys) {
490 for (
const MasterKeyMap::value_type &pMasterKey :
mapMasterKeys) {
492 strWalletPassphrase, pMasterKey.second.vchSalt,
493 pMasterKey.second.nDeriveIterations,
494 pMasterKey.second.nDerivationMethod)) {
497 if (!crypter.
Decrypt(pMasterKey.second.vchCryptedKey,
502 if (
Unlock(_vMasterKey, accept_no_keys)) {
525 strOldWalletPassphrase, pMasterKey.second.vchSalt,
526 pMasterKey.second.nDeriveIterations,
527 pMasterKey.second.nDerivationMethod)) {
531 if (!crypter.
Decrypt(pMasterKey.second.vchCryptedKey, _vMasterKey)) {
535 if (
Unlock(_vMasterKey)) {
537 auto start{SteadyClock::now()};
539 pMasterKey.second.vchSalt,
540 pMasterKey.second.nDeriveIterations,
541 pMasterKey.second.nDerivationMethod);
542 pMasterKey.second.nDeriveIterations =
static_cast<unsigned int>(
543 pMasterKey.second.nDeriveIterations * target /
544 (SteadyClock::now() - start));
546 start = SteadyClock::now();
548 pMasterKey.second.vchSalt,
549 pMasterKey.second.nDeriveIterations,
550 pMasterKey.second.nDerivationMethod);
551 pMasterKey.second.nDeriveIterations =
552 (pMasterKey.second.nDeriveIterations +
553 static_cast<unsigned int>(pMasterKey.second.nDeriveIterations *
555 (SteadyClock::now() - start))) /
558 if (pMasterKey.second.nDeriveIterations < 25000) {
559 pMasterKey.second.nDeriveIterations = 25000;
563 "Wallet passphrase changed to an nDeriveIterations of %i\n",
564 pMasterKey.second.nDeriveIterations);
567 strNewWalletPassphrase, pMasterKey.second.vchSalt,
568 pMasterKey.second.nDeriveIterations,
569 pMasterKey.second.nDerivationMethod)) {
573 if (!crypter.
Encrypt(_vMasterKey,
574 pMasterKey.second.vchCryptedKey)) {
604 if (nWalletVersion >= nVersion) {
610 if (fExplicit && nVersion > nWalletMaxVersion) {
614 nWalletVersion = nVersion;
616 if (nVersion > nWalletMaxVersion) {
617 nWalletMaxVersion = nVersion;
621 if (nWalletVersion > 40000) {
633 if (nWalletVersion > nVersion) {
637 nWalletMaxVersion = nVersion;
643 std::set<TxId> result;
646 std::map<TxId, CWalletTx>::const_iterator it = mapWallet.find(txid);
647 if (it == mapWallet.end()) {
653 std::pair<TxSpends::const_iterator, TxSpends::const_iterator> range;
655 for (
const CTxIn &txin : wtx.
tx->vin) {
656 if (mapTxSpends.count(txin.prevout) <= 1) {
661 range = mapTxSpends.equal_range(txin.prevout);
662 for (TxSpends::const_iterator _it = range.first; _it != range.second;
664 result.insert(_it->second);
673 auto iter = mapTxSpends.lower_bound(COutPoint(txid, 0));
674 return (iter != mapTxSpends.end() && iter->first.GetTxId() == txid);
686 std::pair<TxSpends::iterator, TxSpends::iterator> range) {
691 int nMinOrderPos = std::numeric_limits<int>::max();
693 for (TxSpends::iterator it = range.first; it != range.second; ++it) {
694 const CWalletTx *wtx = &mapWallet.at(it->second);
706 for (TxSpends::iterator it = range.first; it != range.second; ++it) {
707 const TxId &txid = it->second;
709 if (copyFrom == copyTo) {
715 "Oldest wallet transaction in range assumed to have been found.");
737 std::pair<TxSpends::const_iterator, TxSpends::const_iterator> range =
738 mapTxSpends.equal_range(outpoint);
740 for (TxSpends::const_iterator it = range.first; it != range.second; ++it) {
741 const TxId &wtxid = it->second;
742 std::map<TxId, CWalletTx>::const_iterator mit = mapWallet.find(wtxid);
743 if (mit != mapWallet.end()) {
745 if (depth > 0 || (depth == 0 && !mit->second.isAbandoned())) {
756 mapTxSpends.insert(std::make_pair(outpoint, wtxid));
758 setLockedCoins.erase(outpoint);
760 std::pair<TxSpends::iterator, TxSpends::iterator> range;
761 range = mapTxSpends.equal_range(outpoint);
766 auto it = mapWallet.find(wtxid);
767 assert(it != mapWallet.end());
774 for (
const CTxIn &txin : thisTx.
tx->vin) {
796 auto start{SteadyClock::now()};
800 25000 * target / (SteadyClock::now() - start));
802 start = SteadyClock::now();
809 (SteadyClock::now() - start))) /
834 delete encrypted_batch;
835 encrypted_batch =
nullptr;
841 auto spk_man = spk_man_pair.second.get();
842 if (!spk_man->Encrypt(_vMasterKey, encrypted_batch)) {
844 delete encrypted_batch;
845 encrypted_batch =
nullptr;
857 delete encrypted_batch;
858 encrypted_batch =
nullptr;
865 delete encrypted_batch;
866 encrypted_batch =
nullptr;
869 Unlock(strWalletPassphrase);
877 if (spk_man->IsHDEnabled()) {
878 if (!spk_man->SetupGeneration(
true)) {
911 for (
auto &entry : mapWallet) {
917 std::vector<int64_t> nOrderPosOffsets;
918 for (TxItems::iterator it = txByTime.begin(); it != txByTime.end(); ++it) {
922 if (nOrderPos == -1) {
923 nOrderPos = nOrderPosNext++;
924 nOrderPosOffsets.push_back(nOrderPos);
930 int64_t nOrderPosOff = 0;
931 for (
const int64_t &nOffsetStart : nOrderPosOffsets) {
932 if (nOrderPos >= nOffsetStart) {
937 nOrderPos += nOrderPosOff;
938 nOrderPosNext = std::max(nOrderPosNext, nOrderPos + 1);
958 int64_t nRet = nOrderPosNext++;
970 for (std::pair<const TxId, CWalletTx> &item : mapWallet) {
971 item.second.MarkDirty();
976 unsigned int n,
bool used,
977 std::set<CTxDestination> &tx_destinations) {
990 tx_destinations.insert(dst);
992 }
else if (!used &&
GetDestData(dst,
"used",
nullptr)) {
1003 assert(srctx->
tx->vout.size() > n);
1013 assert(spk_man !=
nullptr);
1014 for (
const auto &keyid :
1029 bool fFlushOnClose) {
1034 const TxId &txid = tx->GetId();
1038 std::set<CTxDestination> tx_destinations;
1040 for (
const CTxIn &txin : tx->vin) {
1041 const COutPoint &op = txin.prevout;
1051 mapWallet.emplace(std::piecewise_construct, std::forward_as_tuple(txid),
1052 std::forward_as_tuple(tx));
1054 bool fInsertedNew = ret.second;
1055 bool fUpdated = update_wtx && update_wtx(wtx, fInsertedNew);
1066 if (!fInsertedNew) {
1082 (fInsertedNew ?
"new" :
""), (fUpdated ?
"update" :
""));
1085 if ((fInsertedNew || fUpdated) && !batch.
WriteTx(wtx)) {
1095#if defined(HAVE_SYSTEM)
1098 std::string strCmd =
gArgs.
GetArg(
"-walletnotify",
"");
1100 if (!strCmd.empty()) {
1111 std::thread t(runCommand, strCmd);
1122 mapWallet.emplace(std::piecewise_construct, std::forward_as_tuple(txid),
1123 std::forward_as_tuple(
nullptr));
1125 if (!fill_wtx(wtx, ins.second)) {
1133 if (
chain().findBlock(
1135 FoundBlock().inActiveChain(active).height(height)) &&
1158 for (
const CTxIn &txin : wtx.
tx->vin) {
1159 auto it = mapWallet.find(txin.prevout.GetTxId());
1160 if (it != mapWallet.end()) {
1176 const TxId &txid = ptx->GetId();
1179 for (
const CTxIn &txin : ptx->vin) {
1180 std::pair<TxSpends::const_iterator, TxSpends::const_iterator>
1181 range = mapTxSpends.equal_range(txin.prevout);
1182 while (range.first != range.second) {
1183 if (range.first->second != txid) {
1185 "Transaction %s (in block %s) conflicts with wallet "
1186 "transaction %s (both spend %s:%i)\n",
1188 range.first->second.ToString(),
1189 range.first->first.GetTxId().ToString(),
1190 range.first->first.GetN());
1192 range.first->second);
1199 bool fExisted = mapWallet.count(txid) != 0;
1200 if (fExisted && !fUpdate) {
1213 for (
const CTxOut &txout : ptx->vout) {
1215 spk_man_pair.second->MarkUnusedAddresses(txout.
scriptPubKey);
1236 for (
const CTxIn &txin : tx->vin) {
1237 auto it = mapWallet.find(txin.prevout.GetTxId());
1238 if (it != mapWallet.end()) {
1239 it->second.MarkDirty();
1249 std::set<TxId> todo;
1250 std::set<TxId> done;
1253 auto it = mapWallet.find(txid);
1254 assert(it != mapWallet.end());
1262 while (!todo.empty()) {
1266 it = mapWallet.find(now);
1267 assert(it != mapWallet.end());
1271 assert(currentconfirm <= 0);
1284 TxSpends::const_iterator iter =
1285 mapTxSpends.lower_bound(COutPoint(now, 0));
1286 while (iter != mapTxSpends.end() && iter->first.GetTxId() == now) {
1287 if (!done.count(iter->second)) {
1288 todo.insert(iter->second);
1307 int conflictconfirms =
1308 (m_last_block_processed_height - conflicting_height + 1) * -1;
1313 if (conflictconfirms >= 0) {
1320 std::set<TxId> todo;
1321 std::set<TxId> done;
1325 while (!todo.empty()) {
1329 auto it = mapWallet.find(now);
1330 assert(it != mapWallet.end());
1333 if (conflictconfirms < currentconfirm) {
1344 TxSpends::const_iterator iter =
1345 mapTxSpends.lower_bound(COutPoint(now, 0));
1346 while (iter != mapTxSpends.end() && iter->first.GetTxId() == now) {
1347 if (!done.count(iter->second)) {
1348 todo.insert(iter->second);
1374 uint64_t mempool_sequence) {
1380 auto it = mapWallet.find(tx->GetId());
1381 if (it != mapWallet.end()) {
1382 it->second.fInMempool =
true;
1388 uint64_t mempool_sequence) {
1390 auto it = mapWallet.find(tx->GetId());
1391 if (it != mapWallet.end()) {
1392 it->second.fInMempool =
false;
1423 {CWalletTx::Status::UNCONFIRMED, 0,
1436 m_last_block_processed_height = height;
1437 m_last_block_processed = block_hash;
1438 for (
size_t index = 0; index < block.
vtx.size(); index++) {
1440 block_hash, int(index)});
1455 m_last_block_processed_height = height - 1;
1459 {CWalletTx::Status::UNCONFIRMED, 0,
1468void CWallet::BlockUntilSyncedToCurrentChain()
const {
1483 std::map<TxId, CWalletTx>::const_iterator mi =
1484 mapWallet.find(txin.prevout.GetTxId());
1485 if (mi != mapWallet.end()) {
1487 if (txin.prevout.GetN() < prev.
tx->vout.size()) {
1488 if (
IsMine(prev.
tx->vout[txin.prevout.GetN()]) & filter) {
1489 return prev.
tx->vout[txin.prevout.GetN()].nValue;
1511 result = std::max(result, spk_man_pair.second->IsMine(
script));
1518 for (
const CTxOut &txout : tx.vout) {
1534 for (
const CTxIn &txin : tx.vin) {
1537 throw std::runtime_error(std::string(__func__) +
1538 ": value out of range");
1549 result &= spk_man->IsHDEnabled();
1561 if (spk_man && spk_man->CanGetAddresses(internal)) {
1572 throw std::runtime_error(std::string(__func__) +
1573 ": writing wallet flags failed");
1586 throw std::runtime_error(std::string(__func__) +
1587 ": writing wallet flags failed");
1615 throw std::runtime_error(std::string(__func__) +
1616 ": writing wallet flags failed");
1625 bool use_max_sig)
const {
1630 std::unique_ptr<SigningProvider> provider =
1640 scriptPubKey, sigdata)) {
1651 const std::vector<CTxOut> &txouts,
1652 bool use_max_sig)
const {
1655 for (
const auto &txout : txouts) {
1666 int64_t timestamp) {
1671 LOCK(spk_man->cs_KeyStore);
1672 return spk_man->ImportScripts(scripts, timestamp);
1676 const int64_t timestamp) {
1681 LOCK(spk_man->cs_KeyStore);
1682 return spk_man->ImportPrivKeys(privkey_map, timestamp);
1686 const std::vector<CKeyID> &ordered_pubkeys,
1687 const std::map<CKeyID, CPubKey> &pubkey_map,
1688 const std::map<
CKeyID, std::pair<CPubKey, KeyOriginInfo>> &key_origins,
1689 const bool add_keypool,
const bool internal,
const int64_t timestamp) {
1694 LOCK(spk_man->cs_KeyStore);
1695 return spk_man->ImportPubKeys(ordered_pubkeys, pubkey_map, key_origins,
1696 add_keypool, internal, timestamp);
1700 const std::set<CScript> &script_pub_keys,
1701 const bool have_solving_data,
1702 const bool apply_label,
1703 const int64_t timestamp) {
1708 LOCK(spk_man->cs_KeyStore);
1709 if (!spk_man->ImportScriptPubKeys(script_pub_keys, have_solving_data,
1715 for (
const CScript &
script : script_pub_keys) {
1740 int start_height = 0;
1744 FoundBlock().hash(start_block).height(start_height));
1753 start_block, start_height, {} , reserver, update);
1786 const BlockHash &start_block,
int start_height,
1813 double progress_current = progress_begin;
1814 int block_height = start_height;
1816 if (progress_end - progress_begin > 0.0) {
1818 (progress_end - progress_begin);
1824 if (block_height % 100 == 0 && progress_end - progress_begin > 0.0) {
1826 strprintf(
"%s " +
_(
"Rescanning...").translated,
1833 block_height, progress_current);
1842 bool block_still_active =
false;
1843 bool next_block =
false;
1847 .inActiveChain(block_still_active)
1849 .inActiveChain(next_block)
1850 .hash(next_block_hash)));
1854 if (!block_still_active) {
1861 for (
size_t posInBlock = 0; posInBlock < block.
vtx.size();
1864 block_height, block_hash,
1867 {CWalletTx::Status::CONFIRMED, block_height,
1868 block_hash, int(posInBlock)},
1881 if (max_height && block_height >= *max_height) {
1892 block_hash = next_block_hash;
1897 const BlockHash prev_tip_hash = tip_hash;
1899 if (!max_height && prev_tip_hash != tip_hash) {
1912 block_height, progress_current);
1914 }
else if (block_height &&
chain().shutdownRequested()) {
1916 "Rescan interrupted by shutdown request at block %d. Progress=%f\n",
1917 block_height, progress_current);
1935 std::map<int64_t, CWalletTx *> mapSorted;
1939 for (std::pair<const TxId, CWalletTx> &item : mapWallet) {
1940 const TxId &wtxid = item.first;
1947 mapSorted.insert(std::make_pair(wtx.
nOrderPos, &wtx));
1952 for (
const std::pair<const int64_t, CWalletTx *> &item : mapSorted) {
1954 std::string unused_err_string;
1960 std::string &err_string,
2003 std::set<TxId> result;
2023 if (!
chain().isReadyToBroadcast()) {
2041 int submitted_tx_count = 0;
2047 for (std::pair<const TxId, CWalletTx> &item : mapWallet) {
2055 std::string unused_err_string;
2057 ++submitted_tx_count;
2062 if (submitted_tx_count > 0) {
2063 WalletLogPrintf(
"%s: resubmit %u unconfirmed transactions\n", __func__,
2064 submitted_tx_count);
2071 for (
const std::shared_ptr<CWallet> &pwallet :
GetWallets(context)) {
2072 pwallet->ResendWalletTransactions();
2086 std::map<COutPoint, Coin> coins;
2087 for (
auto &input : tx.
vin) {
2088 auto mi = mapWallet.find(input.prevout.GetTxId());
2089 if (mi == mapWallet.end() ||
2090 input.prevout.GetN() >= mi->second.tx->vout.size()) {
2094 coins[input.prevout] =
2098 std::map<int, std::string> input_errors;
2103 const std::map<COutPoint, Coin> &coins,
2105 std::map<int, std::string> &input_errors)
const {
2110 if (spk_man->SignTransaction(tx, coins, sighash, input_errors)) {
2121 if (legacy_spk_man &&
2122 legacy_spk_man->SignTransaction(tx, coins, sighash, input_errors)) {
2132 bool bip32derivs)
const {
2135 for (
size_t i = 0; i < psbtx.
tx->vin.size(); ++i) {
2136 const CTxIn &txin = psbtx.
tx->vin[i];
2145 const TxId &txid = txin.prevout.GetTxId();
2146 const auto it = mapWallet.find(txid);
2147 if (it != mapWallet.end()) {
2149 if (txin.prevout.GetN() >= wtx.
tx->vout.size()) {
2150 return PSBTError::MISSING_INPUTS;
2153 input.
utxo = wtx.
tx->vout[txin.prevout.GetN()];
2161 spk_man->FillPSBT(psbtx, sighash_type, sign, bip32derivs)};
2169 for (
const auto &input : psbtx.
inputs) {
2178 std::string &str_sig)
const {
2182 if (spk_man_pair.second->CanProvide(script_pub_key, sigdata)) {
2185 return spk_man_pair.second->SignMessage(message, pkhash, str_sig);
2193 const std::vector<CRecipient> &vecSend)
const {
2196 return *change_type;
2210 std::vector<std::pair<std::string, std::string>> orderForm,
2221 wtx.
mapValue = std::move(mapValue);
2229 for (
const CTxIn &txin : tx->vin) {
2230 CWalletTx &coin = mapWallet.at(txin.prevout.GetTxId());
2237 CWalletTx &wtx = mapWallet.at(tx->GetId());
2245 std::string err_string;
2247 WalletLogPrintf(
"CommitTransaction(): Transaction cannot be broadcast "
2248 "immediately, %s\n",
2260 if (
database->Rewrite(
"\x04pool")) {
2262 spk_man_pair.second->RewriteDB();
2273 return nLoadWalletRet;
2280 std::vector<TxId> &txIdsOut) {
2284 for (
const TxId &txid : txIdsOut) {
2285 const auto &it = mapWallet.find(txid);
2286 wtxOrdered.erase(it->second.m_it_wtxOrdered);
2287 for (
const auto &txin : it->second.tx->vin) {
2288 mapTxSpends.erase(txin.prevout);
2290 mapWallet.erase(it);
2295 if (
database->Rewrite(
"\x04pool")) {
2297 spk_man_pair.second->RewriteDB();
2303 return nZapSelectTxRet;
2313 const std::string &strName,
2314 const std::string &strPurpose) {
2315 bool fUpdated =
false;
2319 std::map<CTxDestination, CAddressBookData>::iterator mi =
2320 m_address_book.find(address);
2321 fUpdated = (mi != m_address_book.end() && !mi->second.IsChange());
2322 m_address_book[address].SetLabel(strName);
2324 if (!strPurpose.empty()) {
2325 m_address_book[address].purpose = strPurpose;
2332 if (!strPurpose.empty() && !batch.
WritePurpose(address, strPurpose)) {
2335 return batch.
WriteName(address, strName);
2339 const std::string &strName,
2340 const std::string &strPurpose) {
2359 "%s called with IsMine address, NOT SUPPORTED. Please "
2360 "report this bug! %s\n",
2361 __func__, PACKAGE_BUGREPORT);
2365 for (
const std::pair<const std::string, std::string> &item :
2366 m_address_book[address].destdata) {
2369 m_address_book.erase(address);
2382 unsigned int count = 0;
2384 count += spk_man->KeypoolCountExternalKeys();
2393 unsigned int count = 0;
2395 count += spk_man->GetKeyPoolSize();
2404 res &= spk_man->TopUp(kpSize);
2418 auto op_dest = spk_man->GetNewDestination(type);
2434 _(
"Error: Keypool ran out, please call keypoolrefill first")};
2443 int64_t oldestKey = std::numeric_limits<int64_t>::max();
2446 std::min(oldestKey, spk_man_pair.second->GetOldestKeyPoolTime());
2452 const std::set<CTxDestination> &destinations) {
2453 for (
auto &entry : mapWallet) {
2459 for (
size_t i = 0; i < wtx.
tx->vout.size(); i++) {
2463 destinations.count(dst)) {
2471std::set<CTxDestination>
2474 std::set<CTxDestination> result;
2475 for (
const std::pair<const CTxDestination, CAddressBookData> &item :
2477 if (item.second.IsChange()) {
2481 const std::string &strName = item.second.GetLabel();
2482 if (strName == label) {
2483 result.insert(address);
2530 setLockedCoins.insert(output);
2535 setLockedCoins.erase(output);
2540 setLockedCoins.clear();
2546 return setLockedCoins.count(outpoint) > 0;
2551 for (COutPoint outpoint : setLockedCoins) {
2552 vOutpts.push_back(outpoint);
2560 mapKeyBirth.clear();
2563 std::map<CKeyID, const CWalletTx::Confirmation *> mapKeyFirstBlock;
2574 assert(spk_man !=
nullptr);
2578 for (
const auto &entry : spk_man->mapKeyMetadata) {
2579 if (entry.second.nCreateTime) {
2580 mapKeyBirth[entry.first] = entry.second.nCreateTime;
2586 if (mapKeyBirth.count(keyid) == 0) {
2587 mapKeyFirstBlock[keyid] = &max_confirm;
2592 if (mapKeyFirstBlock.empty()) {
2597 for (
const auto &entry : mapWallet) {
2602 for (
const CTxOut &txout : wtx.
tx->vout) {
2604 for (
const auto &keyid :
2607 auto rit = mapKeyFirstBlock.find(keyid);
2608 if (rit != mapKeyFirstBlock.end() &&
2610 rit->second->block_height) {
2620 for (
const auto &entry : mapKeyFirstBlock) {
2657 int64_t latestEntry = 0;
2661 int64_t latestTolerated = latestNow + 300;
2663 for (
auto it = txOrdered.rbegin(); it != txOrdered.rend(); ++it) {
2673 if (nSmartTime <= latestTolerated) {
2674 latestEntry = nSmartTime;
2675 if (nSmartTime > latestNow) {
2676 latestNow = nSmartTime;
2682 nTimeSmart = std::max(latestEntry, std::min(blocktime, latestNow));
2693 const std::string &key,
const std::string &value) {
2694 if (std::get_if<CNoDestination>(&dest)) {
2698 m_address_book[dest].destdata.insert(std::make_pair(key, value));
2703 const std::string &key) {
2704 if (!m_address_book[dest].destdata.erase(key)) {
2712 const std::string &value) {
2713 m_address_book[dest].destdata.insert(std::make_pair(key, value));
2717 std::string *value)
const {
2718 std::map<CTxDestination, CAddressBookData>::const_iterator i =
2719 m_address_book.find(dest);
2720 if (i != m_address_book.end()) {
2721 CAddressBookData::StringMap::const_iterator j =
2722 i->second.destdata.find(key);
2723 if (j != i->second.destdata.end()) {
2734std::vector<std::string>
2736 std::vector<std::string> values;
2737 for (
const auto &address : m_address_book) {
2738 for (
const auto &data : address.second.destdata) {
2740 values.emplace_back(data.second);
2747std::unique_ptr<WalletDatabase>
2758 fs::file_type path_type = fs::symlink_status(wallet_path).type();
2759 if (!(path_type == fs::file_type::not_found ||
2760 path_type == fs::file_type::directory ||
2761 (path_type == fs::file_type::symlink &&
2762 fs::is_directory(wallet_path)) ||
2763 (path_type == fs::file_type::regular &&
2766 strprintf(
"Invalid -wallet path '%s'. -wallet path should point to "
2767 "a directory where wallet.dat and "
2768 "database/log.?????????? files can be stored, a location "
2769 "where such a directory could be created, "
2770 "or (for backwards compatibility) the name of an "
2771 "existing data file in -walletdir (%s)",
2776 return MakeDatabase(wallet_path, options, status, error_string);
2779std::shared_ptr<CWallet>
2781 std::unique_ptr<WalletDatabase> database,
2783 std::vector<bilingual_str> &warnings) {
2785 const std::string &walletFile =
database->Filename();
2790 std::shared_ptr<CWallet> walletInstance(
2792 DBErrors nLoadWalletRet = walletInstance->LoadWallet();
2796 strprintf(
_(
"Error loading %s: Wallet corrupted"), walletFile);
2802 strprintf(
_(
"Error reading %s! All keys read correctly, but "
2803 "transaction data or address book entries might be "
2804 "missing or incorrect."),
2808 _(
"Error loading %s: Wallet requires newer version of %s"),
2809 walletFile, PACKAGE_NAME);
2813 _(
"Wallet needed to be rewritten: restart %s to complete"),
2817 error =
strprintf(
_(
"Error loading %s"), walletFile);
2824 const bool fFirstRun =
2825 walletInstance->m_spk_managers.empty() &&
2833 walletInstance->AddWalletFlags(wallet_creation_flags);
2837 walletInstance->SetupLegacyScriptPubKeyMan();
2840 if (!(wallet_creation_flags &
2842 LOCK(walletInstance->cs_wallet);
2844 walletInstance->SetupDescriptorScriptPubKeyMans();
2850 walletInstance->GetActiveScriptPubKeyMans()) {
2851 if (!spk_man->SetupGeneration()) {
2852 error =
_(
"Unable to generate initial keys");
2865 error =
strprintf(
_(
"Error loading %s: Private keys can only be "
2866 "disabled during creation"),
2869 }
else if (walletInstance->IsWalletFlagSet(
2871 for (
auto spk_man : walletInstance->GetActiveScriptPubKeyMans()) {
2872 if (spk_man->HavePrivateKeys()) {
2874 strprintf(
_(
"Warning: Private keys detected in wallet {%s} "
2875 "with disabled private keys"),
2890 _(
"This is the minimum transaction fee you pay "
2891 "on every transaction."));
2893 walletInstance->m_min_fee =
CFeeRate(n);
2897 const std::string max_aps_fee{
gArgs.
GetArg(
"-maxapsfee",
"")};
2899 if (max_aps_fee ==
"-1") {
2908 _(
"This is the maximum transaction fee you pay (in addition to"
2909 " the normal fee) to prioritize partial spend avoidance over"
2910 " regular coin selection."));
2912 walletInstance->m_max_aps_fee = n;
2919 strprintf(
_(
"Invalid amount for -fallbackfee=<amount>: '%s'"),
2926 _(
"This is the transaction fee you may pay when "
2927 "fee estimates are not available."));
2929 walletInstance->m_fallback_fee =
CFeeRate(nFeePerK);
2932 walletInstance->m_allow_fallback_fee =
2933 walletInstance->m_fallback_fee.GetFeePerK() !=
Amount::zero();
2943 _(
"This is the transaction fee you will pay if "
2944 "you send a transaction."));
2946 walletInstance->m_pay_tx_fee =
CFeeRate(nFeePerK, 1000);
2948 error =
strprintf(
_(
"Invalid amount for -paytxfee=<amount>: '%s' "
2949 "(must be at least %s)"),
2963 warnings.push_back(
_(
"-maxtxfee is set very high! Fees this large "
2964 "could be paid on a single transaction."));
2968 _(
"Invalid amount for -maxtxfee=<amount>: '%s' (must be at "
2969 "least the minrelay fee of %s to prevent stuck "
2974 walletInstance->m_default_max_tx_fee = nMaxFee;
2980 _(
"The wallet will avoid paying less than the minimum relay fee."));
2983 walletInstance->m_spend_zero_conf_change =
2988 walletInstance->WalletLogPrintf(
"Wallet completed loading in %15dms\n",
2992 walletInstance->TopUpKeyPool();
2996 walletInstance->m_chain_notifications_handler.reset();
3001 LOCK(walletInstance->cs_wallet);
3002 walletInstance->SetBroadcastTransactions(
3004 walletInstance->WalletLogPrintf(
"setKeyPool.size() = %u\n",
3005 walletInstance->GetKeyPoolSize());
3006 walletInstance->WalletLogPrintf(
"mapWallet.size() = %u\n",
3007 walletInstance->mapWallet.size());
3008 walletInstance->WalletLogPrintf(
"m_address_book.size() = %u\n",
3009 walletInstance->m_address_book.size());
3012 return walletInstance;
3017 std::vector<bilingual_str> &warnings) {
3018 LOCK(walletInstance->cs_wallet);
3021 assert(!walletInstance->m_chain || walletInstance->m_chain == &
chain);
3022 walletInstance->m_chain = &
chain;
3036 walletInstance->m_attaching_chain =
true;
3037 walletInstance->m_chain_notifications_handler =
3040 int rescan_height = 0;
3045 if (
const std::optional<int> fork_height =
3047 rescan_height = *fork_height;
3054 walletInstance->m_last_block_processed =
3056 walletInstance->m_last_block_processed_height = *tip_height;
3058 walletInstance->m_last_block_processed.
SetNull();
3059 walletInstance->m_last_block_processed_height = -1;
3062 if (tip_height && *tip_height != rescan_height) {
3067 int block_height = *tip_height;
3068 while (block_height > 0 &&
3070 rescan_height != block_height) {
3074 if (rescan_height != block_height) {
3087 ?
_(
"Prune: last wallet synchronisation goes beyond "
3088 "pruned data. You need to -reindex (download the "
3089 "whole blockchain again in case of pruned node)")
3090 :
strprintf(
_(
"Error loading wallet. Wallet requires "
3091 "blocks to be downloaded, "
3092 "and software does not currently support "
3093 "loading wallets while "
3094 "blocks are being downloaded out of "
3095 "order when using assumeutxo "
3096 "snapshots. Wallet should be able to "
3097 "load successfully after "
3098 "node sync reaches height %s"),
3105 walletInstance->WalletLogPrintf(
3106 "Rescanning last %i blocks (from block %i)...\n",
3107 *tip_height - rescan_height, rescan_height);
3111 std::optional<int64_t> time_first_key;
3112 for (
auto spk_man : walletInstance->GetAllScriptPubKeyMans()) {
3113 int64_t time = spk_man->GetTimeFirstKey();
3114 if (!time_first_key || time < *time_first_key) {
3115 time_first_key = time;
3118 if (time_first_key) {
3129 ->ScanForWalletTransactions(
3131 {} , reserver,
true )
3133 error =
_(
"Failed to rescan the wallet during initialization");
3138 walletInstance->m_attaching_chain =
false;
3141 walletInstance->database->IncrementUpdateCounter();
3143 walletInstance->m_attaching_chain =
false;
3150 bool allow_change)
const {
3151 const auto &address_book_it = m_address_book.find(dest);
3152 if (address_book_it == m_address_book.end()) {
3155 if ((!allow_change) && address_book_it->second.IsChange()) {
3158 return &address_book_it->second;
3163 int nMaxVersion = version;
3165 if (nMaxVersion == 0) {
3175 error =
_(
"Cannot downgrade wallet");
3189 error =
_(
"Cannot upgrade a non HD split wallet without upgrading to "
3190 "support pre split keypool. Please use version 200300 or no "
3191 "version specified.");
3196 if (!spk_man->Upgrade(prev_version, error)) {
3259 assert(chain_depth >= 0);
3279 return vMasterKey.empty();
3289 if (!vMasterKey.empty()) {
3292 sizeof(
decltype(vMasterKey)::value_type));
3305 if (!spk_man_pair.second->CheckDecryptionKey(vMasterKeyIn,
3310 vMasterKey = vMasterKeyIn;
3317 std::set<ScriptPubKeyMan *> spk_mans;
3318 for (
bool internal : {
false,
true}) {
3322 spk_mans.insert(spk_man);
3330 std::set<ScriptPubKeyMan *> spk_mans;
3332 spk_mans.insert(spk_man_pair.second.get());
3338 bool internal)
const {
3339 const std::map<OutputType, ScriptPubKeyMan *> &spk_managers =
3341 std::map<OutputType, ScriptPubKeyMan *>::const_iterator it =
3342 spk_managers.find(type);
3343 if (it == spk_managers.end()) {
3345 "%s scriptPubKey Manager for output type %d does not exist\n",
3346 internal ?
"Internal" :
"External",
static_cast<int>(type));
3352std::set<ScriptPubKeyMan *>
3355 std::set<ScriptPubKeyMan *> spk_mans;
3357 if (spk_man_pair.second->CanProvide(
script, sigdata)) {
3358 spk_mans.insert(spk_man_pair.second.get());
3367 if (spk_man_pair.second->CanProvide(
script, sigdata)) {
3368 return spk_man_pair.second.get();
3381std::unique_ptr<SigningProvider>
3387std::unique_ptr<SigningProvider>
3391 if (spk_man_pair.second->CanProvide(
script, sigdata)) {
3392 return spk_man_pair.second->GetSolvingProvider(
script);
3435 return cb(vMasterKey);
3445 spk_man->NotifyCanGetAddressesChanged.connect(
3452 auto spk_manager = std::unique_ptr<ScriptPubKeyMan>(
3470 for (
bool internal : {
false,
true}) {
3473 std::make_unique<DescriptorScriptPubKeyMan>(*
this, internal);
3476 throw std::runtime_error(
3477 std::string(__func__) +
3478 ": Wallet is locked, cannot setup new descriptors");
3480 if (!spk_manager->CheckDecryptionKey(vMasterKey) &&
3481 !spk_manager->Encrypt(vMasterKey,
nullptr)) {
3482 throw std::runtime_error(
3483 std::string(__func__) +
3484 ": Could not encrypt new descriptors");
3487 spk_manager->SetupDescriptorGeneration(master_key, t);
3488 uint256 id = spk_manager->GetID();
3500 throw std::runtime_error(std::string(__func__) +
3501 ": writing active ScriptPubKeyMan id failed");
3515 "Setting spkMan to active: id = %s, type = %d, internal = %d\n",
3516 id.
ToString(),
static_cast<int>(type),
static_cast<int>(internal));
3519 auto &spk_mans_other =
3522 spk_man->SetInternal(internal);
3523 spk_mans[type] = spk_man;
3525 const auto it = spk_mans_other.find(type);
3526 if (it != spk_mans_other.end() && it->second == spk_man) {
3527 spk_mans_other.erase(type);
3536 if (spk_man !=
nullptr && spk_man->GetID() ==
id) {
3538 "Deactivate spkMan: id = %s, type = %d, internal = %d\n",
3539 id.
ToString(),
static_cast<int>(type),
static_cast<int>(internal));
3543 throw std::runtime_error(
3544 std::string(__func__) +
3545 ": erasing active ScriptPubKeyMan id failed");
3550 spk_mans.erase(type);
3562 return spk_man !=
nullptr;
3572 spk_man_pair.second.get());
3584 const std::string &label,
bool internal) {
3589 "Cannot add WalletDescriptor to a non-descriptor wallet\n");
3597 spk_man->UpdateWalletDescriptor(desc);
3600 std::make_unique<DescriptorScriptPubKeyMan>(*
this, desc);
3601 spk_man = new_spk_man.get();
3608 for (
const auto &entry : signing_provider.
keys) {
3609 const CKey &key = entry.second;
3610 spk_man->AddDescriptorKey(key, key.
GetPubKey());
3614 if (!spk_man->TopUp()) {
3622 auto script_pub_keys = spk_man->GetScriptPubKeys();
3623 if (script_pub_keys.empty()) {
3625 "Could not generate scriptPubKeys (cache is empty)\n");
3636 spk_man->WriteDescriptor();
bool MoneyRange(const Amount nValue)
static constexpr Amount SATOSHI
static constexpr int64_t TIMESTAMP_WINDOW
Timestamp window used as a grace period by code that compares external timestamps (such as timestamps...
const CChainParams & Params()
Return the currently selected parameters.
#define CHECK_NONFATAL(condition)
Identity function.
#define Assert(val)
Identity function.
bool IsArgSet(const std::string &strArg) const
Return true if the given argument has been manually set.
std::string GetArg(const std::string &strArg, const std::string &strDefault) const
Return string argument or default value.
bool GetBoolArg(const std::string &strArg, bool fDefault) const
Return boolean argument or default value.
std::vector< CTransactionRef > vtx
CChainParams defines various tweakable parameters of a given instance of the Bitcoin system.
Encryption/decryption context with key information.
bool Encrypt(const CKeyingMaterial &vchPlaintext, std::vector< uint8_t > &vchCiphertext) const
bool SetKeyFromPassphrase(const SecureString &strKeyData, const std::vector< uint8_t > &chSalt, const unsigned int nRounds, const unsigned int nDerivationMethod)
bool Decrypt(const std::vector< uint8_t > &vchCiphertext, CKeyingMaterial &vchPlaintext) const
Fee rate in satoshis per kilobyte: Amount / kB.
std::string ToString() const
Amount GetFeePerK() const
Return the fee in satoshis for a size of 1000 bytes.
An encapsulated secp256k1 private key.
void MakeNewKey(bool fCompressed)
Generate a new private key using a cryptographic PRNG.
CPubKey GetPubKey() const
Compute the public key from a private key.
bool VerifyPubKey(const CPubKey &vchPubKey) const
Verify thoroughly whether a private key and a public key match.
A reference to a CKey: the Hash160 of its serialized public key.
A key from a CWallet's keypool.
bool fInternal
Whether this keypool entry is in the internal keypool (for change outputs)
CPubKey vchPubKey
The public key.
int64_t nTime
The time at which the key was generated. Set in AddKeypoolPubKeyWithDB.
bool m_pre_split
Whether this key was generated for a keypool before the wallet was upgraded to HD-split.
Private key encryption is done based on a CMasterKey, which holds a salt and random encryption key.
std::vector< uint8_t > vchSalt
unsigned int nDerivationMethod
0 = EVP_sha512() 1 = scrypt()
unsigned int nDeriveIterations
std::vector< uint8_t > vchCryptedKey
A mutable version of CTransaction.
An encapsulated public key.
An output of a transaction.
A CWallet maintains a set of transactions and balances, and provides the ability to create new transa...
std::unique_ptr< SigningProvider > GetSolvingProvider(const CScript &script) const
Get the SigningProvider for a script.
std::atomic< int64_t > m_best_block_time
BlockHash GetLastBlockHash() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
std::set< ScriptPubKeyMan * > GetScriptPubKeyMans(const CScript &script, SignatureData &sigdata) const
Get all of the ScriptPubKeyMans for a script given additional information in sigdata (populated by e....
bool HaveChain() const
Interface to assert chain access.
int GetTxBlocksToMaturity(const CWalletTx &wtx) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
bool DummySignTx(CMutableTransaction &txNew, const std::set< CTxOut > &txouts, bool use_max_sig=false) const
void ConnectScriptPubKeyManNotifiers()
Connect the signals from ScriptPubKeyMans to the signals in CWallet.
void AddActiveScriptPubKeyMan(uint256 id, OutputType type, bool internal)
Adds the active ScriptPubKeyMan for the specified type and internal.
void SetupLegacyScriptPubKeyMan()
Make a LegacyScriptPubKeyMan and set it for all types, internal, and external.
bool AddDestData(WalletBatch &batch, const CTxDestination &dest, const std::string &key, const std::string &value) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Adds a destination data tuple to the store, and saves it to disk When adding new fields,...
boost::signals2::signal< void()> NotifyCanGetAddressesChanged
Keypool has new keys.
MasterKeyMap mapMasterKeys
int GetTxDepthInMainChain(const CWalletTx &wtx) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Return depth of transaction in blockchain: <0 : conflicts with a transaction this deep in the blockch...
bool IsTxImmatureCoinBase(const CWalletTx &wtx) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
boost::signals2::signal< void(const std::string &title, int nProgress)> ShowProgress
Show progress e.g.
bool Unlock(const CKeyingMaterial &vMasterKeyIn, bool accept_no_keys=false)
bool GetBroadcastTransactions() const
Inquire whether this wallet broadcasts transactions.
void WalletLogPrintf(std::string fmt, Params... parameters) const
Prepends the wallet name in logging output to ease debugging in multi-wallet use cases.
interfaces::Chain & chain() const
Interface for accessing chain state.
void SetupDescriptorScriptPubKeyMans() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Create new DescriptorScriptPubKeyMans and add them to the wallet.
WalletDatabase & GetDatabase() override
interfaces::Chain * m_chain
Interface for accessing chain state.
std::atomic< bool > m_attaching_chain
bool WithEncryptionKey(const std::function< bool(const CKeyingMaterial &)> &cb) const override
Pass the encryption key to cb().
LegacyScriptPubKeyMan * GetOrCreateLegacyScriptPubKeyMan()
std::map< OutputType, ScriptPubKeyMan * > m_external_spk_managers
void DeactivateScriptPubKeyMan(const uint256 &id, OutputType type, bool internal)
Remove specified ScriptPubKeyMan from set of active SPK managers.
bool GetDestData(const CTxDestination &dest, const std::string &key, std::string *value) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Look up a destination data tuple in the store, return true if found false otherwise.
bool IsLegacy() const
Determine if we are a legacy wallet.
std::atomic< bool > fAbortRescan
std::map< uint256, std::unique_ptr< ScriptPubKeyMan > > m_spk_managers
void LoadActiveScriptPubKeyMan(uint256 id, OutputType type, bool internal)
Loads an active ScriptPubKeyMan for the specified type and internal.
boost::signals2::signal< void(CWallet *wallet, const CTxDestination &address, const std::string &label, bool isMine, const std::string &purpose, ChangeType status)> NotifyAddressBookChanged
Address book entry changed.
int GetLastBlockHeight() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Get last block processed height.
boost::signals2::signal< void(CWallet *wallet)> NotifyStatusChanged
Wallet status (encrypted, locked) changed.
OutputType m_default_address_type
DescriptorScriptPubKeyMan * GetDescriptorScriptPubKeyMan(const WalletDescriptor &desc) const
Return the DescriptorScriptPubKeyMan for a WalletDescriptor if it is already in the wallet.
static bool AttachChain(const std::shared_ptr< CWallet > &wallet, interfaces::Chain &chain, bilingual_str &error, std::vector< bilingual_str > &warnings)
Catch wallet up to current chain, scanning new blocks, updating the best block locator and m_last_blo...
void LoadDescriptorScriptPubKeyMan(uint256 id, WalletDescriptor &desc)
Instantiate a descriptor ScriptPubKeyMan from the WalletDescriptor and load it.
LegacyScriptPubKeyMan * GetLegacyScriptPubKeyMan() const
Get the LegacyScriptPubKeyMan which is used for all types, internal, and external.
std::atomic< uint64_t > m_wallet_flags
const std::string & GetName() const
Get a name for this wallet for logging/debugging purposes.
bool CanSupportFeature(enum WalletFeature wf) const override EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
check whether we are allowed to upgrade (or already support) to the named feature
bool BackupWallet(const std::string &strDest) const
unsigned int ComputeTimeSmart(const CWalletTx &wtx) const
Compute smart timestamp for a transaction being added to the wallet.
void WalletLogPrintfToBeContinued(std::string fmt, Params... parameters) const
std::unique_ptr< WalletDatabase > database
Internal database handle.
ScriptPubKeyMan * AddWalletDescriptor(WalletDescriptor &desc, const FlatSigningProvider &signing_provider, const std::string &label, bool internal) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Add a descriptor to the wallet, return a ScriptPubKeyMan & associated output type.
std::set< ScriptPubKeyMan * > GetActiveScriptPubKeyMans() const
Returns all unique ScriptPubKeyMans in m_internal_spk_managers and m_external_spk_managers.
std::vector< std::string > GetDestValues(const std::string &prefix) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Get all destination values matching a prefix.
boost::signals2::signal< void(bool fHaveWatchOnly)> NotifyWatchonlyChanged
Watch-only address added.
bool IsLocked() const override
std::map< OutputType, ScriptPubKeyMan * > m_internal_spk_managers
std::atomic< double > m_scanning_progress
int GetVersion() const
get the current wallet format (the oldest client version guaranteed to understand this wallet)
void GetKeyBirthTimes(std::map< CKeyID, int64_t > &mapKeyBirth) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
bool EraseDestData(WalletBatch &batch, const CTxDestination &dest, const std::string &key) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Erases a destination data tuple in the store and on disk.
boost::signals2::signal< void(CWallet *wallet, const TxId &txid, ChangeType status)> NotifyTransactionChanged
Wallet transaction added, removed or updated.
static std::shared_ptr< CWallet > Create(WalletContext &context, const std::string &name, std::unique_ptr< WalletDatabase > database, uint64_t wallet_creation_flags, bilingual_str &error, std::vector< bilingual_str > &warnings)
Initializes the wallet, returns a new CWallet instance or a null pointer in case of an error.
bool HasEncryptionKeys() const override
CWallet(interfaces::Chain *chain, const std::string &name, std::unique_ptr< WalletDatabase > _database)
Construct wallet with specified name and database implementation.
Amount m_default_max_tx_fee
Absolute maximum transaction fee (in satoshis) used by default for the wallet.
bool UpgradeWallet(int version, bilingual_str &error)
Upgrade the wallet.
bool fBroadcastTransactions
ScriptPubKeyMan * GetScriptPubKeyMan(const OutputType &type, bool internal) const
Get the ScriptPubKeyMan for the given OutputType and internal/external chain.
std::set< ScriptPubKeyMan * > GetAllScriptPubKeyMans() const
Returns all unique ScriptPubKeyMans.
std::multimap< int64_t, CWalletTx * > TxItems
std::string GetDisplayName() const override
Returns a bracketed wallet name for displaying in logs, will return [default wallet] if the wallet ha...
void LoadDestData(const CTxDestination &dest, const std::string &key, const std::string &value) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Adds a destination data tuple to the store, without saving it to disk.
unsigned int nMasterKeyMaxID
std::function< bool(CWalletTx &wtx, bool new_tx)> UpdateWalletTxFn
Callback for updating transaction metadata in mapWallet.
void postInitProcess()
Wallet post-init setup Gives the wallet a chance to register repetitive tasks and complete post-init ...
const CAddressBookData * FindAddressBookEntry(const CTxDestination &, bool allow_change=false) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
A transaction with a bunch of additional info that only the owner cares about.
mapValue_t mapValue
Key/value map with information about the transaction.
bool isUnconfirmed() const
unsigned int nTimeSmart
Stable timestamp that never changes, and reflects the order a transaction was added to the wallet.
bool IsEquivalentTo(const CWalletTx &tx) const
bool isConflicted() const
std::vector< std::pair< std::string, std::string > > vOrderForm
bool fFromMe
From me flag is set to 1 for transactions that were created by the wallet on this bitcoin node,...
unsigned int fTimeReceivedIsTxTime
void MarkDirty()
make sure balances are recalculated
bool m_is_cache_empty
This flag is true if all m_amounts caches are empty.
std::multimap< int64_t, CWalletTx * >::const_iterator m_it_wtxOrdered
unsigned int nTimeReceived
time received by this node
int64_t nOrderPos
position in ordered transaction list
bool HasWalletDescriptor(const WalletDescriptor &desc) const
RecursiveMutex cs_KeyStore
Different type to mark Mutex at global scope.
std::set< CKeyID > GetKeys() const override
I randrange(I range) noexcept
Generate a random integer in the range [0..range), with range > 0.
A wrapper to reserve an address from a wallet.
bool fInternal
Whether this is from the internal (change output) keypool.
ScriptPubKeyMan * m_spk_man
The ScriptPubKeyMan to reserve from.
int64_t nIndex
The index of the address's key in the keypool.
CTxDestination address
The destination.
const CWallet *const pwallet
The wallet to reserve from.
A class implementing ScriptPubKeyMan manages some (or all) scriptPubKeys used in a wallet.
virtual bool TopUp(unsigned int size=0)
Fills internal address pool.
virtual bool GetReservedDestination(const OutputType type, bool internal, CTxDestination &address, int64_t &index, CKeyPool &keypool)
virtual void KeepDestination(int64_t index, const OutputType &type)
virtual void ReturnDestination(int64_t index, bool internal, const CTxDestination &addr)
Signature hash type wrapper class.
void push_back(UniValue val)
const std::vector< UniValue > & getValues() const
Access to the wallet database.
bool TxnCommit()
Commit current transaction.
bool WriteActiveScriptPubKeyMan(uint8_t type, const uint256 &id, bool internal)
bool WriteMasterKey(unsigned int nID, const CMasterKey &kMasterKey)
bool WriteName(const CTxDestination &address, const std::string &strName)
bool WritePurpose(const CTxDestination &address, const std::string &purpose)
bool WriteMinVersion(int nVersion)
bool ErasePurpose(const CTxDestination &address)
bool EraseDestData(const CTxDestination &address, const std::string &key)
Erase destination data tuple from wallet database.
bool WriteWalletFlags(const uint64_t flags)
bool ReadBestBlock(CBlockLocator &locator)
bool WriteOrderPosNext(int64_t nOrderPosNext)
bool EraseActiveScriptPubKeyMan(uint8_t type, bool internal)
bool WriteTx(const CWalletTx &wtx)
bool TxnBegin()
Begin a new transaction.
bool TxnAbort()
Abort current transaction.
bool EraseName(const CTxDestination &address)
bool WriteBestBlock(const CBlockLocator &locator)
DBErrors ZapSelectTx(std::vector< TxId > &txIdsIn, std::vector< TxId > &txIdsOut)
DBErrors LoadWallet(CWallet *pwallet)
bool WriteDestData(const CTxDestination &address, const std::string &key, const std::string &value)
Write destination data key,value tuple to database.
Descriptor with some wallet metadata.
std::shared_ptr< Descriptor > descriptor
RAII object to check and reserve a wallet rescan.
constexpr bool IsNull() const
constexpr uint8_t * begin()
std::string ToString() const
std::string GetHex() const
Path class wrapper to block calls to the fs::path(std::string) implicit constructor and the fs::path:...
Interface giving clients (wallet processes, maybe other analysis tools in the future) ability to acce...
virtual CBlockLocator getTipLocator()=0
Get locator for the current chain tip.
virtual std::optional< int > getHeight()=0
Get current chain height, not including genesis block (returns 0 if chain only contains genesis block...
virtual BlockHash getBlockHash(int height)=0
Get block hash. Height must be valid or this function will abort.
virtual bool findBlock(const BlockHash &hash, const FoundBlock &block={})=0
Return whether node has the block and optionally return block metadata or contents.
virtual std::unique_ptr< Handler > handleNotifications(std::shared_ptr< Notifications > notifications)=0
Register handler for notifications.
virtual bool updateRwSetting(const std::string &name, const util::SettingsValue &value, bool write=true)=0
Write a setting to <datadir>/settings.json.
virtual bool findFirstBlockWithTimeAndHeight(int64_t min_time, int min_height, const FoundBlock &block={})=0
Find first block in the chain with timestamp >= the given time and height >= than the given height,...
virtual bool broadcastTransaction(const Config &config, const CTransactionRef &tx, const Amount &max_tx_fee, bool relay, std::string &err_string)=0
Transaction is added to memory pool, if the transaction fee is below the amount specified by max_tx_f...
virtual util::SettingsValue getRwSetting(const std::string &name)=0
Return <datadir>/settings.json setting value.
virtual double guessVerificationProgress(const BlockHash &block_hash)=0
Estimate fraction of total transactions verified if blocks up to the specified block hash are verifie...
virtual const CChainParams & params() const =0
This Chain's parameters.
virtual bool havePruned()=0
Check if any block has been pruned.
virtual bool hasAssumedValidChain()=0
Return true if an assumed-valid chain is in use.
virtual bool findAncestorByHeight(const BlockHash &block_hash, int ancestor_height, const FoundBlock &ancestor_out={})=0
Find ancestor of block at specified height and optionally return ancestor information.
virtual void initMessage(const std::string &message)=0
Send init message.
virtual std::optional< int > findLocatorFork(const CBlockLocator &locator)=0
Return height of the highest block on chain in common with the locator, which will either be the orig...
virtual bool haveBlockOnDisk(int height)=0
Check that the block is available on disk (i.e.
virtual void requestMempoolTransactions(Notifications ¬ifications)=0
Synchronously send transactionAddedToMempool notifications about all current mempool transactions to ...
virtual void waitForNotificationsIfTipChanged(const BlockHash &old_tip)=0
Wait for pending notifications to be processed unless block hash points to the current chain tip.
virtual CFeeRate relayMinFee()=0
Relay current minimum fee (from -minrelaytxfee settings).
Helper for findBlock to selectively return pieces of block data.
void memory_cleanse(void *ptr, size_t len)
Secure overwrite a buffer (possibly containing secret data) with zero-bytes.
const Config & GetConfig()
static const int COINBASE_MATURITY
Coinbase transaction outputs can only be spent after this number of new blocks (network rule).
const unsigned int WALLET_CRYPTO_SALT_SIZE
std::vector< uint8_t, secure_allocator< uint8_t > > CKeyingMaterial
const unsigned int WALLET_CRYPTO_KEY_SIZE
bool TryCreateDirectories(const fs::path &p)
Ignores exceptions thrown by create_directories if the requested directory exists.
void LockCoin(const COutPoint &output) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
void MarkDestinationsDirty(const std::set< CTxDestination > &destinations) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Marks all outputs in each one of the destinations dirty, so their cache is reset and does not return ...
size_t KeypoolCountExternalKeys() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
std::optional< common::PSBTError > FillPSBT(PartiallySignedTransaction &psbtx, bool &complete, SigHashType sighash_type=SigHashType().withForkId(), bool sign=true, bool bip32derivs=true) const
Fills out a PSBT with information from the wallet.
util::Result< CTxDestination > GetNewDestination(const OutputType type, const std::string &label)
util::Result< CTxDestination > GetNewChangeDestination(const OutputType type)
void KeepDestination()
Keep the address.
void ListLockedCoins(std::vector< COutPoint > &vOutpts) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
unsigned int GetKeyPoolSize() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
std::set< CTxDestination > GetLabelAddresses(const std::string &label) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
bool IsLockedCoin(const COutPoint &outpoint) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
SigningResult SignMessage(const std::string &message, const PKHash &pkhash, std::string &str_sig) const
void UnlockCoin(const COutPoint &output) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
bool SetAddressBook(const CTxDestination &address, const std::string &strName, const std::string &purpose)
OutputType TransactionChangeType(const std::optional< OutputType > &change_type, const std::vector< CRecipient > &vecSend) const
bool SignTransaction(CMutableTransaction &tx) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
void ReturnDestination()
Return reserved address.
void UnlockAllCoins() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
bool TopUpKeyPool(unsigned int kpSize=0)
bool SetAddressBookWithDB(WalletBatch &batch, const CTxDestination &address, const std::string &strName, const std::string &strPurpose)
bool GetReservedDestination(CTxDestination &pubkey, bool internal)
Reserve an address.
int64_t GetOldestKeyPoolTime() const
bool DelAddressBook(const CTxDestination &address)
DBErrors ZapSelectTx(std::vector< TxId > &txIdsIn, std::vector< TxId > &txIdsOut) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
void CommitTransaction(CTransactionRef tx, mapValue_t mapValue, std::vector< std::pair< std::string, std::string > > orderForm, bool broadcast=true)
Add the transaction to the wallet and maybe attempt to broadcast it.
bool AddWalletFlags(uint64_t flags)
Overwrite all flags by the given uint64_t.
bool ImportPubKeys(const std::vector< CKeyID > &ordered_pubkeys, const std::map< CKeyID, CPubKey > &pubkey_map, const std::map< CKeyID, std::pair< CPubKey, KeyOriginInfo > > &key_origins, const bool add_keypool, const bool internal, const int64_t timestamp) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
bool LoadToWallet(const TxId &txid, const UpdateWalletTxFn &fill_wtx) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
void MarkConflicted(const BlockHash &hashBlock, int conflicting_height, const TxId &txid)
Mark a transaction (and its in-wallet descendants) as conflicting with a particular block.
void Flush()
Flush wallet (bitdb flush)
void UpgradeKeyMetadata() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Upgrade stored CKeyMetadata objects to store key origin info as KeyOriginInfo.
bool SetMaxVersion(int nVersion)
change which version we're allowed to upgrade to (note that this does not immediately imply upgrading...
std::set< TxId > GetConflicts(const TxId &txid) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Get wallet transactions that conflict with given transaction (spend same outputs)
bool SubmitTxMemoryPoolAndRelay(const CWalletTx &wtx, std::string &err_string, bool relay) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Pass this transaction to node for mempool insertion and relay to peers if flag set to true.
void AddToSpends(const COutPoint &outpoint, const TxId &wtxid) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
void SyncTransaction(const CTransactionRef &tx, CWalletTx::Confirmation confirm, bool update_tx=true) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Used by TransactionAddedToMemorypool/BlockConnected/Disconnected/ScanForWalletTransactions.
bool ImportScripts(const std::set< CScript > scripts, int64_t timestamp) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
CWalletTx * AddToWallet(CTransactionRef tx, const CWalletTx::Confirmation &confirm, const UpdateWalletTxFn &update_wtx=nullptr, bool fFlushOnClose=true)
bool HasWalletSpend(const TxId &txid) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Check if a given transaction has any of its outputs spent by another transaction in the wallet.
bool ChangeWalletPassphrase(const SecureString &strOldWalletPassphrase, const SecureString &strNewWalletPassphrase)
void BlockUntilSyncedToCurrentChain() const LOCKS_EXCLUDED(void SetWalletFlag(uint64_t flags)
Blocks until the wallet state is up-to-date to /at least/ the current chain at the time this function...
bool IsFromMe(const CTransaction &tx) const
should probably be renamed to IsRelevantToMe
bool ImportPrivKeys(const std::map< CKeyID, CKey > &privkey_map, const int64_t timestamp) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
void blockConnected(ChainstateRole role, const CBlock &block, int height) override
isminetype IsMine(const CTxDestination &dest) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
bool LoadWalletFlags(uint64_t flags)
Loads the flags into the wallet.
bool ImportScriptPubKeys(const std::string &label, const std::set< CScript > &script_pub_keys, const bool have_solving_data, const bool apply_label, const int64_t timestamp) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
bool CanGetAddresses(bool internal=false) const
Returns true if the wallet can give out new addresses.
ScanResult ScanForWalletTransactions(const BlockHash &start_block, int start_height, std::optional< int > max_height, const WalletRescanReserver &reserver, bool fUpdate)
Scan the block chain (starting in start_block) for transactions from or to us.
bool IsSpentKey(const TxId &txid, unsigned int n) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
bool TransactionCanBeAbandoned(const TxId &txid) const
Return whether transaction can be abandoned.
const CChainParams & GetChainParams() const override
Amount GetDebit(const CTxIn &txin, const isminefilter &filter) const
Returns amount of debit if the input matches the filter, otherwise returns 0.
void MarkInputsDirty(const CTransactionRef &tx) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Mark a transaction's inputs dirty, thus forcing the outputs to be recomputed.
bool AddToWalletIfInvolvingMe(const CTransactionRef &tx, CWalletTx::Confirmation confirm, bool fUpdate) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Add a transaction to the wallet, or update it.
bool IsSpent(const COutPoint &outpoint) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Outpoint is spent if any non-conflicted transaction, spends it:
void ReacceptWalletTransactions() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
void UnsetWalletFlagWithDB(WalletBatch &batch, uint64_t flag)
Unsets a wallet flag and saves it to disk.
void SyncMetaData(std::pair< TxSpends::iterator, TxSpends::iterator >) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
bool EncryptWallet(const SecureString &strWalletPassphrase)
void chainStateFlushed(ChainstateRole role, const CBlockLocator &loc) override
void updatedBlockTip() override
void UnsetWalletFlag(uint64_t flag)
Unsets a single wallet flag.
void transactionRemovedFromMempool(const CTransactionRef &tx, MemPoolRemovalReason reason, uint64_t mempool_sequence) override
bool IsWalletFlagSet(uint64_t flag) const override
Check if a certain wallet flag is set.
int64_t RescanFromTime(int64_t startTime, const WalletRescanReserver &reserver, bool update)
Scan active chain for relevant transactions after importing keys.
bool AbandonTransaction(const TxId &txid)
Mark a transaction (and it in-wallet descendants) as abandoned so its inputs may be respent.
void UnsetBlankWalletFlag(WalletBatch &batch) override
Unset the blank wallet flag and saves it to disk.
void SetSpentKeyState(WalletBatch &batch, const TxId &txid, unsigned int n, bool used, std::set< CTxDestination > &tx_destinations) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
void transactionAddedToMempool(const CTransactionRef &tx, uint64_t mempool_sequence) override
DBErrors ReorderTransactions()
void blockDisconnected(const CBlock &block, int height) override
void Close()
Close wallet database.
int64_t IncOrderPosNext(WalletBatch *batch=nullptr) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Increment the next transaction order id.
const CWalletTx * GetWalletTx(const TxId &txid) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
void ResendWalletTransactions()
void SetMinVersion(enum WalletFeature, WalletBatch *batch_in=nullptr, bool fExplicit=false) override
signify that a particular wallet feature is now used.
std::set< TxId > GetTxConflicts(const CWalletTx &wtx) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
bool DummySignInput(CTxIn &tx_in, const CTxOut &txout, bool use_max_sig=false) const
isminetype
IsMine() return codes.
ChainstateRole
This enum describes the various roles a specific Chainstate instance can take.
bool ParseMoney(const std::string &money_string, Amount &nRet)
Parse an amount denoted in full coins.
bilingual_str AmountErrMsg(const std::string &optname, const std::string &strValue)
bilingual_str AmountHighWarn(const std::string &optname)
static path u8path(const std::string &utf8_str)
static auto quoted(const std::string &s)
static bool exists(const path &p)
static bool copy_file(const path &from, const path &to, copy_options options)
static std::string PathToString(const path &path)
Convert path object to byte string.
static path PathFromString(const std::string &string)
Convert byte string to path object.
fs::path AbsPathJoin(const fs::path &base, const fs::path &path)
Helper function for joining two paths.
std::unique_ptr< Wallet > MakeWallet(const std::shared_ptr< CWallet > &wallet)
std::unique_ptr< Handler > MakeHandler(boost::signals2::connection connection)
Return handler wrapping a boost signal connection.
void ReplaceAll(std::string &in_out, const std::string &search, const std::string &substitute)
const std::string & FormatOutputType(OutputType type)
const std::array< OutputType, 1 > OUTPUT_TYPES
std::shared_ptr< const CTransaction > CTransactionRef
bool PSBTInputSigned(const PSBTInput &input)
Checks whether a PSBTInput is already signed.
void GetStrongRandBytes(Span< uint8_t > bytes) noexcept
Gather entropy from various sources, feed it into the internal PRNG, and generate random data using i...
std::vector< CKeyID > GetAffectedKeys(const CScript &spk, const SigningProvider &provider)
std::basic_string< char, std::char_traits< char >, secure_allocator< char > > SecureString
static std::string ToString(const CService &ip)
bool ProduceSignature(const SigningProvider &provider, const BaseSignatureCreator &creator, const CScript &fromPubKey, SignatureData &sigdata)
Produce a script signature using a generic signature creator.
void UpdateInput(CTxIn &input, const SignatureData &data)
const BaseSignatureCreator & DUMMY_MAXIMUM_SIGNATURE_CREATOR
A signature creator that just produces 72-byte empty signatures.
const BaseSignatureCreator & DUMMY_SIGNATURE_CREATOR
A signature creator that just produces 71-byte empty signatures.
@ PRIVATE_KEY_NOT_AVAILABLE
bool ExtractDestination(const CScript &scriptPubKey, CTxDestination &addressRet)
Parse a standard scriptPubKey for the destination address.
bool IsValidDestination(const CTxDestination &dest)
Check whether a CTxDestination is a CNoDestination.
CScript GetScriptForDestination(const CTxDestination &dest)
Generate a Bitcoin scriptPubKey for the given CTxDestination.
std::variant< CNoDestination, PKHash, ScriptHash > CTxDestination
A txout script template with a specific destination.
static constexpr Amount zero() noexcept
A BlockHash is a unqiue identifier for a block.
Describes a place in the block chain to another node such that if the other node doesn't have the sam...
void SetSeed(Span< const std::byte > seed)
std::optional< int > last_scanned_height
BlockHash last_scanned_block
Hash and height of most recent block that was successfully scanned.
BlockHash last_failed_block
Hash of the most recent block that could not be scanned due to read errors or pruning.
enum CWallet::ScanResult::@19 status
Confirmation includes tx status and a triplet of {block height/block hash/tx index in block} at which...
SecureString create_passphrase
std::map< CKeyID, CKey > keys
A version of CTransaction with the PSBT format.
std::vector< PSBTInput > inputs
std::optional< CMutableTransaction > tx
A TxId is the identifier of a transaction.
WalletContext struct containing references to state shared between CWallet instances,...
interfaces::Chain * chain
#define WAIT_LOCK(cs, name)
#define AssertLockNotHeld(cs)
#define WITH_LOCK(cs, code)
Run code while locking a mutex.
std::string ShellEscape(const std::string &arg)
int64_t GetTimeMillis()
Returns the system time (not mockable)
int64_t GetTime()
DEPRECATED Use either ClockType::now() or Now<TimePointType>() if a cast is needed.
std::chrono::duration< double, std::chrono::milliseconds::period > MillisecondsDouble
bilingual_str _(const char *psz)
Translation function.
bilingual_str Untranslated(std::string original)
Mark a bilingual_str as untranslated.
MemPoolRemovalReason
Reason why a transaction was removed from the mempool, this is passed to the notification signal.
@ BLOCK
Removed for block.
@ CONFLICT
Removed for conflict with in-block transaction.
std::function< void(std::unique_ptr< interfaces::Wallet > wallet)> LoadWalletFn
std::unique_ptr< WalletDatabase > MakeDatabase(const fs::path &path, const DatabaseOptions &options, DatabaseStatus &status, bilingual_str &error)
@ FAILED_INVALID_BACKUP_FILE
std::map< std::string, std::string > mapValue_t
constexpr Amount HIGH_TX_FEE_PER_KB
Discourage users to set fees higher than this amount (in satoshis) per kB.
constexpr OutputType DEFAULT_ADDRESS_TYPE
Default for -addresstype.
constexpr Amount HIGH_MAX_TX_FEE
-maxtxfee will warn if called with a higher fee than this amount (in satoshis)
static const bool DEFAULT_SPEND_ZEROCONF_CHANGE
Default for -spendzeroconfchange.
static constexpr uint64_t KNOWN_WALLET_FLAGS
static const bool DEFAULT_WALLETBROADCAST
constexpr Amount HIGH_APS_FEE
discourage APS fee higher than this amount
std::unique_ptr< interfaces::Handler > HandleLoadWallet(WalletContext &context, LoadWalletFn load_wallet)
std::unique_ptr< WalletDatabase > MakeWalletDatabase(const std::string &name, const DatabaseOptions &options, DatabaseStatus &status, bilingual_str &error_string)
const std::map< uint64_t, std::string > WALLET_FLAG_CAVEATS
bool RemoveWallet(WalletContext &context, const std::shared_ptr< CWallet > &wallet, std::optional< bool > load_on_start, std::vector< bilingual_str > &warnings)
void MaybeResendWalletTxs(WalletContext &context)
Called periodically by the schedule thread.
static std::condition_variable g_wallet_release_cv
bool AddWallet(WalletContext &context, const std::shared_ptr< CWallet > &wallet)
static void FlushAndDeleteWallet(CWallet *wallet)
void WaitForDeleteWallet(std::shared_ptr< CWallet > &&wallet)
Explicitly delete the wallet.
static GlobalMutex g_loading_wallet_mutex
std::vector< std::shared_ptr< CWallet > > GetWallets(WalletContext &context)
bool AddWalletSetting(interfaces::Chain &chain, const std::string &wallet_name)
Add wallet name to persistent configuration so it will be loaded on startup.
std::shared_ptr< CWallet > RestoreWallet(WalletContext &context, const fs::path &backup_file, const std::string &wallet_name, std::optional< bool > load_on_start, DatabaseStatus &status, bilingual_str &error, std::vector< bilingual_str > &warnings)
bool RemoveWalletSetting(interfaces::Chain &chain, const std::string &wallet_name)
Remove wallet name from persistent configuration so it will not be loaded on startup.
std::shared_ptr< CWallet > GetWallet(WalletContext &context, const std::string &name)
static void UpdateWalletSetting(interfaces::Chain &chain, const std::string &wallet_name, std::optional< bool > load_on_startup, std::vector< bilingual_str > &warnings)
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)
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)
static GlobalMutex g_wallet_release_mutex
static std::set< std::string > g_loading_wallet_set GUARDED_BY(g_loading_wallet_mutex)
void NotifyWalletLoaded(WalletContext &context, const std::shared_ptr< CWallet > &wallet)
DBErrors
Error statuses for the wallet database.
fs::path GetWalletDir()
Get the path of the wallet directory.
@ WALLET_FLAG_DISABLE_PRIVATE_KEYS
@ WALLET_FLAG_AVOID_REUSE
@ WALLET_FLAG_KEY_ORIGIN_METADATA
@ WALLET_FLAG_DESCRIPTORS
Indicate that this wallet supports DescriptorScriptPubKeyMan.
@ WALLET_FLAG_BLANK_WALLET
Flag set when a wallet contains no HD seed and no private keys, scripts, addresses,...
WalletFeature
(client) version numbers for particular wallet features
@ FEATURE_PRE_SPLIT_KEYPOOL