| 680 | |
| 681 | |
| 682 | static bool |
| 683 | openchannel2_hook_deserialize(struct openchannel2_payload *payload, |
| 684 | const char *buffer, |
| 685 | const jsmntok_t *toks) |
| 686 | { |
| 687 | const u8 *shutdown_script; |
| 688 | const char *err; |
| 689 | struct subd *dualopend = payload->dualopend; |
| 690 | |
| 691 | /* If our daemon died, we're done */ |
| 692 | if (!dualopend) { |
| 693 | openchannel2_hook_cb(payload); |
| 694 | return false; |
| 695 | } |
| 696 | |
| 697 | const jsmntok_t *t_result = json_get_member(buffer, toks, "result"); |
| 698 | if (!t_result) |
| 699 | fatal("Plugin returned an invalid response to the" |
| 700 | " openchannel2 hook: %.*s", |
| 701 | json_tok_full_len(toks), |
| 702 | json_tok_full(buffer, toks)); |
| 703 | |
| 704 | if (json_tok_streq(buffer, t_result, "reject")) { |
| 705 | /* Should not have set any other fields if 'reject'ing */ |
| 706 | if (json_get_member(buffer, toks, "close_to")) |
| 707 | fatal("Plugin rejected openchannel2 but" |
| 708 | " also set close_to"); |
| 709 | if (json_get_member(buffer, toks, "psbt")) |
| 710 | fatal("Plugin rejected openchannel2 but" |
| 711 | " also set `psbt`"); |
| 712 | if (json_get_member(buffer, toks, "our_funding_msat")) |
| 713 | fatal("Plugin rejected openchannel2 but" |
| 714 | " also set `our_funding_psbt`"); |
| 715 | |
| 716 | const jsmntok_t *t_errmsg = json_get_member(buffer, toks, |
| 717 | "error_message"); |
| 718 | |
| 719 | if (t_errmsg) |
| 720 | payload->err_msg = json_strdup(payload, |
| 721 | buffer, t_errmsg); |
| 722 | else |
| 723 | payload->err_msg = ""; |
| 724 | |
| 725 | openchannel2_hook_cb(payload); |
| 726 | return false; |
| 727 | } else if (!json_tok_streq(buffer, t_result, "continue")) |
| 728 | fatal("Plugin returned an invalid response to the" |
| 729 | " openchannel2 hook: %.*s", |
| 730 | json_tok_full_len(toks), |
| 731 | json_tok_full(buffer, toks)); |
| 732 | |
| 733 | if (!hook_extract_psbt(payload, dualopend, buffer, toks, |
| 734 | "openchannel2", true, &payload->psbt)) |
| 735 | return false; |
| 736 | |
| 737 | shutdown_script = |
| 738 | hook_extract_shutdown_script(dualopend, buffer, toks); |
| 739 | if (shutdown_script && payload->our_shutdown_scriptpubkey) |
nothing calls this directly
no test coverage detected