channel: assert htlc direction is correct.

The HTLC state encodes the creator; this should match the side argument.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2016-08-18 14:23:45 +09:30
parent 1f99268633
commit 7b2d6925a0

View File

@@ -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);
}