2017-06-20 15:15:03 +09:30
|
|
|
/* 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-29 01:35:01 +09:30
|
|
|
#include <common/htlc_wire.h>
|
2017-06-20 15:15:03 +09:30
|
|
|
|
2018-02-19 11:36:12 +10:30
|
|
|
struct channel;
|
|
|
|
struct htlc_in;
|
2019-06-28 11:28:31 +09:30
|
|
|
struct htlc_in_map;
|
2018-02-19 11:36:12 +10:30
|
|
|
struct htlc_out;
|
2019-06-28 11:28:31 +09:30
|
|
|
struct htlc_out_map;
|
2018-02-19 11:36:12 +10:30
|
|
|
struct htlc_stub;
|
2018-02-21 07:29:09 +10:30
|
|
|
struct lightningd;
|
2019-07-08 19:36:47 +08:00
|
|
|
struct json_stream;
|
2018-02-19 11:36:12 +10:30
|
|
|
|
2017-06-20 15:34:03 +09:30
|
|
|
/* Get all HTLCs for a peer, to send in init message. */
|
2020-04-03 13:44:07 +10:30
|
|
|
const struct existing_htlc **peer_htlcs(const tal_t *ctx,
|
|
|
|
const struct channel *channel);
|
2017-06-20 15:34:03 +09:30
|
|
|
|
2018-02-21 07:29:09 +10:30
|
|
|
void free_htlcs(struct lightningd *ld, const struct channel *channel);
|
|
|
|
|
2018-02-12 20:43:04 +10:30
|
|
|
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 15:15:03 +09:30
|
|
|
|
2018-02-12 20:43:04 +10:30
|
|
|
void update_per_commit_point(struct channel *channel,
|
2017-06-20 15:45:03 +09:30
|
|
|
const struct pubkey *per_commitment_point);
|
|
|
|
|
2022-01-25 06:31:52 +10:30
|
|
|
/* Returns NULL on success, otherwise failmsg*/
|
2020-02-21 15:40:02 +10:30
|
|
|
const u8 *send_htlc_out(const tal_t *ctx,
|
|
|
|
struct channel *out,
|
|
|
|
struct amount_msat amount, u32 cltv,
|
2021-12-07 14:09:28 -06:00
|
|
|
struct amount_msat final_msat,
|
2020-02-21 15:40:02 +10:30
|
|
|
const struct sha256 *payment_hash,
|
2020-04-11 12:52:40 +09:30
|
|
|
const struct pubkey *blinding,
|
2020-02-21 15:40:02 +10:30
|
|
|
u64 partid,
|
2021-09-29 12:33:57 +02:00
|
|
|
u64 groupid,
|
2020-02-21 15:40:02 +10:30
|
|
|
const u8 *onion_routing_packet,
|
|
|
|
struct htlc_in *in,
|
2022-01-25 06:31:52 +10:30
|
|
|
struct htlc_out **houtp);
|
2017-08-23 11:25:16 +09:30
|
|
|
|
2018-02-12 20:43:04 +10:30
|
|
|
void onchain_failed_our_htlc(const struct channel *channel,
|
2017-09-27 06:32:47 +09:30
|
|
|
const struct htlc_stub *htlc,
|
2022-03-30 14:13:12 +10:30
|
|
|
const char *why,
|
|
|
|
bool should_exist);
|
2018-02-12 20:43:04 +10:30
|
|
|
void onchain_fulfilled_htlc(struct channel *channel,
|
|
|
|
const struct preimage *preimage);
|
2018-05-06 13:32:01 +00:00
|
|
|
|
|
|
|
void htlcs_notify_new_block(struct lightningd *ld, u32 height);
|
2018-08-22 12:03:32 +09:30
|
|
|
|
2019-12-12 10:09:10 +10:30
|
|
|
/* Only defined if COMPAT_V061 */
|
|
|
|
void fixup_htlcs_out(struct lightningd *ld);
|
2019-08-10 14:54:57 +09:30
|
|
|
|
2019-12-12 10:09:10 +10:30
|
|
|
void htlcs_resubmit(struct lightningd *ld,
|
2023-01-17 11:17:12 +10:30
|
|
|
struct htlc_in_map *unconnected_htlcs_in STEALS);
|
2018-09-03 10:38:53 +09:30
|
|
|
|
2019-04-11 09:38:55 +09:30
|
|
|
/* 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 15:38:39 +10:30
|
|
|
void local_fail_in_htlc(struct htlc_in *hin, const u8 *failmsg TAKES);
|
2020-02-27 14:17:16 +10:30
|
|
|
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 09:38:55 +09:30
|
|
|
|
2020-02-21 15:38:39 +10:30
|
|
|
/* Helper to create (common) WIRE_INCORRECT_OR_UNKNOWN_PAYMENT_DETAILS */
|
2020-07-20 15:19:52 +09:30
|
|
|
#define failmsg_incorrect_or_unknown(ctx, ld, hin) \
|
|
|
|
failmsg_incorrect_or_unknown_((ctx), (ld), (hin), __FILE__, __LINE__)
|
|
|
|
|
|
|
|
const u8 *failmsg_incorrect_or_unknown_(const tal_t *ctx,
|
|
|
|
struct lightningd *ld,
|
|
|
|
const struct htlc_in *hin,
|
|
|
|
const char *file, int line);
|
2017-06-20 15:15:03 +09:30
|
|
|
#endif /* LIGHTNING_LIGHTNINGD_PEER_HTLCS_H */
|