| 227 | } |
| 228 | |
| 229 | static void add_htlcs(struct bitcoin_tx ***txs, |
| 230 | const struct htlc **htlcmap, |
| 231 | const struct channel *channel, |
| 232 | const struct keyset *keyset, |
| 233 | enum side side) |
| 234 | { |
| 235 | struct bitcoin_outpoint outpoint; |
| 236 | u32 htlc_feerate_per_kw; |
| 237 | bool option_anchor_outputs = channel_has(channel, OPT_ANCHOR_OUTPUTS_DEPRECATED); |
| 238 | bool option_anchors_zero_fee_htlc_tx = channel_has(channel, OPT_ANCHORS_ZERO_FEE_HTLC_TX); |
| 239 | |
| 240 | if (channel_has(channel, OPT_ANCHORS_ZERO_FEE_HTLC_TX)) |
| 241 | htlc_feerate_per_kw = 0; |
| 242 | else |
| 243 | htlc_feerate_per_kw = channel_feerate(channel, side); |
| 244 | |
| 245 | /* Get txid of commitment transaction */ |
| 246 | bitcoin_txid((*txs)[0], &outpoint.txid); |
| 247 | |
| 248 | for (outpoint.n = 0; outpoint.n < tal_count(htlcmap); outpoint.n++) { |
| 249 | const struct htlc *htlc = htlcmap[outpoint.n]; |
| 250 | struct bitcoin_tx *tx; |
| 251 | struct ripemd160 ripemd; |
| 252 | const u8 *wscript; |
| 253 | |
| 254 | if (!htlc) |
| 255 | continue; |
| 256 | |
| 257 | if (htlc_owner(htlc) == side) { |
| 258 | ripemd160(&ripemd, htlc->rhash.u.u8, sizeof(htlc->rhash.u.u8)); |
| 259 | wscript = htlc_offered_wscript(tmpctx, &ripemd, keyset, |
| 260 | option_anchor_outputs, |
| 261 | option_anchors_zero_fee_htlc_tx); |
| 262 | tx = htlc_timeout_tx(*txs, chainparams, &outpoint, |
| 263 | wscript, |
| 264 | htlc->amount, |
| 265 | htlc->expiry.locktime, |
| 266 | channel->config[!side].to_self_delay, |
| 267 | htlc_feerate_per_kw, |
| 268 | keyset, |
| 269 | option_anchor_outputs, |
| 270 | option_anchors_zero_fee_htlc_tx); |
| 271 | } else { |
| 272 | ripemd160(&ripemd, htlc->rhash.u.u8, sizeof(htlc->rhash.u.u8)); |
| 273 | wscript = htlc_received_wscript(tmpctx, &ripemd, |
| 274 | &htlc->expiry, keyset, |
| 275 | option_anchor_outputs, |
| 276 | option_anchors_zero_fee_htlc_tx); |
| 277 | tx = htlc_success_tx(*txs, chainparams, &outpoint, |
| 278 | wscript, |
| 279 | htlc->amount, |
| 280 | channel->config[!side].to_self_delay, |
| 281 | htlc_feerate_per_kw, |
| 282 | keyset, |
| 283 | option_anchor_outputs, |
| 284 | option_anchors_zero_fee_htlc_tx); |
| 285 | } |
| 286 |
no test coverage detected