diff --git a/lightningd/htlc_end.c b/lightningd/htlc_end.c index c6d17709b..acf9d180e 100644 --- a/lightningd/htlc_end.c +++ b/lightningd/htlc_end.c @@ -150,6 +150,7 @@ struct htlc_out *new_htlc_out(const tal_t *ctx, hout->dbid = 0; hout->key.peer = peer; + hout->key.id = HTLC_INVALID_ID; hout->msatoshi = msatoshi; hout->cltv_expiry = cltv_expiry; hout->payment_hash = *payment_hash; diff --git a/lightningd/htlc_end.h b/lightningd/htlc_end.h index 9e41375df..140300c7b 100644 --- a/lightningd/htlc_end.h +++ b/lightningd/htlc_end.h @@ -13,6 +13,8 @@ struct htlc_key { u64 id; }; +#define HTLC_INVALID_ID (-1ULL) + /* Incoming HTLC */ struct htlc_in { /* The database primary key for this htlc. Must be 0 until it diff --git a/lightningd/peer_htlcs.c b/lightningd/peer_htlcs.c index ab15745b2..0d98685d6 100644 --- a/lightningd/peer_htlcs.c +++ b/lightningd/peer_htlcs.c @@ -352,7 +352,8 @@ static void rcvd_htlc_reply(struct subd *subd, const u8 *msg, const int *fds, return; } - if (find_htlc_out(&subd->ld->htlcs_out, hout->key.peer, hout->key.id)) { + if (find_htlc_out(&subd->ld->htlcs_out, hout->key.peer, hout->key.id) + || hout->key.id == HTLC_INVALID_ID) { peer_internal_error(subd->peer, "Bad offer_htlc_reply HTLC id %"PRIu64 " is a duplicate",