closingd: convert to new wire generation style.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2020-08-25 11:45:48 +09:30
parent 6d09c0eba9
commit fe8564555f
22 changed files with 411 additions and 426 deletions

View File

@@ -10,7 +10,7 @@ closingd-all: lightningd/lightning_closingd
# closingd needs these:
LIGHTNINGD_CLOSING_HEADERS_GEN := \
closingd/gen_closing_wire.h
closingd/closingd_wiregen.h
LIGHTNINGD_CLOSING_HEADERS_NOGEN :=
@@ -30,9 +30,9 @@ LIGHTNINGD_CLOSING_CONTROL_HEADERS := $(LIGHTNINGD_CLOSING_HEADERS)
LIGHTNINGD_CLOSING_CONTROL_SRC := $(LIGHTNINGD_CLOSING_HEADERS:.h=.c)
LIGHTNINGD_CLOSING_CONTROL_OBJS := $(LIGHTNINGD_CLOSING_CONTROL_SRC:.c=.o)
LIGHTNINGD_CLOSING_GEN_SRC := $(filter closingd/gen_%, $(LIGHTNINGD_CLOSING_SRC) $(LIGHTNINGD_CLOSING_CONTROL_SRC))
LIGHTNINGD_CLOSING_GEN_SRC := $(filter closingd/%wiregen.c, $(LIGHTNINGD_CLOSING_SRC) $(LIGHTNINGD_CLOSING_CONTROL_SRC))
LIGHTNINGD_CLOSING_SRC_NOGEN := $(filter-out closingd/gen_%, $(LIGHTNINGD_CLOSING_SRC))
LIGHTNINGD_CLOSING_SRC_NOGEN := $(filter-out closingd/%wiregen.c, $(LIGHTNINGD_CLOSING_SRC))
# Add to headers which any object might need.
LIGHTNINGD_HEADERS_GEN += $(LIGHTNINGD_CLOSING_HEADERS_GEN)
@@ -84,12 +84,6 @@ CLOSINGD_COMMON_OBJS := \
common/wireaddr.o \
gossipd/gossipd_peerd_wiregen.o
closingd/gen_closing_wire.h: $(WIRE_GEN) closingd/closing_wire.csv
$(WIRE_GEN) --page header $@ closing_wire_type < closingd/closing_wire.csv > $@
closingd/gen_closing_wire.c: $(WIRE_GEN) closingd/closing_wire.csv
$(WIRE_GEN) --page impl ${@:.c=.h} closing_wire_type < closingd/closing_wire.csv > $@
LIGHTNINGD_CLOSING_OBJS := $(LIGHTNINGD_CLOSING_SRC:.c=.o) $(LIGHTNINGD_CLOSING_GEN_SRC:.c=.o)
lightningd/lightning_closingd: $(LIGHTNINGD_CLOSING_OBJS) $(WIRE_ONION_OBJS) $(CLOSINGD_COMMON_OBJS) $(WIRE_OBJS) $(BITCOIN_OBJS) $(LIGHTNINGD_HSM_CLIENT_OBJS)

View File

@@ -1,45 +0,0 @@
#include <bitcoin/tx.h>
#include <common/cryptomsg.h>
#include <common/htlc_wire.h>
#include <common/per_peer_state.h>
# Begin! (passes peer fd, gossipd-client fd)
msgtype,closing_init,2001
msgdata,closing_init,chainparams,chainparams,
msgdata,closing_init,pps,per_peer_state,
msgdata,closing_init,funding_txid,bitcoin_txid,
msgdata,closing_init,funding_txout,u16,
msgdata,closing_init,funding_satoshi,amount_sat,
msgdata,closing_init,local_fundingkey,pubkey,
msgdata,closing_init,remote_fundingkey,pubkey,
msgdata,closing_init,opener,enum side,
msgdata,closing_init,local_sat,amount_sat,
msgdata,closing_init,remote_sat,amount_sat,
msgdata,closing_init,our_dust_limit,amount_sat,
msgdata,closing_init,min_fee_satoshi,amount_sat,
msgdata,closing_init,fee_limit_satoshi,amount_sat,
msgdata,closing_init,initial_fee_satoshi,amount_sat,
msgdata,closing_init,local_scriptpubkey_len,u16,
msgdata,closing_init,local_scriptpubkey,u8,local_scriptpubkey_len
msgdata,closing_init,remote_scriptpubkey_len,u16,
msgdata,closing_init,remote_scriptpubkey,u8,remote_scriptpubkey_len
msgdata,closing_init,fee_negotiation_step,u64,
msgdata,closing_init,fee_negotiation_step_unit,u8,
msgdata,closing_init,reconnected,bool,
msgdata,closing_init,next_index_local,u64,
msgdata,closing_init,next_index_remote,u64,
msgdata,closing_init,revocations_received,u64,
msgdata,closing_init,channel_reestablish_len,u16,
msgdata,closing_init,channel_reestablish,u8,channel_reestablish_len
msgdata,closing_init,last_remote_secret,secret,
msgdata,closing_init,dev_fast_gossip,bool,
# We received an offer, save signature.
msgtype,closing_received_signature,2002
msgdata,closing_received_signature,signature,bitcoin_signature,
msgdata,closing_received_signature,tx,bitcoin_tx,
msgtype,closing_received_signature_reply,2102
msgdata,closing_received_signature_reply,closing_txid,bitcoin_txid,
# Negotiations complete, we're exiting.
msgtype,closing_complete,2004
1 #include <bitcoin/tx.h>
2 #include <common/cryptomsg.h>
3 #include <common/htlc_wire.h>
4 #include <common/per_peer_state.h>
5 # Begin! (passes peer fd, gossipd-client fd)
6 msgtype,closing_init,2001
7 msgdata,closing_init,chainparams,chainparams,
8 msgdata,closing_init,pps,per_peer_state,
9 msgdata,closing_init,funding_txid,bitcoin_txid,
10 msgdata,closing_init,funding_txout,u16,
11 msgdata,closing_init,funding_satoshi,amount_sat,
12 msgdata,closing_init,local_fundingkey,pubkey,
13 msgdata,closing_init,remote_fundingkey,pubkey,
14 msgdata,closing_init,opener,enum side,
15 msgdata,closing_init,local_sat,amount_sat,
16 msgdata,closing_init,remote_sat,amount_sat,
17 msgdata,closing_init,our_dust_limit,amount_sat,
18 msgdata,closing_init,min_fee_satoshi,amount_sat,
19 msgdata,closing_init,fee_limit_satoshi,amount_sat,
20 msgdata,closing_init,initial_fee_satoshi,amount_sat,
21 msgdata,closing_init,local_scriptpubkey_len,u16,
22 msgdata,closing_init,local_scriptpubkey,u8,local_scriptpubkey_len
23 msgdata,closing_init,remote_scriptpubkey_len,u16,
24 msgdata,closing_init,remote_scriptpubkey,u8,remote_scriptpubkey_len
25 msgdata,closing_init,fee_negotiation_step,u64,
26 msgdata,closing_init,fee_negotiation_step_unit,u8,
27 msgdata,closing_init,reconnected,bool,
28 msgdata,closing_init,next_index_local,u64,
29 msgdata,closing_init,next_index_remote,u64,
30 msgdata,closing_init,revocations_received,u64,
31 msgdata,closing_init,channel_reestablish_len,u16,
32 msgdata,closing_init,channel_reestablish,u8,channel_reestablish_len
33 msgdata,closing_init,last_remote_secret,secret,
34 msgdata,closing_init,dev_fast_gossip,bool,
35 # We received an offer, save signature.
36 msgtype,closing_received_signature,2002
37 msgdata,closing_received_signature,signature,bitcoin_signature,
38 msgdata,closing_received_signature,tx,bitcoin_tx,
39 msgtype,closing_received_signature_reply,2102
40 msgdata,closing_received_signature_reply,closing_txid,bitcoin_txid,
41 # Negotiations complete, we're exiting.
42 msgtype,closing_complete,2004

View File

@@ -1,6 +1,6 @@
#include <bitcoin/script.h>
#include <ccan/fdpass/fdpass.h>
#include <closingd/gen_closing_wire.h>
#include <closingd/closingd_wiregen.h>
#include <common/close_tx.h>
#include <common/closing_fee.h>
#include <common/crypto_sync.h>
@@ -300,7 +300,7 @@ static void tell_master_their_offer(const struct bitcoin_signature *their_sig,
const struct bitcoin_tx *tx,
struct bitcoin_txid *tx_id)
{
u8 *msg = towire_closing_received_signature(NULL, their_sig, tx);
u8 *msg = towire_closingd_received_signature(NULL, their_sig, tx);
if (!wire_sync_write(REQ_FD, take(msg)))
status_failed(STATUS_FAIL_MASTER_IO,
"Writing received to master: %s",
@@ -308,8 +308,8 @@ static void tell_master_their_offer(const struct bitcoin_signature *their_sig,
/* Wait for master to ack, to make sure it's in db. */
msg = wire_sync_read(NULL, REQ_FD);
if (!fromwire_closing_received_signature_reply(msg, tx_id))
master_badmsg(WIRE_CLOSING_RECEIVED_SIGNATURE_REPLY, msg);
if (!fromwire_closingd_received_signature_reply(msg, tx_id))
master_badmsg(WIRE_CLOSINGD_RECEIVED_SIGNATURE_REPLY, msg);
tal_free(msg);
}
@@ -625,7 +625,7 @@ int main(int argc, char *argv[])
status_setup_sync(REQ_FD);
msg = wire_sync_read(tmpctx, REQ_FD);
if (!fromwire_closing_init(ctx, msg,
if (!fromwire_closingd_init(ctx, msg,
&chainparams,
&pps,
&funding_txid, &funding_txout,
@@ -649,7 +649,7 @@ int main(int argc, char *argv[])
&channel_reestablish,
&last_remote_per_commit_secret,
&dev_fast_gossip))
master_badmsg(WIRE_CLOSING_INIT, msg);
master_badmsg(WIRE_CLOSINGD_INIT, msg);
/* stdin == requests, 3 == peer, 4 = gossip, 5 = gossip_store, 6 = hsmd */
per_peer_state_set_fds(pps, 3, 4, 5);
@@ -791,7 +791,7 @@ int main(int argc, char *argv[])
status_unusual("Closing and draining peerfd gave error: %s",
strerror(errno));
/* Sending the below will kill us! */
wire_sync_write(REQ_FD, take(towire_closing_complete(NULL)));
wire_sync_write(REQ_FD, take(towire_closingd_complete(NULL)));
tal_free(ctx);
daemon_shutdown();

View File

@@ -0,0 +1,45 @@
#include <bitcoin/tx.h>
#include <common/cryptomsg.h>
#include <common/htlc_wire.h>
#include <common/per_peer_state.h>
# Begin! (passes peer fd, gossipd-client fd)
msgtype,closingd_init,2001
msgdata,closingd_init,chainparams,chainparams,
msgdata,closingd_init,pps,per_peer_state,
msgdata,closingd_init,funding_txid,bitcoin_txid,
msgdata,closingd_init,funding_txout,u16,
msgdata,closingd_init,funding_satoshi,amount_sat,
msgdata,closingd_init,local_fundingkey,pubkey,
msgdata,closingd_init,remote_fundingkey,pubkey,
msgdata,closingd_init,opener,enum side,
msgdata,closingd_init,local_sat,amount_sat,
msgdata,closingd_init,remote_sat,amount_sat,
msgdata,closingd_init,our_dust_limit,amount_sat,
msgdata,closingd_init,min_fee_satoshi,amount_sat,
msgdata,closingd_init,fee_limit_satoshi,amount_sat,
msgdata,closingd_init,initial_fee_satoshi,amount_sat,
msgdata,closingd_init,local_scriptpubkey_len,u16,
msgdata,closingd_init,local_scriptpubkey,u8,local_scriptpubkey_len
msgdata,closingd_init,remote_scriptpubkey_len,u16,
msgdata,closingd_init,remote_scriptpubkey,u8,remote_scriptpubkey_len
msgdata,closingd_init,fee_negotiation_step,u64,
msgdata,closingd_init,fee_negotiation_step_unit,u8,
msgdata,closingd_init,reconnected,bool,
msgdata,closingd_init,next_index_local,u64,
msgdata,closingd_init,next_index_remote,u64,
msgdata,closingd_init,revocations_received,u64,
msgdata,closingd_init,channel_reestablish_len,u16,
msgdata,closingd_init,channel_reestablish,u8,channel_reestablish_len
msgdata,closingd_init,last_remote_secret,secret,
msgdata,closingd_init,dev_fast_gossip,bool,
# We received an offer, save signature.
msgtype,closingd_received_signature,2002
msgdata,closingd_received_signature,signature,bitcoin_signature,
msgdata,closingd_received_signature,tx,bitcoin_tx,
msgtype,closingd_received_signature_reply,2102
msgdata,closingd_received_signature_reply,closing_txid,bitcoin_txid,
# Negotiations complete, we're exiting.
msgtype,closingd_complete,2004
1 #include <bitcoin/tx.h>
2 #include <common/cryptomsg.h>
3 #include <common/htlc_wire.h>
4 #include <common/per_peer_state.h>
5 # Begin! (passes peer fd, gossipd-client fd)
6 msgtype,closingd_init,2001
7 msgdata,closingd_init,chainparams,chainparams,
8 msgdata,closingd_init,pps,per_peer_state,
9 msgdata,closingd_init,funding_txid,bitcoin_txid,
10 msgdata,closingd_init,funding_txout,u16,
11 msgdata,closingd_init,funding_satoshi,amount_sat,
12 msgdata,closingd_init,local_fundingkey,pubkey,
13 msgdata,closingd_init,remote_fundingkey,pubkey,
14 msgdata,closingd_init,opener,enum side,
15 msgdata,closingd_init,local_sat,amount_sat,
16 msgdata,closingd_init,remote_sat,amount_sat,
17 msgdata,closingd_init,our_dust_limit,amount_sat,
18 msgdata,closingd_init,min_fee_satoshi,amount_sat,
19 msgdata,closingd_init,fee_limit_satoshi,amount_sat,
20 msgdata,closingd_init,initial_fee_satoshi,amount_sat,
21 msgdata,closingd_init,local_scriptpubkey_len,u16,
22 msgdata,closingd_init,local_scriptpubkey,u8,local_scriptpubkey_len
23 msgdata,closingd_init,remote_scriptpubkey_len,u16,
24 msgdata,closingd_init,remote_scriptpubkey,u8,remote_scriptpubkey_len
25 msgdata,closingd_init,fee_negotiation_step,u64,
26 msgdata,closingd_init,fee_negotiation_step_unit,u8,
27 msgdata,closingd_init,reconnected,bool,
28 msgdata,closingd_init,next_index_local,u64,
29 msgdata,closingd_init,next_index_remote,u64,
30 msgdata,closingd_init,revocations_received,u64,
31 msgdata,closingd_init,channel_reestablish_len,u16,
32 msgdata,closingd_init,channel_reestablish,u8,channel_reestablish_len
33 msgdata,closingd_init,last_remote_secret,secret,
34 msgdata,closingd_init,dev_fast_gossip,bool,
35 # We received an offer, save signature.
36 msgtype,closingd_received_signature,2002
37 msgdata,closingd_received_signature,signature,bitcoin_signature,
38 msgdata,closingd_received_signature,tx,bitcoin_tx,
39 msgtype,closingd_received_signature_reply,2102
40 msgdata,closingd_received_signature_reply,closing_txid,bitcoin_txid,
41 # Negotiations complete, we're exiting.
42 msgtype,closingd_complete,2004