From 12b9d39b76e5cc81cf61f93c940c2fb87749ee26 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Fri, 22 Jan 2016 06:44:24 +1030 Subject: [PATCH] daemon: store revocation hashes in the peer_visible_state structure. Signed-off-by: Rusty Russell --- daemon/packets.c | 6 ++---- daemon/peer.h | 5 ++--- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/daemon/packets.c b/daemon/packets.c index df1c49d64..69a544e0c 100644 --- a/daemon/packets.c +++ b/daemon/packets.c @@ -42,12 +42,10 @@ static Pkt *make_pkt(const tal_t *ctx, Pkt__PktCase type, const void *msg) Pkt *pkt_open(const tal_t *ctx, const struct peer *peer, OpenChannel__AnchorOffer anchor) { - struct sha256 revocation_hash; OpenChannel *o = tal(ctx, OpenChannel); open_channel__init(o); - peer_get_revocation_hash(peer, 0, &revocation_hash); - o->revocation_hash = sha256_to_proto(ctx, &revocation_hash); + o->revocation_hash = sha256_to_proto(ctx, &peer->us.revocation_hash); o->commit_key = pubkey_to_proto(o, &peer->us.commitkey); o->final_key = pubkey_to_proto(o, &peer->us.finalkey); o->delay = tal(o, Locktime); @@ -184,7 +182,7 @@ Pkt *accept_pkt_open(const tal_t *ctx, if (!proto_to_pubkey(peer->dstate->secpctx, o->final_key, &peer->them.finalkey)) return pkt_err(ctx, "Bad finalkey"); - proto_to_sha256(o->revocation_hash, &peer->their_rhash); + proto_to_sha256(o->revocation_hash, &peer->them.revocation_hash); return NULL; } diff --git a/daemon/peer.h b/daemon/peer.h index aa7591052..c6837fcbf 100644 --- a/daemon/peer.h +++ b/daemon/peer.h @@ -20,6 +20,8 @@ struct peer_visible_state { unsigned int mindepth; /* Commitment fee they're offering (satoshi). */ u64 commit_fee; + /* Revocation hash for latest commit tx. */ + struct sha256 revocation_hash; }; struct peer { @@ -58,9 +60,6 @@ struct peer { /* Stuff we have in common. */ struct peer_visible_state us, them; - - /* Their last revocation hash. */ - struct sha256 their_rhash; }; void setup_listeners(struct lightningd_state *dstate, unsigned int portnum);