| 234 | #endif |
| 235 | |
| 236 | static void report_htlcs(const struct bitcoin_tx *tx, |
| 237 | const struct htlc **htlc_map, |
| 238 | u16 to_self_delay, |
| 239 | const struct privkey *local_htlcsecretkey, |
| 240 | const struct pubkey *localkey, |
| 241 | const struct pubkey *local_htlckey, |
| 242 | const struct pubkey *local_delayedkey, |
| 243 | const struct privkey *x_remote_htlcsecretkey, |
| 244 | const struct pubkey *remotekey, |
| 245 | const struct pubkey *remote_htlckey, |
| 246 | const struct pubkey *remote_revocation_key, |
| 247 | u32 feerate_per_kw, |
| 248 | bool option_anchor_outputs) |
| 249 | { |
| 250 | size_t i, n; |
| 251 | struct bitcoin_outpoint outpoint; |
| 252 | struct bitcoin_tx **htlc_tx; |
| 253 | struct bitcoin_signature *remotehtlcsig; |
| 254 | struct keyset keyset; |
| 255 | u8 **wscript; |
| 256 | |
| 257 | htlc_tx = tal_arrz(tmpctx, struct bitcoin_tx *, tal_count(htlc_map)); |
| 258 | remotehtlcsig = tal_arr(tmpctx, struct bitcoin_signature, |
| 259 | tal_count(htlc_map)); |
| 260 | wscript = tal_arr(tmpctx, u8 *, tal_count(htlc_map)); |
| 261 | |
| 262 | bitcoin_txid(tx, &outpoint.txid); |
| 263 | |
| 264 | /* First report remote signatures, in order we would receive them. */ |
| 265 | n = 0; |
| 266 | for (i = 0; i < tal_count(htlc_map); i++) |
| 267 | n += (htlc_map[i] != NULL); |
| 268 | |
| 269 | printf("num_htlcs: %zu\n", n); |
| 270 | |
| 271 | /* FIXME: naming here is kind of backwards: local revocation key |
| 272 | * is derived from remote revocation basepoint, but it's local */ |
| 273 | keyset.self_revocation_key = *remote_revocation_key; |
| 274 | keyset.self_delayed_payment_key = *local_delayedkey; |
| 275 | keyset.self_payment_key = *localkey; |
| 276 | keyset.other_payment_key = *remotekey; |
| 277 | keyset.self_htlc_key = *local_htlckey; |
| 278 | keyset.other_htlc_key = *remote_htlckey; |
| 279 | |
| 280 | for (i = 0; i < tal_count(htlc_map); i++) { |
| 281 | struct bitcoin_signature localhtlcsig; |
| 282 | const struct htlc *htlc = htlc_map[i]; |
| 283 | |
| 284 | if (!htlc) |
| 285 | continue; |
| 286 | |
| 287 | outpoint.n = i; |
| 288 | if (htlc_owner(htlc) == LOCAL) { |
| 289 | wscript[i] = bitcoin_wscript_htlc_offer(tmpctx, |
| 290 | local_htlckey, |
| 291 | remote_htlckey, |
| 292 | &htlc->rhash, |
| 293 | remote_revocation_key, |
no test coverage detected