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

Function handle_onchain_init_reply

lightningd/onchain_control.c:130–165  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

128}
129
130static void handle_onchain_init_reply(struct channel *channel, const u8 *msg)
131{
132 struct htlc_stub *stubs;
133 u64 commit_num;
134 bool *tell, *tell_immediate;
135
136 if (!fromwire_onchaind_init_reply(msg, &commit_num)) {
137 channel_internal_error(channel, "Invalid onchaind_init_reply %s",
138 tal_hex(tmpctx, msg));
139 return;
140 }
141
142 /* FIXME: We may already be ONCHAIN state when we implement restart! */
143 channel_set_state(channel,
144 FUNDING_SPEND_SEEN,
145 ONCHAIN,
146 REASON_UNKNOWN,
147 "Onchain init reply");
148
149 /* Tell it about any relevant HTLCs */
150 /* FIXME: Filter by commitnum! */
151 stubs = wallet_htlc_stubs(tmpctx, channel->peer->ld->wallet, channel,
152 commit_num);
153 tell = tal_arr(stubs, bool, tal_count(stubs));
154 tell_immediate = tal_arr(stubs, bool, tal_count(stubs));
155
156 for (size_t i = 0; i < tal_count(stubs); i++) {
157 tell[i] = tell_if_missing(channel, &stubs[i],
158 &tell_immediate[i]);
159 }
160 msg = towire_onchaind_htlcs(channel, stubs, tell, tell_immediate);
161 subd_send_msg(channel->owner, take(msg));
162
163 /* Tell it about any preimages we know. */
164 onchaind_tell_fulfill(channel);
165}
166
167/**
168 * Notify onchaind about the depth change of the watched tx.

Callers 1

onchain_msgFunction · 0.85

Calls 7

tal_hexFunction · 0.85
channel_set_stateFunction · 0.85
wallet_htlc_stubsFunction · 0.85
tell_if_missingFunction · 0.85
onchaind_tell_fulfillFunction · 0.85
channel_internal_errorFunction · 0.70
subd_send_msgFunction · 0.70

Tested by

no test coverage detected