Skip to content

Commit ec3a3d2

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 ec3a3d2

File tree

4 files changed

+12
-3
lines changed

4 files changed

+12
-3
lines changed

channeld/channeld.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
#include <gossipd/gossip_store_wiregen.h>
4949
#include <gossipd/gossipd_peerd_wiregen.h>
5050
#include <hsmd/hsmd_wiregen.h>
51+
#include <stdbool.h>
5152
#include <stdio.h>
5253
#include <wally_bip32.h>
5354
#include <wire/peer_wire.h>
@@ -982,6 +983,7 @@ static void handle_peer_add_htlc(struct peer *peer, const u8 *msg)
982983
add_err = channel_add_htlc(peer->channel, REMOTE, id, amount,
983984
cltv_expiry, &payment_hash,
984985
onion_routing_packet, tlvs->blinding_point, &htlc, NULL,
986+
tlvs->endorsed,
985987
/* We don't immediately fail incoming htlcs,
986988
* instead we wait and fail them after
987989
* they've been committed */
@@ -5270,7 +5272,8 @@ static void handle_offer_htlc(struct peer *peer, const u8 *inmsg)
52705272
e = channel_add_htlc(peer->channel, LOCAL, peer->htlc_id,
52715273
amount, cltv_expiry, &payment_hash,
52725274
onion_routing_packet, take(blinding), NULL,
5273-
&htlc_fee, true);
5275+
// FIXME: See what it is changing in the offers side
5276+
&htlc_fee, false, true);
52745277
status_debug("Adding HTLC %"PRIu64" amount=%s cltv=%u gave %s",
52755278
peer->htlc_id,
52765279
type_to_string(tmpctx, struct amount_msat, &amount),

channeld/full_channel.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include "ccan/short_types/short_types.h"
12
#include "config.h"
23
#include <bitcoin/psbt.h>
34
#include <bitcoin/script.h>
@@ -14,6 +15,7 @@
1415
#include <common/memleak.h>
1516
#include <common/status.h>
1617
#include <common/type_to_string.h>
18+
#include <stdbool.h>
1719
#include <stdio.h>
1820
/* Needs to be at end, since it doesn't include its own hdrs */
1921
#include "full_channel_error_names_gen.h"
@@ -928,6 +930,7 @@ enum channel_add_err channel_add_htlc(struct channel *channel,
928930
const struct pubkey *blinding TAKES,
929931
struct htlc **htlcp,
930932
struct amount_sat *htlc_fee,
933+
const bool endorsed,
931934
bool err_immediate_failures)
932935
{
933936
enum htlc_state state;

channeld/full_channel.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
/* This is the full channel routines, with HTLC support. */
22
#ifndef LIGHTNING_CHANNELD_FULL_CHANNEL_H
33
#define LIGHTNING_CHANNELD_FULL_CHANNEL_H
4+
#include "ccan/short_types/short_types.h"
45
#include "config.h"
56
#include <channeld/channeld_htlc.h>
67
#include <channeld/full_channel_error.h>
78
#include <common/initial_channel.h>
89
#include <common/sphinx.h>
10+
#include <stdbool.h>
911

1012
struct channel_id;
1113
struct existing_htlc;
@@ -138,6 +140,7 @@ enum channel_add_err channel_add_htlc(struct channel *channel,
138140
const struct pubkey *blinding TAKES,
139141
struct htlc **htlcp,
140142
struct amount_sat *htlc_fee,
143+
const bool endorsed,
141144
bool err_immediate_failures);
142145

143146
/**

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)