Skip to content

Commit dc8014f

Browse files
committed
Remove uneeded hsmd_sign_commitment_tx modifications
1 parent a1ff175 commit dc8014f

File tree

8 files changed

+9
-89
lines changed

8 files changed

+9
-89
lines changed

contrib/remote_hsmd/hsmd.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -767,16 +767,14 @@ static struct io_plan *handle_sign_commitment_tx(struct io_conn *conn,
767767
struct node_id peer_id;
768768
u64 dbid;
769769
struct bitcoin_tx *tx;
770-
struct simple_htlc **htlc;
771770
u64 commit_num;
772-
u32 feerate;
773771
struct bitcoin_signature sig;
774772

775773
if (!fromwire_hsmd_sign_commitment_tx(tmpctx, msg_in,
776774
&peer_id, &dbid,
777775
&tx,
778776
&remote_funding_pubkey,
779-
&commit_num, &htlc, &feerate))
777+
&commit_num))
780778
return bad_req(conn, c, msg_in);
781779

782780
tx->chainparams = c->chainparams;
@@ -809,8 +807,7 @@ static struct io_plan *handle_sign_commitment_tx(struct io_conn *conn,
809807
} else {
810808
// This is a unilateral close from our side.
811809
proxy_stat rv = proxy_handle_sign_commitment_tx(
812-
tx, &remote_funding_pubkey, &peer_id, dbid,
813-
htlc, commit_num, feerate, &sig);
810+
&peer_id, dbid, commit_num, &sig);
814811
if (PROXY_PERMANENT(rv))
815812
status_failed(STATUS_FAIL_INTERNAL_ERROR,
816813
"proxy_%s failed: %s", __FUNCTION__,

contrib/remote_hsmd/proxy.cc

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1105,29 +1105,20 @@ proxy_stat proxy_handle_sign_mutual_close_tx(
11051105
}
11061106

11071107
proxy_stat proxy_handle_sign_commitment_tx(
1108-
struct bitcoin_tx *tx,
1109-
const struct pubkey *counterparty_funding_pubkey,
11101108
struct node_id *peer_id,
11111109
u64 dbid,
1112-
struct simple_htlc **htlcs,
1113-
u64 commit_num, u32 feerate,
1110+
u64 commit_num,
11141111
struct bitcoin_signature *o_sig)
11151112
{
11161113
STATUS_DEBUG(
11171114
"%s:%d %s { "
11181115
"\"self_id\":%s, \"peer_id\":%s, \"dbid\":%" PRIu64 ", "
1119-
"\"counterparty_funding_pubkey\":%s, \"tx\":%s, "
1120-
"\"htlcs\":%s, "
1121-
"\"commit_num\":%" PRIu64 ", "
1122-
"\"feerate\":%d }",
1116+
"\"commit_num\":%" PRIu64 " }",
11231117
__FILE__, __LINE__, __FUNCTION__,
11241118
dump_node_id(&self_id).c_str(),
11251119
dump_node_id(peer_id).c_str(),
11261120
dbid,
1127-
dump_pubkey(counterparty_funding_pubkey).c_str(),
1128-
dump_tx(tx).c_str(),
1129-
dump_htlcs((const struct simple_htlc **) htlcs, tal_count(htlcs)).c_str(),
1130-
commit_num, feerate
1121+
commit_num
11311122
);
11321123

11331124
last_message = "";

contrib/remote_hsmd/proxy.hpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,13 +135,9 @@ proxy_stat proxy_handle_sign_mutual_close_tx(
135135
struct bitcoin_signature *o_sig);
136136

137137
proxy_stat proxy_handle_sign_commitment_tx(
138-
struct bitcoin_tx *tx,
139-
const struct pubkey *remote_funding_pubkey,
140138
struct node_id *peer_id,
141139
u64 dbid,
142-
struct simple_htlc **htlc,
143140
u64 commit_num,
144-
u32 feerate,
145141
struct bitcoin_signature *o_sig);
146142

147143
proxy_stat proxy_handle_validate_commitment_tx(

hsmd/hsmd_wire.csv

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,6 @@ 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,
136136
msgdata,hsmd_sign_commitment_tx,commit_num,u64,
137-
msgdata,hsmd_sign_commitment_tx,num_htlcs,u16,
138-
msgdata,hsmd_sign_commitment_tx,htlcs,simple_htlc,num_htlcs
139-
msgdata,hsmd_sign_commitment_tx,feerate,u32,
140137

141138
msgtype,hsmd_sign_commitment_tx_reply,105
142139
msgdata,hsmd_sign_commitment_tx_reply,sig,bitcoin_signature,

hsmd/libhsmd.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1300,17 +1300,15 @@ static u8 *handle_sign_commitment_tx(struct hsmd_client *c, const u8 *msg_in)
13001300
struct secret channel_seed;
13011301
struct bitcoin_tx *tx;
13021302
struct bitcoin_signature sig;
1303-
struct simple_htlc **htlc;
13041303
u64 commit_num;
1305-
u32 feerate;
13061304
struct secrets secrets;
13071305
const u8 *funding_wscript;
13081306

13091307
if (!fromwire_hsmd_sign_commitment_tx(tmpctx, msg_in,
13101308
&peer_id, &dbid,
13111309
&tx,
13121310
&remote_funding_pubkey,
1313-
&commit_num, &htlc, &feerate))
1311+
&commit_num))
13141312
return hsmd_status_malformed_request(c, msg_in);
13151313

13161314
tx->chainparams = c->chainparams;

lightningd/peer_control.c

Lines changed: 1 addition & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -176,61 +176,6 @@ u8 *p2wpkh_for_keyidx(const tal_t *ctx, struct lightningd *ld, u64 keyidx)
176176
return scriptpubkey_p2wpkh(ctx, &shutdownkey);
177177
}
178178

179-
static struct simple_htlc **collect_htlcs(struct channel *channel, u32 local_feerate) {
180-
// Collect the htlcs for call to hsmd.
181-
struct htlc_in_map *htlcs_in = &channel->peer->ld->htlcs_in;
182-
struct htlc_out_map *htlcs_out = &channel->peer->ld->htlcs_out;
183-
struct simple_htlc **htlcs = tal_arr(tmpctx, struct simple_htlc *, 0);
184-
const int committed_flag = HTLC_FLAG(REMOTE, HTLC_F_COMMITTED);
185-
186-
const struct htlc_in *hin;
187-
struct htlc_in_map_iter ini;
188-
for (hin = htlc_in_map_first(htlcs_in, &ini);
189-
hin;
190-
hin = htlc_in_map_next(htlcs_in, &ini)) {
191-
if (hin->key.channel != channel)
192-
continue;
193-
if (!(htlc_state_flags(hin->hstate) & committed_flag))
194-
continue;
195-
if (htlc_is_trimmed(REMOTE, hin->msat, local_feerate,
196-
channel->our_config.dust_limit, LOCAL,
197-
channel_has(channel, OPT_ANCHOR_OUTPUTS)))
198-
continue;
199-
struct simple_htlc *simple =
200-
new_simple_htlc(NULL,
201-
htlc_state_owner(hin->hstate),
202-
hin->msat,
203-
&hin->payment_hash,
204-
hin->cltv_expiry
205-
);
206-
tal_arr_expand(&htlcs, tal_steal(htlcs, simple));
207-
}
208-
209-
const struct htlc_out *hout;
210-
struct htlc_out_map_iter outi;
211-
for (hout = htlc_out_map_first(htlcs_out, &outi);
212-
hout;
213-
hout = htlc_out_map_next(htlcs_out, &outi)) {
214-
if (hout->key.channel != channel)
215-
continue;
216-
if (!(htlc_state_flags(hout->hstate) & committed_flag))
217-
continue;
218-
if (htlc_is_trimmed(REMOTE, hout->msat, local_feerate,
219-
channel->our_config.dust_limit, LOCAL,
220-
channel_has(channel, OPT_ANCHOR_OUTPUTS)))
221-
continue;
222-
struct simple_htlc *simple =
223-
new_simple_htlc(NULL,
224-
htlc_state_owner(hout->hstate),
225-
hout->msat,
226-
&hout->payment_hash,
227-
hout->cltv_expiry
228-
);
229-
tal_arr_expand(&htlcs, tal_steal(htlcs, simple));
230-
}
231-
return htlcs;
232-
}
233-
234179
static void sign_last_tx(struct channel *channel,
235180
struct bitcoin_tx *last_tx,
236181
struct bitcoin_signature *last_sig)
@@ -240,8 +185,6 @@ static void sign_last_tx(struct channel *channel,
240185
u8 *msg, **witness;
241186

242187
u64 commit_index = channel->next_index[LOCAL] - 1;
243-
u32 local_feerate = get_feerate(channel->fee_states, channel->opener, LOCAL);
244-
struct simple_htlc **htlcs = collect_htlcs(channel, local_feerate);
245188

246189
assert(!last_tx->wtx->inputs[0].witness);
247190
msg = towire_hsmd_sign_commitment_tx(tmpctx,
@@ -250,9 +193,7 @@ static void sign_last_tx(struct channel *channel,
250193
last_tx,
251194
&channel->channel_info
252195
.remote_fundingkey,
253-
commit_index,
254-
(const struct simple_htlc **) htlcs,
255-
local_feerate);
196+
commit_index);
256197

257198
if (!wire_sync_write(ld->hsm_fd, take(msg)))
258199
fatal("Could not write to HSM: %s", strerror(errno));

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@ u8 *towire_errorfmt(const tal_t *ctx UNNEEDED,
657657
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)
658658
{ fprintf(stderr, "towire_hsmd_sign_bolt12 called!\n"); abort(); }
659659
/* Generated stub for towire_hsmd_sign_commitment_tx */
660-
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, u64 commit_num UNNEEDED, const struct simple_htlc **htlcs UNNEEDED, u32 feerate UNNEEDED)
660+
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, u64 commit_num UNNEEDED)
661661
{ fprintf(stderr, "towire_hsmd_sign_commitment_tx called!\n"); abort(); }
662662
/* Generated stub for towire_hsmd_sign_invoice */
663663
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
@@ -752,7 +752,7 @@ u8 *towire_gossipd_get_stripped_cupdate(const tal_t *ctx UNNEEDED, const struct
752752
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)
753753
{ fprintf(stderr, "towire_hsmd_get_output_scriptpubkey called!\n"); abort(); }
754754
/* Generated stub for towire_hsmd_sign_commitment_tx */
755-
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, u64 commit_num UNNEEDED, const struct simple_htlc **htlcs UNNEEDED, u32 feerate UNNEEDED)
755+
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, u64 commit_num UNNEEDED)
756756
{ fprintf(stderr, "towire_hsmd_sign_commitment_tx called!\n"); abort(); }
757757
/* Generated stub for towire_incorrect_cltv_expiry */
758758
u8 *towire_incorrect_cltv_expiry(const tal_t *ctx UNNEEDED, u32 cltv_expiry UNNEEDED, const u8 *channel_update UNNEEDED)

0 commit comments

Comments
 (0)