mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-11-19 09:54:16 +01:00
e92b710406
We always hand in "NULL" (which means use tal_len on the msg), except for two places which do that manually for no good reason. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
30 lines
512 B
C
30 lines
512 B
C
#include <hsmd/client.h>
|
|
#include <hsmd/gen_hsm_client_wire.h>
|
|
#include <wire/wire_sync.h>
|
|
|
|
static int hsm_fd = -1;
|
|
|
|
void hsm_setup(int fd)
|
|
{
|
|
hsm_fd = fd;
|
|
}
|
|
|
|
bool hsm_do_ecdh(struct secret *ss, const struct pubkey *point)
|
|
{
|
|
u8 *req = towire_hsm_ecdh_req(NULL, point), *resp;
|
|
|
|
if (!wire_sync_write(hsm_fd, req))
|
|
goto fail;
|
|
resp = wire_sync_read(req, hsm_fd);
|
|
if (!resp)
|
|
goto fail;
|
|
if (!fromwire_hsm_ecdh_resp(resp, ss))
|
|
goto fail;
|
|
tal_free(req);
|
|
return true;
|
|
|
|
fail:
|
|
tal_free(req);
|
|
return false;
|
|
}
|