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

Function handle_onchain_init_reply

lightningd/onchain_control.c:103–138  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

101}
102
103static void handle_onchain_init_reply(struct channel *channel, const u8 *msg)
104{
105 struct htlc_stub *stubs;
106 u64 commit_num;
107 bool *tell, *tell_immediate;
108
109 if (!fromwire_onchaind_init_reply(msg, &commit_num)) {
110 channel_internal_error(channel, "Invalid onchaind_init_reply %s",
111 tal_hex(tmpctx, msg));
112 return;
113 }
114
115 /* FIXME: We may already be ONCHAIN state when we implement restart! */
116 channel_set_state(channel,
117 FUNDING_SPEND_SEEN,
118 ONCHAIN,
119 REASON_UNKNOWN,
120 "Onchain init reply");
121
122 /* Tell it about any relevant HTLCs */
123 /* FIXME: Filter by commitnum! */
124 stubs = wallet_htlc_stubs(tmpctx, channel->peer->ld->wallet, channel,
125 commit_num);
126 tell = tal_arr(stubs, bool, tal_count(stubs));
127 tell_immediate = tal_arr(stubs, bool, tal_count(stubs));
128
129 for (size_t i = 0; i < tal_count(stubs); i++) {
130 tell[i] = tell_if_missing(channel, &stubs[i],
131 &tell_immediate[i]);
132 }
133 msg = towire_onchaind_htlcs(channel, stubs, tell, tell_immediate);
134 subd_send_msg(channel->owner, take(msg));
135
136 /* Tell it about any preimages we know. */
137 onchaind_tell_fulfill(channel);
138}
139
140/**
141 * 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