Changeset View
Changeset View
Standalone View
Standalone View
src/interfaces/wallet.cpp
Show All 9 Lines | |||||
#include <interfaces/chain.h> | #include <interfaces/chain.h> | ||||
#include <interfaces/handler.h> | #include <interfaces/handler.h> | ||||
#include <policy/fees.h> | #include <policy/fees.h> | ||||
#include <primitives/transaction.h> | #include <primitives/transaction.h> | ||||
#include <script/standard.h> | #include <script/standard.h> | ||||
#include <support/allocators/secure.h> | #include <support/allocators/secure.h> | ||||
#include <sync.h> | #include <sync.h> | ||||
#include <ui_interface.h> | #include <ui_interface.h> | ||||
#include <util/check.h> | |||||
#include <util/system.h> | #include <util/system.h> | ||||
#include <wallet/fees.h> | #include <wallet/fees.h> | ||||
#include <wallet/ismine.h> | #include <wallet/ismine.h> | ||||
#include <wallet/load.h> | #include <wallet/load.h> | ||||
#include <wallet/psbtwallet.h> | #include <wallet/psbtwallet.h> | ||||
#include <wallet/rpcdump.h> | #include <wallet/rpcdump.h> | ||||
#include <wallet/wallet.h> | #include <wallet/wallet.h> | ||||
Show All 28 Lines | WalletTx MakeWalletTx(CWallet &wallet, const CWalletTx &wtx) { | ||||
result.is_coinbase = wtx.IsCoinBase(); | result.is_coinbase = wtx.IsCoinBase(); | ||||
return result; | return result; | ||||
} | } | ||||
//! Construct wallet tx status struct. | //! Construct wallet tx status struct. | ||||
WalletTxStatus MakeWalletTxStatus(interfaces::Chain::Lock &locked_chain, | WalletTxStatus MakeWalletTxStatus(interfaces::Chain::Lock &locked_chain, | ||||
const CWalletTx &wtx) { | const CWalletTx &wtx) { | ||||
WalletTxStatus result; | WalletTxStatus result; | ||||
result.block_height = | result.block_height = wtx.m_confirm.block_height > 0 | ||||
locked_chain.getBlockHeight(wtx.m_confirm.hashBlock) | ? wtx.m_confirm.block_height | ||||
.get_value_or(std::numeric_limits<int>::max()); | : 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); | ||||
▲ Show 20 Lines • Show All 225 Lines • ▼ Show 20 Lines | public: | ||||
TRY_LOCK(m_wallet->cs_wallet, locked_wallet); | TRY_LOCK(m_wallet->cs_wallet, locked_wallet); | ||||
if (!locked_wallet) { | if (!locked_wallet) { | ||||
return false; | return false; | ||||
} | } | ||||
auto mi = m_wallet->mapWallet.find(txid); | auto mi = m_wallet->mapWallet.find(txid); | ||||
if (mi == m_wallet->mapWallet.end()) { | if (mi == m_wallet->mapWallet.end()) { | ||||
return false; | return false; | ||||
} | } | ||||
if (Optional<int> height = locked_chain->getHeight()) { | num_blocks = m_wallet->GetLastBlockHeight(); | ||||
num_blocks = *height; | |||||
block_time = locked_chain->getBlockTime(*height); | |||||
} else { | |||||
num_blocks = -1; | |||||
block_time = -1; | block_time = -1; | ||||
} | CHECK_NONFATAL(m_wallet->chain().findBlock( | ||||
m_wallet->GetLastBlockHash(), FoundBlock().time(block_time))); | |||||
tx_status = MakeWalletTxStatus(*locked_chain, mi->second); | tx_status = MakeWalletTxStatus(*locked_chain, mi->second); | ||||
return true; | return true; | ||||
} | } | ||||
WalletTx getWalletTxDetails(const TxId &txid, WalletTxStatus &tx_status, | WalletTx getWalletTxDetails(const TxId &txid, WalletTxStatus &tx_status, | ||||
WalletOrderForm &order_form, | WalletOrderForm &order_form, | ||||
bool &in_mempool, | bool &in_mempool, | ||||
int &num_blocks) override { | int &num_blocks) override { | ||||
auto locked_chain = m_wallet->chain().lock(); | auto locked_chain = m_wallet->chain().lock(); | ||||
Show All 36 Lines | public: | ||||
auto locked_chain = m_wallet->chain().lock(true /* try_lock */); | auto locked_chain = m_wallet->chain().lock(true /* try_lock */); | ||||
if (!locked_chain) { | if (!locked_chain) { | ||||
return false; | return false; | ||||
} | } | ||||
TRY_LOCK(m_wallet->cs_wallet, locked_wallet); | TRY_LOCK(m_wallet->cs_wallet, locked_wallet); | ||||
if (!locked_wallet) { | if (!locked_wallet) { | ||||
return false; | return false; | ||||
} | } | ||||
num_blocks = m_wallet->GetLastBlockHeight(); | |||||
balances = getBalances(); | balances = getBalances(); | ||||
num_blocks = locked_chain->getHeight().value_or(-1); | |||||
return true; | return true; | ||||
} | } | ||||
Amount getBalance() override { | Amount getBalance() override { | ||||
return m_wallet->GetBalance().m_mine_trusted; | return m_wallet->GetBalance().m_mine_trusted; | ||||
} | } | ||||
Amount getAvailableBalance(const CCoinControl &coin_control) override { | Amount getAvailableBalance(const CCoinControl &coin_control) override { | ||||
return m_wallet->GetAvailableBalance(&coin_control); | return m_wallet->GetAvailableBalance(&coin_control); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 158 Lines • Show Last 20 Lines |