| 668 | } |
| 669 | |
| 670 | static void |
| 671 | openchannel_hook_final(struct openchannel_hook_payload *payload STEALS) |
| 672 | { |
| 673 | struct subd *openingd = payload->openingd; |
| 674 | const u8 *our_upfront_shutdown_script = payload->our_upfront_shutdown_script; |
| 675 | const char *errmsg = payload->errmsg; |
| 676 | struct uncommitted_channel* uc = payload->uc; |
| 677 | u32 *upfront_shutdown_script_wallet_index; |
| 678 | |
| 679 | /* We want to free this, whatever happens. */ |
| 680 | tal_steal(tmpctx, payload); |
| 681 | |
| 682 | /* If openingd went away, don't send it anything! */ |
| 683 | if (!openingd) |
| 684 | return; |
| 685 | |
| 686 | tal_del_destructor2(openingd, openchannel_payload_remove_openingd, payload); |
| 687 | |
| 688 | if (!errmsg) { |
| 689 | /* Plugins accepted the offer, cancel any of our |
| 690 | * funder-side commands. */ |
| 691 | opening_funder_failed_cancel_commands(uc, |
| 692 | "Have in-progress " |
| 693 | "`open_channel` from " |
| 694 | "peer"); |
| 695 | uc->got_offer = true; |
| 696 | } |
| 697 | |
| 698 | /* Determine the wallet index for our_upfront_shutdown_script, |
| 699 | * NULL if not found. */ |
| 700 | u32 found_wallet_index; |
| 701 | bool is_p2sh; |
| 702 | if (wallet_can_spend(payload->openingd->ld->wallet, |
| 703 | our_upfront_shutdown_script, |
| 704 | &found_wallet_index, |
| 705 | &is_p2sh)) { |
| 706 | upfront_shutdown_script_wallet_index = tal(tmpctx, u32); |
| 707 | *upfront_shutdown_script_wallet_index = found_wallet_index; |
| 708 | } else |
| 709 | upfront_shutdown_script_wallet_index = NULL; |
| 710 | |
| 711 | subd_send_msg(openingd, |
| 712 | take(towire_openingd_got_offer_reply(NULL, errmsg, |
| 713 | our_upfront_shutdown_script, |
| 714 | upfront_shutdown_script_wallet_index, |
| 715 | payload->uc->reserve))); |
| 716 | } |
| 717 | |
| 718 | static bool |
| 719 | openchannel_hook_deserialize(struct openchannel_hook_payload *payload, |
no test coverage detected