2017-06-20 07:45:03 +02:00
|
|
|
/* All about the HTLCs/commitment transactions for a particular peer. */
|
|
|
|
#ifndef LIGHTNING_LIGHTNINGD_PEER_HTLCS_H
|
|
|
|
#define LIGHTNING_LIGHTNINGD_PEER_HTLCS_H
|
|
|
|
#include "config.h"
|
2017-08-28 18:05:01 +02:00
|
|
|
#include <common/htlc_wire.h>
|
2017-06-20 07:45:03 +02:00
|
|
|
|
2018-02-19 02:06:12 +01:00
|
|
|
struct channel;
|
|
|
|
struct htlc_in;
|
2019-06-28 03:58:31 +02:00
|
|
|
struct htlc_in_map;
|
2018-02-19 02:06:12 +01:00
|
|
|
struct htlc_out;
|
2019-06-28 03:58:31 +02:00
|
|
|
struct htlc_out_map;
|
2018-02-19 02:06:12 +01:00
|
|
|
struct htlc_stub;
|
2018-02-20 21:59:09 +01:00
|
|
|
struct lightningd;
|
2019-07-08 13:36:47 +02:00
|
|
|
struct json_stream;
|
2018-02-19 02:06:12 +01:00
|
|
|
|
2017-06-20 08:04:03 +02:00
|
|
|
/* Get all HTLCs for a peer, to send in init message. */
|
2020-04-03 05:14:07 +02:00
|
|
|
const struct existing_htlc **peer_htlcs(const tal_t *ctx,
|
|
|
|
const struct channel *channel);
|
2017-06-20 08:04:03 +02:00
|
|
|
|
2018-02-20 21:59:09 +01:00
|
|
|
void free_htlcs(struct lightningd *ld, const struct channel *channel);
|
|
|
|
|
2018-02-12 11:13:04 +01:00
|
|
|
void peer_sending_commitsig(struct channel *channel, const u8 *msg);
|
|
|
|
void peer_got_commitsig(struct channel *channel, const u8 *msg);
|
|
|
|
void peer_got_revoke(struct channel *channel, const u8 *msg);
|
2017-06-20 07:45:03 +02:00
|
|
|
|
2018-02-12 11:13:04 +01:00
|
|
|
void update_per_commit_point(struct channel *channel,
|
2017-06-20 08:15:03 +02:00
|
|
|
const struct pubkey *per_commitment_point);
|
|
|
|
|
2022-01-24 21:01:52 +01:00
|
|
|
/* Returns NULL on success, otherwise failmsg*/
|
2020-02-21 06:10:02 +01:00
|
|
|
const u8 *send_htlc_out(const tal_t *ctx,
|
|
|
|
struct channel *out,
|
|
|
|
struct amount_msat amount, u32 cltv,
|
2021-12-07 21:09:28 +01:00
|
|
|
struct amount_msat final_msat,
|
2020-02-21 06:10:02 +01:00
|
|
|
const struct sha256 *payment_hash,
|
2024-10-15 01:24:26 +02:00
|
|
|
const struct pubkey *path_key,
|
2020-02-21 06:10:02 +01:00
|
|
|
u64 partid,
|
2021-09-29 12:33:57 +02:00
|
|
|
u64 groupid,
|
2020-02-21 06:10:02 +01:00
|
|
|
const u8 *onion_routing_packet,
|
|
|
|
struct htlc_in *in,
|
2022-01-24 21:01:52 +01:00
|
|
|
struct htlc_out **houtp);
|
2017-08-23 03:55:16 +02:00
|
|
|
|
2018-02-12 11:13:04 +01:00
|
|
|
void onchain_failed_our_htlc(const struct channel *channel,
|
2017-09-26 23:02:47 +02:00
|
|
|
const struct htlc_stub *htlc,
|
2022-03-30 05:43:12 +02:00
|
|
|
const char *why,
|
|
|
|
bool should_exist);
|
2018-02-12 11:13:04 +01:00
|
|
|
void onchain_fulfilled_htlc(struct channel *channel,
|
|
|
|
const struct preimage *preimage);
|
2018-05-06 15:32:01 +02:00
|
|
|
|
|
|
|
void htlcs_notify_new_block(struct lightningd *ld, u32 height);
|
2018-08-22 04:33:32 +02:00
|
|
|
|
2019-12-12 00:39:10 +01:00
|
|
|
/* Only defined if COMPAT_V061 */
|
|
|
|
void fixup_htlcs_out(struct lightningd *ld);
|
2019-08-10 07:24:57 +02:00
|
|
|
|
2019-12-12 00:39:10 +01:00
|
|
|
void htlcs_resubmit(struct lightningd *ld,
|
2023-01-17 01:47:12 +01:00
|
|
|
struct htlc_in_map *unconnected_htlcs_in STEALS);
|
2018-09-03 03:08:53 +02:00
|
|
|
|
2024-10-22 04:59:47 +02:00
|
|
|
/* Apply tweak to ephemeral key if path_key is non-NULL, then do ECDH */
|
|
|
|
bool ecdh_maybe_blinding(const struct pubkey *ephemeral_key,
|
|
|
|
const struct pubkey *path_key,
|
|
|
|
struct secret *ss);
|
|
|
|
|
|
|
|
/* Select best (highest capacity) to peer. If hint is set, must match that
|
|
|
|
* feerate */
|
|
|
|
struct channel *best_channel(struct lightningd *ld,
|
|
|
|
const struct peer *next_peer,
|
|
|
|
struct amount_msat amt_to_forward,
|
|
|
|
const struct channel *hint);
|
|
|
|
|
2019-04-11 02:08:55 +02:00
|
|
|
/* For HTLCs which terminate here, invoice payment calls one of these. */
|
|
|
|
void fulfill_htlc(struct htlc_in *hin, const struct preimage *preimage);
|
2020-02-21 06:08:39 +01:00
|
|
|
void local_fail_in_htlc(struct htlc_in *hin, const u8 *failmsg TAKES);
|
2020-02-27 04:47:16 +01:00
|
|
|
void local_fail_in_htlc_needs_update(struct htlc_in *hin,
|
|
|
|
const u8 *failmsg_needs_update TAKES,
|
|
|
|
const struct short_channel_id *failmsg_scid);
|
2019-04-11 02:08:55 +02:00
|
|
|
|
2020-02-21 06:08:39 +01:00
|
|
|
/* Helper to create (common) WIRE_INCORRECT_OR_UNKNOWN_PAYMENT_DETAILS */
|
2024-10-22 02:39:46 +02:00
|
|
|
const u8 *failmsg_incorrect_or_unknown(const tal_t *ctx,
|
|
|
|
struct lightningd *ld,
|
|
|
|
struct amount_msat msat);
|
2017-06-20 07:45:03 +02:00
|
|
|
#endif /* LIGHTNING_LIGHTNINGD_PEER_HTLCS_H */
|