cln/openingd/common.h
Matt Morehouse 4b34ad332e openingd: bound funding_satoshis by total bitcoin supply
funding_satoshis values above the total bitcoin supply were not rejected
during open_channel/accept_channel negotiation and would later cause
libwally to fail and openingd to crash during commitment transaction
construction.

Reject such funding_satoshis values immediately so that the negotiation
terminates gracefully.

Fixes: #9225
Changelog-Fixed: `openingd` no longer crashes when a peer opens a channel with a `funding_satoshis` value greater than the total bitcoin supply.
2026-08-19 10:00:27 +02:00

43 lines
1.3 KiB
C

#ifndef LIGHTNING_OPENINGD_COMMON_H
#define LIGHTNING_OPENINGD_COMMON_H
#include "config.h"
#include <common/utils.h>
struct amount_sat;
struct bitcoin_tx;
struct bitcoin_signature;
struct channel_config;
bool check_config_bounds(const tal_t *ctx,
struct amount_sat funding,
u32 feerate_per_kw,
u32 max_to_self_delay,
struct amount_msat min_effective_htlc_capacity,
const struct channel_config *remoteconf,
const struct channel_config *localconf,
bool option_anchors_zero_fee_htlc_tx,
char **err_reason);
bool anchors_negotiated(struct feature_set *our_features,
const u8 *their_features);
struct amount_sat max_channel_funding(const struct feature_set *our_features,
const u8 *their_features);
u8 *no_upfront_shutdown_script(const tal_t *ctx,
bool developer,
struct feature_set *our_features,
const u8 *their_features);
void validate_initial_commitment_signature(int hsm_fd,
struct bitcoin_tx *tx,
struct bitcoin_signature *sig);
char *validate_remote_upfront_shutdown(const tal_t *ctx,
struct feature_set *our_features,
const u8 *their_features,
u8 *shutdown_scriptpubkey STEALS,
u8 **state_script);
#endif /* LIGHTNING_OPENINGD_COMMON_H */