16 return GetTx()->Equals(*_tx.
GetTx(), {.include_script_sig = false, .include_witness_data = false});
21 return state<TxStateInMempool>();
44 if (
auto* conf = state<TxStateConfirmed>()) {
45 lookup_block(conf->confirmed_block_hash, conf->confirmed_block_height,
m_state);
46 }
else if (
auto* conf = state<TxStateBlockConflicted>()) {
47 lookup_block(conf->conflicting_block_hash, conf->conflicting_block_height,
m_state);
61 const auto& [tx_pair, new_variant] =
m_txs.emplace(new_tx->GetWitnessHash(), std::move(new_tx));
64 throw std::ios_base::failure(
"Unable to write wtxvariant record");
67 const auto& [wtxid, tx] = *tx_pair;
69 if (new_state.index() !=
m_state.index()) {
71 if (state<TxStateConfirmed>()) {
74 metadata_changed =
true;
85 metadata_changed =
true;
89 if (metadata_changed) {
91 throw std::ios_base::failure(
"Unable to write tx record");
95 return new_variant || metadata_changed;
#define Assert(val)
Identity function.
#define Assume(val)
Assume is the identity function.
Interface giving clients (wallet processes, maybe other analysis tools in the future) ability to acce...
virtual bool findBlock(const uint256 &hash, const FoundBlock &block={})=0
Return whether node has the block and optionally return block metadata or contents.
Helper for findBlock to selectively return pieces of block data.
A transaction with a bunch of additional info that only the owner cares about.
bool Update(CTransactionRef tx, const TxState &new_state, WalletBatch &batch, bool metadata_changed)
const Txid & GetHash() const LIFETIMEBOUND
std::map< Wtxid, CTransactionRef > m_txs
void updateState(interfaces::Chain &chain)
Update transaction state when attaching to a chain, filling in heights of conflicted and confirmed bl...
unsigned int nTimeReceived
time received by this node
int64_t GetTxTime() const
CTransactionRef GetTx() const
bool IsMalleation(const CWalletTx &tx) const
True if tx is a malleation of this, i.e.
void RecomputeCanonical()
Set m_canonical_wtxid to the best variant under the unconfirmed rule (witnessed preferred,...
unsigned int nTimeSmart
Stable timestamp that never changes, and reflects the order a transaction was added to the wallet.
Access to the wallet database.
bool WriteTxMetadata(const CWalletTx &wtx)
bool WriteWtxVariant(const Txid &txid, const CTransactionRef &tx)
static int32_t GetTransactionWeight(const CTransaction &tx)
std::variant< TxStateConfirmed, TxStateInMempool, TxStateBlockConflicted, TxStateInactive, TxStateUnrecognized > TxState
All possible CWalletTx states.
static int TxStateSerializedIndex(const TxState &state)
Get TxState serialized block index. Inverse of TxStateInterpretSerialized.
static uint256 TxStateSerializedBlockHash(const TxState &state)
Get TxState serialized block hash. Inverse of TxStateInterpretSerialized.
std::shared_ptr< const CTransaction > CTransactionRef
State of transaction not confirmed or conflicting with a known block and not in the mempool.