mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-20 15:44:21 +01:00
devtools/blindedpath: implement scid support.
This is what we expect in an enctlv used for htlcs. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -76,6 +76,7 @@ int main(int argc, char **argv)
|
|||||||
if (streq(argv[1], "create")) {
|
if (streq(argv[1], "create")) {
|
||||||
struct privkey e;
|
struct privkey e;
|
||||||
struct pubkey *pk_e, *b, *nodes;
|
struct pubkey *pk_e, *b, *nodes;
|
||||||
|
struct short_channel_id **scids;
|
||||||
struct secret *rho;
|
struct secret *rho;
|
||||||
size_t num = argc - 2;
|
size_t num = argc - 2;
|
||||||
|
|
||||||
@@ -91,6 +92,7 @@ int main(int argc, char **argv)
|
|||||||
/* rho(i) */
|
/* rho(i) */
|
||||||
rho = tal_arr(tmpctx, struct secret, num);
|
rho = tal_arr(tmpctx, struct secret, num);
|
||||||
|
|
||||||
|
scids = tal_arr(tmpctx, struct short_channel_id *, num);
|
||||||
/* Randomness, chosen with a fair dice roll! */
|
/* Randomness, chosen with a fair dice roll! */
|
||||||
memset(&e, 6, sizeof(e));
|
memset(&e, 6, sizeof(e));
|
||||||
if (!pubkey_from_privkey(&e, &pk_e[0]))
|
if (!pubkey_from_privkey(&e, &pk_e[0]))
|
||||||
@@ -100,12 +102,23 @@ int main(int argc, char **argv)
|
|||||||
struct secret ss;
|
struct secret ss;
|
||||||
struct secret hmac;
|
struct secret hmac;
|
||||||
struct sha256 h;
|
struct sha256 h;
|
||||||
|
const char *slash;
|
||||||
|
|
||||||
if (!pubkey_from_hexstr(argv[2+i],
|
if (!pubkey_from_hexstr(argv[2+i],
|
||||||
strcspn(argv[2+i], "/"),
|
strcspn(argv[2+i], "/"),
|
||||||
&nodes[i]))
|
&nodes[i]))
|
||||||
errx(1, "%s not a valid pubkey", argv[2+i]);
|
errx(1, "%s not a valid pubkey", argv[2+i]);
|
||||||
|
|
||||||
|
slash = strchr(argv[2+i], '/');
|
||||||
|
if (slash) {
|
||||||
|
scids[i] = tal(scids, struct short_channel_id);
|
||||||
|
if (!short_channel_id_from_str(slash+1,
|
||||||
|
strlen(slash+1),
|
||||||
|
scids[i]))
|
||||||
|
errx(1, "%s is not a valid scids",
|
||||||
|
slash + 1);
|
||||||
|
} else
|
||||||
|
scids[i] = NULL;
|
||||||
if (secp256k1_ecdh(secp256k1_ctx, ss.data,
|
if (secp256k1_ecdh(secp256k1_ctx, ss.data,
|
||||||
&nodes[i].pubkey, e.secret.data, NULL, NULL) != 1)
|
&nodes[i].pubkey, e.secret.data, NULL, NULL) != 1)
|
||||||
abort();
|
abort();
|
||||||
@@ -142,9 +155,16 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
/* Inner is encrypted */
|
/* Inner is encrypted */
|
||||||
inner = tlv_onionmsg_payload_new(tmpctx);
|
inner = tlv_onionmsg_payload_new(tmpctx);
|
||||||
/* FIXME: Use /scid for encblob if specified */
|
/* Use scid if they provided one */
|
||||||
inner->next_node_id = tal(inner, struct tlv_onionmsg_payload_next_node_id);
|
if (scids[i]) {
|
||||||
inner->next_node_id->node_id = nodes[i+1];
|
inner->next_short_channel_id
|
||||||
|
= tal(inner, struct tlv_onionmsg_payload_next_short_channel_id);
|
||||||
|
inner->next_short_channel_id->short_channel_id
|
||||||
|
= *scids[i];
|
||||||
|
} else {
|
||||||
|
inner->next_node_id = tal(inner, struct tlv_onionmsg_payload_next_node_id);
|
||||||
|
inner->next_node_id->node_id = nodes[i+1];
|
||||||
|
}
|
||||||
p = tal_arr(tmpctx, u8, 0);
|
p = tal_arr(tmpctx, u8, 0);
|
||||||
towire_encmsg_tlvs(&p, inner);
|
towire_encmsg_tlvs(&p, inner);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user