26 error =
_(
"Error: Keypool ran out, please call keypoolrefill first")
62 bool HaveKeys(
const std::vector<valtype> &pubkeys,
64 for (
const valtype &pubkey : pubkeys) {
78 std::vector<valtype> vSolutions;
89 ret = std::max(ret, IsMineResult::SPENDABLE);
95 ret = std::max(ret, IsMineResult::SPENDABLE);
99 if (sigversion != IsMineSigVersion::TOP) {
101 return IsMineResult::INVALID;
105 if (keystore.
GetCScript(scriptID, subscript)) {
106 ret = std::max(ret, IsMineInner(keystore, subscript,
107 IsMineSigVersion::P2SH));
114 if (sigversion == IsMineSigVersion::TOP) {
123 std::vector<valtype> keys(vSolutions.begin() + 1,
124 vSolutions.begin() + vSolutions.size() -
126 if (HaveKeys(keys, keystore)) {
127 ret = std::max(ret, IsMineResult::SPENDABLE);
133 if (ret == IsMineResult::NO && keystore.
HaveWatchOnly(scriptPubKey)) {
134 ret = std::max(ret, IsMineResult::WATCH_ONLY);
142 switch (IsMineInner(*
this, script, IsMineSigVersion::TOP)) {
143 case IsMineResult::INVALID:
144 case IsMineResult::NO:
146 case IsMineResult::WATCH_ONLY:
148 case IsMineResult::SPENDABLE:
158 assert(mapKeys.empty());
161 bool keyPass = mapCryptedKeys.empty();
162 bool keyFail =
false;
163 CryptedKeyMap::const_iterator mi = mapCryptedKeys.begin();
164 for (; mi != mapCryptedKeys.end(); ++mi) {
165 const CPubKey &vchPubKey = (*mi).second.first;
166 const std::vector<uint8_t> &vchCryptedSecret = (*mi).second.second;
168 if (!
DecryptKey(master_key, vchCryptedSecret, vchPubKey, key)) {
177 if (keyPass && keyFail) {
178 LogPrintf(
"The wallet is probably corrupted: Some keys decrypt but " 180 throw std::runtime_error(
181 "Error unlocking wallet: some keys decrypt but not all. Your " 182 "wallet file may be corrupt.");
184 if (keyFail || (!keyPass && !accept_no_keys)) {
195 encrypted_batch = batch;
196 if (!mapCryptedKeys.empty()) {
197 encrypted_batch =
nullptr;
203 keys_to_encrypt.swap(mapKeys);
204 for (
const KeyMap::value_type &mKey : keys_to_encrypt) {
205 const CKey &key = mKey.second;
208 std::vector<uint8_t> vchCryptedSecret;
211 encrypted_batch =
nullptr;
215 encrypted_batch =
nullptr;
219 encrypted_batch =
nullptr;
244 std::map<CKeyID, int64_t>::const_iterator mi =
248 "key up to this key as used\n",
254 "%s: Topping up keypool failed (locked wallet)\n",
269 for (
auto &meta_pair : mapKeyMetadata) {
281 std::copy(master_id.
begin(), master_id.
begin() + 4,
284 throw std::runtime_error(
"Invalid stored hdKeypath");
293 if (
GetPubKey(meta_pair.first, pubkey)) {
294 batch->WriteKeyMetadata(meta, pubkey,
true);
319 bool keypool_has_keys;
321 keypool_has_keys = setInternalKeyPool.size() > 0;
326 if (!keypool_has_keys) {
329 return keypool_has_keys;
334 bool hd_upgrade =
false;
335 bool split_upgrade =
false;
359 error =
_(
"Unable to generate keys");
368 return !mapKeys.empty() || !mapCryptedKeys.empty();
373 setInternalKeyPool.clear();
374 setExternalKeyPool.clear();
383 if (setKeyPool.empty()) {
388 int64_t nIndex = *(setKeyPool.begin());
389 if (!batch.
ReadPool(nIndex, keypool)) {
390 throw std::runtime_error(std::string(__func__) +
391 ": read oldest key in keypool failed");
395 return keypool.
nTime;
408 if (!set_pre_split_keypool.empty()) {
420 return setExternalKeyPool.size() + set_pre_split_keypool.size();
425 return setInternalKeyPool.size() + setExternalKeyPool.size() +
426 set_pre_split_keypool.size();
431 return nTimeFirstKey;
434 std::unique_ptr<SigningProvider>
436 return std::make_unique<LegacySigningProvider>(*this);
456 bool has_privkeys =
false;
457 for (
const auto &key_sig_pair : sigdata.
signatures) {
458 has_privkeys |=
HaveKey(key_sig_pair.first);
467 SigHashType sighash, std::map<int, std::string> &input_errors)
const {
473 std::string &str_sig)
const {
476 if (!
GetKey(key_id, key)) {
489 bool bip32derivs)
const {
490 for (
size_t i = 0; i < psbtx.
tx->vin.size(); ++i) {
521 for (
size_t i = 0; i < psbtx.
tx->vout.size(); ++i) {
529 std::unique_ptr<CKeyMetadata>
535 auto it = mapKeyMetadata.find(key_id);
536 if (it != mapKeyMetadata.end()) {
537 return std::make_unique<CKeyMetadata>(it->second);
542 auto it = m_script_metadata.find(
CScriptID(scriptPubKey));
543 if (it != m_script_metadata.end()) {
544 return std::make_unique<CKeyMetadata>(it->second);
560 if (nCreateTime <= 1) {
564 }
else if (!nTimeFirstKey || nCreateTime < nTimeFirstKey) {
565 nTimeFirstKey = nCreateTime;
591 bool needsDB = !encrypted_batch;
593 encrypted_batch = &batch;
597 encrypted_batch =
nullptr;
603 encrypted_batch =
nullptr;
620 mapKeyMetadata[pubkey.
GetID()]);
633 std::string strAddr =
636 "of size %i which exceeds maximum size %i thus can " 637 "never be redeemed. Do not use address %s.\n",
650 mapKeyMetadata[keyID] = meta;
657 m_script_metadata[script_id] = meta;
671 std::vector<uint8_t> vchCryptedSecret;
674 pubkey.
GetHash(), vchCryptedSecret)) {
685 const CPubKey &vchPubKey,
const std::vector<uint8_t> &vchCryptedSecret) {
690 const CPubKey &vchPubKey,
const std::vector<uint8_t> &vchCryptedSecret) {
692 assert(mapKeys.empty());
694 mapCryptedKeys[vchPubKey.
GetID()] = make_pair(vchPubKey, vchCryptedSecret);
699 const CPubKey &vchPubKey,
const std::vector<uint8_t> &vchCryptedSecret) {
705 if (encrypted_batch) {
706 return encrypted_batch->WriteCryptedKey(
707 vchPubKey, vchCryptedSecret, mapKeyMetadata[vchPubKey.
GetID()]);
711 .WriteCryptedKey(vchPubKey, vchCryptedSecret,
712 mapKeyMetadata[vchPubKey.
GetID()]);
717 return setWatchOnly.count(dest) > 0;
722 return (!setWatchOnly.empty());
726 std::vector<std::vector<uint8_t>> solutions;
728 (pubKeyOut =
CPubKey(solutions[0])).IsFullyValid();
734 setWatchOnly.erase(dest);
737 mapWatchKeys.erase(pubKey.
GetID());
754 setWatchOnly.insert(dest);
757 mapWatchKeys[pubKey.
GetID()] = pubKey;
780 int64_t create_time) {
781 m_script_metadata[
CScriptID(dest)].nCreateTime = create_time;
791 int64_t nCreateTime) {
792 m_script_metadata[
CScriptID(dest)].nCreateTime = nCreateTime;
799 throw std::runtime_error(std::string(__func__) +
800 ": writing chain failed");
811 return mapCryptedKeys.count(address) > 0;
820 CryptedKeyMap::const_iterator mi = mapCryptedKeys.find(address);
821 if (mi != mapCryptedKeys.end()) {
822 const CPubKey &vchPubKey = (*mi).second.first;
823 const std::vector<uint8_t> &vchCryptedSecret = (*mi).second.second;
835 auto it = mapKeyMetadata.find(keyID);
836 if (it != mapKeyMetadata.end()) {
854 WatchKeyMap::const_iterator it = mapWatchKeys.find(address);
855 if (it != mapWatchKeys.end()) {
856 pubkey_out = it->second;
872 CryptedKeyMap::const_iterator mi = mapCryptedKeys.find(address);
873 if (mi != mapCryptedKeys.end()) {
874 vchPubKeyOut = (*mi).second.first;
893 int64_t nCreationTime =
GetTime();
900 batch, metadata, secret,
914 mapKeyMetadata[pubkey.
GetID()] = metadata;
918 throw std::runtime_error(std::string(__func__) +
": AddKey failed");
928 CKey &secret,
bool internal) {
943 throw std::runtime_error(std::string(__func__) +
": seed not found");
955 accountKey.
Derive(chainChildKey,
986 secret = childKey.
key;
989 std::copy(master_id.
begin(), master_id.
begin() + 4,
994 throw std::runtime_error(std::string(__func__) +
995 ": Writing HD chain model failed");
1003 set_pre_split_keypool.insert(nIndex);
1005 setInternalKeyPool.insert(nIndex);
1007 setExternalKeyPool.insert(nIndex);
1009 m_max_keypool_index = std::max(m_max_keypool_index, nIndex);
1016 if (mapKeyMetadata.count(keyid) == 0) {
1036 int64_t nCreationTime =
GetTime();
1051 mapKeyMetadata[seed.
GetID()] = metadata;
1055 throw std::runtime_error(std::string(__func__) +
1056 ": AddKeyPubKey failed");
1088 for (
const int64_t nIndex : setInternalKeyPool) {
1091 setInternalKeyPool.clear();
1093 for (
const int64_t nIndex : setExternalKeyPool) {
1094 batch.ErasePool(nIndex);
1096 setExternalKeyPool.clear();
1098 for (int64_t nIndex : set_pre_split_keypool) {
1099 batch.ErasePool(nIndex);
1101 set_pre_split_keypool.clear();
1109 WalletLogPrintf(
"LegacyScriptPubKeyMan::NewKeyPool rewrote keypool\n");
1125 unsigned int nTargetSize;
1127 nTargetSize = kpSize;
1129 nTargetSize = std::max<int64_t>(
1136 int64_t missingExternal = std::max<int64_t>(
1137 std::max<int64_t>(nTargetSize, 1) - setExternalKeyPool.size(), 0);
1138 int64_t missingInternal = std::max<int64_t>(
1139 std::max<int64_t>(nTargetSize, 1) - setInternalKeyPool.size(), 0);
1143 missingInternal = 0;
1145 bool internal =
false;
1147 for (int64_t i = missingInternal + missingExternal; i--;) {
1148 if (i < missingInternal) {
1155 if (missingInternal + missingExternal > 0) {
1157 "keypool added %d keys (%d internal), size=%u (%u internal)\n",
1158 missingInternal + missingExternal, missingInternal,
1159 setInternalKeyPool.size() + setExternalKeyPool.size() +
1160 set_pre_split_keypool.size(),
1161 setInternalKeyPool.size());
1169 const bool internal,
1173 assert(m_max_keypool_index < std::numeric_limits<int64_t>::max());
1174 int64_t index = ++m_max_keypool_index;
1176 throw std::runtime_error(std::string(__func__) +
1177 ": writing imported pubkey failed");
1180 setInternalKeyPool.insert(index);
1182 setExternalKeyPool.insert(index);
1206 setInternalKeyPool.insert(nIndex);
1207 }
else if (!set_pre_split_keypool.empty()) {
1208 set_pre_split_keypool.insert(nIndex);
1210 setExternalKeyPool.insert(nIndex);
1249 bool fRequestedInternal) {
1255 bool fReturningInternal = fRequestedInternal;
1256 fReturningInternal &=
1259 bool use_split_keypool = set_pre_split_keypool.empty();
1260 std::set<int64_t> &setKeyPool =
1262 ? (fReturningInternal ? setInternalKeyPool : setExternalKeyPool)
1263 : set_pre_split_keypool;
1266 if (setKeyPool.empty()) {
1272 auto it = setKeyPool.begin();
1274 setKeyPool.erase(it);
1275 if (!batch.ReadPool(nIndex, keypool)) {
1276 throw std::runtime_error(std::string(__func__) +
": read failed");
1280 throw std::runtime_error(std::string(__func__) +
1281 ": unknown key in key pool");
1284 if (use_split_keypool && keypool.
fInternal != fReturningInternal) {
1285 throw std::runtime_error(std::string(__func__) +
1286 ": keypool entry misclassified");
1289 throw std::runtime_error(std::string(__func__) +
1290 ": keypool entry invalid");
1313 bool internal = setInternalKeyPool.count(keypool_id);
1315 assert(setExternalKeyPool.count(keypool_id) ||
1316 set_pre_split_keypool.count(keypool_id));
1319 std::set<int64_t> *setKeyPool =
1320 internal ? &setInternalKeyPool
1321 : (set_pre_split_keypool.empty() ? &setExternalKeyPool
1322 : &set_pre_split_keypool);
1323 auto it = setKeyPool->begin();
1326 while (it != std::end(*setKeyPool)) {
1327 const int64_t &index = *(it);
1328 if (index > keypool_id) {
1334 if (batch.ReadPool(index, keypool)) {
1339 batch.ErasePool(index);
1341 it = setKeyPool->erase(it);
1347 std::vector<CScript> dummy;
1351 std::vector<CKeyID> ret;
1352 for (
const auto &entry : out.
pubkeys) {
1353 ret.push_back(entry.first);
1360 for (
auto it = setExternalKeyPool.begin();
1361 it != setExternalKeyPool.end();) {
1362 int64_t index = *it;
1364 if (!batch.ReadPool(index, keypool)) {
1365 throw std::runtime_error(std::string(__func__) +
1366 ": read keypool entry failed");
1369 if (!batch.WritePool(index, keypool)) {
1370 throw std::runtime_error(std::string(__func__) +
1371 ": writing modified keypool entry failed");
1373 set_pre_split_keypool.insert(index);
1374 it = setExternalKeyPool.erase(it);
1384 const CScript &redeemScript) {
1400 mapKeyMetadata[pubkey.
GetID()].key_origin.fingerprint);
1401 mapKeyMetadata[pubkey.
GetID()].key_origin.path = info.
path;
1402 mapKeyMetadata[pubkey.
GetID()].has_key_origin =
true;
1408 int64_t timestamp) {
1410 for (
const auto &entry : scripts) {
1421 if (timestamp > 0) {
1422 m_script_metadata[
CScriptID(entry)].nCreateTime = timestamp;
1425 if (timestamp > 0) {
1433 const std::map<CKeyID, CKey> &privkey_map,
const int64_t timestamp) {
1435 for (
const auto &entry : privkey_map) {
1436 const CKey &key = entry.second;
1438 const CKeyID &
id = entry.first;
1446 mapKeyMetadata[id].nCreateTime = timestamp;
1457 const std::vector<CKeyID> &ordered_pubkeys,
1458 const std::map<CKeyID, CPubKey> &pubkey_map,
1459 const std::map<
CKeyID, std::pair<CPubKey, KeyOriginInfo>> &key_origins,
1460 const bool add_keypool,
const bool internal,
const int64_t timestamp) {
1462 for (
const auto &entry : key_origins) {
1465 for (
const CKeyID &
id : ordered_pubkeys) {
1466 auto entry = pubkey_map.find(
id);
1467 if (entry == pubkey_map.end()) {
1470 const CPubKey &pubkey = entry->second;
1481 mapKeyMetadata[id].nCreateTime = timestamp;
1493 const std::set<CScript> &script_pub_keys,
const bool have_solving_data,
1494 const int64_t timestamp) {
1496 for (
const CScript &script : script_pub_keys) {
1497 if (!have_solving_data || !
IsMine(script)) {
1513 std::set<CKeyID> set_address;
1514 for (
const auto &mi : mapCryptedKeys) {
1515 set_address.insert(mi.first);
1524 std::string &
error) {
1529 error =
"No addresses available";
1535 assert(m_wallet_descriptor.descriptor->IsSingleType());
1536 if (type != m_address_type) {
1537 throw std::runtime_error(std::string(__func__) +
1538 ": Types are inconsistent");
1545 std::vector<CScript> scripts_temp;
1546 if (m_wallet_descriptor.range_end <= m_max_cached_index && !
TopUp(1)) {
1548 error =
"Error: Keypool ran out, please call keypoolrefill first";
1551 if (!m_wallet_descriptor.descriptor->ExpandFromCache(
1552 m_wallet_descriptor.next_index, m_wallet_descriptor.cache,
1553 scripts_temp, out_keys)) {
1555 error =
"Error: Keypool ran out, please call keypoolrefill first";
1559 std::optional<OutputType> out_script_type =
1560 m_wallet_descriptor.descriptor->GetOutputType();
1561 if (out_script_type && out_script_type == type) {
1564 throw std::runtime_error(
1565 std::string(__func__) +
1566 ": Types are inconsistent. Stored type does not match type of " 1567 "newly generated address");
1569 m_wallet_descriptor.next_index++;
1571 .WriteDescriptor(
GetID(), m_wallet_descriptor);
1578 if (m_map_script_pub_keys.count(script) > 0) {
1587 if (!m_map_keys.empty()) {
1592 bool keyPass = m_map_crypted_keys.empty();
1593 bool keyFail =
false;
1594 for (
const auto &mi : m_map_crypted_keys) {
1595 const CPubKey &pubkey = mi.second.first;
1596 const std::vector<uint8_t> &crypted_secret = mi.second.second;
1598 if (!
DecryptKey(master_key, crypted_secret, pubkey, key)) {
1603 if (m_decryption_thoroughly_checked) {
1607 if (keyPass && keyFail) {
1608 LogPrintf(
"The wallet is probably corrupted: Some keys decrypt but not " 1610 throw std::runtime_error(
1611 "Error unlocking wallet: some keys decrypt but not all. Your " 1612 "wallet file may be corrupt.");
1614 if (keyFail || (!keyPass && !accept_no_keys)) {
1617 m_decryption_thoroughly_checked =
true;
1624 if (!m_map_crypted_keys.empty()) {
1628 for (
const KeyMap::value_type &key_in : m_map_keys) {
1629 const CKey &key = key_in.second;
1632 std::vector<uint8_t> crypted_secret;
1637 m_map_crypted_keys[pubkey.
GetID()] = make_pair(pubkey, crypted_secret);
1652 index = m_wallet_descriptor.next_index - 1;
1660 if (m_wallet_descriptor.next_index - 1 == index) {
1661 m_wallet_descriptor.next_index--;
1664 .WriteDescriptor(
GetID(), m_wallet_descriptor);
1672 for (
auto key_pair : m_map_crypted_keys) {
1673 const CPubKey &pubkey = key_pair.second.first;
1674 const std::vector<uint8_t> &crypted_secret = key_pair.second.second;
1678 keys[pubkey.GetID()] = key;
1687 unsigned int target_size;
1696 int32_t new_range_end =
1697 std::max(m_wallet_descriptor.next_index + int32_t(target_size),
1698 m_wallet_descriptor.range_end);
1702 if (!m_wallet_descriptor.descriptor->IsRange()) {
1704 m_wallet_descriptor.range_end = 1;
1705 m_wallet_descriptor.range_start = 0;
1713 for (int32_t i = m_max_cached_index + 1; i < new_range_end; ++i) {
1715 std::vector<CScript> scripts_temp;
1718 if (!m_wallet_descriptor.descriptor->ExpandFromCache(
1719 i, m_wallet_descriptor.cache, scripts_temp, out_keys)) {
1720 if (!m_wallet_descriptor.descriptor->Expand(
1721 i, provider, scripts_temp, out_keys, &temp_cache)) {
1726 for (
const CScript &script : scripts_temp) {
1727 m_map_script_pub_keys[script] = i;
1729 for (
const auto &pk_pair : out_keys.
pubkeys) {
1730 const CPubKey &pubkey = pk_pair.second;
1731 if (m_map_pubkeys.count(pubkey) != 0) {
1738 m_map_pubkeys[pubkey] = i;
1741 for (
const auto &parent_xpub_pair :
1744 if (m_wallet_descriptor.cache.GetCachedParentExtPubKey(
1745 parent_xpub_pair.first, xpub)) {
1746 if (xpub != parent_xpub_pair.second) {
1747 throw std::runtime_error(
1748 std::string(__func__) +
1749 ": New cached parent xpub does not match already " 1750 "cached parent xpub");
1754 if (!batch.WriteDescriptorParentCache(parent_xpub_pair.second,
id,
1755 parent_xpub_pair.first)) {
1756 throw std::runtime_error(std::string(__func__) +
1757 ": writing cache item failed");
1759 m_wallet_descriptor.cache.CacheParentExtPubKey(
1760 parent_xpub_pair.first, parent_xpub_pair.second);
1762 for (
const auto &derived_xpub_map_pair :
1764 for (
const auto &derived_xpub_pair : derived_xpub_map_pair.second) {
1766 if (m_wallet_descriptor.cache.GetCachedDerivedExtPubKey(
1767 derived_xpub_map_pair.first, derived_xpub_pair.first,
1769 if (xpub != derived_xpub_pair.second) {
1770 throw std::runtime_error(
1771 std::string(__func__) +
1772 ": New cached derived xpub does not match already " 1773 "cached derived xpub");
1777 if (!batch.WriteDescriptorDerivedCache(
1778 derived_xpub_pair.second,
id,
1779 derived_xpub_map_pair.first, derived_xpub_pair.first)) {
1780 throw std::runtime_error(std::string(__func__) +
1781 ": writing cache item failed");
1783 m_wallet_descriptor.cache.CacheDerivedExtPubKey(
1784 derived_xpub_map_pair.first, derived_xpub_pair.first,
1785 derived_xpub_pair.second);
1788 m_max_cached_index++;
1790 m_wallet_descriptor.range_end = new_range_end;
1791 batch.WriteDescriptor(
GetID(), m_wallet_descriptor);
1794 assert(m_wallet_descriptor.range_end - 1 == m_max_cached_index);
1803 int32_t index = m_map_script_pub_keys[script];
1804 if (index >= m_wallet_descriptor.next_index) {
1806 "mark all keypool items up to this item as used\n",
1808 m_wallet_descriptor.next_index = index + 1;
1821 if (!AddDescriptorKeyWithDB(batch, key, pubkey)) {
1822 throw std::runtime_error(std::string(__func__) +
1823 ": writing descriptor private key failed");
1838 std::vector<uint8_t> crypted_secret;
1841 pubkey.
GetHash(), crypted_secret)) {
1845 m_map_crypted_keys[pubkey.
GetID()] = make_pair(pubkey, crypted_secret);
1848 m_map_keys[pubkey.
GetID()] = key;
1859 if (m_wallet_descriptor.descriptor) {
1863 int64_t creation_time =
GetTime();
1868 std::string desc_prefix;
1869 std::string desc_suffix =
"/*)";
1870 switch (m_address_type) {
1872 desc_prefix =
"pkh(" + xpub +
"/44'";
1881 desc_prefix +=
"/1'";
1883 desc_prefix +=
"/0'";
1886 std::string internal_path = m_internal ?
"/1" :
"/0";
1887 std::string desc_str = desc_prefix +
"/0'" + internal_path + desc_suffix;
1892 std::unique_ptr<Descriptor> desc =
Parse(desc_str, keys, error,
false);
1894 m_wallet_descriptor = w_desc;
1898 if (!AddDescriptorKeyWithDB(batch, master_key.
key,
1900 throw std::runtime_error(
1901 std::string(__func__) +
1902 ": writing descriptor master private key failed");
1904 if (!batch.WriteDescriptor(
GetID(), m_wallet_descriptor)) {
1905 throw std::runtime_error(std::string(__func__) +
1906 ": writing descriptor failed");
1918 return m_wallet_descriptor.descriptor->IsRange();
1926 return m_wallet_descriptor.descriptor->IsSingleType() &&
1927 m_wallet_descriptor.descriptor->IsRange() &&
1929 m_wallet_descriptor.next_index < m_wallet_descriptor.range_end);
1934 return m_map_keys.size() > 0 || m_map_crypted_keys.size() > 0;
1953 return m_wallet_descriptor.range_end - m_wallet_descriptor.next_index;
1958 return m_wallet_descriptor.creation_time;
1961 std::unique_ptr<FlatSigningProvider>
1963 bool include_private)
const {
1967 auto it = m_map_script_pub_keys.find(script);
1968 if (it == m_map_script_pub_keys.end()) {
1971 int32_t index = it->second;
1973 return GetSigningProvider(index, include_private);
1976 std::unique_ptr<FlatSigningProvider>
1981 auto it = m_map_pubkeys.find(pubkey);
1982 if (it == m_map_pubkeys.end()) {
1985 int32_t index = it->second;
1989 return GetSigningProvider(index,
true);
1992 std::unique_ptr<FlatSigningProvider>
1994 bool include_private)
const {
1997 std::unique_ptr<FlatSigningProvider> out_keys =
1998 std::make_unique<FlatSigningProvider>();
1999 std::vector<CScript> scripts_temp;
2000 if (!m_wallet_descriptor.descriptor->ExpandFromCache(
2001 index, m_wallet_descriptor.cache, scripts_temp, *out_keys)) {
2008 m_wallet_descriptor.descriptor->ExpandPrivate(index, master_provider,
2015 std::unique_ptr<SigningProvider>
2017 return GetSigningProvider(script,
false);
2027 SigHashType sighash, std::map<int, std::string> &input_errors)
const {
2028 std::unique_ptr<FlatSigningProvider> keys =
2029 std::make_unique<FlatSigningProvider>();
2030 for (
const auto &coin_pair : coins) {
2031 std::unique_ptr<FlatSigningProvider> coin_keys =
2032 GetSigningProvider(coin_pair.second.GetTxOut().scriptPubKey,
true);
2036 *keys =
Merge(*keys, *coin_keys);
2045 std::string &str_sig)
const {
2046 std::unique_ptr<FlatSigningProvider> keys =
2054 if (!keys->GetKey(key_id, key)) {
2067 bool bip32derivs)
const {
2068 for (
size_t i = 0; i < psbtx.
tx->vin.size(); ++i) {
2098 std::unique_ptr<FlatSigningProvider> keys =
2099 std::make_unique<FlatSigningProvider>();
2100 std::unique_ptr<FlatSigningProvider> script_keys =
2101 GetSigningProvider(script, sign);
2103 *keys =
Merge(*keys, *script_keys);
2106 script_keys = std::make_unique<FlatSigningProvider>();
2108 const CPubKey &pubkey = pk_pair.first;
2109 std::unique_ptr<FlatSigningProvider> pk_keys =
2110 GetSigningProvider(pubkey);
2112 *keys =
Merge(*keys, *pk_keys);
2118 psbtx, i, sighash_type);
2123 for (
size_t i = 0; i < psbtx.
tx->vout.size(); ++i) {
2124 std::unique_ptr<SigningProvider> keys =
2136 std::unique_ptr<CKeyMetadata>
2138 std::unique_ptr<SigningProvider> provider =
2143 if (provider->GetKeyOrigin(key_id, orig)) {
2145 std::unique_ptr<CKeyMetadata> meta =
2146 std::make_unique<CKeyMetadata>();
2147 meta->key_origin = orig;
2148 meta->has_key_origin =
true;
2149 meta->nCreateTime = m_wallet_descriptor.creation_time;
2158 std::string desc_str = m_wallet_descriptor.descriptor->ToString();
2161 .
Write((uint8_t *)desc_str.data(), desc_str.size())
2162 .Finalize(
id.begin());
2167 this->m_address_type = type;
2168 this->m_internal =
internal;
2173 m_wallet_descriptor.cache = cache;
2174 for (int32_t i = m_wallet_descriptor.range_start;
2175 i < m_wallet_descriptor.range_end; ++i) {
2177 std::vector<CScript> scripts_temp;
2178 if (!m_wallet_descriptor.descriptor->ExpandFromCache(
2179 i, m_wallet_descriptor.cache, scripts_temp, out_keys)) {
2180 throw std::runtime_error(
2181 "Error: Unable to expand wallet descriptor from cache");
2184 for (
const CScript &script : scripts_temp) {
2185 if (m_map_script_pub_keys.count(script) != 0) {
2186 throw std::runtime_error(
2187 strprintf(
"Error: Already loaded script at index %d as " 2188 "being at index %d",
2189 i, m_map_script_pub_keys[script]));
2191 m_map_script_pub_keys[script] = i;
2193 for (
const auto &pk_pair : out_keys.
pubkeys) {
2194 const CPubKey &pubkey = pk_pair.second;
2195 if (m_map_pubkeys.count(pubkey) != 0) {
2202 m_map_pubkeys[pubkey] = i;
2204 m_max_cached_index++;
2210 m_map_keys[key_id] = key;
2216 const std::vector<uint8_t> &crypted_key) {
2218 if (!m_map_keys.empty()) {
2222 m_map_crypted_keys[key_id] = make_pair(pubkey, crypted_key);
2229 return m_wallet_descriptor.descriptor !=
nullptr &&
2231 m_wallet_descriptor.descriptor->ToString() ==
2238 if (!batch.WriteDescriptor(
GetID(), m_wallet_descriptor)) {
2239 throw std::runtime_error(std::string(__func__) +
2240 ": writing descriptor failed");
2245 return m_wallet_descriptor;
2250 std::vector<CScript> script_pub_keys;
2251 script_pub_keys.reserve(m_map_script_pub_keys.size());
2253 for (
auto const &script_pub_key : m_map_script_pub_keys) {
2254 script_pub_keys.push_back(script_pub_key.first);
2256 return script_pub_keys;
txnouttype Solver(const CScript &scriptPubKey, std::vector< std::vector< uint8_t >> &vSolutionsRet)
Parse a scriptPubKey and identify script type for standard scripts.
void ReturnDestination(int64_t index, bool internal, const CTxDestination &) override
virtual bool GetPubKey(const CKeyID &address, CPubKey &vchPubKeyOut) const override
bool NewKeyPool()
Mark old keypool keys as used, and generate all new keys.
bool AddKeyPubKeyInner(const CKey &key, const CPubKey &pubkey)
void LoadScriptMetadata(const CScriptID &script_id, const CKeyMetadata &metadata)
CPrivKey GetPrivKey() const
Convert the private key to a CPrivKey (serialized OpenSSL private key data).
bool AddKeyPubKeyWithDB(WalletBatch &batch, const CKey &key, const CPubKey &pubkey) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore)
Adds a key to the store, and saves it to disk.
const std::unordered_map< uint32_t, ExtPubKeyMap > GetCachedDerivedExtPubKeys() const
Retrieve all cached derived xpubs.
void KeepDestination(int64_t index, const OutputType &type) override
void SignTransaction(CMutableTransaction &mtx, const SigningProvider *keystore, const std::map< COutPoint, Coin > &coins, const UniValue &hashType, UniValue &result)
Sign a transaction with the given keystore and previous transactions.
bool ExtractDestination(const CScript &scriptPubKey, CTxDestination &addressRet)
Parse a standard scriptPubKey for the destination address.
void RewriteDB() override
The action to do when the DB needs rewrite.
bool GetNewDestination(const OutputType type, CTxDestination &dest, std::string &error) override
virtual const CKeyingMaterial & GetEncryptionKey() const =0
virtual void UnsetBlankWalletFlag(WalletBatch &)=0
virtual bool GetCScript(const CScriptID &hash, CScript &redeemScriptOut) const override
void LearnAllRelatedScripts(const CPubKey &key)
Same as LearnRelatedScripts, but when the OutputType is not known (and could be anything).
void MarkReserveKeysAsUsed(int64_t keypool_id) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore)
Marks all keys in the keypool up to and including reserve_key as used.
std::shared_ptr< Descriptor > descriptor
bool ImportScriptPubKeys(const std::set< CScript > &script_pub_keys, const bool have_solving_data, const int64_t timestamp) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore)
bool LoadCScript(const CScript &redeemScript)
Adds a CScript to the store.
bool AddKeyOriginWithDB(WalletBatch &batch, const CPubKey &pubkey, const KeyOriginInfo &info)
Add a KeyOriginInfo to the wallet.
bool GetKeyOrigin(const CKeyID &keyid, KeyOriginInfo &info) const override
std::vector< uint8_t > valtype
bool Derive(CExtKey &out, unsigned int nChild) const
uint32_t getRawSigHashType() const
isminetype IsMine(const CScript &script) const override
bool AddCryptedKeyInner(const CPubKey &vchPubKey, const std::vector< uint8_t > &vchCryptedSecret)
virtual const CChainParams & GetChainParams() const =0
RecursiveMutex cs_KeyStore
uint256 GetID() const override
bool VerifyPubKey(const CPubKey &vchPubKey) const
Verify thoroughly whether a private key and a public key match.
CPubKey GetPubKey() const
Compute the public key from a private key.
std::vector< uint8_t, secure_allocator< uint8_t > > CKeyingMaterial
bool AddCryptedKey(const CKeyID &key_id, const CPubKey &pubkey, const std::vector< uint8_t > &crypted_key)
std::map< CKeyID, CKey > keys
bool CheckDecryptionKey(const CKeyingMaterial &master_key, bool accept_no_keys=false) override
Check that the given decryption key is valid for this ScriptPubKeyMan, i.e.
int64_t GetOldestKeyPoolTime() const override
FlatSigningProvider Merge(const FlatSigningProvider &a, const FlatSigningProvider &b)
bool WriteHDChain(const CHDChain &chain)
write the hdchain model (external chain child index counter)
void AddKeypoolPubkeyWithDB(const CPubKey &pubkey, const bool internal, WalletBatch &batch)
virtual bool AddCScript(const CScript &redeemScript)
bool WriteWatchOnly(const CScript &script, const CKeyMetadata &keymeta)
const BaseSignatureCreator & DUMMY_SIGNATURE_CREATOR
A signature creator that just produces 71-byte empty signatures.
void SetType(OutputType type, bool internal) override
CScript GetScriptForRawPubKey(const CPubKey &pubKey)
Generate a P2PK script for the given pubkey.
uint256 GetHash() const
Get the 256-bit hash of this public key.
bool CanProvide(const CScript &script, SignatureData &sigdata) override
Whether this ScriptPubKeyMan can provide a SigningProvider (via GetSolvingProvider) that...
unsigned int GetKeyPoolSize() const override
bool CanGetAddresses(bool internal=false) const override
Returns true if the wallet can give out new addresses.
static void LogPrintf(const char *fmt, const Args &... args)
virtual std::set< CKeyID > GetKeys() const
bool DecryptKey(const CKeyingMaterial &vMasterKey, const std::vector< uint8_t > &vchCryptedSecret, const CPubKey &vchPubKey, CKey &key)
uint256 GetID() const override
static std::string WriteHDKeypath(std::vector< uint32_t > &keypath)
CKeyID GetKeyForDestination(const SigningProvider &store, const CTxDestination &dest)
Return the CKeyID of the key involved in a script (if there is a unique one).
uint32_t nExternalChainCounter
void LearnRelatedScripts(const CPubKey &key, OutputType)
Explicitly make the wallet learn the related scripts for outputs to the given key.
std::string EncodeDestination(const CTxDestination &dest, const Config &config)
virtual WalletDatabase & GetDatabase()=0
A version of CTransaction with the PSBT format.
void LoadKeyMetadata(const CKeyID &keyID, const CKeyMetadata &metadata)
Load metadata (used by LoadWallet)
std::unique_ptr< SigningProvider > GetSolvingProvider(const CScript &script) const override
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_KeyStore)
bool CanGenerateKeys() const
uint160 Hash160(const T1 pbegin, const T1 pend)
Compute the 160-bit hash an object.
bool GetReservedDestination(const OutputType type, bool internal, CTxDestination &address, int64_t &index, CKeyPool &keypool) override
static const unsigned int MAX_SCRIPT_ELEMENT_SIZE
const WalletDescriptor GetWalletDescriptor() const EXCLUSIVE_LOCKS_REQUIRED(cs_desc_man)
virtual bool IsWalletFlagSet(uint64_t) const =0
bool RemoveWatchOnly(const CScript &dest)
Remove a watch only script from the keystore.
std::unique_ptr< CKeyMetadata > GetMetadata(const CTxDestination &dest) const override
KeyMap GetKeys() const EXCLUSIVE_LOCKS_REQUIRED(cs_desc_man)
CKeyID GetID() const
Get the KeyID of this public key (hash of its serialization)
bool IsHDEnabled() const override
bool AddKeyPubKey(const CKey &key, const CPubKey &pubkey) override
Adds a key to the store, and saves it to disk.
TransactionError FillPSBT(PartiallySignedTransaction &psbt, SigHashType sighash_type=SigHashType().withForkId(), bool sign=true, bool bip32derivs=false) const override
Adds script and derivation path information to a PSBT, and optionally signs it.
Access to the wallet database.
static bool ExtractPubKey(const CScript &dest, CPubKey &pubKeyOut)
void WalletLogPrintf(std::string fmt, Params... parameters) const
Prepends the wallet name in logging output to ease debugging in multi-wallet use cases.
void MarkPreSplitKeys() EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore)
bool Encrypt(const CKeyingMaterial &master_key, WalletBatch *batch) override
const std::vector< CScript > GetScriptPubKeys() const
int64_t GetOldestKeyPoolTime() const override
bool AddWatchOnlyWithDB(WalletBatch &batch, const CScript &dest) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore)
std::unique_ptr< Descriptor > Parse(const std::string &descriptor, FlatSigningProvider &out, std::string &error, bool require_checksum)
Parse a descriptor string.
CPubKey GenerateNewSeed()
std::string ToString(const T &t)
Locale-independent version of std::to_string.
unsigned int GetKeyPoolSize() const override
void SetHDChain(const CHDChain &chain, bool memonly)
bool MessageSign(const CKey &privkey, const std::string &message, std::string &signature)
Sign a message.
bool IsHDEnabled() const override
IsMineSigVersion
This is an enum that tracks the execution context of a script, similar to SigVersion in script/interp...
CPubKey GenerateNewKey(WalletBatch &batch, bool internal=false) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore)
Generate a new key.
size_t KeypoolCountExternalKeys() const override
int64_t nTime
The time at which the key was generated. Set in AddKeypoolPubKeyWithDB.
bool Upgrade(int prev_version, bilingual_str &error) override
Upgrades the wallet to the specified version.
bool SignTransaction(CMutableTransaction &tx, const std::map< COutPoint, Coin > &coins, SigHashType sighash, std::map< int, std::string > &input_errors) const override
Creates new signatures and adds them to the transaction.
void UpdateTimeFirstKey(int64_t nCreateTime) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore)
Update wallet first key creation time.
bool WriteCScript(const uint160 &hash, const CScript &redeemScript)
void SetSeed(const uint8_t *seed, unsigned int nSeedLen)
bool CanProvide(const CScript &script, SignatureData &sigdata) override
Whether this ScriptPubKeyMan can provide a SigningProvider (via GetSolvingProvider) that...
bool GetWatchPubKey(const CKeyID &address, CPubKey &pubkey_out) const
Fetches a pubkey from mapWatchKeys if it exists there.
bool AddWatchOnlyInMem(const CScript &dest)
void MarkUnusedAddresses(const CScript &script) override
Mark unused addresses as being used.
static const unsigned int DEFAULT_KEYPOOL_SIZE
Default for -keypool.
bilingual_str _(const char *psz)
Translation function.
const SigningProvider & DUMMY_SIGNING_PROVIDER
bool TopUp(unsigned int size=0) override
Fills internal address pool.
An encapsulated public key.
std::map< CKeyID, CPubKey > pubkeys
void SetHDSeed(const CPubKey &key)
void MakeNewKey(bool fCompressed)
Generate a new private key using a cryptographic PRNG.
Flag set when a wallet contains no HD seed and no private keys, scripts, addresses, and other watch only things, and is therefore "blank.".
void ReturnDestination(int64_t index, bool internal, const CTxDestination &addr) override
bool m_pre_split
Whether this key was generated for a keypool before the wallet was upgraded to HD-split.
bool GetKey(const CKeyID &address, CKey &keyOut) const override
const Config & GetConfig()
isminetype
IsMine() return codes.
unsigned int size() const
Simple read-only vector-like interface.
void MarkUnusedAddresses(const CScript &script) override
Mark unused addresses as being used.
boost::signals2::signal< void()> NotifyCanGetAddressesChanged
Keypool has new keys.
void UpdatePSBTOutput(const SigningProvider &provider, PartiallySignedTransaction &psbt, int index)
Updates a PSBTOutput with information from provider.
CScript GetScriptForDestination(const CTxDestination &dest)
Generate a Bitcoin scriptPubKey for the given CTxDestination.
Descriptor with some wallet metadata.
bool SignPSBTInput(const SigningProvider &provider, PartiallySignedTransaction &psbt, int index, SigHashType sighash, SignatureData *out_sigdata, bool use_dummy)
Signs a PSBTInput, verifying that all provided data matches what is being signed. ...
bool AddKey(const CKeyID &key_id, const CKey &key)
const uint8_t * begin() const
bool LoadWatchOnly(const CScript &dest)
Adds a watch-only address to the store, without saving it to disk (used by LoadWallet) ...
bool ReserveKeyFromKeyPool(int64_t &nIndex, CKeyPool &keypool, bool fRequestedInternal)
Reserves a key from the keypool and sets nIndex to its index.
std::vector< PSBTInput > inputs
bool GetKeyFromPool(CPubKey &key, const OutputType type, bool internal=false)
Fetches a key from the keypool.
virtual bool IsLocked() const =0
bool HasWalletDescriptor(const WalletDescriptor &desc) const
bool HavePrivateKeys() const override
bool WriteKeyMetadata(const CKeyMetadata &meta, const CPubKey &pubkey, const bool overwrite)
virtual bool GetKey(const CKeyID &address, CKey &keyOut) const override
std::map< int64_t, CKeyID > m_index_to_reserved_key
bool AddCScript(const CScript &redeemScript) override
std::vector< CKeyID > GetAffectedKeys(const CScript &spk, const SigningProvider &provider)
int64_t GetTimeFirstKey() const override
static int64_t GetOldestKeyTimeInPool(const std::set< int64_t > &setKeyPool, WalletBatch &batch)
bool ErasePool(int64_t nPool)
bool WritePool(int64_t nPool, const CKeyPool &keypool)
bool SignTransaction(CMutableTransaction &tx, const std::map< COutPoint, Coin > &coins, SigHashType sighash, std::map< int, std::string > &input_errors) const override
Creates new signatures and adds them to the transaction.
bool GetReservedDestination(const OutputType type, bool internal, CTxDestination &address, int64_t &index, CKeyPool &keypool) override
CPubKey vchPubKey
The public key.
bool LoadKey(const CKey &key, const CPubKey &pubkey)
Adds a key to the store, without saving it to disk (used by LoadWallet)
virtual bool CanSupportFeature(enum WalletFeature) const =0
bool AddDescriptorKeyWithDB(WalletBatch &batch, const CKey &key, const CPubKey &pubkey)
void SetCache(const DescriptorCache &cache)
bool HaveWatchOnly() const
Returns whether there are any watch-only things in the wallet.
bool WriteCryptedDescriptorKey(const uint256 &desc_id, const CPubKey &pubkey, const std::vector< uint8_t > &secret)
std::string EncodeExtPubKey(const CExtPubKey &key)
bool IsTestChain() const
If this chain is exclusively used for testing.
boost::signals2::signal< void(bool fHaveWatchOnly)> NotifyWatchonlyChanged
Watch-only address added.
bool LoadCryptedKey(const CPubKey &vchPubKey, const std::vector< uint8_t > &vchCryptedSecret)
Adds an encrypted key to the store, without saving it to disk (used by LoadWallet) ...
std::unique_ptr< Descriptor > InferDescriptor(const CScript &script, const SigningProvider &provider)
Find a descriptor for the specified script, using information from provider where possible...
An interface to be implemented by keystores that support signing.
CExtPubKey Neuter() const
bool ParseHDKeypath(const std::string &keypath_str, std::vector< uint32_t > &keypath)
Parse an HD keypaths like "m/7/0'/2000".
Cache for single descriptor's derived extended pubkeys.
bool GetNewDestination(const OutputType type, CTxDestination &dest, std::string &error) override
bool HaveKey(const CKeyID &address) const override
std::map< CKeyID, CKey > KeyMap
Serialized script, used inside transaction inputs and outputs.
std::unique_ptr< FlatSigningProvider > GetSigningProvider(const CScript &script, bool include_private=false) const
std::string GetArg(const std::string &strArg, const std::string &strDefault) const
Return string argument or default value.
void LoadKeyPool(int64_t nIndex, const CKeyPool &keypool)
Load a keypool entry.
void DeriveNewChildKey(WalletBatch &batch, CKeyMetadata &metadata, CKey &secret, bool internal=false) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore)
A mutable version of CTransaction.
A reference to a CKey: the Hash160 of its serialized public key.
bool CheckDecryptionKey(const CKeyingMaterial &master_key, bool accept_no_keys=false) override
Check that the given decryption key is valid for this ScriptPubKeyMan, i.e.
CSHA256 & Write(const uint8_t *data, size_t len)
bool CanGetAddresses(bool internal=false) const override
Returns true if the wallet can give out new addresses.
std::unique_ptr< SigningProvider > GetSolvingProvider(const CScript &script) const override
std::string HexStr(const T itbegin, const T itend)
TransactionError FillPSBT(PartiallySignedTransaction &psbt, SigHashType sighash_type=SigHashType().withForkId(), bool sign=true, bool bip32derivs=false) const override
Adds script and derivation path information to a PSBT, and optionally signs it.
virtual bool HaveCScript(const CScriptID &hash) const override
bool AddWatchOnly(const CScript &dest) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore)
Private version of AddWatchOnly method which does not accept a timestamp, and which will reset the wa...
bool EncryptSecret(const CKeyingMaterial &vMasterKey, const CKeyingMaterial &vchPlaintext, const uint256 &nIV, std::vector< uint8_t > &vchCiphertext)
IsMineResult
This is an internal representation of isminetype + invalidity.
bool ProduceSignature(const SigningProvider &provider, const BaseSignatureCreator &creator, const CScript &fromPubKey, SignatureData &sigdata)
Produce a script signature using a generic signature creator.
void UpgradeKeyMetadata()
Upgrade stored CKeyMetadata objects to store key origin info as KeyOriginInfo.
CPubKey DeriveNewSeed(const CKey &key)
CTxDestination GetDestinationForKey(const CPubKey &key, OutputType type)
Get a destination of the requested type (if possible) to the specified key.
bool ReadPool(int64_t nPool, CKeyPool &keypool)
int64_t GetTimeFirstKey() const override
static const int VERSION_HD_CHAIN_SPLIT
A reference to a CScript: the Hash160 of its serialization (see script.h)
virtual bool HasEncryptionKeys() const =0
const uint8_t * end() const
virtual bool AddKeyPubKey(const CKey &key, const CPubKey &pubkey)
bool PSBTInputSigned(const PSBTInput &input)
Checks whether a PSBTInput is already signed.
bool SetupGeneration(bool force=false) override
Sets up the key generation stuff, i.e.
bool WriteKey(const CPubKey &vchPubKey, const CPrivKey &vchPrivKey, const CKeyMetadata &keyMeta)
bool Encrypt(const CKeyingMaterial &master_key, WalletBatch *batch) override
bool HavePrivateKeys() const override
std::map< CKeyID, CKey > KeyMap
void AddDescriptorKey(const CKey &key, const CPubKey &pubkey)
SigningResult SignMessage(const std::string &message, const PKHash &pkhash, std::string &str_sig) const override
Sign a message with the given script.
An encapsulated secp256k1 private key.
std::unique_ptr< CKeyMetadata > GetMetadata(const CTxDestination &dest) const override
bool SetupDescriptorGeneration(const CExtKey &master_key)
Setup descriptors based on the given CExtkey.
std::optional< CMutableTransaction > tx
bool TopUp(unsigned int size=0) override
Fills internal address pool.
WalletStorage & m_storage
AssertLockHeld(g_cs_orphans)
Indicate that this wallet supports DescriptorScriptPubKeyMan.
CKeyID seed_id
seed hash160
A hasher class for SHA-256.
bool ImportPrivKeys(const std::map< CKeyID, CKey > &privkey_map, const int64_t timestamp) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore)
const ExtPubKeyMap GetCachedParentExtPubKeys() const
Retrieve all cached parent xpubs.
int64_t GetTime()
Return system time (or mocked time, if set)
std::vector< uint32_t > path
virtual void SetMinVersion(enum WalletFeature, WalletBatch *=nullptr, bool=false)=0
bool GetPubKey(const CKeyID &address, CPubKey &vchPubKeyOut) const override
bool error(const char *fmt, const Args &... args)
bool AddCScriptWithDB(WalletBatch &batch, const CScript &script)
Adds a script to the store and saves it to disk.
void SetType(OutputType type, bool internal) override
size_t KeypoolCountExternalKeys() const override
bool fDecryptionThoroughlyChecked
keeps track of whether Unlock has run a thorough check before
bool fInternal
Whether this keypool entry is in the internal keypool (for change outputs)
boost::variant< CNoDestination, PKHash, ScriptHash > CTxDestination
A txout script template with a specific destination.
std::set< CKeyID > GetKeys() const override
static const int VERSION_HD_BASE
isminetype IsMine(const CScript &script) const override
bool AddCryptedKey(const CPubKey &vchPubKey, const std::vector< uint8_t > &vchCryptedSecret)
Adds an encrypted key to the store, and saves it to disk.
bool ImportScripts(const std::set< CScript > scripts, int64_t timestamp) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore)
std::map< CKeyID, SigPair > signatures
BIP 174 style partial signatures for the input.
uint32_t nInternalChainCounter
Signature hash type wrapper class.
bool WriteDescriptorKey(const uint256 &desc_id, const CPubKey &pubkey, const CPrivKey &privkey)
std::map< CKeyID, int64_t > m_pool_key_to_index
A key from a CWallet's keypool.
std::vector< uint8_t > valtype
SigningResult SignMessage(const std::string &message, const PKHash &pkhash, std::string &str_sig) const override
Sign a message with the given script.
bool HaveWatchOnly(const CScript &dest) const
Returns whether the watch-only script is in the wallet.
const uint32_t BIP32_HARDENED_KEY_LIMIT
uint8_t fingerprint[4]
First 32 bits of the Hash160 of the public key at the root of the path.
virtual bool HaveKey(const CKeyID &address) const override