FIXME: We could cache this. */
| 81 | |
| 82 | /* FIXME: We could cache this. */ |
| 83 | struct bitcoin_tx *initial_channel_tx(const tal_t *ctx, |
| 84 | const u8 **wscript, |
| 85 | const struct channel *channel, |
| 86 | const struct pubkey *per_commitment_point, |
| 87 | enum side side, |
| 88 | struct wally_tx_output *direct_outputs[NUM_SIDES], |
| 89 | char** err_reason) |
| 90 | { |
| 91 | struct keyset keyset; |
| 92 | struct bitcoin_tx *init_tx; |
| 93 | u32 csv_lock; |
| 94 | |
| 95 | /* This assumes no HTLCs! */ |
| 96 | assert(!channel->htlcs); |
| 97 | |
| 98 | if (!derive_keyset(per_commitment_point, |
| 99 | &channel->basepoints[side], |
| 100 | &channel->basepoints[!side], |
| 101 | channel_has(channel, OPT_STATIC_REMOTEKEY), |
| 102 | &keyset)) { |
| 103 | *err_reason = "Cannot derive keyset"; |
| 104 | return NULL; |
| 105 | } |
| 106 | |
| 107 | /* Figure out the csv_lock (if there's a lease) */ |
| 108 | if (channel->lease_expiry == 0) |
| 109 | csv_lock = 1; |
| 110 | else |
| 111 | /* For the initial commitment, starts max lease */ |
| 112 | csv_lock = channel->lease_expiry |
| 113 | - get_blockheight(channel->blockheight_states, |
| 114 | channel->opener, |
| 115 | side); |
| 116 | |
| 117 | *wscript = bitcoin_redeem_2of2(ctx, |
| 118 | &channel->funding_pubkey[side], |
| 119 | &channel->funding_pubkey[!side]); |
| 120 | |
| 121 | init_tx = initial_commit_tx(ctx, &channel->funding, |
| 122 | channel->funding_sats, |
| 123 | channel->funding_pubkey, |
| 124 | channel->opener, |
| 125 | /* They specify our to_self_delay and v.v. */ |
| 126 | channel->config[!side].to_self_delay, |
| 127 | &keyset, |
| 128 | channel_feerate(channel, side), |
| 129 | channel->config[side].dust_limit, |
| 130 | channel->view[side].owed[side], |
| 131 | channel->view[side].owed[!side], |
| 132 | channel->config[!side].channel_reserve, |
| 133 | 0 ^ channel->commitment_number_obscurer, |
| 134 | direct_outputs, |
| 135 | side, csv_lock, |
| 136 | channel_has(channel, OPT_ANCHOR_OUTPUTS), |
| 137 | err_reason); |
| 138 | |
| 139 | if (init_tx) { |
| 140 | psbt_input_add_pubkey(init_tx->psbt, 0, |
no test coverage detected