| 697 | } |
| 698 | |
| 699 | static struct chain_event *find_chain_event(const tal_t *ctx, |
| 700 | struct db *db, |
| 701 | const struct account *acct, |
| 702 | const struct bitcoin_outpoint *outpoint, |
| 703 | const struct bitcoin_txid *spending_txid, |
| 704 | const char *tag) |
| 705 | |
| 706 | { |
| 707 | struct db_stmt *stmt; |
| 708 | struct chain_event *e; |
| 709 | |
| 710 | if (spending_txid) { |
| 711 | stmt = db_prepare_v2(db, SQL("SELECT" |
| 712 | " e.id" |
| 713 | ", e.account_id" |
| 714 | ", a.name" |
| 715 | ", e.origin" |
| 716 | ", e.tag" |
| 717 | ", e.credit" |
| 718 | ", e.debit" |
| 719 | ", e.output_value" |
| 720 | ", e.currency" |
| 721 | ", e.timestamp" |
| 722 | ", e.blockheight" |
| 723 | ", e.utxo_txid" |
| 724 | ", e.outnum" |
| 725 | ", e.spending_txid" |
| 726 | ", e.payment_id" |
| 727 | ", e.ignored" |
| 728 | ", e.stealable" |
| 729 | ", e.ev_desc" |
| 730 | " FROM chain_events e" |
| 731 | " LEFT OUTER JOIN accounts a" |
| 732 | " ON e.account_id = a.id" |
| 733 | " WHERE " |
| 734 | " e.account_id = ?" |
| 735 | " AND e.utxo_txid = ?" |
| 736 | " AND e.outnum = ?" |
| 737 | " AND e.spending_txid = ?")); |
| 738 | db_bind_txid(stmt, 3, spending_txid); |
| 739 | } else { |
| 740 | stmt = db_prepare_v2(db, SQL("SELECT" |
| 741 | " e.id" |
| 742 | ", e.account_id" |
| 743 | ", a.name" |
| 744 | ", e.origin" |
| 745 | ", e.tag" |
| 746 | ", e.credit" |
| 747 | ", e.debit" |
| 748 | ", e.output_value" |
| 749 | ", e.currency" |
| 750 | ", e.timestamp" |
| 751 | ", e.blockheight" |
| 752 | ", e.utxo_txid" |
| 753 | ", e.outnum" |
| 754 | ", e.spending_txid" |
| 755 | ", e.payment_id" |
| 756 | ", e.ignored" |
no test coverage detected