Skip to content

Commit b12e6bf

Browse files
committed
Added sign-local-htlc-tx.
1 parent e847eca commit b12e6bf

File tree

4 files changed

+4
-46
lines changed

4 files changed

+4
-46
lines changed

contrib/remote_hsmd/NOTES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ Some popular tests:
4141
export THETEST=tests/test_connection.py::test_balance
4242
export THETEST=tests/test_pay.py::test_sendpay
4343
export THETEST=tests/test_pay.py::test_pay
44-
44+
export THETEST=tests/test_closing.py::test_onchain_different_fees
4545

4646
Tests remote_commitment:
4747

contrib/remote_hsmd/TODO.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ COMPLETE proxy_stat proxy_handle_sign_remote_htlc_tx
1919
COMPLETE proxy_stat proxy_handle_sign_invoice
2020
COMPLETE proxy_stat proxy_handle_get_channel_basepoints
2121
COMPLETE proxy_stat proxy_handle_get_per_commitment_point
22+
COMPLETE proxy_stat proxy_handle_sign_local_htlc_tx
2223

2324
PARTIAL (-P2SH) proxy_stat proxy_handle_sign_withdrawal_tx
2425

@@ -27,7 +28,6 @@ MARSHALED proxy_stat proxy_handle_sign_message
2728
MARSHALED proxy_stat proxy_handle_sign_mutual_close_tx
2829
MARSHALED proxy_stat proxy_handle_sign_commitment_tx
2930
MARSHALED proxy_stat proxy_handle_cannouncement_sig
30-
MARSHALED proxy_stat proxy_handle_sign_local_htlc_tx
3131
MARSHALED proxy_stat proxy_handle_sign_delayed_payment_to_us
3232
MARSHALED proxy_stat proxy_handle_sign_remote_htlc_to_us
3333
MARSHALED proxy_stat proxy_handle_sign_penalty_to_us

contrib/remote_hsmd/hsmd.c

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1423,46 +1423,16 @@ static struct io_plan *handle_sign_local_htlc_tx(struct io_conn *conn,
14231423
{
14241424
u64 commit_num;
14251425
struct amount_sat input_sat;
1426-
struct secret channel_seed, htlc_basepoint_secret;
1427-
struct sha256 shaseed;
1428-
struct pubkey per_commitment_point, htlc_basepoint;
14291426
struct bitcoin_tx *tx;
14301427
u8 *wscript;
14311428
struct bitcoin_signature sig;
1432-
struct privkey htlc_privkey;
1433-
struct pubkey htlc_pubkey;
14341429

14351430
if (!fromwire_hsm_sign_local_htlc_tx(tmpctx, msg_in,
14361431
&commit_num, &tx, &wscript,
14371432
&input_sat))
14381433
return bad_req(conn, c, msg_in);
14391434

14401435
tx->chainparams = c->chainparams;
1441-
get_channel_seed(&c->id, c->dbid, &channel_seed);
1442-
1443-
if (!derive_shaseed(&channel_seed, &shaseed))
1444-
return bad_req_fmt(conn, c, msg_in, "bad derive_shaseed");
1445-
1446-
if (!per_commit_point(&shaseed, &per_commitment_point, commit_num))
1447-
return bad_req_fmt(conn, c, msg_in,
1448-
"bad per_commitment_point %"PRIu64,
1449-
commit_num);
1450-
1451-
if (!derive_htlc_basepoint(&channel_seed,
1452-
&htlc_basepoint,
1453-
&htlc_basepoint_secret))
1454-
return bad_req_fmt(conn, c, msg_in,
1455-
"Failed deriving htlc basepoint");
1456-
1457-
if (!derive_simple_privkey(&htlc_basepoint_secret,
1458-
&htlc_basepoint,
1459-
&per_commitment_point,
1460-
&htlc_privkey))
1461-
return bad_req_fmt(conn, c, msg_in,
1462-
"Failed deriving htlc privkey");
1463-
1464-
if (!pubkey_from_privkey(&htlc_privkey, &htlc_pubkey))
1465-
return bad_req_fmt(conn, c, msg_in, "bad pubkey_from_privkey");
14661436

14671437
if (tx->wtx->num_inputs != 1)
14681438
return bad_req_fmt(conn, c, msg_in, "bad txinput count");
@@ -1478,13 +1448,7 @@ static struct io_plan *handle_sign_local_htlc_tx(struct io_conn *conn,
14781448
return bad_req_fmt(conn, c, msg_in,
14791449
"proxy_%s error: %s", __FUNCTION__,
14801450
proxy_last_message());
1481-
g_proxy_impl = PROXY_IMPL_MARSHALED;
1482-
1483-
/* FIXME - REPLACE BELOW W/ REMOTE RETURN */
1484-
1485-
/* FIXME: Check that output script is correct! */
1486-
sign_tx_input(tx, 0, NULL, wscript, &htlc_privkey, &htlc_pubkey,
1487-
SIGHASH_ALL, &sig);
1451+
g_proxy_impl = PROXY_IMPL_COMPLETE;
14881452

14891453
return req_reply(conn, c, take(towire_hsm_sign_tx_reply(NULL, &sig)));
14901454
}

contrib/remote_hsmd/proxy.cc

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -954,13 +954,7 @@ proxy_stat proxy_handle_sign_local_htlc_tx(
954954
SignatureReply rsp;
955955
Status status = stub->SignLocalHTLCTx(&context, req, &rsp);
956956
if (status.ok()) {
957-
#if 1
958-
/* For now just make valgrind happy */
959-
memset(o_sig->s.data, '\0', sizeof(o_sig->s.data));
960-
#else
961-
assert(rsp.sig().length() == sizeof(o_sig->s.data));
962-
memcpy(o_sig->s.data, rsp.sig().data(), sizeof(o_sig->s.data));
963-
#endif
957+
unmarshal_bitcoin_signature(rsp.signature(), o_sig);
964958
status_debug("%s:%d %s self_id=%s sig=%s",
965959
__FILE__, __LINE__, __FUNCTION__,
966960
dump_node_id(&self_id).c_str(),

0 commit comments

Comments
 (0)