| 913 | } |
| 914 | |
| 915 | static bool |
| 916 | openchannel2_signed_deserialize(struct openchannel2_psbt_payload *payload, |
| 917 | const char *buffer, const jsmntok_t *toks) |
| 918 | { |
| 919 | struct subd *dualopend = payload->dualopend; |
| 920 | struct wally_psbt *psbt; |
| 921 | |
| 922 | if (!hook_extract_psbt(NULL, dualopend, buffer, |
| 923 | toks, "openchannel2_sign", |
| 924 | false, &psbt)) |
| 925 | return false; |
| 926 | |
| 927 | /* We require the PSBT to meet certain criteria such as |
| 928 | * extra, proprietary fields (`serial_id`s) or |
| 929 | * to have a `redeemscripts` iff the inputs are P2SH. |
| 930 | * |
| 931 | * Since this is externally provided, we confirm that |
| 932 | * they've done the right thing / haven't lost any required info. |
| 933 | */ |
| 934 | if (!psbt_has_required_fields(psbt)) |
| 935 | fatal("Plugin supplied PSBT that's missing required fields. %s", |
| 936 | fmt_wally_psbt(tmpctx, psbt)); |
| 937 | |
| 938 | /* NOTE - The psbt_contribs_changed function nulls lots of |
| 939 | * fields in place to compare the PSBTs. This removes the |
| 940 | * witness stack held in final_witness. Give it a clone of |
| 941 | * the PSBT to hack on instead ... */ |
| 942 | struct wally_psbt *psbt_clone; |
| 943 | psbt_clone = clone_psbt(tmpctx, psbt); |
| 944 | |
| 945 | /* Verify that inputs/outputs are the same. Note that this is a |
| 946 | * 'de minimus' check -- we just look at serial_ids. If you've |
| 947 | * totally managled the data here but left the serial_ids intact, |
| 948 | * you'll get a failure back from the peer when you send |
| 949 | * commitment sigs */ |
| 950 | if (psbt_contribs_changed(payload->psbt, psbt_clone)) |
| 951 | fatal("Plugin must not change psbt input/output set. " |
| 952 | "orig: %s. updated: %s", |
| 953 | fmt_wally_psbt(tmpctx, payload->psbt), |
| 954 | fmt_wally_psbt(tmpctx, psbt)); |
| 955 | |
| 956 | if (payload->psbt) |
| 957 | tal_free(payload->psbt); |
| 958 | |
| 959 | payload->psbt = tal_steal(payload, psbt); |
| 960 | return true; |
| 961 | } |
| 962 | |
| 963 | static void dualopend_tell_depth(struct channel *channel, |
| 964 | const struct bitcoin_txid *txid, |
nothing calls this directly
no test coverage detected