You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Current CWalletTx state representation makes it possible to set
inconsistent states that won't be handled correctly by wallet sync code
or serialized & deserialized back into the same form.
For example, it is possible to call setConflicted without setting a
conflicting block hash, or setConfirmed with no transaction index. And
it's possible update individual m_confirm and fInMempool data fields
without setting an overall consistent state that can be serialized and
handled correctly.
Fix this without changing behavior by using std::variant, instead of an
enum and collection of fields, to represent sync state, so state
tracking code is safer and more legible.
This is a first step to fixing state tracking bugs
https://github.com/bitcoin-core/bitcoin-devwiki/wiki/Wallet-Transaction-Conflict-Tracking,
by adding an extra margin of safety that can prevent new bugs from being
introduced as existing bugs are fixed.
// Distributed under the MIT software license, see the accompanying
3
+
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
+
5
+
#ifndef BITCOIN_UTIL_OVERLOADED_H
6
+
#defineBITCOIN_UTIL_OVERLOADED_H
7
+
8
+
#include<optional>
9
+
#include<utility>
10
+
11
+
//! Overloaded helper for std::visit. This helper and std::visit in general are
12
+
//! useful to write code that switches on a variant type. Unlike if/else-if and
13
+
//! switch/case statements, std::visit will trigger compile errors if there are
14
+
//! unhandled cases.
15
+
//!
16
+
//! Implementation comes from and example usage can be found at
auto ret = wallet.mapWallet.emplace(std::piecewise_construct, std::forward_as_tuple(txid), std::forward_as_tuple(MakeTransactionRef(std::move(tx))));
77
+
auto ret = wallet.mapWallet.emplace(std::piecewise_construct, std::forward_as_tuple(txid), std::forward_as_tuple(MakeTransactionRef(std::move(tx)), TxStateInactive{}));
0 commit comments