| 20 | #include <wire/wire_sync.h> |
| 21 | |
| 22 | static int hsm_get_fd(struct lightningd *ld, |
| 23 | const struct node_id *id, |
| 24 | u64 dbid, |
| 25 | int capabilities) |
| 26 | { |
| 27 | int hsm_fd; |
| 28 | u8 *msg; |
| 29 | |
| 30 | msg = towire_hsmd_client_hsmfd(NULL, id, dbid, capabilities); |
| 31 | if (!wire_sync_write(ld->hsm_fd, take(msg))) |
| 32 | fatal("Could not write to HSM: %s", strerror(errno)); |
| 33 | |
| 34 | msg = wire_sync_read(tmpctx, ld->hsm_fd); |
| 35 | if (!fromwire_hsmd_client_hsmfd_reply(msg)) |
| 36 | fatal("Bad reply from HSM: %s", tal_hex(tmpctx, msg)); |
| 37 | |
| 38 | hsm_fd = fdpass_recv(ld->hsm_fd); |
| 39 | if (hsm_fd < 0) |
| 40 | fatal("Could not read fd from HSM: %s", strerror(errno)); |
| 41 | return hsm_fd; |
| 42 | } |
| 43 | |
| 44 | int hsm_get_client_fd(struct lightningd *ld, |
| 45 | const struct node_id *id, |
no test coverage detected