common/amount: new types struct amount_msat and struct amount_sat.

They're generally used pass-by-copy (unusual for C structs, but
convenient they're basically u64) and all possibly problematic
operations return WARN_UNUSED_RESULT bool to make you handle the
over/underflow cases.

The new #include in json.h means we bolt11.c sees the amount.h definition
of MSAT_PER_BTC, so delete its local version.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2019-02-20 22:01:48 +10:30
parent 269dbe585c
commit 7fad7bccba
25 changed files with 780 additions and 5 deletions

View File

@@ -12,6 +12,7 @@ static bool print_superverbose;
#include <ccan/array_size/array_size.h>
#include <ccan/err/err.h>
#include <ccan/str/hex/hex.h>
#include <common/amount.h>
#include <common/key_derive.h>
#include <common/status.h>