diff --git a/bitcoin/chainparams.c b/bitcoin/chainparams.c index fe4a1c645..be1793fac 100644 --- a/bitcoin/chainparams.c +++ b/bitcoin/chainparams.c @@ -12,6 +12,8 @@ const struct chainparams networks[] = { .cli = "bitcoin-cli", .cli_args = NULL, .dust_limit = 546, + .max_funding_satoshi = (1 << 24) - 1, + .max_payment_msat = 0xFFFFFFFFULL, /* "Lightning Charge Powers Developers & Blockstream Store" */ .when_lightning_became_cool = 504500, .testnet = false}, @@ -23,6 +25,8 @@ const struct chainparams networks[] = { .cli = "bitcoin-cli", .cli_args = "-regtest", .dust_limit = 546, + .max_funding_satoshi = (1 << 24) - 1, + .max_payment_msat = 0xFFFFFFFFULL, .when_lightning_became_cool = 1, .testnet = true}, {.index = 2, @@ -33,6 +37,8 @@ const struct chainparams networks[] = { .cli = "bitcoin-cli", .cli_args = "-testnet", .dust_limit = 546, + .max_funding_satoshi = (1 << 24) - 1, + .max_payment_msat = 0xFFFFFFFFULL, .testnet = true}, {.index = 3, .network_name = "litecoin", @@ -42,6 +48,8 @@ const struct chainparams networks[] = { .cli = "litecoin-cli", .cli_args = NULL, .dust_limit = 100000, + .max_funding_satoshi = 60 * ((1 << 24) - 1), + .max_payment_msat = 60 * 0xFFFFFFFFULL, .when_lightning_became_cool = 1320000, .testnet = false}, {.index = 4, @@ -52,6 +60,8 @@ const struct chainparams networks[] = { .cli = "litecoin-cli", .cli_args = "-testnet", .dust_limit = 100000, + .max_funding_satoshi = 60 * ((1 << 24) - 1), + .max_payment_msat = 60 * 0xFFFFFFFFULL, .when_lightning_became_cool = 1, .testnet = true} }; @@ -75,6 +85,16 @@ const struct chainparams *chainparams_by_index(const int index) } } +const struct chainparams *chainparams_by_chainhash(const struct bitcoin_blkid *chain_hash) +{ + for (size_t i = 0; i < ARRAY_SIZE(networks); i++) { + if (bitcoin_blkid_eq(chain_hash, &networks[i].genesis_blockhash)) { + return &networks[i]; + } + } + return NULL; +} + const struct chainparams *chainparams_by_bip173(const char *bip173_name) { for (size_t i = 0; i < ARRAY_SIZE(networks); i++) { diff --git a/bitcoin/chainparams.h b/bitcoin/chainparams.h index 92a0d2d6d..9070a1cd9 100644 --- a/bitcoin/chainparams.h +++ b/bitcoin/chainparams.h @@ -15,6 +15,8 @@ struct chainparams { const char *cli; const char *cli_args; const u64 dust_limit; + const u64 max_funding_satoshi; + const u64 max_payment_msat; const u32 when_lightning_became_cool; /* Whether this is a test network or not */ @@ -40,4 +42,10 @@ const struct chainparams *chainparams_by_index(const int index); * This lets us decode BOLT11 addresses. */ const struct chainparams *chainparams_by_bip173(const char *bip173_name); + +/** + * chainparams_by_chainhash - Helper to get a network by its genesis blockhash + */ +const struct chainparams *chainparams_by_chainhash(const struct bitcoin_blkid *chain_hash); + #endif /* LIGHTNING_BITCOIN_CHAINPARAMS_H */