MCPcopy Create free account
hub / github.com/ElementsProject/lightning / perform_openchannel_update

Function perform_openchannel_update

plugins/spender/openchannel.c:794–882  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

792}
793
794struct command_result *
795perform_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;

Callers 2

Calls 12

redo_multifundchannelFunction · 0.85
dest_countFunction · 0.85
is_v2Function · 0.85
update_parent_psbtFunction · 0.85
fail_destination_msgFunction · 0.85
psbt_sort_by_serial_idFunction · 0.85
tal_freeFunction · 0.85
update_node_psbtFunction · 0.85
openchannel_update_destFunction · 0.85
plugin_logFunction · 0.50
command_still_pendingFunction · 0.50

Tested by

no test coverage detected