mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-22 22:45:27 +01:00
amount: add a helper for msat == sat
Handy dandy method for verifying that a millisatoshi-typed amount is equivalent to a satoshi-typed amount.
This commit is contained in:
parent
824e8fa72b
commit
3a4a3597a3
2 changed files with 12 additions and 0 deletions
|
@ -381,6 +381,16 @@ bool amount_msat_less_eq_sat(struct amount_msat msat, struct amount_sat sat)
|
||||||
return msat.millisatoshis <= msat_from_sat.millisatoshis;
|
return msat.millisatoshis <= msat_from_sat.millisatoshis;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool amount_msat_eq_sat(struct amount_msat msat, struct amount_sat sat)
|
||||||
|
{
|
||||||
|
struct amount_msat msat_from_sat;
|
||||||
|
|
||||||
|
if (!amount_sat_to_msat(&msat_from_sat, sat))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return msat.millisatoshis == msat_from_sat.millisatoshis;
|
||||||
|
}
|
||||||
|
|
||||||
bool amount_msat_to_u32(struct amount_msat msat, u32 *millisatoshis)
|
bool amount_msat_to_u32(struct amount_msat msat, u32 *millisatoshis)
|
||||||
{
|
{
|
||||||
if (amount_msat_greater_eq(msat, AMOUNT_MSAT(0x100000000)))
|
if (amount_msat_greater_eq(msat, AMOUNT_MSAT(0x100000000)))
|
||||||
|
|
|
@ -105,6 +105,8 @@ bool amount_msat_greater_eq_sat(struct amount_msat msat, struct amount_sat sat);
|
||||||
bool amount_msat_less_sat(struct amount_msat msat, struct amount_sat sat);
|
bool amount_msat_less_sat(struct amount_msat msat, struct amount_sat sat);
|
||||||
/* Is msat <= sat? */
|
/* Is msat <= sat? */
|
||||||
bool amount_msat_less_eq_sat(struct amount_msat msat, struct amount_sat sat);
|
bool amount_msat_less_eq_sat(struct amount_msat msat, struct amount_sat sat);
|
||||||
|
/* Is msat == sat? */
|
||||||
|
bool amount_msat_eq_sat(struct amount_msat msat, struct amount_sat sat);
|
||||||
|
|
||||||
/* Check whether this asset is actually the main / fee-paying asset of the
|
/* Check whether this asset is actually the main / fee-paying asset of the
|
||||||
* current chain. */
|
* current chain. */
|
||||||
|
|
Loading…
Add table
Reference in a new issue