Skip to content

Commit a7eb48a

Browse files
wip: support endorsed flag on hook
Signed-off-by: Vincenzo Palazzo <[email protected]>
1 parent 2d339b5 commit a7eb48a

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

lightningd/pay.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <lightningd/notification.h>
1717
#include <lightningd/pay.h>
1818
#include <lightningd/peer_control.h>
19+
#include <stdbool.h>
1920
#include <wallet/invoices.h>
2021

2122
/* Routing failure object */
@@ -768,7 +769,8 @@ static const u8 *send_onion(const tal_t *ctx, struct lightningd *ld,
768769
u64 partid,
769770
u64 groupid,
770771
struct channel *channel,
771-
struct htlc_out **hout)
772+
struct htlc_out **hout,
773+
bool endorsed)
772774
{
773775
const u8 *onion;
774776
unsigned int base_expiry;
@@ -778,7 +780,8 @@ static const u8 *send_onion(const tal_t *ctx, struct lightningd *ld,
778780
return send_htlc_out(ctx, channel, first_hop->amount,
779781
base_expiry + first_hop->delay,
780782
final_amount, payment_hash,
781-
blinding, partid, groupid, onion, NULL, hout);
783+
blinding, partid, groupid, onion, NULL, hout,
784+
endorsed);
782785
}
783786

784787
static struct command_result *check_invoice_request_usage(struct command *cmd,

lightningd/peer_htlcs.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,8 @@ const u8 *send_htlc_out(const tal_t *ctx,
605605
u64 groupid,
606606
const u8 *onion_routing_packet,
607607
struct htlc_in *in,
608-
struct htlc_out **houtp)
608+
struct htlc_out **houtp,
609+
bool endorsed)
609610
{
610611
u8 *msg;
611612

@@ -646,6 +647,7 @@ const u8 *send_htlc_out(const tal_t *ctx,
646647
*houtp);
647648
}
648649

650+
// FIXME: add the `endorsed` variable here
649651
msg = towire_channeld_offer_htlc(out, amount, cltv, payment_hash,
650652
onion_routing_packet, blinding);
651653
subd_req(out->peer->ld, out->owner, take(msg), -1, 0, rcvd_htlc_reply,
@@ -700,7 +702,8 @@ static void forward_htlc(struct htlc_in *hin,
700702
const struct short_channel_id *forward_scid,
701703
const struct channel_id *forward_to,
702704
const u8 next_onion[TOTAL_PACKET_SIZE(ROUTING_INFO_SIZE)],
703-
const struct pubkey *next_blinding)
705+
const struct pubkey *next_blinding,
706+
const bool endorsed)
704707
{
705708
const u8 *failmsg;
706709
struct lightningd *ld = hin->key.channel->peer->ld;
@@ -811,7 +814,7 @@ static void forward_htlc(struct htlc_in *hin,
811814
outgoing_cltv_value, AMOUNT_MSAT(0),
812815
&hin->payment_hash,
813816
next_blinding, 0 /* partid */, 0 /* groupid */,
814-
next_onion, hin, &hout);
817+
next_onion, hin, &hout, endorsed);
815818
if (!failmsg)
816819
return;
817820

@@ -1144,7 +1147,7 @@ htlc_accepted_hook_final(struct htlc_accepted_hook_payload *request STEALS)
11441147
request->payload->forward_channel,
11451148
request->fwd_channel_id,
11461149
serialize_onionpacket(tmpctx, rs->next),
1147-
request->next_blinding);
1150+
request->next_blinding, false /*endorsed*/);
11481151
} else
11491152
handle_localpay(hin,
11501153
request->payload->amt_to_forward,
@@ -1184,6 +1187,7 @@ static bool ecdh_maybe_blinding(const struct pubkey *ephemeral_key,
11841187
return true;
11851188
}
11861189

1190+
// FIXME: this is the way to implement the hook
11871191
REGISTER_PLUGIN_HOOK(htlc_accepted,
11881192
htlc_accepted_hook_deserialize,
11891193
htlc_accepted_hook_final,

lightningd/peer_htlcs.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ const u8 *send_htlc_out(const tal_t *ctx,
5050
u64 groupid,
5151
const u8 *onion_routing_packet,
5252
struct htlc_in *in,
53-
struct htlc_out **houtp);
53+
struct htlc_out **houtp,
54+
bool endorsed);
5455

5556
void onchain_failed_our_htlc(const struct channel *channel,
5657
const struct htlc_stub *htlc,

0 commit comments

Comments
 (0)