| 99 | } |
| 100 | |
| 101 | static struct chain_event *stmt2chain_event(const tal_t *ctx, struct db_stmt *stmt) |
| 102 | { |
| 103 | struct chain_event *e = tal(ctx, struct chain_event); |
| 104 | e->db_id = db_col_u64(stmt, "e.id"); |
| 105 | e->acct_db_id = db_col_u64(stmt, "e.account_id"); |
| 106 | e->acct_name = db_col_strdup(e, stmt, "a.name"); |
| 107 | |
| 108 | if (!db_col_is_null(stmt, "e.origin")) |
| 109 | e->origin_acct = db_col_strdup(e, stmt, "e.origin"); |
| 110 | else |
| 111 | e->origin_acct = NULL; |
| 112 | |
| 113 | e->tag = db_col_strdup(e, stmt, "e.tag"); |
| 114 | |
| 115 | e->credit = db_col_amount_msat(stmt, "e.credit"); |
| 116 | e->debit = db_col_amount_msat(stmt, "e.debit"); |
| 117 | e->output_value = db_col_amount_msat(stmt, "e.output_value"); |
| 118 | |
| 119 | e->currency = db_col_strdup_optional(e, stmt, "e.currency"); |
| 120 | e->timestamp = db_col_u64(stmt, "e.timestamp"); |
| 121 | e->blockheight = db_col_int(stmt, "e.blockheight"); |
| 122 | |
| 123 | db_col_txid(stmt, "e.utxo_txid", &e->outpoint.txid); |
| 124 | e->outpoint.n = db_col_int(stmt, "e.outnum"); |
| 125 | |
| 126 | if (!db_col_is_null(stmt, "e.payment_id")) { |
| 127 | e->payment_id = tal(e, struct sha256); |
| 128 | db_col_sha256(stmt, "e.payment_id", e->payment_id); |
| 129 | } else |
| 130 | e->payment_id = NULL; |
| 131 | |
| 132 | if (!db_col_is_null(stmt, "e.spending_txid")) { |
| 133 | e->spending_txid = tal(e, struct bitcoin_txid); |
| 134 | db_col_txid(stmt, "e.spending_txid", e->spending_txid); |
| 135 | } else |
| 136 | e->spending_txid = NULL; |
| 137 | |
| 138 | /* If they ran master before this, ignored might be null! */ |
| 139 | if (db_col_is_null(stmt, "e.ignored")) |
| 140 | e->ignored = false; |
| 141 | else |
| 142 | e->ignored = db_col_int(stmt, "e.ignored") == 1; |
| 143 | e->stealable = db_col_int(stmt, "e.stealable") == 1; |
| 144 | |
| 145 | if (!db_col_is_null(stmt, "e.ev_desc")) |
| 146 | e->desc = db_col_strdup(e, stmt, "e.ev_desc"); |
| 147 | else |
| 148 | e->desc = NULL; |
| 149 | |
| 150 | e->splice_close = db_col_int(stmt, "e.spliced") == 1; |
| 151 | e->output_count = db_col_int(stmt, "a.closed_count"); |
| 152 | if (!db_col_is_null(stmt, "a.peer_id")) { |
| 153 | e->peer_id = tal(e, struct node_id); |
| 154 | db_col_node_id(stmt, "a.peer_id", e->peer_id); |
| 155 | } else |
| 156 | e->peer_id = NULL; |
| 157 | |
| 158 | e->we_opened = db_col_int(stmt, "a.we_opened"); |
no test coverage detected