mirror of
https://github.com/aljazceru/lightning.git
synced 2026-01-27 09:44:28 +01:00
closingd: convert to new wire generation style.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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,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();
|
||||
|
||||
|
||||
45
closingd/closingd_wire.csv
Normal file
45
closingd/closingd_wire.csv
Normal 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
|
||||
|
Reference in New Issue
Block a user