Changeset View
Changeset View
Standalone View
Standalone View
src/interfaces/wallet.cpp
Show First 20 Lines • Show All 51 Lines • ▼ Show 20 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. | ||||
WalletTxStatus MakeWalletTxStatus(interfaces::Chain::Lock &locked_chain, | WalletTxStatus MakeWalletTxStatus(CWallet &wallet, const CWalletTx &wtx) { | ||||
const CWalletTx &wtx) { | |||||
WalletTxStatus result; | WalletTxStatus result; | ||||
result.block_height = wtx.m_confirm.block_height > 0 | result.block_height = wtx.m_confirm.block_height > 0 | ||||
? wtx.m_confirm.block_height | ? wtx.m_confirm.block_height | ||||
: 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( | wallet.chain().contextualCheckTransactionForCurrentBlock(*wtx.tx, | ||||
Params().GetConsensus(), *wtx.tx, state); | state); | ||||
result.is_trusted = wtx.IsTrusted(locked_chain); | result.is_trusted = wtx.IsTrusted(); | ||||
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. | ||||
WalletTxOut MakeWalletTxOut(CWallet &wallet, const CWalletTx &wtx, int n, | WalletTxOut MakeWalletTxOut(CWallet &wallet, const CWalletTx &wtx, int n, | ||||
▲ Show 20 Lines • Show All 219 Lines • ▼ Show 20 Lines | public: | ||||
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; | ||||
} | } | ||||
num_blocks = m_wallet->GetLastBlockHeight(); | num_blocks = m_wallet->GetLastBlockHeight(); | ||||
block_time = -1; | block_time = -1; | ||||
CHECK_NONFATAL(m_wallet->chain().findBlock( | CHECK_NONFATAL(m_wallet->chain().findBlock( | ||||
m_wallet->GetLastBlockHash(), FoundBlock().time(block_time))); | m_wallet->GetLastBlockHash(), FoundBlock().time(block_time))); | ||||
tx_status = MakeWalletTxStatus(*locked_chain, mi->second); | tx_status = MakeWalletTxStatus(*m_wallet, 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(); | ||||
LOCK(m_wallet->cs_wallet); | LOCK(m_wallet->cs_wallet); | ||||
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()) { | ||||
num_blocks = m_wallet->GetLastBlockHeight(); | num_blocks = m_wallet->GetLastBlockHeight(); | ||||
in_mempool = mi->second.InMempool(); | in_mempool = mi->second.InMempool(); | ||||
order_form = mi->second.vOrderForm; | order_form = mi->second.vOrderForm; | ||||
tx_status = MakeWalletTxStatus(*locked_chain, mi->second); | tx_status = MakeWalletTxStatus(*m_wallet, mi->second); | ||||
return MakeWalletTx(*m_wallet, mi->second); | return MakeWalletTx(*m_wallet, mi->second); | ||||
} | } | ||||
return {}; | return {}; | ||||
} | } | ||||
TransactionError | TransactionError | ||||
fillPSBT(PartiallySignedTransaction &psbtx, bool &complete, | fillPSBT(PartiallySignedTransaction &psbtx, bool &complete, | ||||
SigHashType sighash_type = | SigHashType sighash_type = | ||||
SigHashType().withForkId() /* SIGHASH_ALL|FORKID */, | SigHashType().withForkId() /* SIGHASH_ALL|FORKID */, | ||||
▲ Show 20 Lines • Show All 55 Lines • ▼ Show 20 Lines | public: | ||||
auto locked_chain = m_wallet->chain().lock(); | auto locked_chain = m_wallet->chain().lock(); | ||||
LOCK(m_wallet->cs_wallet); | LOCK(m_wallet->cs_wallet); | ||||
return m_wallet->GetCredit(txout, filter); | return m_wallet->GetCredit(txout, filter); | ||||
} | } | ||||
CoinsList listCoins() override { | CoinsList listCoins() override { | ||||
auto locked_chain = m_wallet->chain().lock(); | auto locked_chain = m_wallet->chain().lock(); | ||||
LOCK(m_wallet->cs_wallet); | LOCK(m_wallet->cs_wallet); | ||||
CoinsList result; | CoinsList result; | ||||
for (const auto &entry : m_wallet->ListCoins(*locked_chain)) { | for (const auto &entry : m_wallet->ListCoins()) { | ||||
auto &group = result[entry.first]; | auto &group = result[entry.first]; | ||||
for (const auto &coin : entry.second) { | for (const auto &coin : entry.second) { | ||||
group.emplace_back(COutPoint(coin.tx->GetId(), coin.i), | group.emplace_back(COutPoint(coin.tx->GetId(), coin.i), | ||||
MakeWalletTxOut(*m_wallet, *coin.tx, | MakeWalletTxOut(*m_wallet, *coin.tx, | ||||
coin.i, coin.nDepth)); | coin.i, coin.nDepth)); | ||||
} | } | ||||
} | } | ||||
return result; | return result; | ||||
▲ Show 20 Lines • Show All 125 Lines • Show Last 20 Lines |