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

Function splice_update_get_result

plugins/spender/splice.c:1014–1054  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1012}
1013
1014static struct command_result *splice_update_get_result(struct command *cmd,
1015 const char *methodname,
1016 const char *buf,
1017 const jsmntok_t *result,
1018 struct splice_index_pkg *pkg)
1019{
1020 size_t index = pkg->index;
1021 struct splice_cmd *splice_cmd = pkg->splice_cmd;
1022 struct splice_cmd_action_state *state = splice_cmd->states[index];
1023 const jsmntok_t *tok;
1024 struct wally_psbt *psbt;
1025 enum splice_cmd_state old_state = state->state;
1026 bool got_sigs;
1027
1028 tal_free(pkg);
1029
1030 /* DTODO: juggle serial ids correctly for cross-channel splice */
1031 tok = json_get_member(buf, result, "psbt");
1032 psbt = json_to_psbt(splice_cmd, buf, tok);
1033
1034 if (psbt_contribs_changed(splice_cmd->psbt, psbt))
1035 for (size_t i = 0; i < tal_count(splice_cmd->states); i++)
1036 if (splice_cmd->actions[i]->channel_id)
1037 splice_cmd->states[i]->state = SPLICE_CMD_UPDATE_NEEDS_CHANGES;
1038
1039 assert(psbt);
1040 tal_free(splice_cmd->psbt);
1041 splice_cmd->psbt = tal_steal(splice_cmd, psbt);
1042
1043 tok = json_get_member(buf, result, "signatures_secured");
1044 if (!json_to_bool(buf, tok, &got_sigs))
1045 return command_fail_badparam(cmd, "signatures_secured", buf,
1046 tok, "invalid bool");
1047
1048 if (old_state != SPLICE_CMD_UPDATE)
1049 state->state = SPLICE_CMD_UPDATE;
1050 else
1051 state->state = got_sigs ? SPLICE_CMD_RECVED_SIGS : SPLICE_CMD_UPDATE_DONE;
1052
1053 return continue_splice(splice_cmd->cmd, splice_cmd);
1054}
1055
1056static struct command_result *splice_update(struct command *cmd,
1057 struct splice_cmd *splice_cmd,

Callers

nothing calls this directly

Calls 7

tal_freeFunction · 0.85
json_get_memberFunction · 0.85
json_to_psbtFunction · 0.85
psbt_contribs_changedFunction · 0.85
continue_spliceFunction · 0.85
json_to_boolFunction · 0.50
command_fail_badparamFunction · 0.50

Tested by

no test coverage detected