| 19 | |
| 20 | |
| 21 | static struct chain_event *stmt2chain_event(const tal_t *ctx, struct db_stmt *stmt) |
| 22 | { |
| 23 | struct chain_event *e = tal(ctx, struct chain_event); |
| 24 | e->db_id = db_col_u64(stmt, "e.id"); |
| 25 | e->acct_db_id = db_col_u64(stmt, "e.account_id"); |
| 26 | e->acct_name = db_col_strdup(e, stmt, "a.name"); |
| 27 | |
| 28 | if (!db_col_is_null(stmt, "e.origin")) |
| 29 | e->origin_acct = db_col_strdup(e, stmt, "e.origin"); |
| 30 | else |
| 31 | e->origin_acct = NULL; |
| 32 | |
| 33 | e->tag = db_col_strdup(e, stmt, "e.tag"); |
| 34 | |
| 35 | db_col_amount_msat(stmt, "e.credit", &e->credit); |
| 36 | db_col_amount_msat(stmt, "e.debit", &e->debit); |
| 37 | db_col_amount_msat(stmt, "e.output_value", &e->output_value); |
| 38 | |
| 39 | e->currency = db_col_strdup(e, stmt, "e.currency"); |
| 40 | e->timestamp = db_col_u64(stmt, "e.timestamp"); |
| 41 | e->blockheight = db_col_int(stmt, "e.blockheight"); |
| 42 | |
| 43 | db_col_txid(stmt, "e.utxo_txid", &e->outpoint.txid); |
| 44 | e->outpoint.n = db_col_int(stmt, "e.outnum"); |
| 45 | |
| 46 | if (!db_col_is_null(stmt, "e.payment_id")) { |
| 47 | e->payment_id = tal(e, struct sha256); |
| 48 | db_col_sha256(stmt, "e.payment_id", e->payment_id); |
| 49 | } else |
| 50 | e->payment_id = NULL; |
| 51 | |
| 52 | if (!db_col_is_null(stmt, "e.spending_txid")) { |
| 53 | e->spending_txid = tal(e, struct bitcoin_txid); |
| 54 | db_col_txid(stmt, "e.spending_txid", e->spending_txid); |
| 55 | } else |
| 56 | e->spending_txid = NULL; |
| 57 | |
| 58 | e->ignored = db_col_int(stmt, "e.ignored") == 1; |
| 59 | e->stealable = db_col_int(stmt, "e.stealable") == 1; |
| 60 | |
| 61 | if (!db_col_is_null(stmt, "e.ev_desc")) |
| 62 | e->desc = db_col_strdup(e, stmt, "e.ev_desc"); |
| 63 | else |
| 64 | e->desc = NULL; |
| 65 | |
| 66 | return e; |
| 67 | } |
| 68 | |
| 69 | static struct chain_event **find_chain_events(const tal_t *ctx, |
| 70 | struct db_stmt *stmt TAKES) |
no test coverage detected