-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbtcmon.cpp
1943 lines (1678 loc) · 69.4 KB
/
btcmon.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include <stdlib.h>
#include <string>
#include <tchar.h>
#include <windows.h>
#include <WinInet.h>
#include <CommCtrl.h>
#include <time.h>
#include <iostream>
#pragma comment(lib, "Wininet.lib")
#define WIN32_LEAN_AND_MEAN
using namespace std;
HINTERNET hInternet = NULL;
HINTERNET hConnect = NULL;
HINTERNET hRequest = NULL;
string wnetpath = "";
COLORREF bkg = RGB(100, 100, 100);
COLORREF greenon = RGB(51, 153, 102);
COLORREF greenoff = RGB(179, 255, 179);
COLORREF redon = RGB(174, 120, 225);
COLORREF redoff = RGB(255, 204, 255);
COLORREF redtext = RGB(236, 198, 217);
COLORREF greentext = RGB(179, 230, 204);
COLORREF gbon = RGB(185, 185, 185);
COLORREF gboff = RGB(85, 85, 85);
COLORREF axis_text = RGB(160, 160, 161);
COLORREF coord_text = RGB(0, 0, 0);
COLORREF top_text = RGB(200, 200, 200);
COLORREF price_text_netural = RGB(220, 220, 220);
COLORREF price_text_up = RGB(0, 200, 0);
COLORREF price_text_down = RGB(200, 0, 0);
HPEN axespen = CreatePen(PS_SOLID, 2, RGB(200, 200, 200));
HPEN axes_dots = CreatePen(PS_DASHDOTDOT, 1, RGB(120, 120, 120));
HPEN hilopen = CreatePen(PS_SOLID, 3, RGB(255, 204, 255));
HPEN predon = CreatePen(PS_SOLID, 2, redon);
HPEN predoff = CreatePen(PS_SOLID, 2, redoff);
HPEN pgreenon = CreatePen(PS_SOLID, 2, greenon);
HPEN pgreenoff = CreatePen(PS_SOLID, 2, greenoff);
HPEN gbtnon = CreatePen(PS_SOLID, 2, gbon);
HPEN gbtnoff = CreatePen(PS_SOLID, 2, gboff);
HBRUSH bgr = CreateSolidBrush(bkg);
HBRUSH btngreenhover = CreateSolidBrush(greenon);
HCURSOR cross = LoadCursor(NULL, IDC_CROSS);
HCURSOR arrow = LoadCursor(NULL, IDC_ARROW);
HFONT btnfont = CreateFont(20, 0, 0, 0, FW_MEDIUM, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_OUTLINE_PRECIS,
CLIP_DEFAULT_PRECIS, CLEARTYPE_QUALITY, VARIABLE_PITCH, TEXT("Arial"));
HFONT mainfont = CreateFont(18, 0 , 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_OUTLINE_PRECIS,
CLIP_DEFAULT_PRECIS, CLEARTYPE_QUALITY, VARIABLE_PITCH, TEXT("Arial"));
HFONT pricefont = CreateFont(34, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_OUTLINE_PRECIS,
CLIP_DEFAULT_PRECIS, CLEARTYPE_QUALITY, VARIABLE_PITCH, TEXT("Arial"));
HFONT axisfont = CreateFont(20, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_OUTLINE_PRECIS,
CLIP_DEFAULT_PRECIS, CLEARTYPE_QUALITY, VARIABLE_PITCH, TEXT("Arial"));
HFONT yaxisfont = CreateFont(20, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_OUTLINE_PRECIS,
CLIP_DEFAULT_PRECIS, CLEARTYPE_QUALITY, VARIABLE_PITCH, TEXT("Arial"));
//IDs
int CRRC = 201;
int COIN = 202;
int GRAPH = 203;
//initial dropdown selections
//usd
int init_curr = 8;
//btc
int init_coin = 22;
//currencies available on coingecko api
TCHAR currencies[55][10] =
{
TEXT("btc"),
TEXT("eth"),
TEXT("ltc"),
TEXT("bch"),
TEXT("bnb"),
TEXT("eos"),
TEXT("xrp"),
TEXT("xlm"),
TEXT("usd"),
TEXT("aed"),
TEXT("ars"),
TEXT("aud"),
TEXT("bdt"),
TEXT("bhd"),
TEXT("bmd"),
TEXT("brl"),
TEXT("cad"),
TEXT("chf"),
TEXT("clp"),
TEXT("cny"),
TEXT("czk"),
TEXT("dkk"),
TEXT("eur"),
TEXT("gbp"),
TEXT("hkd"),
TEXT("huf"),
TEXT("idr"),
TEXT("ils"),
TEXT("inr"),
TEXT("jpy"),
TEXT("krw"),
TEXT("kwd"),
TEXT("lkr"),
TEXT("mmk"),
TEXT("mxn"),
TEXT("myr"),
TEXT("nok"),
TEXT("nzd"),
TEXT("php"),
TEXT("pkr"),
TEXT("pln"),
TEXT("rub"),
TEXT("sar"),
TEXT("sek"),
TEXT("sgd"),
TEXT("thb"),
TEXT("try"),
TEXT("twd"),
TEXT("uah"),
TEXT("vef"),
TEXT("vnd"),
TEXT("zar"),
TEXT("xdr"),
TEXT("xag"),
TEXT("xau")
};
//200+ most popular coins according to some website
TCHAR coins [221][3][30] =
{
//id , symbol, name
{ TEXT("0x") , TEXT("zrx") , TEXT("0x") },
{ TEXT("aelf") , TEXT("elf") , TEXT("aelf") },
{ TEXT("aeternity") , TEXT("ae") , TEXT("Aeternity") },
{ TEXT("aion") , TEXT("aion") , TEXT("Aion") },
{ TEXT("akropolis") , TEXT("akro") , TEXT("Akropolis") },
{ TEXT("algorand") , TEXT("algo") , TEXT("Algorand") },
{ TEXT("alibabacoin") , TEXT("abbc") , TEXT("ABBC") },
{ TEXT("ampleforth") , TEXT("ampl") , TEXT("Ampleforth") },
{ TEXT("ankr") , TEXT("ankr") , TEXT("Ankr") },
{ TEXT("aragon") , TEXT("ant") , TEXT("Aragon") },
{ TEXT("ardor") , TEXT("ardr") , TEXT("Ardor") },
{ TEXT("ark") , TEXT("ark") , TEXT("Ark") },
{ TEXT("augur") , TEXT("rep") , TEXT("Augur") },
{ TEXT("aurora") , TEXT("aoa") , TEXT("Aurora") },
{ TEXT("balancer") , TEXT("bal") , TEXT("Balancer") },
{ TEXT("bancor") , TEXT("bnt") , TEXT("Bancor Network Token") },
{ TEXT("band-protocol") , TEXT("band") , TEXT("Band Protocol") },
{ TEXT("basic-attention-token") , TEXT("bat") , TEXT("Basic Attention Token") },
{ TEXT("beam") , TEXT("beam") , TEXT("BEAM") },
{ TEXT("beats-token") , TEXT("bts") , TEXT("Beats Token") },
{ TEXT("binancecoin") , TEXT("bnb") , TEXT("Binance Coin") },
{ TEXT("binance-usd") , TEXT("busd") , TEXT("Binance USD") },
{ TEXT("bitcoin") , TEXT("btc") , TEXT("Bitcoin") },
{ TEXT("bitcoin-cash") , TEXT("bch") , TEXT("Bitcoin Cash") },
{ TEXT("bitcoin-cash-sv") , TEXT("bsv") , TEXT("Bitcoin SV") },
{ TEXT("bitcoin-diamond") , TEXT("bcd") , TEXT("Bitcoin Diamond") },
{ TEXT("bitcoin-gold") , TEXT("btg") , TEXT("Bitcoin Gold") },
{ TEXT("bitflexo-native-token") , TEXT("bnt") , TEXT("BitFlexo Native Token") },
{ TEXT("bitshares") , TEXT("bts") , TEXT("BitShares") },
{ TEXT("bittorrent-2") , TEXT("btt") , TEXT("BitTorrent") },
{ TEXT("blockstack") , TEXT("stx") , TEXT("Blockstack") },
{ TEXT("blocktrade") , TEXT("btt") , TEXT("Blocktrade") },
{ TEXT("bluzelle") , TEXT("blz") , TEXT("Bluzelle") },
{ TEXT("bora") , TEXT("bora") , TEXT("BORA") },
{ TEXT("bytecoin") , TEXT("bcn") , TEXT("Bytecoin") },
{ TEXT("bytom") , TEXT("btm") , TEXT("Bytom") },
{ TEXT("bzx-protocol") , TEXT("bzrx") , TEXT("bZx Protocol") },
{ TEXT("cardano") , TEXT("ada") , TEXT("Cardano") },
{ TEXT("celer-network") , TEXT("celr") , TEXT("Celer Network") },
{ TEXT("celsius-degree-token") , TEXT("cel") , TEXT("Celsius Network") },
{ TEXT("chainlink") , TEXT("link") , TEXT("ChainLink") },
{ TEXT("chiliz") , TEXT("chz") , TEXT("Chiliz") },
{ TEXT("compound-coin") , TEXT("comp") , TEXT("Compound Coin") },
{ TEXT("compound-governance-token") , TEXT("comp") , TEXT("Compound") },
{ TEXT("concertvr") , TEXT("cvt") , TEXT("concertVR") },
{ TEXT("concierge-io") , TEXT("ava") , TEXT("Travala.com") },
{ TEXT("cortex") , TEXT("ctxc") , TEXT("Cortex") },
{ TEXT("cosmos") , TEXT("atom") , TEXT("Cosmos") },
{ TEXT("coti") , TEXT("coti") , TEXT("COTI") },
{ TEXT("cronos-coin") , TEXT("cro") , TEXT("Cronos Coin") },
{ TEXT("crypterium") , TEXT("crpt") , TEXT("Crypterium") },
{ TEXT("crypto-com-chain") , TEXT("cro") , TEXT("Crypto.com Coin") },
{ TEXT("cybervein") , TEXT("cvt") , TEXT("CyberVeinToken") },
{ TEXT("dai") , TEXT("dai") , TEXT("Dai") },
{ TEXT("dash") , TEXT("dash") , TEXT("Dash") },
{ TEXT("decentraland") , TEXT("mana") , TEXT("Decentraland") },
{ TEXT("decentralized-advertising") , TEXT("dad") , TEXT("DAD") },
{ TEXT("decred") , TEXT("dcr") , TEXT("Decred") },
{ TEXT("dent") , TEXT("dent") , TEXT("Dent") },
{ TEXT("digibyte") , TEXT("dgb") , TEXT("DigiByte") },
{ TEXT("digitex-futures-exchange") , TEXT("dgtx") , TEXT("Digitex Futures Exchange") },
{ TEXT("divi") , TEXT("divi") , TEXT("Divi") },
{ TEXT("dogecoin") , TEXT("doge") , TEXT("Dogecoin") },
{ TEXT("dxchain") , TEXT("dx") , TEXT("DxChain Token") },
{ TEXT("elastos") , TEXT("ela") , TEXT("Elastos") },
{ TEXT("eldorado-token") , TEXT("erd") , TEXT("ELDORADO TOKEN") },
{ TEXT("electroneum") , TEXT("etn") , TEXT("Electroneum") },
{ TEXT("elrond") , TEXT("erd") , TEXT("Elrond") },
{ TEXT("energi") , TEXT("nrg") , TEXT("Energi") },
{ TEXT("energy-web-token") , TEXT("ewt") , TEXT("Energy Web Token") },
{ TEXT("enjincoin") , TEXT("enj") , TEXT("Enjin Coin") },
{ TEXT("eos") , TEXT("eos") , TEXT("EOS") },
{ TEXT("ethereum") , TEXT("eth") , TEXT("Ethereum") },
{ TEXT("ethereum-classic") , TEXT("etc") , TEXT("Ethereum Classic") },
{ TEXT("ethlend") , TEXT("lend") , TEXT("Aave") },
{ TEXT("ethos") , TEXT("vgx") , TEXT("Voyager Token") },
{ TEXT("fantom") , TEXT("ftm") , TEXT("Fantom") },
{ TEXT("farmatrust") , TEXT("ftt") , TEXT("FarmaTrust") },
{ TEXT("fetch-ai") , TEXT("fet") , TEXT("Fetch.ai") },
{ TEXT("firstenergy-token") , TEXT("fet") , TEXT("FirstEnergy Token") },
{ TEXT("flexacoin") , TEXT("fxc") , TEXT("Flexacoin") },
{ TEXT("freetip") , TEXT("ftt") , TEXT("FreeTip") },
{ TEXT("fsn") , TEXT("fsn") , TEXT("FUSION") },
{ TEXT("ftx-token") , TEXT("ftt") , TEXT("FTX Token") },
{ TEXT("funfair") , TEXT("fun") , TEXT("FunFair") },
{ TEXT("game-x-coin") , TEXT("gxc") , TEXT("GameXCoin") },
{ TEXT("gatechain-token") , TEXT("gt") , TEXT("Gatechain Token") },
{ TEXT("gdac-token") , TEXT("gt") , TEXT("GDAC Token") },
{ TEXT("gnosis") , TEXT("gno") , TEXT("Gnosis") },
{ TEXT("golem") , TEXT("gnt") , TEXT("Golem") },
{ TEXT("grin") , TEXT("grin") , TEXT("Grin") },
{ TEXT("gxchain") , TEXT("gxc") , TEXT("GXChain") },
{ TEXT("harmony") , TEXT("one") , TEXT("Harmony") },
{ TEXT("havven") , TEXT("snx") , TEXT("Synthetix Network Token") },
{ TEXT("hedera-hashgraph") , TEXT("hbar") , TEXT("Hedera Hashgraph") },
{ TEXT("hedgetrade") , TEXT("hedg") , TEXT("HedgeTrade") },
{ TEXT("hive") , TEXT("hive") , TEXT("Hive") },
{ TEXT("holotoken") , TEXT("hot") , TEXT("Holo") },
{ TEXT("hotnow") , TEXT("hot") , TEXT("HotNow") },
{ TEXT("hshare") , TEXT("hc") , TEXT("HyperCash") },
{ TEXT("huobi-pool-token") , TEXT("hpt") , TEXT("Huobi Pool Token") },
{ TEXT("huobi-token") , TEXT("ht") , TEXT("Huobi Token") },
{ TEXT("husd") , TEXT("husd") , TEXT("HUSD") },
{ TEXT("hydro-protocol") , TEXT("hot") , TEXT("Hydro Protocol") },
{ TEXT("hyperion") , TEXT("hyn") , TEXT("Hyperion") },
{ TEXT("icon") , TEXT("icx") , TEXT("ICON") },
{ TEXT("iexec-rlc") , TEXT("rlc") , TEXT("iExec RLC") },
{ TEXT("iostoken") , TEXT("iost") , TEXT("IOST") },
{ TEXT("iota") , TEXT("miota") , TEXT("IOTA") },
{ TEXT("iotex") , TEXT("iotx") , TEXT("IoTeX") },
{ TEXT("iris-network") , TEXT("iris") , TEXT("IRISnet") },
{ TEXT("just") , TEXT("jst") , TEXT("JUST") },
{ TEXT("kava") , TEXT("kava") , TEXT("Kava") },
{ TEXT("kleros") , TEXT("pnk") , TEXT("Kleros") },
{ TEXT("komodo") , TEXT("kmd") , TEXT("Komodo") },
{ TEXT("kucoin-shares") , TEXT("kcs") , TEXT("KuCoin Shares") },
{ TEXT("kusama") , TEXT("ksm") , TEXT("Kusama") },
{ TEXT("kyber-network") , TEXT("knc") , TEXT("Kyber Network") },
{ TEXT("leo-token") , TEXT("leo") , TEXT("LEO Token") },
{ TEXT("lisk") , TEXT("lsk") , TEXT("Lisk") },
{ TEXT("litecoin") , TEXT("ltc") , TEXT("Litecoin") },
{ TEXT("loki-network") , TEXT("loki") , TEXT("Loki Network") },
{ TEXT("loopring") , TEXT("lrc") , TEXT("Loopring") },
{ TEXT("maidsafecoin") , TEXT("maid") , TEXT("MaidSafeCoin") },
{ TEXT("maker") , TEXT("mkr") , TEXT("Maker") },
{ TEXT("matic-network") , TEXT("matic") , TEXT("Matic Network") },
{ TEXT("melon") , TEXT("mln") , TEXT("Melon") },
{ TEXT("menlo-one") , TEXT("one") , TEXT("Menlo One") },
{ TEXT("molecular-future") , TEXT("mof") , TEXT("Molecular Future") },
{ TEXT("monaco") , TEXT("mco") , TEXT("MCO") },
{ TEXT("monacoin") , TEXT("mona") , TEXT("MonaCoin") },
{ TEXT("monero") , TEXT("xmr") , TEXT("Monero") },
{ TEXT("monexcoin") , TEXT("mxc") , TEXT("Monexcoin") },
{ TEXT("mxc") , TEXT("mxc") , TEXT("Machine Xchange Coin") },
{ TEXT("nano") , TEXT("nano") , TEXT("Nano") },
{ TEXT("nem") , TEXT("xem") , TEXT("NEM") },
{ TEXT("neo") , TEXT("neo") , TEXT("NEO") },
{ TEXT("nervos-network") , TEXT("ckb") , TEXT("Nervos Network") },
{ TEXT("nexo") , TEXT("nexo") , TEXT("NEXO") },
{ TEXT("nimiq-2") , TEXT("nim") , TEXT("Nimiq") },
{ TEXT("nuls") , TEXT("nuls") , TEXT("Nuls") },
{ TEXT("numeraire") , TEXT("nmr") , TEXT("Numeraire") },
{ TEXT("ocean-protocol") , TEXT("ocean") , TEXT("Ocean Protocol") },
{ TEXT("okb") , TEXT("okb") , TEXT("OKB") },
{ TEXT("omisego") , TEXT("omg") , TEXT("OMG Network") },
{ TEXT("one") , TEXT("one") , TEXT("One") },
{ TEXT("ontology") , TEXT("ont") , TEXT("Ontology") },
{ TEXT("orbs") , TEXT("orbs") , TEXT("Orbs") },
{ TEXT("origin-protocol") , TEXT("ogn") , TEXT("Origin Protocol") },
{ TEXT("origintrail") , TEXT("trac") , TEXT("OriginTrail") },
{ TEXT("pax-gold") , TEXT("paxg") , TEXT("PAX Gold") },
{ TEXT("paxos-standard") , TEXT("pax") , TEXT("Paxos Standard") },
{ TEXT("penta") , TEXT("pnt") , TEXT("Penta Network Token") },
{ TEXT("perlin") , TEXT("perl") , TEXT("Perlin") },
{ TEXT("pivx") , TEXT("pivx") , TEXT("PIVX") },
{ TEXT("pnetwork") , TEXT("pnt") , TEXT("pNetwork") },
{ TEXT("power-ledger") , TEXT("powr") , TEXT("Power Ledger") },
{ TEXT("project-pai") , TEXT("pai") , TEXT("Project Pai") },
{ TEXT("pundi-x") , TEXT("npxs") , TEXT("Pundi X") },
{ TEXT("qtum") , TEXT("qtum") , TEXT("Qtum") },
{ TEXT("quant-network") , TEXT("qnt") , TEXT("Quant") },
{ TEXT("ravencoin") , TEXT("rvn") , TEXT("Ravencoin") },
{ TEXT("reddcoin") , TEXT("rdd") , TEXT("Reddcoin") },
{ TEXT("republic-protocol") , TEXT("ren") , TEXT("REN") },
{ TEXT("request-network") , TEXT("req") , TEXT("Request") },
{ TEXT("reserve-rights-token") , TEXT("rsr") , TEXT("Reserve Rights Token") },
{ TEXT("rif-token") , TEXT("rif") , TEXT("RIF Token") },
{ TEXT("ripio-credit-network") , TEXT("rcn") , TEXT("Ripio Credit Network") },
{ TEXT("ripple") , TEXT("xrp") , TEXT("XRP") },
{ TEXT("siacoin") , TEXT("sc") , TEXT("Siacoin") },
{ TEXT("solana") , TEXT("sol") , TEXT("Solana") },
{ TEXT("solve-care") , TEXT("solve") , TEXT("SOLVE") },
{ TEXT("stasis-eurs") , TEXT("eurs") , TEXT("STASIS EURO") },
{ TEXT("steem") , TEXT("steem") , TEXT("Steem") },
{ TEXT("stellar") , TEXT("xlm") , TEXT("Stellar") },
{ TEXT("storj") , TEXT("storj") , TEXT("Storj") },
{ TEXT("stox") , TEXT("stx") , TEXT("Stox") },
{ TEXT("stratis") , TEXT("strat") , TEXT("Stratis") },
{ TEXT("streamr-datacoin") , TEXT("data") , TEXT("Streamr DATAcoin") },
{ TEXT("super-zero") , TEXT("sero") , TEXT("SERO") },
{ TEXT("swipe") , TEXT("sxp") , TEXT("Swipe") },
{ TEXT("swissborg") , TEXT("chsb") , TEXT("SwissBorg") },
{ TEXT("switcheo") , TEXT("swth") , TEXT("Switcheo") },
{ TEXT("syscoin") , TEXT("sys") , TEXT("Syscoin") },
{ TEXT("terra-luna") , TEXT("luna") , TEXT("Terra") },
{ TEXT("tether") , TEXT("usdt") , TEXT("Tether") },
{ TEXT("tezos") , TEXT("xtz") , TEXT("Tezos") },
{ TEXT("tezos-iou") , TEXT("xtz") , TEXT("Tezos IOU") },
{ TEXT("the-midas-touch-gold") , TEXT("tmtg") , TEXT("The Midas Touch Gold") },
{ TEXT("theta-fuel") , TEXT("tfuel") , TEXT("Theta Fuel") },
{ TEXT("theta-token") , TEXT("theta") , TEXT("Theta Network") },
{ TEXT("thorchain") , TEXT("rune") , TEXT("Thorchain") },
{ TEXT("thunder-token") , TEXT("tt") , TEXT("ThunderCore") },
{ TEXT("tomochain") , TEXT("tomo") , TEXT("TomoChain") },
{ TEXT("tron") , TEXT("trx") , TEXT("TRON") },
{ TEXT("true-usd") , TEXT("tusd") , TEXT("TrueUSD") },
{ TEXT("unibright") , TEXT("ubt") , TEXT("Unibright") },
{ TEXT("usd-coin") , TEXT("usdc") , TEXT("USD Coin") },
{ TEXT("utrust") , TEXT("utk") , TEXT("UTRUST") },
{ TEXT("valix") , TEXT("vlx") , TEXT("Vallix") },
{ TEXT("vechain") , TEXT("vet") , TEXT("VeChain") },
{ TEXT("velas") , TEXT("vlx") , TEXT("Velas") },
{ TEXT("verge") , TEXT("xvg") , TEXT("Verge") },
{ TEXT("vethor-token") , TEXT("vtho") , TEXT("VeThor Token") },
{ TEXT("v-id-blockchain") , TEXT("vidt") , TEXT("V-ID blockchain") },
{ TEXT("v-systems") , TEXT("vsys") , TEXT("V.SYSTEMS") },
{ TEXT("waltonchain") , TEXT("wtc") , TEXT("Waltonchain") },
{ TEXT("wanchain") , TEXT("wan") , TEXT("Wanchain") },
{ TEXT("waves") , TEXT("waves") , TEXT("Waves") },
{ TEXT("wawllet") , TEXT("win") , TEXT("WCoin") },
{ TEXT("wax") , TEXT("waxp") , TEXT("WAX") },
{ TEXT("waykichain") , TEXT("wicc") , TEXT("WaykiChain") },
{ TEXT("wazirx") , TEXT("wrx") , TEXT("WazirX") },
{ TEXT("wink") , TEXT("win") , TEXT("WINk") },
{ TEXT("wirex") , TEXT("wxt") , TEXT("Wirex") },
{ TEXT("zb-token") , TEXT("zb") , TEXT("ZB Token") },
{ TEXT("zcash") , TEXT("zec") , TEXT("Zcash") },
{ TEXT("zcoin") , TEXT("xzc") , TEXT("Zcoin") },
{ TEXT("zencash") , TEXT("zen") , TEXT("Horizen") },
{ TEXT("zerobank") , TEXT("zb") , TEXT("ZeroBank") },
{ TEXT("zilliqa") , TEXT("zil") , TEXT("Zilliqa") }
};
//storing timestamps and price values for graph, as recd from api
struct grawdata {
long int tst = 0;
double price = 0;
string label = "";
};
//this is the final data which will be used to plot the graph
struct gdata {
int x = 0;
int y = 0;
string label = "";
};
struct notch {
int coord = 0;
string label = "";
};
struct btn {
int left = 0;
int top = 0;
int right = 0;
int bottom = 0;
int width = 0;
int height = 0;
string label = "";
string change = "";
string oldprice = "";
bool hover = false;
bool on = false;
};
grawdata json_dump[800];
gdata coords[300];
//x axis map (not the graph line)
//time label for each x pixel
string xmap[1200];
//same but with price labels for y
string ymap[1200];
//notches
notch xnotch[1300];
notch ynotch[1300];
//buttons
btn buttons[5];
//gx,gy is the lower left corner
int gx = 110;
int gy = 500;
int ypadding = 10;
int xpadding = 10;
int notch_xpad = 100;
int notch_ypad = 100;
int gheight = 400;
int gwidth = 800;
int gstatus = 1;
//'current' tst - first received in json dump
long int ctst = 0;
double lastprice = 0;
//dimensions when graph is off/on
int wgoff = 430;
int hgoff = 100;
int wgon = 1024;
int hgon = 600;
int window_width = wgoff;
int window_height = hgoff;
bool mouse_over_graph = false;
//whether mouse is over/close to a graph coord
int cfocus = -1;
int cfocus_x_final = 0;
int cfocus_y_final = 0;
int old_mouse_x = 0;
int old_mouse_y = 0;
int mouse_x = 0;
int mouse_y = 0;
int mouse_dx = 0;
int mouse_dy = 0;
//used as region to update in redrawwindow
POINT upd[12];
int min_idx = 0;
int max_idx = 0;
string minpricestr;
string maxpricestr;
string toptext;
string str_price = "loading.";
double cur_price = 0;
double old_price = 0;
string coin_ratio = ": 1";
int coin_sz = coin_ratio.size();
LPCSTR coinptr = coin_ratio.c_str();
string glabel = "graph:";
int glabelsz = glabel.size();
LPCSTR glabelptr = glabel.c_str();
string ids = coins[init_coin][0];
string vcs = currencies[init_curr];
string price_url = "/api/v3/simple/price";
string final_url = price_url + "?ids=" + ids + "&vs_currencies=" + vcs;
string api_days[4] = {"1","7","30","365"};
//update every n milliseconds
static int update_interval = 2000;
/* Declare Windows procedure */
LRESULT CALLBACK WindowProcedure(HWND, UINT, WPARAM, LPARAM);
/* Make the class name into a global variable */
TCHAR szClassName[] = _T("CryptoWindowsApp");
//graph on/off button
void gbtn_init(int left, int top) {
int size = 50;
buttons[0].left = left;
buttons[0].top = top;
buttons[0].right = left + size;
buttons[0].bottom = top + size;
buttons[0].label = "graph";
}
//initialise graph time buttons, with their base coords
void buttons_init(int top, int left, int bwidth, int bheight, int spacing) {
buttons[1].left = left;
buttons[1].top = top;
buttons[1].right = left + bwidth;
buttons[1].bottom = top + bheight;
buttons[1].label = "24H";
buttons[2].left = buttons[1].right + spacing;
buttons[2].top = top;
buttons[2].right = buttons[2].left + bwidth;
buttons[2].bottom = top + bheight;
buttons[2].label = "7D";
buttons[3].left = buttons[2].right + spacing;
buttons[3].top = top;
buttons[3].right = buttons[3].left + bwidth;
buttons[3].bottom = top + bheight;
buttons[3].label = "30D";
buttons[4].left = buttons[3].right + spacing;
buttons[4].top = top;
buttons[4].right = buttons[4].left + bwidth;
buttons[4].bottom = top + bheight;
buttons[4].label = "1Y";
}
void ytxtauto() {
DeleteObject(yaxisfont);
int maxl = minpricestr.length();
int fsize = 20;
if ((int) maxpricestr.length() > maxl) {
maxl = maxpricestr.length();
}
if (maxl > 10) {
fsize = 25 - (maxl/3);
}
yaxisfont = CreateFont(fsize, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_OUTLINE_PRECIS,
CLIP_DEFAULT_PRECIS, CLEARTYPE_QUALITY, VARIABLE_PITCH, TEXT("Arial"));
}
/*
//auto resize y axis text
void ytxtauto(string ytxt) {
DeleteObject(yaxisfont);
int strl = ytxt.length();
int fsize = 20;
if (strl > 10) {
fsize = fsize - (strl/3);
}
yaxisfont = CreateFont(fsize, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_OUTLINE_PRECIS,
CLIP_DEFAULT_PRECIS, CLEARTYPE_QUALITY, VARIABLE_PITCH, TEXT("Arial"));
}
*/
//auto resize price text
void price_txt_auto() {
DeleteObject(pricefont);
int pl = str_price.length();
int fsize = 34;
if (pl > 10) {
fsize = fsize - (pl / 3);
}
pricefont = CreateFont(fsize, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_OUTLINE_PRECIS,
CLIP_DEFAULT_PRECIS, CLEARTYPE_QUALITY, VARIABLE_PITCH, TEXT("Arial"));
}
//math formatting of price string
string prettystr(string pstr, int len_trig) {
string outstr = "";
bool dec = false;
if (pstr.find(".") != string::npos) {
//if theres over 8 numbers left of the point, dont show any decimals at all
if (pstr.substr(0, pstr.find(".")).length() > 8) {
pstr = pstr.substr(0, pstr.find("."));
dec = false;
}
else {
dec = true;
}
}
else {
dec = false;
}
//add commas for numbers over 999
int ccount = 0;
for (int c = pstr.length(); c-- > 0; ){ // c goes to zero
if (dec) {
if (pstr[c] == '.') {
//if there is a decimal point only show two digits after it
outstr = pstr.substr(c, 3);
dec = false;
}
}
else {
ccount++;
//every third character, add a comma in front
if ((ccount > 2) & (c!=0)) {
outstr = "," + pstr.substr(c, 1) + outstr;
ccount = 0;
}
else {
outstr = pstr.substr(c, 1) + outstr;
}
}
}
//if padding mode is on, pad with spaces if price is less than length_trigger
if (len_trig!=0) {
if ((int) outstr.length() < len_trig) {
string tmpstr = "";
for (int c = 0; c < (len_trig - (int) outstr.length() + 3); c++) {
tmpstr += " ";
}
outstr = tmpstr + outstr;
}
}
return outstr;
}
size_t writeFunction(void* ptr, size_t size, size_t nmemb, std::string* data) {
data->append((char*)ptr, size * nmemb);
return size * nmemb;
}
void start_wininet(std::string host) {
string ua = "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:89.0) Gecko/20100101 Firefox/89.0";
//string host = "api.coingecko.com";
hInternet = InternetOpenA(ua.c_str(), INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
hConnect = InternetConnectA(hInternet, host.c_str(), INTERNET_DEFAULT_HTTPS_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, 0, NULL);
}
std::string wininet_get(std::string path) {
HINTERNET hRequest = HttpOpenRequestA(hConnect, "GET", path.c_str(), NULL, NULL, NULL, INTERNET_FLAG_SECURE | INTERNET_FLAG_NO_AUTO_REDIRECT, 0);
wnetpath = path;
BOOL sendr = HttpSendRequestA(hRequest, NULL, -1L, NULL, NULL);
std::string strResponse;
const int nBuffSize = 1024;
char buff[nBuffSize]; //use bytes rather than string to help with binary file downloads
BOOL bKeepReading = true;
DWORD dwBytesRead = -1;
while (bKeepReading && dwBytesRead != 0)
{
bKeepReading = InternetReadFile(hRequest, buff, nBuffSize, &dwBytesRead);
strResponse.append(buff, dwBytesRead);
}
return strResponse;
}
void stop_wininet() {
InternetCloseHandle(hInternet);
InternetCloseHandle(hConnect);
if (hRequest != NULL) {
InternetCloseHandle(hRequest);
}
}
void get_graph(string coin, string currency, string days) {
//api elements for 30d: 722 (hourly), 7d: 168 (hourly), 1d : 287 (5 minutely)
//0 for high-low, 0< no. of hourly intervals, e.g. every 4 hours
int mode = 4;
if (days=="30"){
mode = 4;
}
if (days == "7") {
mode = 1;
}
if (days == "1") {
mode = 2;
}
string url;
string raw;
string elmnt;
char outp[200];
int start = 0;
int end;
int ct = 0;
long tst;
std::string::size_type sz;
time_t rawtime;
struct tm timeinfo;
url = "https://api.coingecko.com/api/v3/coins/"+coin+"/market_chart?vs_currency="+currency+"&days="+days;
raw = wininet_get("/api/v3/coins/" + coin + "/market_chart?vs_currency=" + currency + "&days=" + days);
str_price = wininet_get(final_url);
cout << "final url:" + final_url << endl;
OutputDebugString("final url\n");
OutputDebugString(final_url.c_str());
//start_curl(str_price, final_url);
start = raw.find(":") + 2;
raw = raw.substr(start);
end = raw.find("]]");
raw = raw.substr(0,end);
end = 0;
double gmax = 0;
double gmin = 0;
double gstepy;
string tempt;
double temppr;
double hi = 0;
long hitst = 0;
string hilbl = "";
double lo = 0;
long lotst = 0;
string lolbl = "";
tm cdate;
cdate.tm_year = 0;
cdate.tm_mday = 0;
cdate.tm_mon = 0;
int idx = 0;
while (raw.find("[",start) != std::string::npos) {
ct++;
start = raw.find("[", end) + 1;
end = raw.find("]",start);
elmnt = raw.substr(start, end-start);
//here we reduce the timestamp given by coingecko, from ms to s
tempt = elmnt.substr(0,10);
//price
temppr = stod(elmnt.substr(elmnt.find(",") + 1));
tst = stol(tempt,&sz);
rawtime = (const time_t)tst;
localtime_s(&timeinfo,&rawtime);
//last tst is set as 'current' -to be used for graph button text
//this is done repeatedly to ensure the last one is used
ctst = tst;
lastprice = temppr;
//if we reached the number of hours in mode, dump json
if (ct > mode) {
strftime(outp, sizeof(outp), " @ %H:%M %d %b", &timeinfo);
json_dump[idx].price = temppr;
json_dump[idx].tst = tst;
json_dump[idx].label = prettystr(to_string(temppr), 0) + outp;
idx++;
ct = 0;
}
}/*end of while loop*/
int k = 0;
gmin = json_dump[k].price;
gmax = json_dump[k].price;
for (k = 0; k < idx; k++) {
if (json_dump[k].price > gmax) {
gmax = json_dump[k].price;
max_idx = k;
}
if (json_dump[k].price < gmin) {
gmin = json_dump[k].price;
min_idx = k;
}
sprintf_s(outp, 200, "item %d\n", k);
OutputDebugString(outp);
sprintf_s(outp, 200, "price: %f\n", json_dump[k].price);
OutputDebugString(outp);
sprintf_s(outp, 200, "tst: %ld\n", json_dump[k].tst);
OutputDebugString(outp);
OutputDebugString(json_dump[k].label.c_str());
OutputDebugString("\n");
}
sprintf_s(outp, 200, "max price: %f\n", gmax);
OutputDebugString(outp);
sprintf_s(outp, 200, "min price: %f\n", gmin);
OutputDebugString(outp);
//sprintf_s(outp, 200, "json_dump[min_idx].price: %f\n", json_dump[min_idx].price);
//OutputDebugString(outp);
//only useful in hilo mode:
//sprintf_s(outp, 200, "total elements in array are %d\n", ct);
//OutputDebugString(outp);
//the price in each y pixel
gstepy = ( (gmax-gmin)/(gheight));
//seconds in each x pixel for tst , for x axis
int gstepxs = 1; // done to avoid IDE warnings
if (idx > 0) { // done to avoid IDE warnings
gstepxs = (int)(json_dump[idx - 1].tst - json_dump[0].tst) / gwidth;
}
for (k = 0; k <= idx; k++) {
if (k == idx) {
coords[k].label = "[end]";
//the last x coord is the graph width
//nb: this can only be done right at the end, because gwidth is
//used to calculate the hours in each xpixel
if (k > 0) {//this is done purely to avoid IDE warnings
gwidth = coords[k - 1].x;
}
}
else {
//arbitrary number to make it small enough to fit the window
coords[k].x = (json_dump[k].tst - json_dump[0].tst)/((json_dump[idx - 1].tst - json_dump[0].tst) / gwidth);
coords[k].y = (int) (( json_dump[k].price - gmin)/gstepy);
coords[k].label = json_dump[k].label;
}
}
//find regular divisions for y axis notches
string tminstr = to_string(gmin);
if (tminstr.find(".") != string::npos) {
tminstr = tminstr.substr(0, tminstr.find("."));
}
string tmaxstr = to_string(gmax);
if (tmaxstr.find(".") != string::npos) {
tmaxstr = tmaxstr.substr(0, tmaxstr.find("."));
}
//no of digits after first
int tlen = tmaxstr.length() -1 ;
int addno = 1;
int ynotch_start = (int)gmin;
for (int c = tlen; c-- > 0; ) { // c goes to zero
addno = 1;
for (int ano = 0; ano < c; ano++) {
addno = addno * 10;
}
ynotch_start = stoi(tminstr.substr(0, tminstr.length() - c)) * addno;
if ((gmin + addno) < gmax) {
ynotch_start += addno;
break;
}
}
sprintf_s(outp, 200, "addno: %d\n", addno);
OutputDebugString(outp);
//dont overcrowd y axis with too many notches -adjust addno accordingly
//reuse tlen to store the initial addno
tlen = addno;
while ((int)((gmax-gmin)/addno)>5) {
addno += tlen;
}
sprintf_s(outp, 200, "addno revised: %d\n", addno);
OutputDebugString(outp);
//clean ynotch and ymap array - otherwise it will mess up if its not the first use
for (k = 0; k < 1300; k++) {
ynotch[k].coord = 0;
ynotch[k].label = "";
if (k < 1200) {
ymap[k] = "";
}
}
//the price for each y axis pixel is stored in ymap
double tempstep = 0;
for (k = 0; k < gheight; k++) {
tempstep = k * gstepy;
ymap[k] = prettystr(to_string(gmin + tempstep), 10);
}
//add y axis notches to array
sprintf_s(outp, 200, "ynotch_start : %d\n", ynotch_start);
OutputDebugString(outp);
int nidy = 0;
while ((int) ((int) ynotch_start ) < ((int) gmax+1)) {
//if not too close to another notch, add min and max notches
//if (nidy==0)
//-currently on hold
ynotch[nidy].coord = (int)((ynotch_start - gmin) / gstepy);
ynotch[nidy].label = prettystr(to_string(ynotch_start), 9);
ynotch_start += addno;
nidy++;
}
ynotch[nidy].label = "[end]";
minpricestr = (coords[min_idx].label.substr(0, coords[min_idx].label.find("@")));
maxpricestr = (coords[max_idx].label.substr(0, coords[max_idx].label.find("@")));
//the time and date for each x axis pixel is stored in xmap
int last_date = 0;
int current_date = 0;
int nidx = 0;
//how many times the x axis will be divided into labeled notches
int xdivs = 3;
int xdstep;
if ((days == "7") || (days == "30")) {
xdstep = (int)(stoi(days) / xdivs);
}
if (days == "365") {
xdstep = (int)(12 / xdivs);
}
if (days == "1") {
xdstep = (int)(24 / xdivs);
}
//clean xnotch and xmap array - otherwise it will mess up if its not the first use
for (k = 0; k < 1300; k++) {
xnotch[k].coord = 0;
xnotch[k].label = "";
if (k < 1200) {
xmap[k] = "";
}
}
for (k = 0; k < gwidth; k++) {
//sprintf_s(outp, 200, "iteration no: %d\n", k);
//OutputDebugString(outp);
tst = json_dump[0].tst + (k* gstepxs);
rawtime = (const time_t)tst;
localtime_s(&timeinfo, &rawtime);
if (k == 0) {
//if looking at one year then only go month by month - if 7/30d day by day - if 24h hour by hour
if ((days == "7") || (days=="30")) {
last_date = timeinfo.tm_mday;
}
if (days == "365") {
last_date = timeinfo.tm_mon;
}
if (days == "1") {
last_date = timeinfo.tm_hour;
}
}
else {
if ((days == "7") || (days == "30")) {
current_date = timeinfo.tm_mday;
}
if (days == "365") {
current_date = timeinfo.tm_mon;
}
if (days == "1") {
current_date = timeinfo.tm_hour;
}
if (last_date != current_date) {
//date has changed, add a notch on x axis
xnotch[nidx].coord = k;
if ((days == "7") || (days == "30")) {
strftime(outp, sizeof(outp), "%d %b", &timeinfo);
}
if (days == "365") {
strftime(outp, sizeof(outp), "%d %b '%y", &timeinfo);
}
if (days == "1") {
//should be %H:%M but its rounded to 00 because sometimes it comes out as :01 or :02
strftime(outp, sizeof(outp), "%H:00 %d %b", &timeinfo);
}
//the first and last notches are always labeled + larger
if (nidx == 0) {
xnotch[nidx].label = outp;
}
else {
//labeled notches between first and last (based on xdivs)
int xd = 1;
for (xd = 1; xd <= xdivs; xd++) {
if (nidx == (xd * xdstep)) {
xnotch[nidx].label = outp;
break;
}
}