mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-11-19 01:43:36 +01:00
6e28412f8f
Some paths were still sending unencrypted failure messages; unify them all. We need to keep the fail_msg around for resubmission if the channeld dies; similarly, we need to keep the htlc_end structure itself after failure, in case the failed HTLC is committed: we can move it to a minimal archive once it's flushed from both sides, however. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
68 lines
1.8 KiB
C
68 lines
1.8 KiB
C
#ifndef LIGHTNING_LIGHTNINGD_HTLC_END_H
|
|
#define LIGHTNING_LIGHTNINGD_HTLC_END_H
|
|
#include "config.h"
|
|
#include <ccan/htable/htable_type.h>
|
|
#include <ccan/short_types/short_types.h>
|
|
#include <lightningd/sphinx.h>
|
|
|
|
/* A HTLC has a source and destination: if other is NULL, it's this node.
|
|
*
|
|
* The main daemon simply shuffles them back and forth.
|
|
*/
|
|
enum htlc_end_type { HTLC_SRC, HTLC_DST };
|
|
|
|
struct htlc_end {
|
|
enum htlc_end_type which_end;
|
|
struct peer *peer;
|
|
u64 htlc_id;
|
|
u64 msatoshis;
|
|
|
|
struct htlc_end *other_end;
|
|
/* If this is driven by a command. */
|
|
struct pay_command *pay_command;
|
|
|
|
/* Temporary information, while we resolve the next hop */
|
|
u8 next_onion[TOTAL_PACKET_SIZE];
|
|
struct short_channel_id next_channel;
|
|
u64 amt_to_forward;
|
|
u32 outgoing_cltv_value;
|
|
u32 cltv_expiry;
|
|
struct sha256 payment_hash;
|
|
|
|
/* If we failed HTLC, here's the message. */
|
|
const u8 *fail_msg;
|
|
|
|
/* If we are forwarding, remember the shared secret for an
|
|
* eventual reply */
|
|
struct secret *shared_secret;
|
|
|
|
/* If we are the origin, remember all shared secrets, so we
|
|
* can unwrap an eventual reply */
|
|
struct secret *path_secrets;
|
|
};
|
|
|
|
static inline const struct htlc_end *keyof_htlc_end(const struct htlc_end *e)
|
|
{
|
|
return e;
|
|
}
|
|
|
|
size_t hash_htlc_end(const struct htlc_end *e);
|
|
|
|
static inline bool htlc_end_eq(const struct htlc_end *a,
|
|
const struct htlc_end *b)
|
|
{
|
|
return a->peer == b->peer
|
|
&& a->htlc_id == b->htlc_id
|
|
&& a->which_end == b->which_end;
|
|
}
|
|
HTABLE_DEFINE_TYPE(struct htlc_end, keyof_htlc_end, hash_htlc_end, htlc_end_eq,
|
|
htlc_end_map);
|
|
|
|
struct htlc_end *find_htlc_end(const struct htlc_end_map *map,
|
|
const struct peer *peer,
|
|
u64 htlc_id,
|
|
enum htlc_end_type which_end);
|
|
|
|
void connect_htlc_end(struct htlc_end_map *map, struct htlc_end *hend);
|
|
#endif /* LIGHTNING_LIGHTNINGD_HTLC_END_H */
|