From 7b2d6925a0d46e5c2a2c3a7084a2e913661b379d Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Thu, 18 Aug 2016 14:23:45 +0930 Subject: [PATCH] channel: assert htlc direction is correct. The HTLC state encodes the creator; this should match the side argument. Signed-off-by: Rusty Russell --- daemon/channel.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/daemon/channel.c b/daemon/channel.c index 1ab0d0cf0..663a73540 100644 --- a/daemon/channel.c +++ b/daemon/channel.c @@ -219,6 +219,7 @@ bool cstate_add_htlc(struct channel_state *cstate, size_t n, nondust; struct channel_oneside *creator, *recipient; + assert(htlc_channel_side(htlc) == side); creator = &cstate->side[side]; recipient = &cstate->side[!side]; @@ -283,6 +284,7 @@ void cstate_fail_htlc(struct channel_state *cstate, struct htlc *htlc, enum channel_side side) { + assert(htlc_channel_side(htlc) == side); remove_htlc(cstate, side, side, htlc); } @@ -290,6 +292,7 @@ void cstate_fulfill_htlc(struct channel_state *cstate, struct htlc *htlc, enum channel_side side) { + assert(htlc_channel_side(htlc) == side); remove_htlc(cstate, side, !side, htlc); }