diff --git a/daemon/peer.c b/daemon/peer.c index ade0df1b6..d9dc5facc 100644 --- a/daemon/peer.c +++ b/daemon/peer.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -743,6 +744,31 @@ static void close_depth_cb(struct peer *peer, unsigned int depth, } } +static UNNEEDED struct channel_htlc *htlc_by_index(const struct commit_info *ci, size_t index) +{ + if (ci->map[index] == -1) + return NULL; + + /* First two are non-HTLC outputs to us, them. */ + assert(index >= 2); + index -= 2; + + if (index < tal_count(ci->cstate->a.htlcs)) + return cast_const(struct channel_htlc *, ci->cstate->a.htlcs) + + index; + index -= tal_count(ci->cstate->a.htlcs); + assert(index < tal_count(ci->cstate->b.htlcs)); + return cast_const(struct channel_htlc *, ci->cstate->b.htlcs) + index; +} + +static UNNEEDED bool htlc_a_offered(struct commit_info *ci, size_t index) +{ + assert(index >= 2); + index -= 2; + + return index < tal_count(ci->cstate->a.htlcs); +} + /* We assume the tx is valid! Don't do a blockchain.info and feed this * invalid transactions! */ static void anchor_spent(struct peer *peer,