Skip to content

Commit 7c7f1e4

Browse files
committed
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 <[email protected]>
1 parent 64563c5 commit 7c7f1e4

File tree

6 files changed

+21
-11
lines changed

6 files changed

+21
-11
lines changed

common/json_stream.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -313,11 +313,6 @@ void json_add_bool(struct json_stream *result, const char *fieldname, bool value
313313
json_add_primitive(result, fieldname, value ? "true" : "false");
314314
}
315315

316-
void json_add_null(struct json_stream *stream, const char *fieldname)
317-
{
318-
json_add_primitive(stream, fieldname, "null");
319-
}
320-
321316
void json_add_hex(struct json_stream *js, const char *fieldname,
322317
const void *data, size_t len)
323318
{

common/json_stream.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,7 @@ void json_add_s32(struct json_stream *result, const char *fieldname,
240240
void json_add_bool(struct json_stream *result, const char *fieldname,
241241
bool value);
242242

243-
/* '"fieldname" : null' or 'null' if fieldname is NULL */
244-
void json_add_null(struct json_stream *stream, const char *fieldname);
243+
/* Looking for json_add_null? Don't do that: we omit fields, don't 'null' them! */
245244

246245
/* '"fieldname" : "0189abcdef..."' or "0189abcdef..." if fieldname is NULL */
247246
void json_add_hex(struct json_stream *result, const char *fieldname,

doc/developers-guide/deprecated-features.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ privacy:
2525
| 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 |
2626
| encrypted_hsm | Config | v25.12 | v26.12 | `hsm-passphrase` is a name which also makes sense for modern hsm_secrets which use BIP 39 |
2727
| 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). |
28-
28+
| channel_state_changed.null_message | Notification Field | v25.12 | v26.12 | In channel_state_changed notification, `message` will be missing instead of `null` |
29+
2930
Inevitably there are features which need to change: either to be generalized, or removed when they can no longer be supported.
3031

3132
Types of deprecation:

doc/schemas/notification/channel_state_changed.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515
"channel_id",
1616
"timestamp",
1717
"new_state",
18-
"cause",
19-
"message"
18+
"cause"
2019
],
2120
"properties": {
2221
"peer_id": {

lightningd/notification.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,12 @@ void notify_channel_opened(struct lightningd *ld,
273273
notify_send(ld, n);
274274
}
275275

276+
/* Don't use this: omit fields instead! */
277+
static void json_add_null(struct json_stream *stream, const char *fieldname)
278+
{
279+
json_add_primitive(stream, fieldname, "null");
280+
}
281+
276282
static void channel_state_changed_notification_serialize(struct json_stream *stream,
277283
struct lightningd *ld,
278284
const struct node_id *peer_id,
@@ -302,8 +308,12 @@ static void channel_state_changed_notification_serialize(struct json_stream *str
302308
json_add_string(stream, "cause", channel_change_state_reason_str(cause));
303309
if (message != NULL)
304310
json_add_string(stream, "message", message);
305-
else
311+
else if (lightningd_deprecated_out_ok(ld, ld->deprecated_ok,
312+
"channel_state_changed",
313+
"null_message",
314+
"v25.12", "v26.12")) {
306315
json_add_null(stream, "message");
316+
}
307317
}
308318

309319
REGISTER_NOTIFICATION(channel_state_changed)

plugins/bcli.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,12 @@ static struct command_result *command_err_bcli_badjson(struct bitcoin_cli *bcli,
418418
return command_done_err(bcli->cmd, BCLI_ERROR, err, NULL);
419419
}
420420

421+
/* Don't use this in general: it's better to omit fields. */
422+
static void json_add_null(struct json_stream *stream, const char *fieldname)
423+
{
424+
json_add_primitive(stream, fieldname, "null");
425+
}
426+
421427
static struct command_result *process_getutxout(struct bitcoin_cli *bcli)
422428
{
423429
const jsmntok_t *tokens;

0 commit comments

Comments
 (0)