Browse Source

openingd: convert wire to new scheme.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
bump-pyln-proto
Rusty Russell 4 years ago
parent
commit
6d09c0eba9
  1. 58
      lightningd/opening_control.c
  2. 12
      openingd/Makefile
  3. 140
      openingd/opening_wire.csv
  4. 64
      openingd/openingd.c
  5. 140
      openingd/openingd_wire.csv

58
lightningd/opening_control.c

@ -32,7 +32,7 @@
#include <lightningd/options.h>
#include <lightningd/plugin_hook.h>
#include <lightningd/subd.h>
#include <openingd/gen_opening_wire.h>
#include <openingd/openingd_wiregen.h>
#include <string.h>
#include <wire/gen_common_wire.h>
#include <wire/wire.h>
@ -365,7 +365,7 @@ static void opening_funder_start_replied(struct subd *openingd, const u8 *resp,
u8 *funding_scriptPubkey;
bool supports_shutdown_script;
if (!fromwire_opening_funder_start_reply(resp, resp,
if (!fromwire_openingd_funder_start_reply(resp, resp,
&funding_scriptPubkey,
&supports_shutdown_script)) {
log_broken(fc->uc->log,
@ -414,7 +414,7 @@ static void opening_funder_finished(struct subd *openingd, const u8 *resp,
/* This is a new channel_info.their_config so set its ID to 0 */
channel_info.their_config.id = 0;
if (!fromwire_opening_funder_reply(resp, resp,
if (!fromwire_openingd_funder_reply(resp, resp,
&channel_info.their_config,
&remote_commit,
&pbase,
@ -511,7 +511,7 @@ static void opening_fundee_finished(struct subd *openingd,
/* This is a new channel_info.their_config, set its ID to 0 */
channel_info.their_config.id = 0;
if (!fromwire_opening_fundee(tmpctx, reply,
if (!fromwire_openingd_fundee(tmpctx, reply,
&channel_info.their_config,
&remote_commit,
&pbase,
@ -603,7 +603,7 @@ static void opening_funder_failed(struct subd *openingd, const u8 *msg,
{
char *desc;
if (!fromwire_opening_funder_failed(msg, msg, &desc)) {
if (!fromwire_openingd_funder_failed(msg, msg, &desc)) {
log_broken(uc->log,
"bad OPENING_FUNDER_FAILED %s",
tal_hex(tmpctx, msg));
@ -872,7 +872,7 @@ static void openchannel_hook_cb(struct openchannel_hook_payload *payload STEALS,
our_upfront_shutdown_script = NULL;
subd_send_msg(openingd,
take(towire_opening_got_offer_reply(NULL, errmsg,
take(towire_openingd_got_offer_reply(NULL, errmsg,
our_upfront_shutdown_script)));
}
@ -890,14 +890,14 @@ static void opening_got_offer(struct subd *openingd,
/* Tell them they can't open, if we already have open channel. */
if (peer_active_channel(uc->peer)) {
subd_send_msg(openingd,
take(towire_opening_got_offer_reply(NULL,
take(towire_openingd_got_offer_reply(NULL,
"Already have active channel", NULL)));
return;
}
payload = tal(openingd, struct openchannel_hook_payload);
payload->openingd = openingd;
if (!fromwire_opening_got_offer(payload, msg,
if (!fromwire_openingd_got_offer(payload, msg,
&payload->funding_satoshis,
&payload->push_msat,
&payload->dust_limit_satoshis,
@ -922,11 +922,11 @@ static void opening_got_offer(struct subd *openingd,
static unsigned int openingd_msg(struct subd *openingd,
const u8 *msg, const int *fds)
{
enum opening_wire_type t = fromwire_peektype(msg);
enum openingd_wire t = fromwire_peektype(msg);
struct uncommitted_channel *uc = openingd->channel;
switch (t) {
case WIRE_OPENING_FUNDER_REPLY:
case WIRE_OPENINGD_FUNDER_REPLY:
if (!uc->fc) {
log_broken(openingd->log, "Unexpected FUNDER_REPLY %s",
tal_hex(tmpctx, msg));
@ -937,7 +937,7 @@ static unsigned int openingd_msg(struct subd *openingd,
return 3;
opening_funder_finished(openingd, msg, fds, uc->fc);
return 0;
case WIRE_OPENING_FUNDER_START_REPLY:
case WIRE_OPENINGD_FUNDER_START_REPLY:
if (!uc->fc) {
log_broken(openingd->log, "Unexpected FUNDER_START_REPLY %s",
tal_hex(tmpctx, msg));
@ -946,7 +946,7 @@ static unsigned int openingd_msg(struct subd *openingd,
}
opening_funder_start_replied(openingd, msg, fds, uc->fc);
return 0;
case WIRE_OPENING_FUNDER_FAILED:
case WIRE_OPENINGD_FUNDER_FAILED:
if (!uc->fc) {
log_unusual(openingd->log, "Unexpected FUNDER_FAILED %s",
tal_hex(tmpctx, msg));
@ -956,25 +956,25 @@ static unsigned int openingd_msg(struct subd *openingd,
opening_funder_failed(openingd, msg, uc);
return 0;
case WIRE_OPENING_FUNDEE:
case WIRE_OPENINGD_FUNDEE:
if (tal_count(fds) != 3)
return 3;
opening_fundee_finished(openingd, msg, fds, uc);
return 0;
case WIRE_OPENING_GOT_OFFER:
case WIRE_OPENINGD_GOT_OFFER:
opening_got_offer(openingd, msg, uc);
return 0;
/* We send these! */
case WIRE_OPENING_INIT:
case WIRE_OPENING_FUNDER_START:
case WIRE_OPENING_FUNDER_COMPLETE:
case WIRE_OPENING_FUNDER_CANCEL:
case WIRE_OPENING_GOT_OFFER_REPLY:
case WIRE_OPENING_DEV_MEMLEAK:
case WIRE_OPENINGD_INIT:
case WIRE_OPENINGD_FUNDER_START:
case WIRE_OPENINGD_FUNDER_COMPLETE:
case WIRE_OPENINGD_FUNDER_CANCEL:
case WIRE_OPENINGD_GOT_OFFER_REPLY:
case WIRE_OPENINGD_DEV_MEMLEAK:
/* Replies never get here */
case WIRE_OPENING_DEV_MEMLEAK_REPLY:
case WIRE_OPENINGD_DEV_MEMLEAK_REPLY:
break;
}
@ -992,7 +992,7 @@ static unsigned int openingd_msg(struct subd *openingd,
}
log_broken(openingd->log, "Unexpected msg %s: %s",
opening_wire_type_name(t), tal_hex(tmpctx, msg));
openingd_wire_name(t), tal_hex(tmpctx, msg));
tal_free(openingd);
return 0;
}
@ -1018,7 +1018,7 @@ void peer_start_openingd(struct peer *peer,
uc->openingd = new_channel_subd(peer->ld,
"lightning_openingd",
uc, &peer->id, uc->log,
true, opening_wire_type_name,
true, openingd_wire_name,
openingd_msg,
opening_channel_errmsg,
opening_channel_set_billboard,
@ -1047,7 +1047,7 @@ void peer_start_openingd(struct peer *peer,
*/
uc->minimum_depth = peer->ld->config.anchor_confirms;
msg = towire_opening_init(NULL,
msg = towire_openingd_init(NULL,
chainparams,
peer->ld->our_features,
&uc->our_config,
@ -1118,7 +1118,7 @@ static struct command_result *json_fund_channel_complete(struct command *cmd,
/* Set the cmd to this new cmd */
peer->uncommitted_channel->fc->cmd = cmd;
msg = towire_opening_funder_complete(NULL,
msg = towire_openingd_funder_complete(NULL,
funding_txid,
funding_txout);
subd_send_msg(peer->uncommitted_channel->openingd, take(msg));
@ -1155,7 +1155,7 @@ static struct command_result *json_fund_channel_cancel(struct command *cmd,
/* Make sure this gets notified if we succeed or cancel */
tal_arr_expand(&peer->uncommitted_channel->fc->cancels, cmd);
msg = towire_opening_funder_cancel(NULL);
msg = towire_openingd_funder_cancel(NULL);
subd_send_msg(peer->uncommitted_channel->openingd, take(msg));
return command_still_pending(cmd);
}
@ -1275,7 +1275,7 @@ static struct command_result *json_fund_channel_start(struct command *cmd,
fc->our_upfront_shutdown_script
= tal_steal(fc, fc->our_upfront_shutdown_script);
msg = towire_opening_funder_start(NULL,
msg = towire_openingd_funder_start(NULL,
*amount,
fc->push,
fc->our_upfront_shutdown_script,
@ -1333,7 +1333,7 @@ static void opening_memleak_req_done(struct subd *openingd,
struct uncommitted_channel *uc = openingd->channel;
tal_del_destructor2(openingd, opening_died_forget_memleak, cmd);
if (!fromwire_opening_dev_memleak_reply(msg, &found_leak)) {
if (!fromwire_openingd_dev_memleak_reply(msg, &found_leak)) {
was_pending(command_fail(cmd, LIGHTNINGD,
"Bad opening_dev_memleak"));
return;
@ -1362,7 +1362,7 @@ static void opening_memleak_req_next(struct command *cmd, struct peer *prev)
subd_req(p,
p->uncommitted_channel->openingd,
take(towire_opening_dev_memleak(NULL)),
take(towire_openingd_dev_memleak(NULL)),
-1, 0, opening_memleak_req_done, cmd);
/* Just in case it dies before replying! */
tal_add_destructor2(p->uncommitted_channel->openingd,

12
openingd/Makefile

@ -10,7 +10,7 @@ opening-all: lightningd/lightning_openingd
# opening needs these:
LIGHTNINGD_OPENING_HEADERS_GEN := \
openingd/gen_opening_wire.h
openingd/openingd_wiregen.h
LIGHTNINGD_OPENING_HEADERS_NOGEN :=
@ -25,9 +25,9 @@ LIGHTNINGD_OPENING_CONTROL_HEADERS := $(LIGHTNINGD_OPENING_HEADERS)
LIGHTNINGD_OPENING_CONTROL_SRC := $(LIGHTNINGD_OPENING_HEADERS:.h=.c)
LIGHTNINGD_OPENING_CONTROL_OBJS := $(LIGHTNINGD_OPENING_CONTROL_SRC:.c=.o)
LIGHTNINGD_OPENING_GEN_SRC := $(filter openingd/gen_%, $(LIGHTNINGD_OPENING_SRC) $(LIGHTNINGD_OPENING_CONTROL_SRC))
LIGHTNINGD_OPENING_GEN_SRC := $(filter openingd/%wiregen.c, $(LIGHTNINGD_OPENING_SRC) $(LIGHTNINGD_OPENING_CONTROL_SRC))
LIGHTNINGD_OPENING_SRC_NOGEN := $(filter-out openingd/gen_%, $(LIGHTNINGD_OPENING_SRC))
LIGHTNINGD_OPENING_SRC_NOGEN := $(filter-out openingd/%wiregen.c, $(LIGHTNINGD_OPENING_SRC))
# Add to headers which any object might need.
LIGHTNINGD_HEADERS_GEN += $(LIGHTNINGD_OPENING_HEADERS_GEN)
@ -87,12 +87,6 @@ OPENINGD_COMMON_OBJS := \
$(LIGHTNINGD_OPENING_OBJS): $(LIGHTNINGD_HEADERS)
openingd/gen_opening_wire.h: $(WIRE_GEN) openingd/opening_wire.csv
$(WIRE_GEN) --page header $@ opening_wire_type < openingd/opening_wire.csv > $@
openingd/gen_opening_wire.c: $(WIRE_GEN) openingd/opening_wire.csv
$(WIRE_GEN) --page impl ${@:.c=.h} opening_wire_type < openingd/opening_wire.csv > $@
LIGHTNINGD_OPENING_OBJS := $(LIGHTNINGD_OPENING_SRC:.c=.o) $(LIGHTNINGD_OPENING_GEN_SRC:.c=.o)
# Make sure these depend on everything.

140
openingd/opening_wire.csv

@ -1,140 +0,0 @@
#include <bitcoin/chainparams.h>
#include <common/cryptomsg.h>
#include <common/channel_config.h>
#include <common/channel_id.h>
#include <common/derive_basepoints.h>
#include <common/features.h>
#include <common/per_peer_state.h>
msgtype,opening_init,6000
# Which network are we configured for?
msgdata,opening_init,chainparams,chainparams,
msgdata,opening_init,our_features,feature_set,
# Base configuration we'll offer (channel reserve will vary with amount)
msgdata,opening_init,our_config,channel_config,
# Minimum/maximum configuration values we'll accept
msgdata,opening_init,max_to_self_delay,u32,
msgdata,opening_init,min_effective_htlc_capacity_msat,amount_msat,
msgdata,opening_init,pps,per_peer_state,
msgdata,opening_init,our_basepoints,basepoints,
msgdata,opening_init,our_funding_pubkey,pubkey,
# Constraints in case the other end tries to open a channel.
msgdata,opening_init,minimum_depth,u32,
msgdata,opening_init,min_feerate,u32,
msgdata,opening_init,max_feerate,u32,
msgdata,opening_init,lfeatures_len,u16,
msgdata,opening_init,lfeatures,u8,lfeatures_len
msgdata,opening_init,option_static_remotekey,bool,
msgdata,opening_init,option_anchor_outputs,bool,
# Optional msg to send.
msgdata,opening_init,len,u16,
msgdata,opening_init,msg,u8,len
msgdata,opening_init,dev_temporary_channel_id,?byte,32
msgdata,opening_init,dev_fast_gossip,bool,
# Openingd->master: they offered channel, should we continue?
msgtype,opening_got_offer,6005
msgdata,opening_got_offer,funding_satoshis,amount_sat,
msgdata,opening_got_offer,push_msat,amount_msat,
msgdata,opening_got_offer,dust_limit_satoshis,amount_sat,
msgdata,opening_got_offer,max_htlc_value_in_flight_msat,amount_msat,
msgdata,opening_got_offer,channel_reserve_satoshis,amount_sat,
msgdata,opening_got_offer,htlc_minimum_msat,amount_msat,
msgdata,opening_got_offer,feerate_per_kw,u32,
msgdata,opening_got_offer,to_self_delay,u16,
msgdata,opening_got_offer,max_accepted_htlcs,u16,
msgdata,opening_got_offer,channel_flags,u8,
msgdata,opening_got_offer,shutdown_len,u16,
msgdata,opening_got_offer,shutdown_scriptpubkey,u8,shutdown_len
# master->openingd: optional rejection message
msgtype,opening_got_offer_reply,6105
msgdata,opening_got_offer_reply,rejection,?wirestring,
msgdata,opening_got_offer_reply,shutdown_len,u16,
msgdata,opening_got_offer_reply,our_shutdown_scriptpubkey,?u8,shutdown_len
#include <common/penalty_base.h>
# Openingd->master: we've successfully offered channel.
# This gives their sig, means we can broadcast tx: we're done.
msgtype,opening_funder_reply,6101
msgdata,opening_funder_reply,their_config,channel_config,
msgdata,opening_funder_reply,first_commit,bitcoin_tx,
msgdata,opening_funder_reply,pbase,?penalty_base,
msgdata,opening_funder_reply,first_commit_sig,bitcoin_signature,
msgdata,opening_funder_reply,pps,per_peer_state,
msgdata,opening_funder_reply,revocation_basepoint,pubkey,
msgdata,opening_funder_reply,payment_basepoint,pubkey,
msgdata,opening_funder_reply,htlc_basepoint,pubkey,
msgdata,opening_funder_reply,delayed_payment_basepoint,pubkey,
msgdata,opening_funder_reply,their_per_commit_point,pubkey,
msgdata,opening_funder_reply,minimum_depth,u32,
msgdata,opening_funder_reply,remote_fundingkey,pubkey,
msgdata,opening_funder_reply,funding_txid,bitcoin_txid,
msgdata,opening_funder_reply,funding_txout,u16,
msgdata,opening_funder_reply,feerate_per_kw,u32,
msgdata,opening_funder_reply,our_channel_reserve_satoshis,amount_sat,
msgdata,opening_funder_reply,shutdown_len,u16,
msgdata,opening_funder_reply,shutdown_scriptpubkey,u8,shutdown_len
# master->openingd: start channel establishment for a funding tx
msgtype,opening_funder_start,6002
msgdata,opening_funder_start,funding_satoshis,amount_sat,
msgdata,opening_funder_start,push_msat,amount_msat,
msgdata,opening_funder_start,len_upfront,u16,
msgdata,opening_funder_start,upfront_shutdown_script,u8,len_upfront
msgdata,opening_funder_start,feerate_per_kw,u32,
msgdata,opening_funder_start,channel_flags,u8,
# openingd->master: send back output script for 2-of-2 funding output
msgtype,opening_funder_start_reply,6102
msgdata,opening_funder_start_reply,script_len,u8,
msgdata,opening_funder_start_reply,scriptpubkey,u8,script_len
msgdata,opening_funder_start_reply,upfront_shutdown_negotiated,bool,
# master->openingd: complete channel establishment for a funding
# tx that will be paid for by an external wallet
# response to this is a normal `opening_funder_reply` ??
msgtype,opening_funder_complete,6012
msgdata,opening_funder_complete,funding_txid,bitcoin_txid,
msgdata,opening_funder_complete,funding_txout,u16,
#master->openingd: cancel channel establishment for a funding
msgtype,opening_funder_cancel,6013
# Openingd->master: we failed to negotiation channel
msgtype,opening_funder_failed,6004
msgdata,opening_funder_failed,reason,wirestring,
# Openingd->master: they offered channel.
# This gives their txid and info, means we can send funding_signed: we're done.
msgtype,opening_fundee,6003
msgdata,opening_fundee,their_config,channel_config,
msgdata,opening_fundee,first_commit,bitcoin_tx,
msgdata,opening_fundee,pbase,?penalty_base,
msgdata,opening_fundee,first_commit_sig,bitcoin_signature,
msgdata,opening_fundee,pps,per_peer_state,
msgdata,opening_fundee,revocation_basepoint,pubkey,
msgdata,opening_fundee,payment_basepoint,pubkey,
msgdata,opening_fundee,htlc_basepoint,pubkey,
msgdata,opening_fundee,delayed_payment_basepoint,pubkey,
msgdata,opening_fundee,their_per_commit_point,pubkey,
msgdata,opening_fundee,remote_fundingkey,pubkey,
msgdata,opening_fundee,funding_txid,bitcoin_txid,
msgdata,opening_fundee,funding_txout,u16,
msgdata,opening_fundee,funding_satoshis,amount_sat,
msgdata,opening_fundee,push_msat,amount_msat,
msgdata,opening_fundee,channel_flags,u8,
msgdata,opening_fundee,feerate_per_kw,u32,
# The funding signed message: send this and we're committed.
msgdata,opening_fundee,msglen,u16,
msgdata,opening_fundee,funding_signed_msg,u8,msglen
msgdata,opening_fundee,our_channel_reserve_satoshis,amount_sat,
msgdata,opening_fundee,local_shutdown_len,u16,
msgdata,opening_fundee,local_shutdown_scriptpubkey,u8,local_shutdown_len
msgdata,opening_fundee,remote_shutdown_len,u16,
msgdata,opening_fundee,remote_shutdown_scriptpubkey,u8,remote_shutdown_len
# master -> openingd: do you have a memleak?
msgtype,opening_dev_memleak,6033
msgtype,opening_dev_memleak_reply,6133
msgdata,opening_dev_memleak_reply,leak,bool,
Can't render this file because it has a wrong number of fields in line 9.

64
openingd/openingd.c

@ -44,7 +44,7 @@
#include <gossipd/gossipd_peerd_wiregen.h>
#include <hsmd/hsmd_wiregen.h>
#include <inttypes.h>
#include <openingd/gen_opening_wire.h>
#include <openingd/openingd_wiregen.h>
#include <poll.h>
#include <secp256k1.h>
#include <stdio.h>
@ -161,7 +161,7 @@ static void negotiation_aborted(struct state *state, bool am_opener,
/* If necessary, tell master that funding failed. */
if (am_opener) {
u8 *msg = towire_opening_funder_failed(NULL, why);
u8 *msg = towire_openingd_funder_failed(NULL, why);
wire_sync_write(REQ_FD, take(msg));
}
@ -463,7 +463,7 @@ static u8 *opening_negotiate_msg(const tal_t *ctx, struct state *state,
/* Close connection on all_channels error. */
if (all_channels) {
if (am_opener) {
msg = towire_opening_funder_failed(NULL,
msg = towire_openingd_funder_failed(NULL,
err);
wire_sync_write(REQ_FD, take(msg));
}
@ -661,7 +661,7 @@ static u8 *funder_channel_start(struct state *state, u8 channel_flags)
"Funding channel start: awaiting funding_txid with output to %s",
tal_hex(tmpctx, funding_output_script));
return towire_opening_funder_start_reply(state,
return towire_openingd_funder_start_reply(state,
funding_output_script,
feature_negotiated(
state->our_features,
@ -900,7 +900,7 @@ static u8 *funder_channel_complete(struct state *state)
&pbase))
return NULL;
return towire_opening_funder_reply(state,
return towire_openingd_funder_reply(state,
&state->remoteconf,
tx,
pbase,
@ -1084,7 +1084,7 @@ static u8 *fundee_channel(struct state *state, const u8 *open_channel_msg)
/* Check with lightningd that we can accept this? In particular,
* if we have an existing channel, we don't support it. */
msg = towire_opening_got_offer(NULL,
msg = towire_openingd_got_offer(NULL,
state->funding,
state->push_msat,
state->remoteconf.dust_limit,
@ -1101,9 +1101,9 @@ static u8 *fundee_channel(struct state *state, const u8 *open_channel_msg)
/* We don't allocate off tmpctx, because that's freed inside
* opening_negotiate_msg */
if (!fromwire_opening_got_offer_reply(state, msg, &err_reason,
if (!fromwire_openingd_got_offer_reply(state, msg, &err_reason,
&state->upfront_shutdown_script[LOCAL]))
master_badmsg(WIRE_OPENING_GOT_OFFER_REPLY, msg);
master_badmsg(WIRE_OPENINGD_GOT_OFFER_REPLY, msg);
/* If they give us a reason to reject, do so. */
if (err_reason) {
@ -1294,7 +1294,7 @@ static u8 *fundee_channel(struct state *state, const u8 *open_channel_msg)
else
pbase = NULL;
return towire_opening_fundee(state,
return towire_openingd_fundee(state,
&state->remoteconf,
local_commit,
pbase,
@ -1412,7 +1412,7 @@ static void handle_dev_memleak(struct state *state, const u8 *msg)
/* If there's anything left, dump it to logs, and return true. */
found_leak = dump_memleak(memtable);
wire_sync_write(REQ_FD,
take(towire_opening_dev_memleak_reply(NULL,
take(towire_openingd_dev_memleak_reply(NULL,
found_leak)));
}
@ -1430,55 +1430,55 @@ static void openingd_send_custommsg(struct state *state, const u8 *msg)
static u8 *handle_master_in(struct state *state)
{
u8 *msg = wire_sync_read(tmpctx, REQ_FD);
enum opening_wire_type t = fromwire_peektype(msg);
enum openingd_wire t = fromwire_peektype(msg);
u8 channel_flags;
struct bitcoin_txid funding_txid;
u16 funding_txout;
switch (t) {
case WIRE_OPENING_FUNDER_START:
if (!fromwire_opening_funder_start(state, msg, &state->funding,
case WIRE_OPENINGD_FUNDER_START:
if (!fromwire_openingd_funder_start(state, msg, &state->funding,
&state->push_msat,
&state->upfront_shutdown_script[LOCAL],
&state->feerate_per_kw,
&channel_flags))
master_badmsg(WIRE_OPENING_FUNDER_START, msg);
master_badmsg(WIRE_OPENINGD_FUNDER_START, msg);
msg = funder_channel_start(state, channel_flags);
/* We want to keep openingd alive, since we're not done yet */
if (msg)
wire_sync_write(REQ_FD, take(msg));
return NULL;
case WIRE_OPENING_FUNDER_COMPLETE:
if (!fromwire_opening_funder_complete(msg,
case WIRE_OPENINGD_FUNDER_COMPLETE:
if (!fromwire_openingd_funder_complete(msg,
&funding_txid,
&funding_txout))
master_badmsg(WIRE_OPENING_FUNDER_COMPLETE, msg);
master_badmsg(WIRE_OPENINGD_FUNDER_COMPLETE, msg);
state->funding_txid = funding_txid;
state->funding_txout = funding_txout;
return funder_channel_complete(state);
case WIRE_OPENING_FUNDER_CANCEL:
case WIRE_OPENINGD_FUNDER_CANCEL:
/* We're aborting this, simple */
if (!fromwire_opening_funder_cancel(msg))
master_badmsg(WIRE_OPENING_FUNDER_CANCEL, msg);
if (!fromwire_openingd_funder_cancel(msg))
master_badmsg(WIRE_OPENINGD_FUNDER_CANCEL, msg);
msg = towire_errorfmt(NULL, &state->channel_id, "Channel open canceled by us");
sync_crypto_write(state->pps, take(msg));
negotiation_aborted(state, true, "Channel open canceled by RPC");
return NULL;
case WIRE_OPENING_DEV_MEMLEAK:
case WIRE_OPENINGD_DEV_MEMLEAK:
#if DEVELOPER
handle_dev_memleak(state, msg);
return NULL;
#endif
case WIRE_OPENING_DEV_MEMLEAK_REPLY:
case WIRE_OPENING_INIT:
case WIRE_OPENING_FUNDER_REPLY:
case WIRE_OPENING_FUNDER_START_REPLY:
case WIRE_OPENING_FUNDEE:
case WIRE_OPENING_FUNDER_FAILED:
case WIRE_OPENING_GOT_OFFER:
case WIRE_OPENING_GOT_OFFER_REPLY:
case WIRE_OPENINGD_DEV_MEMLEAK_REPLY:
case WIRE_OPENINGD_INIT:
case WIRE_OPENINGD_FUNDER_REPLY:
case WIRE_OPENINGD_FUNDER_START_REPLY:
case WIRE_OPENINGD_FUNDEE:
case WIRE_OPENINGD_FUNDER_FAILED:
case WIRE_OPENINGD_GOT_OFFER:
case WIRE_OPENINGD_GOT_OFFER_REPLY:
break;
}
@ -1526,7 +1526,7 @@ int main(int argc, char *argv[])
/*~ The very first thing we read from lightningd is our init msg */
msg = wire_sync_read(tmpctx, REQ_FD);
if (!fromwire_opening_init(state, msg,
if (!fromwire_openingd_init(state, msg,
&chainparams,
&state->our_features,
&state->localconf,
@ -1543,7 +1543,7 @@ int main(int argc, char *argv[])
&inner,
&force_tmp_channel_id,
&dev_fast_gossip))
master_badmsg(WIRE_OPENING_INIT, msg);
master_badmsg(WIRE_OPENINGD_INIT, msg);
#if DEVELOPER
dev_force_tmp_channel_id = force_tmp_channel_id;
@ -1638,7 +1638,7 @@ int main(int argc, char *argv[])
wire_sync_write(REQ_FD, msg);
per_peer_state_fdpass_send(REQ_FD, state->pps);
status_debug("Sent %s with fds",
opening_wire_type_name(fromwire_peektype(msg)));
openingd_wire_name(fromwire_peektype(msg)));
/* This frees the entire tal tree. */
tal_free(state);

140
openingd/openingd_wire.csv

@ -0,0 +1,140 @@
#include <bitcoin/chainparams.h>
#include <common/cryptomsg.h>
#include <common/channel_config.h>
#include <common/channel_id.h>
#include <common/derive_basepoints.h>
#include <common/features.h>
#include <common/per_peer_state.h>
msgtype,openingd_init,6000
# Which network are we configured for?
msgdata,openingd_init,chainparams,chainparams,
msgdata,openingd_init,our_features,feature_set,
# Base configuration we'll offer (channel reserve will vary with amount)
msgdata,openingd_init,our_config,channel_config,
# Minimum/maximum configuration values we'll accept
msgdata,openingd_init,max_to_self_delay,u32,
msgdata,openingd_init,min_effective_htlc_capacity_msat,amount_msat,
msgdata,openingd_init,pps,per_peer_state,
msgdata,openingd_init,our_basepoints,basepoints,
msgdata,openingd_init,our_funding_pubkey,pubkey,
# Constraints in case the other end tries to open a channel.
msgdata,openingd_init,minimum_depth,u32,
msgdata,openingd_init,min_feerate,u32,
msgdata,openingd_init,max_feerate,u32,
msgdata,openingd_init,lfeatures_len,u16,
msgdata,openingd_init,lfeatures,u8,lfeatures_len
msgdata,openingd_init,option_static_remotekey,bool,
msgdata,openingd_init,option_anchor_outputs,bool,
# Optional msg to send.
msgdata,openingd_init,len,u16,
msgdata,openingd_init,msg,u8,len
msgdata,openingd_init,dev_temporary_channel_id,?byte,32
msgdata,openingd_init,dev_fast_gossip,bool,
# Openingd->master: they offered channel, should we continue?
msgtype,openingd_got_offer,6005
msgdata,openingd_got_offer,funding_satoshis,amount_sat,
msgdata,openingd_got_offer,push_msat,amount_msat,
msgdata,openingd_got_offer,dust_limit_satoshis,amount_sat,
msgdata,openingd_got_offer,max_htlc_value_in_flight_msat,amount_msat,
msgdata,openingd_got_offer,channel_reserve_satoshis,amount_sat,
msgdata,openingd_got_offer,htlc_minimum_msat,amount_msat,
msgdata,openingd_got_offer,feerate_per_kw,u32,
msgdata,openingd_got_offer,to_self_delay,u16,
msgdata,openingd_got_offer,max_accepted_htlcs,u16,
msgdata,openingd_got_offer,channel_flags,u8,
msgdata,openingd_got_offer,shutdown_len,u16,
msgdata,openingd_got_offer,shutdown_scriptpubkey,u8,shutdown_len
# master->openingd: optional rejection message
msgtype,openingd_got_offer_reply,6105
msgdata,openingd_got_offer_reply,rejection,?wirestring,
msgdata,openingd_got_offer_reply,shutdown_len,u16,
msgdata,openingd_got_offer_reply,our_shutdown_scriptpubkey,?u8,shutdown_len
#include <common/penalty_base.h>
# Openingd->master: we've successfully offered channel.
# This gives their sig, means we can broadcast tx: we're done.
msgtype,openingd_funder_reply,6101
msgdata,openingd_funder_reply,their_config,channel_config,
msgdata,openingd_funder_reply,first_commit,bitcoin_tx,
msgdata,openingd_funder_reply,pbase,?penalty_base,
msgdata,openingd_funder_reply,first_commit_sig,bitcoin_signature,
msgdata,openingd_funder_reply,pps,per_peer_state,
msgdata,openingd_funder_reply,revocation_basepoint,pubkey,
msgdata,openingd_funder_reply,payment_basepoint,pubkey,
msgdata,openingd_funder_reply,htlc_basepoint,pubkey,
msgdata,openingd_funder_reply,delayed_payment_basepoint,pubkey,
msgdata,openingd_funder_reply,their_per_commit_point,pubkey,
msgdata,openingd_funder_reply,minimum_depth,u32,
msgdata,openingd_funder_reply,remote_fundingkey,pubkey,
msgdata,openingd_funder_reply,funding_txid,bitcoin_txid,
msgdata,openingd_funder_reply,funding_txout,u16,
msgdata,openingd_funder_reply,feerate_per_kw,u32,
msgdata,openingd_funder_reply,our_channel_reserve_satoshis,amount_sat,
msgdata,openingd_funder_reply,shutdown_len,u16,
msgdata,openingd_funder_reply,shutdown_scriptpubkey,u8,shutdown_len
# master->openingd: start channel establishment for a funding tx
msgtype,openingd_funder_start,6002
msgdata,openingd_funder_start,funding_satoshis,amount_sat,
msgdata,openingd_funder_start,push_msat,amount_msat,
msgdata,openingd_funder_start,len_upfront,u16,
msgdata,openingd_funder_start,upfront_shutdown_script,u8,len_upfront
msgdata,openingd_funder_start,feerate_per_kw,u32,
msgdata,openingd_funder_start,channel_flags,u8,
# openingd->master: send back output script for 2-of-2 funding output
msgtype,openingd_funder_start_reply,6102
msgdata,openingd_funder_start_reply,script_len,u8,
msgdata,openingd_funder_start_reply,scriptpubkey,u8,script_len
msgdata,openingd_funder_start_reply,upfront_shutdown_negotiated,bool,
# master->openingd: complete channel establishment for a funding
# tx that will be paid for by an external wallet
# response to this is a normal `openingd_funder_reply` ??
msgtype,openingd_funder_complete,6012
msgdata,openingd_funder_complete,funding_txid,bitcoin_txid,
msgdata,openingd_funder_complete,funding_txout,u16,
#master->openingd: cancel channel establishment for a funding
msgtype,openingd_funder_cancel,6013
# Openingd->master: we failed to negotiation channel
msgtype,openingd_funder_failed,6004
msgdata,openingd_funder_failed,reason,wirestring,
# Openingd->master: they offered channel.
# This gives their txid and info, means we can send funding_signed: we're done.
msgtype,openingd_fundee,6003
msgdata,openingd_fundee,their_config,channel_config,
msgdata,openingd_fundee,first_commit,bitcoin_tx,
msgdata,openingd_fundee,pbase,?penalty_base,
msgdata,openingd_fundee,first_commit_sig,bitcoin_signature,
msgdata,openingd_fundee,pps,per_peer_state,
msgdata,openingd_fundee,revocation_basepoint,pubkey,
msgdata,openingd_fundee,payment_basepoint,pubkey,
msgdata,openingd_fundee,htlc_basepoint,pubkey,
msgdata,openingd_fundee,delayed_payment_basepoint,pubkey,
msgdata,openingd_fundee,their_per_commit_point,pubkey,
msgdata,openingd_fundee,remote_fundingkey,pubkey,
msgdata,openingd_fundee,funding_txid,bitcoin_txid,
msgdata,openingd_fundee,funding_txout,u16,
msgdata,openingd_fundee,funding_satoshis,amount_sat,
msgdata,openingd_fundee,push_msat,amount_msat,
msgdata,openingd_fundee,channel_flags,u8,
msgdata,openingd_fundee,feerate_per_kw,u32,
# The funding signed message: send this and we're committed.
msgdata,openingd_fundee,msglen,u16,
msgdata,openingd_fundee,funding_signed_msg,u8,msglen
msgdata,openingd_fundee,our_channel_reserve_satoshis,amount_sat,
msgdata,openingd_fundee,local_shutdown_len,u16,
msgdata,openingd_fundee,local_shutdown_scriptpubkey,u8,local_shutdown_len
msgdata,openingd_fundee,remote_shutdown_len,u16,
msgdata,openingd_fundee,remote_shutdown_scriptpubkey,u8,remote_shutdown_len
# master -> openingd: do you have a memleak?
msgtype,openingd_dev_memleak,6033
msgtype,openingd_dev_memleak_reply,6133
msgdata,openingd_dev_memleak_reply,leak,bool,
Can't render this file because it has a wrong number of fields in line 9.
Loading…
Cancel
Save