| 917 | } |
| 918 | |
| 919 | static void |
| 920 | openchannel2_sign_hook_cb(struct openchannel2_psbt_payload *payload STEALS) |
| 921 | { |
| 922 | struct channel *channel = payload->channel; |
| 923 | struct channel_inflight *inflight; |
| 924 | struct bitcoin_txid txid; |
| 925 | u8 *msg; |
| 926 | |
| 927 | /* Whatever happens, we free the payload */ |
| 928 | tal_steal(tmpctx, payload); |
| 929 | |
| 930 | /* Finalize it, if not already. It shouldn't work entirely */ |
| 931 | psbt_finalize(payload->psbt); |
| 932 | |
| 933 | if (!psbt_side_finalized(payload->psbt, TX_ACCEPTER)) { |
| 934 | log_broken(channel->log, |
| 935 | "Plugin must return a 'psbt' with signatures " |
| 936 | "for their inputs %s", |
| 937 | type_to_string(tmpctx, |
| 938 | struct wally_psbt, |
| 939 | payload->psbt)); |
| 940 | msg = towire_dualopend_fail(NULL, "Peer error with PSBT" |
| 941 | " signatures."); |
| 942 | goto send_msg; |
| 943 | } |
| 944 | |
| 945 | inflight = channel_current_inflight(channel); |
| 946 | if (!inflight) { |
| 947 | log_broken(channel->log, |
| 948 | "No current channel inflight"); |
| 949 | msg = towire_dualopend_fail(NULL, "No current channel inflight"); |
| 950 | goto send_msg; |
| 951 | } |
| 952 | |
| 953 | /* Check that we've got the same / correct PSBT */ |
| 954 | psbt_txid(NULL, payload->psbt, &txid, NULL); |
| 955 | if (!bitcoin_txid_eq(&inflight->funding->outpoint.txid, &txid)) { |
| 956 | log_broken(channel->log, |
| 957 | "PSBT's txid does not match. %s != %s", |
| 958 | type_to_string(tmpctx, struct bitcoin_txid, |
| 959 | &txid), |
| 960 | type_to_string(tmpctx, struct bitcoin_txid, |
| 961 | &inflight->funding->outpoint.txid)); |
| 962 | msg = towire_dualopend_fail(NULL, "Peer error with PSBT" |
| 963 | " signatures."); |
| 964 | goto send_msg; |
| 965 | } |
| 966 | |
| 967 | /* Now that we've got the signed PSBT, save it */ |
| 968 | tal_free(inflight->funding_psbt); |
| 969 | inflight->funding_psbt = tal_steal(inflight, |
| 970 | cast_const(struct wally_psbt *, |
| 971 | payload->psbt)); |
| 972 | wallet_inflight_save(payload->ld->wallet, inflight); |
| 973 | channel_watch_funding(payload->ld, channel); |
| 974 | msg = towire_dualopend_send_tx_sigs(NULL, inflight->funding_psbt); |
| 975 | |
| 976 | send_msg: |
nothing calls this directly
no test coverage detected