Browse Source

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>
bump-pyln-proto
Rusty Russell 4 years ago
parent
commit
1702c7a69a
  1. 1
      channeld/Makefile
  2. 26
      channeld/channeld.c
  3. 6
      channeld/watchtower.c
  4. 3
      closingd/Makefile
  5. 10
      closingd/closingd.c
  6. 1
      common/bolt11.c
  7. 6
      common/ecdh_hsmd.c
  8. 3
      connectd/Makefile
  9. 2
      connectd/connectd.c
  10. 1
      gossipd/Makefile
  11. 10
      gossipd/gossip_generation.c
  12. 24
      gossipd/test/run-crc32_of_update.c
  13. 18
      hsmd/Makefile
  14. 200
      hsmd/hsm_wire.csv
  15. 244
      hsmd/hsmd.c
  16. 200
      hsmd/hsmd_wire.csv
  17. 5
      lightningd/Makefile
  18. 6
      lightningd/channel.c
  19. 1
      lightningd/channel_control.c
  20. 1
      lightningd/connect_control.c
  21. 1
      lightningd/gossip_control.c
  22. 12
      lightningd/hsm_control.c
  23. 6
      lightningd/invoice.c
  24. 6
      lightningd/memdump.c
  25. 1
      lightningd/onchain_control.c
  26. 1
      lightningd/opening_control.c
  27. 6
      lightningd/peer_control.c
  28. 1
      lightningd/peer_htlcs.c
  29. 6
      lightningd/signmessage.c
  30. 36
      lightningd/test/run-invoice-select-inchan.c
  31. 3
      onchaind/Makefile
  32. 18
      onchaind/onchaind.c
  33. 36
      onchaind/test/run-grind_feerate-bug.c
  34. 42
      onchaind/test/run-grind_feerate.c
  35. 1
      openingd/Makefile
  36. 14
      openingd/openingd.c
  37. 6
      wallet/db.c
  38. 12
      wallet/test/run-db.c
  39. 28
      wallet/test/run-wallet.c
  40. 10
      wallet/walletrpc.c

1
channeld/Makefile

@ -92,7 +92,6 @@ CHANNELD_COMMON_OBJS := \
common/wire_error.o \
common/wireaddr.o \
gossipd/gen_gossip_peerd_wire.o \
hsmd/gen_hsm_wire.o \
lightningd/gossip_msg.o \
wire/fromwire.o \
wire/towire.o

26
channeld/channeld.c

@ -57,7 +57,7 @@
#include <errno.h>
#include <fcntl.h>
#include <gossipd/gen_gossip_peerd_wire.h>
#include <hsmd/gen_hsm_wire.h>
#include <hsmd/hsmd_wiregen.h>
#include <inttypes.h>
#include <secp256k1.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))
status_failed(STATUS_FAIL_HSM_IO,
"Writing %s to HSM: %s",
hsm_wire_type_name(type),
hsmd_wire_name(type),
strerror(errno));
msg = wire_sync_read(ctx, HSM_FD);
if (!msg)
status_failed(STATUS_FAIL_HSM_IO,
"Reading resp to %s: %s",
hsm_wire_type_name(type),
hsmd_wire_name(type),
strerror(errno));
return msg;
@ -385,10 +385,10 @@ static void send_announcement_signatures(struct peer *peer)
status_debug("Exchanging announcement signatures.");
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);
if (!fromwire_hsm_cannouncement_sig_reply(msg,
if (!fromwire_hsmd_cannouncement_sig_reply(msg,
&peer->announcement_node_sigs[LOCAL],
&peer->announcement_bitcoin_sigs[LOCAL]))
status_failed(STATUS_FAIL_HSM_IO,
@ -840,13 +840,13 @@ static struct bitcoin_signature *calc_commitsigs(const tal_t *ctx,
const u8 *msg;
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->remote_per_commit,
peer->channel->option_static_remotekey);
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,
"Reading sign_remote_commitment_tx reply: %s",
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],
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->channel->option_anchor_outputs);
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,
"Bad sign_remote_htlc_tx reply: %s",
tal_hex(tmpctx, msg));
@ -1134,9 +1134,9 @@ static void get_per_commitment_point(u64 index, struct pubkey *point,
const u8 *msg;
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,
&s))
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);
msg = towire_hsm_check_future_secret(NULL,
msg = towire_hsmd_check_future_secret(NULL,
next_revocation_number - 1,
last_local_per_commit_secret);
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,
"Bad hsm_check_future_secret_reply: %s",
tal_hex(tmpctx, msg));

6
channeld/watchtower.c

@ -9,7 +9,7 @@
#include <common/keyset.h>
#include <common/status.h>
#include <common/type_to_string.h>
#include <hsmd/gen_hsm_wire.h>
#include <hsmd/hsmd_wiregen.h>
#include <wire/wire_sync.h>
static const u8 ONE = 0x1;
@ -102,7 +102,7 @@ penalty_tx_create(const tal_t *ctx,
bitcoin_tx_finalize(tx);
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);
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");
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,
"Reading sign_tx_reply: %s", tal_hex(tmpctx, msg));

3
closingd/Makefile

@ -82,8 +82,7 @@ CLOSINGD_COMMON_OBJS := \
common/version.o \
common/wire_error.o \
common/wireaddr.o \
gossipd/gen_gossip_peerd_wire.o \
hsmd/gen_hsm_wire.o
gossipd/gen_gossip_peerd_wire.o
closingd/gen_closing_wire.h: $(WIRE_GEN) closingd/closing_wire.csv
$(WIRE_GEN) --page header $@ closing_wire_type < closingd/closing_wire.csv > $@

10
closingd/closingd.c

@ -20,7 +20,7 @@
#include <common/wire_error.h>
#include <errno.h>
#include <gossipd/gen_gossip_peerd_wire.h>
#include <hsmd/gen_hsm_wire.h>
#include <hsmd/hsmd_wiregen.h>
#include <inttypes.h>
#include <stdio.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
* received signed commitment; HSM gives us that and the previous
* secret (which we don't need). */
msg = towire_hsm_get_per_commitment_point(NULL,
msg = towire_hsmd_get_per_commitment_point(NULL,
commitment_number);
if (!wire_sync_write(HSM_FD, take(msg)))
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,
"Reading resp get_per_commitment_point reply: %s",
strerror(errno));
if (!fromwire_hsm_get_per_commitment_point_reply(tmpctx, msg,
if (!fromwire_hsmd_get_per_commitment_point_reply(tmpctx, msg,
&commitment_point,
&s))
status_failed(STATUS_FAIL_HSM_IO,
@ -279,11 +279,11 @@ static void send_offer(struct per_peer_state *pps,
*/
/* (We don't do this). */
wire_sync_write(HSM_FD,
take(towire_hsm_sign_mutual_close_tx(NULL,
take(towire_hsmd_sign_mutual_close_tx(NULL,
tx,
&funding_pubkey[REMOTE])));
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,
"Bad hsm_sign_mutual_close_tx reply %s",
tal_hex(tmpctx, msg));

1
common/bolt11.c

@ -12,7 +12,6 @@
#include <common/features.h>
#include <common/utils.h>
#include <errno.h>
#include <hsmd/gen_hsm_wire.h>
#include <inttypes.h>
#include <lightningd/hsm_control.h>
#include <lightningd/jsonrpc.h>

6
common/ecdh_hsmd.c

@ -1,6 +1,6 @@
#include <common/ecdh_hsmd.h>
#include <common/utils.h>
#include <hsmd/gen_hsm_wire.h>
#include <hsmd/hsmd_wiregen.h>
#include <wire/wire_sync.h>
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)
{
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)))
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)
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");
}

3
connectd/Makefile

@ -74,7 +74,6 @@ CONNECTD_COMMON_OBJS := \
common/wireaddr.o \
common/wire_error.o \
gossipd/gen_gossip_wire.o \
hsmd/gen_hsm_wire.o \
lightningd/gossip_msg.o \
wire/gen_onion_wire.o
@ -84,7 +83,7 @@ $(LIGHTNINGD_CONNECT_CONTROL_OBJS) : $(LIGHTNINGD_CONNECT_CONTROL_HEADERS)
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
$(WIRE_GEN) --page header $@ connect_wire_type < connectd/connect_wire.csv > $@

2
connectd/connectd.c

@ -53,7 +53,7 @@
#include <connectd/tor_autoservice.h>
#include <errno.h>
#include <gossipd/gen_gossip_wire.h>
#include <hsmd/gen_hsm_wire.h>
#include <hsmd/hsmd_wiregen.h>
#include <inttypes.h>
#include <lightningd/gossip_msg.h>
#include <netdb.h>

1
gossipd/Makefile

@ -77,7 +77,6 @@ GOSSIPD_COMMON_OBJS := \
common/wireaddr.o \
common/wire_error.o \
connectd/gen_connect_gossip_wire.o \
hsmd/gen_hsm_wire.o \
lightningd/gossip_msg.o \
wire/gen_onion_wire.o

10
gossipd/gossip_generation.c

@ -13,7 +13,7 @@
#include <gossipd/gossip_generation.h>
#include <gossipd/gossip_store.h>
#include <gossipd/gossipd.h>
#include <hsmd/gen_hsm_wire.h>
#include <hsmd/hsmd_wiregen.h>
#include <wire/gen_peer_wire.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) */
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));
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");
/* 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
* remote HSMs */
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",
strerror(errno));
}
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,
"Reading cupdate_sig_req: %s",
strerror(errno));

24
gossipd/test/run-crc32_of_update.c

@ -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 */
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(); }
/* Generated stub for fromwire_hsm_cupdate_sig_reply */
bool fromwire_hsm_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(); }
/* Generated stub for fromwire_hsm_node_announcement_sig_reply */
bool fromwire_hsm_node_announcement_sig_reply(const void *p UNNEEDED, secp256k1_ecdsa_signature *signature UNNEEDED)
{ fprintf(stderr, "fromwire_hsm_node_announcement_sig_reply called!\n"); abort(); }
/* Generated stub for fromwire_hsmd_cupdate_sig_reply */
bool fromwire_hsmd_cupdate_sig_reply(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u8 **cu UNNEEDED)
{ fprintf(stderr, "fromwire_hsmd_cupdate_sig_reply called!\n"); abort(); }
/* Generated stub for fromwire_hsmd_node_announcement_sig_reply */
bool fromwire_hsmd_node_announcement_sig_reply(const void *p UNNEEDED, secp256k1_ecdsa_signature *signature UNNEEDED)
{ fprintf(stderr, "fromwire_hsmd_node_announcement_sig_reply called!\n"); abort(); }
/* Generated stub for get_node */
struct node *get_node(struct routing_state *rstate 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 char *fmt UNNEEDED, ...)
{ fprintf(stderr, "towire_errorfmt called!\n"); abort(); }
/* Generated stub for towire_hsm_cupdate_sig_req */
u8 *towire_hsm_cupdate_sig_req(const tal_t *ctx UNNEEDED, const u8 *cu UNNEEDED)
{ fprintf(stderr, "towire_hsm_cupdate_sig_req called!\n"); abort(); }
/* Generated stub for towire_hsm_node_announcement_sig_req */
u8 *towire_hsm_node_announcement_sig_req(const tal_t *ctx UNNEEDED, const u8 *announcement UNNEEDED)
{ fprintf(stderr, "towire_hsm_node_announcement_sig_req called!\n"); abort(); }
/* Generated stub for towire_hsmd_cupdate_sig_req */
u8 *towire_hsmd_cupdate_sig_req(const tal_t *ctx UNNEEDED, const u8 *cu UNNEEDED)
{ fprintf(stderr, "towire_hsmd_cupdate_sig_req called!\n"); abort(); }
/* Generated stub for towire_hsmd_node_announcement_sig_req */
u8 *towire_hsmd_node_announcement_sig_req(const tal_t *ctx UNNEEDED, const u8 *announcement UNNEEDED)
{ fprintf(stderr, "towire_hsmd_node_announcement_sig_req called!\n"); abort(); }
/* Generated stub for towire_wireaddr */
void towire_wireaddr(u8 **pptr UNNEEDED, const struct wireaddr *addr UNNEEDED)
{ fprintf(stderr, "towire_wireaddr called!\n"); abort(); }

18
hsmd/Makefile

@ -7,8 +7,8 @@ hsmd-wrongdir:
default: hsmd-all
LIGHTNINGD_HSM_SRC := hsmd/hsmd.c \
hsmd/gen_hsm_wire.c
LIGHTNINGD_HSM_HEADERS := hsmd/gen_hsm_wire.h
hsmd/hsmd_wiregen.c
LIGHTNINGD_HSM_HEADERS := hsmd/hsmd_wiregen.h
LIGHTNINGD_HSM_OBJS := $(LIGHTNINGD_HSM_SRC:.c=.o)
# Common source we use.
@ -38,27 +38,23 @@ HSMD_COMMON_OBJS := \
common/version.o \
common/withdraw_tx.o
LIGHTNINGD_HSM_CLIENT_OBJS := hsmd/hsmd_wiregen.o
# For checking
LIGHTNINGD_HSM_ALLSRC_NOGEN := $(filter-out hsmd/gen_%, $(LIGHTNINGD_HSM_SRC) $(LIGHTNINGD_HSM_SRC))
LIGHTNINGD_HSM_ALLHEADERS_NOGEN := $(filter-out hsmd/gen_%, $(LIGHTNINGD_HSM_HEADERS))
LIGHTNINGD_HSM_ALLSRC_NOGEN := $(filter-out hsmd/%wiregen.c, $(LIGHTNINGD_HSM_SRC) $(LIGHTNINGD_HSM_SRC))
LIGHTNINGD_HSM_ALLHEADERS_NOGEN := $(filter-out hsmd/%wiregen.h, $(LIGHTNINGD_HSM_HEADERS))
$(LIGHTNINGD_HSM_OBJS): $(LIGHTNINGD_HEADERS)
# Make sure these depend on everything.
ALL_OBJS += $(LIGHTNINGD_HSM_OBJS)
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
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-bolt: $(LIGHTNINGD_HSM_SRC:%=bolt-check/%)

200
hsmd/hsm_wire.csv

@ -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
Can't render this file because it has a wrong number of fields in line 2.

244
hsmd/hsmd.c

@ -41,8 +41,8 @@
#include <errno.h>
#include <fcntl.h>
#include <hsmd/capabilities.h>
/*~ All gen_ files are autogenerated; in this case by tools/generate-wire.py */
#include <hsmd/gen_hsm_wire.h>
/*~ _wiregen files are autogenerated by tools/generate-wire.py */
#include <hsmd/hsmd_wiregen.h>
#include <inttypes.h>
#include <secp256k1_ecdh.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
* an extension of the simple comma-separated format output by the
* 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))
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!
*/
return req_reply(conn, c,
take(towire_hsm_init_reply(NULL, &node_id,
take(towire_hsmd_init_reply(NULL, &node_id,
&secretstuff.bip32)));
}
@ -747,7 +747,7 @@ static struct io_plan *handle_ecdh(struct io_conn *conn,
struct pubkey point;
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);
/*~ 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
* 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
@ -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
* as their first field; tmpctx is good here since we won't need it
* 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);
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(&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);
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;
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);
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,
fee_base_msat, fee_proportional_mill,
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
@ -902,14 +902,14 @@ static struct io_plan *handle_get_channel_basepoints(struct io_conn *conn,
struct basepoints basepoints;
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);
get_channel_seed(&peer_id, dbid, &seed);
derive_basepoints(&seed, &funding_pubkey, &basepoints, NULL, NULL);
return req_reply(conn, c,
take(towire_hsm_get_channel_basepoints_reply(NULL,
take(towire_hsmd_get_channel_basepoints_reply(NULL,
&basepoints,
&funding_pubkey)));
}
@ -934,7 +934,7 @@ static struct io_plan *handle_sign_commitment_tx(struct io_conn *conn,
struct secrets secrets;
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,
&tx,
&remote_funding_pubkey))
@ -965,7 +965,7 @@ static struct io_plan *handle_sign_commitment_tx(struct io_conn *conn,
&sig);
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
@ -989,7 +989,7 @@ static struct io_plan *handle_sign_remote_commitment_tx(struct io_conn *conn,
struct pubkey remote_per_commit;
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,
&remote_funding_pubkey,
&remote_per_commit,
@ -1016,7 +1016,7 @@ static struct io_plan *handle_sign_remote_commitment_tx(struct io_conn *conn,
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 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;
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,
&remote_per_commit_point,
&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_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
@ -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);
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
@ -1115,7 +1115,7 @@ static struct io_plan *handle_sign_delayed_payment_to_us(struct io_conn *conn,
u8 *wscript;
/*~ 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,
&tx, &wscript))
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;
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,
&tx, &wscript,
&option_anchor_outputs))
@ -1217,7 +1217,7 @@ static struct io_plan *handle_sign_penalty_to_us(struct io_conn *conn,
struct privkey privkey;
u8 *wscript;
if (!fromwire_hsm_sign_penalty_to_us(tmpctx, msg_in,
if (!fromwire_hsmd_sign_penalty_to_us(tmpctx, msg_in,
&revocation_secret,
&tx, &wscript))
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;
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,
&option_anchor_outputs))
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,
&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
@ -1331,7 +1331,7 @@ static struct io_plan *handle_get_per_commitment_point(struct io_conn *conn,
u64 n;
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);
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
* pretty badly here, but it's a recommendation not a religion. */
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,
old_secret)));
}
@ -1374,7 +1374,7 @@ static struct io_plan *handle_check_future_secret(struct io_conn *conn,
u64 n;
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);
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
* timing dependent. */
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))));
}
@ -1406,7 +1406,7 @@ static struct io_plan *handle_sign_mutual_close_tx(struct io_conn *conn,
struct secrets secrets;
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,
&remote_funding_pubkey))
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,
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
@ -1473,7 +1473,7 @@ static struct io_plan *pass_client_hsmfd(struct io_conn *conn,
/* This must be lightningd itself. */
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);
/* 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
* create a boutique structure and hand that, but we don't need to. */
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);
}
@ -1606,14 +1606,14 @@ static struct io_plan *handle_sign_withdrawal_tx(struct io_conn *conn,
struct utxo **utxos;
struct wally_psbt *psbt;
if (!fromwire_hsm_sign_withdrawal(tmpctx, msg_in,
if (!fromwire_hsmd_sign_withdrawal(tmpctx, msg_in,
&utxos, &psbt))
return bad_req(conn, c, msg_in);
sign_our_inputs(utxos, psbt);
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,
@ -1626,7 +1626,7 @@ static struct io_plan *handle_get_output_scriptpubkey(struct io_conn *conn,
u8 *scriptPubkey;
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.peer_id,
&info.commitment_point))
@ -1637,7 +1637,7 @@ static struct io_plan *handle_get_output_scriptpubkey(struct io_conn *conn,
scriptPubkey = scriptpubkey_p2wpkh(tmpctx, &pubkey);
return req_reply(conn, c,
take(towire_hsm_get_output_scriptpubkey_reply(NULL,
take(towire_hsmd_get_output_scriptpubkey_reply(NULL,
scriptPubkey)));
}
@ -1661,7 +1661,7 @@ static struct io_plan *handle_sign_invoice(struct io_conn *conn,
struct hash_u5 hu5;
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);
/* BOLT #11:
@ -1702,7 +1702,7 @@ static struct io_plan *handle_sign_invoice(struct io_conn *conn,
}
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
@ -1728,7 +1728,7 @@ static struct io_plan *handle_sign_node_announcement(struct io_conn *conn,
u8 *reply;
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);
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);
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));
}
@ -1766,7 +1766,7 @@ static struct io_plan *handle_sign_message(struct io_conn *conn,
secp256k1_ecdsa_recoverable_signature rsig;
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);
/* 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,
take(towire_hsm_sign_message_reply(NULL, &rsig)));
take(towire_hsmd_sign_message_reply(NULL, &rsig)));
}
#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);
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));
}
#endif /* DEVELOPER */
/*~ This routine checks that a client is allowed to call the handler. */
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
* 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!
*/
switch (t) {
case WIRE_HSM_ECDH_REQ:
case WIRE_HSMD_ECDH_REQ:
return (client->capabilities & HSM_CAP_ECDH) != 0;
case WIRE_HSM_CANNOUNCEMENT_SIG_REQ:
case WIRE_HSM_CUPDATE_SIG_REQ:
case WIRE_HSM_NODE_ANNOUNCEMENT_SIG_REQ:
case WIRE_HSMD_CANNOUNCEMENT_SIG_REQ:
case WIRE_HSMD_CUPDATE_SIG_REQ:
case WIRE_HSMD_NODE_ANNOUNCEMENT_SIG_REQ:
return (client->capabilities & HSM_CAP_SIGN_GOSSIP) != 0;
case WIRE_HSM_SIGN_DELAYED_PAYMENT_TO_US:
case WIRE_HSM_SIGN_REMOTE_HTLC_TO_US:
case WIRE_HSM_SIGN_PENALTY_TO_US:
case WIRE_HSM_SIGN_LOCAL_HTLC_TX:
case WIRE_HSMD_SIGN_DELAYED_PAYMENT_TO_US:
case WIRE_HSMD_SIGN_REMOTE_HTLC_TO_US:
case WIRE_HSMD_SIGN_PENALTY_TO_US:
case WIRE_HSMD_SIGN_LOCAL_HTLC_TX:
return (client->capabilities & HSM_CAP_SIGN_ONCHAIN_TX) != 0;
case WIRE_HSM_GET_PER_COMMITMENT_POINT:
case WIRE_HSM_CHECK_FUTURE_SECRET:
case WIRE_HSMD_GET_PER_COMMITMENT_POINT:
case WIRE_HSMD_CHECK_FUTURE_SECRET:
return (client->capabilities & HSM_CAP_COMMITMENT_POINT) != 0;
case WIRE_HSM_SIGN_REMOTE_COMMITMENT_TX:
case WIRE_HSM_SIGN_REMOTE_HTLC_TX:
case WIRE_HSMD_SIGN_REMOTE_COMMITMENT_TX:
case WIRE_HSMD_SIGN_REMOTE_HTLC_TX:
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;
case WIRE_HSM_INIT:
case WIRE_HSM_CLIENT_HSMFD:
case WIRE_HSM_SIGN_WITHDRAWAL:
case WIRE_HSM_SIGN_INVOICE:
case WIRE_HSM_SIGN_COMMITMENT_TX:
case WIRE_HSM_GET_CHANNEL_BASEPOINTS:
case WIRE_HSM_DEV_MEMLEAK:
case WIRE_HSM_SIGN_MESSAGE:
case WIRE_HSM_GET_OUTPUT_SCRIPTPUBKEY:
case WIRE_HSMD_INIT:
case WIRE_HSMD_CLIENT_HSMFD:
case WIRE_HSMD_SIGN_WITHDRAWAL:
case WIRE_HSMD_SIGN_INVOICE:
case WIRE_HSMD_SIGN_COMMITMENT_TX:
case WIRE_HSMD_GET_CHANNEL_BASEPOINTS:
case WIRE_HSMD_DEV_MEMLEAK:
case WIRE_HSMD_SIGN_MESSAGE:
case WIRE_HSMD_GET_OUTPUT_SCRIPTPUBKEY:
return (client->capabilities & HSM_CAP_MASTER) != 0;
/*~ These are messages sent by the HSM so we should never receive them. */
/* FIXME: Since we autogenerate these, we should really generate separate
* enums for replies to avoid this kind of clutter! */
case WIRE_HSM_ECDH_RESP:
case WIRE_HSM_CANNOUNCEMENT_SIG_REPLY:
case WIRE_HSM_CUPDATE_SIG_REPLY:
case WIRE_HSM_CLIENT_HSMFD_REPLY:
case WIRE_HSM_NODE_ANNOUNCEMENT_SIG_REPLY:
case WIRE_HSM_SIGN_WITHDRAWAL_REPLY:
case WIRE_HSM_SIGN_INVOICE_REPLY:
case WIRE_HSM_INIT_REPLY:
case WIRE_HSMD_ECDH_RESP:
case WIRE_HSMD_CANNOUNCEMENT_SIG_REPLY:
case WIRE_HSMD_CUPDATE_SIG_REPLY:
case WIRE_HSMD_CLIENT_HSMFD_REPLY:
case WIRE_HSMD_NODE_ANNOUNCEMENT_SIG_REPLY:
case WIRE_HSMD_SIGN_WITHDRAWAL_REPLY:
case WIRE_HSMD_SIGN_INVOICE_REPLY:
case WIRE_HSMD_INIT_REPLY:
case WIRE_HSMSTATUS_CLIENT_BAD_REQUEST:
case WIRE_HSM_SIGN_COMMITMENT_TX_REPLY:
case WIRE_HSM_SIGN_TX_REPLY:
case WIRE_HSM_GET_PER_COMMITMENT_POINT_REPLY:
case WIRE_HSM_CHECK_FUTURE_SECRET_REPLY:
case WIRE_HSM_GET_CHANNEL_BASEPOINTS_REPLY:
case WIRE_HSM_DEV_MEMLEAK_REPLY:
case WIRE_HSM_SIGN_MESSAGE_REPLY:
case WIRE_HSM_GET_OUTPUT_SCRIPTPUBKEY_REPLY:
case WIRE_HSMD_SIGN_COMMITMENT_TX_REPLY:
case WIRE_HSMD_SIGN_TX_REPLY:
case WIRE_HSMD_GET_PER_COMMITMENT_POINT_REPLY:
case WIRE_HSMD_CHECK_FUTURE_SECRET_REPLY:
case WIRE_HSMD_GET_CHANNEL_BASEPOINTS_REPLY:
case WIRE_HSMD_DEV_MEMLEAK_REPLY:
case WIRE_HSMD_SIGN_MESSAGE_REPLY:
case WIRE_HSMD_GET_OUTPUT_SCRIPTPUBKEY_REPLY:
break;
}
return false;
@ -1900,7 +1900,7 @@ static bool check_client_capabilities(struct client *client,
/*~ This is the core of the HSM daemon: handling requests. */
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);
@ -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 */
switch (t) {
case WIRE_HSM_INIT:
case WIRE_HSMD_INIT:
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);
case WIRE_HSM_GET_CHANNEL_BASEPOINTS:
case WIRE_HSMD_GET_CHANNEL_BASEPOINTS:
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);
case WIRE_HSM_ECDH_REQ:
case WIRE_HSMD_ECDH_REQ:
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);
case WIRE_HSM_CUPDATE_SIG_REQ:
case WIRE_HSMD_CUPDATE_SIG_REQ:
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);
case WIRE_HSM_SIGN_INVOICE:
case WIRE_HSMD_SIGN_INVOICE:
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);
case WIRE_HSM_SIGN_COMMITMENT_TX:
case WIRE_HSMD_SIGN_COMMITMENT_TX:
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);
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);
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);
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);
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);
case WIRE_HSM_CHECK_FUTURE_SECRET:
case WIRE_HSMD_CHECK_FUTURE_SECRET:
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);
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);
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);
case WIRE_HSM_SIGN_MESSAGE:
case WIRE_HSMD_SIGN_MESSAGE:
return handle_sign_message(conn, c, c->msg_in);
#if DEVELOPER
case WIRE_HSM_DEV_MEMLEAK:
case WIRE_HSMD_DEV_MEMLEAK:
return handle_memleak(conn, c, c->msg_in);
#else
case WIRE_HSM_DEV_MEMLEAK:
case WIRE_HSMD_DEV_MEMLEAK:
#endif /* DEVELOPER */
case WIRE_HSM_ECDH_RESP:
case WIRE_HSM_CANNOUNCEMENT_SIG_REPLY:
case WIRE_HSM_CUPDATE_SIG_REPLY:
case WIRE_HSM_CLIENT_HSMFD_REPLY:
case WIRE_HSM_NODE_ANNOUNCEMENT_SIG_REPLY:
case WIRE_HSM_SIGN_WITHDRAWAL_REPLY:
case WIRE_HSM_SIGN_INVOICE_REPLY:
case WIRE_HSM_INIT_REPLY:
case WIRE_HSMD_ECDH_RESP:
case WIRE_HSMD_CANNOUNCEMENT_SIG_REPLY:
case WIRE_HSMD_CUPDATE_SIG_REPLY:
case WIRE_HSMD_CLIENT_HSMFD_REPLY:
case WIRE_HSMD_NODE_ANNOUNCEMENT_SIG_REPLY:
case WIRE_HSMD_SIGN_WITHDRAWAL_REPLY:
case WIRE_HSMD_SIGN_INVOICE_REPLY:
case WIRE_HSMD_INIT_REPLY:
case WIRE_HSMSTATUS_CLIENT_BAD_REQUEST:
case WIRE_HSM_SIGN_COMMITMENT_TX_REPLY:
case WIRE_HSM_SIGN_TX_REPLY:
case WIRE_HSM_GET_PER_COMMITMENT_POINT_REPLY:
case WIRE_HSM_CHECK_FUTURE_SECRET_REPLY:
case WIRE_HSM_GET_CHANNEL_BASEPOINTS_REPLY:
case WIRE_HSM_DEV_MEMLEAK_REPLY:
case WIRE_HSM_SIGN_MESSAGE_REPLY:
case WIRE_HSM_GET_OUTPUT_SCRIPTPUBKEY_REPLY:
case WIRE_HSMD_SIGN_COMMITMENT_TX_REPLY:
case WIRE_HSMD_SIGN_TX_REPLY:
case WIRE_HSMD_GET_PER_COMMITMENT_POINT_REPLY:
case WIRE_HSMD_CHECK_FUTURE_SECRET_REPLY:
case WIRE_HSMD_GET_CHANNEL_BASEPOINTS_REPLY:
case WIRE_HSMD_DEV_MEMLEAK_REPLY:
case WIRE_HSMD_SIGN_MESSAGE_REPLY:
case WIRE_HSMD_GET_OUTPUT_SCRIPTPUBKEY_REPLY:
break;
}

200
hsmd/hsmd_wire.csv

@ -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
Can't render this file because it has a wrong number of fields in line 2.

5
lightningd/Makefile

@ -72,8 +72,7 @@ LIGHTNINGD_COMMON_OBJS := \
common/wallet_tx.o \
common/wire_error.o \
common/wireaddr.o \
common/withdraw_tx.o \
hsmd/gen_hsm_wire.o
common/withdraw_tx.o
LIGHTNINGD_SRC := \
lightningd/bitcoind.c \
@ -153,7 +152,7 @@ check-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
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

6
lightningd/channel.c

@ -9,7 +9,7 @@
#include <common/wire_error.h>
#include <connectd/gen_connect_wire.h>
#include <errno.h>
#include <hsmd/gen_hsm_wire.h>
#include <hsmd/hsmd_wiregen.h>
#include <inttypes.h>
#include <lightningd/channel.h>
#include <lightningd/connect_control.h>
@ -130,12 +130,12 @@ void get_channel_basepoints(struct lightningd *ld,
u8 *msg;
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)))
fatal("Could not write to HSM: %s", strerror(errno));
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))
fatal("HSM gave bad hsm_get_channel_basepoints_reply %s",
tal_hex(msg, msg));

1
lightningd/channel_control.c

@ -15,7 +15,6 @@
#include <common/wallet_tx.h>
#include <common/wire_error.h>
#include <errno.h>
#include <hsmd/gen_hsm_wire.h>
#include <inttypes.h>
#include <lightningd/channel_control.h>
#include <lightningd/closing_control.h>

1
lightningd/connect_control.c

@ -17,7 +17,6 @@
#include <connectd/gen_connect_wire.h>
#include <errno.h>
#include <hsmd/capabilities.h>
#include <hsmd/gen_hsm_wire.h>
#include <lightningd/channel.h>
#include <lightningd/connect_control.h>
#include <lightningd/hsm_control.h>

1
lightningd/gossip_control.c

@ -22,7 +22,6 @@
#include <errno.h>
#include <gossipd/gen_gossip_wire.h>
#include <hsmd/capabilities.h>
#include <hsmd/gen_hsm_wire.h>
#include <inttypes.h>
#include <lightningd/connect_control.h>
#include <lightningd/gossip_msg.h>

12
lightningd/hsm_control.c

@ -13,7 +13,7 @@
#include <common/status.h>
#include <common/utils.h>
#include <errno.h>
#include <hsmd/gen_hsm_wire.h>
#include <hsmd/hsmd_wiregen.h>
#include <inttypes.h>
#include <lightningd/bitcoind.h>
#include <lightningd/hsm_control.h>
@ -36,12 +36,12 @@ static int hsm_get_fd(struct lightningd *ld,
int hsm_fd;
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)))
fatal("Could not write to HSM: %s", strerror(errno));
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));
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");
ld->hsm = new_global_subd(ld, "lightning_hsmd",
hsm_wire_type_name,
hsmd_wire_name,
hsm_msg,
take(&fds[1]), NULL);
if (!ld->hsm)
@ -112,7 +112,7 @@ struct ext_key *hsm_init(struct lightningd *ld)
}
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,
ld->config.keypass,
@ -124,7 +124,7 @@ struct ext_key *hsm_init(struct lightningd *ld)
bip32_base = tal(ld, struct ext_key);
msg = wire_sync_read(tmpctx, ld->hsm_fd);
if (!fromwire_hsm_init_reply(msg,
if (!fromwire_hsmd_init_reply(msg,
&ld->id, bip32_base)) {
if (ld->config.keypass)
errx(1, "Wrong password for encrypted hsm_secret.");

6
lightningd/invoice.c

@ -21,7 +21,7 @@
#include <common/utils.h>
#include <errno.h>
#include <gossipd/gen_gossip_wire.h>
#include <hsmd/gen_hsm_wire.h>
#include <hsmd/hsmd_wiregen.h>
#include <inttypes.h>
#include <lightningd/channel.h>
#include <lightningd/hsm_control.h>
@ -399,13 +399,13 @@ static bool hsm_sign_b11(const u5 *u5bytes,
secp256k1_ecdsa_recoverable_signature *rsig,
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)))
fatal("Could not write to HSM: %s", strerror(errno));
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",
tal_hex(msg, msg));

6
lightningd/memdump.c

@ -13,7 +13,7 @@
#include <connectd/gen_connect_wire.h>
#include <errno.h>
#include <gossipd/gen_gossip_wire.h>
#include <hsmd/gen_hsm_wire.h>
#include <hsmd/hsmd_wiregen.h>
#include <lightningd/chaintopology.h>
#include <lightningd/jsonrpc.h>
#include <lightningd/lightningd.h>
@ -265,7 +265,7 @@ static void hsm_dev_memleak_done(struct subd *hsmd,
struct lightningd *ld = cmd->ld;
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,
"Bad hsm_dev_memleak"));
return;
@ -287,7 +287,7 @@ void peer_memleak_done(struct command *cmd, struct subd *leaker)
report_leak_info(cmd, leaker);
else {
/* 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)))
fatal("Could not write to HSM: %s", strerror(errno));

1
lightningd/onchain_control.c

@ -3,7 +3,6 @@
#include <common/key_derive.h>
#include <common/utils.h>
#include <errno.h>
#include <hsmd/gen_hsm_wire.h>
#include <inttypes.h>
#include <lightningd/chaintopology.h>
#include <lightningd/coin_mvts.h>

1
lightningd/opening_control.c

@ -19,7 +19,6 @@
#include <common/wire_error.h>
#include <connectd/gen_connect_wire.h>
#include <errno.h>
#include <hsmd/gen_hsm_wire.h>
#include <lightningd/chaintopology.h>
#include <lightningd/channel_control.h>
#include <lightningd/closing_control.h>

6
lightningd/peer_control.c

@ -35,7 +35,7 @@
#include <connectd/gen_connect_wire.h>
#include <errno.h>
#include <fcntl.h>
#include <hsmd/gen_hsm_wire.h>
#include <hsmd/hsmd_wiregen.h>
#include <inttypes.h>
#include <lightningd/bitcoind.h>
#include <lightningd/chaintopology.h>
@ -184,7 +184,7 @@ static void sign_last_tx(struct channel *channel)
u8 *msg, **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->dbid,
channel->last_tx,
@ -195,7 +195,7 @@ static void sign_last_tx(struct channel *channel)
fatal("Could not write to HSM: %s", strerror(errno));
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",
tal_hex(tmpctx, msg));

1
lightningd/peer_htlcs.c

@ -20,7 +20,6 @@
#include <common/timeout.h>
#include <common/utils.h>
#include <gossipd/gen_gossip_wire.h>
#include <hsmd/gen_hsm_wire.h>
#include <lightningd/chaintopology.h>
#include <lightningd/coin_mvts.h>
#include <lightningd/htlc_end.h>

6
lightningd/signmessage.c

@ -8,7 +8,7 @@
#include <common/utils.h>
#include <errno.h>
#include <gossipd/gen_gossip_wire.h>
#include <hsmd/gen_hsm_wire.h>
#include <hsmd/hsmd_wiregen.h>
#include <lightningd/jsonrpc.h>
#include <lightningd/lightningd.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,
"Message must be < 64k");
msg = towire_hsm_sign_message(NULL,
msg = towire_hsmd_sign_message(NULL,
tal_dup_arr(tmpctx, u8, (u8 *)message,
strlen(message), 0));
if (!wire_sync_write(cmd->ld->hsm_fd, take(msg)))
fatal("Could not write to HSM: %s", strerror(errno));
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",
tal_hex(msg, msg));

36
lightningd/test/run-invoice-select-inchan.c

@ -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 */
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(); }
/* Generated stub for fromwire_hsm_get_channel_basepoints_reply */
bool fromwire_hsm_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(); }
/* Generated stub for fromwire_hsm_sign_commitment_tx_reply */
bool fromwire_hsm_sign_commitment_tx_reply(const void *p UNNEEDED, struct bitcoin_signature *sig UNNEEDED)
{ fprintf(stderr, "fromwire_hsm_sign_commitment_tx_reply called!\n"); abort(); }
/* Generated stub for fromwire_hsm_sign_invoice_reply */
bool fromwire_hsm_sign_invoice_reply(const void *p UNNEEDED, secp256k1_ecdsa_recoverable_signature *sig UNNEEDED)
{ fprintf(stderr, "fromwire_hsm_sign_invoice_reply called!\n"); abort(); }
/* Generated stub for fromwire_hsmd_get_channel_basepoints_reply */
bool fromwire_hsmd_get_channel_basepoints_reply(const void *p UNNEEDED, struct basepoints *basepoints UNNEEDED, struct pubkey *funding_pubkey UNNEEDED)
{ fprintf(stderr, "fromwire_hsmd_get_channel_basepoints_reply called!\n"); abort(); }
/* Generated stub for fromwire_hsmd_sign_commitment_tx_reply */
bool fromwire_hsmd_sign_commitment_tx_reply(const void *p UNNEEDED, struct bitcoin_signature *sig UNNEEDED)
{ fprintf(stderr, "fromwire_hsmd_sign_commitment_tx_reply called!\n"); abort(); }
/* Generated stub for fromwire_hsmd_sign_invoice_reply */
bool fromwire_hsmd_sign_invoice_reply(const void *p UNNEEDED, secp256k1_ecdsa_recoverable_signature *sig UNNEEDED)
{ fprintf(stderr, "fromwire_hsmd_sign_invoice_reply called!\n"); abort(); }
/* Generated stub for fromwire_node_id */
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(); }
@ -490,15 +490,15 @@ u8 *towire_errorfmt(const tal_t *ctx UNNEEDED,
/* Generated stub for towire_gossip_get_incoming_channels */
u8 *towire_gossip_get_incoming_channels(const tal_t *ctx UNNEEDED)
{ fprintf(stderr, "towire_gossip_get_incoming_channels called!\n"); abort(); }
/* Generated stub for towire_hsm_get_channel_basepoints */
u8 *towire_hsm_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(); }
/* Generated stub for towire_hsm_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)
{ fprintf(stderr, "towire_hsm_sign_commitment_tx called!\n"); abort(); }
/* Generated stub for towire_hsm_sign_invoice */
u8 *towire_hsm_sign_invoice(const tal_t *ctx UNNEEDED, const u8 *u5bytes UNNEEDED, const u8 *hrp UNNEEDED)
{ fprintf(stderr, "towire_hsm_sign_invoice called!\n"); abort(); }
/* Generated stub for towire_hsmd_get_channel_basepoints */
u8 *towire_hsmd_get_channel_basepoints(const tal_t *ctx UNNEEDED, const struct node_id *peerid UNNEEDED, u64 dbid UNNEEDED)
{ fprintf(stderr, "towire_hsmd_get_channel_basepoints called!\n"); abort(); }
/* Generated stub for towire_hsmd_sign_commitment_tx */
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_hsmd_sign_commitment_tx called!\n"); abort(); }
/* Generated stub for towire_hsmd_sign_invoice */
u8 *towire_hsmd_sign_invoice(const tal_t *ctx UNNEEDED, const u8 *u5bytes UNNEEDED, const u8 *hrp UNNEEDED)
{ fprintf(stderr, "towire_hsmd_sign_invoice called!\n"); abort(); }
/* Generated stub for towire_node_id */
void towire_node_id(u8 **pptr UNNEEDED, const struct node_id *id UNNEEDED)
{ fprintf(stderr, "towire_node_id called!\n"); abort(); }

3
onchaind/Makefile

@ -76,8 +76,7 @@ ONCHAIND_COMMON_OBJS := \
common/utils.o \
common/utxo.o \
common/version.o \
common/wallet.o \
hsmd/gen_hsm_wire.o
common/wallet.o
onchaind/gen_onchain_wire.h: $(WIRE_GEN) onchaind/onchain_wire.csv
$(WIRE_GEN) --page header $@ onchain_wire_type < onchaind/onchain_wire.csv > $@

18
onchaind/onchaind.c

@ -20,7 +20,7 @@
#include <common/version.h>
#include <common/wallet.h>
#include <errno.h>
#include <hsmd/gen_hsm_wire.h>
#include <hsmd/hsmd_wiregen.h>
#include <inttypes.h>
#include <lightningd/channel_state.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,
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);
}
@ -590,7 +590,7 @@ static u8 *remote_htlc_to_us(const tal_t *ctx,
struct bitcoin_tx *tx,
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,
tx, wscript,
option_anchor_outputs);
@ -600,7 +600,7 @@ static u8 *penalty_to_us(const tal_t *ctx,
struct bitcoin_tx *tx,
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);
}
@ -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))))
status_failed(STATUS_FAIL_HSM_IO, "Writing sign request to hsm");
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,
"Reading sign_tx_reply: %s",
tal_hex(tmpctx, msg));
@ -696,7 +696,7 @@ static void hsm_sign_local_htlc_tx(struct bitcoin_tx *tx,
const u8 *wscript,
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,
option_anchor_outputs);
@ -704,7 +704,7 @@ static void hsm_sign_local_htlc_tx(struct bitcoin_tx *tx,
status_failed(STATUS_FAIL_HSM_IO,
"Writing sign_local_htlc_tx to hsm");
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,
"Reading sign_local_htlc_tx: %s",
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)
{
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;
if (!wire_sync_write(HSM_FD, take(msg)))
status_failed(STATUS_FAIL_HSM_IO, "Writing sign_htlc_tx to hsm");
msg = wire_sync_read(tmpctx, HSM_FD);
if (!msg
|| !fromwire_hsm_get_per_commitment_point_reply(tmpctx, msg,
|| !fromwire_hsmd_get_per_commitment_point_reply(tmpctx, msg,
per_commitment_point,
&unused))
status_failed(STATUS_FAIL_HSM_IO,

36
onchaind/test/run-grind_feerate-bug.c

@ -37,9 +37,9 @@ bool fromwire_bool(const u8 **cursor UNNEEDED, size_t *max UNNEEDED)
/* Generated stub for fromwire_fail */
void *fromwire_fail(const u8 **cursor UNNEEDED, size_t *max UNNEEDED)
{ fprintf(stderr, "fromwire_fail called!\n"); abort(); }
/* Generated stub for fromwire_hsm_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)
{ fprintf(stderr, "fromwire_hsm_get_per_commitment_point_reply called!\n"); abort(); }
/* Generated stub for fromwire_hsmd_get_per_commitment_point_reply */
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_hsmd_get_per_commitment_point_reply called!\n"); abort(); }
/* 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)
{ 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 */
void towire_bool(u8 **pptr UNNEEDED, bool v UNNEEDED)
{ fprintf(stderr, "towire_bool called!\n"); abort(); }
/* Generated stub for towire_hsm_get_per_commitment_point */
u8 *towire_hsm_get_per_commitment_point(const tal_t *ctx UNNEEDED, u64 n UNNEEDED)
{ fprintf(stderr, "towire_hsm_get_per_commitment_point called!\n"); abort(); }
/* Generated stub for towire_hsm_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)
{ fprintf(stderr, "towire_hsm_sign_delayed_payment_to_us called!\n"); abort(); }
/* Generated stub for towire_hsm_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)
{ fprintf(stderr, "towire_hsm_sign_penalty_to_us called!\n"); abort(); }
/* Generated stub for towire_hsm_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)
{ fprintf(stderr, "towire_hsm_sign_remote_htlc_to_us called!\n"); abort(); }
/* Generated stub for towire_hsmd_get_per_commitment_point */
u8 *towire_hsmd_get_per_commitment_point(const tal_t *ctx UNNEEDED, u64 n UNNEEDED)
{ fprintf(stderr, "towire_hsmd_get_per_commitment_point called!\n"); abort(); }
/* Generated stub for towire_hsmd_sign_delayed_payment_to_us */
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_hsmd_sign_delayed_payment_to_us called!\n"); abort(); }
/* Generated stub for towire_hsmd_sign_penalty_to_us */
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_hsmd_sign_penalty_to_us called!\n"); abort(); }
/* Generated stub for towire_hsmd_sign_remote_htlc_to_us */
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_hsmd_sign_remote_htlc_to_us called!\n"); abort(); }
/* 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)
{ 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 */
/* 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;
}
@ -309,8 +309,8 @@ bool wire_sync_write(int fd UNNEEDED, const void *msg TAKES UNNEEDED)
return true;
}
/* Generated stub for fromwire_hsm_sign_tx_reply */
bool fromwire_hsm_sign_tx_reply(const void *p UNNEEDED, struct bitcoin_signature *sig)
/* Generated stub for fromwire_hsmd_sign_tx_reply */
bool fromwire_hsmd_sign_tx_reply(const void *p UNNEEDED, struct bitcoin_signature *sig)
{
memset(sig, 0, sizeof(*sig));
return true;

42
onchaind/test/run-grind_feerate.c

@ -38,12 +38,12 @@ bool fromwire_bool(const u8 **cursor UNNEEDED, size_t *max UNNEEDED)
/* Generated stub for fromwire_fail */
void *fromwire_fail(const u8 **cursor UNNEEDED, size_t *max UNNEEDED)
{ fprintf(stderr, "fromwire_fail called!\n"); abort(); }
/* Generated stub for fromwire_hsm_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)
{ fprintf(stderr, "fromwire_hsm_get_per_commitment_point_reply called!\n"); abort(); }
/* Generated stub for fromwire_hsm_sign_tx_reply */
bool fromwire_hsm_sign_tx_reply(const void *p UNNEEDED, struct bitcoin_signature *sig UNNEEDED)
{ fprintf(stderr, "fromwire_hsm_sign_tx_reply called!\n"); abort(); }
/* Generated stub for fromwire_hsmd_get_per_commitment_point_reply */
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_hsmd_get_per_commitment_point_reply called!\n"); abort(); }
/* Generated stub for fromwire_hsmd_sign_tx_reply */
bool fromwire_hsmd_sign_tx_reply(const void *p UNNEEDED, struct bitcoin_signature *sig UNNEEDED)
{ fprintf(stderr, "fromwire_hsmd_sign_tx_reply called!\n"); abort(); }
/* 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)
{ 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 */
void towire_bool(u8 **pptr UNNEEDED, bool v UNNEEDED)
{ fprintf(stderr, "towire_bool called!\n"); abort(); }
/* Generated stub for towire_hsm_get_per_commitment_point */
u8 *towire_hsm_get_per_commitment_point(const tal_t *ctx UNNEEDED, u64 n UNNEEDED)
{ fprintf(stderr, "towire_hsm_get_per_commitment_point called!\n"); abort(); }
/* Generated stub for towire_hsm_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)
{ fprintf(stderr, "towire_hsm_sign_delayed_payment_to_us called!\n"); abort(); }
/* Generated stub for towire_hsm_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)
{ fprintf(stderr, "towire_hsm_sign_local_htlc_tx called!\n"); abort(); }
/* Generated stub for towire_hsm_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)
{ fprintf(stderr, "towire_hsm_sign_penalty_to_us called!\n"); abort(); }
/* Generated stub for towire_hsm_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)
{ fprintf(stderr, "towire_hsm_sign_remote_htlc_to_us called!\n"); abort(); }
/* Generated stub for towire_hsmd_get_per_commitment_point */
u8 *towire_hsmd_get_per_commitment_point(const tal_t *ctx UNNEEDED, u64 n UNNEEDED)
{ fprintf(stderr, "towire_hsmd_get_per_commitment_point called!\n"); abort(); }
/* Generated stub for towire_hsmd_sign_delayed_payment_to_us */
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_hsmd_sign_delayed_payment_to_us called!\n"); abort(); }
/* Generated stub for towire_hsmd_sign_local_htlc_tx */
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_hsmd_sign_local_htlc_tx called!\n"); abort(); }
/* Generated stub for towire_hsmd_sign_penalty_to_us */
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_hsmd_sign_penalty_to_us called!\n"); abort(); }
/* Generated stub for towire_hsmd_sign_remote_htlc_to_us */
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_hsmd_sign_remote_htlc_to_us called!\n"); abort(); }
/* 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)
{ fprintf(stderr, "towire_onchain_add_utxo called!\n"); abort(); }

1
openingd/Makefile

@ -83,7 +83,6 @@ OPENINGD_COMMON_OBJS := \
common/wire_error.o \
common/wireaddr.o \
gossipd/gen_gossip_peerd_wire.o \
hsmd/gen_hsm_wire.o \
lightningd/gossip_msg.o
$(LIGHTNINGD_OPENING_OBJS): $(LIGHTNINGD_HEADERS)

14
openingd/openingd.c

@ -42,7 +42,7 @@
#include <common/wire_error.h>
#include <errno.h>
#include <gossipd/gen_gossip_peerd_wire.h>
#include <hsmd/gen_hsm_wire.h>
#include <hsmd/hsmd_wiregen.h>
#include <inttypes.h>
#include <openingd/gen_opening_wire.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,
* as segwit signatures commit to that as well, even though it doesn't
* explicitly appear in the transaction itself. */
msg = towire_hsm_sign_remote_commitment_tx(NULL,
msg = towire_hsmd_sign_remote_commitment_tx(NULL,
*tx,
&state->channel->funding_pubkey[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));
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",
tal_hex(tmpctx, msg));
@ -1271,7 +1271,7 @@ static u8 *fundee_channel(struct state *state, const u8 *open_channel_msg)
}
/* Make HSM sign it */
msg = towire_hsm_sign_remote_commitment_tx(NULL,
msg = towire_hsmd_sign_remote_commitment_tx(NULL,
remote_commit,
&state->channel->funding_pubkey[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));
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", 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,
* so we might as well get the hsm daemon to generate it now. */
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);
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],
&none))
status_failed(STATUS_FAIL_HSM_IO,

6
wallet/db.c

@ -10,7 +10,7 @@
#include <common/node_id.h>
#include <common/onionreply.h>
#include <common/version.h>
#include <hsmd/gen_hsm_wire.h>
#include <hsmd/hsmd_wiregen.h>
#include <inttypes.h>
#include <lightningd/channel.h>
#include <lightningd/lightningd.h>
@ -1188,14 +1188,14 @@ void fillin_missing_scriptpubkeys(struct lightningd *ld, struct db *db,
commitment_point = NULL;
/* 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,
&peer_id,
commitment_point);
if (!wire_sync_write(ld->hsm_fd, take(msg)))
fatal("Could not write to HSM: %s", strerror(errno));
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))
fatal("HSM gave bad hsm_get_output_scriptpubkey_reply %s",
tal_hex(msg, msg));

12
wallet/test/run-db.c

@ -21,9 +21,9 @@ static void db_log_(struct log *log UNUSED, enum log_level level UNUSED, const s
/* Generated stub for fatal */
void fatal(const char *fmt UNNEEDED, ...)
{ fprintf(stderr, "fatal called!\n"); abort(); }
/* Generated stub for fromwire_hsm_get_output_scriptpubkey_reply */
bool fromwire_hsm_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(); }
/* Generated stub for fromwire_hsmd_get_output_scriptpubkey_reply */
bool fromwire_hsmd_get_output_scriptpubkey_reply(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u8 **script UNNEEDED)
{ fprintf(stderr, "fromwire_hsmd_get_output_scriptpubkey_reply called!\n"); abort(); }
/* Generated stub for get_channel_basepoints */
void get_channel_basepoints(struct lightningd *ld 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 char *fmt UNNEEDED, ...)
{ fprintf(stderr, "new_log called!\n"); abort(); }
/* Generated stub for towire_hsm_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)
{ fprintf(stderr, "towire_hsm_get_output_scriptpubkey called!\n"); abort(); }
/* Generated stub for towire_hsmd_get_output_scriptpubkey */
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_hsmd_get_output_scriptpubkey called!\n"); abort(); }
/* Generated stub for wire_sync_read */
u8 *wire_sync_read(const tal_t *ctx UNNEEDED, int fd UNNEEDED)
{ fprintf(stderr, "wire_sync_read called!\n"); abort(); }

28
wallet/test/run-wallet.c

@ -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 */
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(); }
/* Generated stub for fromwire_hsm_get_output_scriptpubkey_reply */
bool fromwire_hsm_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(); }
/* Generated stub for fromwire_hsm_sign_commitment_tx_reply */
bool fromwire_hsm_sign_commitment_tx_reply(const void *p UNNEEDED, struct bitcoin_signature *sig UNNEEDED)
{ fprintf(stderr, "fromwire_hsm_sign_commitment_tx_reply called!\n"); abort(); }
/* Generated stub for fromwire_hsmd_get_output_scriptpubkey_reply */
bool fromwire_hsmd_get_output_scriptpubkey_reply(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u8 **script UNNEEDED)
{ fprintf(stderr, "fromwire_hsmd_get_output_scriptpubkey_reply called!\n"); abort(); }
/* Generated stub for fromwire_hsmd_sign_commitment_tx_reply */
bool fromwire_hsmd_sign_commitment_tx_reply(const void *p UNNEEDED, struct bitcoin_signature *sig UNNEEDED)
{ fprintf(stderr, "fromwire_hsmd_sign_commitment_tx_reply called!\n"); abort(); }
/* Generated stub for fromwire_onchain_dev_memleak_reply */
bool fromwire_onchain_dev_memleak_reply(const void *p UNNEEDED, bool *leak UNNEEDED)
{ 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 */
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(); }
/* Generated stub for towire_hsm_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)
{ fprintf(stderr, "towire_hsm_get_output_scriptpubkey called!\n"); abort(); }
/* Generated stub for towire_hsm_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)
{ fprintf(stderr, "towire_hsm_sign_commitment_tx called!\n"); abort(); }
/* Generated stub for towire_hsmd_get_output_scriptpubkey */
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_hsmd_get_output_scriptpubkey called!\n"); abort(); }
/* Generated stub for towire_hsmd_sign_commitment_tx */
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_hsmd_sign_commitment_tx called!\n"); abort(); }
/* 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)
{ fprintf(stderr, "towire_incorrect_cltv_expiry called!\n"); abort(); }
@ -782,7 +782,7 @@ bool dev_disconnect_permanent(struct lightningd *ld UNNEEDED)
#endif
/* 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;
}
@ -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)
{
}
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 pubkey *funding_pubkey)
{

10
wallet/walletrpc.c

@ -18,7 +18,7 @@
#include <common/wallet_tx.h>
#include <common/withdraw_tx.h>
#include <errno.h>
#include <hsmd/gen_hsm_wire.h>
#include <hsmd/hsmd_wiregen.h>
#include <inttypes.h>
#include <lightningd/bitcoind.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
* 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)))
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);
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",
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
* 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),
psbt);
@ -1343,7 +1343,7 @@ static struct command_result *json_signpsbt(struct command *cmd,
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",
tal_hex(tmpctx, msg));

Loading…
Cancel
Save