| 2317 | } |
| 2318 | |
| 2319 | static void handle_peer_tx_sigs_msg(struct subd *dualopend, |
| 2320 | const u8 *msg) |
| 2321 | { |
| 2322 | struct wally_psbt *psbt; |
| 2323 | const struct wally_tx *wtx; |
| 2324 | struct lightningd *ld = dualopend->ld; |
| 2325 | struct channel *channel = dualopend->channel; |
| 2326 | struct channel_inflight *inflight; |
| 2327 | |
| 2328 | if (!fromwire_dualopend_funding_sigs(tmpctx, msg, &psbt)) { |
| 2329 | channel_internal_error(channel, |
| 2330 | "Bad DUALOPEND_FUNDING_SIGS: %s", |
| 2331 | tal_hex(tmpctx, msg)); |
| 2332 | return; |
| 2333 | } |
| 2334 | |
| 2335 | inflight = channel_current_inflight(channel); |
| 2336 | if (!inflight) { |
| 2337 | channel_internal_error(channel, |
| 2338 | "No inflight found for channel"); |
| 2339 | return; |
| 2340 | } |
| 2341 | |
| 2342 | /* Save that we've gotten their sigs. Sometimes |
| 2343 | * the peer doesn't send any sigs (no inputs), otherwise |
| 2344 | * we could just check the PSBT was finalized */ |
| 2345 | inflight->remote_tx_sigs = true; |
| 2346 | tal_wally_start(); |
| 2347 | if (wally_psbt_combine(inflight->funding_psbt, psbt) != WALLY_OK) { |
| 2348 | channel_internal_error(channel, |
| 2349 | "Unable to combine PSBTs: %s, %s", |
| 2350 | fmt_wally_psbt(tmpctx, |
| 2351 | inflight->funding_psbt), |
| 2352 | fmt_wally_psbt(tmpctx, |
| 2353 | psbt)); |
| 2354 | tal_wally_end(inflight->funding_psbt); |
| 2355 | return; |
| 2356 | } |
| 2357 | tal_wally_end(inflight->funding_psbt); |
| 2358 | wallet_inflight_save(ld->wallet, inflight); |
| 2359 | |
| 2360 | /* It's possible we haven't sent them our (empty) tx-sigs yet, |
| 2361 | * but we should be sending it soon... */ |
| 2362 | if (psbt_finalize(cast_const(struct wally_psbt *, |
| 2363 | inflight->funding_psbt)) |
| 2364 | && !inflight->tx_broadcast) { |
| 2365 | inflight->tx_broadcast = true; |
| 2366 | |
| 2367 | /* Saves the now finalized version of the psbt */ |
| 2368 | wallet_inflight_save(ld->wallet, inflight); |
| 2369 | wtx = psbt_final_tx(tmpctx, inflight->funding_psbt); |
| 2370 | if (!wtx) { |
| 2371 | channel_internal_error(channel, |
| 2372 | "Unable to extract final tx" |
| 2373 | " from PSBT %s", |
| 2374 | fmt_wally_psbt(tmpctx, |
| 2375 | inflight->funding_psbt)); |
| 2376 | return; |
no test coverage detected