| 3396 | } |
| 3397 | |
| 3398 | void wallet_payment_get_failinfo(const tal_t *ctx, |
| 3399 | struct wallet *wallet, |
| 3400 | const struct sha256 *payment_hash, |
| 3401 | u64 partid, |
| 3402 | u64 groupid, |
| 3403 | /* outputs */ |
| 3404 | struct onionreply **failonionreply, |
| 3405 | bool *faildestperm, |
| 3406 | int *failindex, |
| 3407 | enum onion_wire *failcode, |
| 3408 | struct node_id **failnode, |
| 3409 | struct short_channel_id **failchannel, |
| 3410 | u8 **failupdate, |
| 3411 | char **faildetail, |
| 3412 | int *faildirection) |
| 3413 | { |
| 3414 | struct db_stmt *stmt; |
| 3415 | bool resb; |
| 3416 | |
| 3417 | stmt = db_prepare_v2(wallet->db, |
| 3418 | SQL("SELECT failonionreply, faildestperm" |
| 3419 | ", failindex, failcode" |
| 3420 | ", failnode, failscid" |
| 3421 | ", failupdate, faildetail, faildirection" |
| 3422 | " FROM payments" |
| 3423 | " WHERE payment_hash=? AND partid=? AND groupid=?;")); |
| 3424 | db_bind_sha256(stmt, 0, payment_hash); |
| 3425 | db_bind_u64(stmt, 1, partid); |
| 3426 | db_bind_u64(stmt, 2, groupid); |
| 3427 | db_query_prepared(stmt); |
| 3428 | resb = db_step(stmt); |
| 3429 | assert(resb); |
| 3430 | |
| 3431 | if (db_col_is_null(stmt, "failonionreply")) |
| 3432 | *failonionreply = NULL; |
| 3433 | else { |
| 3434 | *failonionreply = db_col_onionreply(ctx, stmt, "failonionreply"); |
| 3435 | } |
| 3436 | *faildestperm = db_col_int(stmt, "faildestperm") != 0; |
| 3437 | *failindex = db_col_int(stmt, "failindex"); |
| 3438 | *failcode = (enum onion_wire) db_col_int(stmt, "failcode"); |
| 3439 | if (db_col_is_null(stmt, "failnode")) |
| 3440 | *failnode = NULL; |
| 3441 | else { |
| 3442 | *failnode = tal(ctx, struct node_id); |
| 3443 | db_col_node_id(stmt, "failnode", *failnode); |
| 3444 | } |
| 3445 | if (db_col_is_null(stmt, "failscid")) { |
| 3446 | db_col_ignore(stmt, "faildirection"); |
| 3447 | *failchannel = NULL; |
| 3448 | } else { |
| 3449 | *failchannel = tal(ctx, struct short_channel_id); |
| 3450 | db_col_scid(stmt, "failscid", *failchannel); |
| 3451 | |
| 3452 | /* For pre-0.6.2 dbs, direction will be 0 */ |
| 3453 | *faildirection = db_col_int(stmt, "faildirection"); |
| 3454 | } |
| 3455 | if (db_col_is_null(stmt, "failupdate")) |
no test coverage detected