MCPcopy Create free account
hub / github.com/ElementsProject/lightning / change_amount

Function change_amount

bitcoin/tx.c:980–997  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

978}
979
980struct amount_sat change_amount(struct amount_sat excess, u32 feerate_perkw,
981 size_t total_weight)
982{
983 struct amount_sat fee = change_fee(feerate_perkw, total_weight);
984
985 if (!amount_sat_sub(&excess, excess, fee))
986 return AMOUNT_SAT(0);
987
988 if (chainparams->is_elements) {
989 if (!amount_sat_greater_eq(excess, AMOUNT_SAT(546)))
990 return AMOUNT_SAT(0);
991 } else {
992 if (!amount_sat_greater_eq(excess, AMOUNT_SAT(330)))
993 return AMOUNT_SAT(0);
994 }
995
996 return excess;
997}
998
999u32 tx_feerate(const struct bitcoin_tx *tx)
1000{

Callers 4

finish_psbtFunction · 0.85
change_for_emergencyFunction · 0.85
mw_after_fundpsbtFunction · 0.85

Calls 3

change_feeFunction · 0.85
amount_sat_subFunction · 0.50
amount_sat_greater_eqFunction · 0.50

Tested by

no test coverage detected