hsmd: provide message for master to get basepoints & funding pubkey for a channel

This is only used by the master daemon, but it's not secret information.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2018-07-23 11:53:03 +09:30 committed by Christian Decker
parent 429aad8ac7
commit 9bf238e001
3 changed files with 38 additions and 0 deletions

View File

@ -49,6 +49,7 @@ GOSSIPD_COMMON_OBJS := \
common/daemon.o \
common/daemon_conn.o \
common/decode_short_channel_ids.o \
common/derive_basepoints.o \
common/dev_disconnect.o \
common/features.o \
common/gen_status_wire.o \

View File

@ -278,6 +278,28 @@ static struct io_plan *handle_channel_update_sig(struct io_conn *conn,
return daemon_conn_read_next(conn, dc);
}
static struct io_plan *handle_get_channel_basepoints(struct io_conn *conn,
struct daemon_conn *dc)
{
struct pubkey peer_id;
u64 dbid;
struct secret seed;
struct basepoints basepoints;
struct pubkey funding_pubkey;
if (!fromwire_hsm_get_channel_basepoints(dc->msg_in, &peer_id, &dbid))
master_badmsg(WIRE_HSM_GET_CHANNEL_BASEPOINTS, dc->msg_in);
get_channel_seed(&peer_id, dbid, &seed);
derive_basepoints(&seed, &funding_pubkey, &basepoints, NULL, NULL);
daemon_conn_send(dc,
take(towire_hsm_get_channel_basepoints_reply(NULL,
&basepoints,
&funding_pubkey)));
return daemon_conn_read_next(conn, dc);
}
/* FIXME: Ensure HSM never does this twice for same dbid! */
static struct io_plan *handle_sign_commitment_tx(struct io_conn *conn,
struct daemon_conn *dc)
@ -766,6 +788,7 @@ static bool check_client_capabilities(struct client *client,
case WIRE_HSM_SIGN_WITHDRAWAL:
case WIRE_HSM_SIGN_INVOICE:
case WIRE_HSM_SIGN_COMMITMENT_TX:
case WIRE_HSM_GET_CHANNEL_BASEPOINTS:
return (client->capabilities & HSM_CAP_MASTER) != 0;
/* These are messages sent by the HSM so we should never receive them */
@ -782,6 +805,7 @@ static bool check_client_capabilities(struct client *client,
case WIRE_HSM_SIGN_COMMITMENT_TX_REPLY:
case WIRE_HSM_SIGN_TX_REPLY:
case WIRE_HSM_GET_PER_COMMITMENT_POINT_REPLY:
case WIRE_HSM_GET_CHANNEL_BASEPOINTS_REPLY:
break;
}
return false;
@ -815,6 +839,9 @@ static struct io_plan *handle_client(struct io_conn *conn,
pass_client_hsmfd(dc, dc->msg_in);
return daemon_conn_read_next(conn, dc);
case WIRE_HSM_GET_CHANNEL_BASEPOINTS:
return handle_get_channel_basepoints(conn, dc);
case WIRE_HSM_ECDH_REQ:
return handle_ecdh(conn, dc);
@ -880,6 +907,7 @@ static struct io_plan *handle_client(struct io_conn *conn,
case WIRE_HSM_SIGN_COMMITMENT_TX_REPLY:
case WIRE_HSM_SIGN_TX_REPLY:
case WIRE_HSM_GET_PER_COMMITMENT_POINT_REPLY:
case WIRE_HSM_GET_CHANNEL_BASEPOINTS_REPLY:
break;
}

View File

@ -23,6 +23,15 @@ hsm_client_hsmfd,,capabilities,u64
# No content, just an fd.
hsm_client_hsmfd_reply,109
#include <common/derive_basepoints.h>
# Get the basepoints and funding key for this specific channel.
hsm_get_channel_basepoints,10
hsm_get_channel_basepoints,,peerid,struct pubkey
hsm_get_channel_basepoints,,dbid,u64
hsm_get_channel_basepoints_reply,110
hsm_get_channel_basepoints_reply,,basepoints,struct basepoints
hsm_get_channel_basepoints_reply,,funding_pubkey,struct pubkey
# Return signature for a funding tx.
#include <common/utxo.h>