mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-01 17:47:30 +01:00
hsmd: convert to new wire generation style.
Note that other directories were explicitly depending on the generated file, instead of relying on their (already existing) dependency on $(LIGHTNINGD_HSM_CLIENT_OBJS), so we remove that. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
8ae6740bb1
commit
1702c7a69a
40 changed files with 498 additions and 516 deletions
|
@ -92,7 +92,6 @@ CHANNELD_COMMON_OBJS := \
|
||||||
common/wire_error.o \
|
common/wire_error.o \
|
||||||
common/wireaddr.o \
|
common/wireaddr.o \
|
||||||
gossipd/gen_gossip_peerd_wire.o \
|
gossipd/gen_gossip_peerd_wire.o \
|
||||||
hsmd/gen_hsm_wire.o \
|
|
||||||
lightningd/gossip_msg.o \
|
lightningd/gossip_msg.o \
|
||||||
wire/fromwire.o \
|
wire/fromwire.o \
|
||||||
wire/towire.o
|
wire/towire.o
|
||||||
|
|
|
@ -57,7 +57,7 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <gossipd/gen_gossip_peerd_wire.h>
|
#include <gossipd/gen_gossip_peerd_wire.h>
|
||||||
#include <hsmd/gen_hsm_wire.h>
|
#include <hsmd/hsmd_wiregen.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <secp256k1.h>
|
#include <secp256k1.h>
|
||||||
#include <sodium/crypto_aead_chacha20poly1305.h>
|
#include <sodium/crypto_aead_chacha20poly1305.h>
|
||||||
|
@ -237,14 +237,14 @@ static const u8 *hsm_req(const tal_t *ctx, const u8 *req TAKES)
|
||||||
if (!wire_sync_write(HSM_FD, req))
|
if (!wire_sync_write(HSM_FD, req))
|
||||||
status_failed(STATUS_FAIL_HSM_IO,
|
status_failed(STATUS_FAIL_HSM_IO,
|
||||||
"Writing %s to HSM: %s",
|
"Writing %s to HSM: %s",
|
||||||
hsm_wire_type_name(type),
|
hsmd_wire_name(type),
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
|
|
||||||
msg = wire_sync_read(ctx, HSM_FD);
|
msg = wire_sync_read(ctx, HSM_FD);
|
||||||
if (!msg)
|
if (!msg)
|
||||||
status_failed(STATUS_FAIL_HSM_IO,
|
status_failed(STATUS_FAIL_HSM_IO,
|
||||||
"Reading resp to %s: %s",
|
"Reading resp to %s: %s",
|
||||||
hsm_wire_type_name(type),
|
hsmd_wire_name(type),
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
|
|
||||||
return msg;
|
return msg;
|
||||||
|
@ -385,10 +385,10 @@ static void send_announcement_signatures(struct peer *peer)
|
||||||
|
|
||||||
status_debug("Exchanging announcement signatures.");
|
status_debug("Exchanging announcement signatures.");
|
||||||
ca = create_channel_announcement(tmpctx, peer);
|
ca = create_channel_announcement(tmpctx, peer);
|
||||||
req = towire_hsm_cannouncement_sig_req(tmpctx, ca);
|
req = towire_hsmd_cannouncement_sig_req(tmpctx, ca);
|
||||||
|
|
||||||
msg = hsm_req(tmpctx, req);
|
msg = hsm_req(tmpctx, req);
|
||||||
if (!fromwire_hsm_cannouncement_sig_reply(msg,
|
if (!fromwire_hsmd_cannouncement_sig_reply(msg,
|
||||||
&peer->announcement_node_sigs[LOCAL],
|
&peer->announcement_node_sigs[LOCAL],
|
||||||
&peer->announcement_bitcoin_sigs[LOCAL]))
|
&peer->announcement_bitcoin_sigs[LOCAL]))
|
||||||
status_failed(STATUS_FAIL_HSM_IO,
|
status_failed(STATUS_FAIL_HSM_IO,
|
||||||
|
@ -840,13 +840,13 @@ static struct bitcoin_signature *calc_commitsigs(const tal_t *ctx,
|
||||||
const u8 *msg;
|
const u8 *msg;
|
||||||
struct bitcoin_signature *htlc_sigs;
|
struct bitcoin_signature *htlc_sigs;
|
||||||
|
|
||||||
msg = towire_hsm_sign_remote_commitment_tx(NULL, txs[0],
|
msg = towire_hsmd_sign_remote_commitment_tx(NULL, txs[0],
|
||||||
&peer->channel->funding_pubkey[REMOTE],
|
&peer->channel->funding_pubkey[REMOTE],
|
||||||
&peer->remote_per_commit,
|
&peer->remote_per_commit,
|
||||||
peer->channel->option_static_remotekey);
|
peer->channel->option_static_remotekey);
|
||||||
|
|
||||||
msg = hsm_req(tmpctx, take(msg));
|
msg = hsm_req(tmpctx, take(msg));
|
||||||
if (!fromwire_hsm_sign_tx_reply(msg, commit_sig))
|
if (!fromwire_hsmd_sign_tx_reply(msg, commit_sig))
|
||||||
status_failed(STATUS_FAIL_HSM_IO,
|
status_failed(STATUS_FAIL_HSM_IO,
|
||||||
"Reading sign_remote_commitment_tx reply: %s",
|
"Reading sign_remote_commitment_tx reply: %s",
|
||||||
tal_hex(tmpctx, msg));
|
tal_hex(tmpctx, msg));
|
||||||
|
@ -881,12 +881,12 @@ static struct bitcoin_signature *calc_commitsigs(const tal_t *ctx,
|
||||||
|
|
||||||
wscript = bitcoin_tx_output_get_witscript(tmpctx, txs[0],
|
wscript = bitcoin_tx_output_get_witscript(tmpctx, txs[0],
|
||||||
txs[i+1]->wtx->inputs[0].index);
|
txs[i+1]->wtx->inputs[0].index);
|
||||||
msg = towire_hsm_sign_remote_htlc_tx(NULL, txs[i + 1], wscript,
|
msg = towire_hsmd_sign_remote_htlc_tx(NULL, txs[i + 1], wscript,
|
||||||
&peer->remote_per_commit,
|
&peer->remote_per_commit,
|
||||||
peer->channel->option_anchor_outputs);
|
peer->channel->option_anchor_outputs);
|
||||||
|
|
||||||
msg = hsm_req(tmpctx, take(msg));
|
msg = hsm_req(tmpctx, take(msg));
|
||||||
if (!fromwire_hsm_sign_tx_reply(msg, &htlc_sigs[i]))
|
if (!fromwire_hsmd_sign_tx_reply(msg, &htlc_sigs[i]))
|
||||||
status_failed(STATUS_FAIL_HSM_IO,
|
status_failed(STATUS_FAIL_HSM_IO,
|
||||||
"Bad sign_remote_htlc_tx reply: %s",
|
"Bad sign_remote_htlc_tx reply: %s",
|
||||||
tal_hex(tmpctx, msg));
|
tal_hex(tmpctx, msg));
|
||||||
|
@ -1134,9 +1134,9 @@ static void get_per_commitment_point(u64 index, struct pubkey *point,
|
||||||
const u8 *msg;
|
const u8 *msg;
|
||||||
|
|
||||||
msg = hsm_req(tmpctx,
|
msg = hsm_req(tmpctx,
|
||||||
take(towire_hsm_get_per_commitment_point(NULL, index)));
|
take(towire_hsmd_get_per_commitment_point(NULL, index)));
|
||||||
|
|
||||||
if (!fromwire_hsm_get_per_commitment_point_reply(tmpctx, msg,
|
if (!fromwire_hsmd_get_per_commitment_point_reply(tmpctx, msg,
|
||||||
point,
|
point,
|
||||||
&s))
|
&s))
|
||||||
status_failed(STATUS_FAIL_HSM_IO,
|
status_failed(STATUS_FAIL_HSM_IO,
|
||||||
|
@ -2253,11 +2253,11 @@ static void check_future_dataloss_fields(struct peer *peer,
|
||||||
|
|
||||||
assert(next_revocation_number > peer->next_index[LOCAL] - 1);
|
assert(next_revocation_number > peer->next_index[LOCAL] - 1);
|
||||||
|
|
||||||
msg = towire_hsm_check_future_secret(NULL,
|
msg = towire_hsmd_check_future_secret(NULL,
|
||||||
next_revocation_number - 1,
|
next_revocation_number - 1,
|
||||||
last_local_per_commit_secret);
|
last_local_per_commit_secret);
|
||||||
msg = hsm_req(tmpctx, take(msg));
|
msg = hsm_req(tmpctx, take(msg));
|
||||||
if (!fromwire_hsm_check_future_secret_reply(msg, &correct))
|
if (!fromwire_hsmd_check_future_secret_reply(msg, &correct))
|
||||||
status_failed(STATUS_FAIL_HSM_IO,
|
status_failed(STATUS_FAIL_HSM_IO,
|
||||||
"Bad hsm_check_future_secret_reply: %s",
|
"Bad hsm_check_future_secret_reply: %s",
|
||||||
tal_hex(tmpctx, msg));
|
tal_hex(tmpctx, msg));
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
#include <common/keyset.h>
|
#include <common/keyset.h>
|
||||||
#include <common/status.h>
|
#include <common/status.h>
|
||||||
#include <common/type_to_string.h>
|
#include <common/type_to_string.h>
|
||||||
#include <hsmd/gen_hsm_wire.h>
|
#include <hsmd/hsmd_wiregen.h>
|
||||||
#include <wire/wire_sync.h>
|
#include <wire/wire_sync.h>
|
||||||
|
|
||||||
static const u8 ONE = 0x1;
|
static const u8 ONE = 0x1;
|
||||||
|
@ -102,7 +102,7 @@ penalty_tx_create(const tal_t *ctx,
|
||||||
bitcoin_tx_finalize(tx);
|
bitcoin_tx_finalize(tx);
|
||||||
|
|
||||||
u8 *hsm_sign_msg =
|
u8 *hsm_sign_msg =
|
||||||
towire_hsm_sign_penalty_to_us(ctx, &remote_per_commitment_secret,
|
towire_hsmd_sign_penalty_to_us(ctx, &remote_per_commitment_secret,
|
||||||
tx, wscript);
|
tx, wscript);
|
||||||
|
|
||||||
if (!wire_sync_write(hsm_fd, take(hsm_sign_msg)))
|
if (!wire_sync_write(hsm_fd, take(hsm_sign_msg)))
|
||||||
|
@ -110,7 +110,7 @@ penalty_tx_create(const tal_t *ctx,
|
||||||
"Writing sign request to hsm");
|
"Writing sign request to hsm");
|
||||||
|
|
||||||
msg = wire_sync_read(tmpctx, hsm_fd);
|
msg = wire_sync_read(tmpctx, hsm_fd);
|
||||||
if (!msg || !fromwire_hsm_sign_tx_reply(msg, &sig))
|
if (!msg || !fromwire_hsmd_sign_tx_reply(msg, &sig))
|
||||||
status_failed(STATUS_FAIL_INTERNAL_ERROR,
|
status_failed(STATUS_FAIL_INTERNAL_ERROR,
|
||||||
"Reading sign_tx_reply: %s", tal_hex(tmpctx, msg));
|
"Reading sign_tx_reply: %s", tal_hex(tmpctx, msg));
|
||||||
|
|
||||||
|
|
|
@ -82,8 +82,7 @@ CLOSINGD_COMMON_OBJS := \
|
||||||
common/version.o \
|
common/version.o \
|
||||||
common/wire_error.o \
|
common/wire_error.o \
|
||||||
common/wireaddr.o \
|
common/wireaddr.o \
|
||||||
gossipd/gen_gossip_peerd_wire.o \
|
gossipd/gen_gossip_peerd_wire.o
|
||||||
hsmd/gen_hsm_wire.o
|
|
||||||
|
|
||||||
closingd/gen_closing_wire.h: $(WIRE_GEN) closingd/closing_wire.csv
|
closingd/gen_closing_wire.h: $(WIRE_GEN) closingd/closing_wire.csv
|
||||||
$(WIRE_GEN) --page header $@ closing_wire_type < closingd/closing_wire.csv > $@
|
$(WIRE_GEN) --page header $@ closing_wire_type < closingd/closing_wire.csv > $@
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
#include <common/wire_error.h>
|
#include <common/wire_error.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <gossipd/gen_gossip_peerd_wire.h>
|
#include <gossipd/gen_gossip_peerd_wire.h>
|
||||||
#include <hsmd/gen_hsm_wire.h>
|
#include <hsmd/hsmd_wiregen.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
@ -120,7 +120,7 @@ static struct pubkey get_per_commitment_point(u64 commitment_number)
|
||||||
/* Our current per-commitment point is the commitment point in the last
|
/* Our current per-commitment point is the commitment point in the last
|
||||||
* received signed commitment; HSM gives us that and the previous
|
* received signed commitment; HSM gives us that and the previous
|
||||||
* secret (which we don't need). */
|
* secret (which we don't need). */
|
||||||
msg = towire_hsm_get_per_commitment_point(NULL,
|
msg = towire_hsmd_get_per_commitment_point(NULL,
|
||||||
commitment_number);
|
commitment_number);
|
||||||
if (!wire_sync_write(HSM_FD, take(msg)))
|
if (!wire_sync_write(HSM_FD, take(msg)))
|
||||||
status_failed(STATUS_FAIL_HSM_IO,
|
status_failed(STATUS_FAIL_HSM_IO,
|
||||||
|
@ -132,7 +132,7 @@ static struct pubkey get_per_commitment_point(u64 commitment_number)
|
||||||
status_failed(STATUS_FAIL_HSM_IO,
|
status_failed(STATUS_FAIL_HSM_IO,
|
||||||
"Reading resp get_per_commitment_point reply: %s",
|
"Reading resp get_per_commitment_point reply: %s",
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
if (!fromwire_hsm_get_per_commitment_point_reply(tmpctx, msg,
|
if (!fromwire_hsmd_get_per_commitment_point_reply(tmpctx, msg,
|
||||||
&commitment_point,
|
&commitment_point,
|
||||||
&s))
|
&s))
|
||||||
status_failed(STATUS_FAIL_HSM_IO,
|
status_failed(STATUS_FAIL_HSM_IO,
|
||||||
|
@ -279,11 +279,11 @@ static void send_offer(struct per_peer_state *pps,
|
||||||
*/
|
*/
|
||||||
/* (We don't do this). */
|
/* (We don't do this). */
|
||||||
wire_sync_write(HSM_FD,
|
wire_sync_write(HSM_FD,
|
||||||
take(towire_hsm_sign_mutual_close_tx(NULL,
|
take(towire_hsmd_sign_mutual_close_tx(NULL,
|
||||||
tx,
|
tx,
|
||||||
&funding_pubkey[REMOTE])));
|
&funding_pubkey[REMOTE])));
|
||||||
msg = wire_sync_read(tmpctx, HSM_FD);
|
msg = wire_sync_read(tmpctx, HSM_FD);
|
||||||
if (!fromwire_hsm_sign_tx_reply(msg, &our_sig))
|
if (!fromwire_hsmd_sign_tx_reply(msg, &our_sig))
|
||||||
status_failed(STATUS_FAIL_HSM_IO,
|
status_failed(STATUS_FAIL_HSM_IO,
|
||||||
"Bad hsm_sign_mutual_close_tx reply %s",
|
"Bad hsm_sign_mutual_close_tx reply %s",
|
||||||
tal_hex(tmpctx, msg));
|
tal_hex(tmpctx, msg));
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
#include <common/features.h>
|
#include <common/features.h>
|
||||||
#include <common/utils.h>
|
#include <common/utils.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <hsmd/gen_hsm_wire.h>
|
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <lightningd/hsm_control.h>
|
#include <lightningd/hsm_control.h>
|
||||||
#include <lightningd/jsonrpc.h>
|
#include <lightningd/jsonrpc.h>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include <common/ecdh_hsmd.h>
|
#include <common/ecdh_hsmd.h>
|
||||||
#include <common/utils.h>
|
#include <common/utils.h>
|
||||||
#include <hsmd/gen_hsm_wire.h>
|
#include <hsmd/hsmd_wiregen.h>
|
||||||
#include <wire/wire_sync.h>
|
#include <wire/wire_sync.h>
|
||||||
|
|
||||||
static int stashed_hsm_fd = -1;
|
static int stashed_hsm_fd = -1;
|
||||||
|
@ -8,7 +8,7 @@ static void (*stashed_failed)(enum status_failreason, const char *fmt, ...);
|
||||||
|
|
||||||
void ecdh(const struct pubkey *point, struct secret *ss)
|
void ecdh(const struct pubkey *point, struct secret *ss)
|
||||||
{
|
{
|
||||||
const u8 *msg = towire_hsm_ecdh_req(NULL, point);
|
const u8 *msg = towire_hsmd_ecdh_req(NULL, point);
|
||||||
|
|
||||||
if (!wire_sync_write(stashed_hsm_fd, take(msg)))
|
if (!wire_sync_write(stashed_hsm_fd, take(msg)))
|
||||||
stashed_failed(STATUS_FAIL_HSM_IO, "Write ECDH to hsmd failed");
|
stashed_failed(STATUS_FAIL_HSM_IO, "Write ECDH to hsmd failed");
|
||||||
|
@ -17,7 +17,7 @@ void ecdh(const struct pubkey *point, struct secret *ss)
|
||||||
if (!msg)
|
if (!msg)
|
||||||
stashed_failed(STATUS_FAIL_HSM_IO, "No hsmd ECDH response");
|
stashed_failed(STATUS_FAIL_HSM_IO, "No hsmd ECDH response");
|
||||||
|
|
||||||
if (!fromwire_hsm_ecdh_resp(msg, ss))
|
if (!fromwire_hsmd_ecdh_resp(msg, ss))
|
||||||
stashed_failed(STATUS_FAIL_HSM_IO, "Invalid hsmd ECDH response");
|
stashed_failed(STATUS_FAIL_HSM_IO, "Invalid hsmd ECDH response");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -74,7 +74,6 @@ CONNECTD_COMMON_OBJS := \
|
||||||
common/wireaddr.o \
|
common/wireaddr.o \
|
||||||
common/wire_error.o \
|
common/wire_error.o \
|
||||||
gossipd/gen_gossip_wire.o \
|
gossipd/gen_gossip_wire.o \
|
||||||
hsmd/gen_hsm_wire.o \
|
|
||||||
lightningd/gossip_msg.o \
|
lightningd/gossip_msg.o \
|
||||||
wire/gen_onion_wire.o
|
wire/gen_onion_wire.o
|
||||||
|
|
||||||
|
@ -84,7 +83,7 @@ $(LIGHTNINGD_CONNECT_CONTROL_OBJS) : $(LIGHTNINGD_CONNECT_CONTROL_HEADERS)
|
||||||
|
|
||||||
connectd-all: lightningd/lightning_connectd
|
connectd-all: lightningd/lightning_connectd
|
||||||
|
|
||||||
lightningd/lightning_connectd: $(LIGHTNINGD_CONNECT_OBJS) $(CONNECTD_COMMON_OBJS) $(BITCOIN_OBJS) $(WIRE_OBJS)
|
lightningd/lightning_connectd: $(LIGHTNINGD_CONNECT_OBJS) $(CONNECTD_COMMON_OBJS) $(BITCOIN_OBJS) $(WIRE_OBJS) $(LIGHTNINGD_HSM_CLIENT_OBJS)
|
||||||
|
|
||||||
connectd/gen_connect_wire.h: $(WIRE_GEN) connectd/connect_wire.csv
|
connectd/gen_connect_wire.h: $(WIRE_GEN) connectd/connect_wire.csv
|
||||||
$(WIRE_GEN) --page header $@ connect_wire_type < connectd/connect_wire.csv > $@
|
$(WIRE_GEN) --page header $@ connect_wire_type < connectd/connect_wire.csv > $@
|
||||||
|
|
|
@ -53,7 +53,7 @@
|
||||||
#include <connectd/tor_autoservice.h>
|
#include <connectd/tor_autoservice.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <gossipd/gen_gossip_wire.h>
|
#include <gossipd/gen_gossip_wire.h>
|
||||||
#include <hsmd/gen_hsm_wire.h>
|
#include <hsmd/hsmd_wiregen.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <lightningd/gossip_msg.h>
|
#include <lightningd/gossip_msg.h>
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
|
|
|
@ -77,7 +77,6 @@ GOSSIPD_COMMON_OBJS := \
|
||||||
common/wireaddr.o \
|
common/wireaddr.o \
|
||||||
common/wire_error.o \
|
common/wire_error.o \
|
||||||
connectd/gen_connect_gossip_wire.o \
|
connectd/gen_connect_gossip_wire.o \
|
||||||
hsmd/gen_hsm_wire.o \
|
|
||||||
lightningd/gossip_msg.o \
|
lightningd/gossip_msg.o \
|
||||||
wire/gen_onion_wire.o
|
wire/gen_onion_wire.o
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
#include <gossipd/gossip_generation.h>
|
#include <gossipd/gossip_generation.h>
|
||||||
#include <gossipd/gossip_store.h>
|
#include <gossipd/gossip_store.h>
|
||||||
#include <gossipd/gossipd.h>
|
#include <gossipd/gossipd.h>
|
||||||
#include <hsmd/gen_hsm_wire.h>
|
#include <hsmd/hsmd_wiregen.h>
|
||||||
#include <wire/gen_peer_wire.h>
|
#include <wire/gen_peer_wire.h>
|
||||||
#include <wire/wire_sync.h>
|
#include <wire/wire_sync.h>
|
||||||
|
|
||||||
|
@ -194,11 +194,11 @@ static void update_own_node_announcement(struct daemon *daemon)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Ask hsmd to sign it (synchronous) */
|
/* Ask hsmd to sign it (synchronous) */
|
||||||
if (!wire_sync_write(HSM_FD, take(towire_hsm_node_announcement_sig_req(NULL, nannounce))))
|
if (!wire_sync_write(HSM_FD, take(towire_hsmd_node_announcement_sig_req(NULL, nannounce))))
|
||||||
status_failed(STATUS_FAIL_MASTER_IO, "Could not write to HSM: %s", strerror(errno));
|
status_failed(STATUS_FAIL_MASTER_IO, "Could not write to HSM: %s", strerror(errno));
|
||||||
|
|
||||||
msg = wire_sync_read(tmpctx, HSM_FD);
|
msg = wire_sync_read(tmpctx, HSM_FD);
|
||||||
if (!fromwire_hsm_node_announcement_sig_reply(msg, &sig))
|
if (!fromwire_hsmd_node_announcement_sig_reply(msg, &sig))
|
||||||
status_failed(STATUS_FAIL_MASTER_IO, "HSM returned an invalid node_announcement sig");
|
status_failed(STATUS_FAIL_MASTER_IO, "HSM returned an invalid node_announcement sig");
|
||||||
|
|
||||||
/* We got the signature for our provisional node_announcement back
|
/* We got the signature for our provisional node_announcement back
|
||||||
|
@ -355,13 +355,13 @@ static void update_local_channel(struct local_cupdate *lc /* frees! */)
|
||||||
* callback hell)!, but may need to change to async if we ever want
|
* callback hell)!, but may need to change to async if we ever want
|
||||||
* remote HSMs */
|
* remote HSMs */
|
||||||
if (!wire_sync_write(HSM_FD,
|
if (!wire_sync_write(HSM_FD,
|
||||||
towire_hsm_cupdate_sig_req(tmpctx, update))) {
|
towire_hsmd_cupdate_sig_req(tmpctx, update))) {
|
||||||
status_failed(STATUS_FAIL_HSM_IO, "Writing cupdate_sig_req: %s",
|
status_failed(STATUS_FAIL_HSM_IO, "Writing cupdate_sig_req: %s",
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
msg = wire_sync_read(tmpctx, HSM_FD);
|
msg = wire_sync_read(tmpctx, HSM_FD);
|
||||||
if (!msg || !fromwire_hsm_cupdate_sig_reply(tmpctx, msg, &update)) {
|
if (!msg || !fromwire_hsmd_cupdate_sig_reply(tmpctx, msg, &update)) {
|
||||||
status_failed(STATUS_FAIL_HSM_IO,
|
status_failed(STATUS_FAIL_HSM_IO,
|
||||||
"Reading cupdate_sig_req: %s",
|
"Reading cupdate_sig_req: %s",
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
|
|
|
@ -37,12 +37,12 @@ bool fromwire_gossip_dev_set_max_scids_encode_size(const void *p UNNEEDED, u32 *
|
||||||
/* Generated stub for fromwire_gossipd_local_channel_update */
|
/* Generated stub for fromwire_gossipd_local_channel_update */
|
||||||
bool fromwire_gossipd_local_channel_update(const void *p UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, bool *disable UNNEEDED, u16 *cltv_expiry_delta UNNEEDED, struct amount_msat *htlc_minimum_msat UNNEEDED, u32 *fee_base_msat UNNEEDED, u32 *fee_proportional_millionths UNNEEDED, struct amount_msat *htlc_maximum_msat UNNEEDED)
|
bool fromwire_gossipd_local_channel_update(const void *p UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, bool *disable UNNEEDED, u16 *cltv_expiry_delta UNNEEDED, struct amount_msat *htlc_minimum_msat UNNEEDED, u32 *fee_base_msat UNNEEDED, u32 *fee_proportional_millionths UNNEEDED, struct amount_msat *htlc_maximum_msat UNNEEDED)
|
||||||
{ fprintf(stderr, "fromwire_gossipd_local_channel_update called!\n"); abort(); }
|
{ fprintf(stderr, "fromwire_gossipd_local_channel_update called!\n"); abort(); }
|
||||||
/* Generated stub for fromwire_hsm_cupdate_sig_reply */
|
/* Generated stub for fromwire_hsmd_cupdate_sig_reply */
|
||||||
bool fromwire_hsm_cupdate_sig_reply(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u8 **cu UNNEEDED)
|
bool fromwire_hsmd_cupdate_sig_reply(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u8 **cu UNNEEDED)
|
||||||
{ fprintf(stderr, "fromwire_hsm_cupdate_sig_reply called!\n"); abort(); }
|
{ fprintf(stderr, "fromwire_hsmd_cupdate_sig_reply called!\n"); abort(); }
|
||||||
/* Generated stub for fromwire_hsm_node_announcement_sig_reply */
|
/* Generated stub for fromwire_hsmd_node_announcement_sig_reply */
|
||||||
bool fromwire_hsm_node_announcement_sig_reply(const void *p UNNEEDED, secp256k1_ecdsa_signature *signature UNNEEDED)
|
bool fromwire_hsmd_node_announcement_sig_reply(const void *p UNNEEDED, secp256k1_ecdsa_signature *signature UNNEEDED)
|
||||||
{ fprintf(stderr, "fromwire_hsm_node_announcement_sig_reply called!\n"); abort(); }
|
{ fprintf(stderr, "fromwire_hsmd_node_announcement_sig_reply called!\n"); abort(); }
|
||||||
/* Generated stub for get_node */
|
/* Generated stub for get_node */
|
||||||
struct node *get_node(struct routing_state *rstate UNNEEDED,
|
struct node *get_node(struct routing_state *rstate UNNEEDED,
|
||||||
const struct node_id *id UNNEEDED)
|
const struct node_id *id UNNEEDED)
|
||||||
|
@ -123,12 +123,12 @@ u8 *towire_errorfmt(const tal_t *ctx UNNEEDED,
|
||||||
const struct channel_id *channel UNNEEDED,
|
const struct channel_id *channel UNNEEDED,
|
||||||
const char *fmt UNNEEDED, ...)
|
const char *fmt UNNEEDED, ...)
|
||||||
{ fprintf(stderr, "towire_errorfmt called!\n"); abort(); }
|
{ fprintf(stderr, "towire_errorfmt called!\n"); abort(); }
|
||||||
/* Generated stub for towire_hsm_cupdate_sig_req */
|
/* Generated stub for towire_hsmd_cupdate_sig_req */
|
||||||
u8 *towire_hsm_cupdate_sig_req(const tal_t *ctx UNNEEDED, const u8 *cu UNNEEDED)
|
u8 *towire_hsmd_cupdate_sig_req(const tal_t *ctx UNNEEDED, const u8 *cu UNNEEDED)
|
||||||
{ fprintf(stderr, "towire_hsm_cupdate_sig_req called!\n"); abort(); }
|
{ fprintf(stderr, "towire_hsmd_cupdate_sig_req called!\n"); abort(); }
|
||||||
/* Generated stub for towire_hsm_node_announcement_sig_req */
|
/* Generated stub for towire_hsmd_node_announcement_sig_req */
|
||||||
u8 *towire_hsm_node_announcement_sig_req(const tal_t *ctx UNNEEDED, const u8 *announcement UNNEEDED)
|
u8 *towire_hsmd_node_announcement_sig_req(const tal_t *ctx UNNEEDED, const u8 *announcement UNNEEDED)
|
||||||
{ fprintf(stderr, "towire_hsm_node_announcement_sig_req called!\n"); abort(); }
|
{ fprintf(stderr, "towire_hsmd_node_announcement_sig_req called!\n"); abort(); }
|
||||||
/* Generated stub for towire_wireaddr */
|
/* Generated stub for towire_wireaddr */
|
||||||
void towire_wireaddr(u8 **pptr UNNEEDED, const struct wireaddr *addr UNNEEDED)
|
void towire_wireaddr(u8 **pptr UNNEEDED, const struct wireaddr *addr UNNEEDED)
|
||||||
{ fprintf(stderr, "towire_wireaddr called!\n"); abort(); }
|
{ fprintf(stderr, "towire_wireaddr called!\n"); abort(); }
|
||||||
|
|
|
@ -7,8 +7,8 @@ hsmd-wrongdir:
|
||||||
default: hsmd-all
|
default: hsmd-all
|
||||||
|
|
||||||
LIGHTNINGD_HSM_SRC := hsmd/hsmd.c \
|
LIGHTNINGD_HSM_SRC := hsmd/hsmd.c \
|
||||||
hsmd/gen_hsm_wire.c
|
hsmd/hsmd_wiregen.c
|
||||||
LIGHTNINGD_HSM_HEADERS := hsmd/gen_hsm_wire.h
|
LIGHTNINGD_HSM_HEADERS := hsmd/hsmd_wiregen.h
|
||||||
LIGHTNINGD_HSM_OBJS := $(LIGHTNINGD_HSM_SRC:.c=.o)
|
LIGHTNINGD_HSM_OBJS := $(LIGHTNINGD_HSM_SRC:.c=.o)
|
||||||
|
|
||||||
# Common source we use.
|
# Common source we use.
|
||||||
|
@ -38,27 +38,23 @@ HSMD_COMMON_OBJS := \
|
||||||
common/version.o \
|
common/version.o \
|
||||||
common/withdraw_tx.o
|
common/withdraw_tx.o
|
||||||
|
|
||||||
|
LIGHTNINGD_HSM_CLIENT_OBJS := hsmd/hsmd_wiregen.o
|
||||||
|
|
||||||
# For checking
|
# For checking
|
||||||
LIGHTNINGD_HSM_ALLSRC_NOGEN := $(filter-out hsmd/gen_%, $(LIGHTNINGD_HSM_SRC) $(LIGHTNINGD_HSM_SRC))
|
LIGHTNINGD_HSM_ALLSRC_NOGEN := $(filter-out hsmd/%wiregen.c, $(LIGHTNINGD_HSM_SRC) $(LIGHTNINGD_HSM_SRC))
|
||||||
LIGHTNINGD_HSM_ALLHEADERS_NOGEN := $(filter-out hsmd/gen_%, $(LIGHTNINGD_HSM_HEADERS))
|
LIGHTNINGD_HSM_ALLHEADERS_NOGEN := $(filter-out hsmd/%wiregen.h, $(LIGHTNINGD_HSM_HEADERS))
|
||||||
|
|
||||||
$(LIGHTNINGD_HSM_OBJS): $(LIGHTNINGD_HEADERS)
|
$(LIGHTNINGD_HSM_OBJS): $(LIGHTNINGD_HEADERS)
|
||||||
|
|
||||||
# Make sure these depend on everything.
|
# Make sure these depend on everything.
|
||||||
ALL_OBJS += $(LIGHTNINGD_HSM_OBJS)
|
ALL_OBJS += $(LIGHTNINGD_HSM_OBJS)
|
||||||
ALL_PROGRAMS += lightningd/lightning_hsmd
|
ALL_PROGRAMS += lightningd/lightning_hsmd
|
||||||
ALL_GEN_HEADERS += hsmd/gen_hsm_wire.h
|
ALL_GEN_HEADERS += hsmd/hsmd_wiregen.h
|
||||||
|
|
||||||
hsmd-all: lightningd/lightning_hsmd
|
hsmd-all: lightningd/lightning_hsmd
|
||||||
|
|
||||||
lightningd/lightning_hsmd: $(LIGHTNINGD_HSM_OBJS) $(LIGHTNINGD_LIB_OBJS) $(HSMD_COMMON_OBJS) $(BITCOIN_OBJS) $(WIRE_OBJS)
|
lightningd/lightning_hsmd: $(LIGHTNINGD_HSM_OBJS) $(LIGHTNINGD_LIB_OBJS) $(HSMD_COMMON_OBJS) $(BITCOIN_OBJS) $(WIRE_OBJS)
|
||||||
|
|
||||||
hsmd/gen_hsm_wire.h: $(WIRE_GEN) hsmd/hsm_wire.csv
|
|
||||||
$(WIRE_GEN) --page header $@ hsm_wire_type < hsmd/hsm_wire.csv > $@
|
|
||||||
|
|
||||||
hsmd/gen_hsm_wire.c: $(WIRE_GEN) hsmd/hsm_wire.csv
|
|
||||||
$(WIRE_GEN) --page impl ${@:.c=.h} hsm_wire_type < hsmd/hsm_wire.csv > $@
|
|
||||||
|
|
||||||
check-source: $(LIGHTNINGD_HSM_ALLSRC_NOGEN:%=check-src-include-order/%) $(LIGHTNINGD_HSM_ALLHEADERS_NOGEN:%=check-hdr-include-order/%)
|
check-source: $(LIGHTNINGD_HSM_ALLSRC_NOGEN:%=check-src-include-order/%) $(LIGHTNINGD_HSM_ALLHEADERS_NOGEN:%=check-hdr-include-order/%)
|
||||||
check-source-bolt: $(LIGHTNINGD_HSM_SRC:%=bolt-check/%)
|
check-source-bolt: $(LIGHTNINGD_HSM_SRC:%=bolt-check/%)
|
||||||
|
|
||||||
|
|
|
@ -1,200 +0,0 @@
|
||||||
# Clients should not give a bad request but not the HSM's decision to crash.
|
|
||||||
msgtype,hsmstatus_client_bad_request,1000
|
|
||||||
msgdata,hsmstatus_client_bad_request,id,node_id,
|
|
||||||
msgdata,hsmstatus_client_bad_request,description,wirestring,
|
|
||||||
msgdata,hsmstatus_client_bad_request,len,u16,
|
|
||||||
msgdata,hsmstatus_client_bad_request,msg,u8,len
|
|
||||||
|
|
||||||
#include <bitcoin/chainparams.h>
|
|
||||||
# Start the HSM.
|
|
||||||
msgtype,hsm_init,11
|
|
||||||
msgdata,hsm_init,bip32_key_version,bip32_key_version,
|
|
||||||
msgdata,hsm_init,chainparams,chainparams,
|
|
||||||
msgdata,hsm_init,hsm_encryption_key,?secret,
|
|
||||||
msgdata,hsm_init,dev_force_privkey,?privkey,
|
|
||||||
msgdata,hsm_init,dev_force_bip32_seed,?secret,
|
|
||||||
msgdata,hsm_init,dev_force_channel_secrets,?secrets,
|
|
||||||
msgdata,hsm_init,dev_force_channel_secrets_shaseed,?sha256,
|
|
||||||
|
|
||||||
#include <common/bip32.h>
|
|
||||||
msgtype,hsm_init_reply,111
|
|
||||||
msgdata,hsm_init_reply,node_id,node_id,
|
|
||||||
msgdata,hsm_init_reply,bip32,ext_key,
|
|
||||||
|
|
||||||
# Get a new HSM FD, with the specified capabilities
|
|
||||||
msgtype,hsm_client_hsmfd,9
|
|
||||||
# Which identity to use for requests
|
|
||||||
msgdata,hsm_client_hsmfd,id,node_id,
|
|
||||||
# Database id for this client, if any.
|
|
||||||
msgdata,hsm_client_hsmfd,dbid,u64,
|
|
||||||
msgdata,hsm_client_hsmfd,capabilities,u64,
|
|
||||||
|
|
||||||
# No content, just an fd.
|
|
||||||
msgtype,hsm_client_hsmfd_reply,109
|
|
||||||
|
|
||||||
#include <common/derive_basepoints.h>
|
|
||||||
# Get the basepoints and funding key for this specific channel.
|
|
||||||
msgtype,hsm_get_channel_basepoints,10
|
|
||||||
msgdata,hsm_get_channel_basepoints,peerid,node_id,
|
|
||||||
msgdata,hsm_get_channel_basepoints,dbid,u64,
|
|
||||||
|
|
||||||
msgtype,hsm_get_channel_basepoints_reply,110
|
|
||||||
msgdata,hsm_get_channel_basepoints_reply,basepoints,basepoints,
|
|
||||||
msgdata,hsm_get_channel_basepoints_reply,funding_pubkey,pubkey,
|
|
||||||
|
|
||||||
# Return signature for a funding tx.
|
|
||||||
#include <common/utxo.h>
|
|
||||||
|
|
||||||
# Master asks the HSM to sign a node_announcement
|
|
||||||
msgtype,hsm_node_announcement_sig_req,6
|
|
||||||
msgdata,hsm_node_announcement_sig_req,annlen,u16,
|
|
||||||
msgdata,hsm_node_announcement_sig_req,announcement,u8,annlen
|
|
||||||
|
|
||||||
msgtype,hsm_node_announcement_sig_reply,106
|
|
||||||
msgdata,hsm_node_announcement_sig_reply,signature,secp256k1_ecdsa_signature,
|
|
||||||
|
|
||||||
# Sign a withdrawal request
|
|
||||||
#include <bitcoin/psbt.h>
|
|
||||||
msgtype,hsm_sign_withdrawal,7
|
|
||||||
msgdata,hsm_sign_withdrawal,num_inputs,u16,
|
|
||||||
msgdata,hsm_sign_withdrawal,inputs,utxo,num_inputs
|
|
||||||
msgdata,hsm_sign_withdrawal,psbt,wally_psbt,
|
|
||||||
|
|
||||||
msgtype,hsm_sign_withdrawal_reply,107
|
|
||||||
msgdata,hsm_sign_withdrawal_reply,psbt,wally_psbt,
|
|
||||||
|
|
||||||
# Sign an invoice
|
|
||||||
msgtype,hsm_sign_invoice,8
|
|
||||||
msgdata,hsm_sign_invoice,len,u16,
|
|
||||||
msgdata,hsm_sign_invoice,u5bytes,u8,len
|
|
||||||
msgdata,hsm_sign_invoice,hrplen,u16,
|
|
||||||
msgdata,hsm_sign_invoice,hrp,u8,hrplen
|
|
||||||
|
|
||||||
msgtype,hsm_sign_invoice_reply,108
|
|
||||||
msgdata,hsm_sign_invoice_reply,sig,secp256k1_ecdsa_recoverable_signature,
|
|
||||||
|
|
||||||
# Give me ECDH(node-id-secret,point)
|
|
||||||
msgtype,hsm_ecdh_req,1
|
|
||||||
msgdata,hsm_ecdh_req,point,pubkey,
|
|
||||||
msgtype,hsm_ecdh_resp,100
|
|
||||||
msgdata,hsm_ecdh_resp,ss,secret,
|
|
||||||
|
|
||||||
msgtype,hsm_cannouncement_sig_req,2
|
|
||||||
msgdata,hsm_cannouncement_sig_req,calen,u16,
|
|
||||||
msgdata,hsm_cannouncement_sig_req,ca,u8,calen
|
|
||||||
|
|
||||||
msgtype,hsm_cannouncement_sig_reply,102
|
|
||||||
msgdata,hsm_cannouncement_sig_reply,node_signature,secp256k1_ecdsa_signature,
|
|
||||||
msgdata,hsm_cannouncement_sig_reply,bitcoin_signature,secp256k1_ecdsa_signature,
|
|
||||||
|
|
||||||
msgtype,hsm_cupdate_sig_req,3
|
|
||||||
msgdata,hsm_cupdate_sig_req,culen,u16,
|
|
||||||
msgdata,hsm_cupdate_sig_req,cu,u8,culen
|
|
||||||
|
|
||||||
msgtype,hsm_cupdate_sig_reply,103
|
|
||||||
msgdata,hsm_cupdate_sig_reply,culen,u16,
|
|
||||||
msgdata,hsm_cupdate_sig_reply,cu,u8,culen
|
|
||||||
|
|
||||||
# Master asks HSM to sign a commitment transaction.
|
|
||||||
msgtype,hsm_sign_commitment_tx,5
|
|
||||||
msgdata,hsm_sign_commitment_tx,peer_id,node_id,
|
|
||||||
msgdata,hsm_sign_commitment_tx,channel_dbid,u64,
|
|
||||||
msgdata,hsm_sign_commitment_tx,tx,bitcoin_tx,
|
|
||||||
msgdata,hsm_sign_commitment_tx,remote_funding_key,pubkey,
|
|
||||||
|
|
||||||
msgtype,hsm_sign_commitment_tx_reply,105
|
|
||||||
msgdata,hsm_sign_commitment_tx_reply,sig,bitcoin_signature,
|
|
||||||
|
|
||||||
# Onchaind asks HSM to sign a spend to-us. Four variants, since each set
|
|
||||||
# of keys is derived differently...
|
|
||||||
# FIXME: Have master tell hsmd the keyindex, so it can validate output!
|
|
||||||
msgtype,hsm_sign_delayed_payment_to_us,12
|
|
||||||
msgdata,hsm_sign_delayed_payment_to_us,commit_num,u64,
|
|
||||||
msgdata,hsm_sign_delayed_payment_to_us,tx,bitcoin_tx,
|
|
||||||
msgdata,hsm_sign_delayed_payment_to_us,wscript_len,u16,
|
|
||||||
msgdata,hsm_sign_delayed_payment_to_us,wscript,u8,wscript_len
|
|
||||||
|
|
||||||
msgtype,hsm_sign_remote_htlc_to_us,13
|
|
||||||
msgdata,hsm_sign_remote_htlc_to_us,remote_per_commitment_point,pubkey,
|
|
||||||
msgdata,hsm_sign_remote_htlc_to_us,tx,bitcoin_tx,
|
|
||||||
msgdata,hsm_sign_remote_htlc_to_us,wscript_len,u16,
|
|
||||||
msgdata,hsm_sign_remote_htlc_to_us,wscript,u8,wscript_len
|
|
||||||
msgdata,hsm_sign_remote_htlc_to_us,option_anchor_outputs,bool,
|
|
||||||
|
|
||||||
msgtype,hsm_sign_penalty_to_us,14
|
|
||||||
msgdata,hsm_sign_penalty_to_us,revocation_secret,secret,
|
|
||||||
msgdata,hsm_sign_penalty_to_us,tx,bitcoin_tx,
|
|
||||||
msgdata,hsm_sign_penalty_to_us,wscript_len,u16,
|
|
||||||
msgdata,hsm_sign_penalty_to_us,wscript,u8,wscript_len
|
|
||||||
|
|
||||||
# Onchaind asks HSM to sign a local HTLC success or HTLC timeout tx.
|
|
||||||
msgtype,hsm_sign_local_htlc_tx,16
|
|
||||||
msgdata,hsm_sign_local_htlc_tx,commit_num,u64,
|
|
||||||
msgdata,hsm_sign_local_htlc_tx,tx,bitcoin_tx,
|
|
||||||
msgdata,hsm_sign_local_htlc_tx,wscript_len,u16,
|
|
||||||
msgdata,hsm_sign_local_htlc_tx,wscript,u8,wscript_len
|
|
||||||
msgdata,hsm_sign_local_htlc_tx,option_anchor_outputs,bool,
|
|
||||||
|
|
||||||
# Openingd/channeld asks HSM to sign the other sides' commitment tx.
|
|
||||||
msgtype,hsm_sign_remote_commitment_tx,19
|
|
||||||
msgdata,hsm_sign_remote_commitment_tx,tx,bitcoin_tx,
|
|
||||||
msgdata,hsm_sign_remote_commitment_tx,remote_funding_key,pubkey,
|
|
||||||
msgdata,hsm_sign_remote_commitment_tx,remote_per_commit,pubkey,
|
|
||||||
msgdata,hsm_sign_remote_commitment_tx,option_static_remotekey,bool,
|
|
||||||
|
|
||||||
# channeld asks HSM to sign remote HTLC tx.
|
|
||||||
msgtype,hsm_sign_remote_htlc_tx,20
|
|
||||||
msgdata,hsm_sign_remote_htlc_tx,tx,bitcoin_tx,
|
|
||||||
msgdata,hsm_sign_remote_htlc_tx,len,u16,
|
|
||||||
msgdata,hsm_sign_remote_htlc_tx,wscript,u8,len
|
|
||||||
msgdata,hsm_sign_remote_htlc_tx,remote_per_commit_point,pubkey,
|
|
||||||
msgdata,hsm_sign_remote_htlc_tx,option_anchor_outputs,bool,
|
|
||||||
|
|
||||||
# closingd asks HSM to sign mutual close tx.
|
|
||||||
msgtype,hsm_sign_mutual_close_tx,21
|
|
||||||
msgdata,hsm_sign_mutual_close_tx,tx,bitcoin_tx,
|
|
||||||
msgdata,hsm_sign_mutual_close_tx,remote_funding_key,pubkey,
|
|
||||||
|
|
||||||
# Reply for all the above requests.
|
|
||||||
msgtype,hsm_sign_tx_reply,112
|
|
||||||
msgdata,hsm_sign_tx_reply,sig,bitcoin_signature,
|
|
||||||
|
|
||||||
# Openingd/channeld/onchaind asks for Nth per_commitment_point, if > 2, gets N-2 secret.
|
|
||||||
msgtype,hsm_get_per_commitment_point,18
|
|
||||||
msgdata,hsm_get_per_commitment_point,n,u64,
|
|
||||||
|
|
||||||
msgtype,hsm_get_per_commitment_point_reply,118
|
|
||||||
msgdata,hsm_get_per_commitment_point_reply,per_commitment_point,pubkey,
|
|
||||||
msgdata,hsm_get_per_commitment_point_reply,old_commitment_secret,?secret,
|
|
||||||
|
|
||||||
# master -> hsmd: do you have a memleak?
|
|
||||||
msgtype,hsm_dev_memleak,33
|
|
||||||
|
|
||||||
msgtype,hsm_dev_memleak_reply,133
|
|
||||||
msgdata,hsm_dev_memleak_reply,leak,bool,
|
|
||||||
|
|
||||||
# channeld asks to check if claimed future commitment_secret is correct.
|
|
||||||
msgtype,hsm_check_future_secret,22
|
|
||||||
msgdata,hsm_check_future_secret,n,u64,
|
|
||||||
msgdata,hsm_check_future_secret,commitment_secret,secret,
|
|
||||||
|
|
||||||
msgtype,hsm_check_future_secret_reply,122
|
|
||||||
msgdata,hsm_check_future_secret_reply,correct,bool,
|
|
||||||
|
|
||||||
# lightningd asks us to sign a string.
|
|
||||||
msgtype,hsm_sign_message,23
|
|
||||||
msgdata,hsm_sign_message,len,u16,
|
|
||||||
msgdata,hsm_sign_message,msg,u8,len
|
|
||||||
|
|
||||||
msgtype,hsm_sign_message_reply,123
|
|
||||||
msgdata,hsm_sign_message_reply,sig,secp256k1_ecdsa_recoverable_signature,
|
|
||||||
|
|
||||||
# lightningd needs to get a scriptPubkey for a utxo with closeinfo
|
|
||||||
msgtype,hsm_get_output_scriptpubkey,24
|
|
||||||
msgdata,hsm_get_output_scriptpubkey,channel_id,u64,
|
|
||||||
msgdata,hsm_get_output_scriptpubkey,peer_id,node_id,
|
|
||||||
msgdata,hsm_get_output_scriptpubkey,commitment_point,?pubkey,
|
|
||||||
|
|
||||||
msgtype,hsm_get_output_scriptpubkey_reply,124
|
|
||||||
msgdata,hsm_get_output_scriptpubkey_reply,script_len,u16,
|
|
||||||
msgdata,hsm_get_output_scriptpubkey_reply,script,u8,script_len
|
|
|
244
hsmd/hsmd.c
244
hsmd/hsmd.c
|
@ -41,8 +41,8 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <hsmd/capabilities.h>
|
#include <hsmd/capabilities.h>
|
||||||
/*~ All gen_ files are autogenerated; in this case by tools/generate-wire.py */
|
/*~ _wiregen files are autogenerated by tools/generate-wire.py */
|
||||||
#include <hsmd/gen_hsm_wire.h>
|
#include <hsmd/hsmd_wiregen.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <secp256k1_ecdh.h>
|
#include <secp256k1_ecdh.h>
|
||||||
#include <sodium.h>
|
#include <sodium.h>
|
||||||
|
@ -690,7 +690,7 @@ static struct io_plan *init_hsm(struct io_conn *conn,
|
||||||
* definitions in hsm_client_wire.csv. The format of those files is
|
* definitions in hsm_client_wire.csv. The format of those files is
|
||||||
* an extension of the simple comma-separated format output by the
|
* an extension of the simple comma-separated format output by the
|
||||||
* BOLT tools/extract-formats.py tool. */
|
* BOLT tools/extract-formats.py tool. */
|
||||||
if (!fromwire_hsm_init(NULL, msg_in, &bip32_key_version, &chainparams,
|
if (!fromwire_hsmd_init(NULL, msg_in, &bip32_key_version, &chainparams,
|
||||||
&hsm_encryption_key, &privkey, &seed, &secrets, &shaseed))
|
&hsm_encryption_key, &privkey, &seed, &secrets, &shaseed))
|
||||||
return bad_req(conn, c, msg_in);
|
return bad_req(conn, c, msg_in);
|
||||||
|
|
||||||
|
@ -731,7 +731,7 @@ static struct io_plan *init_hsm(struct io_conn *conn,
|
||||||
* not the secrets! So we're not actually handing them out here!
|
* not the secrets! So we're not actually handing them out here!
|
||||||
*/
|
*/
|
||||||
return req_reply(conn, c,
|
return req_reply(conn, c,
|
||||||
take(towire_hsm_init_reply(NULL, &node_id,
|
take(towire_hsmd_init_reply(NULL, &node_id,
|
||||||
&secretstuff.bip32)));
|
&secretstuff.bip32)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -747,7 +747,7 @@ static struct io_plan *handle_ecdh(struct io_conn *conn,
|
||||||
struct pubkey point;
|
struct pubkey point;
|
||||||
struct secret ss;
|
struct secret ss;
|
||||||
|
|
||||||
if (!fromwire_hsm_ecdh_req(msg_in, &point))
|
if (!fromwire_hsmd_ecdh_req(msg_in, &point))
|
||||||
return bad_req(conn, c, msg_in);
|
return bad_req(conn, c, msg_in);
|
||||||
|
|
||||||
/*~ We simply use the secp256k1_ecdh function: if privkey.secret.data is invalid,
|
/*~ We simply use the secp256k1_ecdh function: if privkey.secret.data is invalid,
|
||||||
|
@ -760,7 +760,7 @@ static struct io_plan *handle_ecdh(struct io_conn *conn,
|
||||||
|
|
||||||
/*~ In the normal case, we return the shared secret, and then read
|
/*~ In the normal case, we return the shared secret, and then read
|
||||||
* the next msg. */
|
* the next msg. */
|
||||||
return req_reply(conn, c, take(towire_hsm_ecdh_resp(NULL, &ss)));
|
return req_reply(conn, c, take(towire_hsmd_ecdh_resp(NULL, &ss)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*~ The specific routine to sign the channel_announcement message. This is
|
/*~ The specific routine to sign the channel_announcement message. This is
|
||||||
|
@ -812,7 +812,7 @@ static struct io_plan *handle_cannouncement_sig(struct io_conn *conn,
|
||||||
/*~ fromwire_ routines which need to do allocation take a tal context
|
/*~ fromwire_ routines which need to do allocation take a tal context
|
||||||
* as their first field; tmpctx is good here since we won't need it
|
* as their first field; tmpctx is good here since we won't need it
|
||||||
* after this function. */
|
* after this function. */
|
||||||
if (!fromwire_hsm_cannouncement_sig_req(tmpctx, msg_in, &ca))
|
if (!fromwire_hsmd_cannouncement_sig_req(tmpctx, msg_in, &ca))
|
||||||
return bad_req(conn, c, msg_in);
|
return bad_req(conn, c, msg_in);
|
||||||
|
|
||||||
if (tal_count(ca) < offset)
|
if (tal_count(ca) < offset)
|
||||||
|
@ -830,7 +830,7 @@ static struct io_plan *handle_cannouncement_sig(struct io_conn *conn,
|
||||||
sign_hash(&node_pkey, &hash, &node_sig);
|
sign_hash(&node_pkey, &hash, &node_sig);
|
||||||
sign_hash(&funding_privkey, &hash, &bitcoin_sig);
|
sign_hash(&funding_privkey, &hash, &bitcoin_sig);
|
||||||
|
|
||||||
reply = towire_hsm_cannouncement_sig_reply(NULL, &node_sig,
|
reply = towire_hsmd_cannouncement_sig_reply(NULL, &node_sig,
|
||||||
&bitcoin_sig);
|
&bitcoin_sig);
|
||||||
return req_reply(conn, c, take(reply));
|
return req_reply(conn, c, take(reply));
|
||||||
}
|
}
|
||||||
|
@ -859,7 +859,7 @@ static struct io_plan *handle_channel_update_sig(struct io_conn *conn,
|
||||||
struct bitcoin_blkid chain_hash;
|
struct bitcoin_blkid chain_hash;
|
||||||
u8 *cu;
|
u8 *cu;
|
||||||
|
|
||||||
if (!fromwire_hsm_cupdate_sig_req(tmpctx, msg_in, &cu))
|
if (!fromwire_hsmd_cupdate_sig_req(tmpctx, msg_in, &cu))
|
||||||
return bad_req(conn, c, msg_in);
|
return bad_req(conn, c, msg_in);
|
||||||
|
|
||||||
if (!fromwire_channel_update_option_channel_htlc_max(cu, &sig,
|
if (!fromwire_channel_update_option_channel_htlc_max(cu, &sig,
|
||||||
|
@ -883,7 +883,7 @@ static struct io_plan *handle_channel_update_sig(struct io_conn *conn,
|
||||||
cltv_expiry_delta, htlc_minimum,
|
cltv_expiry_delta, htlc_minimum,
|
||||||
fee_base_msat, fee_proportional_mill,
|
fee_base_msat, fee_proportional_mill,
|
||||||
htlc_maximum);
|
htlc_maximum);
|
||||||
return req_reply(conn, c, take(towire_hsm_cupdate_sig_reply(NULL, cu)));
|
return req_reply(conn, c, take(towire_hsmd_cupdate_sig_reply(NULL, cu)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*~ This gets the basepoints for a channel; it's not private information really
|
/*~ This gets the basepoints for a channel; it's not private information really
|
||||||
|
@ -902,14 +902,14 @@ static struct io_plan *handle_get_channel_basepoints(struct io_conn *conn,
|
||||||
struct basepoints basepoints;
|
struct basepoints basepoints;
|
||||||
struct pubkey funding_pubkey;
|
struct pubkey funding_pubkey;
|
||||||
|
|
||||||
if (!fromwire_hsm_get_channel_basepoints(msg_in, &peer_id, &dbid))
|
if (!fromwire_hsmd_get_channel_basepoints(msg_in, &peer_id, &dbid))
|
||||||
return bad_req(conn, c, msg_in);
|
return bad_req(conn, c, msg_in);
|
||||||
|
|
||||||
get_channel_seed(&peer_id, dbid, &seed);
|
get_channel_seed(&peer_id, dbid, &seed);
|
||||||
derive_basepoints(&seed, &funding_pubkey, &basepoints, NULL, NULL);
|
derive_basepoints(&seed, &funding_pubkey, &basepoints, NULL, NULL);
|
||||||
|
|
||||||
return req_reply(conn, c,
|
return req_reply(conn, c,
|
||||||
take(towire_hsm_get_channel_basepoints_reply(NULL,
|
take(towire_hsmd_get_channel_basepoints_reply(NULL,
|
||||||
&basepoints,
|
&basepoints,
|
||||||
&funding_pubkey)));
|
&funding_pubkey)));
|
||||||
}
|
}
|
||||||
|
@ -934,7 +934,7 @@ static struct io_plan *handle_sign_commitment_tx(struct io_conn *conn,
|
||||||
struct secrets secrets;
|
struct secrets secrets;
|
||||||
const u8 *funding_wscript;
|
const u8 *funding_wscript;
|
||||||
|
|
||||||
if (!fromwire_hsm_sign_commitment_tx(tmpctx, msg_in,
|
if (!fromwire_hsmd_sign_commitment_tx(tmpctx, msg_in,
|
||||||
&peer_id, &dbid,
|
&peer_id, &dbid,
|
||||||
&tx,
|
&tx,
|
||||||
&remote_funding_pubkey))
|
&remote_funding_pubkey))
|
||||||
|
@ -965,7 +965,7 @@ static struct io_plan *handle_sign_commitment_tx(struct io_conn *conn,
|
||||||
&sig);
|
&sig);
|
||||||
|
|
||||||
return req_reply(conn, c,
|
return req_reply(conn, c,
|
||||||
take(towire_hsm_sign_commitment_tx_reply(NULL, &sig)));
|
take(towire_hsmd_sign_commitment_tx_reply(NULL, &sig)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*~ This is used by channeld to create signatures for the remote peer's
|
/*~ This is used by channeld to create signatures for the remote peer's
|
||||||
|
@ -989,7 +989,7 @@ static struct io_plan *handle_sign_remote_commitment_tx(struct io_conn *conn,
|
||||||
struct pubkey remote_per_commit;
|
struct pubkey remote_per_commit;
|
||||||
bool option_static_remotekey;
|
bool option_static_remotekey;
|
||||||
|
|
||||||
if (!fromwire_hsm_sign_remote_commitment_tx(tmpctx, msg_in,
|
if (!fromwire_hsmd_sign_remote_commitment_tx(tmpctx, msg_in,
|
||||||
&tx,
|
&tx,
|
||||||
&remote_funding_pubkey,
|
&remote_funding_pubkey,
|
||||||
&remote_per_commit,
|
&remote_per_commit,
|
||||||
|
@ -1016,7 +1016,7 @@ static struct io_plan *handle_sign_remote_commitment_tx(struct io_conn *conn,
|
||||||
SIGHASH_ALL,
|
SIGHASH_ALL,
|
||||||
&sig);
|
&sig);
|
||||||
|
|
||||||
return req_reply(conn, c, take(towire_hsm_sign_tx_reply(NULL, &sig)));
|
return req_reply(conn, c, take(towire_hsmd_sign_tx_reply(NULL, &sig)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*~ This is used by channeld to create signatures for the remote peer's
|
/*~ This is used by channeld to create signatures for the remote peer's
|
||||||
|
@ -1036,7 +1036,7 @@ static struct io_plan *handle_sign_remote_htlc_tx(struct io_conn *conn,
|
||||||
struct pubkey htlc_pubkey;
|
struct pubkey htlc_pubkey;
|
||||||
bool option_anchor_outputs;
|
bool option_anchor_outputs;
|
||||||
|
|
||||||
if (!fromwire_hsm_sign_remote_htlc_tx(tmpctx, msg_in,
|
if (!fromwire_hsmd_sign_remote_htlc_tx(tmpctx, msg_in,
|
||||||
&tx, &wscript,
|
&tx, &wscript,
|
||||||
&remote_per_commit_point,
|
&remote_per_commit_point,
|
||||||
&option_anchor_outputs))
|
&option_anchor_outputs))
|
||||||
|
@ -1069,7 +1069,7 @@ static struct io_plan *handle_sign_remote_htlc_tx(struct io_conn *conn,
|
||||||
? (SIGHASH_SINGLE|SIGHASH_ANYONECANPAY)
|
? (SIGHASH_SINGLE|SIGHASH_ANYONECANPAY)
|
||||||
: SIGHASH_ALL, &sig);
|
: SIGHASH_ALL, &sig);
|
||||||
|
|
||||||
return req_reply(conn, c, take(towire_hsm_sign_tx_reply(NULL, &sig)));
|
return req_reply(conn, c, take(towire_hsmd_sign_tx_reply(NULL, &sig)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*~ This covers several cases where onchaind is creating a transaction which
|
/*~ This covers several cases where onchaind is creating a transaction which
|
||||||
|
@ -1094,7 +1094,7 @@ static struct io_plan *handle_sign_to_us_tx(struct io_conn *conn,
|
||||||
|
|
||||||
sign_tx_input(tx, 0, NULL, wscript, privkey, &pubkey, sighash_type, &sig);
|
sign_tx_input(tx, 0, NULL, wscript, privkey, &pubkey, sighash_type, &sig);
|
||||||
|
|
||||||
return req_reply(conn, c, take(towire_hsm_sign_tx_reply(NULL, &sig)));
|
return req_reply(conn, c, take(towire_hsmd_sign_tx_reply(NULL, &sig)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*~ When we send a commitment transaction onchain (unilateral close), there's
|
/*~ When we send a commitment transaction onchain (unilateral close), there's
|
||||||
|
@ -1115,7 +1115,7 @@ static struct io_plan *handle_sign_delayed_payment_to_us(struct io_conn *conn,
|
||||||
u8 *wscript;
|
u8 *wscript;
|
||||||
|
|
||||||
/*~ We don't derive the wscript ourselves, but perhaps we should? */
|
/*~ We don't derive the wscript ourselves, but perhaps we should? */
|
||||||
if (!fromwire_hsm_sign_delayed_payment_to_us(tmpctx, msg_in,
|
if (!fromwire_hsmd_sign_delayed_payment_to_us(tmpctx, msg_in,
|
||||||
&commit_num,
|
&commit_num,
|
||||||
&tx, &wscript))
|
&tx, &wscript))
|
||||||
return bad_req(conn, c, msg_in);
|
return bad_req(conn, c, msg_in);
|
||||||
|
@ -1169,7 +1169,7 @@ static struct io_plan *handle_sign_remote_htlc_to_us(struct io_conn *conn,
|
||||||
u8 *wscript;
|
u8 *wscript;
|
||||||
bool option_anchor_outputs;
|
bool option_anchor_outputs;
|
||||||
|
|
||||||
if (!fromwire_hsm_sign_remote_htlc_to_us(tmpctx, msg_in,
|
if (!fromwire_hsmd_sign_remote_htlc_to_us(tmpctx, msg_in,
|
||||||
&remote_per_commitment_point,
|
&remote_per_commitment_point,
|
||||||
&tx, &wscript,
|
&tx, &wscript,
|
||||||
&option_anchor_outputs))
|
&option_anchor_outputs))
|
||||||
|
@ -1217,7 +1217,7 @@ static struct io_plan *handle_sign_penalty_to_us(struct io_conn *conn,
|
||||||
struct privkey privkey;
|
struct privkey privkey;
|
||||||
u8 *wscript;
|
u8 *wscript;
|
||||||
|
|
||||||
if (!fromwire_hsm_sign_penalty_to_us(tmpctx, msg_in,
|
if (!fromwire_hsmd_sign_penalty_to_us(tmpctx, msg_in,
|
||||||
&revocation_secret,
|
&revocation_secret,
|
||||||
&tx, &wscript))
|
&tx, &wscript))
|
||||||
return bad_req(conn, c, msg_in);
|
return bad_req(conn, c, msg_in);
|
||||||
|
@ -1264,7 +1264,7 @@ static struct io_plan *handle_sign_local_htlc_tx(struct io_conn *conn,
|
||||||
struct pubkey htlc_pubkey;
|
struct pubkey htlc_pubkey;
|
||||||
bool option_anchor_outputs;
|
bool option_anchor_outputs;
|
||||||
|
|
||||||
if (!fromwire_hsm_sign_local_htlc_tx(tmpctx, msg_in,
|
if (!fromwire_hsmd_sign_local_htlc_tx(tmpctx, msg_in,
|
||||||
&commit_num, &tx, &wscript,
|
&commit_num, &tx, &wscript,
|
||||||
&option_anchor_outputs))
|
&option_anchor_outputs))
|
||||||
return bad_req(conn, c, msg_in);
|
return bad_req(conn, c, msg_in);
|
||||||
|
@ -1313,7 +1313,7 @@ static struct io_plan *handle_sign_local_htlc_tx(struct io_conn *conn,
|
||||||
: SIGHASH_ALL,
|
: SIGHASH_ALL,
|
||||||
&sig);
|
&sig);
|
||||||
|
|
||||||
return req_reply(conn, c, take(towire_hsm_sign_tx_reply(NULL, &sig)));
|
return req_reply(conn, c, take(towire_hsmd_sign_tx_reply(NULL, &sig)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*~ This get the Nth a per-commitment point, and for N > 2, returns the
|
/*~ This get the Nth a per-commitment point, and for N > 2, returns the
|
||||||
|
@ -1331,7 +1331,7 @@ static struct io_plan *handle_get_per_commitment_point(struct io_conn *conn,
|
||||||
u64 n;
|
u64 n;
|
||||||
struct secret *old_secret;
|
struct secret *old_secret;
|
||||||
|
|
||||||
if (!fromwire_hsm_get_per_commitment_point(msg_in, &n))
|
if (!fromwire_hsmd_get_per_commitment_point(msg_in, &n))
|
||||||
return bad_req(conn, c, msg_in);
|
return bad_req(conn, c, msg_in);
|
||||||
|
|
||||||
get_channel_seed(&c->id, c->dbid, &channel_seed);
|
get_channel_seed(&c->id, c->dbid, &channel_seed);
|
||||||
|
@ -1356,7 +1356,7 @@ static struct io_plan *handle_get_per_commitment_point(struct io_conn *conn,
|
||||||
* gets included if the parameter is non-NULL. We violate 80 columns
|
* gets included if the parameter is non-NULL. We violate 80 columns
|
||||||
* pretty badly here, but it's a recommendation not a religion. */
|
* pretty badly here, but it's a recommendation not a religion. */
|
||||||
return req_reply(conn, c,
|
return req_reply(conn, c,
|
||||||
take(towire_hsm_get_per_commitment_point_reply(NULL,
|
take(towire_hsmd_get_per_commitment_point_reply(NULL,
|
||||||
&per_commitment_point,
|
&per_commitment_point,
|
||||||
old_secret)));
|
old_secret)));
|
||||||
}
|
}
|
||||||
|
@ -1374,7 +1374,7 @@ static struct io_plan *handle_check_future_secret(struct io_conn *conn,
|
||||||
u64 n;
|
u64 n;
|
||||||
struct secret secret, suggested;
|
struct secret secret, suggested;
|
||||||
|
|
||||||
if (!fromwire_hsm_check_future_secret(msg_in, &n, &suggested))
|
if (!fromwire_hsmd_check_future_secret(msg_in, &n, &suggested))
|
||||||
return bad_req(conn, c, msg_in);
|
return bad_req(conn, c, msg_in);
|
||||||
|
|
||||||
get_channel_seed(&c->id, c->dbid, &channel_seed);
|
get_channel_seed(&c->id, c->dbid, &channel_seed);
|
||||||
|
@ -1390,7 +1390,7 @@ static struct io_plan *handle_check_future_secret(struct io_conn *conn,
|
||||||
* comparison risks leaking information about the secret if it is
|
* comparison risks leaking information about the secret if it is
|
||||||
* timing dependent. */
|
* timing dependent. */
|
||||||
return req_reply(conn, c,
|
return req_reply(conn, c,
|
||||||
take(towire_hsm_check_future_secret_reply(NULL,
|
take(towire_hsmd_check_future_secret_reply(NULL,
|
||||||
secret_eq_consttime(&secret, &suggested))));
|
secret_eq_consttime(&secret, &suggested))));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1406,7 +1406,7 @@ static struct io_plan *handle_sign_mutual_close_tx(struct io_conn *conn,
|
||||||
struct secrets secrets;
|
struct secrets secrets;
|
||||||
const u8 *funding_wscript;
|
const u8 *funding_wscript;
|
||||||
|
|
||||||
if (!fromwire_hsm_sign_mutual_close_tx(tmpctx, msg_in,
|
if (!fromwire_hsmd_sign_mutual_close_tx(tmpctx, msg_in,
|
||||||
&tx,
|
&tx,
|
||||||
&remote_funding_pubkey))
|
&remote_funding_pubkey))
|
||||||
return bad_req(conn, c, msg_in);
|
return bad_req(conn, c, msg_in);
|
||||||
|
@ -1427,7 +1427,7 @@ static struct io_plan *handle_sign_mutual_close_tx(struct io_conn *conn,
|
||||||
&local_funding_pubkey,
|
&local_funding_pubkey,
|
||||||
SIGHASH_ALL, &sig);
|
SIGHASH_ALL, &sig);
|
||||||
|
|
||||||
return req_reply(conn, c, take(towire_hsm_sign_tx_reply(NULL, &sig)));
|
return req_reply(conn, c, take(towire_hsmd_sign_tx_reply(NULL, &sig)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*~ Since we process requests then service them in strict order, and because
|
/*~ Since we process requests then service them in strict order, and because
|
||||||
|
@ -1473,7 +1473,7 @@ static struct io_plan *pass_client_hsmfd(struct io_conn *conn,
|
||||||
/* This must be lightningd itself. */
|
/* This must be lightningd itself. */
|
||||||
assert(is_lightningd(c));
|
assert(is_lightningd(c));
|
||||||
|
|
||||||
if (!fromwire_hsm_client_hsmfd(msg_in, &id, &dbid, &capabilities))
|
if (!fromwire_hsmd_client_hsmfd(msg_in, &id, &dbid, &capabilities))
|
||||||
return bad_req(conn, c, msg_in);
|
return bad_req(conn, c, msg_in);
|
||||||
|
|
||||||
/* socketpair is a bi-directional pipe, which is what we want. */
|
/* socketpair is a bi-directional pipe, which is what we want. */
|
||||||
|
@ -1488,7 +1488,7 @@ static struct io_plan *pass_client_hsmfd(struct io_conn *conn,
|
||||||
* the client pointer to the callback. The other way would be to
|
* the client pointer to the callback. The other way would be to
|
||||||
* create a boutique structure and hand that, but we don't need to. */
|
* create a boutique structure and hand that, but we don't need to. */
|
||||||
pending_client_fd = fds[1];
|
pending_client_fd = fds[1];
|
||||||
return io_write_wire(conn, take(towire_hsm_client_hsmfd_reply(NULL)),
|
return io_write_wire(conn, take(towire_hsmd_client_hsmfd_reply(NULL)),
|
||||||
send_pending_client_fd, c);
|
send_pending_client_fd, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1606,14 +1606,14 @@ static struct io_plan *handle_sign_withdrawal_tx(struct io_conn *conn,
|
||||||
struct utxo **utxos;
|
struct utxo **utxos;
|
||||||
struct wally_psbt *psbt;
|
struct wally_psbt *psbt;
|
||||||
|
|
||||||
if (!fromwire_hsm_sign_withdrawal(tmpctx, msg_in,
|
if (!fromwire_hsmd_sign_withdrawal(tmpctx, msg_in,
|
||||||
&utxos, &psbt))
|
&utxos, &psbt))
|
||||||
return bad_req(conn, c, msg_in);
|
return bad_req(conn, c, msg_in);
|
||||||
|
|
||||||
sign_our_inputs(utxos, psbt);
|
sign_our_inputs(utxos, psbt);
|
||||||
|
|
||||||
return req_reply(conn, c,
|
return req_reply(conn, c,
|
||||||
take(towire_hsm_sign_withdrawal_reply(NULL, psbt)));
|
take(towire_hsmd_sign_withdrawal_reply(NULL, psbt)));
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct io_plan *handle_get_output_scriptpubkey(struct io_conn *conn,
|
static struct io_plan *handle_get_output_scriptpubkey(struct io_conn *conn,
|
||||||
|
@ -1626,7 +1626,7 @@ static struct io_plan *handle_get_output_scriptpubkey(struct io_conn *conn,
|
||||||
u8 *scriptPubkey;
|
u8 *scriptPubkey;
|
||||||
|
|
||||||
info.commitment_point = NULL;
|
info.commitment_point = NULL;
|
||||||
if (!fromwire_hsm_get_output_scriptpubkey(tmpctx, msg_in,
|
if (!fromwire_hsmd_get_output_scriptpubkey(tmpctx, msg_in,
|
||||||
&info.channel_id,
|
&info.channel_id,
|
||||||
&info.peer_id,
|
&info.peer_id,
|
||||||
&info.commitment_point))
|
&info.commitment_point))
|
||||||
|
@ -1637,7 +1637,7 @@ static struct io_plan *handle_get_output_scriptpubkey(struct io_conn *conn,
|
||||||
scriptPubkey = scriptpubkey_p2wpkh(tmpctx, &pubkey);
|
scriptPubkey = scriptpubkey_p2wpkh(tmpctx, &pubkey);
|
||||||
|
|
||||||
return req_reply(conn, c,
|
return req_reply(conn, c,
|
||||||
take(towire_hsm_get_output_scriptpubkey_reply(NULL,
|
take(towire_hsmd_get_output_scriptpubkey_reply(NULL,
|
||||||
scriptPubkey)));
|
scriptPubkey)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1661,7 +1661,7 @@ static struct io_plan *handle_sign_invoice(struct io_conn *conn,
|
||||||
struct hash_u5 hu5;
|
struct hash_u5 hu5;
|
||||||
struct privkey node_pkey;
|
struct privkey node_pkey;
|
||||||
|
|
||||||
if (!fromwire_hsm_sign_invoice(tmpctx, msg_in, &u5bytes, &hrpu8))
|
if (!fromwire_hsmd_sign_invoice(tmpctx, msg_in, &u5bytes, &hrpu8))
|
||||||
return bad_req(conn, c, msg_in);
|
return bad_req(conn, c, msg_in);
|
||||||
|
|
||||||
/* BOLT #11:
|
/* BOLT #11:
|
||||||
|
@ -1702,7 +1702,7 @@ static struct io_plan *handle_sign_invoice(struct io_conn *conn,
|
||||||
}
|
}
|
||||||
|
|
||||||
return req_reply(conn, c,
|
return req_reply(conn, c,
|
||||||
take(towire_hsm_sign_invoice_reply(NULL, &rsig)));
|
take(towire_hsmd_sign_invoice_reply(NULL, &rsig)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*~ It's optional for nodes to send node_announcement, but it lets us set our
|
/*~ It's optional for nodes to send node_announcement, but it lets us set our
|
||||||
|
@ -1728,7 +1728,7 @@ static struct io_plan *handle_sign_node_announcement(struct io_conn *conn,
|
||||||
u8 *reply;
|
u8 *reply;
|
||||||
u8 *ann;
|
u8 *ann;
|
||||||
|
|
||||||
if (!fromwire_hsm_node_announcement_sig_req(tmpctx, msg_in, &ann))
|
if (!fromwire_hsmd_node_announcement_sig_req(tmpctx, msg_in, &ann))
|
||||||
return bad_req(conn, c, msg_in);
|
return bad_req(conn, c, msg_in);
|
||||||
|
|
||||||
if (tal_count(ann) < offset)
|
if (tal_count(ann) < offset)
|
||||||
|
@ -1744,7 +1744,7 @@ static struct io_plan *handle_sign_node_announcement(struct io_conn *conn,
|
||||||
|
|
||||||
sign_hash(&node_pkey, &hash, &sig);
|
sign_hash(&node_pkey, &hash, &sig);
|
||||||
|
|
||||||
reply = towire_hsm_node_announcement_sig_reply(NULL, &sig);
|
reply = towire_hsmd_node_announcement_sig_reply(NULL, &sig);
|
||||||
return req_reply(conn, c, take(reply));
|
return req_reply(conn, c, take(reply));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1766,7 +1766,7 @@ static struct io_plan *handle_sign_message(struct io_conn *conn,
|
||||||
secp256k1_ecdsa_recoverable_signature rsig;
|
secp256k1_ecdsa_recoverable_signature rsig;
|
||||||
struct privkey node_pkey;
|
struct privkey node_pkey;
|
||||||
|
|
||||||
if (!fromwire_hsm_sign_message(tmpctx, msg_in, &msg))
|
if (!fromwire_hsmd_sign_message(tmpctx, msg_in, &msg))
|
||||||
return bad_req(conn, c, msg_in);
|
return bad_req(conn, c, msg_in);
|
||||||
|
|
||||||
/* Prefixing by a known string means we'll never be convinced
|
/* Prefixing by a known string means we'll never be convinced
|
||||||
|
@ -1787,7 +1787,7 @@ static struct io_plan *handle_sign_message(struct io_conn *conn,
|
||||||
}
|
}
|
||||||
|
|
||||||
return req_reply(conn, c,
|
return req_reply(conn, c,
|
||||||
take(towire_hsm_sign_message_reply(NULL, &rsig)));
|
take(towire_hsmd_sign_message_reply(NULL, &rsig)));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if DEVELOPER
|
#if DEVELOPER
|
||||||
|
@ -1812,14 +1812,14 @@ static struct io_plan *handle_memleak(struct io_conn *conn,
|
||||||
memleak_scan_region(memtable, dev_force_bip32_seed, 0);
|
memleak_scan_region(memtable, dev_force_bip32_seed, 0);
|
||||||
|
|
||||||
found_leak = dump_memleak(memtable);
|
found_leak = dump_memleak(memtable);
|
||||||
reply = towire_hsm_dev_memleak_reply(NULL, found_leak);
|
reply = towire_hsmd_dev_memleak_reply(NULL, found_leak);
|
||||||
return req_reply(conn, c, take(reply));
|
return req_reply(conn, c, take(reply));
|
||||||
}
|
}
|
||||||
#endif /* DEVELOPER */
|
#endif /* DEVELOPER */
|
||||||
|
|
||||||
/*~ This routine checks that a client is allowed to call the handler. */
|
/*~ This routine checks that a client is allowed to call the handler. */
|
||||||
static bool check_client_capabilities(struct client *client,
|
static bool check_client_capabilities(struct client *client,
|
||||||
enum hsm_wire_type t)
|
enum hsmd_wire t)
|
||||||
{
|
{
|
||||||
/*~ Here's a useful trick: enums in C are not real types, they're
|
/*~ Here's a useful trick: enums in C are not real types, they're
|
||||||
* semantic sugar sprinkled over an int, bascally (in fact, older
|
* semantic sugar sprinkled over an int, bascally (in fact, older
|
||||||
|
@ -1836,62 +1836,62 @@ static bool check_client_capabilities(struct client *client,
|
||||||
* we add a new enum identifier!
|
* we add a new enum identifier!
|
||||||
*/
|
*/
|
||||||
switch (t) {
|
switch (t) {
|
||||||
case WIRE_HSM_ECDH_REQ:
|
case WIRE_HSMD_ECDH_REQ:
|
||||||
return (client->capabilities & HSM_CAP_ECDH) != 0;
|
return (client->capabilities & HSM_CAP_ECDH) != 0;
|
||||||
|
|
||||||
case WIRE_HSM_CANNOUNCEMENT_SIG_REQ:
|
case WIRE_HSMD_CANNOUNCEMENT_SIG_REQ:
|
||||||
case WIRE_HSM_CUPDATE_SIG_REQ:
|
case WIRE_HSMD_CUPDATE_SIG_REQ:
|
||||||
case WIRE_HSM_NODE_ANNOUNCEMENT_SIG_REQ:
|
case WIRE_HSMD_NODE_ANNOUNCEMENT_SIG_REQ:
|
||||||
return (client->capabilities & HSM_CAP_SIGN_GOSSIP) != 0;
|
return (client->capabilities & HSM_CAP_SIGN_GOSSIP) != 0;
|
||||||
|
|
||||||
case WIRE_HSM_SIGN_DELAYED_PAYMENT_TO_US:
|
case WIRE_HSMD_SIGN_DELAYED_PAYMENT_TO_US:
|
||||||
case WIRE_HSM_SIGN_REMOTE_HTLC_TO_US:
|
case WIRE_HSMD_SIGN_REMOTE_HTLC_TO_US:
|
||||||
case WIRE_HSM_SIGN_PENALTY_TO_US:
|
case WIRE_HSMD_SIGN_PENALTY_TO_US:
|
||||||
case WIRE_HSM_SIGN_LOCAL_HTLC_TX:
|
case WIRE_HSMD_SIGN_LOCAL_HTLC_TX:
|
||||||
return (client->capabilities & HSM_CAP_SIGN_ONCHAIN_TX) != 0;
|
return (client->capabilities & HSM_CAP_SIGN_ONCHAIN_TX) != 0;
|
||||||
|
|
||||||
case WIRE_HSM_GET_PER_COMMITMENT_POINT:
|
case WIRE_HSMD_GET_PER_COMMITMENT_POINT:
|
||||||
case WIRE_HSM_CHECK_FUTURE_SECRET:
|
case WIRE_HSMD_CHECK_FUTURE_SECRET:
|
||||||
return (client->capabilities & HSM_CAP_COMMITMENT_POINT) != 0;
|
return (client->capabilities & HSM_CAP_COMMITMENT_POINT) != 0;
|
||||||
|
|
||||||
case WIRE_HSM_SIGN_REMOTE_COMMITMENT_TX:
|
case WIRE_HSMD_SIGN_REMOTE_COMMITMENT_TX:
|
||||||
case WIRE_HSM_SIGN_REMOTE_HTLC_TX:
|
case WIRE_HSMD_SIGN_REMOTE_HTLC_TX:
|
||||||
return (client->capabilities & HSM_CAP_SIGN_REMOTE_TX) != 0;
|
return (client->capabilities & HSM_CAP_SIGN_REMOTE_TX) != 0;
|
||||||
|
|
||||||
case WIRE_HSM_SIGN_MUTUAL_CLOSE_TX:
|
case WIRE_HSMD_SIGN_MUTUAL_CLOSE_TX:
|
||||||
return (client->capabilities & HSM_CAP_SIGN_CLOSING_TX) != 0;
|
return (client->capabilities & HSM_CAP_SIGN_CLOSING_TX) != 0;
|
||||||
|
|
||||||
case WIRE_HSM_INIT:
|
case WIRE_HSMD_INIT:
|
||||||
case WIRE_HSM_CLIENT_HSMFD:
|
case WIRE_HSMD_CLIENT_HSMFD:
|
||||||
case WIRE_HSM_SIGN_WITHDRAWAL:
|
case WIRE_HSMD_SIGN_WITHDRAWAL:
|
||||||
case WIRE_HSM_SIGN_INVOICE:
|
case WIRE_HSMD_SIGN_INVOICE:
|
||||||
case WIRE_HSM_SIGN_COMMITMENT_TX:
|
case WIRE_HSMD_SIGN_COMMITMENT_TX:
|
||||||
case WIRE_HSM_GET_CHANNEL_BASEPOINTS:
|
case WIRE_HSMD_GET_CHANNEL_BASEPOINTS:
|
||||||
case WIRE_HSM_DEV_MEMLEAK:
|
case WIRE_HSMD_DEV_MEMLEAK:
|
||||||
case WIRE_HSM_SIGN_MESSAGE:
|
case WIRE_HSMD_SIGN_MESSAGE:
|
||||||
case WIRE_HSM_GET_OUTPUT_SCRIPTPUBKEY:
|
case WIRE_HSMD_GET_OUTPUT_SCRIPTPUBKEY:
|
||||||
return (client->capabilities & HSM_CAP_MASTER) != 0;
|
return (client->capabilities & HSM_CAP_MASTER) != 0;
|
||||||
|
|
||||||
/*~ These are messages sent by the HSM so we should never receive them. */
|
/*~ These are messages sent by the HSM so we should never receive them. */
|
||||||
/* FIXME: Since we autogenerate these, we should really generate separate
|
/* FIXME: Since we autogenerate these, we should really generate separate
|
||||||
* enums for replies to avoid this kind of clutter! */
|
* enums for replies to avoid this kind of clutter! */
|
||||||
case WIRE_HSM_ECDH_RESP:
|
case WIRE_HSMD_ECDH_RESP:
|
||||||
case WIRE_HSM_CANNOUNCEMENT_SIG_REPLY:
|
case WIRE_HSMD_CANNOUNCEMENT_SIG_REPLY:
|
||||||
case WIRE_HSM_CUPDATE_SIG_REPLY:
|
case WIRE_HSMD_CUPDATE_SIG_REPLY:
|
||||||
case WIRE_HSM_CLIENT_HSMFD_REPLY:
|
case WIRE_HSMD_CLIENT_HSMFD_REPLY:
|
||||||
case WIRE_HSM_NODE_ANNOUNCEMENT_SIG_REPLY:
|
case WIRE_HSMD_NODE_ANNOUNCEMENT_SIG_REPLY:
|
||||||
case WIRE_HSM_SIGN_WITHDRAWAL_REPLY:
|
case WIRE_HSMD_SIGN_WITHDRAWAL_REPLY:
|
||||||
case WIRE_HSM_SIGN_INVOICE_REPLY:
|
case WIRE_HSMD_SIGN_INVOICE_REPLY:
|
||||||
case WIRE_HSM_INIT_REPLY:
|
case WIRE_HSMD_INIT_REPLY:
|
||||||
case WIRE_HSMSTATUS_CLIENT_BAD_REQUEST:
|
case WIRE_HSMSTATUS_CLIENT_BAD_REQUEST:
|
||||||
case WIRE_HSM_SIGN_COMMITMENT_TX_REPLY:
|
case WIRE_HSMD_SIGN_COMMITMENT_TX_REPLY:
|
||||||
case WIRE_HSM_SIGN_TX_REPLY:
|
case WIRE_HSMD_SIGN_TX_REPLY:
|
||||||
case WIRE_HSM_GET_PER_COMMITMENT_POINT_REPLY:
|
case WIRE_HSMD_GET_PER_COMMITMENT_POINT_REPLY:
|
||||||
case WIRE_HSM_CHECK_FUTURE_SECRET_REPLY:
|
case WIRE_HSMD_CHECK_FUTURE_SECRET_REPLY:
|
||||||
case WIRE_HSM_GET_CHANNEL_BASEPOINTS_REPLY:
|
case WIRE_HSMD_GET_CHANNEL_BASEPOINTS_REPLY:
|
||||||
case WIRE_HSM_DEV_MEMLEAK_REPLY:
|
case WIRE_HSMD_DEV_MEMLEAK_REPLY:
|
||||||
case WIRE_HSM_SIGN_MESSAGE_REPLY:
|
case WIRE_HSMD_SIGN_MESSAGE_REPLY:
|
||||||
case WIRE_HSM_GET_OUTPUT_SCRIPTPUBKEY_REPLY:
|
case WIRE_HSMD_GET_OUTPUT_SCRIPTPUBKEY_REPLY:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -1900,7 +1900,7 @@ static bool check_client_capabilities(struct client *client,
|
||||||
/*~ This is the core of the HSM daemon: handling requests. */
|
/*~ This is the core of the HSM daemon: handling requests. */
|
||||||
static struct io_plan *handle_client(struct io_conn *conn, struct client *c)
|
static struct io_plan *handle_client(struct io_conn *conn, struct client *c)
|
||||||
{
|
{
|
||||||
enum hsm_wire_type t = fromwire_peektype(c->msg_in);
|
enum hsmd_wire t = fromwire_peektype(c->msg_in);
|
||||||
|
|
||||||
status_debug("Client: Received message %d from client", t);
|
status_debug("Client: Received message %d from client", t);
|
||||||
|
|
||||||
|
@ -1912,91 +1912,91 @@ static struct io_plan *handle_client(struct io_conn *conn, struct client *c)
|
||||||
|
|
||||||
/* Now actually go and do what the client asked for */
|
/* Now actually go and do what the client asked for */
|
||||||
switch (t) {
|
switch (t) {
|
||||||
case WIRE_HSM_INIT:
|
case WIRE_HSMD_INIT:
|
||||||
return init_hsm(conn, c, c->msg_in);
|
return init_hsm(conn, c, c->msg_in);
|
||||||
|
|
||||||
case WIRE_HSM_CLIENT_HSMFD:
|
case WIRE_HSMD_CLIENT_HSMFD:
|
||||||
return pass_client_hsmfd(conn, c, c->msg_in);
|
return pass_client_hsmfd(conn, c, c->msg_in);
|
||||||
|
|
||||||
case WIRE_HSM_GET_CHANNEL_BASEPOINTS:
|
case WIRE_HSMD_GET_CHANNEL_BASEPOINTS:
|
||||||
return handle_get_channel_basepoints(conn, c, c->msg_in);
|
return handle_get_channel_basepoints(conn, c, c->msg_in);
|
||||||
|
|
||||||
case WIRE_HSM_GET_OUTPUT_SCRIPTPUBKEY:
|
case WIRE_HSMD_GET_OUTPUT_SCRIPTPUBKEY:
|
||||||
return handle_get_output_scriptpubkey(conn, c, c->msg_in);
|
return handle_get_output_scriptpubkey(conn, c, c->msg_in);
|
||||||
|
|
||||||
case WIRE_HSM_ECDH_REQ:
|
case WIRE_HSMD_ECDH_REQ:
|
||||||
return handle_ecdh(conn, c, c->msg_in);
|
return handle_ecdh(conn, c, c->msg_in);
|
||||||
|
|
||||||
case WIRE_HSM_CANNOUNCEMENT_SIG_REQ:
|
case WIRE_HSMD_CANNOUNCEMENT_SIG_REQ:
|
||||||
return handle_cannouncement_sig(conn, c, c->msg_in);
|
return handle_cannouncement_sig(conn, c, c->msg_in);
|
||||||
|
|
||||||
case WIRE_HSM_CUPDATE_SIG_REQ:
|
case WIRE_HSMD_CUPDATE_SIG_REQ:
|
||||||
return handle_channel_update_sig(conn, c, c->msg_in);
|
return handle_channel_update_sig(conn, c, c->msg_in);
|
||||||
|
|
||||||
case WIRE_HSM_NODE_ANNOUNCEMENT_SIG_REQ:
|
case WIRE_HSMD_NODE_ANNOUNCEMENT_SIG_REQ:
|
||||||
return handle_sign_node_announcement(conn, c, c->msg_in);
|
return handle_sign_node_announcement(conn, c, c->msg_in);
|
||||||
|
|
||||||
case WIRE_HSM_SIGN_INVOICE:
|
case WIRE_HSMD_SIGN_INVOICE:
|
||||||
return handle_sign_invoice(conn, c, c->msg_in);
|
return handle_sign_invoice(conn, c, c->msg_in);
|
||||||
|
|
||||||
case WIRE_HSM_SIGN_WITHDRAWAL:
|
case WIRE_HSMD_SIGN_WITHDRAWAL:
|
||||||
return handle_sign_withdrawal_tx(conn, c, c->msg_in);
|
return handle_sign_withdrawal_tx(conn, c, c->msg_in);
|
||||||
|
|
||||||
case WIRE_HSM_SIGN_COMMITMENT_TX:
|
case WIRE_HSMD_SIGN_COMMITMENT_TX:
|
||||||
return handle_sign_commitment_tx(conn, c, c->msg_in);
|
return handle_sign_commitment_tx(conn, c, c->msg_in);
|
||||||
|
|
||||||
case WIRE_HSM_SIGN_DELAYED_PAYMENT_TO_US:
|
case WIRE_HSMD_SIGN_DELAYED_PAYMENT_TO_US:
|
||||||
return handle_sign_delayed_payment_to_us(conn, c, c->msg_in);
|
return handle_sign_delayed_payment_to_us(conn, c, c->msg_in);
|
||||||
|
|
||||||
case WIRE_HSM_SIGN_REMOTE_HTLC_TO_US:
|
case WIRE_HSMD_SIGN_REMOTE_HTLC_TO_US:
|
||||||
return handle_sign_remote_htlc_to_us(conn, c, c->msg_in);
|
return handle_sign_remote_htlc_to_us(conn, c, c->msg_in);
|
||||||
|
|
||||||
case WIRE_HSM_SIGN_PENALTY_TO_US:
|
case WIRE_HSMD_SIGN_PENALTY_TO_US:
|
||||||
return handle_sign_penalty_to_us(conn, c, c->msg_in);
|
return handle_sign_penalty_to_us(conn, c, c->msg_in);
|
||||||
|
|
||||||
case WIRE_HSM_SIGN_LOCAL_HTLC_TX:
|
case WIRE_HSMD_SIGN_LOCAL_HTLC_TX:
|
||||||
return handle_sign_local_htlc_tx(conn, c, c->msg_in);
|
return handle_sign_local_htlc_tx(conn, c, c->msg_in);
|
||||||
|
|
||||||
case WIRE_HSM_GET_PER_COMMITMENT_POINT:
|
case WIRE_HSMD_GET_PER_COMMITMENT_POINT:
|
||||||
return handle_get_per_commitment_point(conn, c, c->msg_in);
|
return handle_get_per_commitment_point(conn, c, c->msg_in);
|
||||||
|
|
||||||
case WIRE_HSM_CHECK_FUTURE_SECRET:
|
case WIRE_HSMD_CHECK_FUTURE_SECRET:
|
||||||
return handle_check_future_secret(conn, c, c->msg_in);
|
return handle_check_future_secret(conn, c, c->msg_in);
|
||||||
|
|
||||||
case WIRE_HSM_SIGN_REMOTE_COMMITMENT_TX:
|
case WIRE_HSMD_SIGN_REMOTE_COMMITMENT_TX:
|
||||||
return handle_sign_remote_commitment_tx(conn, c, c->msg_in);
|
return handle_sign_remote_commitment_tx(conn, c, c->msg_in);
|
||||||
|
|
||||||
case WIRE_HSM_SIGN_REMOTE_HTLC_TX:
|
case WIRE_HSMD_SIGN_REMOTE_HTLC_TX:
|
||||||
return handle_sign_remote_htlc_tx(conn, c, c->msg_in);
|
return handle_sign_remote_htlc_tx(conn, c, c->msg_in);
|
||||||
|
|
||||||
case WIRE_HSM_SIGN_MUTUAL_CLOSE_TX:
|
case WIRE_HSMD_SIGN_MUTUAL_CLOSE_TX:
|
||||||
return handle_sign_mutual_close_tx(conn, c, c->msg_in);
|
return handle_sign_mutual_close_tx(conn, c, c->msg_in);
|
||||||
|
|
||||||
case WIRE_HSM_SIGN_MESSAGE:
|
case WIRE_HSMD_SIGN_MESSAGE:
|
||||||
return handle_sign_message(conn, c, c->msg_in);
|
return handle_sign_message(conn, c, c->msg_in);
|
||||||
#if DEVELOPER
|
#if DEVELOPER
|
||||||
case WIRE_HSM_DEV_MEMLEAK:
|
case WIRE_HSMD_DEV_MEMLEAK:
|
||||||
return handle_memleak(conn, c, c->msg_in);
|
return handle_memleak(conn, c, c->msg_in);
|
||||||
#else
|
#else
|
||||||
case WIRE_HSM_DEV_MEMLEAK:
|
case WIRE_HSMD_DEV_MEMLEAK:
|
||||||
#endif /* DEVELOPER */
|
#endif /* DEVELOPER */
|
||||||
case WIRE_HSM_ECDH_RESP:
|
case WIRE_HSMD_ECDH_RESP:
|
||||||
case WIRE_HSM_CANNOUNCEMENT_SIG_REPLY:
|
case WIRE_HSMD_CANNOUNCEMENT_SIG_REPLY:
|
||||||
case WIRE_HSM_CUPDATE_SIG_REPLY:
|
case WIRE_HSMD_CUPDATE_SIG_REPLY:
|
||||||
case WIRE_HSM_CLIENT_HSMFD_REPLY:
|
case WIRE_HSMD_CLIENT_HSMFD_REPLY:
|
||||||
case WIRE_HSM_NODE_ANNOUNCEMENT_SIG_REPLY:
|
case WIRE_HSMD_NODE_ANNOUNCEMENT_SIG_REPLY:
|
||||||
case WIRE_HSM_SIGN_WITHDRAWAL_REPLY:
|
case WIRE_HSMD_SIGN_WITHDRAWAL_REPLY:
|
||||||
case WIRE_HSM_SIGN_INVOICE_REPLY:
|
case WIRE_HSMD_SIGN_INVOICE_REPLY:
|
||||||
case WIRE_HSM_INIT_REPLY:
|
case WIRE_HSMD_INIT_REPLY:
|
||||||
case WIRE_HSMSTATUS_CLIENT_BAD_REQUEST:
|
case WIRE_HSMSTATUS_CLIENT_BAD_REQUEST:
|
||||||
case WIRE_HSM_SIGN_COMMITMENT_TX_REPLY:
|
case WIRE_HSMD_SIGN_COMMITMENT_TX_REPLY:
|
||||||
case WIRE_HSM_SIGN_TX_REPLY:
|
case WIRE_HSMD_SIGN_TX_REPLY:
|
||||||
case WIRE_HSM_GET_PER_COMMITMENT_POINT_REPLY:
|
case WIRE_HSMD_GET_PER_COMMITMENT_POINT_REPLY:
|
||||||
case WIRE_HSM_CHECK_FUTURE_SECRET_REPLY:
|
case WIRE_HSMD_CHECK_FUTURE_SECRET_REPLY:
|
||||||
case WIRE_HSM_GET_CHANNEL_BASEPOINTS_REPLY:
|
case WIRE_HSMD_GET_CHANNEL_BASEPOINTS_REPLY:
|
||||||
case WIRE_HSM_DEV_MEMLEAK_REPLY:
|
case WIRE_HSMD_DEV_MEMLEAK_REPLY:
|
||||||
case WIRE_HSM_SIGN_MESSAGE_REPLY:
|
case WIRE_HSMD_SIGN_MESSAGE_REPLY:
|
||||||
case WIRE_HSM_GET_OUTPUT_SCRIPTPUBKEY_REPLY:
|
case WIRE_HSMD_GET_OUTPUT_SCRIPTPUBKEY_REPLY:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
200
hsmd/hsmd_wire.csv
Normal file
200
hsmd/hsmd_wire.csv
Normal file
|
@ -0,0 +1,200 @@
|
||||||
|
# Clients should not give a bad request but not the HSM's decision to crash.
|
||||||
|
msgtype,hsmstatus_client_bad_request,1000
|
||||||
|
msgdata,hsmstatus_client_bad_request,id,node_id,
|
||||||
|
msgdata,hsmstatus_client_bad_request,description,wirestring,
|
||||||
|
msgdata,hsmstatus_client_bad_request,len,u16,
|
||||||
|
msgdata,hsmstatus_client_bad_request,msg,u8,len
|
||||||
|
|
||||||
|
#include <bitcoin/chainparams.h>
|
||||||
|
# Start the HSM.
|
||||||
|
msgtype,hsmd_init,11
|
||||||
|
msgdata,hsmd_init,bip32_key_version,bip32_key_version,
|
||||||
|
msgdata,hsmd_init,chainparams,chainparams,
|
||||||
|
msgdata,hsmd_init,hsm_encryption_key,?secret,
|
||||||
|
msgdata,hsmd_init,dev_force_privkey,?privkey,
|
||||||
|
msgdata,hsmd_init,dev_force_bip32_seed,?secret,
|
||||||
|
msgdata,hsmd_init,dev_force_channel_secrets,?secrets,
|
||||||
|
msgdata,hsmd_init,dev_force_channel_secrets_shaseed,?sha256,
|
||||||
|
|
||||||
|
#include <common/bip32.h>
|
||||||
|
msgtype,hsmd_init_reply,111
|
||||||
|
msgdata,hsmd_init_reply,node_id,node_id,
|
||||||
|
msgdata,hsmd_init_reply,bip32,ext_key,
|
||||||
|
|
||||||
|
# Get a new HSM FD, with the specified capabilities
|
||||||
|
msgtype,hsmd_client_hsmfd,9
|
||||||
|
# Which identity to use for requests
|
||||||
|
msgdata,hsmd_client_hsmfd,id,node_id,
|
||||||
|
# Database id for this client, if any.
|
||||||
|
msgdata,hsmd_client_hsmfd,dbid,u64,
|
||||||
|
msgdata,hsmd_client_hsmfd,capabilities,u64,
|
||||||
|
|
||||||
|
# No content, just an fd.
|
||||||
|
msgtype,hsmd_client_hsmfd_reply,109
|
||||||
|
|
||||||
|
#include <common/derive_basepoints.h>
|
||||||
|
# Get the basepoints and funding key for this specific channel.
|
||||||
|
msgtype,hsmd_get_channel_basepoints,10
|
||||||
|
msgdata,hsmd_get_channel_basepoints,peerid,node_id,
|
||||||
|
msgdata,hsmd_get_channel_basepoints,dbid,u64,
|
||||||
|
|
||||||
|
msgtype,hsmd_get_channel_basepoints_reply,110
|
||||||
|
msgdata,hsmd_get_channel_basepoints_reply,basepoints,basepoints,
|
||||||
|
msgdata,hsmd_get_channel_basepoints_reply,funding_pubkey,pubkey,
|
||||||
|
|
||||||
|
# Return signature for a funding tx.
|
||||||
|
#include <common/utxo.h>
|
||||||
|
|
||||||
|
# Master asks the HSM to sign a node_announcement
|
||||||
|
msgtype,hsmd_node_announcement_sig_req,6
|
||||||
|
msgdata,hsmd_node_announcement_sig_req,annlen,u16,
|
||||||
|
msgdata,hsmd_node_announcement_sig_req,announcement,u8,annlen
|
||||||
|
|
||||||
|
msgtype,hsmd_node_announcement_sig_reply,106
|
||||||
|
msgdata,hsmd_node_announcement_sig_reply,signature,secp256k1_ecdsa_signature,
|
||||||
|
|
||||||
|
# Sign a withdrawal request
|
||||||
|
#include <bitcoin/psbt.h>
|
||||||
|
msgtype,hsmd_sign_withdrawal,7
|
||||||
|
msgdata,hsmd_sign_withdrawal,num_inputs,u16,
|
||||||
|
msgdata,hsmd_sign_withdrawal,inputs,utxo,num_inputs
|
||||||
|
msgdata,hsmd_sign_withdrawal,psbt,wally_psbt,
|
||||||
|
|
||||||
|
msgtype,hsmd_sign_withdrawal_reply,107
|
||||||
|
msgdata,hsmd_sign_withdrawal_reply,psbt,wally_psbt,
|
||||||
|
|
||||||
|
# Sign an invoice
|
||||||
|
msgtype,hsmd_sign_invoice,8
|
||||||
|
msgdata,hsmd_sign_invoice,len,u16,
|
||||||
|
msgdata,hsmd_sign_invoice,u5bytes,u8,len
|
||||||
|
msgdata,hsmd_sign_invoice,hrplen,u16,
|
||||||
|
msgdata,hsmd_sign_invoice,hrp,u8,hrplen
|
||||||
|
|
||||||
|
msgtype,hsmd_sign_invoice_reply,108
|
||||||
|
msgdata,hsmd_sign_invoice_reply,sig,secp256k1_ecdsa_recoverable_signature,
|
||||||
|
|
||||||
|
# Give me ECDH(node-id-secret,point)
|
||||||
|
msgtype,hsmd_ecdh_req,1
|
||||||
|
msgdata,hsmd_ecdh_req,point,pubkey,
|
||||||
|
msgtype,hsmd_ecdh_resp,100
|
||||||
|
msgdata,hsmd_ecdh_resp,ss,secret,
|
||||||
|
|
||||||
|
msgtype,hsmd_cannouncement_sig_req,2
|
||||||
|
msgdata,hsmd_cannouncement_sig_req,calen,u16,
|
||||||
|
msgdata,hsmd_cannouncement_sig_req,ca,u8,calen
|
||||||
|
|
||||||
|
msgtype,hsmd_cannouncement_sig_reply,102
|
||||||
|
msgdata,hsmd_cannouncement_sig_reply,node_signature,secp256k1_ecdsa_signature,
|
||||||
|
msgdata,hsmd_cannouncement_sig_reply,bitcoin_signature,secp256k1_ecdsa_signature,
|
||||||
|
|
||||||
|
msgtype,hsmd_cupdate_sig_req,3
|
||||||
|
msgdata,hsmd_cupdate_sig_req,culen,u16,
|
||||||
|
msgdata,hsmd_cupdate_sig_req,cu,u8,culen
|
||||||
|
|
||||||
|
msgtype,hsmd_cupdate_sig_reply,103
|
||||||
|
msgdata,hsmd_cupdate_sig_reply,culen,u16,
|
||||||
|
msgdata,hsmd_cupdate_sig_reply,cu,u8,culen
|
||||||
|
|
||||||
|
# Master asks HSM to sign a commitment transaction.
|
||||||
|
msgtype,hsmd_sign_commitment_tx,5
|
||||||
|
msgdata,hsmd_sign_commitment_tx,peer_id,node_id,
|
||||||
|
msgdata,hsmd_sign_commitment_tx,channel_dbid,u64,
|
||||||
|
msgdata,hsmd_sign_commitment_tx,tx,bitcoin_tx,
|
||||||
|
msgdata,hsmd_sign_commitment_tx,remote_funding_key,pubkey,
|
||||||
|
|
||||||
|
msgtype,hsmd_sign_commitment_tx_reply,105
|
||||||
|
msgdata,hsmd_sign_commitment_tx_reply,sig,bitcoin_signature,
|
||||||
|
|
||||||
|
# Onchaind asks HSM to sign a spend to-us. Four variants, since each set
|
||||||
|
# of keys is derived differently...
|
||||||
|
# FIXME: Have master tell hsmd the keyindex, so it can validate output!
|
||||||
|
msgtype,hsmd_sign_delayed_payment_to_us,12
|
||||||
|
msgdata,hsmd_sign_delayed_payment_to_us,commit_num,u64,
|
||||||
|
msgdata,hsmd_sign_delayed_payment_to_us,tx,bitcoin_tx,
|
||||||
|
msgdata,hsmd_sign_delayed_payment_to_us,wscript_len,u16,
|
||||||
|
msgdata,hsmd_sign_delayed_payment_to_us,wscript,u8,wscript_len
|
||||||
|
|
||||||
|
msgtype,hsmd_sign_remote_htlc_to_us,13
|
||||||
|
msgdata,hsmd_sign_remote_htlc_to_us,remote_per_commitment_point,pubkey,
|
||||||
|
msgdata,hsmd_sign_remote_htlc_to_us,tx,bitcoin_tx,
|
||||||
|
msgdata,hsmd_sign_remote_htlc_to_us,wscript_len,u16,
|
||||||
|
msgdata,hsmd_sign_remote_htlc_to_us,wscript,u8,wscript_len
|
||||||
|
msgdata,hsmd_sign_remote_htlc_to_us,option_anchor_outputs,bool,
|
||||||
|
|
||||||
|
msgtype,hsmd_sign_penalty_to_us,14
|
||||||
|
msgdata,hsmd_sign_penalty_to_us,revocation_secret,secret,
|
||||||
|
msgdata,hsmd_sign_penalty_to_us,tx,bitcoin_tx,
|
||||||
|
msgdata,hsmd_sign_penalty_to_us,wscript_len,u16,
|
||||||
|
msgdata,hsmd_sign_penalty_to_us,wscript,u8,wscript_len
|
||||||
|
|
||||||
|
# Onchaind asks HSM to sign a local HTLC success or HTLC timeout tx.
|
||||||
|
msgtype,hsmd_sign_local_htlc_tx,16
|
||||||
|
msgdata,hsmd_sign_local_htlc_tx,commit_num,u64,
|
||||||
|
msgdata,hsmd_sign_local_htlc_tx,tx,bitcoin_tx,
|
||||||
|
msgdata,hsmd_sign_local_htlc_tx,wscript_len,u16,
|
||||||
|
msgdata,hsmd_sign_local_htlc_tx,wscript,u8,wscript_len
|
||||||
|
msgdata,hsmd_sign_local_htlc_tx,option_anchor_outputs,bool,
|
||||||
|
|
||||||
|
# Openingd/channeld asks HSM to sign the other sides' commitment tx.
|
||||||
|
msgtype,hsmd_sign_remote_commitment_tx,19
|
||||||
|
msgdata,hsmd_sign_remote_commitment_tx,tx,bitcoin_tx,
|
||||||
|
msgdata,hsmd_sign_remote_commitment_tx,remote_funding_key,pubkey,
|
||||||
|
msgdata,hsmd_sign_remote_commitment_tx,remote_per_commit,pubkey,
|
||||||
|
msgdata,hsmd_sign_remote_commitment_tx,option_static_remotekey,bool,
|
||||||
|
|
||||||
|
# channeld asks HSM to sign remote HTLC tx.
|
||||||
|
msgtype,hsmd_sign_remote_htlc_tx,20
|
||||||
|
msgdata,hsmd_sign_remote_htlc_tx,tx,bitcoin_tx,
|
||||||
|
msgdata,hsmd_sign_remote_htlc_tx,len,u16,
|
||||||
|
msgdata,hsmd_sign_remote_htlc_tx,wscript,u8,len
|
||||||
|
msgdata,hsmd_sign_remote_htlc_tx,remote_per_commit_point,pubkey,
|
||||||
|
msgdata,hsmd_sign_remote_htlc_tx,option_anchor_outputs,bool,
|
||||||
|
|
||||||
|
# closingd asks HSM to sign mutual close tx.
|
||||||
|
msgtype,hsmd_sign_mutual_close_tx,21
|
||||||
|
msgdata,hsmd_sign_mutual_close_tx,tx,bitcoin_tx,
|
||||||
|
msgdata,hsmd_sign_mutual_close_tx,remote_funding_key,pubkey,
|
||||||
|
|
||||||
|
# Reply for all the above requests.
|
||||||
|
msgtype,hsmd_sign_tx_reply,112
|
||||||
|
msgdata,hsmd_sign_tx_reply,sig,bitcoin_signature,
|
||||||
|
|
||||||
|
# Openingd/channeld/onchaind asks for Nth per_commitment_point, if > 2, gets N-2 secret.
|
||||||
|
msgtype,hsmd_get_per_commitment_point,18
|
||||||
|
msgdata,hsmd_get_per_commitment_point,n,u64,
|
||||||
|
|
||||||
|
msgtype,hsmd_get_per_commitment_point_reply,118
|
||||||
|
msgdata,hsmd_get_per_commitment_point_reply,per_commitment_point,pubkey,
|
||||||
|
msgdata,hsmd_get_per_commitment_point_reply,old_commitment_secret,?secret,
|
||||||
|
|
||||||
|
# master -> hsmd: do you have a memleak?
|
||||||
|
msgtype,hsmd_dev_memleak,33
|
||||||
|
|
||||||
|
msgtype,hsmd_dev_memleak_reply,133
|
||||||
|
msgdata,hsmd_dev_memleak_reply,leak,bool,
|
||||||
|
|
||||||
|
# channeld asks to check if claimed future commitment_secret is correct.
|
||||||
|
msgtype,hsmd_check_future_secret,22
|
||||||
|
msgdata,hsmd_check_future_secret,n,u64,
|
||||||
|
msgdata,hsmd_check_future_secret,commitment_secret,secret,
|
||||||
|
|
||||||
|
msgtype,hsmd_check_future_secret_reply,122
|
||||||
|
msgdata,hsmd_check_future_secret_reply,correct,bool,
|
||||||
|
|
||||||
|
# lightningd asks us to sign a string.
|
||||||
|
msgtype,hsmd_sign_message,23
|
||||||
|
msgdata,hsmd_sign_message,len,u16,
|
||||||
|
msgdata,hsmd_sign_message,msg,u8,len
|
||||||
|
|
||||||
|
msgtype,hsmd_sign_message_reply,123
|
||||||
|
msgdata,hsmd_sign_message_reply,sig,secp256k1_ecdsa_recoverable_signature,
|
||||||
|
|
||||||
|
# lightningd needs to get a scriptPubkey for a utxo with closeinfo
|
||||||
|
msgtype,hsmd_get_output_scriptpubkey,24
|
||||||
|
msgdata,hsmd_get_output_scriptpubkey,channel_id,u64,
|
||||||
|
msgdata,hsmd_get_output_scriptpubkey,peer_id,node_id,
|
||||||
|
msgdata,hsmd_get_output_scriptpubkey,commitment_point,?pubkey,
|
||||||
|
|
||||||
|
msgtype,hsmd_get_output_scriptpubkey_reply,124
|
||||||
|
msgdata,hsmd_get_output_scriptpubkey_reply,script_len,u16,
|
||||||
|
msgdata,hsmd_get_output_scriptpubkey_reply,script,u8,script_len
|
|
|
@ -72,8 +72,7 @@ LIGHTNINGD_COMMON_OBJS := \
|
||||||
common/wallet_tx.o \
|
common/wallet_tx.o \
|
||||||
common/wire_error.o \
|
common/wire_error.o \
|
||||||
common/wireaddr.o \
|
common/wireaddr.o \
|
||||||
common/withdraw_tx.o \
|
common/withdraw_tx.o
|
||||||
hsmd/gen_hsm_wire.o
|
|
||||||
|
|
||||||
LIGHTNINGD_SRC := \
|
LIGHTNINGD_SRC := \
|
||||||
lightningd/bitcoind.c \
|
lightningd/bitcoind.c \
|
||||||
|
@ -153,7 +152,7 @@ check-makefile: check-lightningd-makefile
|
||||||
check-lightningd-makefile:
|
check-lightningd-makefile:
|
||||||
@for f in lightningd/*.h lightningd/*/*.h; do if ! echo $(LIGHTNINGD_HEADERS_NOGEN) $(LIGHTNINGD_HEADERS_GEN) "" | grep -q "$$f "; then echo $$f not mentioned in LIGHTNINGD_HEADERS_NOGEN or LIGHTNINGD_HEADERS_GEN >&2; exit 1; fi; done
|
@for f in lightningd/*.h lightningd/*/*.h; do if ! echo $(LIGHTNINGD_HEADERS_NOGEN) $(LIGHTNINGD_HEADERS_GEN) "" | grep -q "$$f "; then echo $$f not mentioned in LIGHTNINGD_HEADERS_NOGEN or LIGHTNINGD_HEADERS_GEN >&2; exit 1; fi; done
|
||||||
|
|
||||||
lightningd/lightningd: $(LIGHTNINGD_OBJS) $(LIGHTNINGD_COMMON_OBJS) $(BITCOIN_OBJS) $(WIRE_OBJS) $(WIRE_ONION_OBJS) $(LIGHTNINGD_HANDSHAKE_CONTROL_OBJS) $(LIGHTNINGD_GOSSIP_CONTROL_OBJS) $(LIGHTNINGD_OPENING_CONTROL_OBJS) $(LIGHTNINGD_CHANNEL_CONTROL_OBJS) $(LIGHTNINGD_CLOSING_CONTROL_OBJS) $(LIGHTNINGD_ONCHAIN_CONTROL_OBJS) $(WALLET_LIB_OBJS) $(LIGHTNINGD_CONNECT_CONTROL_OBJS)
|
lightningd/lightningd: $(LIGHTNINGD_OBJS) $(LIGHTNINGD_COMMON_OBJS) $(BITCOIN_OBJS) $(WIRE_OBJS) $(WIRE_ONION_OBJS) $(LIGHTNINGD_HANDSHAKE_CONTROL_OBJS) $(LIGHTNINGD_GOSSIP_CONTROL_OBJS) $(LIGHTNINGD_OPENING_CONTROL_OBJS) $(LIGHTNINGD_CHANNEL_CONTROL_OBJS) $(LIGHTNINGD_CLOSING_CONTROL_OBJS) $(LIGHTNINGD_ONCHAIN_CONTROL_OBJS) $(WALLET_LIB_OBJS) $(LIGHTNINGD_CONNECT_CONTROL_OBJS) $(LIGHTNINGD_HSM_CLIENT_OBJS)
|
||||||
|
|
||||||
clean: lightningd-clean
|
clean: lightningd-clean
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
#include <common/wire_error.h>
|
#include <common/wire_error.h>
|
||||||
#include <connectd/gen_connect_wire.h>
|
#include <connectd/gen_connect_wire.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <hsmd/gen_hsm_wire.h>
|
#include <hsmd/hsmd_wiregen.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <lightningd/channel.h>
|
#include <lightningd/channel.h>
|
||||||
#include <lightningd/connect_control.h>
|
#include <lightningd/connect_control.h>
|
||||||
|
@ -130,12 +130,12 @@ void get_channel_basepoints(struct lightningd *ld,
|
||||||
u8 *msg;
|
u8 *msg;
|
||||||
|
|
||||||
assert(dbid != 0);
|
assert(dbid != 0);
|
||||||
msg = towire_hsm_get_channel_basepoints(NULL, peer_id, dbid);
|
msg = towire_hsmd_get_channel_basepoints(NULL, peer_id, dbid);
|
||||||
if (!wire_sync_write(ld->hsm_fd, take(msg)))
|
if (!wire_sync_write(ld->hsm_fd, take(msg)))
|
||||||
fatal("Could not write to HSM: %s", strerror(errno));
|
fatal("Could not write to HSM: %s", strerror(errno));
|
||||||
|
|
||||||
msg = wire_sync_read(tmpctx, ld->hsm_fd);
|
msg = wire_sync_read(tmpctx, ld->hsm_fd);
|
||||||
if (!fromwire_hsm_get_channel_basepoints_reply(msg, local_basepoints,
|
if (!fromwire_hsmd_get_channel_basepoints_reply(msg, local_basepoints,
|
||||||
local_funding_pubkey))
|
local_funding_pubkey))
|
||||||
fatal("HSM gave bad hsm_get_channel_basepoints_reply %s",
|
fatal("HSM gave bad hsm_get_channel_basepoints_reply %s",
|
||||||
tal_hex(msg, msg));
|
tal_hex(msg, msg));
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
#include <common/wallet_tx.h>
|
#include <common/wallet_tx.h>
|
||||||
#include <common/wire_error.h>
|
#include <common/wire_error.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <hsmd/gen_hsm_wire.h>
|
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <lightningd/channel_control.h>
|
#include <lightningd/channel_control.h>
|
||||||
#include <lightningd/closing_control.h>
|
#include <lightningd/closing_control.h>
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
#include <connectd/gen_connect_wire.h>
|
#include <connectd/gen_connect_wire.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <hsmd/capabilities.h>
|
#include <hsmd/capabilities.h>
|
||||||
#include <hsmd/gen_hsm_wire.h>
|
|
||||||
#include <lightningd/channel.h>
|
#include <lightningd/channel.h>
|
||||||
#include <lightningd/connect_control.h>
|
#include <lightningd/connect_control.h>
|
||||||
#include <lightningd/hsm_control.h>
|
#include <lightningd/hsm_control.h>
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <gossipd/gen_gossip_wire.h>
|
#include <gossipd/gen_gossip_wire.h>
|
||||||
#include <hsmd/capabilities.h>
|
#include <hsmd/capabilities.h>
|
||||||
#include <hsmd/gen_hsm_wire.h>
|
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <lightningd/connect_control.h>
|
#include <lightningd/connect_control.h>
|
||||||
#include <lightningd/gossip_msg.h>
|
#include <lightningd/gossip_msg.h>
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
#include <common/status.h>
|
#include <common/status.h>
|
||||||
#include <common/utils.h>
|
#include <common/utils.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <hsmd/gen_hsm_wire.h>
|
#include <hsmd/hsmd_wiregen.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <lightningd/bitcoind.h>
|
#include <lightningd/bitcoind.h>
|
||||||
#include <lightningd/hsm_control.h>
|
#include <lightningd/hsm_control.h>
|
||||||
|
@ -36,12 +36,12 @@ static int hsm_get_fd(struct lightningd *ld,
|
||||||
int hsm_fd;
|
int hsm_fd;
|
||||||
u8 *msg;
|
u8 *msg;
|
||||||
|
|
||||||
msg = towire_hsm_client_hsmfd(NULL, id, dbid, capabilities);
|
msg = towire_hsmd_client_hsmfd(NULL, id, dbid, capabilities);
|
||||||
if (!wire_sync_write(ld->hsm_fd, take(msg)))
|
if (!wire_sync_write(ld->hsm_fd, take(msg)))
|
||||||
fatal("Could not write to HSM: %s", strerror(errno));
|
fatal("Could not write to HSM: %s", strerror(errno));
|
||||||
|
|
||||||
msg = wire_sync_read(tmpctx, ld->hsm_fd);
|
msg = wire_sync_read(tmpctx, ld->hsm_fd);
|
||||||
if (!fromwire_hsm_client_hsmfd_reply(msg))
|
if (!fromwire_hsmd_client_hsmfd_reply(msg))
|
||||||
fatal("Bad reply from HSM: %s", tal_hex(tmpctx, msg));
|
fatal("Bad reply from HSM: %s", tal_hex(tmpctx, msg));
|
||||||
|
|
||||||
hsm_fd = fdpass_recv(ld->hsm_fd);
|
hsm_fd = fdpass_recv(ld->hsm_fd);
|
||||||
|
@ -95,7 +95,7 @@ struct ext_key *hsm_init(struct lightningd *ld)
|
||||||
err(1, "Could not create hsm socketpair");
|
err(1, "Could not create hsm socketpair");
|
||||||
|
|
||||||
ld->hsm = new_global_subd(ld, "lightning_hsmd",
|
ld->hsm = new_global_subd(ld, "lightning_hsmd",
|
||||||
hsm_wire_type_name,
|
hsmd_wire_name,
|
||||||
hsm_msg,
|
hsm_msg,
|
||||||
take(&fds[1]), NULL);
|
take(&fds[1]), NULL);
|
||||||
if (!ld->hsm)
|
if (!ld->hsm)
|
||||||
|
@ -112,7 +112,7 @@ struct ext_key *hsm_init(struct lightningd *ld)
|
||||||
}
|
}
|
||||||
|
|
||||||
ld->hsm_fd = fds[0];
|
ld->hsm_fd = fds[0];
|
||||||
if (!wire_sync_write(ld->hsm_fd, towire_hsm_init(tmpctx,
|
if (!wire_sync_write(ld->hsm_fd, towire_hsmd_init(tmpctx,
|
||||||
&chainparams->bip32_key_version,
|
&chainparams->bip32_key_version,
|
||||||
chainparams,
|
chainparams,
|
||||||
ld->config.keypass,
|
ld->config.keypass,
|
||||||
|
@ -124,7 +124,7 @@ struct ext_key *hsm_init(struct lightningd *ld)
|
||||||
|
|
||||||
bip32_base = tal(ld, struct ext_key);
|
bip32_base = tal(ld, struct ext_key);
|
||||||
msg = wire_sync_read(tmpctx, ld->hsm_fd);
|
msg = wire_sync_read(tmpctx, ld->hsm_fd);
|
||||||
if (!fromwire_hsm_init_reply(msg,
|
if (!fromwire_hsmd_init_reply(msg,
|
||||||
&ld->id, bip32_base)) {
|
&ld->id, bip32_base)) {
|
||||||
if (ld->config.keypass)
|
if (ld->config.keypass)
|
||||||
errx(1, "Wrong password for encrypted hsm_secret.");
|
errx(1, "Wrong password for encrypted hsm_secret.");
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
#include <common/utils.h>
|
#include <common/utils.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <gossipd/gen_gossip_wire.h>
|
#include <gossipd/gen_gossip_wire.h>
|
||||||
#include <hsmd/gen_hsm_wire.h>
|
#include <hsmd/hsmd_wiregen.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <lightningd/channel.h>
|
#include <lightningd/channel.h>
|
||||||
#include <lightningd/hsm_control.h>
|
#include <lightningd/hsm_control.h>
|
||||||
|
@ -399,13 +399,13 @@ static bool hsm_sign_b11(const u5 *u5bytes,
|
||||||
secp256k1_ecdsa_recoverable_signature *rsig,
|
secp256k1_ecdsa_recoverable_signature *rsig,
|
||||||
struct lightningd *ld)
|
struct lightningd *ld)
|
||||||
{
|
{
|
||||||
u8 *msg = towire_hsm_sign_invoice(NULL, u5bytes, hrpu8);
|
u8 *msg = towire_hsmd_sign_invoice(NULL, u5bytes, hrpu8);
|
||||||
|
|
||||||
if (!wire_sync_write(ld->hsm_fd, take(msg)))
|
if (!wire_sync_write(ld->hsm_fd, take(msg)))
|
||||||
fatal("Could not write to HSM: %s", strerror(errno));
|
fatal("Could not write to HSM: %s", strerror(errno));
|
||||||
|
|
||||||
msg = wire_sync_read(tmpctx, ld->hsm_fd);
|
msg = wire_sync_read(tmpctx, ld->hsm_fd);
|
||||||
if (!fromwire_hsm_sign_invoice_reply(msg, rsig))
|
if (!fromwire_hsmd_sign_invoice_reply(msg, rsig))
|
||||||
fatal("HSM gave bad sign_invoice_reply %s",
|
fatal("HSM gave bad sign_invoice_reply %s",
|
||||||
tal_hex(msg, msg));
|
tal_hex(msg, msg));
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
#include <connectd/gen_connect_wire.h>
|
#include <connectd/gen_connect_wire.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <gossipd/gen_gossip_wire.h>
|
#include <gossipd/gen_gossip_wire.h>
|
||||||
#include <hsmd/gen_hsm_wire.h>
|
#include <hsmd/hsmd_wiregen.h>
|
||||||
#include <lightningd/chaintopology.h>
|
#include <lightningd/chaintopology.h>
|
||||||
#include <lightningd/jsonrpc.h>
|
#include <lightningd/jsonrpc.h>
|
||||||
#include <lightningd/lightningd.h>
|
#include <lightningd/lightningd.h>
|
||||||
|
@ -265,7 +265,7 @@ static void hsm_dev_memleak_done(struct subd *hsmd,
|
||||||
struct lightningd *ld = cmd->ld;
|
struct lightningd *ld = cmd->ld;
|
||||||
bool found_leak;
|
bool found_leak;
|
||||||
|
|
||||||
if (!fromwire_hsm_dev_memleak_reply(reply, &found_leak)) {
|
if (!fromwire_hsmd_dev_memleak_reply(reply, &found_leak)) {
|
||||||
was_pending(command_fail(cmd, LIGHTNINGD,
|
was_pending(command_fail(cmd, LIGHTNINGD,
|
||||||
"Bad hsm_dev_memleak"));
|
"Bad hsm_dev_memleak"));
|
||||||
return;
|
return;
|
||||||
|
@ -287,7 +287,7 @@ void peer_memleak_done(struct command *cmd, struct subd *leaker)
|
||||||
report_leak_info(cmd, leaker);
|
report_leak_info(cmd, leaker);
|
||||||
else {
|
else {
|
||||||
/* No leak there, try hsmd (we talk to hsm sync) */
|
/* No leak there, try hsmd (we talk to hsm sync) */
|
||||||
u8 *msg = towire_hsm_dev_memleak(NULL);
|
u8 *msg = towire_hsmd_dev_memleak(NULL);
|
||||||
if (!wire_sync_write(cmd->ld->hsm_fd, take(msg)))
|
if (!wire_sync_write(cmd->ld->hsm_fd, take(msg)))
|
||||||
fatal("Could not write to HSM: %s", strerror(errno));
|
fatal("Could not write to HSM: %s", strerror(errno));
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
#include <common/key_derive.h>
|
#include <common/key_derive.h>
|
||||||
#include <common/utils.h>
|
#include <common/utils.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <hsmd/gen_hsm_wire.h>
|
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <lightningd/chaintopology.h>
|
#include <lightningd/chaintopology.h>
|
||||||
#include <lightningd/coin_mvts.h>
|
#include <lightningd/coin_mvts.h>
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
#include <common/wire_error.h>
|
#include <common/wire_error.h>
|
||||||
#include <connectd/gen_connect_wire.h>
|
#include <connectd/gen_connect_wire.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <hsmd/gen_hsm_wire.h>
|
|
||||||
#include <lightningd/chaintopology.h>
|
#include <lightningd/chaintopology.h>
|
||||||
#include <lightningd/channel_control.h>
|
#include <lightningd/channel_control.h>
|
||||||
#include <lightningd/closing_control.h>
|
#include <lightningd/closing_control.h>
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
#include <connectd/gen_connect_wire.h>
|
#include <connectd/gen_connect_wire.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <hsmd/gen_hsm_wire.h>
|
#include <hsmd/hsmd_wiregen.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <lightningd/bitcoind.h>
|
#include <lightningd/bitcoind.h>
|
||||||
#include <lightningd/chaintopology.h>
|
#include <lightningd/chaintopology.h>
|
||||||
|
@ -184,7 +184,7 @@ static void sign_last_tx(struct channel *channel)
|
||||||
u8 *msg, **witness;
|
u8 *msg, **witness;
|
||||||
|
|
||||||
assert(!channel->last_tx->wtx->inputs[0].witness);
|
assert(!channel->last_tx->wtx->inputs[0].witness);
|
||||||
msg = towire_hsm_sign_commitment_tx(tmpctx,
|
msg = towire_hsmd_sign_commitment_tx(tmpctx,
|
||||||
&channel->peer->id,
|
&channel->peer->id,
|
||||||
channel->dbid,
|
channel->dbid,
|
||||||
channel->last_tx,
|
channel->last_tx,
|
||||||
|
@ -195,7 +195,7 @@ static void sign_last_tx(struct channel *channel)
|
||||||
fatal("Could not write to HSM: %s", strerror(errno));
|
fatal("Could not write to HSM: %s", strerror(errno));
|
||||||
|
|
||||||
msg = wire_sync_read(tmpctx, ld->hsm_fd);
|
msg = wire_sync_read(tmpctx, ld->hsm_fd);
|
||||||
if (!fromwire_hsm_sign_commitment_tx_reply(msg, &sig))
|
if (!fromwire_hsmd_sign_commitment_tx_reply(msg, &sig))
|
||||||
fatal("HSM gave bad sign_commitment_tx_reply %s",
|
fatal("HSM gave bad sign_commitment_tx_reply %s",
|
||||||
tal_hex(tmpctx, msg));
|
tal_hex(tmpctx, msg));
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,6 @@
|
||||||
#include <common/timeout.h>
|
#include <common/timeout.h>
|
||||||
#include <common/utils.h>
|
#include <common/utils.h>
|
||||||
#include <gossipd/gen_gossip_wire.h>
|
#include <gossipd/gen_gossip_wire.h>
|
||||||
#include <hsmd/gen_hsm_wire.h>
|
|
||||||
#include <lightningd/chaintopology.h>
|
#include <lightningd/chaintopology.h>
|
||||||
#include <lightningd/coin_mvts.h>
|
#include <lightningd/coin_mvts.h>
|
||||||
#include <lightningd/htlc_end.h>
|
#include <lightningd/htlc_end.h>
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
#include <common/utils.h>
|
#include <common/utils.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <gossipd/gen_gossip_wire.h>
|
#include <gossipd/gen_gossip_wire.h>
|
||||||
#include <hsmd/gen_hsm_wire.h>
|
#include <hsmd/hsmd_wiregen.h>
|
||||||
#include <lightningd/jsonrpc.h>
|
#include <lightningd/jsonrpc.h>
|
||||||
#include <lightningd/lightningd.h>
|
#include <lightningd/lightningd.h>
|
||||||
#include <lightningd/subd.h>
|
#include <lightningd/subd.h>
|
||||||
|
@ -85,14 +85,14 @@ static struct command_result *json_signmessage(struct command *cmd,
|
||||||
return command_fail(cmd, JSONRPC2_INVALID_PARAMS,
|
return command_fail(cmd, JSONRPC2_INVALID_PARAMS,
|
||||||
"Message must be < 64k");
|
"Message must be < 64k");
|
||||||
|
|
||||||
msg = towire_hsm_sign_message(NULL,
|
msg = towire_hsmd_sign_message(NULL,
|
||||||
tal_dup_arr(tmpctx, u8, (u8 *)message,
|
tal_dup_arr(tmpctx, u8, (u8 *)message,
|
||||||
strlen(message), 0));
|
strlen(message), 0));
|
||||||
if (!wire_sync_write(cmd->ld->hsm_fd, take(msg)))
|
if (!wire_sync_write(cmd->ld->hsm_fd, take(msg)))
|
||||||
fatal("Could not write to HSM: %s", strerror(errno));
|
fatal("Could not write to HSM: %s", strerror(errno));
|
||||||
|
|
||||||
msg = wire_sync_read(tmpctx, cmd->ld->hsm_fd);
|
msg = wire_sync_read(tmpctx, cmd->ld->hsm_fd);
|
||||||
if (!fromwire_hsm_sign_message_reply(msg, &rsig))
|
if (!fromwire_hsmd_sign_message_reply(msg, &rsig))
|
||||||
fatal("HSM gave bad hsm_sign_message_reply %s",
|
fatal("HSM gave bad hsm_sign_message_reply %s",
|
||||||
tal_hex(msg, msg));
|
tal_hex(msg, msg));
|
||||||
|
|
||||||
|
|
|
@ -119,15 +119,15 @@ bool fromwire_connect_peer_connected(const tal_t *ctx UNNEEDED, const void *p UN
|
||||||
/* Generated stub for fromwire_gossip_get_incoming_channels_reply */
|
/* Generated stub for fromwire_gossip_get_incoming_channels_reply */
|
||||||
bool fromwire_gossip_get_incoming_channels_reply(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct route_info **public_route_info UNNEEDED, bool **public_deadends UNNEEDED, struct route_info **private_route_info UNNEEDED, bool **private_deadends UNNEEDED)
|
bool fromwire_gossip_get_incoming_channels_reply(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct route_info **public_route_info UNNEEDED, bool **public_deadends UNNEEDED, struct route_info **private_route_info UNNEEDED, bool **private_deadends UNNEEDED)
|
||||||
{ fprintf(stderr, "fromwire_gossip_get_incoming_channels_reply called!\n"); abort(); }
|
{ fprintf(stderr, "fromwire_gossip_get_incoming_channels_reply called!\n"); abort(); }
|
||||||
/* Generated stub for fromwire_hsm_get_channel_basepoints_reply */
|
/* Generated stub for fromwire_hsmd_get_channel_basepoints_reply */
|
||||||
bool fromwire_hsm_get_channel_basepoints_reply(const void *p UNNEEDED, struct basepoints *basepoints UNNEEDED, struct pubkey *funding_pubkey UNNEEDED)
|
bool fromwire_hsmd_get_channel_basepoints_reply(const void *p UNNEEDED, struct basepoints *basepoints UNNEEDED, struct pubkey *funding_pubkey UNNEEDED)
|
||||||
{ fprintf(stderr, "fromwire_hsm_get_channel_basepoints_reply called!\n"); abort(); }
|
{ fprintf(stderr, "fromwire_hsmd_get_channel_basepoints_reply called!\n"); abort(); }
|
||||||
/* Generated stub for fromwire_hsm_sign_commitment_tx_reply */
|
/* Generated stub for fromwire_hsmd_sign_commitment_tx_reply */
|
||||||
bool fromwire_hsm_sign_commitment_tx_reply(const void *p UNNEEDED, struct bitcoin_signature *sig UNNEEDED)
|
bool fromwire_hsmd_sign_commitment_tx_reply(const void *p UNNEEDED, struct bitcoin_signature *sig UNNEEDED)
|
||||||
{ fprintf(stderr, "fromwire_hsm_sign_commitment_tx_reply called!\n"); abort(); }
|
{ fprintf(stderr, "fromwire_hsmd_sign_commitment_tx_reply called!\n"); abort(); }
|
||||||
/* Generated stub for fromwire_hsm_sign_invoice_reply */
|
/* Generated stub for fromwire_hsmd_sign_invoice_reply */
|
||||||
bool fromwire_hsm_sign_invoice_reply(const void *p UNNEEDED, secp256k1_ecdsa_recoverable_signature *sig UNNEEDED)
|
bool fromwire_hsmd_sign_invoice_reply(const void *p UNNEEDED, secp256k1_ecdsa_recoverable_signature *sig UNNEEDED)
|
||||||
{ fprintf(stderr, "fromwire_hsm_sign_invoice_reply called!\n"); abort(); }
|
{ fprintf(stderr, "fromwire_hsmd_sign_invoice_reply called!\n"); abort(); }
|
||||||
/* Generated stub for fromwire_node_id */
|
/* Generated stub for fromwire_node_id */
|
||||||
void fromwire_node_id(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, struct node_id *id UNNEEDED)
|
void fromwire_node_id(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, struct node_id *id UNNEEDED)
|
||||||
{ fprintf(stderr, "fromwire_node_id called!\n"); abort(); }
|
{ fprintf(stderr, "fromwire_node_id called!\n"); abort(); }
|
||||||
|
@ -490,15 +490,15 @@ u8 *towire_errorfmt(const tal_t *ctx UNNEEDED,
|
||||||
/* Generated stub for towire_gossip_get_incoming_channels */
|
/* Generated stub for towire_gossip_get_incoming_channels */
|
||||||
u8 *towire_gossip_get_incoming_channels(const tal_t *ctx UNNEEDED)
|
u8 *towire_gossip_get_incoming_channels(const tal_t *ctx UNNEEDED)
|
||||||
{ fprintf(stderr, "towire_gossip_get_incoming_channels called!\n"); abort(); }
|
{ fprintf(stderr, "towire_gossip_get_incoming_channels called!\n"); abort(); }
|
||||||
/* Generated stub for towire_hsm_get_channel_basepoints */
|
/* Generated stub for towire_hsmd_get_channel_basepoints */
|
||||||
u8 *towire_hsm_get_channel_basepoints(const tal_t *ctx UNNEEDED, const struct node_id *peerid UNNEEDED, u64 dbid UNNEEDED)
|
u8 *towire_hsmd_get_channel_basepoints(const tal_t *ctx UNNEEDED, const struct node_id *peerid UNNEEDED, u64 dbid UNNEEDED)
|
||||||
{ fprintf(stderr, "towire_hsm_get_channel_basepoints called!\n"); abort(); }
|
{ fprintf(stderr, "towire_hsmd_get_channel_basepoints called!\n"); abort(); }
|
||||||
/* Generated stub for towire_hsm_sign_commitment_tx */
|
/* Generated stub for towire_hsmd_sign_commitment_tx */
|
||||||
u8 *towire_hsm_sign_commitment_tx(const tal_t *ctx UNNEEDED, const struct node_id *peer_id UNNEEDED, u64 channel_dbid UNNEEDED, const struct bitcoin_tx *tx UNNEEDED, const struct pubkey *remote_funding_key UNNEEDED)
|
u8 *towire_hsmd_sign_commitment_tx(const tal_t *ctx UNNEEDED, const struct node_id *peer_id UNNEEDED, u64 channel_dbid UNNEEDED, const struct bitcoin_tx *tx UNNEEDED, const struct pubkey *remote_funding_key UNNEEDED)
|
||||||
{ fprintf(stderr, "towire_hsm_sign_commitment_tx called!\n"); abort(); }
|
{ fprintf(stderr, "towire_hsmd_sign_commitment_tx called!\n"); abort(); }
|
||||||
/* Generated stub for towire_hsm_sign_invoice */
|
/* Generated stub for towire_hsmd_sign_invoice */
|
||||||
u8 *towire_hsm_sign_invoice(const tal_t *ctx UNNEEDED, const u8 *u5bytes UNNEEDED, const u8 *hrp UNNEEDED)
|
u8 *towire_hsmd_sign_invoice(const tal_t *ctx UNNEEDED, const u8 *u5bytes UNNEEDED, const u8 *hrp UNNEEDED)
|
||||||
{ fprintf(stderr, "towire_hsm_sign_invoice called!\n"); abort(); }
|
{ fprintf(stderr, "towire_hsmd_sign_invoice called!\n"); abort(); }
|
||||||
/* Generated stub for towire_node_id */
|
/* Generated stub for towire_node_id */
|
||||||
void towire_node_id(u8 **pptr UNNEEDED, const struct node_id *id UNNEEDED)
|
void towire_node_id(u8 **pptr UNNEEDED, const struct node_id *id UNNEEDED)
|
||||||
{ fprintf(stderr, "towire_node_id called!\n"); abort(); }
|
{ fprintf(stderr, "towire_node_id called!\n"); abort(); }
|
||||||
|
|
|
@ -76,8 +76,7 @@ ONCHAIND_COMMON_OBJS := \
|
||||||
common/utils.o \
|
common/utils.o \
|
||||||
common/utxo.o \
|
common/utxo.o \
|
||||||
common/version.o \
|
common/version.o \
|
||||||
common/wallet.o \
|
common/wallet.o
|
||||||
hsmd/gen_hsm_wire.o
|
|
||||||
|
|
||||||
onchaind/gen_onchain_wire.h: $(WIRE_GEN) onchaind/onchain_wire.csv
|
onchaind/gen_onchain_wire.h: $(WIRE_GEN) onchaind/onchain_wire.csv
|
||||||
$(WIRE_GEN) --page header $@ onchain_wire_type < onchaind/onchain_wire.csv > $@
|
$(WIRE_GEN) --page header $@ onchain_wire_type < onchaind/onchain_wire.csv > $@
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
#include <common/version.h>
|
#include <common/version.h>
|
||||||
#include <common/wallet.h>
|
#include <common/wallet.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <hsmd/gen_hsm_wire.h>
|
#include <hsmd/hsmd_wiregen.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <lightningd/channel_state.h>
|
#include <lightningd/channel_state.h>
|
||||||
#include <onchaind/gen_onchain_wire.h>
|
#include <onchaind/gen_onchain_wire.h>
|
||||||
|
@ -582,7 +582,7 @@ static u8 *delayed_payment_to_us(const tal_t *ctx,
|
||||||
struct bitcoin_tx *tx,
|
struct bitcoin_tx *tx,
|
||||||
const u8 *wscript)
|
const u8 *wscript)
|
||||||
{
|
{
|
||||||
return towire_hsm_sign_delayed_payment_to_us(ctx, commit_num,
|
return towire_hsmd_sign_delayed_payment_to_us(ctx, commit_num,
|
||||||
tx, wscript);
|
tx, wscript);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -590,7 +590,7 @@ static u8 *remote_htlc_to_us(const tal_t *ctx,
|
||||||
struct bitcoin_tx *tx,
|
struct bitcoin_tx *tx,
|
||||||
const u8 *wscript)
|
const u8 *wscript)
|
||||||
{
|
{
|
||||||
return towire_hsm_sign_remote_htlc_to_us(ctx,
|
return towire_hsmd_sign_remote_htlc_to_us(ctx,
|
||||||
remote_per_commitment_point,
|
remote_per_commitment_point,
|
||||||
tx, wscript,
|
tx, wscript,
|
||||||
option_anchor_outputs);
|
option_anchor_outputs);
|
||||||
|
@ -600,7 +600,7 @@ static u8 *penalty_to_us(const tal_t *ctx,
|
||||||
struct bitcoin_tx *tx,
|
struct bitcoin_tx *tx,
|
||||||
const u8 *wscript)
|
const u8 *wscript)
|
||||||
{
|
{
|
||||||
return towire_hsm_sign_penalty_to_us(ctx, remote_per_commitment_secret,
|
return towire_hsmd_sign_penalty_to_us(ctx, remote_per_commitment_secret,
|
||||||
tx, wscript);
|
tx, wscript);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -680,7 +680,7 @@ static struct bitcoin_tx *tx_to_us(const tal_t *ctx,
|
||||||
if (!wire_sync_write(HSM_FD, take(hsm_sign_msg(NULL, tx, wscript))))
|
if (!wire_sync_write(HSM_FD, take(hsm_sign_msg(NULL, tx, wscript))))
|
||||||
status_failed(STATUS_FAIL_HSM_IO, "Writing sign request to hsm");
|
status_failed(STATUS_FAIL_HSM_IO, "Writing sign request to hsm");
|
||||||
msg = wire_sync_read(tmpctx, HSM_FD);
|
msg = wire_sync_read(tmpctx, HSM_FD);
|
||||||
if (!msg || !fromwire_hsm_sign_tx_reply(msg, &sig)) {
|
if (!msg || !fromwire_hsmd_sign_tx_reply(msg, &sig)) {
|
||||||
status_failed(STATUS_FAIL_HSM_IO,
|
status_failed(STATUS_FAIL_HSM_IO,
|
||||||
"Reading sign_tx_reply: %s",
|
"Reading sign_tx_reply: %s",
|
||||||
tal_hex(tmpctx, msg));
|
tal_hex(tmpctx, msg));
|
||||||
|
@ -696,7 +696,7 @@ static void hsm_sign_local_htlc_tx(struct bitcoin_tx *tx,
|
||||||
const u8 *wscript,
|
const u8 *wscript,
|
||||||
struct bitcoin_signature *sig)
|
struct bitcoin_signature *sig)
|
||||||
{
|
{
|
||||||
u8 *msg = towire_hsm_sign_local_htlc_tx(NULL, commit_num,
|
u8 *msg = towire_hsmd_sign_local_htlc_tx(NULL, commit_num,
|
||||||
tx, wscript,
|
tx, wscript,
|
||||||
option_anchor_outputs);
|
option_anchor_outputs);
|
||||||
|
|
||||||
|
@ -704,7 +704,7 @@ static void hsm_sign_local_htlc_tx(struct bitcoin_tx *tx,
|
||||||
status_failed(STATUS_FAIL_HSM_IO,
|
status_failed(STATUS_FAIL_HSM_IO,
|
||||||
"Writing sign_local_htlc_tx to hsm");
|
"Writing sign_local_htlc_tx to hsm");
|
||||||
msg = wire_sync_read(tmpctx, HSM_FD);
|
msg = wire_sync_read(tmpctx, HSM_FD);
|
||||||
if (!msg || !fromwire_hsm_sign_tx_reply(msg, sig))
|
if (!msg || !fromwire_hsmd_sign_tx_reply(msg, sig))
|
||||||
status_failed(STATUS_FAIL_HSM_IO,
|
status_failed(STATUS_FAIL_HSM_IO,
|
||||||
"Reading sign_local_htlc_tx: %s",
|
"Reading sign_local_htlc_tx: %s",
|
||||||
tal_hex(tmpctx, msg));
|
tal_hex(tmpctx, msg));
|
||||||
|
@ -712,14 +712,14 @@ static void hsm_sign_local_htlc_tx(struct bitcoin_tx *tx,
|
||||||
|
|
||||||
static void hsm_get_per_commitment_point(struct pubkey *per_commitment_point)
|
static void hsm_get_per_commitment_point(struct pubkey *per_commitment_point)
|
||||||
{
|
{
|
||||||
u8 *msg = towire_hsm_get_per_commitment_point(NULL, commit_num);
|
u8 *msg = towire_hsmd_get_per_commitment_point(NULL, commit_num);
|
||||||
struct secret *unused;
|
struct secret *unused;
|
||||||
|
|
||||||
if (!wire_sync_write(HSM_FD, take(msg)))
|
if (!wire_sync_write(HSM_FD, take(msg)))
|
||||||
status_failed(STATUS_FAIL_HSM_IO, "Writing sign_htlc_tx to hsm");
|
status_failed(STATUS_FAIL_HSM_IO, "Writing sign_htlc_tx to hsm");
|
||||||
msg = wire_sync_read(tmpctx, HSM_FD);
|
msg = wire_sync_read(tmpctx, HSM_FD);
|
||||||
if (!msg
|
if (!msg
|
||||||
|| !fromwire_hsm_get_per_commitment_point_reply(tmpctx, msg,
|
|| !fromwire_hsmd_get_per_commitment_point_reply(tmpctx, msg,
|
||||||
per_commitment_point,
|
per_commitment_point,
|
||||||
&unused))
|
&unused))
|
||||||
status_failed(STATUS_FAIL_HSM_IO,
|
status_failed(STATUS_FAIL_HSM_IO,
|
||||||
|
|
|
@ -37,9 +37,9 @@ bool fromwire_bool(const u8 **cursor UNNEEDED, size_t *max UNNEEDED)
|
||||||
/* Generated stub for fromwire_fail */
|
/* Generated stub for fromwire_fail */
|
||||||
void *fromwire_fail(const u8 **cursor UNNEEDED, size_t *max UNNEEDED)
|
void *fromwire_fail(const u8 **cursor UNNEEDED, size_t *max UNNEEDED)
|
||||||
{ fprintf(stderr, "fromwire_fail called!\n"); abort(); }
|
{ fprintf(stderr, "fromwire_fail called!\n"); abort(); }
|
||||||
/* Generated stub for fromwire_hsm_get_per_commitment_point_reply */
|
/* Generated stub for fromwire_hsmd_get_per_commitment_point_reply */
|
||||||
bool fromwire_hsm_get_per_commitment_point_reply(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct pubkey *per_commitment_point UNNEEDED, struct secret **old_commitment_secret UNNEEDED)
|
bool fromwire_hsmd_get_per_commitment_point_reply(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct pubkey *per_commitment_point UNNEEDED, struct secret **old_commitment_secret UNNEEDED)
|
||||||
{ fprintf(stderr, "fromwire_hsm_get_per_commitment_point_reply called!\n"); abort(); }
|
{ fprintf(stderr, "fromwire_hsmd_get_per_commitment_point_reply called!\n"); abort(); }
|
||||||
/* Generated stub for fromwire_onchain_depth */
|
/* Generated stub for fromwire_onchain_depth */
|
||||||
bool fromwire_onchain_depth(const void *p UNNEEDED, struct bitcoin_txid *txid UNNEEDED, u32 *depth UNNEEDED, bool *is_replay UNNEEDED)
|
bool fromwire_onchain_depth(const void *p UNNEEDED, struct bitcoin_txid *txid UNNEEDED, u32 *depth UNNEEDED, bool *is_replay UNNEEDED)
|
||||||
{ fprintf(stderr, "fromwire_onchain_depth called!\n"); abort(); }
|
{ fprintf(stderr, "fromwire_onchain_depth called!\n"); abort(); }
|
||||||
|
@ -221,18 +221,18 @@ void towire(u8 **pptr UNNEEDED, const void *data UNNEEDED, size_t len UNNEEDED)
|
||||||
/* Generated stub for towire_bool */
|
/* Generated stub for towire_bool */
|
||||||
void towire_bool(u8 **pptr UNNEEDED, bool v UNNEEDED)
|
void towire_bool(u8 **pptr UNNEEDED, bool v UNNEEDED)
|
||||||
{ fprintf(stderr, "towire_bool called!\n"); abort(); }
|
{ fprintf(stderr, "towire_bool called!\n"); abort(); }
|
||||||
/* Generated stub for towire_hsm_get_per_commitment_point */
|
/* Generated stub for towire_hsmd_get_per_commitment_point */
|
||||||
u8 *towire_hsm_get_per_commitment_point(const tal_t *ctx UNNEEDED, u64 n UNNEEDED)
|
u8 *towire_hsmd_get_per_commitment_point(const tal_t *ctx UNNEEDED, u64 n UNNEEDED)
|
||||||
{ fprintf(stderr, "towire_hsm_get_per_commitment_point called!\n"); abort(); }
|
{ fprintf(stderr, "towire_hsmd_get_per_commitment_point called!\n"); abort(); }
|
||||||
/* Generated stub for towire_hsm_sign_delayed_payment_to_us */
|
/* Generated stub for towire_hsmd_sign_delayed_payment_to_us */
|
||||||
u8 *towire_hsm_sign_delayed_payment_to_us(const tal_t *ctx UNNEEDED, u64 commit_num UNNEEDED, const struct bitcoin_tx *tx UNNEEDED, const u8 *wscript UNNEEDED)
|
u8 *towire_hsmd_sign_delayed_payment_to_us(const tal_t *ctx UNNEEDED, u64 commit_num UNNEEDED, const struct bitcoin_tx *tx UNNEEDED, const u8 *wscript UNNEEDED)
|
||||||
{ fprintf(stderr, "towire_hsm_sign_delayed_payment_to_us called!\n"); abort(); }
|
{ fprintf(stderr, "towire_hsmd_sign_delayed_payment_to_us called!\n"); abort(); }
|
||||||
/* Generated stub for towire_hsm_sign_penalty_to_us */
|
/* Generated stub for towire_hsmd_sign_penalty_to_us */
|
||||||
u8 *towire_hsm_sign_penalty_to_us(const tal_t *ctx UNNEEDED, const struct secret *revocation_secret UNNEEDED, const struct bitcoin_tx *tx UNNEEDED, const u8 *wscript UNNEEDED)
|
u8 *towire_hsmd_sign_penalty_to_us(const tal_t *ctx UNNEEDED, const struct secret *revocation_secret UNNEEDED, const struct bitcoin_tx *tx UNNEEDED, const u8 *wscript UNNEEDED)
|
||||||
{ fprintf(stderr, "towire_hsm_sign_penalty_to_us called!\n"); abort(); }
|
{ fprintf(stderr, "towire_hsmd_sign_penalty_to_us called!\n"); abort(); }
|
||||||
/* Generated stub for towire_hsm_sign_remote_htlc_to_us */
|
/* Generated stub for towire_hsmd_sign_remote_htlc_to_us */
|
||||||
u8 *towire_hsm_sign_remote_htlc_to_us(const tal_t *ctx UNNEEDED, const struct pubkey *remote_per_commitment_point UNNEEDED, const struct bitcoin_tx *tx UNNEEDED, const u8 *wscript UNNEEDED, bool option_anchor_outputs UNNEEDED)
|
u8 *towire_hsmd_sign_remote_htlc_to_us(const tal_t *ctx UNNEEDED, const struct pubkey *remote_per_commitment_point UNNEEDED, const struct bitcoin_tx *tx UNNEEDED, const u8 *wscript UNNEEDED, bool option_anchor_outputs UNNEEDED)
|
||||||
{ fprintf(stderr, "towire_hsm_sign_remote_htlc_to_us called!\n"); abort(); }
|
{ fprintf(stderr, "towire_hsmd_sign_remote_htlc_to_us called!\n"); abort(); }
|
||||||
/* Generated stub for towire_onchain_add_utxo */
|
/* Generated stub for towire_onchain_add_utxo */
|
||||||
u8 *towire_onchain_add_utxo(const tal_t *ctx UNNEEDED, const struct bitcoin_txid *prev_out_tx UNNEEDED, u32 prev_out_index UNNEEDED, const struct pubkey *per_commit_point UNNEEDED, struct amount_sat value UNNEEDED, u32 blockheight UNNEEDED, const u8 *scriptpubkey UNNEEDED)
|
u8 *towire_onchain_add_utxo(const tal_t *ctx UNNEEDED, const struct bitcoin_txid *prev_out_tx UNNEEDED, u32 prev_out_index UNNEEDED, const struct pubkey *per_commit_point UNNEEDED, struct amount_sat value UNNEEDED, u32 blockheight UNNEEDED, const u8 *scriptpubkey UNNEEDED)
|
||||||
{ fprintf(stderr, "towire_onchain_add_utxo called!\n"); abort(); }
|
{ fprintf(stderr, "towire_onchain_add_utxo called!\n"); abort(); }
|
||||||
|
@ -294,7 +294,7 @@ void towire_u8_array(u8 **pptr UNNEEDED, const u8 *arr UNNEEDED, size_t num UNNE
|
||||||
/* AUTOGENERATED MOCKS END */
|
/* AUTOGENERATED MOCKS END */
|
||||||
|
|
||||||
/* Stubs which do get called. */
|
/* Stubs which do get called. */
|
||||||
u8 *towire_hsm_sign_local_htlc_tx(const tal_t *ctx UNNEEDED, u64 commit_num UNNEEDED, const struct bitcoin_tx *tx UNNEEDED, const u8 *wscript UNNEEDED, bool option_anchor_outputs UNNEEDED)
|
u8 *towire_hsmd_sign_local_htlc_tx(const tal_t *ctx UNNEEDED, u64 commit_num UNNEEDED, const struct bitcoin_tx *tx UNNEEDED, const u8 *wscript UNNEEDED, bool option_anchor_outputs UNNEEDED)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -309,8 +309,8 @@ bool wire_sync_write(int fd UNNEEDED, const void *msg TAKES UNNEEDED)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Generated stub for fromwire_hsm_sign_tx_reply */
|
/* Generated stub for fromwire_hsmd_sign_tx_reply */
|
||||||
bool fromwire_hsm_sign_tx_reply(const void *p UNNEEDED, struct bitcoin_signature *sig)
|
bool fromwire_hsmd_sign_tx_reply(const void *p UNNEEDED, struct bitcoin_signature *sig)
|
||||||
{
|
{
|
||||||
memset(sig, 0, sizeof(*sig));
|
memset(sig, 0, sizeof(*sig));
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -38,12 +38,12 @@ bool fromwire_bool(const u8 **cursor UNNEEDED, size_t *max UNNEEDED)
|
||||||
/* Generated stub for fromwire_fail */
|
/* Generated stub for fromwire_fail */
|
||||||
void *fromwire_fail(const u8 **cursor UNNEEDED, size_t *max UNNEEDED)
|
void *fromwire_fail(const u8 **cursor UNNEEDED, size_t *max UNNEEDED)
|
||||||
{ fprintf(stderr, "fromwire_fail called!\n"); abort(); }
|
{ fprintf(stderr, "fromwire_fail called!\n"); abort(); }
|
||||||
/* Generated stub for fromwire_hsm_get_per_commitment_point_reply */
|
/* Generated stub for fromwire_hsmd_get_per_commitment_point_reply */
|
||||||
bool fromwire_hsm_get_per_commitment_point_reply(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct pubkey *per_commitment_point UNNEEDED, struct secret **old_commitment_secret UNNEEDED)
|
bool fromwire_hsmd_get_per_commitment_point_reply(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct pubkey *per_commitment_point UNNEEDED, struct secret **old_commitment_secret UNNEEDED)
|
||||||
{ fprintf(stderr, "fromwire_hsm_get_per_commitment_point_reply called!\n"); abort(); }
|
{ fprintf(stderr, "fromwire_hsmd_get_per_commitment_point_reply called!\n"); abort(); }
|
||||||
/* Generated stub for fromwire_hsm_sign_tx_reply */
|
/* Generated stub for fromwire_hsmd_sign_tx_reply */
|
||||||
bool fromwire_hsm_sign_tx_reply(const void *p UNNEEDED, struct bitcoin_signature *sig UNNEEDED)
|
bool fromwire_hsmd_sign_tx_reply(const void *p UNNEEDED, struct bitcoin_signature *sig UNNEEDED)
|
||||||
{ fprintf(stderr, "fromwire_hsm_sign_tx_reply called!\n"); abort(); }
|
{ fprintf(stderr, "fromwire_hsmd_sign_tx_reply called!\n"); abort(); }
|
||||||
/* Generated stub for fromwire_onchain_depth */
|
/* Generated stub for fromwire_onchain_depth */
|
||||||
bool fromwire_onchain_depth(const void *p UNNEEDED, struct bitcoin_txid *txid UNNEEDED, u32 *depth UNNEEDED, bool *is_replay UNNEEDED)
|
bool fromwire_onchain_depth(const void *p UNNEEDED, struct bitcoin_txid *txid UNNEEDED, u32 *depth UNNEEDED, bool *is_replay UNNEEDED)
|
||||||
{ fprintf(stderr, "fromwire_onchain_depth called!\n"); abort(); }
|
{ fprintf(stderr, "fromwire_onchain_depth called!\n"); abort(); }
|
||||||
|
@ -238,21 +238,21 @@ void towire(u8 **pptr UNNEEDED, const void *data UNNEEDED, size_t len UNNEEDED)
|
||||||
/* Generated stub for towire_bool */
|
/* Generated stub for towire_bool */
|
||||||
void towire_bool(u8 **pptr UNNEEDED, bool v UNNEEDED)
|
void towire_bool(u8 **pptr UNNEEDED, bool v UNNEEDED)
|
||||||
{ fprintf(stderr, "towire_bool called!\n"); abort(); }
|
{ fprintf(stderr, "towire_bool called!\n"); abort(); }
|
||||||
/* Generated stub for towire_hsm_get_per_commitment_point */
|
/* Generated stub for towire_hsmd_get_per_commitment_point */
|
||||||
u8 *towire_hsm_get_per_commitment_point(const tal_t *ctx UNNEEDED, u64 n UNNEEDED)
|
u8 *towire_hsmd_get_per_commitment_point(const tal_t *ctx UNNEEDED, u64 n UNNEEDED)
|
||||||
{ fprintf(stderr, "towire_hsm_get_per_commitment_point called!\n"); abort(); }
|
{ fprintf(stderr, "towire_hsmd_get_per_commitment_point called!\n"); abort(); }
|
||||||
/* Generated stub for towire_hsm_sign_delayed_payment_to_us */
|
/* Generated stub for towire_hsmd_sign_delayed_payment_to_us */
|
||||||
u8 *towire_hsm_sign_delayed_payment_to_us(const tal_t *ctx UNNEEDED, u64 commit_num UNNEEDED, const struct bitcoin_tx *tx UNNEEDED, const u8 *wscript UNNEEDED)
|
u8 *towire_hsmd_sign_delayed_payment_to_us(const tal_t *ctx UNNEEDED, u64 commit_num UNNEEDED, const struct bitcoin_tx *tx UNNEEDED, const u8 *wscript UNNEEDED)
|
||||||
{ fprintf(stderr, "towire_hsm_sign_delayed_payment_to_us called!\n"); abort(); }
|
{ fprintf(stderr, "towire_hsmd_sign_delayed_payment_to_us called!\n"); abort(); }
|
||||||
/* Generated stub for towire_hsm_sign_local_htlc_tx */
|
/* Generated stub for towire_hsmd_sign_local_htlc_tx */
|
||||||
u8 *towire_hsm_sign_local_htlc_tx(const tal_t *ctx UNNEEDED, u64 commit_num UNNEEDED, const struct bitcoin_tx *tx UNNEEDED, const u8 *wscript UNNEEDED, bool option_anchor_outputs UNNEEDED)
|
u8 *towire_hsmd_sign_local_htlc_tx(const tal_t *ctx UNNEEDED, u64 commit_num UNNEEDED, const struct bitcoin_tx *tx UNNEEDED, const u8 *wscript UNNEEDED, bool option_anchor_outputs UNNEEDED)
|
||||||
{ fprintf(stderr, "towire_hsm_sign_local_htlc_tx called!\n"); abort(); }
|
{ fprintf(stderr, "towire_hsmd_sign_local_htlc_tx called!\n"); abort(); }
|
||||||
/* Generated stub for towire_hsm_sign_penalty_to_us */
|
/* Generated stub for towire_hsmd_sign_penalty_to_us */
|
||||||
u8 *towire_hsm_sign_penalty_to_us(const tal_t *ctx UNNEEDED, const struct secret *revocation_secret UNNEEDED, const struct bitcoin_tx *tx UNNEEDED, const u8 *wscript UNNEEDED)
|
u8 *towire_hsmd_sign_penalty_to_us(const tal_t *ctx UNNEEDED, const struct secret *revocation_secret UNNEEDED, const struct bitcoin_tx *tx UNNEEDED, const u8 *wscript UNNEEDED)
|
||||||
{ fprintf(stderr, "towire_hsm_sign_penalty_to_us called!\n"); abort(); }
|
{ fprintf(stderr, "towire_hsmd_sign_penalty_to_us called!\n"); abort(); }
|
||||||
/* Generated stub for towire_hsm_sign_remote_htlc_to_us */
|
/* Generated stub for towire_hsmd_sign_remote_htlc_to_us */
|
||||||
u8 *towire_hsm_sign_remote_htlc_to_us(const tal_t *ctx UNNEEDED, const struct pubkey *remote_per_commitment_point UNNEEDED, const struct bitcoin_tx *tx UNNEEDED, const u8 *wscript UNNEEDED, bool option_anchor_outputs UNNEEDED)
|
u8 *towire_hsmd_sign_remote_htlc_to_us(const tal_t *ctx UNNEEDED, const struct pubkey *remote_per_commitment_point UNNEEDED, const struct bitcoin_tx *tx UNNEEDED, const u8 *wscript UNNEEDED, bool option_anchor_outputs UNNEEDED)
|
||||||
{ fprintf(stderr, "towire_hsm_sign_remote_htlc_to_us called!\n"); abort(); }
|
{ fprintf(stderr, "towire_hsmd_sign_remote_htlc_to_us called!\n"); abort(); }
|
||||||
/* Generated stub for towire_onchain_add_utxo */
|
/* Generated stub for towire_onchain_add_utxo */
|
||||||
u8 *towire_onchain_add_utxo(const tal_t *ctx UNNEEDED, const struct bitcoin_txid *prev_out_tx UNNEEDED, u32 prev_out_index UNNEEDED, const struct pubkey *per_commit_point UNNEEDED, struct amount_sat value UNNEEDED, u32 blockheight UNNEEDED, const u8 *scriptpubkey UNNEEDED)
|
u8 *towire_onchain_add_utxo(const tal_t *ctx UNNEEDED, const struct bitcoin_txid *prev_out_tx UNNEEDED, u32 prev_out_index UNNEEDED, const struct pubkey *per_commit_point UNNEEDED, struct amount_sat value UNNEEDED, u32 blockheight UNNEEDED, const u8 *scriptpubkey UNNEEDED)
|
||||||
{ fprintf(stderr, "towire_onchain_add_utxo called!\n"); abort(); }
|
{ fprintf(stderr, "towire_onchain_add_utxo called!\n"); abort(); }
|
||||||
|
|
|
@ -83,7 +83,6 @@ OPENINGD_COMMON_OBJS := \
|
||||||
common/wire_error.o \
|
common/wire_error.o \
|
||||||
common/wireaddr.o \
|
common/wireaddr.o \
|
||||||
gossipd/gen_gossip_peerd_wire.o \
|
gossipd/gen_gossip_peerd_wire.o \
|
||||||
hsmd/gen_hsm_wire.o \
|
|
||||||
lightningd/gossip_msg.o
|
lightningd/gossip_msg.o
|
||||||
|
|
||||||
$(LIGHTNINGD_OPENING_OBJS): $(LIGHTNINGD_HEADERS)
|
$(LIGHTNINGD_OPENING_OBJS): $(LIGHTNINGD_HEADERS)
|
||||||
|
|
|
@ -42,7 +42,7 @@
|
||||||
#include <common/wire_error.h>
|
#include <common/wire_error.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <gossipd/gen_gossip_peerd_wire.h>
|
#include <gossipd/gen_gossip_peerd_wire.h>
|
||||||
#include <hsmd/gen_hsm_wire.h>
|
#include <hsmd/hsmd_wiregen.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <openingd/gen_opening_wire.h>
|
#include <openingd/gen_opening_wire.h>
|
||||||
#include <poll.h>
|
#include <poll.h>
|
||||||
|
@ -745,7 +745,7 @@ static bool funder_finalize_channel_setup(struct state *state,
|
||||||
* witness script. It also needs the amount of the funding output,
|
* witness script. It also needs the amount of the funding output,
|
||||||
* as segwit signatures commit to that as well, even though it doesn't
|
* as segwit signatures commit to that as well, even though it doesn't
|
||||||
* explicitly appear in the transaction itself. */
|
* explicitly appear in the transaction itself. */
|
||||||
msg = towire_hsm_sign_remote_commitment_tx(NULL,
|
msg = towire_hsmd_sign_remote_commitment_tx(NULL,
|
||||||
*tx,
|
*tx,
|
||||||
&state->channel->funding_pubkey[REMOTE],
|
&state->channel->funding_pubkey[REMOTE],
|
||||||
&state->first_per_commitment_point[REMOTE],
|
&state->first_per_commitment_point[REMOTE],
|
||||||
|
@ -753,7 +753,7 @@ static bool funder_finalize_channel_setup(struct state *state,
|
||||||
|
|
||||||
wire_sync_write(HSM_FD, take(msg));
|
wire_sync_write(HSM_FD, take(msg));
|
||||||
msg = wire_sync_read(tmpctx, HSM_FD);
|
msg = wire_sync_read(tmpctx, HSM_FD);
|
||||||
if (!fromwire_hsm_sign_tx_reply(msg, sig))
|
if (!fromwire_hsmd_sign_tx_reply(msg, sig))
|
||||||
status_failed(STATUS_FAIL_HSM_IO, "Bad sign_tx_reply %s",
|
status_failed(STATUS_FAIL_HSM_IO, "Bad sign_tx_reply %s",
|
||||||
tal_hex(tmpctx, msg));
|
tal_hex(tmpctx, msg));
|
||||||
|
|
||||||
|
@ -1271,7 +1271,7 @@ static u8 *fundee_channel(struct state *state, const u8 *open_channel_msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Make HSM sign it */
|
/* Make HSM sign it */
|
||||||
msg = towire_hsm_sign_remote_commitment_tx(NULL,
|
msg = towire_hsmd_sign_remote_commitment_tx(NULL,
|
||||||
remote_commit,
|
remote_commit,
|
||||||
&state->channel->funding_pubkey[REMOTE],
|
&state->channel->funding_pubkey[REMOTE],
|
||||||
&state->first_per_commitment_point[REMOTE],
|
&state->first_per_commitment_point[REMOTE],
|
||||||
|
@ -1279,7 +1279,7 @@ static u8 *fundee_channel(struct state *state, const u8 *open_channel_msg)
|
||||||
|
|
||||||
wire_sync_write(HSM_FD, take(msg));
|
wire_sync_write(HSM_FD, take(msg));
|
||||||
msg = wire_sync_read(tmpctx, HSM_FD);
|
msg = wire_sync_read(tmpctx, HSM_FD);
|
||||||
if (!fromwire_hsm_sign_tx_reply(msg, &sig))
|
if (!fromwire_hsmd_sign_tx_reply(msg, &sig))
|
||||||
status_failed(STATUS_FAIL_HSM_IO,
|
status_failed(STATUS_FAIL_HSM_IO,
|
||||||
"Bad sign_tx_reply %s", tal_hex(tmpctx, msg));
|
"Bad sign_tx_reply %s", tal_hex(tmpctx, msg));
|
||||||
|
|
||||||
|
@ -1574,9 +1574,9 @@ int main(int argc, char *argv[])
|
||||||
* they are, and lightningd has reserved a unique dbid for us already,
|
* they are, and lightningd has reserved a unique dbid for us already,
|
||||||
* so we might as well get the hsm daemon to generate it now. */
|
* so we might as well get the hsm daemon to generate it now. */
|
||||||
wire_sync_write(HSM_FD,
|
wire_sync_write(HSM_FD,
|
||||||
take(towire_hsm_get_per_commitment_point(NULL, 0)));
|
take(towire_hsmd_get_per_commitment_point(NULL, 0)));
|
||||||
msg = wire_sync_read(tmpctx, HSM_FD);
|
msg = wire_sync_read(tmpctx, HSM_FD);
|
||||||
if (!fromwire_hsm_get_per_commitment_point_reply(tmpctx, msg,
|
if (!fromwire_hsmd_get_per_commitment_point_reply(tmpctx, msg,
|
||||||
&state->first_per_commitment_point[LOCAL],
|
&state->first_per_commitment_point[LOCAL],
|
||||||
&none))
|
&none))
|
||||||
status_failed(STATUS_FAIL_HSM_IO,
|
status_failed(STATUS_FAIL_HSM_IO,
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
#include <common/node_id.h>
|
#include <common/node_id.h>
|
||||||
#include <common/onionreply.h>
|
#include <common/onionreply.h>
|
||||||
#include <common/version.h>
|
#include <common/version.h>
|
||||||
#include <hsmd/gen_hsm_wire.h>
|
#include <hsmd/hsmd_wiregen.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <lightningd/channel.h>
|
#include <lightningd/channel.h>
|
||||||
#include <lightningd/lightningd.h>
|
#include <lightningd/lightningd.h>
|
||||||
|
@ -1188,14 +1188,14 @@ void fillin_missing_scriptpubkeys(struct lightningd *ld, struct db *db,
|
||||||
commitment_point = NULL;
|
commitment_point = NULL;
|
||||||
|
|
||||||
/* Have to go ask the HSM to derive the pubkey for us */
|
/* Have to go ask the HSM to derive the pubkey for us */
|
||||||
msg = towire_hsm_get_output_scriptpubkey(NULL,
|
msg = towire_hsmd_get_output_scriptpubkey(NULL,
|
||||||
channel_id,
|
channel_id,
|
||||||
&peer_id,
|
&peer_id,
|
||||||
commitment_point);
|
commitment_point);
|
||||||
if (!wire_sync_write(ld->hsm_fd, take(msg)))
|
if (!wire_sync_write(ld->hsm_fd, take(msg)))
|
||||||
fatal("Could not write to HSM: %s", strerror(errno));
|
fatal("Could not write to HSM: %s", strerror(errno));
|
||||||
msg = wire_sync_read(stmt, ld->hsm_fd);
|
msg = wire_sync_read(stmt, ld->hsm_fd);
|
||||||
if (!fromwire_hsm_get_output_scriptpubkey_reply(stmt, msg,
|
if (!fromwire_hsmd_get_output_scriptpubkey_reply(stmt, msg,
|
||||||
&scriptPubkey))
|
&scriptPubkey))
|
||||||
fatal("HSM gave bad hsm_get_output_scriptpubkey_reply %s",
|
fatal("HSM gave bad hsm_get_output_scriptpubkey_reply %s",
|
||||||
tal_hex(msg, msg));
|
tal_hex(msg, msg));
|
||||||
|
|
|
@ -21,9 +21,9 @@ static void db_log_(struct log *log UNUSED, enum log_level level UNUSED, const s
|
||||||
/* Generated stub for fatal */
|
/* Generated stub for fatal */
|
||||||
void fatal(const char *fmt UNNEEDED, ...)
|
void fatal(const char *fmt UNNEEDED, ...)
|
||||||
{ fprintf(stderr, "fatal called!\n"); abort(); }
|
{ fprintf(stderr, "fatal called!\n"); abort(); }
|
||||||
/* Generated stub for fromwire_hsm_get_output_scriptpubkey_reply */
|
/* Generated stub for fromwire_hsmd_get_output_scriptpubkey_reply */
|
||||||
bool fromwire_hsm_get_output_scriptpubkey_reply(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u8 **script UNNEEDED)
|
bool fromwire_hsmd_get_output_scriptpubkey_reply(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u8 **script UNNEEDED)
|
||||||
{ fprintf(stderr, "fromwire_hsm_get_output_scriptpubkey_reply called!\n"); abort(); }
|
{ fprintf(stderr, "fromwire_hsmd_get_output_scriptpubkey_reply called!\n"); abort(); }
|
||||||
/* Generated stub for get_channel_basepoints */
|
/* Generated stub for get_channel_basepoints */
|
||||||
void get_channel_basepoints(struct lightningd *ld UNNEEDED,
|
void get_channel_basepoints(struct lightningd *ld UNNEEDED,
|
||||||
const struct node_id *peer_id UNNEEDED,
|
const struct node_id *peer_id UNNEEDED,
|
||||||
|
@ -36,9 +36,9 @@ struct log *new_log(const tal_t *ctx UNNEEDED, struct log_book *record UNNEEDED,
|
||||||
const struct node_id *default_node_id UNNEEDED,
|
const struct node_id *default_node_id UNNEEDED,
|
||||||
const char *fmt UNNEEDED, ...)
|
const char *fmt UNNEEDED, ...)
|
||||||
{ fprintf(stderr, "new_log called!\n"); abort(); }
|
{ fprintf(stderr, "new_log called!\n"); abort(); }
|
||||||
/* Generated stub for towire_hsm_get_output_scriptpubkey */
|
/* Generated stub for towire_hsmd_get_output_scriptpubkey */
|
||||||
u8 *towire_hsm_get_output_scriptpubkey(const tal_t *ctx UNNEEDED, u64 channel_id UNNEEDED, const struct node_id *peer_id UNNEEDED, const struct pubkey *commitment_point UNNEEDED)
|
u8 *towire_hsmd_get_output_scriptpubkey(const tal_t *ctx UNNEEDED, u64 channel_id UNNEEDED, const struct node_id *peer_id UNNEEDED, const struct pubkey *commitment_point UNNEEDED)
|
||||||
{ fprintf(stderr, "towire_hsm_get_output_scriptpubkey called!\n"); abort(); }
|
{ fprintf(stderr, "towire_hsmd_get_output_scriptpubkey called!\n"); abort(); }
|
||||||
/* Generated stub for wire_sync_read */
|
/* Generated stub for wire_sync_read */
|
||||||
u8 *wire_sync_read(const tal_t *ctx UNNEEDED, int fd UNNEEDED)
|
u8 *wire_sync_read(const tal_t *ctx UNNEEDED, int fd UNNEEDED)
|
||||||
{ fprintf(stderr, "wire_sync_read called!\n"); abort(); }
|
{ fprintf(stderr, "wire_sync_read called!\n"); abort(); }
|
||||||
|
|
|
@ -135,12 +135,12 @@ bool fromwire_custommsg_in(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u8
|
||||||
/* Generated stub for fromwire_gossip_get_stripped_cupdate_reply */
|
/* Generated stub for fromwire_gossip_get_stripped_cupdate_reply */
|
||||||
bool fromwire_gossip_get_stripped_cupdate_reply(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u8 **stripped_update UNNEEDED)
|
bool fromwire_gossip_get_stripped_cupdate_reply(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u8 **stripped_update UNNEEDED)
|
||||||
{ fprintf(stderr, "fromwire_gossip_get_stripped_cupdate_reply called!\n"); abort(); }
|
{ fprintf(stderr, "fromwire_gossip_get_stripped_cupdate_reply called!\n"); abort(); }
|
||||||
/* Generated stub for fromwire_hsm_get_output_scriptpubkey_reply */
|
/* Generated stub for fromwire_hsmd_get_output_scriptpubkey_reply */
|
||||||
bool fromwire_hsm_get_output_scriptpubkey_reply(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u8 **script UNNEEDED)
|
bool fromwire_hsmd_get_output_scriptpubkey_reply(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u8 **script UNNEEDED)
|
||||||
{ fprintf(stderr, "fromwire_hsm_get_output_scriptpubkey_reply called!\n"); abort(); }
|
{ fprintf(stderr, "fromwire_hsmd_get_output_scriptpubkey_reply called!\n"); abort(); }
|
||||||
/* Generated stub for fromwire_hsm_sign_commitment_tx_reply */
|
/* Generated stub for fromwire_hsmd_sign_commitment_tx_reply */
|
||||||
bool fromwire_hsm_sign_commitment_tx_reply(const void *p UNNEEDED, struct bitcoin_signature *sig UNNEEDED)
|
bool fromwire_hsmd_sign_commitment_tx_reply(const void *p UNNEEDED, struct bitcoin_signature *sig UNNEEDED)
|
||||||
{ fprintf(stderr, "fromwire_hsm_sign_commitment_tx_reply called!\n"); abort(); }
|
{ fprintf(stderr, "fromwire_hsmd_sign_commitment_tx_reply called!\n"); abort(); }
|
||||||
/* Generated stub for fromwire_onchain_dev_memleak_reply */
|
/* Generated stub for fromwire_onchain_dev_memleak_reply */
|
||||||
bool fromwire_onchain_dev_memleak_reply(const void *p UNNEEDED, bool *leak UNNEEDED)
|
bool fromwire_onchain_dev_memleak_reply(const void *p UNNEEDED, bool *leak UNNEEDED)
|
||||||
{ fprintf(stderr, "fromwire_onchain_dev_memleak_reply called!\n"); abort(); }
|
{ fprintf(stderr, "fromwire_onchain_dev_memleak_reply called!\n"); abort(); }
|
||||||
|
@ -696,12 +696,12 @@ u8 *towire_final_incorrect_htlc_amount(const tal_t *ctx UNNEEDED, struct amount_
|
||||||
/* Generated stub for towire_gossip_get_stripped_cupdate */
|
/* Generated stub for towire_gossip_get_stripped_cupdate */
|
||||||
u8 *towire_gossip_get_stripped_cupdate(const tal_t *ctx UNNEEDED, const struct short_channel_id *channel_id UNNEEDED)
|
u8 *towire_gossip_get_stripped_cupdate(const tal_t *ctx UNNEEDED, const struct short_channel_id *channel_id UNNEEDED)
|
||||||
{ fprintf(stderr, "towire_gossip_get_stripped_cupdate called!\n"); abort(); }
|
{ fprintf(stderr, "towire_gossip_get_stripped_cupdate called!\n"); abort(); }
|
||||||
/* Generated stub for towire_hsm_get_output_scriptpubkey */
|
/* Generated stub for towire_hsmd_get_output_scriptpubkey */
|
||||||
u8 *towire_hsm_get_output_scriptpubkey(const tal_t *ctx UNNEEDED, u64 channel_id UNNEEDED, const struct node_id *peer_id UNNEEDED, const struct pubkey *commitment_point UNNEEDED)
|
u8 *towire_hsmd_get_output_scriptpubkey(const tal_t *ctx UNNEEDED, u64 channel_id UNNEEDED, const struct node_id *peer_id UNNEEDED, const struct pubkey *commitment_point UNNEEDED)
|
||||||
{ fprintf(stderr, "towire_hsm_get_output_scriptpubkey called!\n"); abort(); }
|
{ fprintf(stderr, "towire_hsmd_get_output_scriptpubkey called!\n"); abort(); }
|
||||||
/* Generated stub for towire_hsm_sign_commitment_tx */
|
/* Generated stub for towire_hsmd_sign_commitment_tx */
|
||||||
u8 *towire_hsm_sign_commitment_tx(const tal_t *ctx UNNEEDED, const struct node_id *peer_id UNNEEDED, u64 channel_dbid UNNEEDED, const struct bitcoin_tx *tx UNNEEDED, const struct pubkey *remote_funding_key UNNEEDED)
|
u8 *towire_hsmd_sign_commitment_tx(const tal_t *ctx UNNEEDED, const struct node_id *peer_id UNNEEDED, u64 channel_dbid UNNEEDED, const struct bitcoin_tx *tx UNNEEDED, const struct pubkey *remote_funding_key UNNEEDED)
|
||||||
{ fprintf(stderr, "towire_hsm_sign_commitment_tx called!\n"); abort(); }
|
{ fprintf(stderr, "towire_hsmd_sign_commitment_tx called!\n"); abort(); }
|
||||||
/* Generated stub for towire_incorrect_cltv_expiry */
|
/* Generated stub for towire_incorrect_cltv_expiry */
|
||||||
u8 *towire_incorrect_cltv_expiry(const tal_t *ctx UNNEEDED, u32 cltv_expiry UNNEEDED, const u8 *channel_update UNNEEDED)
|
u8 *towire_incorrect_cltv_expiry(const tal_t *ctx UNNEEDED, u32 cltv_expiry UNNEEDED, const u8 *channel_update UNNEEDED)
|
||||||
{ fprintf(stderr, "towire_incorrect_cltv_expiry called!\n"); abort(); }
|
{ fprintf(stderr, "towire_incorrect_cltv_expiry called!\n"); abort(); }
|
||||||
|
@ -782,7 +782,7 @@ bool dev_disconnect_permanent(struct lightningd *ld UNNEEDED)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Fake stubs to talk to hsm */
|
/* Fake stubs to talk to hsm */
|
||||||
u8 *towire_hsm_get_channel_basepoints(const tal_t *ctx UNNEEDED, const struct node_id *peerid UNNEEDED, u64 dbid UNNEEDED)
|
u8 *towire_hsmd_get_channel_basepoints(const tal_t *ctx UNNEEDED, const struct node_id *peerid UNNEEDED, u64 dbid UNNEEDED)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -797,7 +797,7 @@ u8 *wire_sync_read(const tal_t *ctx UNNEEDED, int fd UNNEEDED)
|
||||||
void plugin_hook_db_sync(struct db *db UNNEEDED)
|
void plugin_hook_db_sync(struct db *db UNNEEDED)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
bool fromwire_hsm_get_channel_basepoints_reply(const void *p UNNEEDED,
|
bool fromwire_hsmd_get_channel_basepoints_reply(const void *p UNNEEDED,
|
||||||
struct basepoints *basepoints,
|
struct basepoints *basepoints,
|
||||||
struct pubkey *funding_pubkey)
|
struct pubkey *funding_pubkey)
|
||||||
{
|
{
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
#include <common/wallet_tx.h>
|
#include <common/wallet_tx.h>
|
||||||
#include <common/withdraw_tx.h>
|
#include <common/withdraw_tx.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <hsmd/gen_hsm_wire.h>
|
#include <hsmd/hsmd_wiregen.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <lightningd/bitcoind.h>
|
#include <lightningd/bitcoind.h>
|
||||||
#include <lightningd/chaintopology.h>
|
#include <lightningd/chaintopology.h>
|
||||||
|
@ -115,7 +115,7 @@ static struct command_result *broadcast_and_wait(struct command *cmd,
|
||||||
|
|
||||||
/* FIXME: hsm will sign almost anything, but it should really
|
/* FIXME: hsm will sign almost anything, but it should really
|
||||||
* fail cleanly (not abort!) and let us report the error here. */
|
* fail cleanly (not abort!) and let us report the error here. */
|
||||||
u8 *msg = towire_hsm_sign_withdrawal(cmd, utx->wtx->utxos, utx->tx->psbt);
|
u8 *msg = towire_hsmd_sign_withdrawal(cmd, utx->wtx->utxos, utx->tx->psbt);
|
||||||
|
|
||||||
if (!wire_sync_write(cmd->ld->hsm_fd, take(msg)))
|
if (!wire_sync_write(cmd->ld->hsm_fd, take(msg)))
|
||||||
fatal("Could not write sign_withdrawal to HSM: %s",
|
fatal("Could not write sign_withdrawal to HSM: %s",
|
||||||
|
@ -123,7 +123,7 @@ static struct command_result *broadcast_and_wait(struct command *cmd,
|
||||||
|
|
||||||
msg = wire_sync_read(cmd, cmd->ld->hsm_fd);
|
msg = wire_sync_read(cmd, cmd->ld->hsm_fd);
|
||||||
|
|
||||||
if (!fromwire_hsm_sign_withdrawal_reply(utx, msg, &signed_psbt))
|
if (!fromwire_hsmd_sign_withdrawal_reply(utx, msg, &signed_psbt))
|
||||||
fatal("HSM gave bad sign_withdrawal_reply %s",
|
fatal("HSM gave bad sign_withdrawal_reply %s",
|
||||||
tal_hex(tmpctx, msg));
|
tal_hex(tmpctx, msg));
|
||||||
|
|
||||||
|
@ -1333,7 +1333,7 @@ static struct command_result *json_signpsbt(struct command *cmd,
|
||||||
|
|
||||||
/* FIXME: hsm will sign almost anything, but it should really
|
/* FIXME: hsm will sign almost anything, but it should really
|
||||||
* fail cleanly (not abort!) and let us report the error here. */
|
* fail cleanly (not abort!) and let us report the error here. */
|
||||||
u8 *msg = towire_hsm_sign_withdrawal(cmd,
|
u8 *msg = towire_hsmd_sign_withdrawal(cmd,
|
||||||
cast_const2(const struct utxo **, utxos),
|
cast_const2(const struct utxo **, utxos),
|
||||||
psbt);
|
psbt);
|
||||||
|
|
||||||
|
@ -1343,7 +1343,7 @@ static struct command_result *json_signpsbt(struct command *cmd,
|
||||||
|
|
||||||
msg = wire_sync_read(cmd, cmd->ld->hsm_fd);
|
msg = wire_sync_read(cmd, cmd->ld->hsm_fd);
|
||||||
|
|
||||||
if (!fromwire_hsm_sign_withdrawal_reply(cmd, msg, &signed_psbt))
|
if (!fromwire_hsmd_sign_withdrawal_reply(cmd, msg, &signed_psbt))
|
||||||
fatal("HSM gave bad sign_withdrawal_reply %s",
|
fatal("HSM gave bad sign_withdrawal_reply %s",
|
||||||
tal_hex(tmpctx, msg));
|
tal_hex(tmpctx, msg));
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue