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 <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2026-01-07 16:12:41 +10:30
parent 94e3c1502f
commit 03025469be

View File

@@ -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);