Skip to content

Commit

Permalink
feat(main): Print channel status when loading it from DB
Browse files Browse the repository at this point in the history
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
  • Loading branch information
cdecker committed Jun 22, 2024
1 parent e21b70c commit 001b190
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
3 changes: 3 additions & 0 deletions wallet/test/run-db.c
Original file line number Diff line number Diff line change
Expand Up @@ -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(); }
Expand Down
1 change: 1 addition & 0 deletions wallet/test/run-wallet.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 3 additions & 1 deletion wallet/wallet.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 001b190

Please sign in to comment.