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"
|
|
|
|
#include <ccan/short_types/short_types.h>
|
2018-02-19 02:06:12 +01:00
|
|
|
#include <common/channel_config.h>
|
2017-08-28 18:02:01 +02:00
|
|
|
#include <common/derive_basepoints.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 forwarding;
|
|
|
|
struct json_stream;
|
2018-02-19 02:06:12 +01:00
|
|
|
|
2017-06-20 07:55:03 +02:00
|
|
|
/* FIXME: Define serialization primitive for this? */
|
|
|
|
struct channel_info {
|
|
|
|
struct channel_config their_config;
|
|
|
|
struct pubkey remote_fundingkey;
|
|
|
|
struct basepoints theirbase;
|
2017-08-23 03:55:16 +02:00
|
|
|
/* The old_remote_per_commit is for the locked-in remote commit_tx,
|
|
|
|
* and the remote_per_commit is for the commit_tx we're modifying now. */
|
2017-06-20 08:15:03 +02:00
|
|
|
struct pubkey remote_per_commit, old_remote_per_commit;
|
2019-12-12 18:18:25 +01:00
|
|
|
struct fee_states *fee_states;
|
2017-06-20 07:55:03 +02: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);
|
|
|
|
|
2020-02-27 05:12:17 +01:00
|
|
|
/* Returns NULL on success, otherwise failmsg (and sets *needs_update_appended)*/
|
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,
|
|
|
|
const struct sha256 *payment_hash,
|
2020-04-11 05:22:40 +02:00
|
|
|
const struct pubkey *blinding,
|
2020-02-21 06:10:02 +01:00
|
|
|
u64 partid,
|
|
|
|
const u8 *onion_routing_packet,
|
|
|
|
struct htlc_in *in,
|
2020-02-27 05:12:17 +01:00
|
|
|
struct htlc_out **houtp,
|
|
|
|
bool *needs_update_appended);
|
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,
|
|
|
|
const char *why);
|
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,
|
|
|
|
struct htlc_in_map *unconnected_htlcs_in);
|
2018-09-03 03:08:53 +02:00
|
|
|
|
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
|
|
|
|
2019-09-02 16:31:51 +02:00
|
|
|
/* This json process will be used as the serialize method for
|
|
|
|
* forward_event_notification_gen and be used in
|
|
|
|
* `listforwardings_add_forwardings()`. */
|
2019-07-08 13:36:47 +02:00
|
|
|
void json_format_forwarding_object(struct json_stream *response, const char *fieldname,
|
|
|
|
const struct forwarding *cur);
|
2020-02-21 06:08:39 +01:00
|
|
|
|
|
|
|
/* Helper to create (common) WIRE_INCORRECT_OR_UNKNOWN_PAYMENT_DETAILS */
|
|
|
|
const u8 *failmsg_incorrect_or_unknown(const tal_t *ctx,
|
2020-04-15 12:19:46 +02:00
|
|
|
struct lightningd *ld,
|
2020-02-21 06:08:39 +01:00
|
|
|
const struct htlc_in *hin);
|
2017-06-20 07:45:03 +02:00
|
|
|
#endif /* LIGHTNING_LIGHTNINGD_PEER_HTLCS_H */
|