mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 21:35:11 +01:00
JSON: remove handling of pre-Adelaide (B:T:N) short_channel_ids.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
714e7fb670
commit
acf3952acc
@ -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.
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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++;
|
||||
}
|
||||
|
@ -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")) {
|
||||
|
@ -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)
|
||||
|
@ -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),
|
||||
|
@ -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)
|
||||
|
@ -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,
|
||||
|
@ -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)
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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 *
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user