Skip to content

Commit 741122d

Browse files
committed
Implement MarkUnusedAddresses in DescriptorScriptPubKeyMan
1 parent 2db7ca7 commit 741122d

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/wallet/scriptpubkeyman.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1540,6 +1540,17 @@ bool DescriptorScriptPubKeyMan::TopUp(unsigned int size)
15401540

15411541
void DescriptorScriptPubKeyMan::MarkUnusedAddresses(const CScript& script)
15421542
{
1543+
LOCK(cs_desc_man);
1544+
if (IsMine(script)) {
1545+
int32_t index = m_map_script_pub_keys[script];
1546+
if (index >= m_wallet_descriptor.next_index) {
1547+
WalletLogPrintf("%s: Detected a used keypool item at index %d, mark all keypool items up to this item as used\n", __func__, index);
1548+
m_wallet_descriptor.next_index = index + 1;
1549+
}
1550+
if (!TopUp()) {
1551+
WalletLogPrintf("%s: Topping up keypool failed (locked wallet)\n", __func__);
1552+
}
1553+
}
15431554
}
15441555

15451556
bool DescriptorScriptPubKeyMan::IsHDEnabled() const

0 commit comments

Comments
 (0)