| 4229 | } |
| 4230 | |
| 4231 | struct wallet_payment *payment_get_details(const tal_t *ctx, |
| 4232 | struct db_stmt *stmt) |
| 4233 | { |
| 4234 | struct wallet_payment *payment; |
| 4235 | u32 *completed_at; |
| 4236 | struct sha256 payment_hash; |
| 4237 | |
| 4238 | db_col_sha256(stmt, "payment_hash", &payment_hash); |
| 4239 | |
| 4240 | if (!db_col_is_null(stmt, "completed_at")) { |
| 4241 | completed_at = tal(tmpctx, u32); |
| 4242 | *completed_at = db_col_int(stmt, "completed_at"); |
| 4243 | } else |
| 4244 | completed_at = NULL; |
| 4245 | |
| 4246 | payment = wallet_payment_new(ctx, |
| 4247 | db_col_u64(stmt, "id"), |
| 4248 | db_col_u64(stmt, "updated_index"), |
| 4249 | db_col_int(stmt, "timestamp"), |
| 4250 | completed_at, |
| 4251 | &payment_hash, |
| 4252 | db_col_is_null(stmt, "partid") ? 0 : db_col_u64(stmt, "partid"), |
| 4253 | db_col_u64(stmt, "groupid"), |
| 4254 | payment_status_in_db(db_col_int(stmt, "status")), |
| 4255 | take(db_col_optional(NULL, stmt, "destination", node_id)), |
| 4256 | db_col_amount_msat(stmt, "msatoshi"), |
| 4257 | db_col_amount_msat(stmt, "msatoshi_sent"), |
| 4258 | db_col_is_null(stmt, "total_msat") ? AMOUNT_MSAT(0) : db_col_amount_msat(stmt, "total_msat"), |
| 4259 | take(db_col_optional(NULL, stmt, "payment_preimage", preimage)), |
| 4260 | take(db_col_secret_arr(NULL, stmt, "path_secrets")), |
| 4261 | take(db_col_node_id_arr(NULL, stmt, "route_nodes")), |
| 4262 | take(db_col_short_channel_id_arr(NULL, stmt, "route_channels")), |
| 4263 | take(db_col_strdup_optional(NULL, stmt, "bolt11")), |
| 4264 | take(db_col_strdup_optional(NULL, stmt, "description")), |
| 4265 | take(db_col_strdup_optional(NULL, stmt, "paydescription")), |
| 4266 | take(db_col_arr(NULL, stmt, "failonionreply", u8)), |
| 4267 | take(db_col_optional(NULL, stmt, "local_invreq_id", sha256))); |
| 4268 | |
| 4269 | /* Either none, or both are set */ |
| 4270 | assert(db_col_is_null(stmt, "route_nodes") |
| 4271 | == db_col_is_null(stmt, "route_channels")); |
| 4272 | return payment; |
| 4273 | } |
| 4274 | |
| 4275 | struct wallet_payment * |
| 4276 | wallet_payment_by_hash(const tal_t *ctx, struct wallet *wallet, |
no test coverage detected