Skip to content

Commit 474d042

Browse files
authored
Merge pull request #37 from lightning-signer/greenlight-signer-old-proxy-fixes
Adapt the original proxy to simple_htlc
2 parents 900508e + f19f0a0 commit 474d042

File tree

5 files changed

+21
-22
lines changed

5 files changed

+21
-22
lines changed

contrib/remote_hsmd/dump.cc

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -497,20 +497,19 @@ string dump_rhashes(const struct sha256 *rhashes, size_t num_rhashes)
497497
return ostrm.str();
498498
}
499499

500-
string dump_htlc(const struct existing_htlc *htlc)
500+
string dump_htlc(const struct simple_htlc *htlc)
501501
{
502502
ostringstream ostrm;
503503
ostrm << "{ "
504-
<< "\"id\":" << htlc->id
505-
<< ", \"state\":" << htlc_state_name(htlc->state)
504+
<< ", \"side\":" << htlc->side
506505
<< ", \"amount_msat\":" << htlc->amount.millisatoshis
507506
<< ", \"payment_hash\":" << dump_hex(&htlc->payment_hash, sizeof(htlc->payment_hash))
508507
<< ", \"cltv_expiry\":" << htlc->cltv_expiry
509508
<< " }";
510509
return ostrm.str();
511510
}
512511

513-
string dump_htlcs(const struct existing_htlc **htlc, size_t num_htlc)
512+
string dump_htlcs(const struct simple_htlc **htlc, size_t num_htlc)
514513
{
515514
ostringstream ostrm;
516515
ostrm << "[";

contrib/remote_hsmd/dump.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ std::string dump_wally_tx(const struct wally_tx *wtx);
3838
std::string dump_wally_psbt(const struct wally_psbt *psbt);
3939
std::string dump_tx(const struct bitcoin_tx *tx);
4040
std::string dump_rhashes(const struct sha256 *rhashes, size_t num_rhashes);
41-
std::string dump_htlc(const struct existing_htlc *htlc);
42-
std::string dump_htlcs(const struct existing_htlc **htlc, size_t num_htlc);
41+
std::string dump_htlc(const struct simple_htlc *htlc);
42+
std::string dump_htlcs(const struct simple_htlc **htlc, size_t num_htlc);
4343

4444
// needed for formatting txid
4545
void reverse_bytes(u8 *arr, size_t len);

contrib/remote_hsmd/hsmd.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,7 @@ static struct io_plan *handle_sign_commitment_tx(struct io_conn *conn,
752752
struct node_id peer_id;
753753
u64 dbid;
754754
struct bitcoin_tx *tx;
755-
struct existing_htlc **htlc;
755+
struct simple_htlc **htlc;
756756
u64 commit_num;
757757
u32 feerate;
758758
struct bitcoin_signature sig;
@@ -816,7 +816,7 @@ static struct io_plan *handle_validate_commitment_tx(struct io_conn *conn,
816816
const u8 *msg_in)
817817
{
818818
struct bitcoin_tx *tx;
819-
struct existing_htlc **htlc;
819+
struct simple_htlc **htlc;
820820
u64 commit_num;
821821
u32 feerate;
822822
struct bitcoin_signature commit_sig;
@@ -896,7 +896,7 @@ static struct io_plan *handle_sign_remote_commitment_tx(struct io_conn *conn,
896896
struct pubkey remote_per_commit;
897897
bool option_static_remotekey;
898898
u64 commit_num;
899-
struct existing_htlc **htlc;
899+
struct simple_htlc **htlc;
900900
u32 feerate;
901901

902902
if (!fromwire_hsmd_sign_remote_commitment_tx(tmpctx, msg_in,

contrib/remote_hsmd/proxy.cc

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ void marshal_rhashes(const struct sha256 *rhashes,
244244
}
245245
}
246246

247-
void marshal_htlc(const struct existing_htlc *htlc, HTLCInfo *o_htlc)
247+
void marshal_htlc(const struct simple_htlc *htlc, HTLCInfo *o_htlc)
248248
{
249249
o_htlc->set_value_sat(htlc->amount.millisatoshis / 1000);
250250
o_htlc->set_payment_hash(&htlc->payment_hash, sizeof(htlc->payment_hash));
@@ -768,7 +768,7 @@ proxy_stat proxy_handle_sign_remote_commitment_tx(
768768
struct node_id *peer_id,
769769
u64 dbid,
770770
const struct pubkey *remote_per_commit,
771-
struct existing_htlc **htlcs,
771+
struct simple_htlc **htlcs,
772772
u64 commit_num, u32 feerate,
773773
struct bitcoin_signature *o_sig)
774774
{
@@ -787,7 +787,7 @@ proxy_stat proxy_handle_sign_remote_commitment_tx(
787787
dump_pubkey(counterparty_funding_pubkey).c_str(),
788788
dump_pubkey(remote_per_commit).c_str(),
789789
dump_tx(tx).c_str(),
790-
dump_htlcs((const struct existing_htlc **) htlcs, tal_count(htlcs)).c_str(),
790+
dump_htlcs((const struct simple_htlc **) htlcs, tal_count(htlcs)).c_str(),
791791
commit_num, feerate
792792
);
793793

@@ -799,7 +799,7 @@ proxy_stat proxy_handle_sign_remote_commitment_tx(
799799
req.mutable_remote_per_commit_point());
800800
marshal_single_input_tx(tx, NULL, req.mutable_tx());
801801
for (size_t ii = 0; ii < tal_count(htlcs); ++ii) {
802-
if (htlc_state_owner(htlcs[ii]->state) == REMOTE) {
802+
if (htlcs[ii]->side == REMOTE) {
803803
marshal_htlc(htlcs[ii], req.add_offered_htlcs());
804804
} else {
805805
marshal_htlc(htlcs[ii], req.add_received_htlcs());
@@ -1105,7 +1105,7 @@ proxy_stat proxy_handle_sign_commitment_tx(
11051105
const struct pubkey *counterparty_funding_pubkey,
11061106
struct node_id *peer_id,
11071107
u64 dbid,
1108-
struct existing_htlc **htlcs,
1108+
struct simple_htlc **htlcs,
11091109
u64 commit_num, u32 feerate,
11101110
struct bitcoin_signature *o_sig)
11111111
{
@@ -1122,7 +1122,7 @@ proxy_stat proxy_handle_sign_commitment_tx(
11221122
dbid,
11231123
dump_pubkey(counterparty_funding_pubkey).c_str(),
11241124
dump_tx(tx).c_str(),
1125-
dump_htlcs((const struct existing_htlc **) htlcs, tal_count(htlcs)).c_str(),
1125+
dump_htlcs((const struct simple_htlc **) htlcs, tal_count(htlcs)).c_str(),
11261126
commit_num, feerate
11271127
);
11281128

@@ -1132,7 +1132,7 @@ proxy_stat proxy_handle_sign_commitment_tx(
11321132
marshal_channel_nonce(peer_id, dbid, req.mutable_channel_nonce());
11331133
marshal_single_input_tx(tx, NULL, req.mutable_tx());
11341134
for (size_t ii = 0; ii < tal_count(htlcs); ++ii) {
1135-
if (htlc_state_owner(htlcs[ii]->state) == LOCAL) {
1135+
if (htlcs[ii]->side == LOCAL) {
11361136
marshal_htlc(htlcs[ii], req.add_offered_htlcs());
11371137
} else {
11381138
marshal_htlc(htlcs[ii], req.add_received_htlcs());
@@ -1166,7 +1166,7 @@ proxy_stat proxy_handle_validate_commitment_tx(
11661166
struct bitcoin_tx *tx,
11671167
struct node_id *peer_id,
11681168
u64 dbid,
1169-
struct existing_htlc **htlcs,
1169+
struct simple_htlc **htlcs,
11701170
u64 commit_num, u32 feerate,
11711171
struct bitcoin_signature *commit_sig,
11721172
struct bitcoin_signature *htlc_sigs,
@@ -1186,7 +1186,7 @@ proxy_stat proxy_handle_validate_commitment_tx(
11861186
dump_node_id(peer_id).c_str(),
11871187
dbid,
11881188
dump_tx(tx).c_str(),
1189-
dump_htlcs((const struct existing_htlc **) htlcs, tal_count(htlcs)).c_str(),
1189+
dump_htlcs((const struct simple_htlc **) htlcs, tal_count(htlcs)).c_str(),
11901190
commit_num, feerate,
11911191
dump_bitcoin_signature(commit_sig).c_str(),
11921192
dump_htlc_signatures(htlc_sigs).c_str()
@@ -1198,7 +1198,7 @@ proxy_stat proxy_handle_validate_commitment_tx(
11981198
marshal_channel_nonce(peer_id, dbid, req.mutable_channel_nonce());
11991199
marshal_single_input_tx(tx, NULL, req.mutable_tx());
12001200
for (size_t ii = 0; ii < tal_count(htlcs); ++ii) {
1201-
if (htlc_state_owner(htlcs[ii]->state) == LOCAL) {
1201+
if (htlcs[ii]->side == LOCAL) {
12021202
marshal_htlc(htlcs[ii], req.add_offered_htlcs());
12031203
} else {
12041204
marshal_htlc(htlcs[ii], req.add_received_htlcs());

contrib/remote_hsmd/proxy.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ 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-
struct existing_htlc **htlc,
94+
struct simple_htlc **htlc,
9595
u64 commit_num,
9696
u32 feerate,
9797
struct bitcoin_signature *o_sig);
@@ -130,7 +130,7 @@ proxy_stat proxy_handle_sign_commitment_tx(
130130
const struct pubkey *remote_funding_pubkey,
131131
struct node_id *peer_id,
132132
u64 dbid,
133-
struct existing_htlc **htlc,
133+
struct simple_htlc **htlc,
134134
u64 commit_num,
135135
u32 feerate,
136136
struct bitcoin_signature *o_sig);
@@ -139,7 +139,7 @@ proxy_stat proxy_handle_validate_commitment_tx(
139139
struct bitcoin_tx *tx,
140140
struct node_id *peer_id,
141141
u64 dbid,
142-
struct existing_htlc **htlc,
142+
struct simple_htlc **htlc,
143143
u64 commit_num,
144144
u32 feerate,
145145
struct bitcoin_signature *commit_sig,

0 commit comments

Comments
 (0)