| 1123 | } |
| 1124 | |
| 1125 | struct account *find_account(const tal_t *ctx, |
| 1126 | struct db *db, |
| 1127 | const char *name) |
| 1128 | { |
| 1129 | struct db_stmt *stmt; |
| 1130 | struct account *a; |
| 1131 | |
| 1132 | stmt = db_prepare_v2(db, SQL("SELECT" |
| 1133 | " id" |
| 1134 | ", name" |
| 1135 | ", peer_id" |
| 1136 | ", opened_event_id" |
| 1137 | ", closed_event_id" |
| 1138 | ", onchain_resolved_block" |
| 1139 | ", is_wallet" |
| 1140 | ", we_opened" |
| 1141 | ", leased" |
| 1142 | ", closed_count" |
| 1143 | " FROM accounts" |
| 1144 | " WHERE name = ?")); |
| 1145 | |
| 1146 | db_bind_text(stmt, 0, name); |
| 1147 | db_query_prepared(stmt); |
| 1148 | |
| 1149 | if (db_step(stmt)) |
| 1150 | a = stmt2account(ctx, stmt); |
| 1151 | else |
| 1152 | a = NULL; |
| 1153 | |
| 1154 | tal_free(stmt); |
| 1155 | |
| 1156 | return a; |
| 1157 | } |
| 1158 | |
| 1159 | struct onchain_fee **account_onchain_fees(const tal_t *ctx, |
| 1160 | struct db *db, |