MCPcopy Create free account
hub / github.com/ElementsProject/lightning / report_htlcs

Function report_htlcs

channeld/test/run-commit_tx.c:215–351  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

213#endif
214
215static void report_htlcs(const struct bitcoin_tx *tx,
216 const struct htlc **htlc_map,
217 u16 to_self_delay,
218 const struct privkey *local_htlcsecretkey,
219 const struct pubkey *localkey,
220 const struct pubkey *local_htlckey,
221 const struct pubkey *local_delayedkey,
222 const struct privkey *x_remote_htlcsecretkey,
223 const struct pubkey *remotekey,
224 const struct pubkey *remote_htlckey,
225 const struct pubkey *remote_revocation_key,
226 u32 feerate_per_kw,
227 bool option_anchor_outputs,
228 bool option_anchors_zero_fee_htlc_tx)
229{
230 size_t i, n;
231 struct bitcoin_outpoint outpoint;
232 struct bitcoin_tx **htlc_tx;
233 struct bitcoin_signature *remotehtlcsig;
234 struct keyset keyset;
235 u8 **wscript;
236
237 htlc_tx = tal_arrz(tmpctx, struct bitcoin_tx *, tal_count(htlc_map));
238 remotehtlcsig = tal_arr(tmpctx, struct bitcoin_signature,
239 tal_count(htlc_map));
240 wscript = tal_arr(tmpctx, u8 *, tal_count(htlc_map));
241
242 bitcoin_txid(tx, &outpoint.txid);
243
244 /* First report remote signatures, in order we would receive them. */
245 n = 0;
246 for (i = 0; i < tal_count(htlc_map); i++)
247 n += (htlc_map[i] != NULL);
248
249 printf("num_htlcs: %zu\n", n);
250
251 /* FIXME: naming here is kind of backwards: local revocation key
252 * is derived from remote revocation basepoint, but it's local */
253 keyset.self_revocation_key = *remote_revocation_key;
254 keyset.self_delayed_payment_key = *local_delayedkey;
255 keyset.self_payment_key = *localkey;
256 keyset.other_payment_key = *remotekey;
257 keyset.self_htlc_key = *local_htlckey;
258 keyset.other_htlc_key = *remote_htlckey;
259
260 for (i = 0; i < tal_count(htlc_map); i++) {
261 struct bitcoin_signature localhtlcsig;
262 const struct htlc *htlc = htlc_map[i];
263
264 if (!htlc)
265 continue;
266
267 outpoint.n = i;
268 if (htlc_owner(htlc) == LOCAL) {
269 wscript[i] = bitcoin_wscript_htlc_offer(tmpctx,
270 local_htlckey,
271 remote_htlckey,
272 &htlc->rhash,

Callers 1

reportFunction · 0.85

Calls 12

htlc_ownerFunction · 0.85
sign_tx_inputFunction · 0.85
tal_hexFunction · 0.85
linearize_txFunction · 0.85
bitcoin_txidClass · 0.70
htlc_timeout_txFunction · 0.50
htlc_success_txFunction · 0.50

Tested by

no test coverage detected