MCPcopy Create free account
hub / github.com/ElementsProject/lightning / list_income_events

Function list_income_events

plugins/bkpr/incomestmt.c:323–425  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

321}
322
323struct income_event **list_income_events(const tal_t *ctx,
324 struct db *db,
325 u64 start_time,
326 u64 end_time,
327 bool consolidate_fees)
328{
329 struct channel_event **channel_events;
330 struct chain_event **chain_events;
331 struct onchain_fee **onchain_fees;
332 struct account **accts;
333
334 struct income_event **evs;
335
336 channel_events = list_channel_events_timebox(ctx, db,
337 start_time, end_time);
338 chain_events = list_chain_events_timebox(ctx, db, start_time, end_time);
339 accts = list_accounts(ctx, db);
340
341 if (consolidate_fees) {
342 onchain_fees = find_consolidated_fees(ctx, db,
343 start_time,
344 end_time);
345 } else
346 onchain_fees = list_chain_fees_timebox(ctx, db,
347 start_time, end_time);
348
349 evs = tal_arr(ctx, struct income_event *, 0);
350
351 for (size_t i = 0, j = 0, k = 0;
352 i < tal_count(chain_events)
353 || j < tal_count(channel_events)
354 || k < tal_count(onchain_fees);
355 /* Incrementing happens inside loop */) {
356 struct channel_event *chan;
357 struct chain_event *chain;
358 struct onchain_fee *fee;
359 u64 lowest = 0;
360
361 if (i < tal_count(chain_events))
362 chain = chain_events[i];
363 else
364 chain = NULL;
365 if (j < tal_count(channel_events))
366 chan = channel_events[j];
367 else
368 chan = NULL;
369 if (k < tal_count(onchain_fees))
370 fee = onchain_fees[k];
371 else
372 fee = NULL;
373
374 if (chain)
375 lowest = chain->timestamp;
376
377 if (chan
378 && (lowest == 0 || lowest > chan->timestamp))
379 lowest = chan->timestamp;
380

Callers 3

json_dump_incomeFunction · 0.85
json_list_incomeFunction · 0.85
list_income_events_allFunction · 0.85

Calls 12

list_accountsFunction · 0.85
find_consolidated_feesFunction · 0.85
list_chain_fees_timeboxFunction · 0.85
get_accountFunction · 0.85
maybe_chain_incomeFunction · 0.85
maybe_channel_incomeFunction · 0.85
amount_msat_zeroFunction · 0.85
paid_invoice_feeFunction · 0.85
rebalance_feeFunction · 0.85
onchainfee_to_incomeFunction · 0.85

Tested by

no test coverage detected