Skip to content

Commit 48ed900

Browse files
committed
adds payment_hashes and commit_num to sign_holder_commitment_tx (#26)
1 parent 66794d0 commit 48ed900

File tree

8 files changed

+39
-16
lines changed

8 files changed

+39
-16
lines changed

contrib/remote_hsmd/hsmd.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -752,11 +752,14 @@ static struct io_plan *handle_sign_commitment_tx(struct io_conn *conn,
752752
u64 dbid;
753753
struct bitcoin_tx *tx;
754754
struct bitcoin_signature sig;
755+
struct sha256 *rhashes;
756+
u64 commit_num;
755757

756758
if (!fromwire_hsmd_sign_commitment_tx(tmpctx, msg_in,
757759
&peer_id, &dbid,
758760
&tx,
759-
&remote_funding_pubkey))
761+
&remote_funding_pubkey,
762+
&rhashes, &commit_num))
760763
return bad_req(conn, c, msg_in);
761764

762765
tx->chainparams = c->chainparams;
@@ -768,7 +771,8 @@ static struct io_plan *handle_sign_commitment_tx(struct io_conn *conn,
768771
return bad_req_fmt(conn, c, msg_in, "tx must have > 0 outputs");
769772

770773
proxy_stat rv = proxy_handle_sign_commitment_tx(
771-
tx, &remote_funding_pubkey, &peer_id, dbid, &sig);
774+
tx, &remote_funding_pubkey, &peer_id, dbid,
775+
rhashes, commit_num, &sig);
772776
if (PROXY_PERMANENT(rv))
773777
status_failed(STATUS_FAIL_INTERNAL_ERROR,
774778
"proxy_%s failed: %s", __FUNCTION__,
@@ -821,7 +825,6 @@ static struct io_plan *handle_sign_remote_commitment_tx(struct io_conn *conn,
821825
tx, &remote_funding_pubkey,
822826
&c->id, c->dbid,
823827
&remote_per_commit,
824-
option_static_remotekey,
825828
rhashes, commit_num,
826829
&sig);
827830
if (PROXY_PERMANENT(rv))

contrib/remote_hsmd/proxy.cc

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -691,24 +691,21 @@ proxy_stat proxy_handle_sign_remote_commitment_tx(
691691
struct node_id *peer_id,
692692
u64 dbid,
693693
const struct pubkey *remote_per_commit,
694-
bool option_static_remotekey,
695694
struct sha256 *rhashes, u64 commit_num,
696695
struct bitcoin_signature *o_sig)
697696
{
698697
STATUS_DEBUG(
699698
"%s:%d %s { "
700699
"\"self_id\":%s, \"peer_id\":%s, \"dbid\":%" PRIu64 ", "
701700
"\"counterparty_funding_pubkey\":%s, "
702-
"\"remote_per_commit\":%s, "
703-
"\"option_static_remotekey\":%s, \"tx\":%s, "
701+
"\"remote_per_commit\":%s, \"tx\":%s, "
704702
"\"rhashes\":%s, \"commit_num\":%" PRIu64 " }",
705703
__FILE__, __LINE__, __FUNCTION__,
706704
dump_node_id(&self_id).c_str(),
707705
dump_node_id(peer_id).c_str(),
708706
dbid,
709707
dump_pubkey(counterparty_funding_pubkey).c_str(),
710708
dump_pubkey(remote_per_commit).c_str(),
711-
(option_static_remotekey ? "true" : "false"),
712709
dump_tx(tx).c_str(),
713710
dump_rhashes(rhashes, tal_count(rhashes)).c_str(),
714711
commit_num
@@ -1020,25 +1017,31 @@ proxy_stat proxy_handle_sign_commitment_tx(
10201017
const struct pubkey *counterparty_funding_pubkey,
10211018
struct node_id *peer_id,
10221019
u64 dbid,
1020+
struct sha256 *rhashes, u64 commit_num,
10231021
struct bitcoin_signature *o_sig)
10241022
{
10251023
STATUS_DEBUG(
10261024
"%s:%d %s { "
10271025
"\"self_id\":%s, \"peer_id\":%s, \"dbid\":%" PRIu64 ", "
1028-
"\"counterparty_funding_pubkey\":%s, \"tx\":%s }",
1026+
"\"counterparty_funding_pubkey\":%s, \"tx\":%s, "
1027+
"\"rhashes\":%s, \"commit_num\":%" PRIu64 " }",
10291028
__FILE__, __LINE__, __FUNCTION__,
10301029
dump_node_id(&self_id).c_str(),
10311030
dump_node_id(peer_id).c_str(),
10321031
dbid,
10331032
dump_pubkey(counterparty_funding_pubkey).c_str(),
1034-
dump_tx(tx).c_str()
1033+
dump_tx(tx).c_str(),
1034+
dump_rhashes(rhashes, tal_count(rhashes)).c_str(),
1035+
commit_num
10351036
);
10361037

10371038
last_message = "";
10381039
SignHolderCommitmentTxRequest req;
10391040
marshal_node_id(&self_id, req.mutable_node_id());
10401041
marshal_channel_nonce(peer_id, dbid, req.mutable_channel_nonce());
10411042
marshal_single_input_tx(tx, NULL, req.mutable_tx());
1043+
marshal_rhashes(rhashes, req.mutable_payment_hashes());
1044+
req.set_commit_num(commit_num);
10421045

10431046
ClientContext context;
10441047
SignatureReply rsp;

contrib/remote_hsmd/proxy.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ proxy_stat proxy_handle_sign_remote_commitment_tx(
9191
struct node_id *peer_id,
9292
u64 dbid,
9393
const struct pubkey *remote_per_commit,
94-
bool option_static_remotekey,
9594
struct sha256 *rhashes,
9695
u64 commit_num,
9796
struct bitcoin_signature *o_sig);
@@ -130,6 +129,8 @@ proxy_stat proxy_handle_sign_commitment_tx(
130129
const struct pubkey *remote_funding_pubkey,
131130
struct node_id *peer_id,
132131
u64 dbid,
132+
struct sha256 *rhashes,
133+
u64 commit_num,
133134
struct bitcoin_signature *o_sig);
134135

135136
proxy_stat proxy_handle_cannouncement_sig(

hsmd/hsmd_wire.csv

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,9 @@ msgdata,hsmd_sign_commitment_tx,peer_id,node_id,
133133
msgdata,hsmd_sign_commitment_tx,channel_dbid,u64,
134134
msgdata,hsmd_sign_commitment_tx,tx,bitcoin_tx,
135135
msgdata,hsmd_sign_commitment_tx,remote_funding_key,pubkey,
136+
msgdata,hsmd_sign_commitment_tx,num_htlc_rhash,u16,
137+
msgdata,hsmd_sign_commitment_tx,htlc_rhash,sha256,num_htlc_rhash
138+
msgdata,hsmd_sign_commitment_tx,commit_num,u64,
136139

137140
msgtype,hsmd_sign_commitment_tx_reply,105
138141
msgdata,hsmd_sign_commitment_tx_reply,sig,bitcoin_signature,

hsmd/hsmd_wiregen.c

Lines changed: 15 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

hsmd/hsmd_wiregen.h

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lightningd/test/run-invoice-select-inchan.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,7 @@ u8 *towire_errorfmt(const tal_t *ctx UNNEEDED,
676676
u8 *towire_hsmd_sign_bolt12(const tal_t *ctx UNNEEDED, const wirestring *messagename UNNEEDED, const wirestring *fieldname UNNEEDED, const struct sha256 *merkleroot UNNEEDED, const u8 *publictweak UNNEEDED)
677677
{ fprintf(stderr, "towire_hsmd_sign_bolt12 called!\n"); abort(); }
678678
/* Generated stub for towire_hsmd_sign_commitment_tx */
679-
u8 *towire_hsmd_sign_commitment_tx(const tal_t *ctx UNNEEDED, const struct node_id *peer_id UNNEEDED, u64 channel_dbid UNNEEDED, const struct bitcoin_tx *tx UNNEEDED, const struct pubkey *remote_funding_key UNNEEDED)
679+
u8 *towire_hsmd_sign_commitment_tx(const tal_t *ctx UNNEEDED, const struct node_id *peer_id UNNEEDED, u64 channel_dbid UNNEEDED, const struct bitcoin_tx *tx UNNEEDED, const struct pubkey *remote_funding_key UNNEEDED, const struct sha256 *htlc_rhash UNNEEDED, u64 commit_num UNNEEDED)
680680
{ fprintf(stderr, "towire_hsmd_sign_commitment_tx called!\n"); abort(); }
681681
/* Generated stub for towire_hsmd_sign_invoice */
682682
u8 *towire_hsmd_sign_invoice(const tal_t *ctx UNNEEDED, const u8 *u5bytes UNNEEDED, const u8 *hrp UNNEEDED)

wallet/test/run-wallet.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,7 @@ u8 *towire_gossipd_get_stripped_cupdate(const tal_t *ctx UNNEEDED, const struct
791791
u8 *towire_hsmd_get_output_scriptpubkey(const tal_t *ctx UNNEEDED, u64 channel_id UNNEEDED, const struct node_id *peer_id UNNEEDED, const struct pubkey *commitment_point UNNEEDED)
792792
{ fprintf(stderr, "towire_hsmd_get_output_scriptpubkey called!\n"); abort(); }
793793
/* Generated stub for towire_hsmd_sign_commitment_tx */
794-
u8 *towire_hsmd_sign_commitment_tx(const tal_t *ctx UNNEEDED, const struct node_id *peer_id UNNEEDED, u64 channel_dbid UNNEEDED, const struct bitcoin_tx *tx UNNEEDED, const struct pubkey *remote_funding_key UNNEEDED)
794+
u8 *towire_hsmd_sign_commitment_tx(const tal_t *ctx UNNEEDED, const struct node_id *peer_id UNNEEDED, u64 channel_dbid UNNEEDED, const struct bitcoin_tx *tx UNNEEDED, const struct pubkey *remote_funding_key UNNEEDED, const struct sha256 *htlc_rhash UNNEEDED, u64 commit_num UNNEEDED)
795795
{ fprintf(stderr, "towire_hsmd_sign_commitment_tx called!\n"); abort(); }
796796
/* Generated stub for towire_incorrect_cltv_expiry */
797797
u8 *towire_incorrect_cltv_expiry(const tal_t *ctx UNNEEDED, u32 cltv_expiry UNNEEDED, const u8 *channel_update UNNEEDED)

0 commit comments

Comments
 (0)