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

Function remember_channel_utxos

plugins/funder.c:212–246  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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