mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-20 07:34:24 +01:00
fixed argv indexes for parsing commands
This commit is contained in:
committed by
Rusty Russell
parent
eaa72edbd6
commit
d4c074676e
@@ -37,32 +37,32 @@ static void do_generate(int argc, char **argv,
|
|||||||
sp = sphinx_path_new_with_key(ctx, assocdata, &session_key);
|
sp = sphinx_path_new_with_key(ctx, assocdata, &session_key);
|
||||||
|
|
||||||
for (int i = 0; i < num_hops; i++) {
|
for (int i = 0; i < num_hops; i++) {
|
||||||
size_t klen = strcspn(argv[1 + i], "/");
|
size_t klen = strcspn(argv[2 + i], "/");
|
||||||
if (hex_data_size(klen) == PRIVKEY_LEN) {
|
if (hex_data_size(klen) == PRIVKEY_LEN) {
|
||||||
if (!hex_decode(argv[1 + i], klen, rawprivkey, PRIVKEY_LEN))
|
if (!hex_decode(argv[2 + i], klen, rawprivkey, PRIVKEY_LEN))
|
||||||
errx(1, "Invalid private key hex '%s'",
|
errx(1, "Invalid private key hex '%s'",
|
||||||
argv[1 + i]);
|
argv[2 + i]);
|
||||||
|
|
||||||
if (secp256k1_ec_pubkey_create(secp256k1_ctx,
|
if (secp256k1_ec_pubkey_create(secp256k1_ctx,
|
||||||
&path[i].pubkey,
|
&path[i].pubkey,
|
||||||
rawprivkey) != 1)
|
rawprivkey) != 1)
|
||||||
errx(1, "Could not decode pubkey");
|
errx(1, "Could not decode pubkey");
|
||||||
} else if (hex_data_size(klen) == PUBKEY_CMPR_LEN) {
|
} else if (hex_data_size(klen) == PUBKEY_CMPR_LEN) {
|
||||||
if (!pubkey_from_hexstr(argv[i + 1], klen, &path[i]))
|
if (!pubkey_from_hexstr(argv[2 + i], klen, &path[i]))
|
||||||
errx(1, "Invalid public key hex '%s'",
|
errx(1, "Invalid public key hex '%s'",
|
||||||
argv[1 + i]);
|
argv[2 + i]);
|
||||||
} else {
|
} else {
|
||||||
errx(1,
|
errx(1,
|
||||||
"Provided key is neither a pubkey nor a privkey: "
|
"Provided key is neither a pubkey nor a privkey: "
|
||||||
"%s\n",
|
"%s\n",
|
||||||
argv[1 + i]);
|
argv[2 + i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(&hops_data[i], 0, sizeof(hops_data[i]));
|
memset(&hops_data[i], 0, sizeof(hops_data[i]));
|
||||||
if (argv[1 + i][klen] != '\0') {
|
if (argv[2 + i][klen] != '\0') {
|
||||||
/* FIXME: Generic realm support, not this hack! */
|
/* FIXME: Generic realm support, not this hack! */
|
||||||
/* FIXME: Multi hop! */
|
/* FIXME: Multi hop! */
|
||||||
const char *hopstr = argv[1 + i] + klen + 1;
|
const char *hopstr = argv[2 + i] + klen + 1;
|
||||||
size_t dsize = hex_data_size(strlen(hopstr));
|
size_t dsize = hex_data_size(strlen(hopstr));
|
||||||
be64 scid, msat;
|
be64 scid, msat;
|
||||||
be32 cltv;
|
be32 cltv;
|
||||||
|
|||||||
Reference in New Issue
Block a user