Skip to content

Commit 77814e5

Browse files
committed
Adapt the original proxy to simple_htlc
1 parent 810f19a commit 77814e5

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
@@ -498,20 +498,19 @@ string dump_rhashes(const struct sha256 *rhashes, size_t num_rhashes)
498498
return ostrm.str();
499499
}
500500

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

514-
string dump_htlcs(const struct existing_htlc **htlc, size_t num_htlc)
513+
string dump_htlcs(const struct simple_htlc **htlc, size_t num_htlc)
515514
{
516515
ostringstream ostrm;
517516
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
@@ -767,7 +767,7 @@ 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 existing_htlc **htlc;
770+
struct simple_htlc **htlc;
771771
u64 commit_num;
772772
u32 feerate;
773773
struct bitcoin_signature sig;
@@ -831,7 +831,7 @@ static struct io_plan *handle_validate_commitment_tx(struct io_conn *conn,
831831
const u8 *msg_in)
832832
{
833833
struct bitcoin_tx *tx;
834-
struct existing_htlc **htlc;
834+
struct simple_htlc **htlc;
835835
u64 commit_num;
836836
u32 feerate;
837837
struct bitcoin_signature commit_sig;
@@ -911,7 +911,7 @@ static struct io_plan *handle_sign_remote_commitment_tx(struct io_conn *conn,
911911
struct pubkey remote_per_commit;
912912
bool option_static_remotekey;
913913
u64 commit_num;
914-
struct existing_htlc **htlc;
914+
struct simple_htlc **htlc;
915915
u32 feerate;
916916

917917
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
@@ -247,7 +247,7 @@ void marshal_rhashes(const struct sha256 *rhashes,
247247
}
248248
}
249249

250-
void marshal_htlc(const struct existing_htlc *htlc, HTLCInfo *o_htlc)
250+
void marshal_htlc(const struct simple_htlc *htlc, HTLCInfo *o_htlc)
251251
{
252252
o_htlc->set_value_sat(htlc->amount.millisatoshis / 1000);
253253
o_htlc->set_payment_hash(&htlc->payment_hash, sizeof(htlc->payment_hash));
@@ -772,7 +772,7 @@ proxy_stat proxy_handle_sign_remote_commitment_tx(
772772
struct node_id *peer_id,
773773
u64 dbid,
774774
const struct pubkey *remote_per_commit,
775-
struct existing_htlc **htlcs,
775+
struct simple_htlc **htlcs,
776776
u64 commit_num, u32 feerate,
777777
struct bitcoin_signature *o_sig)
778778
{
@@ -791,7 +791,7 @@ proxy_stat proxy_handle_sign_remote_commitment_tx(
791791
dump_pubkey(counterparty_funding_pubkey).c_str(),
792792
dump_pubkey(remote_per_commit).c_str(),
793793
dump_tx(tx).c_str(),
794-
dump_htlcs((const struct existing_htlc **) htlcs, tal_count(htlcs)).c_str(),
794+
dump_htlcs((const struct simple_htlc **) htlcs, tal_count(htlcs)).c_str(),
795795
commit_num, feerate
796796
);
797797

@@ -803,7 +803,7 @@ proxy_stat proxy_handle_sign_remote_commitment_tx(
803803
req.mutable_remote_per_commit_point());
804804
marshal_single_input_tx(tx, NULL, req.mutable_tx());
805805
for (size_t ii = 0; ii < tal_count(htlcs); ++ii) {
806-
if (htlc_state_owner(htlcs[ii]->state) == REMOTE) {
806+
if (htlcs[ii]->side == REMOTE) {
807807
marshal_htlc(htlcs[ii], req.add_offered_htlcs());
808808
} else {
809809
marshal_htlc(htlcs[ii], req.add_received_htlcs());
@@ -1109,7 +1109,7 @@ proxy_stat proxy_handle_sign_commitment_tx(
11091109
const struct pubkey *counterparty_funding_pubkey,
11101110
struct node_id *peer_id,
11111111
u64 dbid,
1112-
struct existing_htlc **htlcs,
1112+
struct simple_htlc **htlcs,
11131113
u64 commit_num, u32 feerate,
11141114
struct bitcoin_signature *o_sig)
11151115
{
@@ -1126,7 +1126,7 @@ proxy_stat proxy_handle_sign_commitment_tx(
11261126
dbid,
11271127
dump_pubkey(counterparty_funding_pubkey).c_str(),
11281128
dump_tx(tx).c_str(),
1129-
dump_htlcs((const struct existing_htlc **) htlcs, tal_count(htlcs)).c_str(),
1129+
dump_htlcs((const struct simple_htlc **) htlcs, tal_count(htlcs)).c_str(),
11301130
commit_num, feerate
11311131
);
11321132

@@ -1136,7 +1136,7 @@ proxy_stat proxy_handle_sign_commitment_tx(
11361136
marshal_channel_nonce(peer_id, dbid, req.mutable_channel_nonce());
11371137
marshal_single_input_tx(tx, NULL, req.mutable_tx());
11381138
for (size_t ii = 0; ii < tal_count(htlcs); ++ii) {
1139-
if (htlc_state_owner(htlcs[ii]->state) == LOCAL) {
1139+
if (htlcs[ii]->side == LOCAL) {
11401140
marshal_htlc(htlcs[ii], req.add_offered_htlcs());
11411141
} else {
11421142
marshal_htlc(htlcs[ii], req.add_received_htlcs());
@@ -1170,7 +1170,7 @@ proxy_stat proxy_handle_validate_commitment_tx(
11701170
struct bitcoin_tx *tx,
11711171
struct node_id *peer_id,
11721172
u64 dbid,
1173-
struct existing_htlc **htlcs,
1173+
struct simple_htlc **htlcs,
11741174
u64 commit_num, u32 feerate,
11751175
struct bitcoin_signature *commit_sig,
11761176
struct bitcoin_signature *htlc_sigs,
@@ -1190,7 +1190,7 @@ proxy_stat proxy_handle_validate_commitment_tx(
11901190
dump_node_id(peer_id).c_str(),
11911191
dbid,
11921192
dump_tx(tx).c_str(),
1193-
dump_htlcs((const struct existing_htlc **) htlcs, tal_count(htlcs)).c_str(),
1193+
dump_htlcs((const struct simple_htlc **) htlcs, tal_count(htlcs)).c_str(),
11941194
commit_num, feerate,
11951195
dump_bitcoin_signature(commit_sig).c_str(),
11961196
dump_htlc_signatures(htlc_sigs).c_str()
@@ -1202,7 +1202,7 @@ proxy_stat proxy_handle_validate_commitment_tx(
12021202
marshal_channel_nonce(peer_id, dbid, req.mutable_channel_nonce());
12031203
marshal_single_input_tx(tx, NULL, req.mutable_tx());
12041204
for (size_t ii = 0; ii < tal_count(htlcs); ++ii) {
1205-
if (htlc_state_owner(htlcs[ii]->state) == LOCAL) {
1205+
if (htlcs[ii]->side == LOCAL) {
12061206
marshal_htlc(htlcs[ii], req.add_offered_htlcs());
12071207
} else {
12081208
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
@@ -96,7 +96,7 @@ proxy_stat proxy_handle_sign_remote_commitment_tx(
9696
struct node_id *peer_id,
9797
u64 dbid,
9898
const struct pubkey *remote_per_commit,
99-
struct existing_htlc **htlc,
99+
struct simple_htlc **htlc,
100100
u64 commit_num,
101101
u32 feerate,
102102
struct bitcoin_signature *o_sig);
@@ -135,7 +135,7 @@ proxy_stat proxy_handle_sign_commitment_tx(
135135
const struct pubkey *remote_funding_pubkey,
136136
struct node_id *peer_id,
137137
u64 dbid,
138-
struct existing_htlc **htlc,
138+
struct simple_htlc **htlc,
139139
u64 commit_num,
140140
u32 feerate,
141141
struct bitcoin_signature *o_sig);
@@ -144,7 +144,7 @@ proxy_stat proxy_handle_validate_commitment_tx(
144144
struct bitcoin_tx *tx,
145145
struct node_id *peer_id,
146146
u64 dbid,
147-
struct existing_htlc **htlc,
147+
struct simple_htlc **htlc,
148148
u64 commit_num,
149149
u32 feerate,
150150
struct bitcoin_signature *commit_sig,

0 commit comments

Comments
 (0)