From 03025469be8d607b978e80aa68fd975f8d87c2af Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Wed, 7 Jan 2026 16:12:41 +1030 Subject: [PATCH] pay: don't notify using uninitialized hint field. Rather than break the API, use total capacity here. ``` Valgrind error file: valgrind-errors.5880 ==5880== Use of uninitialised value of size 8 ==5880== at 0x4A390BB: _itoa_word (_itoa.c:183) ==5880== by 0x4A43C9B: __printf_buffer (vfprintf-process-arg.c:155) ==5880== by 0x4A69D90: vsnprintf (vsnprintf.c:96) ==5880== by 0x1875E6: json_out_addv (json_out.c:239) ==5880== by 0x14471E: json_add_primitive_fmt (json_stream.c:170) ==5880== by 0x144BA2: json_add_u64 (json_stream.c:282) ==5880== by 0x145E33: json_add_amount_msat (json_stream.c:619) ==5880== by 0x11DDE2: channel_hint_to_json (channel_hint.c:33) ==5880== by 0x11FE9F: channel_hint_notify_core (libplugin-pay.c:394) ==5880== by 0x11FF7A: channel_hint_notify (libplugin-pay.c:412) ==5880== by 0x1201EA: channel_hints_update (libplugin-pay.c:455) ==5880== by 0x122DAF: handle_intermediate_failure (libplugin-pay.c:1437) ==5880== ``` Signed-off-by: Rusty Russell --- plugins/channel_hint.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/plugins/channel_hint.c b/plugins/channel_hint.c index 4862832d8..299c605d6 100644 --- a/plugins/channel_hint.c +++ b/plugins/channel_hint.c @@ -30,8 +30,14 @@ void channel_hint_to_json(const char *name, const struct channel_hint *hint, json_object_start(dest, name); json_add_u32(dest, "timestamp", hint->timestamp); json_add_short_channel_id_dir(dest, "scid", hint->scid); - json_add_amount_msat(dest, "estimated_capacity_msat", - hint->estimated_capacity); + /* The estimated_capacity is unset if it's not enabled; use total_capacity */ + if (hint->enabled) { + json_add_amount_msat(dest, "estimated_capacity_msat", + hint->estimated_capacity); + } else { + json_add_amount_msat(dest, "estimated_capacity_msat", + hint->capacity); + } json_add_amount_msat(dest, "total_capacity_msat", hint->capacity); json_add_bool(dest, "enabled", hint->enabled); json_object_end(dest);