From 0376e08fea0818a618f0ebb176172954cef4baad Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Fri, 22 Jan 2016 06:41:49 +1030 Subject: [PATCH] daemon: peer needs to know who offered the anchor. Signed-off-by: Rusty Russell --- daemon/peer.c | 8 ++++++-- daemon/peer.h | 6 +++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/daemon/peer.c b/daemon/peer.c index afaf08987..4a3f75e55 100644 --- a/daemon/peer.c +++ b/daemon/peer.c @@ -59,6 +59,7 @@ static void destroy_peer(struct peer *peer) static struct peer *new_peer(struct lightningd_state *state, struct io_conn *conn, int addr_type, int addr_protocol, + enum state_input offer_anchor, const char *in_or_out) { struct peer *peer = tal(state, struct peer); @@ -71,6 +72,9 @@ static struct peer *new_peer(struct lightningd_state *state, peer->addr.protocol = addr_protocol; peer->io_data = NULL; peer->secrets = NULL; + peer->offer_anchor = offer_anchor; + assert(offer_anchor == CMD_OPEN_WITH_ANCHOR + || offer_anchor == CMD_OPEN_WITHOUT_ANCHOR); list_head_init(&peer->watches); /* FIXME: Attach IO logging for this peer. */ @@ -97,7 +101,7 @@ static struct io_plan *peer_connected_out(struct io_conn *conn, { struct json_result *response; struct peer *peer = new_peer(state, conn, SOCK_STREAM, IPPROTO_TCP, - "out"); + CMD_OPEN_WITH_ANCHOR, "out"); if (!peer) { command_fail(connect->cmd, "Failed to make peer for %s:%s", connect->name, connect->port); @@ -118,7 +122,7 @@ static struct io_plan *peer_connected_in(struct io_conn *conn, struct lightningd_state *state) { struct peer *peer = new_peer(state, conn, SOCK_STREAM, IPPROTO_TCP, - "in"); + CMD_OPEN_WITHOUT_ANCHOR, "in"); if (!peer) return io_close(conn); diff --git a/daemon/peer.h b/daemon/peer.h index e0360ee1e..fed6129b8 100644 --- a/daemon/peer.h +++ b/daemon/peer.h @@ -4,6 +4,7 @@ #include "bitcoin/pubkey.h" #include "lightning.pb-c.h" #include "netaddr.h" +#include "state_types.h" #include struct peer { @@ -30,7 +31,10 @@ struct peer { /* Things we're watching for (see watches.c) */ struct list_head watches; - + + /* Did we offer an anchor? */ + enum state_input offer_anchor; + /* Keys for transactions with this peer. */ struct pubkey their_commitkey, their_finalkey; struct pubkey our_commitkey, our_finalkey;