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

Function remember_channel_utxos

plugins/funder.c:218–252  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

216}
217
218static struct command_result *
219remember_channel_utxos(struct command *cmd,
220 struct pending_open *open,
221 struct wally_psbt *signed_psbt)
222{
223 struct out_req *req;
224 u8 *utxos_bin;
225 char *chan_key = tal_fmt(cmd, "funder/%s",
226 fmt_channel_id(cmd,
227 &open->channel_id));
228
229 req = jsonrpc_request_start(cmd,
230 "datastore",
231 &datastore_add_success,
232 &datastore_add_fail,
233 signed_psbt);
234
235 utxos_bin = tal_arr(cmd, u8, 0);
236 for (size_t i = 0; i < signed_psbt->num_inputs; i++) {
237 struct bitcoin_outpoint outpoint;
238
239 /* Don't save peer's UTXOS */
240 if (!psbt_input_is_ours(&signed_psbt->inputs[i]))
241 continue;
242
243 wally_psbt_input_get_outpoint(&signed_psbt->inputs[i],
244 &outpoint);
245 towire_bitcoin_outpoint(&utxos_bin, &outpoint);
246 }
247 json_add_string(req->js, "key", chan_key);
248 /* We either update the existing or add a new one, nbd */
249 json_add_string(req->js, "mode", "create-or-replace");
250 json_add_hex(req->js, "hex", utxos_bin, tal_bytelen(utxos_bin));
251 return send_outreq(req);
252}
253
254static struct command_result *
255signpsbt_done(struct command *cmd,

Callers 1

signpsbt_doneFunction · 0.85

Calls 8

psbt_input_is_oursFunction · 0.85
towire_bitcoin_outpointFunction · 0.85
json_add_hexFunction · 0.85
tal_bytelenFunction · 0.85
send_outreqFunction · 0.70
fmt_channel_idFunction · 0.50
json_add_stringFunction · 0.50

Tested by

no test coverage detected