mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 07:04:22 +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:
committed by
Christian Decker
parent
714e7fb670
commit
acf3952acc
@@ -22,6 +22,8 @@ changes.
|
|||||||
|
|
||||||
### Removed
|
### Removed
|
||||||
|
|
||||||
|
- JSON API: `short_channel_id` parameters in JSON commands with `:` separators (deprecated since 0.7.0).
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- Relative `--lightning_dir` is now working again.
|
- 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,
|
bool short_channel_id_from_str(const char *str, size_t strlen,
|
||||||
struct short_channel_id *dst,
|
struct short_channel_id *dst)
|
||||||
bool may_be_deprecated_form)
|
|
||||||
{
|
{
|
||||||
u32 blocknum, txnum;
|
u32 blocknum, txnum;
|
||||||
u16 outnum;
|
u16 outnum;
|
||||||
@@ -48,15 +47,7 @@ bool short_channel_id_from_str(const char *str, size_t strlen,
|
|||||||
memcpy(buf, str, strlen);
|
memcpy(buf, str, strlen);
|
||||||
buf[strlen] = 0;
|
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);
|
matches = sscanf(buf, "%ux%ux%hu", &blocknum, &txnum, &outnum);
|
||||||
#endif
|
|
||||||
return matches == 3
|
return matches == 3
|
||||||
&& mk_short_channel_id(dst, blocknum, txnum, outnum);
|
&& 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,
|
bool short_channel_id_dir_from_str(const char *str, size_t strlen,
|
||||||
struct short_channel_id_dir *scidd,
|
struct short_channel_id_dir *scidd)
|
||||||
bool may_be_deprecated_form)
|
|
||||||
{
|
{
|
||||||
const char *slash = memchr(str, '/', strlen);
|
const char *slash = memchr(str, '/', strlen);
|
||||||
if (!slash || slash + 2 != str + strlen)
|
if (!slash || slash + 2 != str + strlen)
|
||||||
return false;
|
return false;
|
||||||
if (!short_channel_id_from_str(str, slash - str, &scidd->scid,
|
if (!short_channel_id_from_str(str, slash - str, &scidd->scid))
|
||||||
may_be_deprecated_form))
|
|
||||||
return false;
|
return false;
|
||||||
if (slash[1] == '0')
|
if (slash[1] == '0')
|
||||||
scidd->dir = 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,
|
bool WARN_UNUSED_RESULT mk_short_channel_id(struct short_channel_id *scid,
|
||||||
u64 blocknum, u64 txnum, u64 outnum);
|
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,
|
bool WARN_UNUSED_RESULT short_channel_id_from_str(const char *str, size_t strlen,
|
||||||
struct short_channel_id *dst,
|
struct short_channel_id *dst);
|
||||||
bool may_be_deprecated_form);
|
|
||||||
|
|
||||||
char *short_channel_id_to_str(const tal_t *ctx, const struct short_channel_id *scid);
|
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,
|
bool WARN_UNUSED_RESULT short_channel_id_dir_from_str(const char *str, size_t strlen,
|
||||||
struct short_channel_id_dir *scidd,
|
struct short_channel_id_dir *scidd);
|
||||||
bool may_be_deprecated_form);
|
|
||||||
|
|
||||||
char *short_channel_id_dir_to_str(const tal_t *ctx,
|
char *short_channel_id_dir_to_str(const tal_t *ctx,
|
||||||
const struct short_channel_id_dir *scidd);
|
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,
|
bool json_to_short_channel_id(const char *buffer, const jsmntok_t *tok,
|
||||||
struct short_channel_id *scid,
|
struct short_channel_id *scid)
|
||||||
bool may_be_deprecated_form)
|
|
||||||
{
|
{
|
||||||
return (short_channel_id_from_str(buffer + tok->start,
|
return (short_channel_id_from_str(buffer + tok->start,
|
||||||
tok->end - tok->start, scid,
|
tok->end - tok->start, scid));
|
||||||
may_be_deprecated_form));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool json_to_txid(const char *buffer, const jsmntok_t *tok,
|
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 */
|
/* Extract a short_channel_id from this */
|
||||||
bool json_to_short_channel_id(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,
|
struct short_channel_id *scid);
|
||||||
bool may_be_deprecated_form);
|
|
||||||
|
|
||||||
/* Extract a satoshis amount from this */
|
/* Extract a satoshis amount from this */
|
||||||
bool json_to_sat(const char *buffer, const jsmntok_t *tok,
|
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");
|
err(1, "reading 'scid ,satoshis' from csv failed");
|
||||||
|
|
||||||
while(fscanf(scidf, "%s ,%"SCNu64"\n", str, &scidsats[i].sat.satoshis) == 2 ) { /* Raw: read from file */
|
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");
|
err(1, "failed to make scid struct");
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -567,7 +567,7 @@ static u8 *get_scid_array(const tal_t *ctx,
|
|||||||
encoding = json_get_member(test_vector, scids, "encoding");
|
encoding = json_get_member(test_vector, scids, "encoding");
|
||||||
json_for_each_arr(i, t, arr) {
|
json_for_each_arr(i, t, arr) {
|
||||||
struct short_channel_id scid;
|
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);
|
encoding_add_short_channel_id(&encoded, &scid);
|
||||||
}
|
}
|
||||||
if (json_tok_streq(test_vector, encoding, "UNCOMPRESSED")) {
|
if (json_tok_streq(test_vector, encoding, "UNCOMPRESSED")) {
|
||||||
|
|||||||
@@ -76,8 +76,7 @@ get_or_make_connection(struct routing_state *rstate,
|
|||||||
struct chan *chan;
|
struct chan *chan;
|
||||||
const int idx = node_id_idx(from_id, to_id);
|
const int idx = node_id_idx(from_id, to_id);
|
||||||
|
|
||||||
if (!short_channel_id_from_str(shortid, strlen(shortid), &scid,
|
if (!short_channel_id_from_str(shortid, strlen(shortid), &scid))
|
||||||
false))
|
|
||||||
abort();
|
abort();
|
||||||
chan = get_channel(rstate, &scid);
|
chan = get_channel(rstate, &scid);
|
||||||
if (!chan)
|
if (!chan)
|
||||||
|
|||||||
@@ -353,8 +353,7 @@ static struct command_result *json_getroute(struct command *cmd,
|
|||||||
json_for_each_arr(i, t, excludetok) {
|
json_for_each_arr(i, t, excludetok) {
|
||||||
if (!short_channel_id_dir_from_str(buffer + t->start,
|
if (!short_channel_id_dir_from_str(buffer + t->start,
|
||||||
t->end - t->start,
|
t->end - t->start,
|
||||||
&excluded[i],
|
&excluded[i])) {
|
||||||
deprecated_apis)) {
|
|
||||||
return command_fail(cmd, JSONRPC2_INVALID_PARAMS,
|
return command_fail(cmd, JSONRPC2_INVALID_PARAMS,
|
||||||
"%.*s is not a valid"
|
"%.*s is not a valid"
|
||||||
" short_channel_id/direction",
|
" 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);
|
scids = tal_arr(cmd, struct short_channel_id, scidstok->size);
|
||||||
json_for_each_arr(i, t, scidstok) {
|
json_for_each_arr(i, t, scidstok) {
|
||||||
if (!json_to_short_channel_id(buffer, t, &scids[i],
|
if (!json_to_short_channel_id(buffer, t, &scids[i])) {
|
||||||
deprecated_apis)) {
|
|
||||||
return command_fail(cmd, JSONRPC2_INVALID_PARAMS,
|
return command_fail(cmd, JSONRPC2_INVALID_PARAMS,
|
||||||
"scid %zu '%.*s' is not an scid",
|
"scid %zu '%.*s' is not an scid",
|
||||||
i, json_tok_full_len(t),
|
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)
|
if (!json_to_node_id(buffer, pubkey, &r->pubkey)
|
||||||
|| !json_to_short_channel_id(buffer, scid,
|
|| !json_to_short_channel_id(buffer, scid,
|
||||||
&r->short_channel_id,
|
&r->short_channel_id)
|
||||||
deprecated_apis)
|
|
||||||
|| !json_to_number(buffer, fee_base, &r->fee_base_msat)
|
|| !json_to_number(buffer, fee_base, &r->fee_base_msat)
|
||||||
|| !json_to_number(buffer, fee_prop,
|
|| !json_to_number(buffer, fee_prop,
|
||||||
&r->fee_proportional_millionths)
|
&r->fee_proportional_millionths)
|
||||||
|
|||||||
@@ -140,8 +140,7 @@ struct command_result *param_short_channel_id(struct command *cmd,
|
|||||||
struct short_channel_id **scid)
|
struct short_channel_id **scid)
|
||||||
{
|
{
|
||||||
*scid = tal(cmd, struct short_channel_id);
|
*scid = tal(cmd, struct short_channel_id);
|
||||||
if (json_to_short_channel_id(buffer, tok, *scid,
|
if (json_to_short_channel_id(buffer, tok, *scid))
|
||||||
deprecated_apis))
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return command_fail(cmd, JSONRPC2_INVALID_PARAMS,
|
return command_fail(cmd, JSONRPC2_INVALID_PARAMS,
|
||||||
|
|||||||
@@ -1194,8 +1194,7 @@ command_find_channel(struct command *cmd,
|
|||||||
"Channel ID not found: '%.*s'",
|
"Channel ID not found: '%.*s'",
|
||||||
tok->end - tok->start,
|
tok->end - tok->start,
|
||||||
buffer + tok->start);
|
buffer + tok->start);
|
||||||
} else if (json_to_short_channel_id(buffer, tok, &scid,
|
} else if (json_to_short_channel_id(buffer, tok, &scid)) {
|
||||||
deprecated_apis)) {
|
|
||||||
list_for_each(&ld->peers, peer, list) {
|
list_for_each(&ld->peers, peer, list) {
|
||||||
*channel = peer_active_channel(peer);
|
*channel = peer_active_channel(peer);
|
||||||
if (!*channel)
|
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(); }
|
{ fprintf(stderr, "json_to_node_id called!\n"); abort(); }
|
||||||
/* Generated stub for json_to_short_channel_id */
|
/* Generated stub for json_to_short_channel_id */
|
||||||
bool json_to_short_channel_id(const char *buffer UNNEEDED, const jsmntok_t *tok UNNEEDED,
|
bool json_to_short_channel_id(const char *buffer UNNEEDED, const jsmntok_t *tok UNNEEDED,
|
||||||
struct short_channel_id *scid UNNEEDED,
|
struct short_channel_id *scid UNNEEDED)
|
||||||
bool may_be_deprecated_form UNNEEDED)
|
|
||||||
{ fprintf(stderr, "json_to_short_channel_id called!\n"); abort(); }
|
{ fprintf(stderr, "json_to_short_channel_id called!\n"); abort(); }
|
||||||
/* Generated stub for kill_uncommitted_channel */
|
/* Generated stub for kill_uncommitted_channel */
|
||||||
void kill_uncommitted_channel(struct uncommitted_channel *uc UNNEEDED,
|
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(); }
|
{ fprintf(stderr, "json_to_pubkey called!\n"); abort(); }
|
||||||
/* Generated stub for json_to_short_channel_id */
|
/* Generated stub for json_to_short_channel_id */
|
||||||
bool json_to_short_channel_id(const char *buffer UNNEEDED, const jsmntok_t *tok UNNEEDED,
|
bool json_to_short_channel_id(const char *buffer UNNEEDED, const jsmntok_t *tok UNNEEDED,
|
||||||
struct short_channel_id *scid UNNEEDED,
|
struct short_channel_id *scid UNNEEDED)
|
||||||
bool may_be_deprecated_form UNNEEDED)
|
|
||||||
{ fprintf(stderr, "json_to_short_channel_id called!\n"); abort(); }
|
{ fprintf(stderr, "json_to_short_channel_id called!\n"); abort(); }
|
||||||
/* Generated stub for json_to_txid */
|
/* Generated stub for json_to_txid */
|
||||||
bool json_to_txid(const char *buffer UNNEEDED, const jsmntok_t *tok UNNEEDED,
|
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;
|
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'",
|
plugin_err("bad erring_channel '%.*s'",
|
||||||
(int)scidlen, scidstr);
|
(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);
|
const char *source = db_column_blob(stmt, col);
|
||||||
size_t sourcelen = db_column_bytes(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 *
|
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(); }
|
{ fprintf(stderr, "json_to_preimage called!\n"); abort(); }
|
||||||
/* Generated stub for json_to_short_channel_id */
|
/* Generated stub for json_to_short_channel_id */
|
||||||
bool json_to_short_channel_id(const char *buffer UNNEEDED, const jsmntok_t *tok UNNEEDED,
|
bool json_to_short_channel_id(const char *buffer UNNEEDED, const jsmntok_t *tok UNNEEDED,
|
||||||
struct short_channel_id *scid UNNEEDED,
|
struct short_channel_id *scid UNNEEDED)
|
||||||
bool may_be_deprecated_form UNNEEDED)
|
|
||||||
{ fprintf(stderr, "json_to_short_channel_id called!\n"); abort(); }
|
{ fprintf(stderr, "json_to_short_channel_id called!\n"); abort(); }
|
||||||
/* Generated stub for kill_uncommitted_channel */
|
/* Generated stub for kill_uncommitted_channel */
|
||||||
void kill_uncommitted_channel(struct uncommitted_channel *uc UNNEEDED,
|
void kill_uncommitted_channel(struct uncommitted_channel *uc UNNEEDED,
|
||||||
|
|||||||
Reference in New Issue
Block a user