Skip to content

Commit e399424

Browse files
channeld: wip: be able to handle the update htlc by handling the endorsed field
Signed-off-by: Vincenzo Palazzo <[email protected]>
1 parent 3c40001 commit e399424

File tree

4 files changed

+8
-3
lines changed

4 files changed

+8
-3
lines changed

channeld/channeld.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -982,6 +982,7 @@ static void handle_peer_add_htlc(struct peer *peer, const u8 *msg)
982982
add_err = channel_add_htlc(peer->channel, REMOTE, id, amount,
983983
cltv_expiry, &payment_hash,
984984
onion_routing_packet, tlvs->blinding_point, &htlc, NULL,
985+
tlvs->endorsed,
985986
/* We don't immediately fail incoming htlcs,
986987
* instead we wait and fail them after
987988
* they've been committed */
@@ -5270,7 +5271,7 @@ static void handle_offer_htlc(struct peer *peer, const u8 *inmsg)
52705271
e = channel_add_htlc(peer->channel, LOCAL, peer->htlc_id,
52715272
amount, cltv_expiry, &payment_hash,
52725273
onion_routing_packet, take(blinding), NULL,
5273-
&htlc_fee, true);
5274+
&htlc_fee, false, true);
52745275
status_debug("Adding HTLC %"PRIu64" amount=%s cltv=%u gave %s",
52755276
peer->htlc_id,
52765277
type_to_string(tmpctx, struct amount_msat, &amount),

channeld/full_channel.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <common/memleak.h>
1515
#include <common/status.h>
1616
#include <common/type_to_string.h>
17+
#include <stdbool.h>
1718
#include <stdio.h>
1819
/* Needs to be at end, since it doesn't include its own hdrs */
1920
#include "full_channel_error_names_gen.h"
@@ -928,6 +929,7 @@ enum channel_add_err channel_add_htlc(struct channel *channel,
928929
const struct pubkey *blinding TAKES,
929930
struct htlc **htlcp,
930931
struct amount_sat *htlc_fee,
932+
const bool endorsed,
931933
bool err_immediate_failures)
932934
{
933935
enum htlc_state state;

channeld/full_channel.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <channeld/full_channel_error.h>
77
#include <common/initial_channel.h>
88
#include <common/sphinx.h>
9+
#include <stdbool.h>
910

1011
struct channel_id;
1112
struct existing_htlc;
@@ -138,6 +139,7 @@ enum channel_add_err channel_add_htlc(struct channel *channel,
138139
const struct pubkey *blinding TAKES,
139140
struct htlc **htlcp,
140141
struct amount_sat *htlc_fee,
142+
const bool endorsed,
141143
bool err_immediate_failures);
142144

143145
/**

channeld/test/run-full_channel.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ static const struct htlc **include_htlcs(struct channel *channel, enum side side
168168
memset(&preimage, i, sizeof(preimage));
169169
sha256(&hash, &preimage, sizeof(preimage));
170170
e = channel_add_htlc(channel, sender, i, msatoshi, 500+i, &hash,
171-
dummy_routing, NULL, NULL, NULL, true);
171+
dummy_routing, NULL, NULL, NULL, false, true);
172172
assert(e == CHANNEL_ERR_ADD_OK);
173173
htlcs[i] = channel_get_htlc(channel, sender, i);
174174
}
@@ -260,7 +260,7 @@ static void send_and_fulfill_htlc(struct channel *channel,
260260
sha256(&rhash, &r, sizeof(r));
261261

262262
assert(channel_add_htlc(channel, sender, 1337, msatoshi, 900, &rhash,
263-
dummy_routing, NULL, NULL, NULL, true)
263+
dummy_routing, NULL, NULL, NULL, false, true)
264264
== CHANNEL_ERR_ADD_OK);
265265
htlc = channel_get_htlc(channel, sender, 1337);
266266
assert(htlc);

0 commit comments

Comments
 (0)