mirror of
https://github.com/aljazceru/lightning.git
synced 2026-01-05 15:24:18 +01:00
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:
3
Makefile
3
Makefile
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user