diff options
| author | Andrew Chow <[email protected]> | 2019-07-08 16:25:10 -0400 |
|---|---|---|
| committer | Andrew Chow <[email protected]> | 2020-04-23 13:59:48 -0400 |
| commit | 741122d4c1a62ced3e96d16d67f4eeb3a6522d99 (patch) | |
| tree | c8d59701d55bb1537255be73df37ac70e3a81707 /src/wallet/scriptpubkeyman.cpp | |
| parent | Implement IsMine for DescriptorScriptPubKeyMan (diff) | |
| download | discoin-741122d4c1a62ced3e96d16d67f4eeb3a6522d99.tar.xz discoin-741122d4c1a62ced3e96d16d67f4eeb3a6522d99.zip | |
Implement MarkUnusedAddresses in DescriptorScriptPubKeyMan
Diffstat (limited to 'src/wallet/scriptpubkeyman.cpp')
| -rw-r--r-- | src/wallet/scriptpubkeyman.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/wallet/scriptpubkeyman.cpp b/src/wallet/scriptpubkeyman.cpp index 88563459b..31a87a53f 100644 --- a/src/wallet/scriptpubkeyman.cpp +++ b/src/wallet/scriptpubkeyman.cpp @@ -1540,6 +1540,17 @@ bool DescriptorScriptPubKeyMan::TopUp(unsigned int size) void DescriptorScriptPubKeyMan::MarkUnusedAddresses(const CScript& script) { + LOCK(cs_desc_man); + if (IsMine(script)) { + int32_t index = m_map_script_pub_keys[script]; + if (index >= m_wallet_descriptor.next_index) { + WalletLogPrintf("%s: Detected a used keypool item at index %d, mark all keypool items up to this item as used\n", __func__, index); + m_wallet_descriptor.next_index = index + 1; + } + if (!TopUp()) { + WalletLogPrintf("%s: Topping up keypool failed (locked wallet)\n", __func__); + } + } } bool DescriptorScriptPubKeyMan::IsHDEnabled() const |