| 1157 | } |
| 1158 | |
| 1159 | struct onchain_fee **account_onchain_fees(const tal_t *ctx, |
| 1160 | struct db *db, |
| 1161 | struct account *acct) |
| 1162 | { |
| 1163 | struct db_stmt *stmt; |
| 1164 | struct onchain_fee **results; |
| 1165 | |
| 1166 | stmt = db_prepare_v2(db, SQL("SELECT" |
| 1167 | " of.account_id" |
| 1168 | ", a.name" |
| 1169 | ", of.txid" |
| 1170 | ", of.credit" |
| 1171 | ", of.debit" |
| 1172 | ", of.currency" |
| 1173 | ", of.timestamp" |
| 1174 | ", of.update_count" |
| 1175 | " FROM onchain_fees of" |
| 1176 | " LEFT OUTER JOIN accounts a" |
| 1177 | " ON a.id = of.account_id" |
| 1178 | " WHERE of.account_id = ?;")); |
| 1179 | |
| 1180 | db_bind_u64(stmt, 0, acct->db_id); |
| 1181 | db_query_prepared(stmt); |
| 1182 | |
| 1183 | results = tal_arr(ctx, struct onchain_fee *, 0); |
| 1184 | while (db_step(stmt)) { |
| 1185 | struct onchain_fee *of = stmt2onchain_fee(results, stmt); |
| 1186 | tal_arr_expand(&results, of); |
| 1187 | } |
| 1188 | tal_free(stmt); |
| 1189 | |
| 1190 | return results; |
| 1191 | } |
| 1192 | |
| 1193 | struct account **list_accounts(const tal_t *ctx, struct db *db) |
| 1194 | { |