diff --git a/doc/PLUGINS.md b/doc/PLUGINS.md index cfb9a6c03..644f3a254 100644 --- a/doc/PLUGINS.md +++ b/doc/PLUGINS.md @@ -1212,7 +1212,7 @@ The payload for a call follows this format: ```json { "peer_id": "02df5ffe895c778e10f7742a6c5b8a0cefbe9465df58b92fadeb883752c8107c8f", - "message": "1337ffffffff" + "payload": "1337ffffffff" } ``` diff --git a/lightningd/peer_control.c b/lightningd/peer_control.c index 7f87bf549..086b21821 100644 --- a/lightningd/peer_control.c +++ b/lightningd/peer_control.c @@ -2454,7 +2454,16 @@ static void custommsg_final(struct custommsg_payload *payload STEALS) static void custommsg_payload_serialize(struct custommsg_payload *payload, struct json_stream *stream) { - json_add_hex_talarr(stream, "message", payload->msg); + if (deprecated_apis) { + json_add_hex_talarr(stream, "message", payload->msg); + json_add_string( + stream, "warning", + "The `message` field is deprecated and has been replaced " + "with the payload` field which skips the internal type and " + "the length prefix. Please update to use that instead."); + } + json_add_hex(stream, "payload", payload->msg + 4, + tal_bytelen(payload->msg) - 4); json_add_node_id(stream, "peer_id", &payload->peer_id); } diff --git a/tests/plugins/custommsg_a.py b/tests/plugins/custommsg_a.py index fcc7ac133..731adb144 100755 --- a/tests/plugins/custommsg_a.py +++ b/tests/plugins/custommsg_a.py @@ -5,9 +5,9 @@ plugin = Plugin() @plugin.hook('custommsg') -def on_custommsg(peer_id, message, plugin, **kwargs): +def on_custommsg(peer_id, payload, plugin, message=None, **kwargs): plugin.log("Got custommessage_a {msg} from peer {peer_id}".format( - msg=message, + msg=payload, peer_id=peer_id )) return {'result': 'continue'} diff --git a/tests/plugins/custommsg_b.py b/tests/plugins/custommsg_b.py index 3f9ab307b..6282701f4 100755 --- a/tests/plugins/custommsg_b.py +++ b/tests/plugins/custommsg_b.py @@ -5,9 +5,9 @@ plugin = Plugin() @plugin.hook('custommsg') -def on_custommsg(peer_id, message, plugin, **kwargs): +def on_custommsg(peer_id, payload, plugin, message=None, **kwargs): plugin.log("Got custommessage_b {msg} from peer {peer_id}".format( - msg=message, + msg=payload, peer_id=peer_id )) return {'result': 'continue'} diff --git a/tests/test_misc.py b/tests/test_misc.py index ee2d6415f..11a472c80 100644 --- a/tests/test_misc.py +++ b/tests/test_misc.py @@ -2284,10 +2284,10 @@ def test_sendcustommsg(node_factory): ) l1.daemon.wait_for_log(r'\[IN\] {}'.format(serialized)) l1.daemon.wait_for_logs([ - r'Got custommessage_a {serialized} from peer {peer_id}'.format( - serialized=serialized, peer_id=l2.info['id']), - r'Got custommessage_b {serialized} from peer {peer_id}'.format( - serialized=serialized, peer_id=l2.info['id']) + r'Got custommessage_a {msg} from peer {peer_id}'.format( + msg=msg, peer_id=l2.info['id']), + r'Got custommessage_b {msg} from peer {peer_id}'.format( + msg=msg, peer_id=l2.info['id']) ]) # This should work since the peer is currently owned by `openingd` @@ -2299,10 +2299,10 @@ def test_sendcustommsg(node_factory): ) l4.daemon.wait_for_log(r'\[IN\] {}'.format(serialized)) l4.daemon.wait_for_logs([ - r'Got custommessage_a {serialized} from peer {peer_id}'.format( - serialized=serialized, peer_id=l2.info['id']), - r'Got custommessage_b {serialized} from peer {peer_id}'.format( - serialized=serialized, peer_id=l2.info['id']), + r'Got custommessage_a {msg} from peer {peer_id}'.format( + msg=msg, peer_id=l2.info['id']), + r'Got custommessage_b {msg} from peer {peer_id}'.format( + msg=msg, peer_id=l2.info['id']), ]) diff --git a/wallet/db_postgres_sqlgen.c b/wallet/db_postgres_sqlgen.c index a805cdcb7..7707b9dd4 100644 --- a/wallet/db_postgres_sqlgen.c +++ b/wallet/db_postgres_sqlgen.c @@ -1792,4 +1792,4 @@ struct db_query db_postgres_queries[] = { #endif /* LIGHTNINGD_WALLET_GEN_DB_POSTGRES */ -// SHA256STAMP:d5554774287ded802c96fc975565e5557e5f7e174fea04ad7ec080400a15992b +// SHA256STAMP:759b19435d68328d597f6540e1f4f8c42ce22ef91dbf66c1098de0434462546c diff --git a/wallet/db_sqlite3_sqlgen.c b/wallet/db_sqlite3_sqlgen.c index 600791b57..4212510f4 100644 --- a/wallet/db_sqlite3_sqlgen.c +++ b/wallet/db_sqlite3_sqlgen.c @@ -1792,4 +1792,4 @@ struct db_query db_sqlite3_queries[] = { #endif /* LIGHTNINGD_WALLET_GEN_DB_SQLITE3 */ -// SHA256STAMP:d5554774287ded802c96fc975565e5557e5f7e174fea04ad7ec080400a15992b +// SHA256STAMP:759b19435d68328d597f6540e1f4f8c42ce22ef91dbf66c1098de0434462546c diff --git a/wallet/statements_gettextgen.po b/wallet/statements_gettextgen.po index fbed496ec..5a7b1ac35 100644 --- a/wallet/statements_gettextgen.po +++ b/wallet/statements_gettextgen.po @@ -1178,7 +1178,7 @@ msgstr "" msgid "not a valid SQL statement" msgstr "" -#: wallet/test/run-wallet.c:1395 +#: wallet/test/run-wallet.c:1399 msgid "INSERT INTO channels (id) VALUES (1);" msgstr "" -# SHA256STAMP:6aef0052df3b7141edbb7af83a1242a31af18b55aed8e14ca5ede7d783f86309 +# SHA256STAMP:c51857ae4385dd151d6a60f5ce99a5227a9a0cd01a66e0507bb81c04db07c39e diff --git a/wallet/test/run-wallet.c b/wallet/test/run-wallet.c index 04d23ebf9..6a1520573 100644 --- a/wallet/test/run-wallet.c +++ b/wallet/test/run-wallet.c @@ -272,6 +272,10 @@ void json_add_amount_sat_compat(struct json_stream *result UNNEEDED, void json_add_bool(struct json_stream *result UNNEEDED, const char *fieldname UNNEEDED, bool value UNNEEDED) { fprintf(stderr, "json_add_bool called!\n"); abort(); } +/* Generated stub for json_add_hex */ +void json_add_hex(struct json_stream *result UNNEEDED, const char *fieldname UNNEEDED, + const void *data UNNEEDED, size_t len UNNEEDED) +{ fprintf(stderr, "json_add_hex called!\n"); abort(); } /* Generated stub for json_add_hex_talarr */ void json_add_hex_talarr(struct json_stream *result UNNEEDED, const char *fieldname UNNEEDED,