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

Function load_csv_file

devtools/create-gossipstore.c:21–44  ·  view source on GitHub ↗

read scid,satoshis csv file and create return an array of scidsat pointers */

Source from the content-addressed store, hash-verified

19
20/* read scid,satoshis csv file and create return an array of scidsat pointers */
21static struct scidsat *load_csv_file(FILE *scidf)
22{
23 int n, r;
24 char title[15];
25 int i = 0;
26 struct scidsat *scidsats;
27 /* max characters is 8 (0xffffff) + 8 for tx + 5 (0xffffff) for outputs (0xffff) + 2 (x's) */
28 char str[23];
29
30 if (fscanf(scidf, "%d\n", &n) != 1)
31 err(1, "reading number of entries from csv failed");
32
33 scidsats = tal_arr(NULL, struct scidsat, n);
34 r = fscanf(scidf, "%5s ,%8s\n", title, &title[6]);
35 if (r != 2 || strcmp(title, "scid") != 0 || strcmp(&title[6], "satoshis") != 0)
36 err(1, "reading 'scid ,satoshis' from csv failed");
37
38 while(fscanf(scidf, "%s ,%"SCNu64"\n", str, &scidsats[i].sat.satoshis) == 2 ) { /* Raw: read from file */
39 if (!short_channel_id_from_str(str, strlen(str), &scidsats[i].scid))
40 err(1, "failed to make scid struct");
41 i++;
42 }
43 return scidsats;
44}
45
46static void write_outmsg(int outfd, const u8 *outmsg, u32 timestamp)
47{

Callers 1

mainFunction · 0.85

Calls 2

errFunction · 0.85

Tested by

no test coverage detected