diff --git a/CHANGELOG.md b/CHANGELOG.md index fc53ebfd6..ab0f12aac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,8 @@ changes. ### Removed +- JSON API: `short_channel_id` parameters in JSON commands with `:` separators (deprecated since 0.7.0). + ### Fixed - Relative `--lightning_dir` is now working again. diff --git a/bitcoin/short_channel_id.c b/bitcoin/short_channel_id.c index ee3d2e833..f2f9140bc 100644 --- a/bitcoin/short_channel_id.c +++ b/bitcoin/short_channel_id.c @@ -37,8 +37,7 @@ bool mk_short_channel_id(struct short_channel_id *scid, } bool short_channel_id_from_str(const char *str, size_t strlen, - struct short_channel_id *dst, - bool may_be_deprecated_form) + struct short_channel_id *dst) { u32 blocknum, txnum; u16 outnum; @@ -48,15 +47,7 @@ bool short_channel_id_from_str(const char *str, size_t strlen, memcpy(buf, str, strlen); buf[strlen] = 0; -#ifdef COMPAT_V062 - /* Pre-adelaide format vs. post-adelaide format */ - if (may_be_deprecated_form && strchr(buf, ':')) - matches = sscanf(buf, "%u:%u:%hu", &blocknum, &txnum, &outnum); - else - matches = sscanf(buf, "%ux%ux%hu", &blocknum, &txnum, &outnum); -#else matches = sscanf(buf, "%ux%ux%hu", &blocknum, &txnum, &outnum); -#endif return matches == 3 && mk_short_channel_id(dst, blocknum, txnum, outnum); } @@ -70,14 +61,12 @@ char *short_channel_id_to_str(const tal_t *ctx, const struct short_channel_id *s } bool short_channel_id_dir_from_str(const char *str, size_t strlen, - struct short_channel_id_dir *scidd, - bool may_be_deprecated_form) + struct short_channel_id_dir *scidd) { const char *slash = memchr(str, '/', strlen); if (!slash || slash + 2 != str + strlen) return false; - if (!short_channel_id_from_str(str, slash - str, &scidd->scid, - may_be_deprecated_form)) + if (!short_channel_id_from_str(str, slash - str, &scidd->scid)) return false; if (slash[1] == '0') scidd->dir = 0; diff --git a/bitcoin/short_channel_id.h b/bitcoin/short_channel_id.h index 4e0a25441..bcf2ef38d 100644 --- a/bitcoin/short_channel_id.h +++ b/bitcoin/short_channel_id.h @@ -51,16 +51,13 @@ static inline u16 short_channel_id_outnum(const struct short_channel_id *scid) bool WARN_UNUSED_RESULT mk_short_channel_id(struct short_channel_id *scid, u64 blocknum, u64 txnum, u64 outnum); -/* may_be_deprecated_form allows : separators if COMPAT defined */ bool WARN_UNUSED_RESULT short_channel_id_from_str(const char *str, size_t strlen, - struct short_channel_id *dst, - bool may_be_deprecated_form); + struct short_channel_id *dst); char *short_channel_id_to_str(const tal_t *ctx, const struct short_channel_id *scid); bool WARN_UNUSED_RESULT short_channel_id_dir_from_str(const char *str, size_t strlen, - struct short_channel_id_dir *scidd, - bool may_be_deprecated_form); + struct short_channel_id_dir *scidd); char *short_channel_id_dir_to_str(const tal_t *ctx, const struct short_channel_id_dir *scidd); diff --git a/common/json_helpers.c b/common/json_helpers.c index 7664fa67f..0878be2ff 100644 --- a/common/json_helpers.c +++ b/common/json_helpers.c @@ -71,12 +71,10 @@ bool json_to_sat_or_all(const char *buffer, const jsmntok_t *tok, } bool json_to_short_channel_id(const char *buffer, const jsmntok_t *tok, - struct short_channel_id *scid, - bool may_be_deprecated_form) + struct short_channel_id *scid) { return (short_channel_id_from_str(buffer + tok->start, - tok->end - tok->start, scid, - may_be_deprecated_form)); + tok->end - tok->start, scid)); } bool json_to_txid(const char *buffer, const jsmntok_t *tok, diff --git a/common/json_helpers.h b/common/json_helpers.h index b3b21f713..68b29dc31 100644 --- a/common/json_helpers.h +++ b/common/json_helpers.h @@ -25,8 +25,7 @@ bool json_to_bitcoin_amount(const char *buffer, const jsmntok_t *tok, /* Extract a short_channel_id from this */ bool json_to_short_channel_id(const char *buffer, const jsmntok_t *tok, - struct short_channel_id *scid, - bool may_be_deprecated_form); + struct short_channel_id *scid); /* Extract a satoshis amount from this */ bool json_to_sat(const char *buffer, const jsmntok_t *tok, diff --git a/devtools/create-gossipstore.c b/devtools/create-gossipstore.c index d6a38a310..5cc0b0323 100644 --- a/devtools/create-gossipstore.c +++ b/devtools/create-gossipstore.c @@ -43,7 +43,7 @@ static struct scidsat *load_csv_file(FILE *scidf) err(1, "reading 'scid ,satoshis' from csv failed"); while(fscanf(scidf, "%s ,%"SCNu64"\n", str, &scidsats[i].sat.satoshis) == 2 ) { /* Raw: read from file */ - if (!short_channel_id_from_str(str, strlen(str), &scidsats[i].scid, 0)) + if (!short_channel_id_from_str(str, strlen(str), &scidsats[i].scid)) err(1, "failed to make scid struct"); i++; } diff --git a/gossipd/test/run-extended-info.c b/gossipd/test/run-extended-info.c index 1a6d09ec2..dbee24681 100644 --- a/gossipd/test/run-extended-info.c +++ b/gossipd/test/run-extended-info.c @@ -567,7 +567,7 @@ static u8 *get_scid_array(const tal_t *ctx, encoding = json_get_member(test_vector, scids, "encoding"); json_for_each_arr(i, t, arr) { struct short_channel_id scid; - assert(json_to_short_channel_id(test_vector, t, &scid, false)); + assert(json_to_short_channel_id(test_vector, t, &scid)); encoding_add_short_channel_id(&encoded, &scid); } if (json_tok_streq(test_vector, encoding, "UNCOMPRESSED")) { diff --git a/gossipd/test/run-find_route-specific.c b/gossipd/test/run-find_route-specific.c index 926775d91..5f670f993 100644 --- a/gossipd/test/run-find_route-specific.c +++ b/gossipd/test/run-find_route-specific.c @@ -76,8 +76,7 @@ get_or_make_connection(struct routing_state *rstate, struct chan *chan; const int idx = node_id_idx(from_id, to_id); - if (!short_channel_id_from_str(shortid, strlen(shortid), &scid, - false)) + if (!short_channel_id_from_str(shortid, strlen(shortid), &scid)) abort(); chan = get_channel(rstate, &scid); if (!chan) diff --git a/lightningd/gossip_control.c b/lightningd/gossip_control.c index 021c1dd98..caf2d6b03 100644 --- a/lightningd/gossip_control.c +++ b/lightningd/gossip_control.c @@ -353,8 +353,7 @@ static struct command_result *json_getroute(struct command *cmd, json_for_each_arr(i, t, excludetok) { if (!short_channel_id_dir_from_str(buffer + t->start, t->end - t->start, - &excluded[i], - deprecated_apis)) { + &excluded[i])) { return command_fail(cmd, JSONRPC2_INVALID_PARAMS, "%.*s is not a valid" " short_channel_id/direction", @@ -548,8 +547,7 @@ static struct command_result *json_dev_query_scids(struct command *cmd, scids = tal_arr(cmd, struct short_channel_id, scidstok->size); json_for_each_arr(i, t, scidstok) { - if (!json_to_short_channel_id(buffer, t, &scids[i], - deprecated_apis)) { + if (!json_to_short_channel_id(buffer, t, &scids[i])) { return command_fail(cmd, JSONRPC2_INVALID_PARAMS, "scid %zu '%.*s' is not an scid", i, json_tok_full_len(t), diff --git a/lightningd/invoice.c b/lightningd/invoice.c index b26a95d08..c021e0048 100644 --- a/lightningd/invoice.c +++ b/lightningd/invoice.c @@ -567,8 +567,7 @@ static struct route_info *unpack_route(const tal_t *ctx, if (!json_to_node_id(buffer, pubkey, &r->pubkey) || !json_to_short_channel_id(buffer, scid, - &r->short_channel_id, - deprecated_apis) + &r->short_channel_id) || !json_to_number(buffer, fee_base, &r->fee_base_msat) || !json_to_number(buffer, fee_prop, &r->fee_proportional_millionths) diff --git a/lightningd/json.c b/lightningd/json.c index bbc533a2c..f811c6e3e 100644 --- a/lightningd/json.c +++ b/lightningd/json.c @@ -140,8 +140,7 @@ struct command_result *param_short_channel_id(struct command *cmd, struct short_channel_id **scid) { *scid = tal(cmd, struct short_channel_id); - if (json_to_short_channel_id(buffer, tok, *scid, - deprecated_apis)) + if (json_to_short_channel_id(buffer, tok, *scid)) return NULL; return command_fail(cmd, JSONRPC2_INVALID_PARAMS, diff --git a/lightningd/peer_control.c b/lightningd/peer_control.c index abddb3a04..03977275e 100644 --- a/lightningd/peer_control.c +++ b/lightningd/peer_control.c @@ -1194,8 +1194,7 @@ command_find_channel(struct command *cmd, "Channel ID not found: '%.*s'", tok->end - tok->start, buffer + tok->start); - } else if (json_to_short_channel_id(buffer, tok, &scid, - deprecated_apis)) { + } else if (json_to_short_channel_id(buffer, tok, &scid)) { list_for_each(&ld->peers, peer, list) { *channel = peer_active_channel(peer); if (!*channel) diff --git a/lightningd/test/run-invoice-select-inchan.c b/lightningd/test/run-invoice-select-inchan.c index b74078fbd..7f5272783 100644 --- a/lightningd/test/run-invoice-select-inchan.c +++ b/lightningd/test/run-invoice-select-inchan.c @@ -249,8 +249,7 @@ bool json_to_node_id(const char *buffer UNNEEDED, const jsmntok_t *tok UNNEEDED, { fprintf(stderr, "json_to_node_id called!\n"); abort(); } /* Generated stub for json_to_short_channel_id */ bool json_to_short_channel_id(const char *buffer UNNEEDED, const jsmntok_t *tok UNNEEDED, - struct short_channel_id *scid UNNEEDED, - bool may_be_deprecated_form UNNEEDED) + struct short_channel_id *scid UNNEEDED) { fprintf(stderr, "json_to_short_channel_id called!\n"); abort(); } /* Generated stub for kill_uncommitted_channel */ void kill_uncommitted_channel(struct uncommitted_channel *uc UNNEEDED, diff --git a/lightningd/test/run-jsonrpc.c b/lightningd/test/run-jsonrpc.c index 6c1b14e67..018e027f8 100644 --- a/lightningd/test/run-jsonrpc.c +++ b/lightningd/test/run-jsonrpc.c @@ -40,8 +40,7 @@ bool json_to_pubkey(const char *buffer UNNEEDED, const jsmntok_t *tok UNNEEDED, { fprintf(stderr, "json_to_pubkey called!\n"); abort(); } /* Generated stub for json_to_short_channel_id */ bool json_to_short_channel_id(const char *buffer UNNEEDED, const jsmntok_t *tok UNNEEDED, - struct short_channel_id *scid UNNEEDED, - bool may_be_deprecated_form UNNEEDED) + struct short_channel_id *scid UNNEEDED) { fprintf(stderr, "json_to_short_channel_id called!\n"); abort(); } /* Generated stub for json_to_txid */ bool json_to_txid(const char *buffer UNNEEDED, const jsmntok_t *tok UNNEEDED, diff --git a/plugins/pay.c b/plugins/pay.c index 7baba1d53..31ef8bf36 100644 --- a/plugins/pay.c +++ b/plugins/pay.c @@ -196,7 +196,7 @@ static bool channel_in_routehint(const struct route_info *routehint, { struct short_channel_id scid; - if (!short_channel_id_from_str(scidstr, scidlen, &scid, false)) + if (!short_channel_id_from_str(scidstr, scidlen, &scid)) plugin_err("bad erring_channel '%.*s'", (int)scidlen, scidstr); diff --git a/wallet/db.c b/wallet/db.c index 633983ce7..dc4b9cd04 100644 --- a/wallet/db.c +++ b/wallet/db.c @@ -1052,7 +1052,7 @@ bool db_column_short_channel_id(struct db_stmt *stmt, int col, { const char *source = db_column_blob(stmt, col); size_t sourcelen = db_column_bytes(stmt, col); - return short_channel_id_from_str(source, sourcelen, dest, true); + return short_channel_id_from_str(source, sourcelen, dest); } struct short_channel_id * diff --git a/wallet/test/run-wallet.c b/wallet/test/run-wallet.c index 93e4ecb8b..c714f8215 100644 --- a/wallet/test/run-wallet.c +++ b/wallet/test/run-wallet.c @@ -357,8 +357,7 @@ bool json_to_preimage(const char *buffer UNNEEDED, const jsmntok_t *tok UNNEEDED { fprintf(stderr, "json_to_preimage called!\n"); abort(); } /* Generated stub for json_to_short_channel_id */ bool json_to_short_channel_id(const char *buffer UNNEEDED, const jsmntok_t *tok UNNEEDED, - struct short_channel_id *scid UNNEEDED, - bool may_be_deprecated_form UNNEEDED) + struct short_channel_id *scid UNNEEDED) { fprintf(stderr, "json_to_short_channel_id called!\n"); abort(); } /* Generated stub for kill_uncommitted_channel */ void kill_uncommitted_channel(struct uncommitted_channel *uc UNNEEDED,