core-lightning/daemon/output_to_htlc.h
Rusty Russell ec3344ce6e daemon/output_to_htlc: routines to map outputs for HTLCs for a given commit_num.
And use this to resolve old transactions by comparing outputs with
HTLCs.

Rather than remembering the output ordering for every one of their
previous commitment transactions, we just remember the commitment
number for each commitment txid, and when we see it, derive all the
HTLC scriptpubkeys and the to-us and to-them scriptpubkeys, and figure
out which is which.

This avoids us having to save information on disk, except for the
txid->commitment-number mapping (and the shachain).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-08-18 14:23:45 +09:30

22 lines
670 B
C

#ifndef LIGHTNING_DAEMON_OUTPUT_TO_HTLC_H
#define LIGHTNING_DAEMON_OUTPUT_TO_HTLC_H
#include "config.h"
#include "htlc.h"
struct peer;
struct sha256;
/* Get a map of HTLCs (including at least those at the given commit_num). */
struct htlc_output_map *get_htlc_output_map(const tal_t *ctx,
const struct peer *peer,
const struct sha256 *rhash,
enum htlc_side side,
unsigned int commit_num);
/* If this scriptPubkey pays to a HTLC, get the full wscript */
struct htlc *txout_get_htlc(struct htlc_output_map *omap,
const u8 *script, size_t script_len,
const u8 **wscript);
#endif /* LIGHTNING_DAEMON_OUTPUT_TO_HTLC_H */