Changeset View
Changeset View
Standalone View
Standalone View
src/interfaces/wallet.cpp
Show All 21 Lines | |||||
#include <wallet/psbtwallet.h> | #include <wallet/psbtwallet.h> | ||||
#include <wallet/rpcdump.h> | #include <wallet/rpcdump.h> | ||||
#include <wallet/wallet.h> | #include <wallet/wallet.h> | ||||
namespace interfaces { | namespace interfaces { | ||||
namespace { | namespace { | ||||
//! Construct wallet tx struct. | //! Construct wallet tx struct. | ||||
static WalletTx MakeWalletTx(CWallet &wallet, const CWalletTx &wtx) { | WalletTx MakeWalletTx(CWallet &wallet, const CWalletTx &wtx) { | ||||
WalletTx result; | WalletTx result; | ||||
result.tx = wtx.tx; | result.tx = wtx.tx; | ||||
result.txin_is_mine.reserve(wtx.tx->vin.size()); | result.txin_is_mine.reserve(wtx.tx->vin.size()); | ||||
for (const auto &txin : wtx.tx->vin) { | for (const auto &txin : wtx.tx->vin) { | ||||
result.txin_is_mine.emplace_back(wallet.IsMine(txin)); | result.txin_is_mine.emplace_back(wallet.IsMine(txin)); | ||||
} | } | ||||
result.txout_is_mine.reserve(wtx.tx->vout.size()); | result.txout_is_mine.reserve(wtx.tx->vout.size()); | ||||
result.txout_address.reserve(wtx.tx->vout.size()); | result.txout_address.reserve(wtx.tx->vout.size()); | ||||
Show All 12 Lines | WalletTx MakeWalletTx(CWallet &wallet, const CWalletTx &wtx) { | ||||
result.change = wtx.GetChange(); | result.change = wtx.GetChange(); | ||||
result.time = wtx.GetTxTime(); | result.time = wtx.GetTxTime(); | ||||
result.value_map = wtx.mapValue; | result.value_map = wtx.mapValue; | ||||
result.is_coinbase = wtx.IsCoinBase(); | result.is_coinbase = wtx.IsCoinBase(); | ||||
return result; | return result; | ||||
} | } | ||||
//! Construct wallet tx status struct. | //! Construct wallet tx status struct. | ||||
static WalletTxStatus | WalletTxStatus MakeWalletTxStatus(interfaces::Chain::Lock &locked_chain, | ||||
MakeWalletTxStatus(interfaces::Chain::Lock &locked_chain, | |||||
const CWalletTx &wtx) { | const CWalletTx &wtx) { | ||||
WalletTxStatus result; | WalletTxStatus result; | ||||
result.block_height = | result.block_height = | ||||
locked_chain.getBlockHeight(wtx.m_confirm.hashBlock) | locked_chain.getBlockHeight(wtx.m_confirm.hashBlock) | ||||
.get_value_or(std::numeric_limits<int>::max()); | .get_value_or(std::numeric_limits<int>::max()); | ||||
result.blocks_to_maturity = wtx.GetBlocksToMaturity(); | result.blocks_to_maturity = wtx.GetBlocksToMaturity(); | ||||
result.depth_in_main_chain = wtx.GetDepthInMainChain(); | result.depth_in_main_chain = wtx.GetDepthInMainChain(); | ||||
result.time_received = wtx.nTimeReceived; | result.time_received = wtx.nTimeReceived; | ||||
result.lock_time = wtx.tx->nLockTime; | result.lock_time = wtx.tx->nLockTime; | ||||
TxValidationState state; | TxValidationState state; | ||||
result.is_final = | result.is_final = | ||||
locked_chain.contextualCheckTransactionForCurrentBlock( | locked_chain.contextualCheckTransactionForCurrentBlock( | ||||
Params().GetConsensus(), *wtx.tx, state); | Params().GetConsensus(), *wtx.tx, state); | ||||
result.is_trusted = wtx.IsTrusted(locked_chain); | result.is_trusted = wtx.IsTrusted(locked_chain); | ||||
result.is_abandoned = wtx.isAbandoned(); | result.is_abandoned = wtx.isAbandoned(); | ||||
result.is_coinbase = wtx.IsCoinBase(); | result.is_coinbase = wtx.IsCoinBase(); | ||||
result.is_in_main_chain = wtx.IsInMainChain(); | result.is_in_main_chain = wtx.IsInMainChain(); | ||||
return result; | return result; | ||||
} | } | ||||
//! Construct wallet TxOut struct. | //! Construct wallet TxOut struct. | ||||
static WalletTxOut MakeWalletTxOut(CWallet &wallet, const CWalletTx &wtx, | WalletTxOut MakeWalletTxOut(CWallet &wallet, const CWalletTx &wtx, int n, | ||||
int n, int depth) | int depth) | ||||
EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet) { | EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet) { | ||||
WalletTxOut result; | WalletTxOut result; | ||||
result.txout = wtx.tx->vout[n]; | result.txout = wtx.tx->vout[n]; | ||||
result.time = wtx.GetTxTime(); | result.time = wtx.GetTxTime(); | ||||
result.depth_in_main_chain = depth; | result.depth_in_main_chain = depth; | ||||
result.is_spent = wallet.IsSpent(COutPoint(wtx.GetId(), n)); | result.is_spent = wallet.IsSpent(COutPoint(wtx.GetId(), n)); | ||||
return result; | return result; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 446 Lines • Show Last 20 Lines |