dualopend: check that we're not exceeding max allowable capacity

This commit is contained in:
niftynei 2020-09-03 13:16:25 -05:00 committed by Rusty Russell
parent 8761468f42
commit 5f6a2c05bd
1 changed files with 17 additions and 0 deletions

View File

@ -985,6 +985,23 @@ static u8 *accepter_start(struct state *state, const u8 *oc2_msg)
type_to_string(tmpctx, struct amount_sat,
&state->opener_funding));
/* Check that total funding doesn't exceed allowed channel capacity */
/* BOLT #2:
*
* The receiving node MUST fail the channel if:
*...
* - `funding_satoshis` is greater than or equal to 2^24 and the receiver does not support
* `option_support_large_channel`. */
/* We choose to require *negotiation*, not just support! */
if (!feature_negotiated(state->our_features, state->their_features,
OPT_LARGE_CHANNELS)
&& amount_sat_greater(total, chainparams->max_funding)) {
negotiation_failed(state, false,
"total funding_satoshis %s too large",
type_to_string(tmpctx, struct amount_sat,
&total));
return NULL;
}
/* Add all of our inputs/outputs to the changeset */
init_changeset(state, psbt);