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

Function sync_crypto_read

devtools/gossipwith.c:146–178  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

144}
145
146static u8 *sync_crypto_read(const tal_t *ctx, int peer_fd, struct crypto_state *cs)
147{
148 u8 hdr[18], *enc, *dec;
149 u16 len;
150
151 if (!read_all(peer_fd, hdr, sizeof(hdr))) {
152 status_debug("Failed reading header: %s", strerror(errno));
153 if (no_early_close)
154 exit(1);
155 exit(0);
156 }
157
158 if (!cryptomsg_decrypt_header(cs, hdr, &len)) {
159 status_debug("Failed hdr decrypt with rn=%"PRIu64,
160 cs->rn-1);
161 exit(1);
162 }
163
164 enc = tal_arr(ctx, u8, len + 16);
165 if (!read_all(peer_fd, enc, tal_count(enc))) {
166 status_debug("Failed reading body: %s", strerror(errno));
167 exit(1);
168 }
169
170 dec = cryptomsg_decrypt_body(ctx, cs, enc);
171 tal_free(enc);
172 if (!dec)
173 exit(1);
174 else
175 status_peer_io(LOG_IO_IN, NULL, dec);
176
177 return dec;
178}
179
180static struct io_plan *handshake_success(struct io_conn *conn,
181 const struct pubkey *them,

Callers 1

handshake_successFunction · 0.85

Calls 5

read_allFunction · 0.85
cryptomsg_decrypt_headerFunction · 0.85
cryptomsg_decrypt_bodyFunction · 0.85
tal_freeFunction · 0.85
status_peer_ioFunction · 0.70

Tested by

no test coverage detected