From 9c3ac38544f4bdcc407ec6ec5a16b96f7e5d3fe5 Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Tue, 22 Aug 2017 13:19:38 +0200 Subject: [PATCH] lighthningd: Make sure peer->htlcs is initialized When loading from DB the list of htlcs was not being initialized which caused a segfault when the first commit came around, this fixes it. Signed-off-by: Christian Decker --- lightningd/lightningd.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lightningd/lightningd.c b/lightningd/lightningd.c index c90424f44..3fab3401a 100644 --- a/lightningd/lightningd.c +++ b/lightningd/lightningd.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -265,11 +266,14 @@ int main(int argc, char *argv[]) /* Load peers from database */ wallet_channels_load_active(ld->wallet, &ld->peers); + + /* TODO(cdecker) Move this into common location for initialization */ struct peer *peer; list_for_each(&ld->peers, peer, list) { populate_peer(ld, peer); peer->seed = tal(peer, struct privkey); derive_peer_seed(ld, peer->seed, &peer->id, peer->channel->id); + peer->htlcs = tal_arr(peer, struct htlc_stub, 0); } /* Create RPC socket (if any) */