diff --git a/common/amount.c b/common/amount.c index 786d56db4..74fa2252c 100644 --- a/common/amount.c +++ b/common/amount.c @@ -370,6 +370,16 @@ bool amount_msat_to_u32(struct amount_msat msat, u32 *millisatoshis) return true; } +void amount_msat_from_u64(struct amount_msat *msat, u64 millisatoshis) +{ + msat->millisatoshis = millisatoshis; +} + +void amount_msat_from_sat_u64(struct amount_msat *msat, u64 satoshis) +{ + msat->millisatoshis = satoshis * 1000; +} + bool amount_msat_fee(struct amount_msat *fee, struct amount_msat amt, u32 fee_base_msat, diff --git a/common/amount.h b/common/amount.h index eac851b7b..26602312b 100644 --- a/common/amount.h +++ b/common/amount.h @@ -102,6 +102,10 @@ bool amount_msat_less_eq_sat(struct amount_msat msat, struct amount_sat sat); WARN_UNUSED_RESULT bool amount_msat_to_u32(struct amount_msat msat, u32 *millisatoshis); +/* Programatically initialize from various types */ +void amount_msat_from_u64(struct amount_msat *msat, u64 millisatoshis); +void amount_msat_from_sat_u64(struct amount_msat *msat, u64 satoshis); + /* Common operation: what is the HTLC fee for given feerate? Can overflow! */ WARN_UNUSED_RESULT bool amount_msat_fee(struct amount_msat *fee, struct amount_msat amt,