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>
This commit is contained in:
Rusty Russell
2016-08-18 14:23:45 +09:30
parent 7c2165f5b4
commit ec3344ce6e
7 changed files with 388 additions and 202 deletions

View File

@@ -195,6 +195,8 @@ struct peer {
struct {
/* Everything (watches, resolved[], etc) tal'ed off this */
const struct bitcoin_tx *tx;
/* Set for STATE_CLOSE_ONCHAIN_THEIR_UNILATERAL
* and STATE_CLOSE_ONCHAIN_OUR_UNILATERAL */
const struct commit_info *ci;
const struct bitcoin_tx **resolved;
} closing_onchain;