| 792 | } |
| 793 | |
| 794 | struct command_result * |
| 795 | perform_openchannel_update(struct multifundchannel_command *mfc) |
| 796 | { |
| 797 | size_t i, ready_count = 0; |
| 798 | |
| 799 | plugin_log(mfc->cmd->plugin, LOG_DBG, |
| 800 | "mfc %"PRIu64": parallel `openchannel_update`.", |
| 801 | mfc->id); |
| 802 | |
| 803 | /* First we check for failures/finished state */ |
| 804 | for (i = 0; i < tal_count(mfc->destinations); i++) { |
| 805 | struct multifundchannel_destination *dest; |
| 806 | dest = &mfc->destinations[i]; |
| 807 | |
| 808 | if (dest->state == MULTIFUNDCHANNEL_FAILED) |
| 809 | return redo_multifundchannel(mfc, |
| 810 | "openchannel_update", |
| 811 | dest->error_message); |
| 812 | |
| 813 | if (dest->state == MULTIFUNDCHANNEL_SECURED || |
| 814 | dest->state == MULTIFUNDCHANNEL_SIGNED) { |
| 815 | ready_count++; |
| 816 | continue; |
| 817 | } |
| 818 | |
| 819 | assert(dest->state == MULTIFUNDCHANNEL_UPDATED || |
| 820 | dest->state == MULTIFUNDCHANNEL_STARTED); |
| 821 | } |
| 822 | |
| 823 | /* Check if we can stop doing this and move to the next |
| 824 | * phase */ |
| 825 | if (ready_count == dest_count(mfc, OPEN_CHANNEL)) |
| 826 | return funding_transaction_established(mfc); |
| 827 | |
| 828 | /* Then, we update the parent with every node's result */ |
| 829 | for (i = 0; i < tal_count(mfc->destinations); i++) { |
| 830 | struct multifundchannel_destination *dest; |
| 831 | dest = &mfc->destinations[i]; |
| 832 | |
| 833 | if (!is_v2(dest)) |
| 834 | continue; |
| 835 | |
| 836 | if (!update_parent_psbt(mfc, dest, dest->psbt, |
| 837 | dest->updated_psbt, |
| 838 | &mfc->psbt)) { |
| 839 | fail_destination_msg(dest, FUNDING_PSBT_INVALID, |
| 840 | "Unable to update parent " |
| 841 | "with node's PSBT"); |
| 842 | return redo_multifundchannel(mfc, |
| 843 | "openchannel_init_parent", |
| 844 | dest->error_message); |
| 845 | } |
| 846 | /* Get everything sorted correctly */ |
| 847 | psbt_sort_by_serial_id(mfc->psbt); |
| 848 | |
| 849 | tal_free(dest->psbt); |
| 850 | dest->psbt = dest->updated_psbt; |
| 851 | dest->updated_psbt = NULL; |
no test coverage detected