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