MCPcopy Create free account
hub / github.com/ElementsProject/lightning / try_other_parity

Function try_other_parity

plugins/fetchinvoice.c:862–886  ·  view source on GitHub ↗

Offers contain only a 32-byte id. If we can't find the address, we * don't know if it's 02 or 03, so we try both. If we're here, we * failed 02. */

Source from the content-addressed store, hash-verified

860 * don't know if it's 02 or 03, so we try both. If we're here, we
861 * failed 02. */
862static struct command_result *try_other_parity(struct command *cmd,
863 const char *buf,
864 const jsmntok_t *result,
865 struct connect_attempt *ca)
866{
867 struct out_req *req;
868
869 /* Flip parity */
870 ca->node_id.k[0] = SECP256K1_TAG_PUBKEY_ODD;
871 /* Path is us -> them, so they're second entry */
872 if (!pubkey_from_node_id(&ca->sent->path[1], &ca->node_id)) {
873 /* Should not happen!
874 * Pieter Wuille points out:
875 * y^2 = x^3 + 7 mod p
876 * negating y doesn’t change the left hand side
877 */
878 return command_done_err(cmd, LIGHTNINGD,
879 "Failed: could not convert inverted pubkey?",
880 NULL);
881 }
882 req = jsonrpc_request_start(cmd->plugin, cmd, "connect", connected,
883 connect_failed, ca);
884 json_add_node_id(req->js, "id", &ca->node_id);
885 return send_outreq(cmd->plugin, req);
886}
887
888/* We can't find a route, so we're going to try to connect, then just blast it
889 * to them. */

Callers

nothing calls this directly

Calls 4

command_done_errFunction · 0.85
send_outreqFunction · 0.70
pubkey_from_node_idFunction · 0.50
json_add_node_idFunction · 0.50

Tested by

no test coverage detected