MCPcopy Create free account
hub / github.com/ElementsProject/elements / TxGetCredit

Function TxGetCredit

src/wallet/receive.cpp:68–89  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

66}
67
68CAmountMap TxGetCredit(const CWallet& wallet, const CWalletTx& wtx, const isminefilter& filter) {
69 CAmountMap nCredit;
70 {
71 LOCK(wallet.cs_wallet);
72
73 CAsset pegged_asset{Params().GetConsensus().pegged_asset};
74 for (unsigned int i = 0; i < wtx.tx->vout.size(); ++i) {
75 if (wallet.IsMine(wtx.tx->vout[i]) & filter) {
76 CAsset asset{wtx.GetOutputAsset(wallet, i)};
77 CAmount credit = std::max<CAmount>(0, wtx.GetOutputValueOut(wallet, i));
78 if (asset == pegged_asset && !MoneyRange(credit)) {
79 throw std::runtime_error(std::string(__func__) + ": value out of range");
80 }
81
82 nCredit[asset] += credit;
83 if (!MoneyRange(nCredit, pegged_asset))
84 throw std::runtime_error(std::string(__func__) + ": value out of range");
85 }
86 }
87 }
88 return nCredit;
89}
90
91CAmountMap GetChange(const CWallet& wallet, const CWalletTx& wtx) {
92 CAmountMap nChange;

Callers 1

GetCachableAmountFunction · 0.85

Calls 6

GetOutputAssetMethod · 0.80
GetOutputValueOutMethod · 0.80
ParamsClass · 0.50
MoneyRangeFunction · 0.50
sizeMethod · 0.45
IsMineMethod · 0.45

Tested by

no test coverage detected