5 #ifndef BITCOIN_WALLET_TRANSACTION_H
6 #define BITCOIN_WALLET_TRANSACTION_H
68 using TxState = std::variant<TxStateConfirmed, TxStateInMempool, TxStateConflicted, TxStateInactive, TxStateUnrecognized>;
71 using SyncTxState = std::variant<TxStateConfirmed, TxStateInMempool, TxStateInactive>;
80 }
else if (data.
index >= 0) {
82 }
else if (data.
index == -1) {
94 [](
const TxStateConfirmed& confirmed) {
return confirmed.confirmed_block_hash; },
95 [](
const TxStateConflicted& conflicted) {
return conflicted.conflicting_block_hash; },
104 [](
const TxStateInactive& inactive) {
return inactive.abandoned ? -1 : 0; },
106 [](
const TxStateConfirmed& confirmed) {
return confirmed.position_in_block; },
144 template<
typename Stream>
149 std::vector<uint256> vMerkleBranch;
152 s >> tx >> hashBlock >> vMerkleBranch >> nIndex;
189 std::vector<std::pair<std::string, std::string> >
vOrderForm;
245 template<
typename Stream>
250 mapValueCopy[
"fromaccount"] =
"";
258 std::vector<uint8_t> dummy_vector1;
259 std::vector<uint8_t> dummy_vector2;
260 bool dummy_bool =
false;
266 template<
typename Stream>
271 std::vector<uint256> dummy_vector1;
272 std::vector<CMerkleTx> dummy_vector2;
280 const auto it_op =
mapValue.find(
"n");
281 nOrderPos = (it_op !=
mapValue.end()) ? LocaleIndependentAtoi<int64_t>(it_op->second) : -1;
282 const auto it_ts =
mapValue.find(
"timesmart");
283 nTimeSmart = (it_ts !=
mapValue.end()) ?
static_cast<unsigned int>(LocaleIndependentAtoi<int64_t>(it_ts->second)) : 0;
314 template<
typename T>
const T*
state()
const {
return std::get_if<T>(&
m_state); }
317 bool isAbandoned()
const {
return state<TxStateInactive>() && state<TxStateInactive>()->abandoned; }
int64_t CAmount
Amount in satoshis (Can be negative)
static const uint256 ZERO
Legacy class used for deserializing vtxPrev for backwards compatibility.
void Unserialize(Stream &s)
A transaction with a bunch of additional info that only the owner cares about.
bool IsEquivalentTo(const CWalletTx &tx) const
True if only scriptSigs are different.
std::vector< std::pair< std::string, std::string > > vOrderForm
mapValue_t mapValue
Key/value map with information about the transaction.
@ AMOUNTTYPE_ENUM_ELEMENTS
void Serialize(Stream &s) const
int64_t nOrderPos
position in ordered transaction list
bool isUnconfirmed() const
bool fFromMe
From me flag is set to 1 for transactions that were created by the wallet on this bitcoin node,...
unsigned int nTimeReceived
time received by this node
bool isConflicted() const
void Unserialize(Stream &s)
void SetTx(CTransactionRef arg)
void operator=(CWalletTx const &x)=delete
unsigned int fTimeReceivedIsTxTime
CachableAmount m_amounts[AMOUNTTYPE_ENUM_ELEMENTS]
const uint256 & GetHash() const
const uint256 & GetWitnessHash() const
std::multimap< int64_t, CWalletTx * >::const_iterator m_it_wtxOrdered
int64_t GetTxTime() const
CWalletTx(CTransactionRef tx, const TxState &state)
CWalletTx(CWalletTx const &)=delete
bool m_is_cache_empty
This flag is true if all m_amounts caches are empty.
unsigned int nTimeSmart
Stable timestamp that never changes, and reflects the order a transaction was added to the wallet.
void MarkDirty()
make sure balances are recalculated
#define T(expected, seed, data)
std::variant< TxStateConfirmed, TxStateInMempool, TxStateInactive > SyncTxState
Subset of states transaction sync logic is implemented to handle.
std::map< std::string, std::string > mapValue_t
static int TxStateSerializedIndex(const TxState &state)
Get TxState serialized block index. Inverse of TxStateInterpretSerialized.
std::underlying_type< isminetype >::type isminefilter
used for bitflags of isminetype
static TxState TxStateInterpretSerialized(TxStateUnrecognized data)
Try to interpret deserialized TxStateUnrecognized data as a recognized state.
static uint256 TxStateSerializedBlockHash(const TxState &state)
Get TxState serialized block hash. Inverse of TxStateInterpretSerialized.
std::variant< TxStateConfirmed, TxStateInMempool, TxStateConflicted, TxStateInactive, TxStateUnrecognized > TxState
All possible CWalletTx states.
std::shared_ptr< const CTransaction > CTransactionRef
std::string ToString(const T &t)
Locale-independent version of std::to_string.
Overloaded helper for std::visit.
Cachable amount subdivided into watchonly and spendable parts.
void Set(isminefilter filter, CAmount value)
CAmount m_value[ISMINE_ENUM_ELEMENTS]
std::bitset< ISMINE_ENUM_ELEMENTS > m_cached
State of transaction confirmed in a block.
int confirmed_block_height
TxStateConfirmed(const uint256 &block_hash, int height, int index)
uint256 confirmed_block_hash
State of rejected transaction that conflicts with a confirmed block.
uint256 conflicting_block_hash
TxStateConflicted(const uint256 &block_hash, int height)
int conflicting_block_height
State of transaction added to mempool.
State of transaction not confirmed or conflicting with a known block and not in the mempool.
TxStateInactive(bool abandoned=false)
State of transaction loaded in an unrecognized state with unexpected hash or index values.
TxStateUnrecognized(const uint256 &block_hash, int index)
bool operator()(const CWalletTx *a, const CWalletTx *b) const