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>
|
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
|
|
|
|
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-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);
|
|
|
|
|
2018-02-12 11:13:04 +01:00
|
|
|
enum onion_type send_htlc_out(struct channel *out, u64 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
|
|
|
struct htlc_out *find_htlc_out_by_ripemd(const struct channel *channel,
|
2017-09-26 23:02:47 +02:00
|
|
|
const struct ripemd160 *ripemd160);
|
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);
|
2017-06-20 07:45:03 +02:00
|
|
|
#endif /* LIGHTNING_LIGHTNINGD_PEER_HTLCS_H */
|