MCPcopy Create free account
hub / github.com/ElementsProject/lightning / new_initial_channel

Function new_initial_channel

common/initial_channel.c:13–80  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 8

new_full_channelFunction · 0.85
runFunction · 0.85
fundee_channelFunction · 0.85
revert_channel_stateFunction · 0.85
accepter_commitsFunction · 0.85
opener_commitsFunction · 0.85
mainFunction · 0.85

Calls 5

amount_sat_sub_msatFunction · 0.85
tal_freeFunction · 0.85
dup_fee_statesFunction · 0.85
dup_height_statesFunction · 0.85
commit_number_obscurerFunction · 0.70

Tested by

no test coverage detected