From 586b57a9a6b4b12a78f792785b63a5a1743bce0c Mon Sep 17 00:00:00 2001 From: Andrew Chow Date: Thu, 11 Jul 2019 14:44:53 -0400 Subject: Implement ReturnDestination in DescriptorScriptPubKeyMan --- src/wallet/scriptpubkeyman.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/wallet/scriptpubkeyman.cpp') diff --git a/src/wallet/scriptpubkeyman.cpp b/src/wallet/scriptpubkeyman.cpp index c9f2e38ae1..c0d48c2242 100644 --- a/src/wallet/scriptpubkeyman.cpp +++ b/src/wallet/scriptpubkeyman.cpp @@ -1617,6 +1617,13 @@ bool DescriptorScriptPubKeyMan::GetReservedDestination(const OutputType type, bo void DescriptorScriptPubKeyMan::ReturnDestination(int64_t index, bool internal, const CTxDestination& addr) { + LOCK(cs_desc_man); + // Only return when the index was the most recent + if (m_wallet_descriptor.next_index - 1 == index) { + m_wallet_descriptor.next_index--; + } + WalletBatch(m_storage.GetDatabase()).WriteDescriptor(GetID(), m_wallet_descriptor); + NotifyCanGetAddressesChanged(); } std::map DescriptorScriptPubKeyMan::GetKeys() const -- cgit v1.2.3