dual-funding: convert to runtime flag, --experimental-dual-fund

You can now activate dual-funded channels using the
`--experimental-dual-fund` flag

Changelog-Changed: Config: `--experimental-dual-fund` runtime flag will enable dual-funded protocol on this node
This commit is contained in:
niftynei
2021-03-11 18:19:40 -06:00
committed by Rusty Russell
parent 737658503f
commit 3e8f575f9e
25 changed files with 1617 additions and 131 deletions

View File

@@ -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)

View File

@@ -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;
@@ -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)
{
@@ -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) {
@@ -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:
@@ -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:

View File

@@ -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 \
@@ -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) \

View File

@@ -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
};
@@ -117,7 +117,6 @@ static const struct dependency feature_deps[] = {
*...
* `option_anchor_outputs` | ... | ... | `option_static_remotekey`
*/
#if EXPERIMENTAL_FEATURES
{ OPT_ANCHOR_OUTPUTS, OPT_STATIC_REMOTEKEY },
/* BOLT-f53ca2301232db780843e894f55d95d512f297f9 #9:
* Name | Description | Context | Dependencies |
@@ -125,7 +124,6 @@ static const struct dependency feature_deps[] = {
* `option_dual_fund` | ... | ... | `option_anchor_outputs`
*/
{ OPT_DUAL_FUND, OPT_ANCHOR_OUTPUTS },
#endif
};
static void trim_features(u8 **features)
@@ -393,6 +391,7 @@ static const char *feature_name(const tal_t *ctx, size_t f)
"option_basic_mpp",
"option_support_large_channel",
"option_anchor_outputs",
"option_dual_fund",
"option_anchors_zero_fee_htlc_tx",
NULL,
"option_shutdown_anysegwit",

View File

@@ -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,
@@ -103,5 +102,3 @@ psbt_to_witness_stacks(const tal_t *ctx,
tal_resize(&stacks, stack_index);
return stacks;
}
#endif /* EXPERIMENTAL_FEATURES */

View File

@@ -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
@@ -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 */

View File

@@ -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:
@@ -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)));

View File

@@ -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 \
@@ -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
@@ -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)

View File

@@ -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>
@@ -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;
@@ -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

View File

@@ -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)

View File

@@ -2324,7 +2324,6 @@ 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)) {
@@ -2332,7 +2331,6 @@ static struct command_result *json_openchannel_init(struct command *cmd,
"v2 openchannel not supported "
"by peer");
}
#endif /* EXPERIMENTAL_FEATURES */
/* BOLT #2:
* - if both nodes advertised `option_support_large_channel`:
@@ -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,

View File

@@ -873,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",

View File

@@ -1058,14 +1058,10 @@ static void peer_connected_hook_final(struct peer_connected_hook_payload *payloa
}
case DUALOPEND_OPEN_INIT:
case DUALOPEND_AWAITING_LOCKIN:
#if EXPERIMENTAL_FEATURES
assert(!channel->owner);
channel->peer->addr = addr;
peer_restart_dualopend(peer, payload->pps, channel, NULL);
return;
#else
abort();
#endif /* EXPERIMENTAL_FEATURES */
case CHANNELD_AWAITING_LOCKIN:
case CHANNELD_NORMAL:
case CHANNELD_SHUTTING_DOWN:
@@ -1089,7 +1085,6 @@ static void peer_connected_hook_final(struct peer_connected_hook_payload *payloa
error = NULL;
send_error:
#if EXPERIMENTAL_FEATURES
if (feature_negotiated(ld->our_features,
peer->their_features,
OPT_DUAL_FUND)) {
@@ -1104,7 +1099,6 @@ send_error:
} else
peer_start_dualopend(peer, payload->pps, error);
} else
#endif /* EXPERIMENTAL_FEATURES */
peer_start_openingd(peer, payload->pps, error);
}
@@ -1415,11 +1409,9 @@ static void json_add_peer(struct lightningd *ld,
json_add_uncommitted_channel(response, p->uncommitted_channel);
list_for_each(&p->channels, channel, list) {
#if EXPERIMENTAL_FEATURES
if (channel_unsaved(channel))
json_add_unsaved_channel(response, channel);
else
#endif /* EXPERIMENTAL_FEATURES */
json_add_channel(ld, response, NULL, channel);
}
json_array_end(response);
@@ -1562,12 +1554,10 @@ static struct command_result *json_close(struct command *cmd,
return command_success(cmd, json_stream_success(cmd));
}
#if EXPERIMENTAL_FEATURES
if ((channel = peer_unsaved_channel(peer))) {
channel_close_conn(channel, "close command called");
return command_success(cmd, json_stream_success(cmd));
}
#endif /* EXPERIMENTAL_FEATURES */
return command_fail(cmd, LIGHTNINGD,
"Peer has no active channel");
}
@@ -1863,13 +1853,11 @@ static struct command_result *json_disconnect(struct command *cmd,
return command_fail(cmd, LIGHTNINGD, "Peer is in state %s",
channel_state_name(channel));
}
#if EXPERIMENTAL_FEATURES
channel = peer_unsaved_channel(peer);
if (channel) {
channel_close_conn(channel, "disconnect command");
return command_success(cmd, json_stream_success(cmd));
}
#endif /* EXPERIMENTAL_FEATURES */
if (!peer->uncommitted_channel) {
return command_fail(cmd, LIGHTNINGD, "Peer not connected");
}

View File

@@ -23,12 +23,7 @@ $(DUALOPEND_OBJS): $(DUALOPEND_HEADERS)
# Make sure these depend on everything.
ALL_C_SOURCES += $(OPENINGD_SRC) $(DUALOPEND_SRC)
ALL_C_HEADERS += $(OPENINGD_HEADERS) $(DUALOPEND_HEADERS)
ALL_PROGRAMS += lightningd/lightning_openingd
# Only build dualopend if experimental features is on
ifeq ($(EXPERIMENTAL_FEATURES),1)
ALL_PROGRAMS += lightningd/lightning_dualopend
endif
ALL_PROGRAMS += lightningd/lightning_openingd lightningd/lightning_dualopend
# Here's what lightningd depends on
LIGHTNINGD_CONTROL_HEADERS += openingd/openingd_wiregen.h openingd/dualopend_wiregen.h
@@ -71,6 +66,7 @@ OPENINGD_COMMON_OBJS := \
common/peer_billboard.o \
common/peer_failed.o \
common/permute_tx.o \
common/psbt_internal.o \
common/psbt_open.o \
common/pseudorand.o \
common/read_peer_msg.o \
@@ -88,10 +84,6 @@ OPENINGD_COMMON_OBJS := \
gossipd/gossipd_peerd_wiregen.o \
lightningd/gossip_msg.o
ifeq ($(EXPERIMENTAL_FEATURES),1)
OPENINGD_COMMON_OBJS += common/psbt_internal.o
endif
lightningd/lightning_openingd: $(OPENINGD_OBJS) $(OPENINGD_COMMON_OBJS) $(WIRE_OBJS) $(BITCOIN_OBJS) $(HSMD_CLIENT_OBJS)
lightningd/lightning_dualopend: $(DUALOPEND_OBJS) $(OPENINGD_COMMON_OBJS) $(WIRE_OBJS) $(BITCOIN_OBJS) $(HSMD_CLIENT_OBJS)

View File

@@ -1540,12 +1540,10 @@ connect_ok(struct command *cmd,
json_tok_full(buf, features_tok));
/* Set the open protocol to use now */
#if EXPERIMENTAL_FEATURES
if (feature_negotiated(plugin_feature_set(mfc->cmd->plugin),
dest->their_features,
OPT_DUAL_FUND))
dest->protocol = OPEN_CHANNEL;
#endif /* EXPERIMENTAL_FEATURES */
dest->state = MULTIFUNDCHANNEL_CONNECTED;
return connect_done(dest);

View File

@@ -338,8 +338,8 @@ def test_disconnect_fundee(node_factory):
assert len(l2.rpc.listpeers()) == 1
@unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need')
@unittest.skipIf(not DEVELOPER, "needs DEVELOPER=1")
@unittest.skipIf(not EXPERIMENTAL_DUAL_FUND, "needs OPT_DUAL_FUND")
def test_disconnect_fundee_v2(node_factory):
# Now error on fundee side during channel open, with them funding
disconnects = ['-WIRE_ACCEPT_CHANNEL2',
@@ -357,9 +357,10 @@ def test_disconnect_fundee_v2(node_factory):
accepter_plugin = os.path.join(os.path.dirname(__file__),
'plugins/df_accepter.py')
l1 = node_factory.get_node()
l1 = node_factory.get_node(options={'experimental-dual-fund': None})
l2 = node_factory.get_node(disconnect=disconnects,
options={'plugin': accepter_plugin})
options={'plugin': accepter_plugin,
'experimental-dual-fund': None})
l1.fundwallet(2000000)
l2.fundwallet(2000000)
@@ -950,12 +951,10 @@ def test_funding_toolarge(node_factory, bitcoind):
@unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need')
@unittest.skipIf(not EXPERIMENTAL_FEATURES, "dual-funding is experimental only")
@unittest.skipIf(not DEVELOPER, "Requires --dev-force-features")
def test_v2_open(node_factory, bitcoind, chainparams):
l1, l2 = node_factory.get_nodes(2,
opts=[{'dev-force-features': '+223'},
{'dev-force-features': '+223'}])
opts=[{'experimental-dual-fund': None},
{'experimental-dual-fund': None}])
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
amount = 2**24
@@ -1398,7 +1397,7 @@ def test_funding_external_wallet(node_factory, bitcoind):
l3.rpc.close(l2.info["id"])
@unittest.skipIf(not EXPERIMENTAL_FEATURES, "requires opt_dual_fund")
@unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need')
def test_multifunding_v2_v1_mixed(node_factory, bitcoind):
'''
Simple test for multifundchannel, using v1 + v2
@@ -1436,8 +1435,7 @@ def test_multifunding_v2_v1_mixed(node_factory, bitcoind):
l1.rpc.pay(inv)
@unittest.skipIf(not EXPERIMENTAL_FEATURES, "requires opt_dual_fund")
@unittest.skipIf(not DEVELOPER, "requires dev-force-features")
@unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need')
def test_multifunding_v2_exclusive(node_factory, bitcoind):
'''
Simple test for multifundchannel, using v2
@@ -1445,10 +1443,10 @@ def test_multifunding_v2_exclusive(node_factory, bitcoind):
accepter_plugin = os.path.join(os.path.dirname(__file__),
'plugins/df_accepter.py')
# Two of three will reply with inputs of their own
options = [{'dev-force-features': '+223'},
{'plugin': accepter_plugin, 'dev-force-features': '+223'},
{'plugin': accepter_plugin, 'dev-force-features': '+223'},
{'dev-force-features': '+223'}]
options = [{'experimental-dual-fund': None},
{'plugin': accepter_plugin, 'experimental-dual-fund': None},
{'plugin': accepter_plugin, 'experimental-dual-fund': None},
{'experimental-dual-fund': None}]
l1, l2, l3, l4 = node_factory.get_nodes(4, opts=options)
l1.fundwallet(2000000)
@@ -2809,13 +2807,14 @@ def test_fail_unconfirmed(node_factory, bitcoind, executor):
@unittest.skipIf(not DEVELOPER, "need dev-disconnect")
@unittest.skipIf(not EXPERIMENTAL_DUAL_FUND, "need dev-disconnect")
@unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need')
def test_fail_unconfirmed_openchannel2(node_factory, bitcoind, executor):
"""Test that if we crash with an unconfirmed connection to a known
peer, we don't have a dangling peer in db"""
# = is a NOOP disconnect, but sets up file.
l1 = node_factory.get_node(disconnect=['=WIRE_OPEN_CHANNEL2'])
l2 = node_factory.get_node()
l1 = node_factory.get_node(disconnect=['=WIRE_OPEN_CHANNEL2'],
options={'experimental-dual-fund': None})
l2 = node_factory.get_node(options={'experimental-dual-fund': None})
# First one, we close by mutual agreement.
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)

View File

@@ -2,8 +2,7 @@ from fixtures import * # noqa: F401,F403
from fixtures import TEST_NETWORK
from pyln.client import RpcError
from utils import (
only_one, wait_for, sync_blockheight, EXPERIMENTAL_FEATURES, DEVELOPER,
first_channel_id
only_one, wait_for, sync_blockheight, DEVELOPER, first_channel_id
)
import pytest
@@ -17,7 +16,7 @@ def find_next_feerate(node, peer):
@unittest.skipIf(not DEVELOPER, "disconnect=... needs DEVELOPER=1")
@unittest.skipIf(not EXPERIMENTAL_FEATURES, "dual-funding is experimental only")
@unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need')
def test_multifunding_v2_best_effort(node_factory, bitcoind):
'''
Check that best_effort flag works.
@@ -25,10 +24,10 @@ def test_multifunding_v2_best_effort(node_factory, bitcoind):
disconnects = ["-WIRE_INIT",
"-WIRE_ACCEPT_CHANNEL",
"-WIRE_FUNDING_SIGNED"]
l1 = node_factory.get_node(options={'dev-force-features': '+223'},
l1 = node_factory.get_node(options={'experimental-dual-fund': None},
allow_warning=True,
may_reconnect=True)
l2 = node_factory.get_node(options={'dev-force-features': '+223'},
l2 = node_factory.get_node(options={'experimental-dual-fund': None},
allow_warning=True,
may_reconnect=True)
l3 = node_factory.get_node(disconnect=disconnects)
@@ -101,7 +100,7 @@ def test_multifunding_v2_best_effort(node_factory, bitcoind):
@unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need')
@unittest.skipIf(not EXPERIMENTAL_FEATURES, "dual-funding is experimental only")
@unittest.skipIf(not DEVELOPER, "disconnect=... needs DEVELOPER=1")
def test_v2_open_sigs_restart(node_factory, bitcoind):
disconnects_1 = ['-WIRE_TX_SIGNATURES']
disconnects_2 = ['+WIRE_TX_SIGNATURES']
@@ -146,7 +145,7 @@ def test_v2_open_sigs_restart(node_factory, bitcoind):
@unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need')
@unittest.skipIf(not EXPERIMENTAL_FEATURES, "dual-funding is experimental only")
@unittest.skipIf(not DEVELOPER, "disconnect=... needs DEVELOPER=1")
def test_v2_open_sigs_restart_while_dead(node_factory, bitcoind):
# Same thing as above, except the transaction mines
# while we're asleep
@@ -154,10 +153,10 @@ def test_v2_open_sigs_restart_while_dead(node_factory, bitcoind):
disconnects_2 = ['+WIRE_TX_SIGNATURES']
l1, l2 = node_factory.get_nodes(2,
opts=[{'dev-force-features': '+223',
opts=[{'experimental-dual-fund': None,
'disconnect': disconnects_1,
'may_reconnect': True},
{'dev-force-features': '+223',
{'experimental-dual-fund': None,
'disconnect': disconnects_2,
'may_reconnect': True}])
@@ -197,11 +196,10 @@ def test_v2_open_sigs_restart_while_dead(node_factory, bitcoind):
@unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need')
@unittest.skipIf(not EXPERIMENTAL_FEATURES, "dual-funding is experimental only")
def test_v2_rbf(node_factory, bitcoind, chainparams):
l1, l2 = node_factory.get_nodes(2,
opts=[{'dev-force-features': '+223'},
{'dev-force-features': '+223'}])
opts=[{'experimental-dual-fund': None},
{'experimental-dual-fund': None}])
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
amount = 2**24
@@ -275,10 +273,9 @@ def test_v2_rbf(node_factory, bitcoind, chainparams):
@unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need')
@unittest.skipIf(not EXPERIMENTAL_FEATURES, "dual-funding is experimental only")
def test_v2_rbf_multi(node_factory, bitcoind, chainparams):
l1, l2 = node_factory.get_nodes(2,
opts={'dev-force-features': '+223',
opts={'experimental-dual-fund': None,
'may_reconnect': True,
'allow_warning': True})
@@ -356,17 +353,17 @@ def test_v2_rbf_multi(node_factory, bitcoind, chainparams):
@unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need')
@unittest.skipIf(not EXPERIMENTAL_FEATURES, "dual-funding is experimental only")
@unittest.skipIf(not DEVELOPER, "disconnect=... needs DEVELOPER=1")
def test_rbf_reconnect_init(node_factory, bitcoind, chainparams):
disconnects = ['-WIRE_INIT_RBF',
'@WIRE_INIT_RBF',
'+WIRE_INIT_RBF']
l1, l2 = node_factory.get_nodes(2,
opts=[{'dev-force-features': '+223',
opts=[{'experimental-dual-fund': None,
'disconnect': disconnects,
'may_reconnect': True},
{'dev-force-features': '+223',
{'experimental-dual-fund': None,
'may_reconnect': True}])
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
@@ -408,16 +405,16 @@ def test_rbf_reconnect_init(node_factory, bitcoind, chainparams):
@unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need')
@unittest.skipIf(not EXPERIMENTAL_FEATURES, "dual-funding is experimental only")
@unittest.skipIf(not DEVELOPER, "disconnect=... needs DEVELOPER=1")
def test_rbf_reconnect_ack(node_factory, bitcoind, chainparams):
disconnects = ['-WIRE_ACK_RBF',
'@WIRE_ACK_RBF',
'+WIRE_ACK_RBF']
l1, l2 = node_factory.get_nodes(2,
opts=[{'dev-force-features': '+223',
opts=[{'experimental-dual-fund': None,
'may_reconnect': True},
{'dev-force-features': '+223',
{'experimental-dual-fund': None,
'disconnect': disconnects,
'may_reconnect': True}])
@@ -460,7 +457,7 @@ def test_rbf_reconnect_ack(node_factory, bitcoind, chainparams):
@unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need')
@unittest.skipIf(not EXPERIMENTAL_FEATURES, "dual-funding is experimental only")
@unittest.skipIf(not DEVELOPER, "disconnect=... needs DEVELOPER=1")
def test_rbf_reconnect_tx_construct(node_factory, bitcoind, chainparams):
disconnects = ['=WIRE_TX_ADD_INPUT', # Initial funding succeeds
'-WIRE_TX_ADD_INPUT',
@@ -474,10 +471,10 @@ def test_rbf_reconnect_tx_construct(node_factory, bitcoind, chainparams):
'+WIRE_TX_COMPLETE']
l1, l2 = node_factory.get_nodes(2,
opts=[{'dev-force-features': '+223',
opts=[{'experimental-dual-fund': None,
'disconnect': disconnects,
'may_reconnect': True},
{'dev-force-features': '+223',
{'experimental-dual-fund': None,
'may_reconnect': True}])
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
@@ -528,7 +525,6 @@ def test_rbf_reconnect_tx_construct(node_factory, bitcoind, chainparams):
@unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need')
@unittest.skipIf(not EXPERIMENTAL_FEATURES, "dual-funding is experimental only")
def test_rbf_reconnect_tx_sigs(node_factory, bitcoind, chainparams):
disconnects = ['=WIRE_TX_SIGNATURES', # Initial funding succeeds
'-WIRE_TX_SIGNATURES', # When we send tx-sigs, RBF
@@ -538,10 +534,10 @@ def test_rbf_reconnect_tx_sigs(node_factory, bitcoind, chainparams):
'+WIRE_TX_SIGNATURES'] # When we RBF again
l1, l2 = node_factory.get_nodes(2,
opts=[{'dev-force-features': '+223',
opts=[{'experimental-dual-fund': None,
'disconnect': disconnects,
'may_reconnect': True},
{'dev-force-features': '+223',
{'experimental-dual-fund': None,
'may_reconnect': True}])
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
@@ -662,10 +658,9 @@ def test_rbf_reconnect_tx_sigs(node_factory, bitcoind, chainparams):
@unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need')
@unittest.skipIf(not EXPERIMENTAL_FEATURES, "dual-funding is experimental only")
def test_rbf_no_overlap(node_factory, bitcoind, chainparams):
l1, l2 = node_factory.get_nodes(2,
opts={'dev-force-features': '+223',
opts={'experimental-dual-fund': None,
'allow_warning': True})
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)

774
wire/peer_printgen.c generated
View File

@@ -32,6 +32,30 @@ void printpeer_wire_message(const u8 *msg)
printf("WIRE_PONG:\n");
printwire_pong("pong", msg);
return;
case WIRE_TX_ADD_INPUT:
printf("WIRE_TX_ADD_INPUT:\n");
printwire_tx_add_input("tx_add_input", msg);
return;
case WIRE_TX_ADD_OUTPUT:
printf("WIRE_TX_ADD_OUTPUT:\n");
printwire_tx_add_output("tx_add_output", msg);
return;
case WIRE_TX_REMOVE_INPUT:
printf("WIRE_TX_REMOVE_INPUT:\n");
printwire_tx_remove_input("tx_remove_input", msg);
return;
case WIRE_TX_REMOVE_OUTPUT:
printf("WIRE_TX_REMOVE_OUTPUT:\n");
printwire_tx_remove_output("tx_remove_output", msg);
return;
case WIRE_TX_COMPLETE:
printf("WIRE_TX_COMPLETE:\n");
printwire_tx_complete("tx_complete", msg);
return;
case WIRE_TX_SIGNATURES:
printf("WIRE_TX_SIGNATURES:\n");
printwire_tx_signatures("tx_signatures", msg);
return;
case WIRE_OPEN_CHANNEL:
printf("WIRE_OPEN_CHANNEL:\n");
printwire_open_channel("open_channel", msg);
@@ -52,6 +76,22 @@ void printpeer_wire_message(const u8 *msg)
printf("WIRE_FUNDING_LOCKED:\n");
printwire_funding_locked("funding_locked", msg);
return;
case WIRE_OPEN_CHANNEL2:
printf("WIRE_OPEN_CHANNEL2:\n");
printwire_open_channel2("open_channel2", msg);
return;
case WIRE_ACCEPT_CHANNEL2:
printf("WIRE_ACCEPT_CHANNEL2:\n");
printwire_accept_channel2("accept_channel2", msg);
return;
case WIRE_INIT_RBF:
printf("WIRE_INIT_RBF:\n");
printwire_init_rbf("init_rbf", msg);
return;
case WIRE_ACK_RBF:
printf("WIRE_ACK_RBF:\n");
printwire_ack_rbf("ack_rbf", msg);
return;
case WIRE_SHUTDOWN:
printf("WIRE_SHUTDOWN:\n");
printwire_shutdown("shutdown", msg);
@@ -138,6 +178,24 @@ void printpeer_wire_message(const u8 *msg)
}
void printwire_witness_element(const char *fieldname, const u8 **cursor, size_t *plen)
{
u16 len = fromwire_u16(cursor, plen);
if (!*cursor) {
printf("**TRUNCATED**\n");
return;
}
printf("witness=");
printwire_u8_array(tal_fmt(NULL, "%s.witness", fieldname), cursor, plen, len);
if (!*cursor) {
printf("**TRUNCATED**\n");
return;
}
}
void printwire_channel_update_checksums(const char *fieldname, const u8 **cursor, size_t *plen)
{
@@ -182,6 +240,30 @@ void printwire_channel_update_timestamps(const char *fieldname, const u8 **curso
}
void printwire_witness_stack(const char *fieldname, const u8 **cursor, size_t *plen)
{
u16 num_input_witness = fromwire_u16(cursor, plen);
if (!*cursor) {
printf("**TRUNCATED**\n");
return;
}
printf("witness_element=");
printf("[");
for (size_t i = 0; i < num_input_witness; i++) {
printf("{\n");
printwire_witness_element(tal_fmt(NULL, "%s.witness_element", fieldname), cursor, plen);
printf("}\n");
}
printf("]");
if (!*cursor) {
printf("**TRUNCATED**\n");
return;
}
}
static void printwire_tlv_init_tlvs_networks(const char *fieldname, const u8 **cursor, size_t *plen)
{
printf("(msg_name=%s)\n", "networks");
@@ -362,6 +444,52 @@ static const struct tlv_print_record_type print_tlvs_accept_channel_tlvs[] = {
{ 0, printwire_tlv_accept_channel_tlvs_upfront_shutdown_script },
};
static void printwire_tlv_opening_tlvs_option_upfront_shutdown_script(const char *fieldname, const u8 **cursor, size_t *plen)
{
printf("(msg_name=%s)\n", "option_upfront_shutdown_script");
u16 shutdown_len = fromwire_u16(cursor, plen);
if (!*cursor) {
printf("**TRUNCATED**\n");
return;
}
printf("shutdown_scriptpubkey=");
printwire_u8_array(tal_fmt(NULL, "%s.shutdown_scriptpubkey", fieldname), cursor, plen, shutdown_len);
if (!*cursor) {
printf("**TRUNCATED**\n");
return;
}
}
static const struct tlv_print_record_type print_tlvs_opening_tlvs[] = {
{ 1, printwire_tlv_opening_tlvs_option_upfront_shutdown_script },
};
static void printwire_tlv_accept_tlvs_option_upfront_shutdown_script(const char *fieldname, const u8 **cursor, size_t *plen)
{
printf("(msg_name=%s)\n", "option_upfront_shutdown_script");
u16 shutdown_len = fromwire_u16(cursor, plen);
if (!*cursor) {
printf("**TRUNCATED**\n");
return;
}
printf("shutdown_scriptpubkey=");
printwire_u8_array(tal_fmt(NULL, "%s.shutdown_scriptpubkey", fieldname), cursor, plen, shutdown_len);
if (!*cursor) {
printf("**TRUNCATED**\n");
return;
}
}
static const struct tlv_print_record_type print_tlvs_accept_tlvs[] = {
{ 1, printwire_tlv_accept_tlvs_option_upfront_shutdown_script },
};
static void printwire_tlv_shutdown_tlvs_wrong_funding(const char *fieldname, const u8 **cursor, size_t *plen)
{
printf("(msg_name=%s)\n", "wrong_funding");
@@ -667,6 +795,263 @@ void printwire_pong(const char *fieldname, const u8 *cursor)
}
if (plen != 0)
printf("EXTRA: %s\n", tal_hexstr(NULL, cursor, plen));
}
void printwire_tx_add_input(const char *fieldname, const u8 *cursor)
{
size_t plen = tal_count(cursor);
if (fromwire_u16(&cursor, &plen) != WIRE_TX_ADD_INPUT) {
printf("WRONG TYPE?!\n");
return;
}
printf("channel_id=");
struct channel_id channel_id;
fromwire_channel_id(&cursor, &plen, &channel_id);
printwire_channel_id(tal_fmt(NULL, "%s.channel_id", fieldname), &channel_id);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
printf("serial_id=");
u64 serial_id = fromwire_u64(&cursor, &plen);
printwire_u64(tal_fmt(NULL, "%s.serial_id", fieldname), &serial_id);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
u16 prevtx_len = fromwire_u16(&cursor, &plen);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
printf("prevtx=");
printwire_u8_array(tal_fmt(NULL, "%s.prevtx", fieldname), &cursor, &plen, prevtx_len);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
printf("prevtx_vout=");
u32 prevtx_vout = fromwire_u32(&cursor, &plen);
printwire_u32(tal_fmt(NULL, "%s.prevtx_vout", fieldname), &prevtx_vout);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
printf("sequence=");
u32 sequence = fromwire_u32(&cursor, &plen);
printwire_u32(tal_fmt(NULL, "%s.sequence", fieldname), &sequence);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
u16 script_sig_len = fromwire_u16(&cursor, &plen);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
printf("script_sig=");
printwire_u8_array(tal_fmt(NULL, "%s.script_sig", fieldname), &cursor, &plen, script_sig_len);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
if (plen != 0)
printf("EXTRA: %s\n", tal_hexstr(NULL, cursor, plen));
}
void printwire_tx_add_output(const char *fieldname, const u8 *cursor)
{
size_t plen = tal_count(cursor);
if (fromwire_u16(&cursor, &plen) != WIRE_TX_ADD_OUTPUT) {
printf("WRONG TYPE?!\n");
return;
}
printf("channel_id=");
struct channel_id channel_id;
fromwire_channel_id(&cursor, &plen, &channel_id);
printwire_channel_id(tal_fmt(NULL, "%s.channel_id", fieldname), &channel_id);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
printf("serial_id=");
u64 serial_id = fromwire_u64(&cursor, &plen);
printwire_u64(tal_fmt(NULL, "%s.serial_id", fieldname), &serial_id);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
printf("sats=");
u64 sats = fromwire_u64(&cursor, &plen);
printwire_u64(tal_fmt(NULL, "%s.sats", fieldname), &sats);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
u16 scriptlen = fromwire_u16(&cursor, &plen);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
printf("script=");
printwire_u8_array(tal_fmt(NULL, "%s.script", fieldname), &cursor, &plen, scriptlen);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
if (plen != 0)
printf("EXTRA: %s\n", tal_hexstr(NULL, cursor, plen));
}
void printwire_tx_remove_input(const char *fieldname, const u8 *cursor)
{
size_t plen = tal_count(cursor);
if (fromwire_u16(&cursor, &plen) != WIRE_TX_REMOVE_INPUT) {
printf("WRONG TYPE?!\n");
return;
}
printf("channel_id=");
struct channel_id channel_id;
fromwire_channel_id(&cursor, &plen, &channel_id);
printwire_channel_id(tal_fmt(NULL, "%s.channel_id", fieldname), &channel_id);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
printf("serial_id=");
u64 serial_id = fromwire_u64(&cursor, &plen);
printwire_u64(tal_fmt(NULL, "%s.serial_id", fieldname), &serial_id);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
if (plen != 0)
printf("EXTRA: %s\n", tal_hexstr(NULL, cursor, plen));
}
void printwire_tx_remove_output(const char *fieldname, const u8 *cursor)
{
size_t plen = tal_count(cursor);
if (fromwire_u16(&cursor, &plen) != WIRE_TX_REMOVE_OUTPUT) {
printf("WRONG TYPE?!\n");
return;
}
printf("channel_id=");
struct channel_id channel_id;
fromwire_channel_id(&cursor, &plen, &channel_id);
printwire_channel_id(tal_fmt(NULL, "%s.channel_id", fieldname), &channel_id);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
printf("serial_id=");
u64 serial_id = fromwire_u64(&cursor, &plen);
printwire_u64(tal_fmt(NULL, "%s.serial_id", fieldname), &serial_id);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
if (plen != 0)
printf("EXTRA: %s\n", tal_hexstr(NULL, cursor, plen));
}
void printwire_tx_complete(const char *fieldname, const u8 *cursor)
{
size_t plen = tal_count(cursor);
if (fromwire_u16(&cursor, &plen) != WIRE_TX_COMPLETE) {
printf("WRONG TYPE?!\n");
return;
}
printf("channel_id=");
struct channel_id channel_id;
fromwire_channel_id(&cursor, &plen, &channel_id);
printwire_channel_id(tal_fmt(NULL, "%s.channel_id", fieldname), &channel_id);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
if (plen != 0)
printf("EXTRA: %s\n", tal_hexstr(NULL, cursor, plen));
}
void printwire_tx_signatures(const char *fieldname, const u8 *cursor)
{
size_t plen = tal_count(cursor);
if (fromwire_u16(&cursor, &plen) != WIRE_TX_SIGNATURES) {
printf("WRONG TYPE?!\n");
return;
}
printf("channel_id=");
struct channel_id channel_id;
fromwire_channel_id(&cursor, &plen, &channel_id);
printwire_channel_id(tal_fmt(NULL, "%s.channel_id", fieldname), &channel_id);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
printf("txid=");
struct bitcoin_txid txid;
fromwire_bitcoin_txid(&cursor, &plen, &txid);
printwire_bitcoin_txid(tal_fmt(NULL, "%s.txid", fieldname), &txid);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
u16 num_witnesses = fromwire_u16(&cursor, &plen);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
printf("witness_stack=");
printf("[");
for (size_t i = 0; i < num_witnesses; i++) {
printf("{\n");
printwire_witness_stack(tal_fmt(NULL, "%s.witness_stack", fieldname), &cursor, &plen);
printf("}\n");
}
printf("]");
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
if (plen != 0)
printf("EXTRA: %s\n", tal_hexstr(NULL, cursor, plen));
}
@@ -1083,6 +1468,387 @@ void printwire_funding_locked(const char *fieldname, const u8 *cursor)
}
if (plen != 0)
printf("EXTRA: %s\n", tal_hexstr(NULL, cursor, plen));
}
void printwire_open_channel2(const char *fieldname, const u8 *cursor)
{
size_t plen = tal_count(cursor);
if (fromwire_u16(&cursor, &plen) != WIRE_OPEN_CHANNEL2) {
printf("WRONG TYPE?!\n");
return;
}
printf("chain_hash=");
struct bitcoin_blkid chain_hash;
fromwire_bitcoin_blkid(&cursor, &plen, &chain_hash);
printwire_bitcoin_blkid(tal_fmt(NULL, "%s.chain_hash", fieldname), &chain_hash);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
printf("channel_id=");
struct channel_id channel_id;
fromwire_channel_id(&cursor, &plen, &channel_id);
printwire_channel_id(tal_fmt(NULL, "%s.channel_id", fieldname), &channel_id);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
printf("funding_feerate_perkw=");
u32 funding_feerate_perkw = fromwire_u32(&cursor, &plen);
printwire_u32(tal_fmt(NULL, "%s.funding_feerate_perkw", fieldname), &funding_feerate_perkw);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
printf("commitment_feerate_perkw=");
u32 commitment_feerate_perkw = fromwire_u32(&cursor, &plen);
printwire_u32(tal_fmt(NULL, "%s.commitment_feerate_perkw", fieldname), &commitment_feerate_perkw);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
printf("funding_satoshis=");
struct amount_sat funding_satoshis = fromwire_amount_sat(&cursor, &plen);
printwire_amount_sat(tal_fmt(NULL, "%s.funding_satoshis", fieldname), &funding_satoshis);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
printf("dust_limit_satoshis=");
struct amount_sat dust_limit_satoshis = fromwire_amount_sat(&cursor, &plen);
printwire_amount_sat(tal_fmt(NULL, "%s.dust_limit_satoshis", fieldname), &dust_limit_satoshis);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
printf("max_htlc_value_in_flight_msat=");
struct amount_msat max_htlc_value_in_flight_msat = fromwire_amount_msat(&cursor, &plen);
printwire_amount_msat(tal_fmt(NULL, "%s.max_htlc_value_in_flight_msat", fieldname), &max_htlc_value_in_flight_msat);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
printf("htlc_minimum_msat=");
struct amount_msat htlc_minimum_msat = fromwire_amount_msat(&cursor, &plen);
printwire_amount_msat(tal_fmt(NULL, "%s.htlc_minimum_msat", fieldname), &htlc_minimum_msat);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
printf("to_self_delay=");
u16 to_self_delay = fromwire_u16(&cursor, &plen);
printwire_u16(tal_fmt(NULL, "%s.to_self_delay", fieldname), &to_self_delay);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
printf("max_accepted_htlcs=");
u16 max_accepted_htlcs = fromwire_u16(&cursor, &plen);
printwire_u16(tal_fmt(NULL, "%s.max_accepted_htlcs", fieldname), &max_accepted_htlcs);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
printf("locktime=");
u32 locktime = fromwire_u32(&cursor, &plen);
printwire_u32(tal_fmt(NULL, "%s.locktime", fieldname), &locktime);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
printf("funding_pubkey=");
struct pubkey funding_pubkey;
fromwire_pubkey(&cursor, &plen, &funding_pubkey);
printwire_pubkey(tal_fmt(NULL, "%s.funding_pubkey", fieldname), &funding_pubkey);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
printf("revocation_basepoint=");
struct pubkey revocation_basepoint;
fromwire_pubkey(&cursor, &plen, &revocation_basepoint);
printwire_pubkey(tal_fmt(NULL, "%s.revocation_basepoint", fieldname), &revocation_basepoint);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
printf("payment_basepoint=");
struct pubkey payment_basepoint;
fromwire_pubkey(&cursor, &plen, &payment_basepoint);
printwire_pubkey(tal_fmt(NULL, "%s.payment_basepoint", fieldname), &payment_basepoint);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
printf("delayed_payment_basepoint=");
struct pubkey delayed_payment_basepoint;
fromwire_pubkey(&cursor, &plen, &delayed_payment_basepoint);
printwire_pubkey(tal_fmt(NULL, "%s.delayed_payment_basepoint", fieldname), &delayed_payment_basepoint);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
printf("htlc_basepoint=");
struct pubkey htlc_basepoint;
fromwire_pubkey(&cursor, &plen, &htlc_basepoint);
printwire_pubkey(tal_fmt(NULL, "%s.htlc_basepoint", fieldname), &htlc_basepoint);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
printf("first_per_commitment_point=");
struct pubkey first_per_commitment_point;
fromwire_pubkey(&cursor, &plen, &first_per_commitment_point);
printwire_pubkey(tal_fmt(NULL, "%s.first_per_commitment_point", fieldname), &first_per_commitment_point);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
printf("channel_flags=");
u8 channel_flags = fromwire_u8(&cursor, &plen);
printwire_u8(tal_fmt(NULL, "%s.channel_flags", fieldname), &channel_flags);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
printf("tlvs=");
printwire_tlvs(tal_fmt(NULL, "%s.tlvs", fieldname), &cursor, &plen, print_tlvs_opening_tlvs, ARRAY_SIZE(print_tlvs_opening_tlvs));
if (plen != 0)
printf("EXTRA: %s\n", tal_hexstr(NULL, cursor, plen));
}
void printwire_accept_channel2(const char *fieldname, const u8 *cursor)
{
size_t plen = tal_count(cursor);
if (fromwire_u16(&cursor, &plen) != WIRE_ACCEPT_CHANNEL2) {
printf("WRONG TYPE?!\n");
return;
}
printf("channel_id=");
struct channel_id channel_id;
fromwire_channel_id(&cursor, &plen, &channel_id);
printwire_channel_id(tal_fmt(NULL, "%s.channel_id", fieldname), &channel_id);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
printf("funding_satoshis=");
struct amount_sat funding_satoshis = fromwire_amount_sat(&cursor, &plen);
printwire_amount_sat(tal_fmt(NULL, "%s.funding_satoshis", fieldname), &funding_satoshis);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
printf("dust_limit_satoshis=");
struct amount_sat dust_limit_satoshis = fromwire_amount_sat(&cursor, &plen);
printwire_amount_sat(tal_fmt(NULL, "%s.dust_limit_satoshis", fieldname), &dust_limit_satoshis);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
printf("max_htlc_value_in_flight_msat=");
struct amount_msat max_htlc_value_in_flight_msat = fromwire_amount_msat(&cursor, &plen);
printwire_amount_msat(tal_fmt(NULL, "%s.max_htlc_value_in_flight_msat", fieldname), &max_htlc_value_in_flight_msat);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
printf("htlc_minimum_msat=");
struct amount_msat htlc_minimum_msat = fromwire_amount_msat(&cursor, &plen);
printwire_amount_msat(tal_fmt(NULL, "%s.htlc_minimum_msat", fieldname), &htlc_minimum_msat);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
printf("minimum_depth=");
u32 minimum_depth = fromwire_u32(&cursor, &plen);
printwire_u32(tal_fmt(NULL, "%s.minimum_depth", fieldname), &minimum_depth);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
printf("to_self_delay=");
u16 to_self_delay = fromwire_u16(&cursor, &plen);
printwire_u16(tal_fmt(NULL, "%s.to_self_delay", fieldname), &to_self_delay);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
printf("max_accepted_htlcs=");
u16 max_accepted_htlcs = fromwire_u16(&cursor, &plen);
printwire_u16(tal_fmt(NULL, "%s.max_accepted_htlcs", fieldname), &max_accepted_htlcs);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
printf("funding_pubkey=");
struct pubkey funding_pubkey;
fromwire_pubkey(&cursor, &plen, &funding_pubkey);
printwire_pubkey(tal_fmt(NULL, "%s.funding_pubkey", fieldname), &funding_pubkey);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
printf("revocation_basepoint=");
struct pubkey revocation_basepoint;
fromwire_pubkey(&cursor, &plen, &revocation_basepoint);
printwire_pubkey(tal_fmt(NULL, "%s.revocation_basepoint", fieldname), &revocation_basepoint);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
printf("payment_basepoint=");
struct pubkey payment_basepoint;
fromwire_pubkey(&cursor, &plen, &payment_basepoint);
printwire_pubkey(tal_fmt(NULL, "%s.payment_basepoint", fieldname), &payment_basepoint);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
printf("delayed_payment_basepoint=");
struct pubkey delayed_payment_basepoint;
fromwire_pubkey(&cursor, &plen, &delayed_payment_basepoint);
printwire_pubkey(tal_fmt(NULL, "%s.delayed_payment_basepoint", fieldname), &delayed_payment_basepoint);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
printf("htlc_basepoint=");
struct pubkey htlc_basepoint;
fromwire_pubkey(&cursor, &plen, &htlc_basepoint);
printwire_pubkey(tal_fmt(NULL, "%s.htlc_basepoint", fieldname), &htlc_basepoint);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
printf("first_per_commitment_point=");
struct pubkey first_per_commitment_point;
fromwire_pubkey(&cursor, &plen, &first_per_commitment_point);
printwire_pubkey(tal_fmt(NULL, "%s.first_per_commitment_point", fieldname), &first_per_commitment_point);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
printf("tlvs=");
printwire_tlvs(tal_fmt(NULL, "%s.tlvs", fieldname), &cursor, &plen, print_tlvs_accept_tlvs, ARRAY_SIZE(print_tlvs_accept_tlvs));
if (plen != 0)
printf("EXTRA: %s\n", tal_hexstr(NULL, cursor, plen));
}
void printwire_init_rbf(const char *fieldname, const u8 *cursor)
{
size_t plen = tal_count(cursor);
if (fromwire_u16(&cursor, &plen) != WIRE_INIT_RBF) {
printf("WRONG TYPE?!\n");
return;
}
printf("channel_id=");
struct channel_id channel_id;
fromwire_channel_id(&cursor, &plen, &channel_id);
printwire_channel_id(tal_fmt(NULL, "%s.channel_id", fieldname), &channel_id);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
printf("funding_satoshis=");
struct amount_sat funding_satoshis = fromwire_amount_sat(&cursor, &plen);
printwire_amount_sat(tal_fmt(NULL, "%s.funding_satoshis", fieldname), &funding_satoshis);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
printf("locktime=");
u32 locktime = fromwire_u32(&cursor, &plen);
printwire_u32(tal_fmt(NULL, "%s.locktime", fieldname), &locktime);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
printf("fee_step=");
u8 fee_step = fromwire_u8(&cursor, &plen);
printwire_u8(tal_fmt(NULL, "%s.fee_step", fieldname), &fee_step);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
if (plen != 0)
printf("EXTRA: %s\n", tal_hexstr(NULL, cursor, plen));
}
void printwire_ack_rbf(const char *fieldname, const u8 *cursor)
{
size_t plen = tal_count(cursor);
if (fromwire_u16(&cursor, &plen) != WIRE_ACK_RBF) {
printf("WRONG TYPE?!\n");
return;
}
printf("channel_id=");
struct channel_id channel_id;
fromwire_channel_id(&cursor, &plen, &channel_id);
printwire_channel_id(tal_fmt(NULL, "%s.channel_id", fieldname), &channel_id);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
printf("funding_satoshis=");
struct amount_sat funding_satoshis = fromwire_amount_sat(&cursor, &plen);
printwire_amount_sat(tal_fmt(NULL, "%s.funding_satoshis", fieldname), &funding_satoshis);
if (!cursor) {
printf("**TRUNCATED**\n");
return;
}
if (plen != 0)
printf("EXTRA: %s\n", tal_hexstr(NULL, cursor, plen));
}
@@ -2147,6 +2913,12 @@ void printpeer_wire_tlv_message(const char *tlv_name, const u8 *msg) {
if (strcmp(tlv_name, "accept_channel_tlvs") == 0) {
printwire_tlvs(tlv_name, &msg, &plen, print_tlvs_accept_channel_tlvs, ARRAY_SIZE(print_tlvs_accept_channel_tlvs));
}
if (strcmp(tlv_name, "opening_tlvs") == 0) {
printwire_tlvs(tlv_name, &msg, &plen, print_tlvs_opening_tlvs, ARRAY_SIZE(print_tlvs_opening_tlvs));
}
if (strcmp(tlv_name, "accept_tlvs") == 0) {
printwire_tlvs(tlv_name, &msg, &plen, print_tlvs_accept_tlvs, ARRAY_SIZE(print_tlvs_accept_tlvs));
}
if (strcmp(tlv_name, "shutdown_tlvs") == 0) {
printwire_tlvs(tlv_name, &msg, &plen, print_tlvs_shutdown_tlvs, ARRAY_SIZE(print_tlvs_shutdown_tlvs));
}
@@ -2163,4 +2935,4 @@ void printpeer_wire_tlv_message(const char *tlv_name, const u8 *msg) {
printwire_tlvs(tlv_name, &msg, &plen, print_tlvs_onion_message_tlvs, ARRAY_SIZE(print_tlvs_onion_message_tlvs));
}
}
// SHA256STAMP:c7056cc0ec6b038e425e0800dce339f6ba38a18f14d1b33271656de218052ee2
// SHA256STAMP:650e49e75f12d335a4fc1a0ca7fd8231f8f50b605c0fb5c0b4ba085125c7d457

24
wire/peer_printgen.h generated
View File

@@ -20,6 +20,18 @@ void printwire_ping(const char *fieldname, const u8 *cursor);
void printwire_pong(const char *fieldname, const u8 *cursor);
void printwire_tx_add_input(const char *fieldname, const u8 *cursor);
void printwire_tx_add_output(const char *fieldname, const u8 *cursor);
void printwire_tx_remove_input(const char *fieldname, const u8 *cursor);
void printwire_tx_remove_output(const char *fieldname, const u8 *cursor);
void printwire_tx_complete(const char *fieldname, const u8 *cursor);
void printwire_tx_signatures(const char *fieldname, const u8 *cursor);
void printwire_open_channel(const char *fieldname, const u8 *cursor);
void printwire_accept_channel(const char *fieldname, const u8 *cursor);
@@ -30,6 +42,14 @@ void printwire_funding_signed(const char *fieldname, const u8 *cursor);
void printwire_funding_locked(const char *fieldname, const u8 *cursor);
void printwire_open_channel2(const char *fieldname, const u8 *cursor);
void printwire_accept_channel2(const char *fieldname, const u8 *cursor);
void printwire_init_rbf(const char *fieldname, const u8 *cursor);
void printwire_ack_rbf(const char *fieldname, const u8 *cursor);
void printwire_shutdown(const char *fieldname, const u8 *cursor);
void printwire_closing_signed(const char *fieldname, const u8 *cursor);
@@ -71,7 +91,9 @@ void printwire_gossip_timestamp_filter(const char *fieldname, const u8 *cursor);
void printwire_onion_message(const char *fieldname, const u8 *cursor);
void printwire_witness_element(const char *fieldname, const u8 **cursor, size_t *plen);
void printwire_channel_update_checksums(const char *fieldname, const u8 **cursor, size_t *plen);
void printwire_channel_update_timestamps(const char *fieldname, const u8 **cursor, size_t *plen);
void printwire_witness_stack(const char *fieldname, const u8 **cursor, size_t *plen);
#endif /* LIGHTNING_WIRE_PEER_PRINTGEN_H */
// SHA256STAMP:c7056cc0ec6b038e425e0800dce339f6ba38a18f14d1b33271656de218052ee2
// SHA256STAMP:650e49e75f12d335a4fc1a0ca7fd8231f8f50b605c0fb5c0b4ba085125c7d457

View File

@@ -34,7 +34,6 @@ static bool unknown_type(enum peer_wire t)
case WIRE_REPLY_CHANNEL_RANGE:
case WIRE_GOSSIP_TIMESTAMP_FILTER:
case WIRE_ONION_MESSAGE:
#if EXPERIMENTAL_FEATURES
case WIRE_TX_ADD_INPUT:
case WIRE_TX_REMOVE_INPUT:
case WIRE_TX_ADD_OUTPUT:
@@ -45,7 +44,6 @@ static bool unknown_type(enum peer_wire t)
case WIRE_ACCEPT_CHANNEL2:
case WIRE_INIT_RBF:
case WIRE_ACK_RBF:
#endif
return false;
}
return true;
@@ -85,7 +83,6 @@ bool is_msg_for_gossipd(const u8 *cursor)
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:
@@ -96,7 +93,6 @@ bool is_msg_for_gossipd(const u8 *cursor)
case WIRE_ACCEPT_CHANNEL2:
case WIRE_INIT_RBF:
case WIRE_ACK_RBF:
#endif
break;
}
return false;

View File

@@ -35,6 +35,40 @@ tlvtype,n2,tlv1,0
tlvdata,n2,tlv1,amount_msat,tu64,
tlvtype,n2,tlv2,11
tlvdata,n2,tlv2,cltv_expiry,tu32,
msgtype,tx_add_input,66
msgdata,tx_add_input,channel_id,channel_id,
msgdata,tx_add_input,serial_id,u64,
msgdata,tx_add_input,prevtx_len,u16,
msgdata,tx_add_input,prevtx,byte,prevtx_len
msgdata,tx_add_input,prevtx_vout,u32,
msgdata,tx_add_input,sequence,u32,
msgdata,tx_add_input,script_sig_len,u16,
msgdata,tx_add_input,script_sig,byte,script_sig_len
msgtype,tx_add_output,67
msgdata,tx_add_output,channel_id,channel_id,
msgdata,tx_add_output,serial_id,u64,
msgdata,tx_add_output,sats,u64,
msgdata,tx_add_output,scriptlen,u16,
msgdata,tx_add_output,script,byte,scriptlen
msgtype,tx_remove_input,68
msgdata,tx_remove_input,channel_id,channel_id,
msgdata,tx_remove_input,serial_id,u64,
msgtype,tx_remove_output,69
msgdata,tx_remove_output,channel_id,channel_id,
msgdata,tx_remove_output,serial_id,u64,
msgtype,tx_complete,70
msgdata,tx_complete,channel_id,channel_id,
msgtype,tx_signatures,71
msgdata,tx_signatures,channel_id,channel_id,
msgdata,tx_signatures,txid,sha256,
msgdata,tx_signatures,num_witnesses,u16,
msgdata,tx_signatures,witness_stack,witness_stack,num_witnesses
subtype,witness_stack
subtypedata,witness_stack,num_input_witness,u16,
subtypedata,witness_stack,witness_element,witness_element,num_input_witness
subtype,witness_element
subtypedata,witness_element,len,u16,
subtypedata,witness_element,witness,byte,len
msgtype,open_channel,32
msgdata,open_channel,chain_hash,chain_hash,
msgdata,open_channel,temporary_channel_id,byte,32
@@ -86,6 +120,56 @@ msgdata,funding_signed,signature,signature,
msgtype,funding_locked,36
msgdata,funding_locked,channel_id,channel_id,
msgdata,funding_locked,next_per_commitment_point,point,
msgtype,open_channel2,64
msgdata,open_channel2,chain_hash,chain_hash,
msgdata,open_channel2,channel_id,channel_id,
msgdata,open_channel2,funding_feerate_perkw,u32,
msgdata,open_channel2,commitment_feerate_perkw,u32,
msgdata,open_channel2,funding_satoshis,u64,
msgdata,open_channel2,dust_limit_satoshis,u64,
msgdata,open_channel2,max_htlc_value_in_flight_msat,u64,
msgdata,open_channel2,htlc_minimum_msat,u64,
msgdata,open_channel2,to_self_delay,u16,
msgdata,open_channel2,max_accepted_htlcs,u16,
msgdata,open_channel2,locktime,u32,
msgdata,open_channel2,funding_pubkey,point,
msgdata,open_channel2,revocation_basepoint,point,
msgdata,open_channel2,payment_basepoint,point,
msgdata,open_channel2,delayed_payment_basepoint,point,
msgdata,open_channel2,htlc_basepoint,point,
msgdata,open_channel2,first_per_commitment_point,point,
msgdata,open_channel2,channel_flags,byte,
msgdata,open_channel2,tlvs,opening_tlvs,
tlvtype,opening_tlvs,option_upfront_shutdown_script,1
tlvdata,opening_tlvs,option_upfront_shutdown_script,shutdown_len,u16,
tlvdata,opening_tlvs,option_upfront_shutdown_script,shutdown_scriptpubkey,byte,shutdown_len
msgtype,accept_channel2,65
msgdata,accept_channel2,channel_id,channel_id,
msgdata,accept_channel2,funding_satoshis,u64,
msgdata,accept_channel2,dust_limit_satoshis,u64,
msgdata,accept_channel2,max_htlc_value_in_flight_msat,u64,
msgdata,accept_channel2,htlc_minimum_msat,u64,
msgdata,accept_channel2,minimum_depth,u32,
msgdata,accept_channel2,to_self_delay,u16,
msgdata,accept_channel2,max_accepted_htlcs,u16,
msgdata,accept_channel2,funding_pubkey,point,
msgdata,accept_channel2,revocation_basepoint,point,
msgdata,accept_channel2,payment_basepoint,point,
msgdata,accept_channel2,delayed_payment_basepoint,point,
msgdata,accept_channel2,htlc_basepoint,point,
msgdata,accept_channel2,first_per_commitment_point,point,
msgdata,accept_channel2,tlvs,accept_tlvs,
tlvtype,accept_tlvs,option_upfront_shutdown_script,1
tlvdata,accept_tlvs,option_upfront_shutdown_script,shutdown_len,u16,
tlvdata,accept_tlvs,option_upfront_shutdown_script,shutdown_scriptpubkey,byte,shutdown_len
msgtype,init_rbf,72
msgdata,init_rbf,channel_id,channel_id,
msgdata,init_rbf,funding_satoshis,u64,
msgdata,init_rbf,locktime,u32,
msgdata,init_rbf,fee_step,byte,
msgtype,ack_rbf,73
msgdata,ack_rbf,channel_id,channel_id,
msgdata,ack_rbf,funding_satoshis,u64,
msgtype,shutdown,38
msgdata,shutdown,channel_id,channel_id,
msgdata,shutdown,len,u16,
1 msgtype,init,16
35 tlvdata,n2,tlv1,amount_msat,tu64,
36 tlvtype,n2,tlv2,11
37 tlvdata,n2,tlv2,cltv_expiry,tu32,
38 msgtype,tx_add_input,66
39 msgdata,tx_add_input,channel_id,channel_id,
40 msgdata,tx_add_input,serial_id,u64,
41 msgdata,tx_add_input,prevtx_len,u16,
42 msgdata,tx_add_input,prevtx,byte,prevtx_len
43 msgdata,tx_add_input,prevtx_vout,u32,
44 msgdata,tx_add_input,sequence,u32,
45 msgdata,tx_add_input,script_sig_len,u16,
46 msgdata,tx_add_input,script_sig,byte,script_sig_len
47 msgtype,tx_add_output,67
48 msgdata,tx_add_output,channel_id,channel_id,
49 msgdata,tx_add_output,serial_id,u64,
50 msgdata,tx_add_output,sats,u64,
51 msgdata,tx_add_output,scriptlen,u16,
52 msgdata,tx_add_output,script,byte,scriptlen
53 msgtype,tx_remove_input,68
54 msgdata,tx_remove_input,channel_id,channel_id,
55 msgdata,tx_remove_input,serial_id,u64,
56 msgtype,tx_remove_output,69
57 msgdata,tx_remove_output,channel_id,channel_id,
58 msgdata,tx_remove_output,serial_id,u64,
59 msgtype,tx_complete,70
60 msgdata,tx_complete,channel_id,channel_id,
61 msgtype,tx_signatures,71
62 msgdata,tx_signatures,channel_id,channel_id,
63 msgdata,tx_signatures,txid,sha256,
64 msgdata,tx_signatures,num_witnesses,u16,
65 msgdata,tx_signatures,witness_stack,witness_stack,num_witnesses
66 subtype,witness_stack
67 subtypedata,witness_stack,num_input_witness,u16,
68 subtypedata,witness_stack,witness_element,witness_element,num_input_witness
69 subtype,witness_element
70 subtypedata,witness_element,len,u16,
71 subtypedata,witness_element,witness,byte,len
72 msgtype,open_channel,32
73 msgdata,open_channel,chain_hash,chain_hash,
74 msgdata,open_channel,temporary_channel_id,byte,32
120 msgtype,funding_locked,36
121 msgdata,funding_locked,channel_id,channel_id,
122 msgdata,funding_locked,next_per_commitment_point,point,
123 msgtype,open_channel2,64
124 msgdata,open_channel2,chain_hash,chain_hash,
125 msgdata,open_channel2,channel_id,channel_id,
126 msgdata,open_channel2,funding_feerate_perkw,u32,
127 msgdata,open_channel2,commitment_feerate_perkw,u32,
128 msgdata,open_channel2,funding_satoshis,u64,
129 msgdata,open_channel2,dust_limit_satoshis,u64,
130 msgdata,open_channel2,max_htlc_value_in_flight_msat,u64,
131 msgdata,open_channel2,htlc_minimum_msat,u64,
132 msgdata,open_channel2,to_self_delay,u16,
133 msgdata,open_channel2,max_accepted_htlcs,u16,
134 msgdata,open_channel2,locktime,u32,
135 msgdata,open_channel2,funding_pubkey,point,
136 msgdata,open_channel2,revocation_basepoint,point,
137 msgdata,open_channel2,payment_basepoint,point,
138 msgdata,open_channel2,delayed_payment_basepoint,point,
139 msgdata,open_channel2,htlc_basepoint,point,
140 msgdata,open_channel2,first_per_commitment_point,point,
141 msgdata,open_channel2,channel_flags,byte,
142 msgdata,open_channel2,tlvs,opening_tlvs,
143 tlvtype,opening_tlvs,option_upfront_shutdown_script,1
144 tlvdata,opening_tlvs,option_upfront_shutdown_script,shutdown_len,u16,
145 tlvdata,opening_tlvs,option_upfront_shutdown_script,shutdown_scriptpubkey,byte,shutdown_len
146 msgtype,accept_channel2,65
147 msgdata,accept_channel2,channel_id,channel_id,
148 msgdata,accept_channel2,funding_satoshis,u64,
149 msgdata,accept_channel2,dust_limit_satoshis,u64,
150 msgdata,accept_channel2,max_htlc_value_in_flight_msat,u64,
151 msgdata,accept_channel2,htlc_minimum_msat,u64,
152 msgdata,accept_channel2,minimum_depth,u32,
153 msgdata,accept_channel2,to_self_delay,u16,
154 msgdata,accept_channel2,max_accepted_htlcs,u16,
155 msgdata,accept_channel2,funding_pubkey,point,
156 msgdata,accept_channel2,revocation_basepoint,point,
157 msgdata,accept_channel2,payment_basepoint,point,
158 msgdata,accept_channel2,delayed_payment_basepoint,point,
159 msgdata,accept_channel2,htlc_basepoint,point,
160 msgdata,accept_channel2,first_per_commitment_point,point,
161 msgdata,accept_channel2,tlvs,accept_tlvs,
162 tlvtype,accept_tlvs,option_upfront_shutdown_script,1
163 tlvdata,accept_tlvs,option_upfront_shutdown_script,shutdown_len,u16,
164 tlvdata,accept_tlvs,option_upfront_shutdown_script,shutdown_scriptpubkey,byte,shutdown_len
165 msgtype,init_rbf,72
166 msgdata,init_rbf,channel_id,channel_id,
167 msgdata,init_rbf,funding_satoshis,u64,
168 msgdata,init_rbf,locktime,u32,
169 msgdata,init_rbf,fee_step,byte,
170 msgtype,ack_rbf,73
171 msgdata,ack_rbf,channel_id,channel_id,
172 msgdata,ack_rbf,funding_satoshis,u64,
173 msgtype,shutdown,38
174 msgdata,shutdown,channel_id,channel_id,
175 msgdata,shutdown,len,u16,

524
wire/peer_wiregen.c generated
View File

@@ -25,11 +25,21 @@ const char *peer_wire_name(int e)
case WIRE_WARNING: return "WIRE_WARNING";
case WIRE_PING: return "WIRE_PING";
case WIRE_PONG: return "WIRE_PONG";
case WIRE_TX_ADD_INPUT: return "WIRE_TX_ADD_INPUT";
case WIRE_TX_ADD_OUTPUT: return "WIRE_TX_ADD_OUTPUT";
case WIRE_TX_REMOVE_INPUT: return "WIRE_TX_REMOVE_INPUT";
case WIRE_TX_REMOVE_OUTPUT: return "WIRE_TX_REMOVE_OUTPUT";
case WIRE_TX_COMPLETE: return "WIRE_TX_COMPLETE";
case WIRE_TX_SIGNATURES: return "WIRE_TX_SIGNATURES";
case WIRE_OPEN_CHANNEL: return "WIRE_OPEN_CHANNEL";
case WIRE_ACCEPT_CHANNEL: return "WIRE_ACCEPT_CHANNEL";
case WIRE_FUNDING_CREATED: return "WIRE_FUNDING_CREATED";
case WIRE_FUNDING_SIGNED: return "WIRE_FUNDING_SIGNED";
case WIRE_FUNDING_LOCKED: return "WIRE_FUNDING_LOCKED";
case WIRE_OPEN_CHANNEL2: return "WIRE_OPEN_CHANNEL2";
case WIRE_ACCEPT_CHANNEL2: return "WIRE_ACCEPT_CHANNEL2";
case WIRE_INIT_RBF: return "WIRE_INIT_RBF";
case WIRE_ACK_RBF: return "WIRE_ACK_RBF";
case WIRE_SHUTDOWN: return "WIRE_SHUTDOWN";
case WIRE_CLOSING_SIGNED: return "WIRE_CLOSING_SIGNED";
case WIRE_UPDATE_ADD_HTLC: return "WIRE_UPDATE_ADD_HTLC";
@@ -64,11 +74,21 @@ bool peer_wire_is_defined(u16 type)
case WIRE_WARNING:;
case WIRE_PING:;
case WIRE_PONG:;
case WIRE_TX_ADD_INPUT:;
case WIRE_TX_ADD_OUTPUT:;
case WIRE_TX_REMOVE_INPUT:;
case WIRE_TX_REMOVE_OUTPUT:;
case WIRE_TX_COMPLETE:;
case WIRE_TX_SIGNATURES:;
case WIRE_OPEN_CHANNEL:;
case WIRE_ACCEPT_CHANNEL:;
case WIRE_FUNDING_CREATED:;
case WIRE_FUNDING_SIGNED:;
case WIRE_FUNDING_LOCKED:;
case WIRE_OPEN_CHANNEL2:;
case WIRE_ACCEPT_CHANNEL2:;
case WIRE_INIT_RBF:;
case WIRE_ACK_RBF:;
case WIRE_SHUTDOWN:;
case WIRE_CLOSING_SIGNED:;
case WIRE_UPDATE_ADD_HTLC:;
@@ -97,6 +117,27 @@ bool peer_wire_is_defined(u16 type)
/* SUBTYPE: WITNESS_ELEMENT */
void towire_witness_element(u8 **p, const struct witness_element *witness_element)
{
u16 len = tal_count(witness_element->witness);
towire_u16(p, len);
towire_u8_array(p, witness_element->witness, len);
}
struct witness_element *
fromwire_witness_element(const tal_t *ctx, const u8 **cursor, size_t *plen)
{
struct witness_element *witness_element = tal(ctx, struct witness_element);
u16 len;
len = fromwire_u16(cursor, plen);
witness_element->witness = len ? tal_arr(witness_element, u8, len) : NULL;
fromwire_u8_array(cursor, plen, witness_element->witness, len);
return witness_element;
}
/* SUBTYPE: CHANNEL_UPDATE_CHECKSUMS */
void towire_channel_update_checksums(u8 **p, const struct channel_update_checksums *channel_update_checksums)
{
@@ -125,6 +166,32 @@ void fromwire_channel_update_timestamps(const u8 **cursor, size_t *plen, struct
channel_update_timestamps->timestamp_node_id_2 = fromwire_u32(cursor, plen);
}
/* SUBTYPE: WITNESS_STACK */
void towire_witness_stack(u8 **p, const struct witness_stack *witness_stack)
{
u16 num_input_witness = tal_count(witness_stack->witness_element);
towire_u16(p, num_input_witness);
for (size_t i = 0; i < num_input_witness; i++)
towire_witness_element(p, witness_stack->witness_element[i]);
}
struct witness_stack *
fromwire_witness_stack(const tal_t *ctx, const u8 **cursor, size_t *plen)
{
struct witness_stack *witness_stack = tal(ctx, struct witness_stack);
u16 num_input_witness;
num_input_witness = fromwire_u16(cursor, plen);
witness_stack->witness_element = num_input_witness ? tal_arr(witness_stack, struct witness_element *, 0) : NULL;
for (size_t i = 0; i < num_input_witness; i++) {
struct witness_element * tmp;
tmp = fromwire_witness_element(witness_stack, cursor, plen);
tal_arr_expand(&witness_stack->witness_element, tmp);
}
return witness_stack;
}
struct tlv_init_tlvs *tlv_init_tlvs_new(const tal_t *ctx)
{
@@ -504,6 +571,126 @@ bool accept_channel_tlvs_is_valid(const struct tlv_accept_channel_tlvs *record,
}
struct tlv_opening_tlvs *tlv_opening_tlvs_new(const tal_t *ctx)
{
/* Initialize everything to NULL. (Quiet, C pedants!) */
struct tlv_opening_tlvs *inst = talz(ctx, struct tlv_opening_tlvs);
/* Initialized the fields to an empty array. */
inst->fields = tal_arr(inst, struct tlv_field, 0);
return inst;
}
/* OPENING_TLVS MSG: option_upfront_shutdown_script */
static u8 *towire_tlv_opening_tlvs_option_upfront_shutdown_script(const tal_t *ctx, const void *vrecord)
{
const struct tlv_opening_tlvs *r = vrecord;
u8 *ptr;
if (!r->option_upfront_shutdown_script)
return NULL;
u16 shutdown_len = tal_count(r->option_upfront_shutdown_script->shutdown_scriptpubkey);
ptr = tal_arr(ctx, u8, 0);
towire_u16(&ptr, shutdown_len);
towire_u8_array(&ptr, r->option_upfront_shutdown_script->shutdown_scriptpubkey, shutdown_len);
return ptr;
}
static void fromwire_tlv_opening_tlvs_option_upfront_shutdown_script(const u8 **cursor, size_t *plen, void *vrecord)
{
struct tlv_opening_tlvs *r = vrecord;
u16 shutdown_len;
r->option_upfront_shutdown_script = tal(r, struct tlv_opening_tlvs_option_upfront_shutdown_script);
shutdown_len = fromwire_u16(cursor, plen);
r->option_upfront_shutdown_script->shutdown_scriptpubkey = shutdown_len ? tal_arr(r->option_upfront_shutdown_script, u8, shutdown_len) : NULL;
fromwire_u8_array(cursor, plen, r->option_upfront_shutdown_script->shutdown_scriptpubkey, shutdown_len);
}
static const struct tlv_record_type tlvs_opening_tlvs[] = {
{ 1, towire_tlv_opening_tlvs_option_upfront_shutdown_script, fromwire_tlv_opening_tlvs_option_upfront_shutdown_script },
};
void towire_opening_tlvs(u8 **pptr, const struct tlv_opening_tlvs *record)
{
towire_tlv(pptr, tlvs_opening_tlvs, 1, record);
}
bool fromwire_opening_tlvs(const u8 **cursor, size_t *max, struct tlv_opening_tlvs *record)
{
return fromwire_tlv(cursor, max, tlvs_opening_tlvs, 1, record, &record->fields);
}
bool opening_tlvs_is_valid(const struct tlv_opening_tlvs *record, size_t *err_index)
{
return tlv_fields_valid(record->fields, err_index);
}
struct tlv_accept_tlvs *tlv_accept_tlvs_new(const tal_t *ctx)
{
/* Initialize everything to NULL. (Quiet, C pedants!) */
struct tlv_accept_tlvs *inst = talz(ctx, struct tlv_accept_tlvs);
/* Initialized the fields to an empty array. */
inst->fields = tal_arr(inst, struct tlv_field, 0);
return inst;
}
/* ACCEPT_TLVS MSG: option_upfront_shutdown_script */
static u8 *towire_tlv_accept_tlvs_option_upfront_shutdown_script(const tal_t *ctx, const void *vrecord)
{
const struct tlv_accept_tlvs *r = vrecord;
u8 *ptr;
if (!r->option_upfront_shutdown_script)
return NULL;
u16 shutdown_len = tal_count(r->option_upfront_shutdown_script->shutdown_scriptpubkey);
ptr = tal_arr(ctx, u8, 0);
towire_u16(&ptr, shutdown_len);
towire_u8_array(&ptr, r->option_upfront_shutdown_script->shutdown_scriptpubkey, shutdown_len);
return ptr;
}
static void fromwire_tlv_accept_tlvs_option_upfront_shutdown_script(const u8 **cursor, size_t *plen, void *vrecord)
{
struct tlv_accept_tlvs *r = vrecord;
u16 shutdown_len;
r->option_upfront_shutdown_script = tal(r, struct tlv_accept_tlvs_option_upfront_shutdown_script);
shutdown_len = fromwire_u16(cursor, plen);
r->option_upfront_shutdown_script->shutdown_scriptpubkey = shutdown_len ? tal_arr(r->option_upfront_shutdown_script, u8, shutdown_len) : NULL;
fromwire_u8_array(cursor, plen, r->option_upfront_shutdown_script->shutdown_scriptpubkey, shutdown_len);
}
static const struct tlv_record_type tlvs_accept_tlvs[] = {
{ 1, towire_tlv_accept_tlvs_option_upfront_shutdown_script, fromwire_tlv_accept_tlvs_option_upfront_shutdown_script },
};
void towire_accept_tlvs(u8 **pptr, const struct tlv_accept_tlvs *record)
{
towire_tlv(pptr, tlvs_accept_tlvs, 1, record);
}
bool fromwire_accept_tlvs(const u8 **cursor, size_t *max, struct tlv_accept_tlvs *record)
{
return fromwire_tlv(cursor, max, tlvs_accept_tlvs, 1, record, &record->fields);
}
bool accept_tlvs_is_valid(const struct tlv_accept_tlvs *record, size_t *err_index)
{
return tlv_fields_valid(record->fields, err_index);
}
struct tlv_shutdown_tlvs *tlv_shutdown_tlvs_new(const tal_t *ctx)
{
/* Initialize everything to NULL. (Quiet, C pedants!) */
@@ -971,6 +1158,185 @@ bool fromwire_pong(const tal_t *ctx, const void *p, u8 **ignored)
return cursor != NULL;
}
/* WIRE: TX_ADD_INPUT */
u8 *towire_tx_add_input(const tal_t *ctx, const struct channel_id *channel_id, u64 serial_id, const u8 *prevtx, u32 prevtx_vout, u32 sequence, const u8 *script_sig)
{
u16 prevtx_len = tal_count(prevtx);
u16 script_sig_len = tal_count(script_sig);
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_TX_ADD_INPUT);
towire_channel_id(&p, channel_id);
towire_u64(&p, serial_id);
towire_u16(&p, prevtx_len);
towire_u8_array(&p, prevtx, prevtx_len);
towire_u32(&p, prevtx_vout);
towire_u32(&p, sequence);
towire_u16(&p, script_sig_len);
towire_u8_array(&p, script_sig, script_sig_len);
return memcheck(p, tal_count(p));
}
bool fromwire_tx_add_input(const tal_t *ctx, const void *p, struct channel_id *channel_id, u64 *serial_id, u8 **prevtx, u32 *prevtx_vout, u32 *sequence, u8 **script_sig)
{
u16 prevtx_len;
u16 script_sig_len;
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_TX_ADD_INPUT)
return false;
fromwire_channel_id(&cursor, &plen, channel_id);
*serial_id = fromwire_u64(&cursor, &plen);
prevtx_len = fromwire_u16(&cursor, &plen);
// 2nd case prevtx
*prevtx = prevtx_len ? tal_arr(ctx, u8, prevtx_len) : NULL;
fromwire_u8_array(&cursor, &plen, *prevtx, prevtx_len);
*prevtx_vout = fromwire_u32(&cursor, &plen);
*sequence = fromwire_u32(&cursor, &plen);
script_sig_len = fromwire_u16(&cursor, &plen);
// 2nd case script_sig
*script_sig = script_sig_len ? tal_arr(ctx, u8, script_sig_len) : NULL;
fromwire_u8_array(&cursor, &plen, *script_sig, script_sig_len);
return cursor != NULL;
}
/* WIRE: TX_ADD_OUTPUT */
u8 *towire_tx_add_output(const tal_t *ctx, const struct channel_id *channel_id, u64 serial_id, u64 sats, const u8 *script)
{
u16 scriptlen = tal_count(script);
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_TX_ADD_OUTPUT);
towire_channel_id(&p, channel_id);
towire_u64(&p, serial_id);
towire_u64(&p, sats);
towire_u16(&p, scriptlen);
towire_u8_array(&p, script, scriptlen);
return memcheck(p, tal_count(p));
}
bool fromwire_tx_add_output(const tal_t *ctx, const void *p, struct channel_id *channel_id, u64 *serial_id, u64 *sats, u8 **script)
{
u16 scriptlen;
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_TX_ADD_OUTPUT)
return false;
fromwire_channel_id(&cursor, &plen, channel_id);
*serial_id = fromwire_u64(&cursor, &plen);
*sats = fromwire_u64(&cursor, &plen);
scriptlen = fromwire_u16(&cursor, &plen);
// 2nd case script
*script = scriptlen ? tal_arr(ctx, u8, scriptlen) : NULL;
fromwire_u8_array(&cursor, &plen, *script, scriptlen);
return cursor != NULL;
}
/* WIRE: TX_REMOVE_INPUT */
u8 *towire_tx_remove_input(const tal_t *ctx, const struct channel_id *channel_id, u64 serial_id)
{
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_TX_REMOVE_INPUT);
towire_channel_id(&p, channel_id);
towire_u64(&p, serial_id);
return memcheck(p, tal_count(p));
}
bool fromwire_tx_remove_input(const void *p, struct channel_id *channel_id, u64 *serial_id)
{
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_TX_REMOVE_INPUT)
return false;
fromwire_channel_id(&cursor, &plen, channel_id);
*serial_id = fromwire_u64(&cursor, &plen);
return cursor != NULL;
}
/* WIRE: TX_REMOVE_OUTPUT */
u8 *towire_tx_remove_output(const tal_t *ctx, const struct channel_id *channel_id, u64 serial_id)
{
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_TX_REMOVE_OUTPUT);
towire_channel_id(&p, channel_id);
towire_u64(&p, serial_id);
return memcheck(p, tal_count(p));
}
bool fromwire_tx_remove_output(const void *p, struct channel_id *channel_id, u64 *serial_id)
{
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_TX_REMOVE_OUTPUT)
return false;
fromwire_channel_id(&cursor, &plen, channel_id);
*serial_id = fromwire_u64(&cursor, &plen);
return cursor != NULL;
}
/* WIRE: TX_COMPLETE */
u8 *towire_tx_complete(const tal_t *ctx, const struct channel_id *channel_id)
{
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_TX_COMPLETE);
towire_channel_id(&p, channel_id);
return memcheck(p, tal_count(p));
}
bool fromwire_tx_complete(const void *p, struct channel_id *channel_id)
{
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_TX_COMPLETE)
return false;
fromwire_channel_id(&cursor, &plen, channel_id);
return cursor != NULL;
}
/* WIRE: TX_SIGNATURES */
u8 *towire_tx_signatures(const tal_t *ctx, const struct channel_id *channel_id, const struct bitcoin_txid *txid, const struct witness_stack **witness_stack)
{
u16 num_witnesses = tal_count(witness_stack);
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_TX_SIGNATURES);
towire_channel_id(&p, channel_id);
towire_bitcoin_txid(&p, txid);
towire_u16(&p, num_witnesses);
for (size_t i = 0; i < num_witnesses; i++)
towire_witness_stack(&p, witness_stack[i]);
return memcheck(p, tal_count(p));
}
bool fromwire_tx_signatures(const tal_t *ctx, const void *p, struct channel_id *channel_id, struct bitcoin_txid *txid, struct witness_stack ***witness_stack)
{
u16 num_witnesses;
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_TX_SIGNATURES)
return false;
fromwire_channel_id(&cursor, &plen, channel_id);
fromwire_bitcoin_txid(&cursor, &plen, txid);
num_witnesses = fromwire_u16(&cursor, &plen);
// 2nd case witness_stack
*witness_stack = num_witnesses ? tal_arr(ctx, struct witness_stack *, num_witnesses) : NULL;
for (size_t i = 0; i < num_witnesses; i++)
(*witness_stack)[i] = fromwire_witness_stack(*witness_stack, &cursor, &plen);
return cursor != NULL;
}
/* WIRE: OPEN_CHANNEL */
u8 *towire_open_channel(const tal_t *ctx, const struct bitcoin_blkid *chain_hash, const struct channel_id *temporary_channel_id, struct amount_sat funding_satoshis, struct amount_msat push_msat, struct amount_sat dust_limit_satoshis, struct amount_msat max_htlc_value_in_flight_msat, struct amount_sat channel_reserve_satoshis, struct amount_msat htlc_minimum_msat, u32 feerate_per_kw, u16 to_self_delay, u16 max_accepted_htlcs, const struct pubkey *funding_pubkey, const struct pubkey *revocation_basepoint, const struct pubkey *payment_basepoint, const struct pubkey *delayed_payment_basepoint, const struct pubkey *htlc_basepoint, const struct pubkey *first_per_commitment_point, u8 channel_flags, const struct tlv_open_channel_tlvs *tlvs)
{
@@ -1150,6 +1516,162 @@ bool fromwire_funding_locked(const void *p, struct channel_id *channel_id, struc
return cursor != NULL;
}
/* WIRE: OPEN_CHANNEL2 */
u8 *towire_open_channel2(const tal_t *ctx, const struct bitcoin_blkid *chain_hash, const struct channel_id *channel_id, u32 funding_feerate_perkw, u32 commitment_feerate_perkw, struct amount_sat funding_satoshis, struct amount_sat dust_limit_satoshis, struct amount_msat max_htlc_value_in_flight_msat, struct amount_msat htlc_minimum_msat, u16 to_self_delay, u16 max_accepted_htlcs, u32 locktime, const struct pubkey *funding_pubkey, const struct pubkey *revocation_basepoint, const struct pubkey *payment_basepoint, const struct pubkey *delayed_payment_basepoint, const struct pubkey *htlc_basepoint, const struct pubkey *first_per_commitment_point, u8 channel_flags, const struct tlv_opening_tlvs *tlvs)
{
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_OPEN_CHANNEL2);
towire_bitcoin_blkid(&p, chain_hash);
towire_channel_id(&p, channel_id);
towire_u32(&p, funding_feerate_perkw);
towire_u32(&p, commitment_feerate_perkw);
towire_amount_sat(&p, funding_satoshis);
towire_amount_sat(&p, dust_limit_satoshis);
towire_amount_msat(&p, max_htlc_value_in_flight_msat);
towire_amount_msat(&p, htlc_minimum_msat);
towire_u16(&p, to_self_delay);
towire_u16(&p, max_accepted_htlcs);
towire_u32(&p, locktime);
towire_pubkey(&p, funding_pubkey);
towire_pubkey(&p, revocation_basepoint);
towire_pubkey(&p, payment_basepoint);
towire_pubkey(&p, delayed_payment_basepoint);
towire_pubkey(&p, htlc_basepoint);
towire_pubkey(&p, first_per_commitment_point);
towire_u8(&p, channel_flags);
towire_opening_tlvs(&p, tlvs);
return memcheck(p, tal_count(p));
}
bool fromwire_open_channel2(const void *p, struct bitcoin_blkid *chain_hash, struct channel_id *channel_id, u32 *funding_feerate_perkw, u32 *commitment_feerate_perkw, struct amount_sat *funding_satoshis, struct amount_sat *dust_limit_satoshis, struct amount_msat *max_htlc_value_in_flight_msat, struct amount_msat *htlc_minimum_msat, u16 *to_self_delay, u16 *max_accepted_htlcs, u32 *locktime, struct pubkey *funding_pubkey, struct pubkey *revocation_basepoint, struct pubkey *payment_basepoint, struct pubkey *delayed_payment_basepoint, struct pubkey *htlc_basepoint, struct pubkey *first_per_commitment_point, u8 *channel_flags, struct tlv_opening_tlvs *tlvs)
{
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_OPEN_CHANNEL2)
return false;
fromwire_bitcoin_blkid(&cursor, &plen, chain_hash);
fromwire_channel_id(&cursor, &plen, channel_id);
*funding_feerate_perkw = fromwire_u32(&cursor, &plen);
*commitment_feerate_perkw = fromwire_u32(&cursor, &plen);
*funding_satoshis = fromwire_amount_sat(&cursor, &plen);
*dust_limit_satoshis = fromwire_amount_sat(&cursor, &plen);
*max_htlc_value_in_flight_msat = fromwire_amount_msat(&cursor, &plen);
*htlc_minimum_msat = fromwire_amount_msat(&cursor, &plen);
*to_self_delay = fromwire_u16(&cursor, &plen);
*max_accepted_htlcs = fromwire_u16(&cursor, &plen);
*locktime = fromwire_u32(&cursor, &plen);
fromwire_pubkey(&cursor, &plen, funding_pubkey);
fromwire_pubkey(&cursor, &plen, revocation_basepoint);
fromwire_pubkey(&cursor, &plen, payment_basepoint);
fromwire_pubkey(&cursor, &plen, delayed_payment_basepoint);
fromwire_pubkey(&cursor, &plen, htlc_basepoint);
fromwire_pubkey(&cursor, &plen, first_per_commitment_point);
*channel_flags = fromwire_u8(&cursor, &plen);
fromwire_opening_tlvs(&cursor, &plen, tlvs);
return cursor != NULL;
}
/* WIRE: ACCEPT_CHANNEL2 */
u8 *towire_accept_channel2(const tal_t *ctx, const struct channel_id *channel_id, struct amount_sat funding_satoshis, struct amount_sat dust_limit_satoshis, struct amount_msat max_htlc_value_in_flight_msat, struct amount_msat htlc_minimum_msat, u32 minimum_depth, u16 to_self_delay, u16 max_accepted_htlcs, const struct pubkey *funding_pubkey, const struct pubkey *revocation_basepoint, const struct pubkey *payment_basepoint, const struct pubkey *delayed_payment_basepoint, const struct pubkey *htlc_basepoint, const struct pubkey *first_per_commitment_point, const struct tlv_accept_tlvs *tlvs)
{
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_ACCEPT_CHANNEL2);
towire_channel_id(&p, channel_id);
towire_amount_sat(&p, funding_satoshis);
towire_amount_sat(&p, dust_limit_satoshis);
towire_amount_msat(&p, max_htlc_value_in_flight_msat);
towire_amount_msat(&p, htlc_minimum_msat);
towire_u32(&p, minimum_depth);
towire_u16(&p, to_self_delay);
towire_u16(&p, max_accepted_htlcs);
towire_pubkey(&p, funding_pubkey);
towire_pubkey(&p, revocation_basepoint);
towire_pubkey(&p, payment_basepoint);
towire_pubkey(&p, delayed_payment_basepoint);
towire_pubkey(&p, htlc_basepoint);
towire_pubkey(&p, first_per_commitment_point);
towire_accept_tlvs(&p, tlvs);
return memcheck(p, tal_count(p));
}
bool fromwire_accept_channel2(const void *p, struct channel_id *channel_id, struct amount_sat *funding_satoshis, struct amount_sat *dust_limit_satoshis, struct amount_msat *max_htlc_value_in_flight_msat, struct amount_msat *htlc_minimum_msat, u32 *minimum_depth, u16 *to_self_delay, u16 *max_accepted_htlcs, struct pubkey *funding_pubkey, struct pubkey *revocation_basepoint, struct pubkey *payment_basepoint, struct pubkey *delayed_payment_basepoint, struct pubkey *htlc_basepoint, struct pubkey *first_per_commitment_point, struct tlv_accept_tlvs *tlvs)
{
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_ACCEPT_CHANNEL2)
return false;
fromwire_channel_id(&cursor, &plen, channel_id);
*funding_satoshis = fromwire_amount_sat(&cursor, &plen);
*dust_limit_satoshis = fromwire_amount_sat(&cursor, &plen);
*max_htlc_value_in_flight_msat = fromwire_amount_msat(&cursor, &plen);
*htlc_minimum_msat = fromwire_amount_msat(&cursor, &plen);
*minimum_depth = fromwire_u32(&cursor, &plen);
*to_self_delay = fromwire_u16(&cursor, &plen);
*max_accepted_htlcs = fromwire_u16(&cursor, &plen);
fromwire_pubkey(&cursor, &plen, funding_pubkey);
fromwire_pubkey(&cursor, &plen, revocation_basepoint);
fromwire_pubkey(&cursor, &plen, payment_basepoint);
fromwire_pubkey(&cursor, &plen, delayed_payment_basepoint);
fromwire_pubkey(&cursor, &plen, htlc_basepoint);
fromwire_pubkey(&cursor, &plen, first_per_commitment_point);
fromwire_accept_tlvs(&cursor, &plen, tlvs);
return cursor != NULL;
}
/* WIRE: INIT_RBF */
u8 *towire_init_rbf(const tal_t *ctx, const struct channel_id *channel_id, struct amount_sat funding_satoshis, u32 locktime, u8 fee_step)
{
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_INIT_RBF);
towire_channel_id(&p, channel_id);
towire_amount_sat(&p, funding_satoshis);
towire_u32(&p, locktime);
towire_u8(&p, fee_step);
return memcheck(p, tal_count(p));
}
bool fromwire_init_rbf(const void *p, struct channel_id *channel_id, struct amount_sat *funding_satoshis, u32 *locktime, u8 *fee_step)
{
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_INIT_RBF)
return false;
fromwire_channel_id(&cursor, &plen, channel_id);
*funding_satoshis = fromwire_amount_sat(&cursor, &plen);
*locktime = fromwire_u32(&cursor, &plen);
*fee_step = fromwire_u8(&cursor, &plen);
return cursor != NULL;
}
/* WIRE: ACK_RBF */
u8 *towire_ack_rbf(const tal_t *ctx, const struct channel_id *channel_id, struct amount_sat funding_satoshis)
{
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_ACK_RBF);
towire_channel_id(&p, channel_id);
towire_amount_sat(&p, funding_satoshis);
return memcheck(p, tal_count(p));
}
bool fromwire_ack_rbf(const void *p, struct channel_id *channel_id, struct amount_sat *funding_satoshis)
{
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_ACK_RBF)
return false;
fromwire_channel_id(&cursor, &plen, channel_id);
*funding_satoshis = fromwire_amount_sat(&cursor, &plen);
return cursor != NULL;
}
/* WIRE: SHUTDOWN */
u8 *towire_shutdown(const tal_t *ctx, const struct channel_id *channel_id, const u8 *scriptpubkey, const struct tlv_shutdown_tlvs *tlvs)
{
@@ -1808,4 +2330,4 @@ bool fromwire_channel_update_option_channel_htlc_max(const void *p, secp256k1_ec
*htlc_maximum_msat = fromwire_amount_msat(&cursor, &plen);
return cursor != NULL;
}
// SHA256STAMP:c7056cc0ec6b038e425e0800dce339f6ba38a18f14d1b33271656de218052ee2
// SHA256STAMP:650e49e75f12d335a4fc1a0ca7fd8231f8f50b605c0fb5c0b4ba085125c7d457

162
wire/peer_wiregen.h generated
View File

@@ -22,11 +22,21 @@ enum peer_wire {
WIRE_WARNING = 1,
WIRE_PING = 18,
WIRE_PONG = 19,
WIRE_TX_ADD_INPUT = 66,
WIRE_TX_ADD_OUTPUT = 67,
WIRE_TX_REMOVE_INPUT = 68,
WIRE_TX_REMOVE_OUTPUT = 69,
WIRE_TX_COMPLETE = 70,
WIRE_TX_SIGNATURES = 71,
WIRE_OPEN_CHANNEL = 32,
WIRE_ACCEPT_CHANNEL = 33,
WIRE_FUNDING_CREATED = 34,
WIRE_FUNDING_SIGNED = 35,
WIRE_FUNDING_LOCKED = 36,
WIRE_OPEN_CHANNEL2 = 64,
WIRE_ACCEPT_CHANNEL2 = 65,
WIRE_INIT_RBF = 72,
WIRE_ACK_RBF = 73,
WIRE_SHUTDOWN = 38,
WIRE_CLOSING_SIGNED = 39,
WIRE_UPDATE_ADD_HTLC = 128,
@@ -60,6 +70,9 @@ const char *peer_wire_name(int e);
*/
bool peer_wire_is_defined(u16 type);
struct witness_element {
u8 *witness;
};
struct channel_update_checksums {
u32 checksum_node_id_1;
u32 checksum_node_id_2;
@@ -68,11 +81,20 @@ struct channel_update_timestamps {
u32 timestamp_node_id_1;
u32 timestamp_node_id_2;
};
struct witness_stack {
struct witness_element **witness_element;
};
struct tlv_n1_tlv3 {
struct pubkey node_id;
struct amount_msat amount_msat_1;
struct amount_msat amount_msat_2;
};
struct tlv_opening_tlvs_option_upfront_shutdown_script {
u8 *shutdown_scriptpubkey;
};
struct tlv_accept_tlvs_option_upfront_shutdown_script {
u8 *shutdown_scriptpubkey;
};
struct tlv_shutdown_tlvs_wrong_funding {
struct bitcoin_txid txid;
u32 outnum;
@@ -129,6 +151,22 @@ struct tlv_accept_channel_tlvs {
* tlv_field entries above to save on memory. */
u8 *upfront_shutdown_script;
};
struct tlv_opening_tlvs {
/* Raw fields including unknown ones. */
struct tlv_field *fields;
/* TODO The following explicit fields could just point into the
* tlv_field entries above to save on memory. */
struct tlv_opening_tlvs_option_upfront_shutdown_script *option_upfront_shutdown_script;
};
struct tlv_accept_tlvs {
/* Raw fields including unknown ones. */
struct tlv_field *fields;
/* TODO The following explicit fields could just point into the
* tlv_field entries above to save on memory. */
struct tlv_accept_tlvs_option_upfront_shutdown_script *option_upfront_shutdown_script;
};
struct tlv_shutdown_tlvs {
/* Raw fields including unknown ones. */
struct tlv_field *fields;
@@ -380,6 +418,80 @@ void towire_accept_channel_tlvs(u8 **pptr, const struct tlv_accept_channel_tlvs
bool accept_channel_tlvs_is_valid(const struct tlv_accept_channel_tlvs *record,
size_t *err_index);
struct tlv_opening_tlvs *tlv_opening_tlvs_new(const tal_t *ctx);
/**
* Deserialize a TLV stream for the opening_tlvs namespace.
*
* This function will parse any TLV stream, as long as the type, length and
* value fields are formatted correctly. Fields that are not known in the
* current namespace are stored in the `fields` member. Validity can be
* checked using opening_tlvs_is_valid.
*/
bool fromwire_opening_tlvs(const u8 **cursor, size_t *max,
struct tlv_opening_tlvs * record);
/**
* Serialize a TLV stream for the opening_tlvs namespace.
*
* This function only considers known fields from the opening_tlvs namespace,
* and will ignore any fields that may be stored in the `fields` member. This
* ensures that the resulting stream is valid according to
* `opening_tlvs_is_valid`.
*/
void towire_opening_tlvs(u8 **pptr, const struct tlv_opening_tlvs *record);
/**
* Check that the TLV stream is valid.
*
* Enforces the followin validity rules:
* - Types must be in monotonic non-repeating order
* - We must understand all even types
*
* Returns false if an error was detected, otherwise returns true. If err_index
* is non-null and we detect an error it is set to the index of the first error
* detected.
*/
bool opening_tlvs_is_valid(const struct tlv_opening_tlvs *record,
size_t *err_index);
struct tlv_accept_tlvs *tlv_accept_tlvs_new(const tal_t *ctx);
/**
* Deserialize a TLV stream for the accept_tlvs namespace.
*
* This function will parse any TLV stream, as long as the type, length and
* value fields are formatted correctly. Fields that are not known in the
* current namespace are stored in the `fields` member. Validity can be
* checked using accept_tlvs_is_valid.
*/
bool fromwire_accept_tlvs(const u8 **cursor, size_t *max,
struct tlv_accept_tlvs * record);
/**
* Serialize a TLV stream for the accept_tlvs namespace.
*
* This function only considers known fields from the accept_tlvs namespace,
* and will ignore any fields that may be stored in the `fields` member. This
* ensures that the resulting stream is valid according to
* `accept_tlvs_is_valid`.
*/
void towire_accept_tlvs(u8 **pptr, const struct tlv_accept_tlvs *record);
/**
* Check that the TLV stream is valid.
*
* Enforces the followin validity rules:
* - Types must be in monotonic non-repeating order
* - We must understand all even types
*
* Returns false if an error was detected, otherwise returns true. If err_index
* is non-null and we detect an error it is set to the index of the first error
* detected.
*/
bool accept_tlvs_is_valid(const struct tlv_accept_tlvs *record,
size_t *err_index);
struct tlv_shutdown_tlvs *tlv_shutdown_tlvs_new(const tal_t *ctx);
/**
@@ -565,6 +677,10 @@ void towire_onion_message_tlvs(u8 **pptr, const struct tlv_onion_message_tlvs *r
bool onion_message_tlvs_is_valid(const struct tlv_onion_message_tlvs *record,
size_t *err_index);
/* SUBTYPE: WITNESS_ELEMENT */
void towire_witness_element(u8 **p, const struct witness_element *witness_element);
struct witness_element *fromwire_witness_element(const tal_t *ctx, const u8 **cursor, size_t *plen);
/* SUBTYPE: CHANNEL_UPDATE_CHECKSUMS */
void towire_channel_update_checksums(u8 **p, const struct channel_update_checksums *channel_update_checksums);
void fromwire_channel_update_checksums(const u8 **cursor, size_t *plen, struct channel_update_checksums *channel_update_checksums);
@@ -573,6 +689,10 @@ void fromwire_channel_update_checksums(const u8 **cursor, size_t *plen, struct c
void towire_channel_update_timestamps(u8 **p, const struct channel_update_timestamps *channel_update_timestamps);
void fromwire_channel_update_timestamps(const u8 **cursor, size_t *plen, struct channel_update_timestamps *channel_update_timestamps);
/* SUBTYPE: WITNESS_STACK */
void towire_witness_stack(u8 **p, const struct witness_stack *witness_stack);
struct witness_stack *fromwire_witness_stack(const tal_t *ctx, const u8 **cursor, size_t *plen);
/* WIRE: INIT */
u8 *towire_init(const tal_t *ctx, const u8 *globalfeatures, const u8 *features, const struct tlv_init_tlvs *tlvs);
bool fromwire_init(const tal_t *ctx, const void *p, u8 **globalfeatures, u8 **features, struct tlv_init_tlvs *tlvs);
@@ -593,6 +713,30 @@ bool fromwire_ping(const tal_t *ctx, const void *p, u16 *num_pong_bytes, u8 **ig
u8 *towire_pong(const tal_t *ctx, const u8 *ignored);
bool fromwire_pong(const tal_t *ctx, const void *p, u8 **ignored);
/* WIRE: TX_ADD_INPUT */
u8 *towire_tx_add_input(const tal_t *ctx, const struct channel_id *channel_id, u64 serial_id, const u8 *prevtx, u32 prevtx_vout, u32 sequence, const u8 *script_sig);
bool fromwire_tx_add_input(const tal_t *ctx, const void *p, struct channel_id *channel_id, u64 *serial_id, u8 **prevtx, u32 *prevtx_vout, u32 *sequence, u8 **script_sig);
/* WIRE: TX_ADD_OUTPUT */
u8 *towire_tx_add_output(const tal_t *ctx, const struct channel_id *channel_id, u64 serial_id, u64 sats, const u8 *script);
bool fromwire_tx_add_output(const tal_t *ctx, const void *p, struct channel_id *channel_id, u64 *serial_id, u64 *sats, u8 **script);
/* WIRE: TX_REMOVE_INPUT */
u8 *towire_tx_remove_input(const tal_t *ctx, const struct channel_id *channel_id, u64 serial_id);
bool fromwire_tx_remove_input(const void *p, struct channel_id *channel_id, u64 *serial_id);
/* WIRE: TX_REMOVE_OUTPUT */
u8 *towire_tx_remove_output(const tal_t *ctx, const struct channel_id *channel_id, u64 serial_id);
bool fromwire_tx_remove_output(const void *p, struct channel_id *channel_id, u64 *serial_id);
/* WIRE: TX_COMPLETE */
u8 *towire_tx_complete(const tal_t *ctx, const struct channel_id *channel_id);
bool fromwire_tx_complete(const void *p, struct channel_id *channel_id);
/* WIRE: TX_SIGNATURES */
u8 *towire_tx_signatures(const tal_t *ctx, const struct channel_id *channel_id, const struct bitcoin_txid *txid, const struct witness_stack **witness_stack);
bool fromwire_tx_signatures(const tal_t *ctx, const void *p, struct channel_id *channel_id, struct bitcoin_txid *txid, struct witness_stack ***witness_stack);
/* WIRE: OPEN_CHANNEL */
u8 *towire_open_channel(const tal_t *ctx, const struct bitcoin_blkid *chain_hash, const struct channel_id *temporary_channel_id, struct amount_sat funding_satoshis, struct amount_msat push_msat, struct amount_sat dust_limit_satoshis, struct amount_msat max_htlc_value_in_flight_msat, struct amount_sat channel_reserve_satoshis, struct amount_msat htlc_minimum_msat, u32 feerate_per_kw, u16 to_self_delay, u16 max_accepted_htlcs, const struct pubkey *funding_pubkey, const struct pubkey *revocation_basepoint, const struct pubkey *payment_basepoint, const struct pubkey *delayed_payment_basepoint, const struct pubkey *htlc_basepoint, const struct pubkey *first_per_commitment_point, u8 channel_flags, const struct tlv_open_channel_tlvs *tlvs);
bool fromwire_open_channel(const void *p, struct bitcoin_blkid *chain_hash, struct channel_id *temporary_channel_id, struct amount_sat *funding_satoshis, struct amount_msat *push_msat, struct amount_sat *dust_limit_satoshis, struct amount_msat *max_htlc_value_in_flight_msat, struct amount_sat *channel_reserve_satoshis, struct amount_msat *htlc_minimum_msat, u32 *feerate_per_kw, u16 *to_self_delay, u16 *max_accepted_htlcs, struct pubkey *funding_pubkey, struct pubkey *revocation_basepoint, struct pubkey *payment_basepoint, struct pubkey *delayed_payment_basepoint, struct pubkey *htlc_basepoint, struct pubkey *first_per_commitment_point, u8 *channel_flags, struct tlv_open_channel_tlvs *tlvs);
@@ -613,6 +757,22 @@ bool fromwire_funding_signed(const void *p, struct channel_id *channel_id, secp2
u8 *towire_funding_locked(const tal_t *ctx, const struct channel_id *channel_id, const struct pubkey *next_per_commitment_point);
bool fromwire_funding_locked(const void *p, struct channel_id *channel_id, struct pubkey *next_per_commitment_point);
/* WIRE: OPEN_CHANNEL2 */
u8 *towire_open_channel2(const tal_t *ctx, const struct bitcoin_blkid *chain_hash, const struct channel_id *channel_id, u32 funding_feerate_perkw, u32 commitment_feerate_perkw, struct amount_sat funding_satoshis, struct amount_sat dust_limit_satoshis, struct amount_msat max_htlc_value_in_flight_msat, struct amount_msat htlc_minimum_msat, u16 to_self_delay, u16 max_accepted_htlcs, u32 locktime, const struct pubkey *funding_pubkey, const struct pubkey *revocation_basepoint, const struct pubkey *payment_basepoint, const struct pubkey *delayed_payment_basepoint, const struct pubkey *htlc_basepoint, const struct pubkey *first_per_commitment_point, u8 channel_flags, const struct tlv_opening_tlvs *tlvs);
bool fromwire_open_channel2(const void *p, struct bitcoin_blkid *chain_hash, struct channel_id *channel_id, u32 *funding_feerate_perkw, u32 *commitment_feerate_perkw, struct amount_sat *funding_satoshis, struct amount_sat *dust_limit_satoshis, struct amount_msat *max_htlc_value_in_flight_msat, struct amount_msat *htlc_minimum_msat, u16 *to_self_delay, u16 *max_accepted_htlcs, u32 *locktime, struct pubkey *funding_pubkey, struct pubkey *revocation_basepoint, struct pubkey *payment_basepoint, struct pubkey *delayed_payment_basepoint, struct pubkey *htlc_basepoint, struct pubkey *first_per_commitment_point, u8 *channel_flags, struct tlv_opening_tlvs *tlvs);
/* WIRE: ACCEPT_CHANNEL2 */
u8 *towire_accept_channel2(const tal_t *ctx, const struct channel_id *channel_id, struct amount_sat funding_satoshis, struct amount_sat dust_limit_satoshis, struct amount_msat max_htlc_value_in_flight_msat, struct amount_msat htlc_minimum_msat, u32 minimum_depth, u16 to_self_delay, u16 max_accepted_htlcs, const struct pubkey *funding_pubkey, const struct pubkey *revocation_basepoint, const struct pubkey *payment_basepoint, const struct pubkey *delayed_payment_basepoint, const struct pubkey *htlc_basepoint, const struct pubkey *first_per_commitment_point, const struct tlv_accept_tlvs *tlvs);
bool fromwire_accept_channel2(const void *p, struct channel_id *channel_id, struct amount_sat *funding_satoshis, struct amount_sat *dust_limit_satoshis, struct amount_msat *max_htlc_value_in_flight_msat, struct amount_msat *htlc_minimum_msat, u32 *minimum_depth, u16 *to_self_delay, u16 *max_accepted_htlcs, struct pubkey *funding_pubkey, struct pubkey *revocation_basepoint, struct pubkey *payment_basepoint, struct pubkey *delayed_payment_basepoint, struct pubkey *htlc_basepoint, struct pubkey *first_per_commitment_point, struct tlv_accept_tlvs *tlvs);
/* WIRE: INIT_RBF */
u8 *towire_init_rbf(const tal_t *ctx, const struct channel_id *channel_id, struct amount_sat funding_satoshis, u32 locktime, u8 fee_step);
bool fromwire_init_rbf(const void *p, struct channel_id *channel_id, struct amount_sat *funding_satoshis, u32 *locktime, u8 *fee_step);
/* WIRE: ACK_RBF */
u8 *towire_ack_rbf(const tal_t *ctx, const struct channel_id *channel_id, struct amount_sat funding_satoshis);
bool fromwire_ack_rbf(const void *p, struct channel_id *channel_id, struct amount_sat *funding_satoshis);
/* WIRE: SHUTDOWN */
u8 *towire_shutdown(const tal_t *ctx, const struct channel_id *channel_id, const u8 *scriptpubkey, const struct tlv_shutdown_tlvs *tlvs);
bool fromwire_shutdown(const tal_t *ctx, const void *p, struct channel_id *channel_id, u8 **scriptpubkey, struct tlv_shutdown_tlvs *tlvs);
@@ -699,4 +859,4 @@ bool fromwire_channel_update_option_channel_htlc_max(const void *p, secp256k1_ec
#endif /* LIGHTNING_WIRE_PEER_WIREGEN_H */
// SHA256STAMP:c7056cc0ec6b038e425e0800dce339f6ba38a18f14d1b33271656de218052ee2
// SHA256STAMP:650e49e75f12d335a4fc1a0ca7fd8231f8f50b605c0fb5c0b4ba085125c7d457