mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 05:12:45 +01:00
daemon: peer needs to know who offered the anchor.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
e9237f94b1
commit
0376e08fea
@ -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);
|
||||
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include "bitcoin/pubkey.h"
|
||||
#include "lightning.pb-c.h"
|
||||
#include "netaddr.h"
|
||||
#include "state_types.h"
|
||||
#include <ccan/list/list.h>
|
||||
|
||||
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;
|
||||
|
Loading…
Reference in New Issue
Block a user