13 std::map<uint256, CWalletTx>::const_iterator mi = mapWallet.find(txin.
prevout.
hash);
14 if (mi != mapWallet.end())
30 if (mi == mapWallet.end())
47 throw std::runtime_error(std::string(__func__) +
": value out of range");
59 throw std::runtime_error(std::string(__func__) +
": value out of range");
95 throw std::runtime_error(std::string(__func__) +
": value out of range");
107 throw std::runtime_error(std::string(__func__) +
": value out of range");
115 if (recalculate || !amount.m_cached[filter]) {
119 return amount.m_value[filter];
200 for (
unsigned int i = 0; i <
tx->vout.size(); i++)
206 throw std::runtime_error(std::string(__func__) +
" : value out of range");
222 listReceived.clear();
230 nFee = nDebit - nValueOut;
235 for (
unsigned int i = 0; i <
tx->vout.size(); ++i)
248 else if (!(fIsMine & filter))
265 listSent.push_back(output);
268 if (fIsMine & filter)
269 listReceived.push_back(output);
278 if (!
chain().checkFinalTx(*wtx.
tx))
return false;
280 if (nDepth >= 1)
return true;
281 if (nDepth < 0)
return false;
289 for (
const CTxIn& txin : wtx.
tx->vin)
293 if (parent ==
nullptr)
return false;
298 if (trusted_parents.count(parent->
GetHash()))
continue;
300 if (!
IsTrusted(*parent, trusted_parents))
return false;
301 trusted_parents.insert(parent->
GetHash());
308 std::set<uint256> trusted_parents;
319 std::set<uint256> trusted_parents;
320 for (
const auto& entry : mapWallet)
323 const bool is_trusted{
IsTrusted(wtx, trusted_parents)};
327 if (is_trusted && tx_depth >= min_depth) {
331 if (!is_trusted && tx_depth == 0 && wtx.
InMempool()) {
344 std::map<CTxDestination, CAmount> balances;
348 std::set<uint256> trusted_parents;
349 for (
const auto& walletEntry : mapWallet)
351 const CWalletTx& wtx = walletEntry.second;
363 for (
unsigned int i = 0; i < wtx.
tx->vout.size(); i++)
383 std::set< std::set<CTxDestination> > groupings;
384 std::set<CTxDestination> grouping;
386 for (
const auto& walletEntry : mapWallet)
388 const CWalletTx& wtx = walletEntry.second;
390 if (wtx.
tx->vin.size() > 0)
392 bool any_mine =
false;
394 for (
const CTxIn& txin : wtx.
tx->vin)
401 grouping.insert(address);
408 for (
const CTxOut& txout : wtx.
tx->vout)
414 grouping.insert(txoutAddr);
417 if (grouping.size() > 0)
419 groupings.insert(grouping);
425 for (
const auto& txout : wtx.
tx->vout)
431 grouping.insert(address);
432 groupings.insert(grouping);
437 std::set< std::set<CTxDestination>* > uniqueGroupings;
438 std::map< CTxDestination, std::set<CTxDestination>* > setmap;
439 for (std::set<CTxDestination> _grouping : groupings)
442 std::set< std::set<CTxDestination>* > hits;
443 std::map< CTxDestination, std::set<CTxDestination>* >::iterator it;
445 if ((it = setmap.find(address)) != setmap.end())
446 hits.insert((*it).second);
449 std::set<CTxDestination>* merged =
new std::set<CTxDestination>(_grouping);
450 for (std::set<CTxDestination>* hit : hits)
452 merged->insert(hit->begin(), hit->end());
453 uniqueGroupings.erase(hit);
456 uniqueGroupings.insert(merged);
460 setmap[element] = merged;
463 std::set< std::set<CTxDestination> > ret;
464 for (
const std::set<CTxDestination>* uniqueGrouping : uniqueGroupings)
466 ret.insert(*uniqueGrouping);
467 delete uniqueGrouping;
bool IsWalletFlagSet(uint64_t flag) const override
check if a certain wallet flag is set
CAmount GetAvailableCredit(bool fUseCache=true, const isminefilter &filter=ISMINE_SPENDABLE) const NO_THREAD_SAFETY_ANALYSIS
bool m_is_cache_empty
This flag is true if all m_amounts caches are empty.
bool ExtractDestination(const CScript &scriptPubKey, CTxDestination &addressRet)
Parse a standard scriptPubKey for the destination address.
CAmount GetImmatureCredit(bool fUseCache=true) const
isminetype IsMine(const CTxDestination &dest) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
bool IsTrusted(const CWalletTx &wtx, std::set< uint256 > &trusted_parents) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
CAmount GetCachableAmount(AmountType type, const isminefilter &filter, bool recalculate=false) const
bool IsFromMe(const isminefilter &filter) const
CAmount m_mine_untrusted_pending
Untrusted, but in mempool (pending)
CAmount m_value[ISMINE_ENUM_ELEMENTS]
std::set< std::set< CTxDestination > > GetAddressGroupings() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
bool IsAllFromMe(const CTransaction &tx, const isminefilter &filter) const
Returns whether all of the inputs match the filter.
bool MoneyRange(const CAmount &nValue)
CAmount GetCredit(const isminefilter &filter) const
bool m_spend_zero_conf_change
Allow Coin Selection to pick unconfirmed UTXOs that were sent from our own wallet if it cannot fund t...
bool IsInMainChain() const
CAmount m_mine_trusted
Trusted, at depth=GetBalance.min_depth or more.
CAmount m_watchonly_untrusted_pending
CAmount m_watchonly_immature
const CWalletTx * GetWalletTx(const uint256 &hash) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Balance GetBalance(int min_depth=0, bool avoid_reuse=true) const
CAmount m_watchonly_trusted
const std::vector< CTxIn > vin
bool IsUnspendable() const
Returns whether the script is guaranteed to fail at execution, regardless of the initial stack...
interfaces::Chain & chain() const
Interface for accessing chain state.
int64_t CAmount
Amount in satoshis (Can be negative)
std::string ToString(const T &t)
Locale-independent version of std::to_string.
CAmount m_mine_immature
Immature coinbases in the main chain.
void WalletLogPrintf(std::string fmt, Params... parameters) const
Prepends the wallet name in logging output to ease debugging in multi-wallet use cases.
An input of a transaction.
void Set(isminefilter filter, CAmount value)
CAmount GetChange() const
const std::vector< CTxOut > vout
CAmount GetChange(const CTxOut &txout) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
std::variant< CNoDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, WitnessUnknown > CTxDestination
A txout script template with a specific destination.
isminetype
IsMine() return codes, which depend on ScriptPubKeyMan implementation.
bool IsChange(const CTxOut &txout) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
An output of a transaction.
std::map< CTxDestination, CAmount > GetAddressBalances() const
const uint256 & GetHash() const
A transaction with a bunch of additional info that only the owner cares about.
void GetAmounts(std::list< COutputEntry > &listReceived, std::list< COutputEntry > &listSent, CAmount &nFee, const isminefilter &filter) const
bool IsImmatureCoinBase() const
CachableAmount m_amounts[AMOUNTTYPE_ENUM_ELEMENTS]
CAmount GetCredit(const CTxOut &txout, const isminefilter &filter) const
CAmount GetDebit(const CTxIn &txin, const isminefilter &filter) const
Returns amount of debit if the input matches the filter, otherwise returns 0.
Serialized script, used inside transaction inputs and outputs.
int GetDepthInMainChain() const NO_THREAD_SAFETY_ANALYSIS
Return depth of transaction in blockchain: <0 : conflicts with a transaction this deep in the blockch...
CAmount GetDebit(const isminefilter &filter) const
filter decides which addresses will count towards the debit
RecursiveMutex cs_wallet
Main wallet lock.
bool IsSpent(const uint256 &hash, unsigned int n) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Outpoint is spent if any non-conflicted transaction spends it:
The basic transaction that is broadcasted on the network and contained in blocks. ...
bool IsSpentKey(const uint256 &hash, unsigned int n) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
const CAddressBookData * FindAddressBookEntry(const CTxDestination &, bool allow_change=false) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
CAmount GetImmatureWatchOnlyCredit(const bool fUseCache=true) const
const CWallet *const pwallet