From 2dc86bf29b3b8c3134aad3915a74849041f30bab Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Thu, 28 Apr 2022 17:58:15 +0200 Subject: [PATCH] db: Store the alias if that's all we got in a forward --- wallet/wallet.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/wallet/wallet.c b/wallet/wallet.c index a6355a62e..ddd0de046 100644 --- a/wallet/wallet.c +++ b/wallet/wallet.c @@ -4334,6 +4334,7 @@ void wallet_forwarded_payment_add(struct wallet *w, const struct htlc_in *in, { struct db_stmt *stmt; struct timeabs *resolved_time; + struct channel *outchan; if (state == FORWARD_SETTLED || state == FORWARD_FAILED) { resolved_time = tal(tmpctx, struct timeabs); @@ -4362,8 +4363,18 @@ void wallet_forwarded_payment_add(struct wallet *w, const struct htlc_in *in, db_bind_u64(stmt, 0, in->dbid); if (out) { + outchan = out->key.channel; db_bind_u64(stmt, 1, out->dbid); - db_bind_u64(stmt, 3, out->key.channel->scid->u64); + + /* IF we forward we must have a name for this + * channel. It can be either a locally assigned alias, + * or the real scid. */ + assert(outchan->scid != NULL || outchan->alias[LOCAL]); + if (out->key.channel->scid) + db_bind_u64(stmt, 3, outchan->scid->u64); + else + db_bind_u64(stmt, 3, outchan->alias[LOCAL]->u64); + db_bind_amount_msat(stmt, 5, &out->msat); } else { /* FORWARD_LOCAL_FAILED may occur before we get htlc_out */