Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecations and spec updates post-0.12 #5490

Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
2003a1b
test: fix tlvs test in funding_locked tlv.
rustyrussell Sep 10, 2022
1657202
wire/test: neaten and complete tlv checks.
rustyrussell Sep 10, 2022
0bb9cc3
common: remove unused parameter "allow_deprecated" from parse_wireadd…
rustyrussell Sep 10, 2022
e241348
lightningd: remove double-wrapped rpc_command hook.
rustyrussell Sep 10, 2022
986a0c2
lightningd: always require "jsonrpc": "2.0" in request.
rustyrussell Sep 10, 2022
560b7ef
lightningd: don't allow old listforwards arg order.
rustyrussell Sep 10, 2022
13738d1
lightningd: do inline parsing for listforwards status parameter
rustyrussell Sep 10, 2022
c6b2832
plugins: require usage for plugin APIs.
rustyrussell Sep 10, 2022
ffd6b70
lightningd: remove `use_proxy_always` parameter to plugin init.
rustyrussell Sep 10, 2022
185be8d
listchannels: don't show "htlc_maximum_msat" if channel_update didn't…
rustyrussell Sep 10, 2022
b90ba77
offers: update to remove "vendor" and "timestamp" fields.
rustyrussell Sep 10, 2022
258cdf8
offers: remove backwards-compatiblity invoice_request signatures.
rustyrussell Sep 10, 2022
d3a573d
hsmtool: remove hsm_secret passwords on cmdline support in `dumponcha…
rustyrussell Sep 10, 2022
a0eeb0b
devtools/bolt-catchup.sh: a tool to update the specs, one commit at a…
rustyrussell Sep 10, 2022
00bce5e
doc: increase BOLT level to 03468e17563650fb9bfe58b2da4d1e5d28e92009
rustyrussell Sep 10, 2022
4543a7d
doc: update BOLTs to bc86304b4b0af5fd5ce9d24f74e2ebbceb7e2730
rustyrussell Sep 10, 2022
cbb569e
channeld/dualopend/lightningd: use channel_ready everywhere.
rustyrussell Sep 10, 2022
7580973
doc: upgrade to BOLTs 2ecc091f3484f7a3450e7f5543ae851edd1e0761
rustyrussell Sep 10, 2022
4d6efb4
doc: upgrade to BOLTs 341ec844f13c0c0abc4fe849059fbb98173f9766
rustyrussell Sep 10, 2022
380ee93
doc: include recent BOLT recommendation on grace period.
rustyrussell Sep 10, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions common/test/run-ip_port_parsing.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,8 @@ int main(int argc, char *argv[])
assert(!parse_wireaddr("odpzvneidqdf5hdq.onion:49150", &addr, 1, false, NULL));
assert(!parse_wireaddr("odpzvneidqdf5hdq.onion", &addr, 1, false, NULL));

/* Neither allow_deprecated = true nor false will parse it now */
assert(!parse_wireaddr_internal("odpzvneidqdf5hdq.onion", &addr_int, 1,
false, false, false, false, NULL));
assert(!parse_wireaddr_internal("odpzvneidqdf5hdq.onion", &addr_int, 1,
false, false, false, true, NULL));
false, false, false, NULL));

assert(wireaddr_from_hostname(tmpctx, "odpzvneidqdf5hdq.onion", 1, NULL, NULL, NULL) == NULL);
assert(wireaddr_from_hostname(tmpctx, "aaa.onion", 1, NULL, NULL, NULL) == NULL);
Expand Down
36 changes: 18 additions & 18 deletions common/test/run-wireaddr.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,59 +127,59 @@ int main(int argc, char *argv[])

common_setup(argv[0]);
/* Simple IPv4 address. */
assert(parse_wireaddr_internal("127.0.0.1", &addr, DEFAULT_PORT, false, false, false, false, &err));
assert(parse_wireaddr_internal("127.0.0.1", &addr, DEFAULT_PORT, false, false, false, &err));
expect->itype = ADDR_INTERNAL_WIREADDR;
assert(parse_wireaddr("127.0.0.1:9735", &expect->u.wireaddr, 0, NULL, &err));
assert(wireaddr_internal_eq(&addr, expect));

/* IPv4 address with port. */
assert(parse_wireaddr_internal("127.0.0.1:1", &addr, DEFAULT_PORT, false, false, false, false, &err));
assert(parse_wireaddr_internal("127.0.0.1:1", &addr, DEFAULT_PORT, false, false, false, &err));
expect->itype = ADDR_INTERNAL_WIREADDR;
assert(parse_wireaddr("127.0.0.1:1", &expect->u.wireaddr, 0, NULL, &err));
assert(wireaddr_internal_eq(&addr, expect));

/* Simple IPv6 address. */
assert(parse_wireaddr_internal("::1", &addr, DEFAULT_PORT, false, false, false, false, &err));
assert(parse_wireaddr_internal("::1", &addr, DEFAULT_PORT, false, false, false, &err));
expect->itype = ADDR_INTERNAL_WIREADDR;
assert(parse_wireaddr("::1", &expect->u.wireaddr, DEFAULT_PORT, NULL, &err));
assert(wireaddr_internal_eq(&addr, expect));

/* IPv6 address with port. */
assert(parse_wireaddr_internal("[::1]:1", &addr, DEFAULT_PORT, false, false, false, false, &err));
assert(parse_wireaddr_internal("[::1]:1", &addr, DEFAULT_PORT, false, false, false, &err));
expect->itype = ADDR_INTERNAL_WIREADDR;
assert(parse_wireaddr("::1", &expect->u.wireaddr, 1, NULL, &err));
assert(wireaddr_internal_eq(&addr, expect));

/* autotor address */
assert(parse_wireaddr_internal("autotor:127.0.0.1", &addr, DEFAULT_PORT, false, false, false, false, &err));
assert(parse_wireaddr_internal("autotor:127.0.0.1", &addr, DEFAULT_PORT, false, false, false, &err));
expect->itype = ADDR_INTERNAL_AUTOTOR;
expect->u.torservice.port = DEFAULT_PORT;
assert(parse_wireaddr("127.0.0.1", &expect->u.torservice.address, 9051, NULL, &err));
assert(wireaddr_internal_eq(&addr, expect));

/* autotor address with port */
assert(parse_wireaddr_internal("autotor:127.0.0.1:9055", &addr, DEFAULT_PORT, false, false, false, false, &err));
assert(parse_wireaddr_internal("autotor:127.0.0.1:9055", &addr, DEFAULT_PORT, false, false, false, &err));
expect->itype = ADDR_INTERNAL_AUTOTOR;
expect->u.torservice.port = DEFAULT_PORT;
assert(parse_wireaddr("127.0.0.1", &expect->u.torservice.address, 9055, NULL, &err));
assert(wireaddr_internal_eq(&addr, expect));

/* autotor address with torport */
assert(parse_wireaddr_internal("autotor:127.0.0.1/torport=9055", &addr, DEFAULT_PORT, false, false, false, false, &err));
assert(parse_wireaddr_internal("autotor:127.0.0.1/torport=9055", &addr, DEFAULT_PORT, false, false, false, &err));
expect->itype = ADDR_INTERNAL_AUTOTOR;
expect->u.torservice.port = 9055;
assert(parse_wireaddr("127.0.0.1", &expect->u.torservice.address, 9051, NULL, &err));
assert(wireaddr_internal_eq(&addr, expect));

/* autotor address with port and torport */
assert(parse_wireaddr_internal("autotor:127.0.0.1:9055/torport=10055", &addr, DEFAULT_PORT, false, false, false, false, &err));
assert(parse_wireaddr_internal("autotor:127.0.0.1:9055/torport=10055", &addr, DEFAULT_PORT, false, false, false, &err));
expect->itype = ADDR_INTERNAL_AUTOTOR;
expect->u.torservice.port = 10055;
assert(parse_wireaddr("127.0.0.1", &expect->u.torservice.address, 9055, NULL, &err));
assert(wireaddr_internal_eq(&addr, expect));

/* statictor address */
assert(parse_wireaddr_internal("statictor:127.0.0.1", &addr, DEFAULT_PORT, false, false, false, false, &err));
assert(parse_wireaddr_internal("statictor:127.0.0.1", &addr, DEFAULT_PORT, false, false, false, &err));
expect->itype = ADDR_INTERNAL_STATICTOR;
expect->u.torservice.port = DEFAULT_PORT;
memset(expect->u.torservice.blob, 0, sizeof(expect->u.torservice.blob));
Expand All @@ -188,28 +188,28 @@ int main(int argc, char *argv[])
assert(wireaddr_internal_eq(&addr, expect));

/* statictor address with port */
assert(parse_wireaddr_internal("statictor:127.0.0.1:9055", &addr, DEFAULT_PORT, false, false, false, false, &err));
assert(parse_wireaddr_internal("statictor:127.0.0.1:9055", &addr, DEFAULT_PORT, false, false, false, &err));
expect->itype = ADDR_INTERNAL_STATICTOR;
expect->u.torservice.port = DEFAULT_PORT;
assert(parse_wireaddr("127.0.0.1", &expect->u.torservice.address, 9055, NULL, &err));
assert(wireaddr_internal_eq(&addr, expect));

/* statictor address with torport */
assert(parse_wireaddr_internal("statictor:127.0.0.1/torport=9055", &addr, DEFAULT_PORT, false, false, false, false, &err));
assert(parse_wireaddr_internal("statictor:127.0.0.1/torport=9055", &addr, DEFAULT_PORT, false, false, false, &err));
expect->itype = ADDR_INTERNAL_STATICTOR;
expect->u.torservice.port = 9055;
assert(parse_wireaddr("127.0.0.1", &expect->u.torservice.address, 9051, NULL, &err));
assert(wireaddr_internal_eq(&addr, expect));

/* statictor address with port and torport */
assert(parse_wireaddr_internal("statictor:127.0.0.1:9055/torport=10055", &addr, DEFAULT_PORT, false, false, false, false, &err));
assert(parse_wireaddr_internal("statictor:127.0.0.1:9055/torport=10055", &addr, DEFAULT_PORT, false, false, false, &err));
expect->itype = ADDR_INTERNAL_STATICTOR;
expect->u.torservice.port = 10055;
assert(parse_wireaddr("127.0.0.1", &expect->u.torservice.address, 9055, NULL, &err));
assert(wireaddr_internal_eq(&addr, expect));

/* statictor address with port and torport and torblob */
assert(parse_wireaddr_internal("statictor:127.0.0.1:9055/torport=10055/torblob=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", &addr, DEFAULT_PORT, false, false, false, false, &err));
assert(parse_wireaddr_internal("statictor:127.0.0.1:9055/torport=10055/torblob=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", &addr, DEFAULT_PORT, false, false, false, &err));
expect->itype = ADDR_INTERNAL_STATICTOR;
expect->u.torservice.port = 10055;
/* This is actually nul terminated */
Expand All @@ -218,24 +218,24 @@ int main(int argc, char *argv[])
assert(wireaddr_internal_eq(&addr, expect));

/* local socket path */
assert(parse_wireaddr_internal("/tmp/foo.sock", &addr, DEFAULT_PORT, false, false, false, false, &err));
assert(parse_wireaddr_internal("/tmp/foo.sock", &addr, DEFAULT_PORT, false, false, false, &err));
expect->itype = ADDR_INTERNAL_SOCKNAME;
strcpy(expect->u.sockname, "/tmp/foo.sock");
assert(wireaddr_internal_eq(&addr, expect));

/* Unresolved */
assert(!parse_wireaddr_internal("ozlabs.org", &addr, DEFAULT_PORT, false, false, false, false, &err));
assert(!parse_wireaddr_internal("ozlabs.org", &addr, DEFAULT_PORT, false, false, false, &err));
assert(streq(err, "Needed DNS, but lookups suppressed"));
assert(parse_wireaddr_internal("ozlabs.org", &addr, DEFAULT_PORT, false, false, true, false, &err));
assert(parse_wireaddr_internal("ozlabs.org", &addr, DEFAULT_PORT, false, false, true, &err));
expect->itype = ADDR_INTERNAL_FORPROXY;
strcpy(expect->u.unresolved.name, "ozlabs.org");
expect->u.unresolved.port = DEFAULT_PORT;
assert(wireaddr_internal_eq(&addr, expect));

/* Unresolved with port */
assert(!parse_wireaddr_internal("ozlabs.org:1234", &addr, DEFAULT_PORT, false, false, false, false, &err));
assert(!parse_wireaddr_internal("ozlabs.org:1234", &addr, DEFAULT_PORT, false, false, false, &err));
assert(streq(err, "Needed DNS, but lookups suppressed"));
assert(parse_wireaddr_internal("ozlabs.org:1234", &addr, DEFAULT_PORT, false, false, true, false, &err));
assert(parse_wireaddr_internal("ozlabs.org:1234", &addr, DEFAULT_PORT, false, false, true, &err));
expect->itype = ADDR_INTERNAL_FORPROXY;
strcpy(expect->u.unresolved.name, "ozlabs.org");
expect->u.unresolved.port = 1234;
Expand Down
2 changes: 1 addition & 1 deletion common/wireaddr.c
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ bool wireaddr_internal_eq(const struct wireaddr_internal *a,

bool parse_wireaddr_internal(const char *arg, struct wireaddr_internal *addr,
u16 port, bool wildcard_ok, bool dns_ok,
bool unresolved_ok, bool allow_deprecated,
bool unresolved_ok,
const char **err_msg)
{
u16 splitport;
Expand Down
2 changes: 1 addition & 1 deletion common/wireaddr.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ bool is_dnsaddr(const char *arg);

bool parse_wireaddr_internal(const char *arg, struct wireaddr_internal *addr,
u16 port, bool wildcard_ok, bool dns_ok,
bool unresolved_ok, bool allow_deprecated,
bool unresolved_ok,
const char **err_msg);

void towire_wireaddr_internal(u8 **pptr,
Expand Down
2 changes: 1 addition & 1 deletion devtools/gossipwith.c
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ int main(int argc, char *argv[])
(int)(at - argv[1]), argv[1]);

if (!parse_wireaddr_internal(at+1, &addr, chainparams_get_ln_port(chainparams), NULL,
true, false, true, &err_msg))
true, false, &err_msg))
opt_usage_exit_fail("%s '%s'", err_msg, argv[1]);

switch (addr.itype) {
Expand Down
2 changes: 1 addition & 1 deletion lightningd/connect_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ static struct command_result *json_connect(struct command *cmd,
if (!parse_wireaddr_internal(id_addr.host, addr, port, false,
!cmd->ld->always_use_proxy
&& !cmd->ld->pure_tor_setup,
true, deprecated_apis,
true,
&err_msg)) {
return command_fail(cmd, LIGHTNINGD,
"Host %s:%u not valid: %s",
Expand Down
31 changes: 10 additions & 21 deletions lightningd/jsonrpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -664,11 +664,6 @@ static void rpc_command_hook_serialize(struct rpc_command_hook_payload *p,
char *key;
json_object_start(s, "rpc_command");

#ifdef COMPAT_V081
if (deprecated_apis)
json_add_tok(s, "rpc_command", p->request, p->buffer);
#endif

json_for_each_obj(i, tok, p->request) {
key = tal_strndup(NULL, p->buffer + tok->start,
tok->end - tok->start);
Expand All @@ -682,7 +677,7 @@ static void replace_command(struct rpc_command_hook_payload *p,
const char *buffer,
const jsmntok_t *replacetok)
{
const jsmntok_t *method = NULL, *params = NULL;
const jsmntok_t *method = NULL, *params = NULL, *jsonrpc;
const char *bad;

/* Must contain "method", "params" and "id" */
Expand Down Expand Up @@ -714,14 +709,10 @@ static void replace_command(struct rpc_command_hook_payload *p,
goto fail;
}

// deprecated phase to give the possibility to all to migrate and stay safe
// from this more restrictive change.
if (!deprecated_apis) {
const jsmntok_t *jsonrpc = json_get_member(buffer, replacetok, "jsonrpc");
if (!jsonrpc || jsonrpc->type != JSMN_STRING || !json_tok_streq(buffer, jsonrpc, "2.0")) {
bad = "jsonrpc: \"2.0\" must be specified in the request";
goto fail;
}
jsonrpc = json_get_member(buffer, replacetok, "jsonrpc");
if (!jsonrpc || jsonrpc->type != JSMN_STRING || !json_tok_streq(buffer, jsonrpc, "2.0")) {
bad = "jsonrpc: \"2.0\" must be specified in the request";
Copy link
Contributor

@Sjors Sjors Dec 3, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this broke the BTCPay server integration… cc @NicolasDorier

btcpayserver/btcpayserver#4399

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The broken part is the RPC library used inside it

goto fail;
}

was_pending(command_exec(p->cmd->jcon, p->cmd, buffer, replacetok,
Expand Down Expand Up @@ -858,7 +849,7 @@ REGISTER_PLUGIN_HOOK(rpc_command,
static struct command_result *
parse_request(struct json_connection *jcon, const jsmntok_t tok[])
{
const jsmntok_t *method, *id, *params;
const jsmntok_t *method, *id, *params, *jsonrpc;
struct command *c;
struct rpc_command_hook_payload *rpc_hook;
bool completed;
Expand Down Expand Up @@ -886,13 +877,11 @@ parse_request(struct json_connection *jcon, const jsmntok_t tok[])

// Adding a deprecated phase to make sure that all the Core Lightning wrapper
// can migrate all the frameworks
if (!deprecated_apis) {
const jsmntok_t *jsonrpc = json_get_member(jcon->buffer, tok, "jsonrpc");
jsonrpc = json_get_member(jcon->buffer, tok, "jsonrpc");

if (!jsonrpc || jsonrpc->type != JSMN_STRING || !json_tok_streq(jcon->buffer, jsonrpc, "2.0")) {
json_command_malformed(jcon, "null", "jsonrpc: \"2.0\" must be specified in the request");
return NULL;
}
if (!jsonrpc || jsonrpc->type != JSMN_STRING || !json_tok_streq(jcon->buffer, jsonrpc, "2.0")) {
json_command_malformed(jcon, "null", "jsonrpc: \"2.0\" must be specified in the request");
return NULL;
}

/* Allocate the command off of the `jsonrpc` object and not
Expand Down
8 changes: 3 additions & 5 deletions lightningd/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ static char *opt_add_addr_withtype(const char *arg,
|| ala != ADDR_ANNOUNCE) {
if (!parse_wireaddr_internal(arg, &wi, ld->portnum,
wildcard_ok, dns_ok, false,
deprecated_apis, &err_msg)) {
&err_msg)) {
return tal_fmt(NULL, "Unable to parse address '%s': %s", arg, err_msg);
}

Expand Down Expand Up @@ -318,8 +318,7 @@ static char *opt_add_addr(const char *arg, struct lightningd *ld)
struct wireaddr_internal addr;

/* handle in case you used the addr option with an .onion */
if (parse_wireaddr_internal(arg, &addr, 0, true, false, true,
deprecated_apis, NULL)) {
if (parse_wireaddr_internal(arg, &addr, 0, true, false, true, NULL)) {
if (addr.itype == ADDR_INTERNAL_WIREADDR &&
addr.u.wireaddr.type == ADDR_TYPE_TOR_V3) {
log_unusual(ld->log, "You used `--addr=%s` option with an .onion address, please use"
Expand Down Expand Up @@ -365,8 +364,7 @@ static char *opt_add_bind_addr(const char *arg, struct lightningd *ld)
struct wireaddr_internal addr;

/* handle in case you used the bind option with an .onion */
if (parse_wireaddr_internal(arg, &addr, 0, true, false, true,
deprecated_apis, NULL)) {
if (parse_wireaddr_internal(arg, &addr, 0, true, false, true, NULL)) {
if (addr.itype == ADDR_INTERNAL_WIREADDR &&
addr.u.wireaddr.type == ADDR_TYPE_TOR_V3) {
log_unusual(ld->log, "You used `--bind-addr=%s` option with an .onion address,"
Expand Down
6 changes: 3 additions & 3 deletions wallet/test/run-wallet.c
Original file line number Diff line number Diff line change
Expand Up @@ -1098,7 +1098,7 @@ static bool test_wallet_outputs(struct lightningd *ld, const tal_t *ctx)

/* Add another utxo that's CSV-locked for 5 blocks */
parse_wireaddr_internal("localhost:1234", &addr, 0, false, false, false,
true, NULL);
NULL);
channel.peer = new_peer(ld, 0, &id, &addr, false);
channel.dbid = 1;
channel.type = channel_type_anchor_outputs(tmpctx);
Expand Down Expand Up @@ -1395,7 +1395,7 @@ static bool test_channel_crud(struct lightningd *ld, const tal_t *ctx)
mempat(scriptpubkey, tal_count(scriptpubkey));
c1.first_blocknum = 1;
parse_wireaddr_internal("localhost:1234", &addr, 0, false, false, false,
true, NULL);
NULL);
c1.final_key_idx = 1337;
p = new_peer(ld, 0, &id, &addr, false);
c1.peer = p;
Expand Down Expand Up @@ -1558,7 +1558,7 @@ static bool test_channel_inflight_crud(struct lightningd *ld, const tal_t *ctx)
pubkey_from_der(tal_hexdata(w, "02a1633cafcc01ebfb6d78e39f687a1f0995c62fc95f51ead10a02ee0be551b5dc", 66), 33, &pk);
node_id_from_pubkey(&id, &pk);
parse_wireaddr_internal("localhost:1234", &addr, 0, false, false, false,
true, NULL);
NULL);

/* new channel! */
p = new_peer(ld, 0, &id, &addr, false);
Expand Down
4 changes: 2 additions & 2 deletions wallet/wallet.c
Original file line number Diff line number Diff line change
Expand Up @@ -839,11 +839,11 @@ static struct peer *wallet_peer_load(struct wallet *w, const u64 dbid)
/* This can happen for peers last seen on Torv2! */
addrstr = db_col_strdup(tmpctx, stmt, "address");
if (!parse_wireaddr_internal(addrstr, &addr, chainparams_get_ln_port(chainparams),
false, false, true, true, NULL)) {
false, false, true, NULL)) {
log_unusual(w->log, "Unparsable peer address %s: replacing",
addrstr);
parse_wireaddr_internal("127.0.0.1:1", &addr, chainparams_get_ln_port(chainparams),
false, false, true, true, NULL);
false, false, true, NULL);
}

/* FIXME: save incoming in db! */
Expand Down
Loading