aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/wallet.h
diff options
context:
space:
mode:
authorSamuel Dobson <dobsonsa68@gmail.com>2020-01-15 22:10:39 +1300
committerSamuel Dobson <dobsonsa68@gmail.com>2020-01-15 22:11:33 +1300
commitac61ec9da6793f00b29ba11f784b9b1c3ae662e9 (patch)
treefb898950ce506e21fcd5d41484c2d4228e5a4c02 /src/wallet/wallet.h
parent002f9e9b4041e9b5bf8a91680ce980bf9ff15074 (diff)
parent6fc554f591d8ea1681b8bb25aa12da8d4f023f66 (diff)
downloadbitcoin-ac61ec9da6793f00b29ba11f784b9b1c3ae662e9.tar.xz
Merge #17843: wallet: Reset reused transactions cache
6fc554f591d8ea1681b8bb25aa12da8d4f023f66 wallet: Reset reused transactions cache (Fabian Jahr) Pull request description: Fixes #17603 (together with #17824) `getbalances` is using the cache within `GetAvailableCredit` under certain conditions [here](https://github.com/bitcoin/bitcoin/blob/35fff5be60e853455abc24713481544e91adfedb/src/wallet/wallet.cpp#L1826). For a wallet with `avoid_reuse` activated this can lead to inconsistent reporting of `used` transactions/balances between `getbalances` and `listunspent` as pointed out in #17603. When an address is reused before the first transaction is spending from this address, the cache is not updated even after the transaction is sent. This means the remaining outputs at the reused address are not showing up as `used` in `getbalances`. With this change, any newly incoming transaction belonging to the wallet marks all the other outputs at the same address as dirty. ACKs for top commit: kallewoof: Code review re-ACK 6fc554f591d8ea1681b8bb25aa12da8d4f023f66 promag: ACK 6fc554f591d8ea1681b8bb25aa12da8d4f023f66. achow101: Re-ACK 6fc554f591d8ea1681b8bb25aa12da8d4f023f66 meshcollider: Code review ACK 6fc554f591d8ea1681b8bb25aa12da8d4f023f66 Tree-SHA512: c4cad2c752176d16d77b4a4202291d20baddf9f27250896a40274d74a6945e0f6b34be04c2f9b1b2e756d3ac669b794969df8f82a98e0b16f10e92f276649ea2
Diffstat (limited to 'src/wallet/wallet.h')
-rw-r--r--src/wallet/wallet.h8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h
index 1f81e34322..846a502614 100644
--- a/src/wallet/wallet.h
+++ b/src/wallet/wallet.h
@@ -803,7 +803,7 @@ public:
// Whether this or any known UTXO with the same single key has been spent.
bool IsUsedDestination(const uint256& hash, unsigned int n) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
- void SetUsedDestinationState(WalletBatch& batch, const uint256& hash, unsigned int n, bool used) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
+ void SetUsedDestinationState(WalletBatch& batch, const uint256& hash, unsigned int n, bool used, std::set<CTxDestination>& tx_destinations) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
std::vector<OutputGroup> GroupOutputs(const std::vector<COutput>& outputs, bool single_coin) const;
@@ -963,6 +963,12 @@ public:
std::set<CTxDestination> GetLabelAddresses(const std::string& label) const;
+ /**
+ * Marks all outputs in each one of the destinations dirty, so their cache is
+ * reset and does not return outdated information.
+ */
+ void MarkDestinationsDirty(const std::set<CTxDestination>& destinations) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
+
bool GetNewDestination(const OutputType type, const std::string label, CTxDestination& dest, std::string& error);
bool GetNewChangeDestination(const OutputType type, CTxDestination& dest, std::string& error);