From 001b190c618855c1a892e8f7c1dc3eddbc540509 Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Wed, 29 May 2024 11:10:03 +0200 Subject: [PATCH] feat(main): Print channel status when loading it from DB I was trying to debug a node with several multiplexed channels, and was finding it a bit difficult to determine which channel index matches which result of `listpeerchannels` as well as figuring out what their status was. This just prints the status in string format when loading the channel from the DB. Changelog-Changed: wallet: The channel status is printed when loading it from the DB --- wallet/test/run-db.c | 3 +++ wallet/test/run-wallet.c | 1 + wallet/wallet.c | 4 +++- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/wallet/test/run-db.c b/wallet/test/run-db.c index 07620011e410..fc73479c23ae 100644 --- a/wallet/test/run-db.c +++ b/wallet/test/run-db.c @@ -34,6 +34,9 @@ void channel_gossip_update(struct channel *channel UNNEEDED) /* Generated stub for channel_scid_or_local_alias */ struct short_channel_id channel_scid_or_local_alias(const struct channel *chan UNNEEDED) { fprintf(stderr, "channel_scid_or_local_alias called!\n"); abort(); } +/* Generated stub for channel_state_name */ +const char *channel_state_name(const struct channel *channel UNNEEDED) +{ fprintf(stderr, "channel_state_name called!\n"); abort(); } /* Generated stub for connect_htlc_in */ void connect_htlc_in(struct htlc_in_map *map UNNEEDED, struct htlc_in *hin UNNEEDED) { fprintf(stderr, "connect_htlc_in called!\n"); abort(); } diff --git a/wallet/test/run-wallet.c b/wallet/test/run-wallet.c index 9b117b94ba79..ce7691367230 100644 --- a/wallet/test/run-wallet.c +++ b/wallet/test/run-wallet.c @@ -2117,6 +2117,7 @@ static bool test_htlc_crud(struct lightningd *ld, const tal_t *ctx) db_commit_transaction(w->db); chan->dbid = 1; + chan->state = CHANNELD_NORMAL; chan->peer = peer; chan->next_index[LOCAL] = chan->next_index[REMOTE] = 1; diff --git a/wallet/wallet.c b/wallet/wallet.c index 813a2118ce19..5d9a1e564c99 100644 --- a/wallet/wallet.c +++ b/wallet/wallet.c @@ -3194,7 +3194,9 @@ bool wallet_htlcs_load_in_for_channel(struct wallet *wallet, bool ok = true; int incount = 0; - log_debug(wallet->log, "Loading in HTLCs for channel %"PRIu64, chan->dbid); + log_debug(wallet->log, + "Loading in HTLCs for channel %"PRIu64" (state=%s)", + chan->dbid, channel_state_name(chan)); stmt = db_prepare_v2(wallet->db, SQL("SELECT" " id" ", channel_htlc_id"