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

Function handle_onchain_init_reply

lightningd/onchain_control.c:131–166  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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