MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / MarkUnusedAddresses

Method MarkUnusedAddresses

src/wallet/scriptpubkeyman.cpp:1116–1142  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1114}
1115
1116std::vector<WalletDestination> DescriptorScriptPubKeyMan::MarkUnusedAddresses(const CScript& script)
1117{
1118 LOCK(cs_desc_man);
1119 std::vector<WalletDestination> result;
1120 if (IsMine(script)) {
1121 int32_t index = m_map_script_pub_keys[script];
1122 if (index >= m_wallet_descriptor.next_index) {
1123 WalletLogPrintf("%s: Detected a used keypool item at index %d, mark all keypool items up to this item as used\n", __func__, index);
1124 auto out_keys = std::make_unique<FlatSigningProvider>();
1125 std::vector<CScript> scripts_temp;
1126 while (index >= m_wallet_descriptor.next_index) {
1127 if (!m_wallet_descriptor.descriptor->ExpandFromCache(m_wallet_descriptor.next_index, m_wallet_descriptor.cache, scripts_temp, *out_keys)) {
1128 throw std::runtime_error(std::string(__func__) + ": Unable to expand descriptor from cache");
1129 }
1130 CTxDestination dest;
1131 ExtractDestination(scripts_temp[0], dest);
1132 result.push_back({dest, std::nullopt});
1133 m_wallet_descriptor.next_index++;
1134 }
1135 }
1136 if (!TopUp()) {
1137 WalletLogPrintf("%s: Topping up keypool failed (locked wallet)\n", __func__);
1138 }
1139 }
1140
1141 return result;
1142}
1143
1144void DescriptorScriptPubKeyMan::AddDescriptorKey(const CKey& key, const CPubKey &pubkey)
1145{

Callers 2

Calls 3

ExtractDestinationFunction · 0.85
ExpandFromCacheMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected