common: add programatic initialization of msat

This commit is contained in:
Michael Schmoock 2019-04-03 10:20:35 +02:00 committed by Christian Decker
parent 898df57fa0
commit a26665a421
2 changed files with 14 additions and 0 deletions

View File

@ -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,

View File

@ -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,