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

Function load_csv_file

devtools/create-gossipstore.c:22–45  ·  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

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

Callers 1

mainFunction · 0.85

Calls 2

errFunction · 0.85

Tested by

no test coverage detected