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