channeld: allow large HTLCs if peer offers option_support_large_channel

This check is going away anyway (only Electrum enforced it), but we
know that all wumbo peers expect large HTLCs to work today.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Added: Protocol: Allow sending large HTLCs if peer offers option_support_large_channel (> 4294967295msat)
This commit is contained in:
Rusty Russell 2021-09-08 09:36:14 +09:30
parent d637680476
commit 88d55441c5
8 changed files with 31 additions and 4 deletions

View File

@ -3789,6 +3789,8 @@ static void init_channel(struct peer *peer)
&funding_pubkey[REMOTE],
option_static_remotekey,
option_anchor_outputs,
feature_offered(peer->their_features,
OPT_LARGE_CHANNELS),
opener);
if (!channel_force_htlcs(peer->channel,

View File

@ -109,6 +109,7 @@ struct channel *new_full_channel(const tal_t *ctx,
const struct pubkey *remote_funding_pubkey,
bool option_static_remotekey,
bool option_anchor_outputs,
bool option_wumbo,
enum side opener)
{
struct channel *channel = new_initial_channel(ctx,
@ -128,6 +129,7 @@ struct channel *new_full_channel(const tal_t *ctx,
remote_funding_pubkey,
option_static_remotekey,
option_anchor_outputs,
option_wumbo,
opener);
if (channel) {
@ -584,7 +586,8 @@ static enum channel_add_err add_htlc(struct channel *channel,
* - MUST set the four most significant bytes of `amount_msat` to 0.
*/
if (sender == LOCAL
&& amount_msat_greater(htlc->amount, chainparams->max_payment)) {
&& amount_msat_greater(htlc->amount, chainparams->max_payment)
&& !channel->option_wumbo) {
return CHANNEL_ERR_MAX_HTLC_VALUE_EXCEEDED;
}

View File

@ -30,6 +30,7 @@ struct existing_htlc;
* @remote_fundingkey: remote funding key
* @option_static_remotekey: use `option_static_remotekey`.
* @option_anchor_outputs: use `option_anchor_outputs`.
* @option_wumbo: large channel negotiated.
* @opener: which side initiated it.
*
* Returns state, or NULL if malformed.
@ -52,6 +53,7 @@ struct channel *new_full_channel(const tal_t *ctx,
const struct pubkey *remote_funding_pubkey,
bool option_static_remotekey,
bool option_anchor_outputs,
bool option_wumbo,
enum side opener);
/**

View File

@ -493,7 +493,7 @@ int main(int argc, const char *argv[])
&localbase, &remotebase,
&local_funding_pubkey,
&remote_funding_pubkey,
false, false, LOCAL);
false, false, false, LOCAL);
rchannel = new_full_channel(tmpctx, &cid,
&funding_txid, funding_output_index, 0,
take(new_height_states(NULL, REMOTE, &blockheight)),
@ -506,7 +506,7 @@ int main(int argc, const char *argv[])
&remotebase, &localbase,
&remote_funding_pubkey,
&local_funding_pubkey,
false, false, REMOTE);
false, false, false, REMOTE);
/* BOLT #3:
*

View File

@ -35,6 +35,7 @@ struct channel *new_initial_channel(const tal_t *ctx,
const struct pubkey *remote_funding_pubkey,
bool option_static_remotekey,
bool option_anchor_outputs,
bool option_wumbo,
enum side opener)
{
struct channel *channel = tal(ctx, struct channel);
@ -83,6 +84,7 @@ struct channel *new_initial_channel(const tal_t *ctx,
channel->option_static_remotekey = option_static_remotekey;
channel->option_anchor_outputs = option_anchor_outputs;
channel->option_wumbo = option_wumbo;
if (option_anchor_outputs)
assert(option_static_remotekey);
return channel;

View File

@ -75,6 +75,9 @@ struct channel {
/* Is this using option_anchor_outputs? */
bool option_anchor_outputs;
/* Are we using big channels? */
bool option_wumbo;
/* When the lease expires for the funds in this channel */
u32 lease_expiry;
};
@ -99,6 +102,7 @@ struct channel {
* @remote_fundingkey: remote funding key
* @option_static_remotekey: was this created with option_static_remotekey?
* @option_anchor_outputs: was this created with option_anchor_outputs?
* @option_wumbo: has peer currently negotiated wumbo?
* @opener: which side initiated it.
*
* Returns channel, or NULL if malformed.
@ -121,6 +125,7 @@ struct channel *new_initial_channel(const tal_t *ctx,
const struct pubkey *remote_funding_pubkey,
bool option_static_remotekey,
bool option_anchor_outputs,
bool option_wumbo,
enum side opener);
/**

View File

@ -1726,6 +1726,8 @@ static void revert_channel_state(struct state *state)
&state->our_funding_pubkey,
&state->their_funding_pubkey,
true, true,
feature_offered(state->their_features,
OPT_LARGE_CHANNELS),
opener);
}
@ -1828,6 +1830,8 @@ static u8 *accepter_commits(struct state *state,
&state->our_funding_pubkey,
&state->their_funding_pubkey,
true, true,
feature_offered(state->their_features,
OPT_LARGE_CHANNELS),
REMOTE);
local_commit = initial_channel_tx(state, &wscript, state->channel,
@ -2436,6 +2440,8 @@ static u8 *opener_commits(struct state *state,
&state->our_funding_pubkey,
&state->their_funding_pubkey,
true, true,
feature_offered(state->their_features,
OPT_LARGE_CHANNELS),
/* Opener is local */
LOCAL);
@ -3858,7 +3864,10 @@ int main(int argc, char *argv[])
&state->their_points,
&state->our_funding_pubkey,
&state->their_funding_pubkey,
true, true, opener);
true, true,
feature_offered(state->their_features,
OPT_LARGE_CHANNELS),
opener);
if (opener == LOCAL)
state->our_role = TX_INITIATOR;

View File

@ -533,6 +533,8 @@ static bool funder_finalize_channel_setup(struct state *state,
&state->their_funding_pubkey,
state->option_static_remotekey,
state->option_anchor_outputs,
feature_offered(state->their_features,
OPT_LARGE_CHANNELS),
/* Opener is local */
LOCAL);
/* We were supposed to do enough checks above, but just in case,
@ -1023,6 +1025,8 @@ static u8 *fundee_channel(struct state *state, const u8 *open_channel_msg)
&their_funding_pubkey,
state->option_static_remotekey,
state->option_anchor_outputs,
feature_offered(state->their_features,
OPT_LARGE_CHANNELS),
REMOTE);
/* We don't expect this to fail, but it does do some additional
* internal sanity checks. */