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

Function channel_events

plugins/bkpr/sql.c:36–95  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34}
35
36static struct channel_event **channel_events(const tal_t *ctx,
37 const char *buf,
38 const jsmntok_t *result)
39{
40 struct channel_event **evs;
41 size_t i;
42 const jsmntok_t *row, *rows = json_get_member(buf, result, "rows");
43
44 evs = tal_arr(ctx, struct channel_event *, rows->size);
45 json_for_each_arr(i, row, rows) {
46 bool ok = true;
47 struct channel_event *ev;
48 u64 created_index;
49 const char *account_name;
50 const char *primary_tag;
51 struct amount_msat credit, debit, fees;
52 struct sha256 *payment_id, payment_hash;
53 u64 part_id, timestamp;
54
55 const jsmntok_t *val = row + 1;
56 assert(row->size == 9);
57 ok &= json_to_u64(buf, val, &created_index);
58 val = json_next(val);
59 account_name = json_strdup(NULL, buf, val);
60 val = json_next(val);
61 primary_tag = json_strdup(NULL, buf, val);
62 val = json_next(val);
63 ok &= json_to_msat(buf, val, &credit);
64 val = json_next(val);
65 ok &= json_to_msat(buf, val, &debit);
66 val = json_next(val);
67 ok &= json_to_msat(buf, val, &fees);
68 val = json_next(val);
69 if (json_tok_is_null(buf, val))
70 payment_id = NULL;
71 else {
72 ok &= json_to_sha256(buf, val, &payment_hash);
73 payment_id = &payment_hash;
74 }
75 val = json_next(val);
76 if (json_tok_is_null(buf, val))
77 part_id = 0;
78 else {
79 ok &= json_to_u64(buf, val, &part_id);
80 }
81 val = json_next(val);
82 ok &= json_to_u64(buf, val, &timestamp);
83 assert(ok);
84 ev = new_channel_event(evs,
85 take(primary_tag),
86 credit, debit, fees,
87 payment_id,
88 part_id,
89 timestamp);
90 ev->acct_name = tal_steal(ev, account_name);
91 ev->db_id = created_index;
92 evs[i] = ev;
93 }

Callers 1

channel_events_from_sqlFunction · 0.85

Calls 8

json_get_memberFunction · 0.85
json_to_sha256Function · 0.85
json_to_u64Function · 0.50
json_nextFunction · 0.50
json_strdupFunction · 0.50
json_to_msatFunction · 0.50
json_tok_is_nullFunction · 0.50
new_channel_eventFunction · 0.50

Tested by

no test coverage detected