17 if (
prev &&
txin.prevout.n <
prev->GetTx()->vout.size()) {
35 throw std::runtime_error(std::string(
__func__) +
": value out of range");
47 throw std::runtime_error(std::string(
__func__) +
": value out of range");
67 if (!
wallet.FindAddressBookEntry(address)) {
83 throw std::runtime_error(std::string(
__func__) +
": value out of range");
95 throw std::runtime_error(std::string(
__func__) +
": value out of range");
115 if (
wallet.IsTxImmatureCoinBase(wtx))
124 if (wtx.
GetTx()->vin.empty())
158 for (
unsigned int i = 0; i < wtx.
GetTx()->vout.size(); ++i)
178 wallet.WalletLogPrintf(
"CWalletTx::GetAmounts: Unknown transaction type found, txid %s",
225 if (parent ==
nullptr)
return false;
252 for (
const auto& [outpoint,
txo] :
wallet.GetTXOs()) {
259 switch (
wallet.HowSpent(outpoint)) {
273 bucket = &
ret.m_mine_immature;
275 bucket = &
ret.m_mine_trusted;
276 }
else if (!is_trusted && wtx.
InMempool()) {
277 bucket = &
ret.m_mine_untrusted_pending;
284 bucket = &
ret.m_mine_used;
299 std::map<CTxDestination, CAmount>
balances;
304 for (
const auto& [outpoint,
txo] :
wallet.GetTXOs()) {
308 if (
wallet.IsTxImmatureCoinBase(wtx))
continue;
310 int nDepth =
wallet.GetTxDepthInMainChain(wtx);
328 std::set< std::set<CTxDestination> >
groupings;
335 if (wtx.
GetTx()->vin.size() > 0)
370 for (
const auto& txout : wtx.
GetTx()->vout)
383 std::map< CTxDestination, std::set<CTxDestination>* >
setmap;
387 std::set< std::set<CTxDestination>* >
hits;
388 std::map< CTxDestination, std::set<CTxDestination>* >::iterator it;
391 hits.insert((*it).second);
394 std::set<CTxDestination>*
merged =
new std::set<CTxDestination>(
_grouping);
395 for (std::set<CTxDestination>*
hit :
hits)
408 std::set< std::set<CTxDestination> >
ret;
bool ExtractDestination(const CScript &scriptPubKey, CTxDestination &addressRet)
Parse a scriptPubKey for the destination.
std::variant< CNoDestination, PubKeyDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, PayToAnchor, WitnessUnknown > CTxDestination
A txout script categorized into standard templates.
bool MoneyRange(const CAmount &nValue)
int64_t CAmount
Amount in satoshis (Can be negative)
#define Assume(val)
Assume is the identity function.
Serialized script, used inside transaction inputs and outputs.
bool IsUnspendable() const
Returns whether the script is guaranteed to fail at execution, regardless of the initial stack.
The basic transaction that is broadcasted on the network and contained in blocks.
const std::vector< CTxOut > vout
const std::vector< CTxIn > vin
An input of a transaction.
An output of a transaction.
std::string ToString() const
A CWallet maintains a set of transactions and balances, and provides the ability to create new transa...
A transaction with a bunch of additional info that only the owner cares about.
bool isBlockConflicted() const
const Txid & GetHash() const LIFETIMEBOUND
std::optional< bool > m_cached_from_me
CachableAmount m_amounts[AMOUNTTYPE_ENUM_ELEMENTS]
CTransactionRef GetTx() const
bool m_is_cache_empty
This flag is true if all m_amounts caches are empty.
bool OutputIsChange(const CWallet &wallet, const CTxOut &txout)
bool AllInputsMine(const CWallet &wallet, const CTransaction &tx)
Returns whether all of the inputs belong to the wallet.
bool CachedTxIsFromMe(const CWallet &wallet, const CWalletTx &wtx)
CAmount TxGetChange(const CWallet &wallet, const CTransaction &tx)
bool CachedTxIsTrusted(const CWallet &wallet, const CWalletTx &wtx, std::set< Txid > &trusted_parents)
bool ScriptIsChange(const CWallet &wallet, const CScript &script)
CAmount TxGetCredit(const CWallet &wallet, const CTransaction &tx)
static CAmount GetCachableAmount(const CWallet &wallet, const CWalletTx &wtx, CWalletTx::AmountType type, bool avoid_reuse)
CAmount OutputGetChange(const CWallet &wallet, const CTxOut &txout)
CAmount CachedTxGetDebit(const CWallet &wallet, const CWalletTx &wtx, bool avoid_reuse)
CAmount CachedTxGetChange(const CWallet &wallet, const CWalletTx &wtx)
CAmount CachedTxGetCredit(const CWallet &wallet, const CWalletTx &wtx, bool avoid_reuse)
void CachedTxGetAmounts(const CWallet &wallet, const CWalletTx &wtx, std::list< COutputEntry > &listReceived, std::list< COutputEntry > &listSent, CAmount &nFee, bool include_change)
Balance GetBalance(const CWallet &wallet, const int min_depth, bool avoid_reuse, bool include_nonmempool)
std::map< CTxDestination, CAmount > GetAddressBalances(const CWallet &wallet)
@ WALLET_FLAG_AVOID_REUSE
bool InputIsMine(const CWallet &wallet, const CTxIn &txin)
CAmount OutputGetCredit(const CWallet &wallet, const CTxOut &txout)
std::set< std::set< CTxDestination > > GetAddressGroupings(const CWallet &wallet)
void Set(bool avoid_reuse, CAmount value)
#define AssertLockHeld(cs)
constexpr auto Ticks(Dur2 d)
Helper to count the seconds of a duration/time_point.