amount: add helper to convert u64 sats to amount_sat type

This commit is contained in:
niftynei
2020-08-05 12:45:40 +09:30
committed by Rusty Russell
parent 1ded3fc52f
commit 28b839f306
2 changed files with 6 additions and 0 deletions

View File

@@ -406,6 +406,11 @@ void amount_msat_from_u64(struct amount_msat *msat, u64 millisatoshis)
msat->millisatoshis = millisatoshis;
}
void amount_sat_from_u64(struct amount_sat *sat, u64 satoshis)
{
sat->satoshis = satoshis;
}
WARN_UNUSED_RESULT bool amount_msat_from_sat_u64(struct amount_msat *msat, u64 satoshis)
{
if (mul_overflows_u64(satoshis, MSAT_PER_SAT))

View File

@@ -130,6 +130,7 @@ WARN_UNUSED_RESULT bool amount_msat_to_u32(struct amount_msat msat,
/* Programatically initialize from various types */
void amount_msat_from_u64(struct amount_msat *msat, u64 millisatoshis);
void amount_sat_from_u64(struct amount_sat *sat, u64 satoshis);
WARN_UNUSED_RESULT bool amount_msat_from_sat_u64(struct amount_msat *msat, u64 satoshis);
/* Common operation: what is the HTLC fee for given feerate? Can overflow! */