| 131 | } |
| 132 | |
| 133 | struct bitcoin_tx *htlc_timeout_tx(const tal_t *ctx, |
| 134 | const struct chainparams *chainparams, |
| 135 | const struct bitcoin_outpoint *commit, |
| 136 | const u8 *commit_wscript, |
| 137 | struct amount_msat htlc_msatoshi, |
| 138 | u32 cltv_expiry, |
| 139 | u16 to_self_delay, |
| 140 | u32 feerate_per_kw, |
| 141 | const struct keyset *keyset, |
| 142 | bool option_anchor_outputs, |
| 143 | bool option_anchors_zero_fee_htlc_tx) |
| 144 | { |
| 145 | const u8 *htlc_wscript; |
| 146 | |
| 147 | htlc_wscript = bitcoin_wscript_htlc_tx(tmpctx, |
| 148 | to_self_delay, |
| 149 | &keyset->self_revocation_key, |
| 150 | &keyset->self_delayed_payment_key); |
| 151 | /* BOLT #3: |
| 152 | * * locktime: `0` for HTLC-success, `cltv_expiry` for HTLC-timeout |
| 153 | */ |
| 154 | return htlc_tx(ctx, chainparams, commit, |
| 155 | commit_wscript, |
| 156 | amount_msat_to_sat_round_down(htlc_msatoshi), |
| 157 | htlc_wscript, |
| 158 | htlc_timeout_fee(feerate_per_kw, |
| 159 | option_anchor_outputs, |
| 160 | option_anchors_zero_fee_htlc_tx), |
| 161 | cltv_expiry, |
| 162 | option_anchor_outputs, |
| 163 | option_anchors_zero_fee_htlc_tx); |
| 164 | } |
| 165 | |
| 166 | /* Fill in the witness for HTLC-timeout tx produced above. */ |
| 167 | void htlc_timeout_tx_add_witness(struct bitcoin_tx *htlc_timeout, |