diff --git a/lightningd/peer_control.c b/lightningd/peer_control.c index 5495a5ff6..facbe3dc9 100644 --- a/lightningd/peer_control.c +++ b/lightningd/peer_control.c @@ -3,7 +3,6 @@ #include "subd.h" #include #include -#include #include #include #include @@ -31,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -530,6 +530,7 @@ void add_peer(struct lightningd *ld, u64 unique_id, = peer->next_index[REMOTE] = peer->num_revocations_received = 0; peer->next_htlc_id = 0; + peer->htlcs = tal_arr(peer, struct htlc_stub, 0); wallet_shachain_init(ld->wallet, &peer->their_shachain); idname = type_to_string(peer, struct pubkey, id); diff --git a/lightningd/peer_control.h b/lightningd/peer_control.h index 5340a531f..084512ed0 100644 --- a/lightningd/peer_control.h +++ b/lightningd/peer_control.h @@ -94,6 +94,9 @@ struct peer { /* Reestablishment stuff: last sent commit and revocation details. */ bool last_was_revoke; struct changed_htlc *last_sent_commit; + + /* FIXME: Just leave this in the db. */ + struct htlc_stub *htlcs; }; static inline bool peer_can_add_htlc(const struct peer *peer) diff --git a/lightningd/peer_htlcs.c b/lightningd/peer_htlcs.c index ee411c0e2..683d3156b 100644 --- a/lightningd/peer_htlcs.c +++ b/lightningd/peer_htlcs.c @@ -1,5 +1,6 @@ #include #include +#include #include #include #include @@ -11,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -80,7 +82,14 @@ static void save_htlc_stub(struct lightningd *ld, u32 cltv_value, const struct sha256 *payment_hash) { - /* FIXME: remember peer, side, cltv and RIPEMD160(hash) */ + size_t n = tal_count(peer->htlcs); + tal_resize(&peer->htlcs, n+1); + peer->htlcs[n].owner = owner; + peer->htlcs[n].cltv_expiry = cltv_value; + ripemd160(&peer->htlcs[n].ripemd, + payment_hash->u.u8, sizeof(payment_hash->u)); + + /* FIXME: save to db instead! */ } static void fail_in_htlc(struct htlc_in *hin,