aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/scriptpubkeyman.cpp
diff options
context:
space:
mode:
authorAndrew Chow <achow101-github@achow101.com>2019-07-11 14:44:53 -0400
committerAndrew Chow <achow101-github@achow101.com>2020-04-23 13:59:48 -0400
commit586b57a9a6b4b12a78f792785b63a5a1743bce0c (patch)
tree9f739a60610a81ffd2093c0f23f59119396103c6 /src/wallet/scriptpubkeyman.cpp
parentf866957979c23cefd41efa9dae9e53b9177818dc (diff)
downloadbitcoin-586b57a9a6b4b12a78f792785b63a5a1743bce0c.tar.xz
Implement ReturnDestination in DescriptorScriptPubKeyMan
Diffstat (limited to 'src/wallet/scriptpubkeyman.cpp')
-rw-r--r--src/wallet/scriptpubkeyman.cpp7
1 files changed, 7 insertions, 0 deletions
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<CKeyID, CKey> DescriptorScriptPubKeyMan::GetKeys() const