Skip to content

Commit f5ce32d

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 d688023 commit f5ce32d

File tree

12 files changed

+35
-25
lines changed

12 files changed

+35
-25
lines changed

cln-grpc/proto/node.proto

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cln-grpc/src/convert.rs

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cln-rpc/src/notifications.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,8 @@ impl ToString for ChannelStateChangedCause {
192192

193193
#[derive(Clone, Debug, Deserialize, Serialize)]
194194
pub struct ChannelStateChangedNotification {
195+
#[serde(skip_serializing_if = "Option::is_none")]
196+
pub message: Option<String>,
195197
#[serde(skip_serializing_if = "Option::is_none")]
196198
pub old_state: Option<ChannelState>,
197199
#[serde(skip_serializing_if = "Option::is_none")]
@@ -201,7 +203,6 @@ pub struct ChannelStateChangedNotification {
201203
// Path `channel_state_changed.new_state`
202204
pub new_state: ChannelState,
203205
pub channel_id: Sha256,
204-
pub message: String,
205206
pub peer_id: PublicKey,
206207
pub timestamp: String,
207208
}

common/json_stream.c

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

326-
void json_add_null(struct json_stream *stream, const char *fieldname)
327-
{
328-
json_add_primitive(stream, fieldname, "null");
329-
}
330-
331326
void json_add_hex(struct json_stream *js, const char *fieldname,
332327
const void *data, size_t len)
333328
{

common/json_stream.h

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

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

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

contrib/msggen/msggen/schema.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36286,8 +36286,7 @@
3628636286
"channel_id",
3628736287
"timestamp",
3628836288
"new_state",
36289-
"cause",
36290-
"message"
36289+
"cause"
3629136290
],
3629236291
"properties": {
3629336292
"peer_id": {

contrib/pyln-grpc-proto/pyln/grpc/node_pb2.py

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

doc/developers-guide/deprecated-features.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ hidden: false
2424
| channel_state_changed.null_scid | Notification Field | v25.09 | v26.09 | In channel_state_changed notification, `short_channel_id` will be missing instead of `null` |
2525
| notification.payload | Notification Field | v25.09 | v26.09 | Notifications from plugins used to have fields in `payload` sub-object, now they are not (just like normal notifications) |
2626
| 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 |
27+
| channel_state_changed.null_message | Notification Field | v25.12 | v26.12 | In channel_state_changed notification, `message` will be missing instead of `null` |
2728

2829
Inevitably there are features which need to change: either to be generalized, or removed when they can no longer be supported.
2930

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
@@ -275,6 +275,12 @@ void notify_channel_opened(struct lightningd *ld,
275275
notify_send(ld, n);
276276
}
277277

278+
/* Don't use this: omit fields instead! */
279+
static void json_add_null(struct json_stream *stream, const char *fieldname)
280+
{
281+
json_add_primitive(stream, fieldname, "null");
282+
}
283+
278284
static void channel_state_changed_notification_serialize(struct json_stream *stream,
279285
struct lightningd *ld,
280286
const struct node_id *peer_id,
@@ -304,8 +310,12 @@ static void channel_state_changed_notification_serialize(struct json_stream *str
304310
json_add_string(stream, "cause", channel_change_state_reason_str(cause));
305311
if (message != NULL)
306312
json_add_string(stream, "message", message);
307-
else
313+
else if (lightningd_deprecated_out_ok(ld, ld->deprecated_ok,
314+
"channel_state_changed",
315+
"null_message",
316+
"v25.12", "v26.12")) {
308317
json_add_null(stream, "message");
318+
}
309319
}
310320

311321
REGISTER_NOTIFICATION(channel_state_changed)

0 commit comments

Comments
 (0)