MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / GetChange

Method GetChange

src/wallet/coinselection.cpp:1048–1065  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1046}
1047
1048CAmount SelectionResult::GetChange(const CAmount min_viable_change, const CAmount change_fee) const
1049{
1050 // change = SUM(inputs) - SUM(outputs) - fees
1051 // 1) With SFFO we don't pay any fees
1052 // 2) Otherwise we pay all the fees:
1053 // - input fees are covered by GetSelectedEffectiveValue()
1054 // - non_input_fee is included in m_target
1055 // - change_fee
1056 const CAmount change = m_use_effective
1057 ? GetSelectedEffectiveValue() - m_target - change_fee
1058 : GetSelectedValue() - m_target;
1059
1060 if (change < min_viable_change) {
1061 return 0;
1062 }
1063
1064 return change;
1065}
1066
1067} // namespace wallet

Callers 3

spend.cppFile · 0.80
FUZZ_TARGETFunction · 0.80

Calls

no outgoing calls

Tested by 2

FUZZ_TARGETFunction · 0.64