Skip to content
Permalink
Browse files

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>
  • Loading branch information...
rustyrussell committed Feb 17, 2019
1 parent cd415ff commit 5e949f356aeb4b0b13dc175c9b746d6cb317cdbf
@@ -33,8 +33,9 @@ ALL_GEN_HEADERS += $(LIGHTNINGD_CHANNEL_HEADERS_GEN)

# Common source we use.
CHANNELD_COMMON_OBJS := \
common/amount.o \
common/base32.o \
common/bip32.o \
common/bip32.o \
common/channel_config.o \
common/crypto_state.o \
common/crypto_sync.o \
@@ -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>

@@ -7,11 +7,15 @@
#include <bitcoin/pubkey.h>
#include <ccan/err/err.h>
#include <ccan/str/hex/hex.h>
#include <common/amount.h>
#include <common/sphinx.h>
#include <common/type_to_string.h>
#include <stdio.h>
#include <wally_core.h>

/* AUTOGENERATED MOCKS START */
/* AUTOGENERATED MOCKS END */

void status_fmt(enum log_level level UNUSED, const char *fmt, ...)
{
va_list ap;
@@ -1,4 +1,5 @@
#include <assert.h>
#include <common/amount.h>
#include <fcntl.h>
#include <sys/socket.h>
#include <sys/stat.h>
@@ -42,6 +42,7 @@ $(LIGHTNINGD_CLOSING_OBJS): $(LIGHTNINGD_HEADERS)

# Common source we use.
CLOSINGD_COMMON_OBJS := \
common/amount.o \
common/base32.o \
common/bip32.o \
common/close_tx.o \
@@ -1,4 +1,5 @@
COMMON_SRC_NOGEN := \
common/amount.c \
common/base32.c \
common/bech32.c \
common/bech32_util.c \
Oops, something went wrong.

0 comments on commit 5e949f3

Please sign in to comment.
You can’t perform that action at this time.