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

Function GetChange

src/wallet/receive.cpp:91–109  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

89}
90
91CAmountMap GetChange(const CWallet& wallet, const CWalletTx& wtx) {
92 CAmountMap nChange;
93 for (unsigned int i = 0; i < wtx.tx->vout.size(); ++i) {
94 if (OutputIsChange(wallet, wtx.tx->vout[i])) {
95 CAmount change = wtx.GetOutputValueOut(wallet, i);
96 if (change < 0) {
97 continue;
98 }
99
100 if (!MoneyRange(change))
101 throw std::runtime_error(std::string(__func__) + ": value out of range");
102
103 nChange[wtx.GetOutputAsset(wallet, i)] += change;
104 if (!MoneyRange(nChange))
105 throw std::runtime_error(std::string(__func__) + ": value out of range");
106 }
107 }
108 return nChange;
109}
110
111bool OutputIsChange(const CWallet& wallet, const CTxOut& txout)
112{

Callers 1

TxGetChangeFunction · 0.85

Calls 5

OutputIsChangeFunction · 0.85
GetOutputValueOutMethod · 0.80
GetOutputAssetMethod · 0.80
MoneyRangeFunction · 0.50
sizeMethod · 0.45

Tested by

no test coverage detected