lnsocket_wasm.c (1013B)
1 2 #include "handshake.h" 3 #include "lnsocket_internal.h" 4 #include <emscripten.h> 5 6 struct act_three* lnsocket_act_two(struct lnsocket *ln, struct act_two *act2); 7 8 void* EMSCRIPTEN_KEEPALIVE lnsocket_act_one(struct lnsocket *ln, const char *node_id) 9 { 10 struct pubkey their_id; 11 struct node_id their_node_id; 12 13 if (is_zero(&ln->key, sizeof(ln->key))) { 14 note_error(&ln->errs, "key not initialized, use lnsocket_set_key() or lnsocket_genkey()"); 15 return NULL; 16 } 17 18 if (!parse_node_id(node_id, &their_node_id)) { 19 note_error(&ln->errs, "failed to parse node id"); 20 return NULL; 21 } 22 23 if (!pubkey_from_node_id(ln->secp, &their_id, &their_node_id)) { 24 note_error(&ln->errs, "failed to convert node_id to pubkey"); 25 return NULL; 26 } 27 28 new_handshake(ln->secp, &ln->handshake, &their_id); 29 30 ln->handshake.side = INITIATOR; 31 ln->handshake.their_id = their_id; 32 33 if (!act_one_initiator_prep(ln)) { 34 note_error(&ln->errs, "failed to build initial handshake data (act1)"); 35 return NULL; 36 } 37 38 return &ln->handshake.act1; 39 }