| 535 | } |
| 536 | |
| 537 | struct account *find_close_account(const tal_t *ctx, |
| 538 | struct db *db, |
| 539 | struct bitcoin_txid *txid) |
| 540 | { |
| 541 | struct db_stmt *stmt; |
| 542 | struct account *close_acct; |
| 543 | char *acct_name; |
| 544 | |
| 545 | stmt = db_prepare_v2(db, SQL("SELECT" |
| 546 | " a.name" |
| 547 | " FROM chain_events e" |
| 548 | " LEFT OUTER JOIN accounts a" |
| 549 | " ON e.account_id = a.id" |
| 550 | " WHERE " |
| 551 | " e.tag = ?" |
| 552 | " AND e.spending_txid = ?")); |
| 553 | |
| 554 | db_bind_text(stmt, 0, mvt_tag_str(CHANNEL_CLOSE)); |
| 555 | db_bind_txid(stmt, 1, txid); |
| 556 | db_query_prepared(stmt); |
| 557 | |
| 558 | if (db_step(stmt)) { |
| 559 | acct_name = db_col_strdup(stmt, stmt, "a.name"); |
| 560 | close_acct = find_account(ctx, db, acct_name); |
| 561 | } else |
| 562 | close_acct = NULL; |
| 563 | |
| 564 | tal_free(stmt); |
| 565 | return close_acct; |
| 566 | } |
| 567 | |
| 568 | void maybe_mark_account_onchain(struct db *db, struct account *acct) |
| 569 | { |
no test coverage detected