13 std::map<TxId, CWalletTx>::const_iterator
mi =
17 if (
txin.prevout.GetN() <
prev.tx->vout.size()) {
38 if (
txin.prevout.GetN() >=
prev.tx->vout.size()) {
43 if (!(
wallet.IsMine(
prev.tx->vout[
txin.prevout.GetN()]) & filter)) {
54 throw std::runtime_error(std::string(
__func__) +
55 ": value out of range");
67 throw std::runtime_error(std::string(
__func__) +
68 ": value out of range");
85 if (
wallet.IsMine(script)) {
90 if (!
wallet.FindAddressBookEntry(address)) {
105 throw std::runtime_error(std::string(
__func__) +
106 ": value out of range");
117 throw std::runtime_error(std::string(
__func__) +
118 ": value out of range");
136 return amount.m_value[filter];
145 if (
wallet.IsTxImmatureCoinBase(wtx)) {
166 if (wtx.
tx->vin.empty()) {
196 if (
wallet.IsTxImmatureCoinBase(wtx) &&
wallet.IsTxInMainChain(wtx)) {
209 if (
wallet.IsTxImmatureCoinBase(wtx) &&
wallet.IsTxInMainChain(wtx)) {
228 if (
wallet.IsTxImmatureCoinBase(wtx)) {
242 for (
uint32_t i = 0; i < wtx.
tx->vout.size(); i++) {
245 const CTxOut &txout = wtx.
tx->vout[i];
248 throw std::runtime_error(std::string(
__func__) +
249 " : value out of range");
280 for (
unsigned int i = 0; i < wtx.
tx->vout.size(); ++i) {
281 const CTxOut &txout = wtx.
tx->vout[i];
291 }
else if (!(
fIsMine & filter)) {
300 wallet.WalletLogPrintf(
"CWalletTx::GetAmounts: Unknown transaction "
301 "type found, txid %s\n",
330 int nDepth =
wallet.GetTxDepthInMainChain(wtx);
340 if (!
wallet.m_spend_zero_conf_change ||
355 if (parent ==
nullptr) {
390 for (
const auto &entry :
wallet.mapWallet) {
407 ret.m_watchonly_immature +=
414 std::map<CTxDestination, Amount>
balances;
425 if (
wallet.IsTxImmatureCoinBase(wtx)) {
429 int nDepth =
wallet.GetTxDepthInMainChain(wtx);
434 for (
uint32_t i = 0; i < wtx.
tx->vout.size(); i++) {
436 if (!
wallet.IsMine(wtx.
tx->vout[i])) {
445 : wtx.
tx->vout[i].nValue;
455 std::set<std::set<CTxDestination>>
groupings;
461 if (wtx.
tx->vin.size() > 0) {
464 for (
const auto &
txin : wtx.
tx->vin) {
473 .tx->vout[
txin.prevout.GetN()]
485 for (
const auto &txout : wtx.
tx->vout) {
505 for (
const auto &txout : wtx.
tx->vout) {
506 if (
wallet.IsMine(txout)) {
522 std::map<CTxDestination, std::set<CTxDestination> *>
setmap;
525 std::set<std::set<CTxDestination> *>
hits;
526 std::map<CTxDestination, std::set<CTxDestination> *>::iterator it;
529 hits.insert((*it).second);
534 std::set<CTxDestination> *
merged =
536 for (std::set<CTxDestination> *
hit :
hits) {
549 std::set<std::set<CTxDestination>>
ret;
bool MoneyRange(const Amount nValue)
An outpoint - a combination of a transaction hash and an index n into its vout.
Serialized script, used inside transaction inputs and outputs.
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.
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.
CachableAmount m_amounts[AMOUNTTYPE_ENUM_ELEMENTS]
bool m_is_cache_empty
This flag is true if all m_amounts caches are empty.
std::string ToString() const
isminetype
IsMine() return codes.
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...
Amount CachedTxGetImmatureCredit(const CWallet &wallet, const CWalletTx &wtx, bool fUseCache)
bool CachedTxIsFromMe(const CWallet &wallet, const CWalletTx &wtx, const isminefilter &filter)
Amount OutputGetChange(const CWallet &wallet, const CTxOut &txout)
std::set< std::set< CTxDestination > > GetAddressGroupings(const CWallet &wallet)
Amount CachedTxGetAvailableCredit(const CWallet &wallet, const CWalletTx &wtx, bool fUseCache, const isminefilter &filter)
Amount CachedTxGetChange(const CWallet &wallet, const CWalletTx &wtx)
Amount CachedTxGetDebit(const CWallet &wallet, const CWalletTx &wtx, const isminefilter &filter)
filter decides which addresses will count towards the debit
bool ScriptIsChange(const CWallet &wallet, const CScript &script)
Amount TxGetCredit(const CWallet &wallet, const CTransaction &tx, const isminefilter &filter)
Amount CachedTxGetImmatureWatchOnlyCredit(const CWallet &wallet, const CWalletTx &wtx, const bool fUseCache)
void CachedTxGetAmounts(const CWallet &wallet, const CWalletTx &wtx, std::list< COutputEntry > &listReceived, std::list< COutputEntry > &listSent, Amount &nFee, const isminefilter &filter)
Amount OutputGetCredit(const CWallet &wallet, const CTxOut &txout, const isminefilter &filter)
Amount TxGetChange(const CWallet &wallet, const CTransaction &tx)
std::map< CTxDestination, Amount > GetAddressBalances(const CWallet &wallet)
bool AllInputsMine(const CWallet &wallet, const CTransaction &tx, const isminefilter &filter)
Returns whether all of the inputs match the filter.
Amount CachedTxGetCredit(const CWallet &wallet, const CWalletTx &wtx, const isminefilter &filter)
bool OutputIsChange(const CWallet &wallet, const CTxOut &txout)
bool CachedTxIsTrusted(const CWallet &wallet, const CWalletTx &wtx, std::set< TxId > &trusted_parents)
Balance GetBalance(const CWallet &wallet, const int min_depth, bool avoid_reuse)
static Amount GetCachableAmount(const CWallet &wallet, const CWalletTx &wtx, CWalletTx::AmountType type, const isminefilter &filter, bool recalculate=false)
isminetype InputIsMine(const CWallet &wallet, const CTxIn &txin)
bool ExtractDestination(const CScript &scriptPubKey, CTxDestination &addressRet)
Parse a standard scriptPubKey for the destination address.
std::variant< CNoDestination, PKHash, ScriptHash > CTxDestination
A txout script template with a specific destination.
static constexpr Amount zero() noexcept
Amount m_value[ISMINE_ENUM_ELEMENTS]
void Set(isminefilter filter, Amount value)
std::bitset< ISMINE_ENUM_ELEMENTS > m_cached
A TxId is the identifier of a transaction.
#define AssertLockHeld(cs)
@ WALLET_FLAG_AVOID_REUSE