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

Function chain_events

plugins/bkpr/sql.c:97–165  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

95}
96
97static struct chain_event **chain_events(const tal_t *ctx,
98 const struct bkpr *bkpr,
99 const char *buf,
100 const jsmntok_t *result)
101{
102 struct chain_event **evs;
103 size_t i;
104 const jsmntok_t *row, *rows = json_get_member(buf, result, "rows");
105
106 evs = tal_arr(ctx, struct chain_event *, rows->size);
107 json_for_each_arr(i, row, rows) {
108 bool ok = true;
109 struct chain_event *ev = tal(evs, struct chain_event);
110 int flag;
111
112 const jsmntok_t *val = row + 1;
113 assert(row->size == 14);
114 ok &= json_to_u64(buf, val, &ev->db_id);
115 val = json_next(val);
116 ev->acct_name = json_strdup(ev, buf, val);
117 val = json_next(val);
118 if (json_tok_is_null(buf, val))
119 ev->origin_acct = NULL;
120 else
121 ev->origin_acct = json_strdup(ev, buf, val);
122 val = json_next(val);
123 ev->tag = json_strdup(ev, buf, val);
124 val = json_next(val);
125 ok &= json_to_msat(buf, val, &ev->credit);
126 val = json_next(val);
127 ok &= json_to_msat(buf, val, &ev->debit);
128 val = json_next(val);
129 ok &= json_to_msat(buf, val, &ev->output_value);
130 val = json_next(val);
131 ok &= json_to_u64(buf, val, &ev->timestamp);
132 val = json_next(val);
133 ok &= json_to_u32(buf, val, &ev->blockheight);
134 val = json_next(val);
135 ok &= json_to_outpoint(buf, val, &ev->outpoint);
136 /* We may know better! */
137 if (ev->blockheight == 0)
138 ev->blockheight = find_blockheight(bkpr, &ev->outpoint.txid);
139 val = json_next(val);
140 if (json_tok_is_null(buf, val))
141 ev->spending_txid = NULL;
142 else {
143 ev->spending_txid = tal(ev, struct bitcoin_txid);
144 ok &= json_to_txid(buf, val, ev->spending_txid);
145 }
146 val = json_next(val);
147 if (json_tok_is_null(buf, val))
148 ev->payment_id = NULL;
149 else {
150 ev->payment_id = tal(ev, struct sha256);
151 ok &= json_to_sha256(buf, val, ev->payment_id);
152 }
153 val = json_next(val);
154 /* These are 0/1 not true/false */

Callers 1

chain_events_from_sqlFunction · 0.85

Calls 12

json_get_memberFunction · 0.85
json_to_sha256Function · 0.85
json_to_intFunction · 0.85
find_blockheightFunction · 0.70
json_to_u64Function · 0.50
json_nextFunction · 0.50
json_strdupFunction · 0.50
json_tok_is_nullFunction · 0.50
json_to_msatFunction · 0.50
json_to_u32Function · 0.50
json_to_outpointFunction · 0.50
json_to_txidFunction · 0.50

Tested by

no test coverage detected