Skip to content

Commit 451b2c2

Browse files
committed
Added get-channel-basepoints.
1 parent df5fd66 commit 451b2c2

File tree

3 files changed

+9
-47
lines changed

3 files changed

+9
-47
lines changed

contrib/remote_hsmd/TODO.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ COMPLETE proxy_stat proxy_handle_channel_update_sig
1717
COMPLETE proxy_stat proxy_handle_sign_node_announcement
1818
COMPLETE proxy_stat proxy_handle_sign_remote_htlc_tx
1919
COMPLETE proxy_stat proxy_handle_sign_invoice
20+
COMPLETE proxy_stat proxy_handle_get_channel_basepoints
2021

2122
PARTIAL (-P2SH) proxy_stat proxy_handle_sign_withdrawal_tx
2223

2324
MARSHALED proxy_stat proxy_init_hsm
2425
MARSHALED proxy_stat proxy_handle_get_per_commitment_point
2526
MARSHALED proxy_stat proxy_handle_sign_message
26-
MARSHALED proxy_stat proxy_handle_get_channel_basepoints
2727
MARSHALED proxy_stat proxy_handle_sign_mutual_close_tx
2828
MARSHALED proxy_stat proxy_handle_sign_commitment_tx
2929
MARSHALED proxy_stat proxy_handle_cannouncement_sig

contrib/remote_hsmd/hsmd.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -963,7 +963,6 @@ static struct io_plan *handle_get_channel_basepoints(struct io_conn *conn,
963963
{
964964
struct node_id peer_id;
965965
u64 dbid;
966-
struct secret seed;
967966
struct basepoints basepoints;
968967
struct pubkey funding_pubkey;
969968

@@ -980,12 +979,7 @@ static struct io_plan *handle_get_channel_basepoints(struct io_conn *conn,
980979
return bad_req_fmt(conn, c, msg_in,
981980
"proxy_%s error: %s", __FUNCTION__,
982981
proxy_last_message());
983-
g_proxy_impl = PROXY_IMPL_MARSHALED;
984-
985-
/* FIXME - REPLACE BELOW W/ REMOTE RETURN */
986-
987-
get_channel_seed(&peer_id, dbid, &seed);
988-
derive_basepoints(&seed, &funding_pubkey, &basepoints, NULL, NULL);
982+
g_proxy_impl = PROXY_IMPL_COMPLETE;
989983

990984
return req_reply(conn, c,
991985
take(towire_hsm_get_channel_basepoints_reply(NULL,

contrib/remote_hsmd/proxy.cc

Lines changed: 7 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -249,13 +249,6 @@ void unmarshal_witnesses(RepeatedPtrField<WitnessStack> const &wits,
249249
*o_sigs = osigs;
250250
}
251251

252-
bool return_pubkey(const string &i_pubkey, struct pubkey *o_pubkey)
253-
{
254-
/* pubkey needs to be compressed DER */
255-
return pubkey_from_der(
256-
(const u8*)i_pubkey.c_str(), i_pubkey.length(), o_pubkey);
257-
}
258-
259252
/* Copied from ccan/mem/mem.h which the c++ compiler doesn't like */
260253
static inline bool memeq(const void *a, size_t al, const void *b, size_t bl)
261254
{
@@ -740,38 +733,13 @@ proxy_stat proxy_handle_get_channel_basepoints(
740733
GetChannelBasepointsReply rsp;
741734
Status status = stub->GetChannelBasepoints(&context, req, &rsp);
742735
if (status.ok()) {
743-
/* FIXME - Uncomment these when real value returned */
744-
#if 1
745-
/* For now just make valgrind happy */
746-
memset(o_basepoints, '\0', sizeof(*o_basepoints));
747-
memset(o_funding_pubkey, '\0', sizeof(*o_funding_pubkey));
748-
#else
749-
if (!return_pubkey(rsp.basepoints().revocation(),
750-
&o_basepoints->revocation)) {
751-
last_message = "bad returned revocation basepoint";
752-
return PROXY_INTERNAL_ERROR;
753-
}
754-
if (!return_pubkey(rsp.basepoints().payment(),
755-
&o_basepoints->payment)) {
756-
last_message = "bad returned payment basepoint";
757-
return PROXY_INTERNAL_ERROR;
758-
}
759-
if (!return_pubkey(rsp.basepoints().htlc(),
760-
&o_basepoints->htlc)) {
761-
last_message = "bad returned htlc basepoint";
762-
return PROXY_INTERNAL_ERROR;
763-
}
764-
if (!return_pubkey(rsp.basepoints().delayed_payment(),
765-
&o_basepoints->delayed_payment)) {
766-
last_message = "bad returned delayed_payment basepoint";
767-
return PROXY_INTERNAL_ERROR;
768-
}
769-
if (!return_pubkey(rsp.remote_funding_pubkey(),
770-
o_funding_pubkey)) {
771-
last_message = "bad returned funding pubkey";
772-
return PROXY_INTERNAL_ERROR;
773-
}
774-
#endif
736+
Basepoints const & bps = rsp.basepoints();
737+
unmarshal_pubkey(bps.revocation(), &o_basepoints->revocation);
738+
unmarshal_pubkey(bps.payment(), &o_basepoints->payment);
739+
unmarshal_pubkey(bps.htlc(), &o_basepoints->htlc);
740+
unmarshal_pubkey(bps.delayed_payment(),
741+
&o_basepoints->delayed_payment);
742+
unmarshal_pubkey(bps.funding_pubkey(), o_funding_pubkey);
775743
status_debug("%s:%d %s self_id=%s",
776744
__FILE__, __LINE__, __FUNCTION__,
777745
dump_node_id(&self_id).c_str(),

0 commit comments

Comments
 (0)