diff --git a/bitcoin/chainparams.c b/bitcoin/chainparams.c index 3dc5682f4..ef070e8e7 100644 --- a/bitcoin/chainparams.c +++ b/bitcoin/chainparams.c @@ -17,8 +17,8 @@ const struct chainparams networks[] = { *... * - MUST set `funding_satoshis` to less than 2^24 satoshi. */ - .max_funding = AMOUNT_SAT((1 << 24) - 1), - .max_payment = AMOUNT_MSAT(0xFFFFFFFFULL), + .max_funding = AMOUNT_SAT_INIT((1 << 24) - 1), + .max_payment = AMOUNT_MSAT_INIT(0xFFFFFFFFULL), /* "Lightning Charge Powers Developers & Blockstream Store" */ .when_lightning_became_cool = 504500, .testnet = false}, @@ -29,8 +29,8 @@ const struct chainparams networks[] = { .cli = "bitcoin-cli", .cli_args = "-regtest", .dust_limit = { 546 }, - .max_funding = AMOUNT_SAT((1 << 24) - 1), - .max_payment = AMOUNT_MSAT(0xFFFFFFFFULL), + .max_funding = AMOUNT_SAT_INIT((1 << 24) - 1), + .max_payment = AMOUNT_MSAT_INIT(0xFFFFFFFFULL), .when_lightning_became_cool = 1, .testnet = true}, {.network_name = "testnet", @@ -40,8 +40,8 @@ const struct chainparams networks[] = { .cli = "bitcoin-cli", .cli_args = "-testnet", .dust_limit = { 546 }, - .max_funding = AMOUNT_SAT((1 << 24) - 1), - .max_payment = AMOUNT_MSAT(0xFFFFFFFFULL), + .max_funding = AMOUNT_SAT_INIT((1 << 24) - 1), + .max_payment = AMOUNT_MSAT_INIT(0xFFFFFFFFULL), .testnet = true}, {.network_name = "litecoin", .bip173_name = "ltc", @@ -50,8 +50,8 @@ const struct chainparams networks[] = { .cli = "litecoin-cli", .cli_args = NULL, .dust_limit = { 100000 }, - .max_funding = AMOUNT_SAT(60 * ((1 << 24) - 1)), - .max_payment = AMOUNT_MSAT(60 * 0xFFFFFFFFULL), + .max_funding = AMOUNT_SAT_INIT(60 * ((1 << 24) - 1)), + .max_payment = AMOUNT_MSAT_INIT(60 * 0xFFFFFFFFULL), .when_lightning_became_cool = 1320000, .testnet = false}, {.network_name = "litecoin-testnet", @@ -61,8 +61,8 @@ const struct chainparams networks[] = { .cli = "litecoin-cli", .cli_args = "-testnet", .dust_limit = { 100000 }, - .max_funding = AMOUNT_SAT(60 * ((1 << 24) - 1)), - .max_payment = AMOUNT_MSAT(60 * 0xFFFFFFFFULL), + .max_funding = AMOUNT_SAT_INIT(60 * ((1 << 24) - 1)), + .max_payment = AMOUNT_MSAT_INIT(60 * 0xFFFFFFFFULL), .when_lightning_became_cool = 1, .testnet = true} }; diff --git a/common/amount.h b/common/amount.h index f98db4668..6df3e7c64 100644 --- a/common/amount.h +++ b/common/amount.h @@ -29,6 +29,13 @@ struct amount_msat { #define AMOUNT_MUST_BE_CONST(c) 0 #endif +/* GCC 4.8.5 (Centos 7.6!) thinks struct casts are not constants, so we + * need to not use a cast for static initializations. */ +#define AMOUNT_MSAT_INIT(msat) \ + { .millisatoshis = (msat) } +#define AMOUNT_SAT_INIT(sat) \ + { .satoshis = (sat) } + #define AMOUNT_MSAT(constant) \ ((struct amount_msat){(constant) + AMOUNT_MUST_BE_CONST(constant)}) diff --git a/onchaind/onchaind.c b/onchaind/onchaind.c index 9945227d5..3fc432d8a 100644 --- a/onchaind/onchaind.c +++ b/onchaind/onchaind.c @@ -156,7 +156,7 @@ static bool set_htlc_timeout_fee(struct bitcoin_tx *tx, const struct bitcoin_signature *remotesig, const u8 *wscript) { - static struct amount_sat fee = AMOUNT_SAT(UINT64_MAX); + static struct amount_sat fee = AMOUNT_SAT_INIT(UINT64_MAX); /* BOLT #3: * @@ -181,7 +181,7 @@ static void set_htlc_success_fee(struct bitcoin_tx *tx, const struct bitcoin_signature *remotesig, const u8 *wscript) { - static struct amount_sat fee = AMOUNT_SAT(UINT64_MAX); + static struct amount_sat fee = AMOUNT_SAT_INIT(UINT64_MAX); /* BOLT #3: *