hsmd: rename "capabilities" flags for hsm fds to "permissions"

I obviously like the word "capabilities" since I reused it to refer
to the HSM's overall features :(

Suggested-by: @ksedgwic
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2023-08-07 15:21:40 +09:30
parent 32b88a2340
commit d95cfc0b64
16 changed files with 64 additions and 63 deletions

View File

@@ -13,7 +13,7 @@
#include <connectd/connectd_wiregen.h>
#include <errno.h>
#include <fcntl.h>
#include <hsmd/capabilities.h>
#include <hsmd/permissions.h>
#include <lightningd/chaintopology.h>
#include <lightningd/channel.h>
#include <lightningd/channel_control.h>
@@ -1264,12 +1264,12 @@ bool peer_start_channeld(struct channel *channel,
hsmfd = hsm_get_client_fd(ld, &channel->peer->id,
channel->dbid,
HSM_CAP_SIGN_GOSSIP
| HSM_CAP_ECDH
| HSM_CAP_COMMITMENT_POINT
| HSM_CAP_SIGN_REMOTE_TX
| HSM_CAP_SIGN_ONCHAIN_TX
| HSM_CAP_SIGN_CLOSING_TX);
HSM_PERM_SIGN_GOSSIP
| HSM_PERM_ECDH
| HSM_PERM_COMMITMENT_POINT
| HSM_PERM_SIGN_REMOTE_TX
| HSM_PERM_SIGN_ONCHAIN_TX
| HSM_PERM_SIGN_CLOSING_TX);
channel_set_owner(channel,
new_channel_subd(channel, ld,

View File

@@ -20,7 +20,7 @@
#include <connectd/connectd_wiregen.h>
#include <errno.h>
#include <gossipd/gossipd_wiregen.h>
#include <hsmd/capabilities.h>
#include <hsmd/permissions.h>
#include <inttypes.h>
#include <lightningd/bitcoind.h>
#include <lightningd/chaintopology.h>
@@ -379,8 +379,8 @@ void peer_start_closingd(struct channel *channel, struct peer_fd *peer_fd)
}
hsmfd = hsm_get_client_fd(ld, &channel->peer->id, channel->dbid,
HSM_CAP_SIGN_CLOSING_TX
| HSM_CAP_COMMITMENT_POINT);
HSM_PERM_SIGN_CLOSING_TX
| HSM_PERM_COMMITMENT_POINT);
channel_set_owner(channel,
new_channel_subd(channel, ld,

View File

@@ -10,7 +10,7 @@
#include <common/type_to_string.h>
#include <connectd/connectd_wiregen.h>
#include <gossipd/gossipd_wiregen.h>
#include <hsmd/capabilities.h>
#include <hsmd/permissions.h>
#include <lightningd/channel.h>
#include <lightningd/connect_control.h>
#include <lightningd/dual_open_control.h>
@@ -661,7 +661,7 @@ int connectd_init(struct lightningd *ld)
if (socketpair(AF_LOCAL, SOCK_STREAM, 0, fds) != 0)
fatal("Could not socketpair for connectd<->gossipd");
hsmfd = hsm_get_global_fd(ld, HSM_CAP_ECDH);
hsmfd = hsm_get_global_fd(ld, HSM_PERM_ECDH);
ld->connectd = new_global_subd(ld, "lightning_connectd",
connectd_wire_name, connectd_msg,

View File

@@ -17,7 +17,7 @@
#include <common/wire_error.h>
#include <connectd/connectd_wiregen.h>
#include <errno.h>
#include <hsmd/capabilities.h>
#include <hsmd/permissions.h>
#include <lightningd/chaintopology.h>
#include <lightningd/channel.h>
#include <lightningd/channel_control.h>
@@ -3695,9 +3695,9 @@ bool peer_start_dualopend(struct peer *peer,
const u8 *msg;
hsmfd = hsm_get_client_fd(peer->ld, &peer->id, channel->unsaved_dbid,
HSM_CAP_COMMITMENT_POINT
| HSM_CAP_SIGN_REMOTE_TX
| HSM_CAP_SIGN_WILL_FUND_OFFER);
HSM_PERM_COMMITMENT_POINT
| HSM_PERM_SIGN_REMOTE_TX
| HSM_PERM_SIGN_WILL_FUND_OFFER);
channel->owner = new_channel_subd(channel,
peer->ld,
@@ -3767,9 +3767,9 @@ bool peer_restart_dualopend(struct peer *peer,
return peer_start_dualopend(peer, peer_fd, channel);
hsmfd = hsm_get_client_fd(peer->ld, &peer->id, channel->dbid,
HSM_CAP_COMMITMENT_POINT
| HSM_CAP_SIGN_REMOTE_TX
| HSM_CAP_SIGN_WILL_FUND_OFFER);
HSM_PERM_COMMITMENT_POINT
| HSM_PERM_SIGN_REMOTE_TX
| HSM_PERM_SIGN_WILL_FUND_OFFER);
channel_set_owner(channel,
new_channel_subd(channel, peer->ld,

View File

@@ -7,7 +7,7 @@
#include <common/json_stream.h>
#include <common/type_to_string.h>
#include <gossipd/gossipd_wiregen.h>
#include <hsmd/capabilities.h>
#include <hsmd/permissions.h>
#include <lightningd/bitcoind.h>
#include <lightningd/chaintopology.h>
#include <lightningd/channel.h>
@@ -270,7 +270,7 @@ void gossip_init(struct lightningd *ld, int connectd_fd)
int hsmfd;
void *ret;
hsmfd = hsm_get_global_fd(ld, HSM_CAP_ECDH|HSM_CAP_SIGN_GOSSIP);
hsmfd = hsm_get_global_fd(ld, HSM_PERM_ECDH|HSM_PERM_SIGN_GOSSIP);
ld->gossip = new_global_subd(ld, "lightning_gossipd",
gossipd_wire_name, gossip_msg,

View File

@@ -24,12 +24,12 @@
static int hsm_get_fd(struct lightningd *ld,
const struct node_id *id,
u64 dbid,
int capabilities)
u64 permissions)
{
int hsm_fd;
const u8 *msg;
msg = towire_hsmd_client_hsmfd(NULL, id, dbid, capabilities);
msg = towire_hsmd_client_hsmfd(NULL, id, dbid, permissions);
msg = hsm_sync_req(tmpctx, ld, take(msg));
if (!fromwire_hsmd_client_hsmfd_reply(msg))
fatal("Bad reply from HSM: %s", tal_hex(tmpctx, msg));
@@ -43,16 +43,16 @@ static int hsm_get_fd(struct lightningd *ld,
int hsm_get_client_fd(struct lightningd *ld,
const struct node_id *id,
u64 dbid,
int capabilities)
u64 permissions)
{
assert(dbid);
return hsm_get_fd(ld, id, dbid, capabilities);
return hsm_get_fd(ld, id, dbid, permissions);
}
int hsm_get_global_fd(struct lightningd *ld, int capabilities)
int hsm_get_global_fd(struct lightningd *ld, u64 permissions)
{
return hsm_get_fd(ld, &ld->id, 0, capabilities);
return hsm_get_fd(ld, &ld->id, 0, permissions);
}
static unsigned int hsm_msg(struct subd *hsmd,

View File

@@ -11,10 +11,10 @@ struct ext_key;
int hsm_get_client_fd(struct lightningd *ld,
const struct node_id *id,
u64 dbid,
int capabilities);
u64 permissions);
/* Ask HSM for an fd for a global subdaemon to use (gossipd, connectd) */
int hsm_get_global_fd(struct lightningd *ld, int capabilities);
int hsm_get_global_fd(struct lightningd *ld, u64 permissions);
/* Is this capability supported by the HSM? (So far, always a message
* number) */

View File

@@ -9,8 +9,8 @@
#include <common/type_to_string.h>
#include <db/exec.h>
#include <errno.h>
#include <hsmd/capabilities.h>
#include <hsmd/hsmd_wiregen.h>
#include <hsmd/permissions.h>
#include <inttypes.h>
#include <lightningd/chaintopology.h>
#include <lightningd/channel.h>
@@ -1553,8 +1553,8 @@ enum watch_result onchaind_funding_spent(struct channel *channel,
hsmfd = hsm_get_client_fd(ld, &channel->peer->id,
channel->dbid,
HSM_CAP_SIGN_ONCHAIN_TX
| HSM_CAP_COMMITMENT_POINT);
HSM_PERM_SIGN_ONCHAIN_TX
| HSM_PERM_COMMITMENT_POINT);
channel_set_owner(channel, new_channel_subd(channel, ld,
"lightning_onchaind",

View File

@@ -15,7 +15,7 @@
#include <common/type_to_string.h>
#include <connectd/connectd_wiregen.h>
#include <errno.h>
#include <hsmd/capabilities.h>
#include <hsmd/permissions.h>
#include <lightningd/chaintopology.h>
#include <lightningd/channel.h>
#include <lightningd/channel_control.h>
@@ -933,8 +933,8 @@ bool peer_start_openingd(struct peer *peer, struct peer_fd *peer_fd)
assert(!uc->open_daemon);
hsmfd = hsm_get_client_fd(peer->ld, &uc->peer->id, uc->dbid,
HSM_CAP_COMMITMENT_POINT
| HSM_CAP_SIGN_REMOTE_TX);
HSM_PERM_COMMITMENT_POINT
| HSM_PERM_SIGN_REMOTE_TX);
uc->open_daemon = new_channel_subd(peer, peer->ld,
"lightning_openingd",