- if(sscanf(request, "%*d " MAX_STRING " " MAX_STRING " %d", from_name, to_name, &kx_version) < 2) {
- logger(LOG_ERR, "Got bad %s from %s (%s)", "REQ_KEY", c->name,
- c->hostname);
- return false;
+ node_t *to = handle;
+ meshlink_handle_t *mesh = to->mesh;
+ to->sptps.send_data = send_sptps_data;
+ char buf[len * 4 / 3 + 5];
+ b64encode(data, buf, len);
+ return send_request(mesh, to->nexthop->connection, NULL, "%d %s %s %d %s", REQ_KEY, mesh->self->name, to->name, REQ_KEY, buf);
+}
+
+bool send_req_key(meshlink_handle_t *mesh, node_t *to) {
+ if(!node_read_public_key(mesh, to)) {
+ logger(mesh, MESHLINK_DEBUG, "No ECDSA key known for %s", to->name);
+ send_request(mesh, to->nexthop->connection, NULL, "%d %s %s %d", REQ_KEY, mesh->self->name, to->name, REQ_PUBKEY);
+ return true;