| 210 | } |
| 211 | |
| 212 | static struct command_result * |
| 213 | remember_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 | |
| 248 | static struct command_result * |
| 249 | signpsbt_done(struct command *cmd, |
no test coverage detected