Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dual-Funding Flag Day #4427

Merged
merged 6 commits into from
Mar 25, 2021
Merged
Show file tree
Hide file tree
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
6 changes: 1 addition & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -340,16 +340,12 @@ PKGLIBEXEC_PROGRAMS = \
lightningd/lightning_channeld \
lightningd/lightning_closingd \
lightningd/lightning_connectd \
lightningd/lightning_dualopend \
lightningd/lightning_gossipd \
lightningd/lightning_hsmd \
lightningd/lightning_onchaind \
lightningd/lightning_openingd

# Only build dualopend if experimental features is on
ifeq ($(EXPERIMENTAL_FEATURES),1)
PKGLIBEXEC_PROGRAMS += lightningd/lightning_dualopend
endif

# Don't delete these intermediaries.
.PRECIOUS: $(ALL_GEN_HEADERS) $(ALL_GEN_SOURCES)

Expand Down
6 changes: 0 additions & 6 deletions channeld/channeld.c
Original file line number Diff line number Diff line change
Expand Up @@ -1756,7 +1756,6 @@ static bool channeld_handle_custommsg(const u8 *msg)
#endif
}

#if EXPERIMENTAL_FEATURES
static void handle_unexpected_tx_sigs(struct peer *peer, const u8 *msg)
{
const struct witness_stack **ws;
Expand All @@ -1781,7 +1780,6 @@ static void handle_unexpected_tx_sigs(struct peer *peer, const u8 *msg)

peer->tx_sigs_allowed = false;
}
#endif /* EXPERIMENTAL_FEATURES */

static void handle_unexpected_reestablish(struct peer *peer, const u8 *msg)
{
Expand Down Expand Up @@ -1866,10 +1864,8 @@ static void peer_in(struct peer *peer, const u8 *msg)
if (type != WIRE_FUNDING_LOCKED
&& type != WIRE_PONG
&& type != WIRE_SHUTDOWN
#if EXPERIMENTAL_FEATURES
/* We expect these for v2 !! */
&& type != WIRE_TX_SIGNATURES
#endif /* EXPERIMENTAL_FEATURES */
/* lnd sends these early; it's harmless. */
&& type != WIRE_UPDATE_FEE
&& type != WIRE_ANNOUNCEMENT_SIGNATURES) {
Expand Down Expand Up @@ -1917,7 +1913,6 @@ static void peer_in(struct peer *peer, const u8 *msg)
case WIRE_FUNDING_CREATED:
case WIRE_FUNDING_SIGNED:
case WIRE_CLOSING_SIGNED:
#if EXPERIMENTAL_FEATURES
case WIRE_TX_ADD_INPUT:
case WIRE_TX_REMOVE_INPUT:
case WIRE_TX_ADD_OUTPUT:
Expand All @@ -1930,7 +1925,6 @@ static void peer_in(struct peer *peer, const u8 *msg)
return;
case WIRE_INIT_RBF:
case WIRE_ACK_RBF:
#endif
break;

case WIRE_CHANNEL_REESTABLISH:
Expand Down
5 changes: 1 addition & 4 deletions common/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ COMMON_SRC_NOGEN := \
common/peer_failed.c \
common/permute_tx.c \
common/ping.c \
common/psbt_internal.c \
common/psbt_open.c \
common/private_channel_announcement.c \
common/pseudorand.c \
Expand All @@ -89,10 +90,6 @@ COMMON_SRC_NOGEN := \
common/wire_error.c


ifeq ($(EXPERIMENTAL_FEATURES),1)
COMMON_SRC_NOGEN += common/psbt_internal.c
endif

COMMON_SRC_GEN := common/status_wiregen.c common/peer_status_wiregen.c

COMMON_HEADERS_NOGEN := $(COMMON_SRC_NOGEN:.c=.h) \
Expand Down
58 changes: 47 additions & 11 deletions common/features.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,20 +77,20 @@ static const struct feature_style feature_styles[] = {
.copy_style = { [INIT_FEATURE] = FEATURE_REPRESENT,
[NODE_ANNOUNCE_FEATURE] = FEATURE_REPRESENT,
[CHANNEL_FEATURE] = FEATURE_DONT_REPRESENT} },
#if EXPERIMENTAL_FEATURES
{ OPT_ANCHOR_OUTPUTS,
.copy_style = { [INIT_FEATURE] = FEATURE_REPRESENT,
[NODE_ANNOUNCE_FEATURE] = FEATURE_REPRESENT,
[CHANNEL_FEATURE] = FEATURE_DONT_REPRESENT } },
{ OPT_SHUTDOWN_ANYSEGWIT,
.copy_style = { [INIT_FEATURE] = FEATURE_REPRESENT,
[NODE_ANNOUNCE_FEATURE] = FEATURE_REPRESENT,
[CHANNEL_FEATURE] = FEATURE_DONT_REPRESENT } },
{ OPT_DUAL_FUND,
.copy_style = { [INIT_FEATURE] = FEATURE_REPRESENT,
[NODE_ANNOUNCE_FEATURE] = FEATURE_REPRESENT,
[BOLT11_FEATURE] = FEATURE_REPRESENT,
[CHANNEL_FEATURE] = FEATURE_DONT_REPRESENT} },
#if EXPERIMENTAL_FEATURES
{ OPT_SHUTDOWN_ANYSEGWIT,
.copy_style = { [INIT_FEATURE] = FEATURE_REPRESENT,
[NODE_ANNOUNCE_FEATURE] = FEATURE_REPRESENT,
[CHANNEL_FEATURE] = FEATURE_DONT_REPRESENT } },
#endif
};

Expand All @@ -117,15 +117,13 @@ static const struct dependency feature_deps[] = {
*...
* `option_anchor_outputs` | ... | ... | `option_static_remotekey`
*/
#if EXPERIMENTAL_FEATURES
{ OPT_ANCHOR_OUTPUTS, OPT_STATIC_REMOTEKEY },
/* BOLT-7b04b1461739c5036add61782d58ac490842d98b #9:
/* BOLT-f53ca2301232db780843e894f55d95d512f297f9 #9:
* Name | Description | Context | Dependencies |
* ...
* `option_dual_fund` | ... | ... | `option_anchor_outputs`
*/
{ OPT_DUAL_FUND, OPT_ANCHOR_OUTPUTS },
#endif
};

static void trim_features(u8 **features)
Expand Down Expand Up @@ -382,20 +380,58 @@ int features_unsupported(const struct feature_set *our_features,
static const char *feature_name(const tal_t *ctx, size_t f)
{
static const char *fnames[] = {
"option_data_loss_protect",
"option_data_loss_protect", /* 0/1 */
"option_initial_routing_sync",
"option_upfront_shutdown_script",
"option_gossip_queries",
"option_var_onion_optin",
"option_gossip_queries_ex",
"option_gossip_queries_ex", /* 10/11 */
"option_static_remotekey",
"option_payment_secret",
"option_basic_mpp",
"option_support_large_channel",
"option_anchor_outputs",
"option_anchor_outputs", /* 20/21 */
"option_anchors_zero_fee_htlc_tx",
NULL,
"option_shutdown_anysegwit",
"option_dual_fund",
NULL, /* 30/31 */
NULL,
NULL,
NULL,
NULL,
NULL, /* 40/41 */
NULL,
NULL,
NULL,
NULL,
NULL, /* 50/51 */
NULL,
NULL,
NULL,
NULL,
NULL, /* 60/61 */
NULL,
NULL,
NULL,
NULL,
NULL, /* 70/71 */
NULL,
NULL,
NULL,
NULL,
NULL, /* 80/81 */
NULL,
NULL,
NULL,
NULL,
NULL, /* 90/91 */
NULL,
NULL,
NULL,
NULL,
NULL, /* 100/101 */
"option_onion_messages", /* 102/103 */
};

if (f / 2 >= ARRAY_SIZE(fnames) || !fnames[f / 2])
Expand Down
6 changes: 3 additions & 3 deletions common/features.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,10 @@ u8 *featurebits_or(const tal_t *ctx, const u8 *f1 TAKES, const u8 *f2 TAKES);
*/
#define OPT_SHUTDOWN_ANYSEGWIT 26

/* BOLT-7b04b1461739c5036add61782d58ac490842d98b #9:
* | 222/223 | `option_dual_fund` | ... IN9 ...
/* BOLT-f53ca2301232db780843e894f55d95d512f297f9 #9:
* | 28/29 | `option_dual_fund` | ... IN9 ...
*/
#define OPT_DUAL_FUND 222
#define OPT_DUAL_FUND 28

/* BOLT-9fc25cfd2895578c0b1ab701ebe6c1eb67a19623 #9:
*
Expand Down
3 changes: 0 additions & 3 deletions common/psbt_internal.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include <wally_psbt.h>
#include <wire/peer_wire.h>

#if EXPERIMENTAL_FEATURES
static void
psbt_input_set_final_witness_stack(const tal_t *ctx,
struct wally_psbt_input *in,
Expand Down Expand Up @@ -103,5 +102,3 @@ psbt_to_witness_stacks(const tal_t *ctx,
tal_resize(&stacks, stack_index);
return stacks;
}

#endif /* EXPERIMENTAL_FEATURES */
5 changes: 1 addition & 4 deletions common/psbt_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,8 @@

struct wally_psbt;
struct wally_psbt_input;
#if EXPERIMENTAL_FEATURES
struct witness_element;
#endif /* EXPERIMENTAL_FEATURES */

#if EXPERIMENTAL_FEATURES
/* psbt_finalize_input - Finalize an input with a given witness stack
*
* Sets the given witness elements onto the PSBT. Also finalizes
Expand All @@ -34,5 +31,5 @@ const struct witness_stack **
psbt_to_witness_stacks(const tal_t *ctx,
const struct wally_psbt *psbt,
enum tx_role side_to_stack);
#endif /* EXPERIMENTAL_FEATURES */

#endif /* LIGHTNING_COMMON_PSBT_INTERNAL_H */
2 changes: 0 additions & 2 deletions gossipd/gossipd.c
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,6 @@ static struct io_plan *peer_msg_in(struct io_conn *conn,
case WIRE_CHANNEL_REESTABLISH:
case WIRE_ANNOUNCEMENT_SIGNATURES:
case WIRE_GOSSIP_TIMESTAMP_FILTER:
#if EXPERIMENTAL_FEATURES
case WIRE_TX_ADD_INPUT:
case WIRE_TX_REMOVE_INPUT:
case WIRE_TX_ADD_OUTPUT:
Expand All @@ -768,7 +767,6 @@ static struct io_plan *peer_msg_in(struct io_conn *conn,
case WIRE_ACCEPT_CHANNEL2:
case WIRE_INIT_RBF:
case WIRE_ACK_RBF:
#endif
status_broken("peer %s: relayed unexpected msg of type %s",
type_to_string(tmpctx, struct node_id, &peer->id),
peer_wire_name(fromwire_peektype(msg)));
Expand Down
9 changes: 1 addition & 8 deletions lightningd/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ LIGHTNINGD_SRC := \
lightningd/channel_control.c \
lightningd/closing_control.c \
lightningd/coin_mvts.c \
lightningd/dual_open_control.c \
lightningd/connect_control.c \
lightningd/onion_message.c \
lightningd/gossip_control.c \
Expand Down Expand Up @@ -39,11 +40,6 @@ LIGHTNINGD_SRC := \
lightningd/watch.c


# Only build dualopend if experimental features is on
ifeq ($(EXPERIMENTAL_FEATURES),1)
LIGHTNINGD_SRC += lightningd/dual_open_control.c
endif

LIGHTNINGD_SRC_NOHDR := \
lightningd/offer.c \
lightningd/signmessage.c
Expand All @@ -53,9 +49,6 @@ LIGHTNINGD_HEADERS := \
lightningd/channel_state.h \
lightningd/channel_state_names_gen.h

ifeq ($(EXPERIMENTAL_FEATURES),1)
LIGHTNINGD_HEADERS += lightningd/dual_open_control.h
endif

LIGHTNINGD_OBJS := $(LIGHTNINGD_SRC:.c=.o) $(LIGHTNINGD_SRC_NOHDR:.c=.o)
$(LIGHTNINGD_OBJS): $(LIGHTNINGD_HEADERS) $(LIGHTNINGD_CONTROL_HEADERS)
Expand Down
7 changes: 1 addition & 6 deletions lightningd/channel_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <lightningd/channel_control.h>
#include <lightningd/closing_control.h>
#include <lightningd/coin_mvts.h>
#include <lightningd/dual_open_control.h>
#include <lightningd/hsm_control.h>
#include <lightningd/jsonrpc.h>
#include <lightningd/lightningd.h>
Expand All @@ -32,10 +33,6 @@
#include <wire/common_wiregen.h>
#include <wire/wire_sync.h>

#if EXPERIMENTAL_FEATURES
#include <lightningd/dual_open_control.h>
#endif

static void update_feerates(struct lightningd *ld, struct channel *channel)
{
u8 *msg;
Expand Down Expand Up @@ -648,11 +645,9 @@ bool channel_tell_depth(struct lightningd *ld,
return true;
}

#if EXPERIMENTAL_FEATURES
dualopen_tell_depth(channel->owner, channel,
txid, depth);
return true;
#endif /* EXPERIMENTAL_FEATURES */
} else if (channel->state != CHANNELD_AWAITING_LOCKIN
&& channel->state != CHANNELD_NORMAL) {
/* If not awaiting lockin/announce, it doesn't
Expand Down
2 changes: 0 additions & 2 deletions lightningd/connect_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -292,14 +292,12 @@ static void peer_please_disconnect(struct lightningd *ld, const u8 *msg)
channel_cleanup_commands(c, "Reconnected");
channel_fail_reconnect(c, "Reconnected");
}
#if EXPERIMENTAL_FEATURES
else {
/* v2 has unsaved channels, not uncommitted_chans */
c = unsaved_channel_by_id(ld, &id);
if (c)
channel_close_conn(c, "Reconnected");
}
#endif /* EXPERIMENTAL_FEATURES */
}

static unsigned connectd_msg(struct subd *connectd, const u8 *msg, const int *fds)
Expand Down
4 changes: 0 additions & 4 deletions lightningd/dual_open_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -2324,15 +2324,13 @@ static struct command_result *json_openchannel_init(struct command *cmd,
"Channel funding in-progress. %s",
channel_state_name(channel));

#if EXPERIMENTAL_FEATURES
if (!feature_negotiated(cmd->ld->our_features,
peer->their_features,
OPT_DUAL_FUND)) {
return command_fail(cmd, FUNDING_V2_NOT_SUPPORTED,
"v2 openchannel not supported "
"by peer");
}
#endif /* EXPERIMENTAL_FEATURES */

/* BOLT #2:
* - if both nodes advertised `option_support_large_channel`:
Expand Down Expand Up @@ -2775,13 +2773,11 @@ static const struct json_command openchannel_abort_command = {
"Abort {channel_id}'s open. Usable while `commitment_signed=false`."
};

#if EXPERIMENTAL_FEATURES
AUTODATA(json_command, &openchannel_init_command);
AUTODATA(json_command, &openchannel_update_command);
AUTODATA(json_command, &openchannel_signed_command);
AUTODATA(json_command, &openchannel_bump_command);
AUTODATA(json_command, &openchannel_abort_command);
#endif /* EXPERIMENTAL_FEATURES */

static void start_fresh_dualopend(struct peer *peer,
struct per_peer_state *pps,
Expand Down
8 changes: 5 additions & 3 deletions lightningd/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -800,6 +800,10 @@ static char *opt_set_wumbo(struct lightningd *ld)

static char *opt_set_dual_fund(struct lightningd *ld)
{
/* Dual funding implies anchor outputs */
feature_set_or(ld->our_features,
take(feature_set_for_feature(NULL,
OPTIONAL_FEATURE(OPT_ANCHOR_OUTPUTS))));
feature_set_or(ld->our_features,
take(feature_set_for_feature(NULL,
OPTIONAL_FEATURE(OPT_DUAL_FUND))));
Expand Down Expand Up @@ -869,13 +873,11 @@ static void register_opts(struct lightningd *ld)
opt_set_wumbo, ld,
"Allow channels larger than 0.16777215 BTC");

#if EXPERIMENTAL_FEATURES
opt_register_early_noarg("--experimental-dual-fund",
opt_set_dual_fund, ld,
"experimental: Advertise dual-funding"
" and allow peers to establish channels"
" via v2 channel open protocol");
#endif
" via v2 channel open protocol.");

/* This affects our features, so set early. */
opt_register_early_noarg("--experimental-onion-messages",
Expand Down
Loading