read scid,satoshis csv file and create return an array of scidsat pointers */
| 19 | |
| 20 | /* read scid,satoshis csv file and create return an array of scidsat pointers */ |
| 21 | static 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 | |
| 46 | static void write_outmsg(int outfd, const u8 *outmsg, u32 timestamp) |
| 47 | { |
no test coverage detected