Browse Source

common: add programatic initialization of msat

pr-2587
Michael Schmoock 6 years ago
committed by Christian Decker
parent
commit
a26665a421
  1. 10
      common/amount.c
  2. 4
      common/amount.h

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

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

Loading…
Cancel
Save