| 370 | } |
| 371 | |
| 372 | struct utxo *wallet_utxo_get(const tal_t *ctx, struct wallet *w, |
| 373 | const struct bitcoin_outpoint *outpoint) |
| 374 | { |
| 375 | struct db_stmt *stmt; |
| 376 | struct utxo *utxo; |
| 377 | |
| 378 | stmt = db_prepare_v2(w->db, SQL("SELECT" |
| 379 | " prev_out_tx" |
| 380 | ", prev_out_index" |
| 381 | ", value" |
| 382 | ", type" |
| 383 | ", status" |
| 384 | ", keyindex" |
| 385 | ", channel_id" |
| 386 | ", peer_id" |
| 387 | ", commitment_point" |
| 388 | ", option_anchor_outputs" |
| 389 | ", confirmation_height" |
| 390 | ", spend_height" |
| 391 | ", scriptpubkey" |
| 392 | ", reserved_til" |
| 393 | ", csv_lock" |
| 394 | " FROM outputs" |
| 395 | " WHERE prev_out_tx = ?" |
| 396 | " AND prev_out_index = ?")); |
| 397 | |
| 398 | db_bind_txid(stmt, 0, &outpoint->txid); |
| 399 | db_bind_int(stmt, 1, outpoint->n); |
| 400 | |
| 401 | db_query_prepared(stmt); |
| 402 | |
| 403 | if (!db_step(stmt)) { |
| 404 | tal_free(stmt); |
| 405 | return NULL; |
| 406 | } |
| 407 | |
| 408 | utxo = wallet_stmt2output(ctx, stmt); |
| 409 | tal_free(stmt); |
| 410 | |
| 411 | return utxo; |
| 412 | } |
| 413 | |
| 414 | static void db_set_utxo(struct db *db, const struct utxo *utxo) |
| 415 | { |
no test coverage detected