openingd: Add zeroconf-no-really-zero mode

This is incompatible with the spec as it removes the enforcement for
reserves being above dust, but from what I can see from other
implementations it seems that others have allowed this as well.

This commit just guards the necessary changes with compilation guards, so
we can decide either way quickly. This part of the PR is not intended
to be final, just as a discussion basis.
This commit is contained in:
Christian Decker
2022-06-09 17:04:43 +02:00
parent 2def843dce
commit c3e9cb7a47
3 changed files with 14 additions and 0 deletions

View File

@@ -257,6 +257,9 @@ endif
CPPFLAGS += -DBINTOPKGLIBEXECDIR="\"$(shell sh tools/rel.sh $(bindir) $(pkglibexecdir))\""
CFLAGS = $(CPPFLAGS) $(CWARNFLAGS) $(CDEBUGFLAGS) $(COPTFLAGS) -I $(CCANDIR) $(EXTERNAL_INCLUDE_FLAGS) -I . -I$(CPATH) $(SQLITE3_CFLAGS) $(POSTGRES_INCLUDE) $(FEATURES) $(COVFLAGS) $(DEV_CFLAGS) -DSHACHAIN_BITS=48 -DJSMN_PARENT_LINKS $(PIE_CFLAGS) $(COMPAT_CFLAGS) -DBUILD_ELEMENTS=1
CFLAGS += -DZERORESERVE=1
# If CFLAGS is already set in the environment of make (to whatever value, it
# does not matter) then it would export it to subprocesses with the above value
# we set, including CWARNFLAGS which by default contains -Wall -Werror. This

View File

@@ -180,6 +180,7 @@ bool check_config_bounds(const tal_t *ctx,
return false;
}
#ifndef ZERORESERVE
/* BOLT #2:
*
* The receiving node MUST fail the channel if:
@@ -197,6 +198,7 @@ bool check_config_bounds(const tal_t *ctx,
&remoteconf->channel_reserve));
return false;
}
#endif
return true;
}

View File

@@ -144,6 +144,9 @@ static void set_reserve_absolute(struct state * state, const struct amount_sat d
{
status_debug("Setting their reserve to %s",
type_to_string(tmpctx, struct amount_sat, &reserve_sat));
#ifdef ZERORESERVE
state->localconf.channel_reserve = reserve_sat;
#else
/* BOLT #2:
*
* The sending node:
@@ -161,6 +164,7 @@ static void set_reserve_absolute(struct state * state, const struct amount_sat d
} else {
state->localconf.channel_reserve = reserve_sat;
}
#endif
}
/* We always set channel_reserve_satoshis to 1%, rounded down. */
@@ -458,6 +462,7 @@ static u8 *funder_channel_start(struct state *state, u8 channel_flags)
type_to_string(msg, struct channel_id,
&state->channel_id));
#ifndef ZERORESERVE
if (amount_sat_greater(state->remoteconf.dust_limit,
state->localconf.channel_reserve)) {
negotiation_failed(state,
@@ -469,6 +474,7 @@ static u8 *funder_channel_start(struct state *state, u8 channel_flags)
&state->localconf.channel_reserve));
return NULL;
}
#endif
if (!check_config_bounds(tmpctx, state->funding_sats,
state->feerate_per_kw,
@@ -954,6 +960,8 @@ static u8 *fundee_channel(struct state *state, const u8 *open_channel_msg)
/* This reserves 1% of the channel (rounded up) */
set_reserve(state, state->remoteconf.dust_limit);
#ifndef ZERORESERVE
/* Pending proposal to remove these limits. */
/* BOLT #2:
*
* The sender:
@@ -985,6 +993,7 @@ static u8 *fundee_channel(struct state *state, const u8 *open_channel_msg)
&state->remoteconf.channel_reserve));
return NULL;
}
#endif
/* These checks are the same whether we're opener or accepter... */
if (!check_config_bounds(tmpctx, state->funding_sats,