| 285 | } |
| 286 | |
| 287 | static struct onchain_fee **find_consolidated_fees(const tal_t *ctx, |
| 288 | struct db *db, |
| 289 | u64 start_time, |
| 290 | u64 end_time) |
| 291 | { |
| 292 | struct fee_sum **sums; |
| 293 | struct onchain_fee **fee_sums |
| 294 | = tal_arr(ctx, struct onchain_fee *, 0); |
| 295 | |
| 296 | sums = calculate_onchain_fee_sums(ctx, db); |
| 297 | |
| 298 | for (size_t i = 0; i < tal_count(sums); i++) { |
| 299 | /* Find the last matching feerate's data */ |
| 300 | struct onchain_fee *fee; |
| 301 | |
| 302 | if (amount_msat_zero(sums[i]->fees_paid)) |
| 303 | continue; |
| 304 | |
| 305 | fee = tal(fee_sums, struct onchain_fee); |
| 306 | fee->credit = sums[i]->fees_paid; |
| 307 | fee->debit = AMOUNT_MSAT(0); |
| 308 | fee->currency = tal_steal(fee, sums[i]->currency); |
| 309 | fee->acct_name = tal_steal(fee, sums[i]->acct_name); |
| 310 | fee->txid = *sums[i]->txid; |
| 311 | |
| 312 | fee->timestamp = |
| 313 | onchain_fee_last_timestamp(db, sums[i]->acct_db_id, |
| 314 | sums[i]->txid); |
| 315 | |
| 316 | tal_arr_expand(&fee_sums, fee); |
| 317 | } |
| 318 | |
| 319 | tal_free(sums); |
| 320 | return fee_sums; |
| 321 | } |
| 322 | |
| 323 | struct income_event **list_income_events(const tal_t *ctx, |
| 324 | struct db *db, |
no test coverage detected