lightningd: deprecate "message": null in channel_state_changed notifications.

Somehow I missed this when deprecating `short_channel_id` being null.

Changelog-Deprecated: Plugins: `channel_state_changed` notification `message` field being `null`: it will be omitted instead.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2025-11-18 10:11:24 +10:30
parent 64563c51f4
commit 7c7f1e4235
6 changed files with 21 additions and 11 deletions

View File

@@ -313,11 +313,6 @@ void json_add_bool(struct json_stream *result, const char *fieldname, bool value
json_add_primitive(result, fieldname, value ? "true" : "false");
}
void json_add_null(struct json_stream *stream, const char *fieldname)
{
json_add_primitive(stream, fieldname, "null");
}
void json_add_hex(struct json_stream *js, const char *fieldname,
const void *data, size_t len)
{

View File

@@ -240,8 +240,7 @@ void json_add_s32(struct json_stream *result, const char *fieldname,
void json_add_bool(struct json_stream *result, const char *fieldname,
bool value);
/* '"fieldname" : null' or 'null' if fieldname is NULL */
void json_add_null(struct json_stream *stream, const char *fieldname);
/* Looking for json_add_null? Don't do that: we omit fields, don't 'null' them! */
/* '"fieldname" : "0189abcdef..."' or "0189abcdef..." if fieldname is NULL */
void json_add_hex(struct json_stream *result, const char *fieldname,

View File

@@ -25,7 +25,8 @@ privacy:
| pay_notifications.raw_fields | Field | v25.09 | v26.09 | `channel_hint_update`, `pay_failure` and `pay_success` notifications now wrap members in an object of the same name |
| encrypted_hsm | Config | v25.12 | v26.12 | `hsm-passphrase` is a name which also makes sense for modern hsm_secrets which use BIP 39 |
| newaddr.addresstype.defaultbech32 | Parameter | v25.12 | v26.12 | Use `p2tr` in the response (present since v23.08 if `addresstype` is `p2tr`, and always present since v24.12). |
| channel_state_changed.null_message | Notification Field | v25.12 | v26.12 | In channel_state_changed notification, `message` will be missing instead of `null` |
Inevitably there are features which need to change: either to be generalized, or removed when they can no longer be supported.
Types of deprecation:

View File

@@ -15,8 +15,7 @@
"channel_id",
"timestamp",
"new_state",
"cause",
"message"
"cause"
],
"properties": {
"peer_id": {

View File

@@ -273,6 +273,12 @@ void notify_channel_opened(struct lightningd *ld,
notify_send(ld, n);
}
/* Don't use this: omit fields instead! */
static void json_add_null(struct json_stream *stream, const char *fieldname)
{
json_add_primitive(stream, fieldname, "null");
}
static void channel_state_changed_notification_serialize(struct json_stream *stream,
struct lightningd *ld,
const struct node_id *peer_id,
@@ -302,8 +308,12 @@ static void channel_state_changed_notification_serialize(struct json_stream *str
json_add_string(stream, "cause", channel_change_state_reason_str(cause));
if (message != NULL)
json_add_string(stream, "message", message);
else
else if (lightningd_deprecated_out_ok(ld, ld->deprecated_ok,
"channel_state_changed",
"null_message",
"v25.12", "v26.12")) {
json_add_null(stream, "message");
}
}
REGISTER_NOTIFICATION(channel_state_changed)

View File

@@ -418,6 +418,12 @@ static struct command_result *command_err_bcli_badjson(struct bitcoin_cli *bcli,
return command_done_err(bcli->cmd, BCLI_ERROR, err, NULL);
}
/* Don't use this in general: it's better to omit fields. */
static void json_add_null(struct json_stream *stream, const char *fieldname)
{
json_add_primitive(stream, fieldname, "null");
}
static struct command_result *process_getutxout(struct bitcoin_cli *bcli)
{
const jsmntok_t *tokens;