| 101 | } |
| 102 | |
| 103 | static 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. |
no test coverage detected