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;
|
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;
|
2017-11-21 04:44:35 +01:00
|
|
|
/* In transition, these can be different! */
|
|
|
|
u32 feerate_per_kw[NUM_SIDES];
|
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. */
|
|
|
|
void peer_htlcs(const tal_t *ctx,
|
2018-02-12 11:13:04 +01:00
|
|
|
const struct channel *channel,
|
2017-06-20 08:04:03 +02:00
|
|
|
struct added_htlc **htlcs,
|
2017-06-20 08:06:03 +02:00
|
|
|
enum htlc_state **htlc_states,
|
|
|
|
struct fulfilled_htlc **fulfilled_htlcs,
|
|
|
|
enum side **fulfilled_sides,
|
2018-02-08 02:24:46 +01:00
|
|
|
const struct failed_htlc ***failed_htlcs,
|
2017-06-20 08:06:03 +02:00
|
|
|
enum side **failed_sides);
|
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);
|
|
|
|
|
2019-02-21 04:45:55 +01:00
|
|
|
enum onion_type send_htlc_out(struct channel *out,
|
|
|
|
struct amount_msat amount, u32 cltv,
|
2017-06-20 08:14:03 +02:00
|
|
|
const struct sha256 *payment_hash,
|
|
|
|
const u8 *onion_routing_packet,
|
|
|
|
struct htlc_in *in,
|
|
|
|
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,
|
|
|
|
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
|
|
|
|
2018-09-03 03:08:53 +02:00
|
|
|
void htlcs_reconnect(struct lightningd *ld,
|
|
|
|
struct htlc_in_map *htlcs_in,
|
|
|
|
struct htlc_out_map *htlcs_out);
|
|
|
|
|
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);
|
|
|
|
void fail_htlc(struct htlc_in *hin, enum onion_type failcode);
|
|
|
|
|
2017-06-20 07:45:03 +02:00
|
|
|
#endif /* LIGHTNING_LIGHTNINGD_PEER_HTLCS_H */
|