| 2946 | } |
| 2947 | |
| 2948 | struct htlc_stub *wallet_htlc_stubs(const tal_t *ctx, struct wallet *wallet, |
| 2949 | struct channel *chan, u64 commit_num) |
| 2950 | { |
| 2951 | struct htlc_stub *stubs; |
| 2952 | struct sha256 payment_hash; |
| 2953 | struct db_stmt *stmt; |
| 2954 | |
| 2955 | stmt = db_prepare_v2(wallet->db, |
| 2956 | SQL("SELECT channel_id, direction, cltv_expiry, " |
| 2957 | "channel_htlc_id, payment_hash " |
| 2958 | "FROM channel_htlcs WHERE channel_id = ? AND min_commit_num <= ? AND ((max_commit_num IS NULL) OR max_commit_num >= ?);")); |
| 2959 | |
| 2960 | db_bind_u64(stmt, 0, chan->dbid); |
| 2961 | db_bind_u64(stmt, 1, commit_num); |
| 2962 | db_bind_u64(stmt, 2, commit_num); |
| 2963 | db_query_prepared(stmt); |
| 2964 | |
| 2965 | stubs = tal_arr(ctx, struct htlc_stub, 0); |
| 2966 | |
| 2967 | while (db_step(stmt)) { |
| 2968 | struct htlc_stub stub; |
| 2969 | |
| 2970 | assert(db_col_u64(stmt, "channel_id") == chan->dbid); |
| 2971 | |
| 2972 | /* FIXME: merge these two enums */ |
| 2973 | stub.owner = db_col_int(stmt, "direction")==DIRECTION_INCOMING?REMOTE:LOCAL; |
| 2974 | stub.cltv_expiry = db_col_int(stmt, "cltv_expiry"); |
| 2975 | stub.id = db_col_u64(stmt, "channel_htlc_id"); |
| 2976 | |
| 2977 | db_col_sha256(stmt, "payment_hash", &payment_hash); |
| 2978 | ripemd160(&stub.ripemd, payment_hash.u.u8, sizeof(payment_hash.u)); |
| 2979 | tal_arr_expand(&stubs, stub); |
| 2980 | } |
| 2981 | tal_free(stmt); |
| 2982 | return stubs; |
| 2983 | } |
| 2984 | |
| 2985 | void wallet_local_htlc_out_delete(struct wallet *wallet, |
| 2986 | struct channel *chan, |
no test coverage detected