| 128 | } |
| 129 | |
| 130 | static 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. |
no test coverage detected