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

Function wallet_commit_channel

lightningd/opening_control.c:80–248  ·  view source on GitHub ↗

Steals fields from uncommitted_channel: returns NULL if can't generate a * key for this channel (shouldn't happen!). */

Source from the content-addressed store, hash-verified

78/* Steals fields from uncommitted_channel: returns NULL if can't generate a
79 * key for this channel (shouldn't happen!). */
80static struct channel *
81wallet_commit_channel(struct lightningd *ld,
82 struct uncommitted_channel *uc,
83 struct channel_id *cid,
84 struct bitcoin_tx *remote_commit,
85 struct bitcoin_signature *remote_commit_sig,
86 const struct bitcoin_outpoint *funding,
87 struct amount_sat funding_sats,
88 struct amount_msat push,
89 u8 channel_flags,
90 struct channel_info *channel_info,
91 u32 feerate,
92 const u8 *our_upfront_shutdown_script,
93 const u8 *remote_upfront_shutdown_script,
94 const struct channel_type *type)
95{
96 struct channel *channel;
97 struct amount_msat our_msat;
98 struct amount_sat local_funding;
99 s64 final_key_idx;
100 u64 static_remotekey_start;
101 u32 lease_start_blockheight = 0; /* No leases on v1 */
102 struct short_channel_id *alias_local;
103 struct timeabs timestamp;
104 bool any_active = peer_any_active_channel(uc->peer, NULL);
105
106 /* We cannot both be the fundee *and* have a `fundchannel_start`
107 * command running!
108 */
109 assert(!(uc->got_offer && uc->fc));
110
111 /* Get a key to use for closing outputs from this tx */
112 final_key_idx = wallet_get_newindex(ld);
113 if (final_key_idx == -1) {
114 log_broken(uc->log, "Can't get final key index");
115 return NULL;
116 }
117
118 if (uc->fc) {
119 if (!amount_sat_sub_msat(&our_msat, funding_sats, push)) {
120 log_broken(uc->log, "push %s exceeds funding %s",
121 type_to_string(tmpctx, struct amount_msat,
122 &push),
123 type_to_string(tmpctx, struct amount_sat,
124 &funding_sats));
125 return NULL;
126 }
127 local_funding = funding_sats;
128 } else {
129 our_msat = push;
130 local_funding = AMOUNT_SAT(0);
131 }
132
133 /* old_remote_per_commit not valid yet, copy valid one. */
134 channel_info->old_remote_per_commit = channel_info->remote_per_commit;
135
136 /* BOLT #2:
137 * 1. type: 35 (`funding_signed`)

Callers 2

opening_funder_finishedFunction · 0.70
opening_fundee_finishedFunction · 0.70

Calls 13

wallet_get_newindexFunction · 0.85
amount_sat_sub_msatFunction · 0.85
new_fee_statesFunction · 0.85
get_network_blockheightFunction · 0.85
wallet_channel_insertFunction · 0.85
time_nowFunction · 0.85
peer_any_active_channelFunction · 0.70
new_channelFunction · 0.70
try_reconnectFunction · 0.70
type_to_stringClass · 0.50
channel_type_hasFunction · 0.50

Tested by

no test coverage detected