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

Function json_sendpsbt

wallet/walletrpc.c:1189–1279  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1187}
1188
1189static struct command_result *json_sendpsbt(struct command *cmd,
1190 const char *buffer,
1191 const jsmntok_t *obj,
1192 const jsmntok_t *params)
1193{
1194 struct command_result *res;
1195 struct sending_psbt *sending;
1196 struct wally_psbt *psbt;
1197 struct lightningd *ld = cmd->ld;
1198 u32 *reserve_blocks;
1199 struct peer *p;
1200 struct peer_node_id_map_iter it;
1201
1202 if (!param_check(cmd, buffer, params,
1203 p_req("psbt", param_psbt, &psbt),
1204 p_opt_def("reserve", param_number, &reserve_blocks, 12 * 6),
1205 NULL))
1206 return command_param_failed();
1207
1208 sending = tal(cmd, struct sending_psbt);
1209 sending->cmd = cmd;
1210 sending->reserve_blocks = *reserve_blocks;
1211
1212 psbt_finalize(psbt);
1213 sending->wtx = psbt_final_tx(sending, psbt);
1214
1215 /* psbt contains info about which outputs are to external,
1216 * and thus need a coin_move issued for them. We only
1217 * notify if the transaction broadcasts */
1218 sending->psbt = tal_steal(sending, psbt);
1219
1220 if (!sending->wtx)
1221 return command_fail(cmd, LIGHTNINGD,
1222 "PSBT not finalizeable %s",
1223 fmt_wally_psbt(tmpctx, psbt));
1224
1225 /* We have to find/locate the utxos that are ours on this PSBT,
1226 * so that we know who to mark as used.
1227 */
1228 res = match_psbt_inputs_to_utxos(cmd, psbt, NULL, &sending->utxos);
1229 if (res)
1230 return res;
1231
1232 if (command_check_only(cmd))
1233 return command_check_done(cmd);
1234
1235 /* If this corresponds to one or more channels' PSBT, upgrade
1236 * those to signed versions! */
1237 for (p = peer_node_id_map_first(ld->peers, &it);
1238 p;
1239 p = peer_node_id_map_next(ld->peers, &it)) {
1240 struct channel *c;
1241
1242 list_for_each(&p->channels, c, list) {
1243 bool was_withheld;
1244
1245 if (!c->funding_psbt)
1246 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