Skip to content

Commit e2a0639

Browse files
committed
Added sign-penalty-to-us.
1 parent 30fdaa4 commit e2a0639

File tree

4 files changed

+13
-66
lines changed

4 files changed

+13
-66
lines changed

contrib/remote_hsmd/NOTES.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,13 @@ Some popular tests:
4545
export THETEST=tests/test_closing.py::test_onchain_feechange
4646
export THETEST=tests/test_closing.py::test_onchain_all_dust
4747
export THETEST=tests/test_closing.py::test_permfail_new_commit
48-
export THETEST=tests/test_closing.py::test_onchain_multihtlc_our_unilateral
49-
export THETEST=tests/test_closing.py::test_onchain_multihtlc_their_unilateral
50-
export THETEST=tests/test_closing.py::test_permfail_htlc_in
51-
export THETEST=tests/test_closing.py::test_permfail_htlc_out
48+
export THETEST=tests/test_closing.py::test_onchain_multihtlc_our_unilateral
49+
export THETEST=tests/test_closing.py::test_onchain_multihtlc_their_unilateral
50+
export THETEST=tests/test_closing.py::test_permfail_htlc_in
51+
export THETEST=tests/test_closing.py::test_permfail_htlc_out
52+
export THETEST=tests/test_closing.py::test_penalty_inhtlc
53+
export THETEST=tests/test_closing.py::test_penalty_outhtlc
54+
5255

5356
Tests remote_commitment:
5457

contrib/remote_hsmd/TODO.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ tests/test_misc.py::test_bad_onion_immediate_peer
1010

1111
## Proxy Scoreboard
1212

13+
```
1314
COMPLETE proxy_stat proxy_handle_ecdh
1415
COMPLETE proxy_stat proxy_handle_pass_client_hsmfd
1516
COMPLETE proxy_stat proxy_handle_sign_remote_commitment_tx
@@ -22,6 +23,7 @@ COMPLETE proxy_stat proxy_handle_get_per_commitment_point
2223
COMPLETE proxy_stat proxy_handle_sign_local_htlc_tx
2324
COMPLETE proxy_stat proxy_handle_sign_remote_htlc_to_us
2425
COMPLETE proxy_stat proxy_handle_sign_delayed_payment_to_us
26+
COMPLETE proxy_stat proxy_handle_sign_penalty_to_us
2527
2628
PARTIAL (-P2SH) proxy_stat proxy_handle_sign_withdrawal_tx
2729
@@ -30,9 +32,8 @@ MARSHALED proxy_stat proxy_handle_sign_message
3032
MARSHALED proxy_stat proxy_handle_sign_mutual_close_tx
3133
MARSHALED proxy_stat proxy_handle_sign_commitment_tx
3234
MARSHALED proxy_stat proxy_handle_cannouncement_sig
33-
MARSHALED proxy_stat proxy_handle_sign_penalty_to_us
3435
MARSHALED proxy_stat proxy_handle_check_future_secret
35-
36+
```
3637

3738
Improvements
3839
----------------------------------------------------------------

contrib/remote_hsmd/hsmd.c

Lines changed: 3 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1179,34 +1179,6 @@ static struct io_plan *handle_sign_remote_htlc_tx(struct io_conn *conn,
11791179
return req_reply(conn, c, take(towire_hsm_sign_tx_reply(NULL, &sig)));
11801180
}
11811181

1182-
// TODO - This goes away when we complete all callers.
1183-
//
1184-
/*~ This covers several cases where onchaind is creating a transaction which
1185-
* sends funds to our internal wallet. */
1186-
/* FIXME: Derive output address for this client, and check it here! */
1187-
static struct io_plan *handle_sign_to_us_tx(struct io_conn *conn,
1188-
struct client *c,
1189-
const u8 *msg_in,
1190-
struct bitcoin_tx *tx,
1191-
const struct privkey *privkey,
1192-
const u8 *wscript,
1193-
struct amount_sat input_sat)
1194-
{
1195-
struct bitcoin_signature sig;
1196-
struct pubkey pubkey;
1197-
1198-
if (!pubkey_from_privkey(privkey, &pubkey))
1199-
return bad_req_fmt(conn, c, msg_in, "bad pubkey_from_privkey");
1200-
1201-
if (tx->wtx->num_inputs != 1)
1202-
return bad_req_fmt(conn, c, msg_in, "bad txinput count");
1203-
1204-
tx->input_amounts[0] = tal_dup(tx, struct amount_sat, &input_sat);
1205-
sign_tx_input(tx, 0, NULL, wscript, privkey, &pubkey, SIGHASH_ALL, &sig);
1206-
1207-
return req_reply(conn, c, take(towire_hsm_sign_tx_reply(NULL, &sig)));
1208-
}
1209-
12101182
/*~ When we send a commitment transaction onchain (unilateral close), there's
12111183
* a delay before we can spend it. onchaind does an explicit transaction to
12121184
* transfer it to the wallet so that doesn't need to remember how to spend
@@ -1302,11 +1274,8 @@ static struct io_plan *handle_sign_penalty_to_us(struct io_conn *conn,
13021274
const u8 *msg_in)
13031275
{
13041276
struct amount_sat input_sat;
1305-
struct secret channel_seed, revocation_secret, revocation_basepoint_secret;
1306-
struct pubkey revocation_basepoint;
1277+
struct secret revocation_secret;
13071278
struct bitcoin_tx *tx;
1308-
struct pubkey point;
1309-
struct privkey privkey;
13101279
u8 *wscript;
13111280

13121281
if (!fromwire_hsm_sign_penalty_to_us(tmpctx, msg_in,
@@ -1332,30 +1301,9 @@ static struct io_plan *handle_sign_penalty_to_us(struct io_conn *conn,
13321301
return bad_req_fmt(conn, c, msg_in,
13331302
"proxy_%s error: %s", __FUNCTION__,
13341303
proxy_last_message());
1335-
g_proxy_impl = PROXY_IMPL_MARSHALED;
1336-
1337-
/* FIXME - REPLACE BELOW W/ REMOTE RETURN */
1338-
1339-
if (!pubkey_from_secret(&revocation_secret, &point))
1340-
return bad_req_fmt(conn, c, msg_in, "Failed deriving pubkey");
1341-
1342-
get_channel_seed(&c->id, c->dbid, &channel_seed);
1343-
if (!derive_revocation_basepoint(&channel_seed,
1344-
&revocation_basepoint,
1345-
&revocation_basepoint_secret))
1346-
return bad_req_fmt(conn, c, msg_in,
1347-
"Failed deriving revocation basepoint");
1348-
1349-
if (!derive_revocation_privkey(&revocation_basepoint_secret,
1350-
&revocation_secret,
1351-
&revocation_basepoint,
1352-
&point,
1353-
&privkey))
1354-
return bad_req_fmt(conn, c, msg_in,
1355-
"Failed deriving revocation privkey");
1304+
g_proxy_impl = PROXY_IMPL_COMPLETE;
13561305

1357-
return handle_sign_to_us_tx(conn, c, msg_in,
1358-
tx, &privkey, wscript, input_sat);
1306+
return req_reply(conn, c, take(towire_hsm_sign_tx_reply(NULL, &sig)));
13591307
}
13601308

13611309
/*~ This is used when a commitment transaction is onchain, and has an HTLC

contrib/remote_hsmd/proxy.cc

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,12 +1152,7 @@ proxy_stat proxy_handle_sign_penalty_to_us(
11521152
SignatureReply rsp;
11531153
Status status = stub->SignPenaltyToUs(&context, req, &rsp);
11541154
if (status.ok()) {
1155-
// FIXME - UNCOMMENT WHEN SERVER IMPLEMENTS:
1156-
#if 0
11571155
unmarshal_bitcoin_signature(rsp.signature(), o_sig);
1158-
#else
1159-
memset(o_sig, '\0', sizeof(*o_sig));
1160-
#endif
11611156
status_debug("%s:%d %s self_id=%s sig=%s",
11621157
__FILE__, __LINE__, __FUNCTION__,
11631158
dump_node_id(&self_id).c_str(),

0 commit comments

Comments
 (0)