| 10 | #include <common/keyset.h> |
| 11 | |
| 12 | struct channel *new_initial_channel(const tal_t *ctx, |
| 13 | const struct channel_id *cid, |
| 14 | const struct bitcoin_outpoint *funding, |
| 15 | u32 minimum_depth, |
| 16 | const struct height_states *height_states TAKES, |
| 17 | u32 lease_expiry, |
| 18 | struct amount_sat funding_sats, |
| 19 | struct amount_msat local_msatoshi, |
| 20 | const struct fee_states *fee_states TAKES, |
| 21 | const struct channel_config *local, |
| 22 | const struct channel_config *remote, |
| 23 | const struct basepoints *local_basepoints, |
| 24 | const struct basepoints *remote_basepoints, |
| 25 | const struct pubkey *local_funding_pubkey, |
| 26 | const struct pubkey *remote_funding_pubkey, |
| 27 | const struct channel_type *type TAKES, |
| 28 | bool option_wumbo, |
| 29 | enum side opener) |
| 30 | { |
| 31 | struct channel *channel = tal(ctx, struct channel); |
| 32 | struct amount_msat remote_msatoshi; |
| 33 | |
| 34 | /* takes() if necessary */ |
| 35 | channel->fee_states = dup_fee_states(channel, fee_states); |
| 36 | |
| 37 | /* takes() if necessary */ |
| 38 | if (!height_states) |
| 39 | channel->blockheight_states = NULL; |
| 40 | else |
| 41 | channel->blockheight_states |
| 42 | = dup_height_states(channel, height_states); |
| 43 | |
| 44 | /* takes() if necessary */ |
| 45 | channel->type = tal_dup(channel, struct channel_type, type); |
| 46 | |
| 47 | channel->cid = *cid; |
| 48 | channel->funding = *funding; |
| 49 | channel->funding_sats = funding_sats; |
| 50 | channel->minimum_depth = minimum_depth; |
| 51 | channel->lease_expiry = lease_expiry; |
| 52 | if (!amount_sat_sub_msat(&remote_msatoshi, |
| 53 | channel->funding_sats, local_msatoshi)) |
| 54 | return tal_free(channel); |
| 55 | |
| 56 | channel->opener = opener; |
| 57 | channel->config[LOCAL] = *local; |
| 58 | channel->config[REMOTE] = *remote; |
| 59 | channel->funding_pubkey[LOCAL] = *local_funding_pubkey; |
| 60 | channel->funding_pubkey[REMOTE] = *remote_funding_pubkey; |
| 61 | channel->htlcs = NULL; |
| 62 | |
| 63 | channel->view[LOCAL].owed[LOCAL] |
| 64 | = channel->view[REMOTE].owed[LOCAL] |
| 65 | = local_msatoshi; |
| 66 | channel->view[REMOTE].owed[REMOTE] |
| 67 | = channel->view[LOCAL].owed[REMOTE] |
| 68 | = remote_msatoshi; |
| 69 |
no test coverage detected