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

Function json_sendpsbt

wallet/walletrpc.c:1153–1243  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1151}
1152
1153static struct command_result *json_sendpsbt(struct command *cmd,
1154 const char *buffer,
1155 const jsmntok_t *obj,
1156 const jsmntok_t *params)
1157{
1158 struct command_result *res;
1159 struct sending_psbt *sending;
1160 struct wally_psbt *psbt;
1161 struct lightningd *ld = cmd->ld;
1162 u32 *reserve_blocks;
1163 struct peer *p;
1164 struct peer_node_id_map_iter it;
1165
1166 if (!param_check(cmd, buffer, params,
1167 p_req("psbt", param_psbt, &psbt),
1168 p_opt_def("reserve", param_number, &reserve_blocks, 12 * 6),
1169 NULL))
1170 return command_param_failed();
1171
1172 sending = tal(cmd, struct sending_psbt);
1173 sending->cmd = cmd;
1174 sending->reserve_blocks = *reserve_blocks;
1175
1176 psbt_finalize(psbt);
1177 sending->wtx = psbt_final_tx(sending, psbt);
1178
1179 /* psbt contains info about which outputs are to external,
1180 * and thus need a coin_move issued for them. We only
1181 * notify if the transaction broadcasts */
1182 sending->psbt = tal_steal(sending, psbt);
1183
1184 if (!sending->wtx)
1185 return command_fail(cmd, LIGHTNINGD,
1186 "PSBT not finalizeable %s",
1187 fmt_wally_psbt(tmpctx, psbt));
1188
1189 /* We have to find/locate the utxos that are ours on this PSBT,
1190 * so that we know who to mark as used.
1191 */
1192 res = match_psbt_inputs_to_utxos(cmd, psbt, NULL, &sending->utxos);
1193 if (res)
1194 return res;
1195
1196 if (command_check_only(cmd))
1197 return command_check_done(cmd);
1198
1199 /* If this corresponds to one or more channels' PSBT, upgrade
1200 * those to signed versions! */
1201 for (p = peer_node_id_map_first(ld->peers, &it);
1202 p;
1203 p = peer_node_id_map_next(ld->peers, &it)) {
1204 struct channel *c;
1205
1206 list_for_each(&p->channels, c, list) {
1207 bool was_withheld;
1208
1209 if (!c->funding_psbt)
1210 continue;

Callers

nothing calls this directly

Calls 15

param_checkFunction · 0.85
psbt_finalizeFunction · 0.85
psbt_final_txFunction · 0.85
fmt_wally_psbtFunction · 0.85
psbt_is_finalizedFunction · 0.85
psbt_equivalentFunction · 0.85
tal_freeFunction · 0.85
clone_psbtFunction · 0.85
log_infoClass · 0.85
wallet_reserve_utxoFunction · 0.85
tal_hexFunction · 0.85

Tested by

no test coverage detected