Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions openingd/openingd.c
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,13 @@ static bool setup_channel_funder(struct state *state)
return false;
}

if (amount_sat_greater(state->funding_sats, chainparams->max_supply)) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you check whether dualopend.c has the same unbounded-total issue when building its commitment transaction?

status_failed(STATUS_FAIL_MASTER_IO,
"funding_satoshis %s exceeds maximum Bitcoin supply",
fmt_amount_sat(tmpctx, state->funding_sats));
return false;
}

return true;
}

Expand Down Expand Up @@ -939,6 +946,19 @@ static u8 *fundee_channel(struct state *state, const u8 *open_channel_msg)
return NULL;
}

/* BOLT #2:
*
* The receiving node MUST fail the channel if:
*...
* - `funding_satoshis` is greater than the maximum Bitcoin supply.
*/
if (amount_sat_greater(state->funding_sats, chainparams->max_supply)) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason you added the check at two separate call sites instead of inside check_config_bounds(), given that function already receives the funding amount at every relevant call site?

peer_failed_err(state->pps, &state->channel_id,
"funding_satoshis %s exceeds maximum Bitcoin supply",
fmt_amount_sat(tmpctx, state->funding_sats));
return NULL;
}

/* BOLT #2:
*
* The receiving node MUST fail the channel if:
Expand Down