| 3285 | } |
| 3286 | |
| 3287 | struct wallet_payment * |
| 3288 | wallet_payment_by_hash(const tal_t *ctx, struct wallet *wallet, |
| 3289 | const struct sha256 *payment_hash, |
| 3290 | u64 partid, u64 groupid) |
| 3291 | { |
| 3292 | struct db_stmt *stmt; |
| 3293 | struct wallet_payment *payment; |
| 3294 | |
| 3295 | /* Present the illusion that it's in the db... */ |
| 3296 | payment = find_unstored_payment(wallet, payment_hash, partid); |
| 3297 | if (payment) |
| 3298 | return payment; |
| 3299 | |
| 3300 | stmt = db_prepare_v2(wallet->db, SQL("SELECT" |
| 3301 | " id" |
| 3302 | ", status" |
| 3303 | ", destination" |
| 3304 | ", msatoshi" |
| 3305 | ", payment_hash" |
| 3306 | ", timestamp" |
| 3307 | ", payment_preimage" |
| 3308 | ", path_secrets" |
| 3309 | ", route_nodes" |
| 3310 | ", route_channels" |
| 3311 | ", msatoshi_sent" |
| 3312 | ", description" |
| 3313 | ", bolt11" |
| 3314 | ", paydescription" |
| 3315 | ", failonionreply" |
| 3316 | ", total_msat" |
| 3317 | ", partid" |
| 3318 | ", local_offer_id" |
| 3319 | ", groupid" |
| 3320 | ", completed_at" |
| 3321 | " FROM payments" |
| 3322 | " WHERE payment_hash = ?" |
| 3323 | " AND partid = ? AND groupid=?")); |
| 3324 | |
| 3325 | db_bind_sha256(stmt, 0, payment_hash); |
| 3326 | db_bind_u64(stmt, 1, partid); |
| 3327 | db_bind_u64(stmt, 2, groupid); |
| 3328 | db_query_prepared(stmt); |
| 3329 | if (db_step(stmt)) { |
| 3330 | payment = wallet_stmt2payment(ctx, stmt); |
| 3331 | } |
| 3332 | tal_free(stmt); |
| 3333 | return payment; |
| 3334 | } |
| 3335 | |
| 3336 | void wallet_payment_set_status(struct wallet *wallet, |
| 3337 | const struct sha256 *payment_hash, |