coin moves: stash the payment hash for onchaind in tracked_output

We'll use it when we record 'onchain' htlc movements that are fulfilled
This commit is contained in:
lisa neigut 2020-04-01 21:31:28 -05:00 committed by Rusty Russell
parent 6914adf861
commit 175515b914

View file

@ -117,6 +117,9 @@ struct tracked_output {
struct resolution *resolved; struct resolution *resolved;
const struct chainparams *chainparams; const struct chainparams *chainparams;
/* stashed so we can pass it along to the coin ledger */
struct sha256 *payment_hash;
}; };
/* We vary feerate until signature they offered matches. */ /* We vary feerate until signature they offered matches. */
@ -928,6 +931,10 @@ static void handle_htlc_onchain_fulfill(struct tracked_output *out,
type_to_string(tmpctx, struct ripemd160, type_to_string(tmpctx, struct ripemd160,
&out->htlc.ripemd)); &out->htlc.ripemd));
/* we stash the payment_hash into the tracking_output so we
* can pass it along, if needbe, to the coin movement tracker */
out->payment_hash = tal_dup(out, struct sha256, &sha);
/* Tell master we found a preimage. */ /* Tell master we found a preimage. */
status_debug("%s/%s gave us preimage %s", status_debug("%s/%s gave us preimage %s",
tx_type_name(out->tx_type), tx_type_name(out->tx_type),
@ -1272,6 +1279,9 @@ static void handle_preimage(const struct chainparams *chainparams,
return; return;
} }
/* stash the payment_hash so we can track this coin movement */
outs[i]->payment_hash = tal_dup(outs[i], struct sha256, &sha);
/* Discard any previous resolution. Could be a timeout, /* Discard any previous resolution. Could be a timeout,
* could be due to multiple identical rhashes in tx. */ * could be due to multiple identical rhashes in tx. */
outs[i]->proposal = tal_free(outs[i]->proposal); outs[i]->proposal = tal_free(outs[i]->proposal);