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

Function perform_openchannel_update

plugins/spender/openchannel.c:804–893  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

802}
803
804struct command_result *
805perform_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;

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