diff --git a/bitcoin/chainparams.c b/bitcoin/chainparams.c index ac48ee5da..d26e77910 100644 --- a/bitcoin/chainparams.c +++ b/bitcoin/chainparams.c @@ -50,6 +50,7 @@ const struct chainparams networks[] = { */ .max_funding = AMOUNT_SAT_INIT((1 << 24) - 1), .max_payment = AMOUNT_MSAT_INIT(0xFFFFFFFFULL), + .max_supply = AMOUNT_SAT_INIT(2100000000000000), /* "Lightning Charge Powers Developers & Blockstream Store" */ .when_lightning_became_cool = 504500, .p2pkh_version = 0, @@ -76,6 +77,7 @@ const struct chainparams networks[] = { .dust_limit = { 546 }, .max_funding = AMOUNT_SAT_INIT((1 << 24) - 1), .max_payment = AMOUNT_MSAT_INIT(0xFFFFFFFFULL), + .max_supply = AMOUNT_SAT_INIT(2100000000000000), .when_lightning_became_cool = 1, .p2pkh_version = 111, .p2sh_version = 196, @@ -102,6 +104,7 @@ const struct chainparams networks[] = { .dust_limit = { 546 }, .max_funding = AMOUNT_SAT_INIT((1 << 24) - 1), .max_payment = AMOUNT_MSAT_INIT(0xFFFFFFFFULL), + .max_supply = AMOUNT_SAT_INIT(2100000000000000), .when_lightning_became_cool = 1, .p2pkh_version = 111, .p2sh_version = 196, @@ -126,6 +129,7 @@ const struct chainparams networks[] = { .dust_limit = { 546 }, .max_funding = AMOUNT_SAT_INIT((1 << 24) - 1), .max_payment = AMOUNT_MSAT_INIT(0xFFFFFFFFULL), + .max_supply = AMOUNT_SAT_INIT(2100000000000000), .p2pkh_version = 111, .p2sh_version = 196, .testnet = true, @@ -150,6 +154,7 @@ const struct chainparams networks[] = { .dust_limit = { 100000 }, .max_funding = AMOUNT_SAT_INIT(60 * ((1 << 24) - 1)), .max_payment = AMOUNT_MSAT_INIT(60 * 0xFFFFFFFFULL), + .max_supply = AMOUNT_SAT_INIT(2100000000000000), .when_lightning_became_cool = 1320000, .p2pkh_version = 48, .p2sh_version = 50, @@ -175,6 +180,7 @@ const struct chainparams networks[] = { .dust_limit = { 100000 }, .max_funding = AMOUNT_SAT_INIT(60 * ((1 << 24) - 1)), .max_payment = AMOUNT_MSAT_INIT(60 * 0xFFFFFFFFULL), + .max_supply = AMOUNT_SAT_INIT(2100000000000000), .when_lightning_became_cool = 1, .p2pkh_version = 111, .p2sh_version = 58, @@ -199,6 +205,7 @@ const struct chainparams networks[] = { .dust_limit = {546}, .max_funding = AMOUNT_SAT_INIT((1 << 24) - 1), .max_payment = AMOUNT_MSAT_INIT(0xFFFFFFFFULL), + .max_supply = AMOUNT_SAT_INIT(2100000000000000), .when_lightning_became_cool = 1, .p2pkh_version = 91, .p2sh_version = 75, @@ -223,6 +230,7 @@ const struct chainparams networks[] = { .dust_limit = {546}, .max_funding = AMOUNT_SAT_INIT((1 << 24) - 1), .max_payment = AMOUNT_MSAT_INIT(0xFFFFFFFFULL), + .max_supply = AMOUNT_SAT_INIT(2100000000000000), .when_lightning_became_cool = 1, .p2pkh_version = 57, .p2sh_version = 39, diff --git a/bitcoin/chainparams.h b/bitcoin/chainparams.h index f4e493de6..a8e74fe17 100644 --- a/bitcoin/chainparams.h +++ b/bitcoin/chainparams.h @@ -39,6 +39,8 @@ struct chainparams { const struct amount_sat dust_limit; const struct amount_sat max_funding; const struct amount_msat max_payment; + /* Total coins in network */ + const struct amount_sat max_supply; const u32 when_lightning_became_cool; const u8 p2pkh_version; const u8 p2sh_version; diff --git a/lightningd/dual_open_control.c b/lightningd/dual_open_control.c index 9e593faff..8cd70683c 100644 --- a/lightningd/dual_open_control.c +++ b/lightningd/dual_open_control.c @@ -1849,11 +1849,12 @@ static void rbf_got_offer(struct subd *dualopend, const u8 *msg) /* No error message known (yet) */ payload->err_msg = NULL; - payload->channel_max = chainparams->max_funding; if (feature_negotiated(dualopend->ld->our_features, channel->peer->their_features, OPT_LARGE_CHANNELS)) - payload->channel_max = AMOUNT_SAT(UINT_MAX); + payload->channel_max = chainparams->max_supply; + else + payload->channel_max = chainparams->max_funding; tal_add_destructor2(dualopend, rbf_channel_remove_dualopend, payload); plugin_hook_call_rbf_channel(dualopend->ld, NULL, payload); @@ -1910,11 +1911,12 @@ static void accepter_got_offer(struct subd *dualopend, payload->feerate_our_max = feerate_max(dualopend->ld, NULL); payload->node_blockheight = get_block_height(dualopend->ld->topology); - payload->channel_max = chainparams->max_funding; if (feature_negotiated(dualopend->ld->our_features, channel->peer->their_features, OPT_LARGE_CHANNELS)) - payload->channel_max = AMOUNT_SAT(UINT64_MAX); + payload->channel_max = chainparams->max_supply; + else + payload->channel_max = chainparams->max_funding; tal_add_destructor2(dualopend, openchannel2_remove_dualopend, payload); plugin_hook_call_openchannel2(dualopend->ld, NULL, payload);