From 28b839f306a933538dbfae998f82a41cc3c9dead Mon Sep 17 00:00:00 2001 From: niftynei Date: Wed, 5 Aug 2020 12:45:40 +0930 Subject: [PATCH] amount: add helper to convert u64 sats to amount_sat type --- common/amount.c | 5 +++++ common/amount.h | 1 + 2 files changed, 6 insertions(+) diff --git a/common/amount.c b/common/amount.c index 680499f39..6894c24bb 100644 --- a/common/amount.c +++ b/common/amount.c @@ -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)) diff --git a/common/amount.h b/common/amount.h index 3883e6320..b209881fb 100644 --- a/common/amount.h +++ b/common/amount.h @@ -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! */