commit_tx: keep permutation map.

This lets us map the HTLCs back to outputs when txs occur onchain.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2016-05-02 16:05:56 +09:30
parent 76cb195ea1
commit 7614e513bd
7 changed files with 26 additions and 17 deletions

View File

@@ -304,7 +304,8 @@ void queue_pkt_commit(struct peer *peer)
peer->anchor.index,
peer->anchor.satoshis,
&ci->revocation_hash,
ci->cstate);
ci->cstate,
&ci->map);
log_debug(peer->log, "Signing tx for %u/%u msatoshis, %zu/%zu htlcs",
ci->cstate->a.pay_msat,
@@ -693,7 +694,8 @@ Pkt *accept_pkt_commit(struct peer *peer, const Pkt *pkt)
peer->anchor.index,
peer->anchor.satoshis,
&ci->revocation_hash,
ci->cstate);
ci->cstate,
&ci->map);
/* BOLT #2:
*

View File

@@ -1330,7 +1330,8 @@ bool setup_first_commit(struct peer *peer)
peer->anchor.index,
peer->anchor.satoshis,
&peer->us.commit->revocation_hash,
peer->us.commit->cstate);
peer->us.commit->cstate,
&peer->us.commit->map);
peer->them.commit->tx = create_commit_tx(peer->them.commit,
&peer->them.finalkey,
@@ -1340,7 +1341,8 @@ bool setup_first_commit(struct peer *peer)
peer->anchor.index,
peer->anchor.satoshis,
&peer->them.commit->revocation_hash,
peer->them.commit->cstate);
peer->them.commit->cstate,
&peer->them.commit->map);
peer->us.staging_cstate = copy_funding(peer, peer->us.commit->cstate);
peer->them.staging_cstate = copy_funding(peer, peer->them.commit->cstate);

View File

@@ -63,6 +63,8 @@ struct commit_info {
struct channel_state *cstate;
/* Other side's signature for this commit tx. */
struct bitcoin_signature sig;
/* Map for permutation: see commit_tx.c */
int *map;
/* Revocation preimage (if known). */
struct sha256 *revocation_preimage;
};