#ifndef LIGHTNING_DAEMON_PEER_H #define LIGHTNING_DAEMON_PEER_H #include "config.h" #include "bitcoin/locktime.h" #include "bitcoin/pubkey.h" #include "lightning.pb-c.h" #include "netaddr.h" #include "state.h" #include #include struct peer_visible_state { /* CMD_OPEN_WITH_ANCHOR or CMD_OPEN_WITHOUT_ANCHOR */ enum state_input offer_anchor; /* Key for commitment tx inputs, then key for commitment tx outputs */ struct pubkey commitkey, finalkey; /* How long to they want the other's outputs locked (seconds) */ struct rel_locktime locktime; /* Minimum depth of anchor before channel usable. */ unsigned int mindepth; /* Commitment fee they're offering (satoshi). */ u64 commit_fee; /* Revocation hash for latest commit tx. */ struct sha256 revocation_hash; }; struct peer { /* dstate->peers list */ struct list_node list; /* State in state machine. */ enum state state; /* Condition of communications */ enum state_peercond cond; /* Network connection. */ struct io_conn *conn; /* Current command (if any) */ enum state_input cmd; union input cmddata; struct command *jsoncmd; /* Global state. */ struct lightningd_state *dstate; /* The other end's address. */ struct netaddr addr; /* Their ID. */ struct pubkey id; /* Current received packet. */ Pkt *inpkt; /* Queue of output packets. */ Pkt *outpkt[5]; size_t num_outpkt; /* Current ongoing packetflow */ struct io_data *io_data; /* What happened. */ struct log *log; /* Things we're watching for (see watches.c) */ struct list_head watches; /* Private keys for dealing with this peer. */ struct peer_secrets *secrets; /* Stuff we have in common. */ struct peer_visible_state us, them; }; void setup_listeners(struct lightningd_state *dstate, unsigned int portnum); #endif /* LIGHTNING_DAEMON_PEER_H */