]> Git Repo - VerusCoin.git/blame - src/komodo_pax.h
Test
[VerusCoin.git] / src / komodo_pax.h
CommitLineData
d019c447 1/******************************************************************************
37fed603 2 * Copyright © 2014-2017 The SuperNET Developers. *
d019c447 3 * *
4 * See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at *
5 * the top-level directory of this distribution for the individual copyright *
6 * holder information and the developer policies on copyright and licensing. *
7 * *
8 * Unless otherwise agreed in a custom licensing agreement, no part of the *
9 * SuperNET software, including this file may be copied, modified, propagated *
10 * or distributed except according to the terms contained in the LICENSE file *
11 * *
12 * Removal or modification of this copyright notice is prohibited. *
13 * *
14 ******************************************************************************/
1e81ccb7 15
41a4a4db 16#define USD 0
dd39b6bf 17#define EUR 1
18#define JPY 2
19#define GBP 3
20#define AUD 4
21#define CAD 5
22#define CHF 6
23#define NZD 7
24
25#define CNY 8
26#define RUB 9
27#define MXN 10
28#define BRL 11
29#define INR 12
30#define HKD 13
31#define TRY 14
32#define ZAR 15
33
34#define PLN 16
35#define NOK 17
36#define SEK 18
37#define DKK 19
38#define CZK 20
39#define HUF 21
40#define ILS 22
41#define KRW 23
42
43#define MYR 24
44#define PHP 25
45#define RON 26
46#define SGD 27
47#define THB 28
48#define BGN 29
49#define IDR 30
50#define HRK 31
41a4a4db 51
1e81ccb7 52#define MAX_CURRENCIES 32
18d9697a 53extern char CURRENCIES[][8];
1e81ccb7 54
a4ebaad7 55uint64_t M1SUPPLY[] = { 3317900000000, 6991604000000, 667780000000000, 1616854000000, 331000000000, 861909000000, 584629000000, 46530000000, // major currencies
05dfe053 56 45434000000000, 16827000000000, 3473357229000, 306435000000, 27139000000000, 2150641000000, 347724099000, 1469583000000, 749543000000, 1826110000000, 2400434000000, 1123925000000, 3125276000000, 13975000000000, 317657000000, 759706000000000, 354902000000, 2797061000000, 162189000000, 163745000000, 1712000000000, 39093000000, 1135490000000000, 80317000000,
a4ebaad7 57 100000000 };
58
59#define MIND 1000
60uint32_t MINDENOMS[] = { MIND, MIND, 100*MIND, MIND, MIND, MIND, MIND, MIND, // major currencies
61 10*MIND, 100*MIND, 10*MIND, MIND, 100*MIND, 10*MIND, MIND, 10*MIND, MIND, 10*MIND, 10*MIND, 10*MIND, 10*MIND, 100*MIND, MIND, 1000*MIND, MIND, 10*MIND, MIND, MIND, 10*MIND, MIND, 10000*MIND, 10*MIND, // end of currencies
6210*MIND,
1e81ccb7 63};
64
2e9292fe 65int32_t Peggy_inds[539] = {289, 404, 50, 490, 59, 208, 87, 508, 366, 288, 13, 38, 159, 440, 120, 480, 361, 104, 534, 195, 300, 362, 489, 108, 143, 220, 131, 244, 133, 473, 315, 439, 210, 456, 219, 352, 153, 444, 397, 491, 286, 479, 519, 384, 126, 369, 155, 427, 373, 360, 135, 297, 256, 506, 322, 425, 501, 251, 75, 18, 420, 537, 443, 438, 407, 145, 173, 78, 340, 240, 422, 160, 329, 32, 127, 128, 415, 495, 372, 522, 60, 238, 129, 364, 471, 140, 171, 215, 378, 292, 432, 526, 252, 389, 459, 350, 233, 408, 433, 51, 423, 19, 62, 115, 211, 22, 247, 197, 530, 7, 492, 5, 53, 318, 313, 283, 169, 464, 224, 282, 514, 385, 228, 175, 494, 237, 446, 105, 150, 338, 346, 510, 6, 348, 89, 63, 536, 442, 414, 209, 216, 227, 380, 72, 319, 259, 305, 334, 236, 103, 400, 176, 267, 355, 429, 134, 257, 527, 111, 287, 386, 15, 392, 535, 405, 23, 447, 399, 291, 112, 74, 36, 435, 434, 330, 520, 335, 201, 478, 17, 162, 483, 33, 130, 436, 395, 93, 298, 498, 511, 66, 487, 218, 65, 309, 419, 48, 214, 377, 409, 462, 139, 349, 4, 513, 497, 394, 170, 307, 241, 185, 454, 29, 367, 465, 194, 398, 301, 229, 212, 477, 303, 39, 524, 451, 116, 532, 30, 344, 85, 186, 202, 517, 531, 515, 230, 331, 466, 147, 426, 234, 304, 64, 100, 416, 336, 199, 383, 200, 166, 258, 95, 188, 246, 136, 90, 68, 45, 312, 354, 184, 314, 518, 326, 401, 269, 217, 512, 81, 88, 272, 14, 413, 328, 393, 198, 226, 381, 161, 474, 353, 337, 294, 295, 302, 505, 137, 207, 249, 46, 98, 27, 458, 482, 262, 253, 71, 25, 0, 40, 525, 122, 341, 107, 80, 165, 243, 168, 250, 375, 151, 503, 124, 52, 343, 371, 206, 178, 528, 232, 424, 163, 273, 191, 149, 493, 177, 144, 193, 388, 1, 412, 265, 457, 255, 475, 223, 41, 430, 76, 102, 132, 96, 97, 316, 472, 213, 263, 3, 317, 324, 274, 396, 486, 254, 205, 285, 101, 21, 279, 58, 467, 271, 92, 538, 516, 235, 332, 117, 500, 529, 113, 445, 390, 358, 79, 34, 488, 245, 83, 509, 203, 476, 496, 347, 280, 12, 84, 485, 323, 452, 10, 146, 391, 293, 86, 94, 523, 299, 91, 164, 363, 402, 110, 321, 181, 138, 192, 469, 351, 276, 308, 277, 428, 182, 260, 55, 152, 157, 382, 121, 507, 225, 61, 431, 31, 106, 327, 154, 16, 49, 499, 73, 70, 449, 460, 187, 24, 248, 311, 275, 158, 387, 125, 67, 284, 35, 463, 190, 179, 266, 376, 221, 42, 26, 290, 357, 268, 43, 167, 99, 374, 242, 156, 239, 403, 339, 183, 320, 180, 306, 379, 441, 20, 481, 141, 77, 484, 69, 410, 502, 172, 417, 118, 461, 261, 47, 333, 450, 296, 453, 368, 359, 437, 421, 264, 504, 281, 270, 114, 278, 56, 406, 448, 411, 521, 418, 470, 123, 455, 148, 356, 468, 109, 204, 533, 365, 8, 345, 174, 370, 28, 57, 11, 2, 231, 310, 196, 119, 82, 325, 44, 342, 37, 189, 142, 222, 9, 54, };
66
67uint64_t peggy_smooth_coeffs[sizeof(Peggy_inds)/sizeof(*Peggy_inds)] = // numprimes.13
68{
69 962714545, 962506087, 962158759, 961672710, 961048151, 960285354, 959384649, 958346426, 957171134, // x.8
70 955859283, 954411438, 952828225, 951110328, 949258485, 947273493, 945156207, 942907532, 940528434, // x.17
71 938019929, 935383089, 932619036, 929728945, 926714044, 923575608, 920314964, 916933485, 913432593, // x.26
72 909813756, 906078486, 902228342, 898264923, 894189872, 890004874, 885711650, 881311964, 876807614, // x.35
73 872200436, 867492300, 862685110, 857780804, 852781347, 847688737, 842505000, 837232189, 831872382, // x.44
74 826427681, 820900212, 815292123, 809605581, 803842772, 798005901, 792097186, 786118864, 780073180, // x.53
75 773962395, 767788778, 761554609, 755262175, 748913768, 742511686, 736058231, 729555707, 723006417, // x.62
76 716412665, 709776755, 703100984, 696387648, 689639036, 682857428, 676045100, 669204315, 662337327, // x.71
77 655446378, 648533696, 641601496, 634651978, 627687325, 620709702, 613721256, 606724115, 599720386, // x.80
78 592712154, 585701482, 578690411, 571680955, 564675105, 557674825, 550682053, 543698699, 536726645, // x.89
79 529767743, 522823816, 515896658, 508988029, 502099660, 495233249, 488390461, 481572928, 474782249, // x.98
80 468019988, 461287675, 454586804, 447918836, 441285195, 434687268, 428126409, 421603932, 415121117, // x.107
81 408679208, 402279408, 395922888, 389610779, 383344175, 377124134, 370951677, 364827785, 358753406, // x.116
82 352729449, 346756785, 340836251, 334968645, 329154729, 323395230, 317690838, 312042206, 306449955, // x.125
83 300914667, 295436891, 290017141, 284655897, 279353604, 274110676, 268927490, 263804394, 258741701, // x.134
84 253739694, 248798623, 243918709, 239100140, 234343077, 229647649, 225013957, 220442073, 215932043, // x.143
85 211483883, 207097585, 202773112, 198510404, 194309373, 190169909, 186091877, 182075118, 178119452, // x.152
86 174224676, 170390565, 166616873, 162903335, 159249664, 155655556, 152120688, 148644718, 145227287, // x.161
87 141868021, 138566528, 135322401, 132135218, 129004542, 125929924, 122910901, 119946997, 117037723, // x.170
88 114182582, 111381062, 108632643, 105936795, 103292978, 100700645, 98159238, 95668194, 93226942, // x.179
89 90834903, 88491495, 86196126, 83948203, 81747126, 79592292, 77483092, 75418916, 73399150, // x.188
90 71423178, 69490383, 67600142, 65751837, 63944844, 62178541, 60452305, 58765515, 57117547, // x.197
91 55507781, 53935597, 52400377, 50901505, 49438366, 48010349, 46616844, 45257246, 43930951, // x.206
92 42637360, 41375878, 40145912, 38946876, 37778185, 36639262, 35529533, 34448428, 33395384, // x.215
93 32369842, 31371249, 30399057, 29452725, 28531717, 27635503, 26763558, 25915365, 25090413, // x.224
94 24288196, 23508216, 22749980, 22013003, 21296806, 20600917, 19924870, 19268206, 18630475, // x.233
95 18011231, 17410035, 16826458, 16260073, 15710466, 15177224, 14659944, 14158231, 13671694, // x.242
96 13199950, 12742625, 12299348, 11869759, 11453500, 11050225, 10659590, 10281262, 9914910, // x.251
97 9560213, 9216856, 8884529, 8562931, 8251764, 7950739, 7659571, 7377984, 7105706, // x.260
98 6842471, 6588020, 6342099, 6104460, 5874861, 5653066, 5438844, 5231969, 5032221, // x.269
99 4839386, 4653254, 4473620, 4300287, 4133059, 3971747, 3816167, 3666139, 3521488, // x.278
100 3382043, 3247640, 3118115, 2993313, 2873079, 2757266, 2645728, 2538325, 2434919, // x.287
101 2335380, 2239575, 2147382, 2058677, 1973342, 1891262, 1812325, 1736424, 1663453, // x.296
102 1593311, 1525898, 1461118, 1398879, 1339091, 1281666, 1226519, 1173569, 1122736, // x.305
103 1073944, 1027117, 982185, 939076, 897725, 858065, 820033, 783568, 748612, // x.314
104 715108, 682999, 652233, 622759, 594527, 567488, 541597, 516808, 493079, // x.323
105 470368, 448635, 427841, 407948, 388921, 370725, 353326, 336692, 320792, // x.332
106 305596, 291075, 277202, 263950, 251292, 239204, 227663, 216646, 206130, // x.341
107 196094, 186517, 177381, 168667, 160356, 152430, 144874, 137671, 130806, // x.350
108 124264, 118031, 112093, 106437, 101050, 95921, 91039, 86391, 81968, // x.359
109 77759, 73755, 69945, 66322, 62877, 59602, 56488, 53528, 50716, // x.368
110 48043, 45505, 43093, 40803, 38629, 36564, 34604, 32745, 30980, // x.377
111 29305, 27717, 26211, 24782, 23428, 22144, 20927, 19774, 18681, // x.386
112 17646, 16665, 15737, 14857, 14025, 13237, 12491, 11786, 11118, // x.395
113 10487, 9890, 9325, 8791, 8287, 7810, 7359, 6933, 6531, // x.404
114 6151, 5792, 5453, 5133, 4831, 4547, 4278, 4024, 3785, // x.413
115 3560, 3347, 3147, 2958, 2779, 2612, 2454, 2305, 2164, // x.422
116 2032, 1908, 1791, 1681, 1577, 1480, 1388, 1302, 1221, // x.431
117 1145, 1073, 1006, 942, 883, 827, 775, 725, 679, // x.440
118 636, 595, 557, 521, 487, 456, 426, 399, 373, // x.449
119 348, 325, 304, 284, 265, 248, 231, 216, 202, // x.458
120 188, 175, 164, 153, 142, 133, 124, 115, 107, // x.467
121 100, 93, 87, 81, 75, 70, 65, 61, 56, // x.476
122 53, 49, 45, 42, 39, 36, 34, 31, 29, // x.485
123 27, 25, 23, 22, 20, 19, 17, 16, 15, // x.494
124 14, 13, 12, 11, 10, 9, 9, 8, 7, // x.503
125 7, 6, 6, 5, 5, 5, 4, 4, 4, // x.512
126 3, 3, 3, 3, 2, 2, 2, 2, 2, // x.521
127 2, 2, 1, 1, 1, 1, 1, 1, 1, // x.530
128 1, 1, 1, 1, 1, 1, 0, 0, // isum 100000000000
129};
130
5334d5ad 131uint64_t komodo_maxallowed(int32_t baseid)
132{
dff4ef45 133 uint64_t mult,val = COIN * (uint64_t)10000;
5334d5ad 134 if ( baseid < 0 || baseid >= 32 )
135 return(0);
136 if ( baseid < 10 )
dff4ef45 137 val *= 4;
5334d5ad 138 mult = MINDENOMS[baseid] / MIND;
139 return(mult * val);
140}
141
ab6984e9 142uint64_t komodo_paxvol(uint64_t volume,uint64_t price)
143{
144 if ( volume < 10000000000 )
145 return((volume * price) / 1000000000);
146 else if ( volume < (uint64_t)10 * 10000000000 )
147 return((volume * (price / 10)) / 100000000);
148 else if ( volume < (uint64_t)100 * 10000000000 )
149 return(((volume / 10) * (price / 10)) / 10000000);
150 else if ( volume < (uint64_t)1000 * 10000000000 )
151 return(((volume / 10) * (price / 100)) / 1000000);
152 else if ( volume < (uint64_t)10000 * 10000000000 )
153 return(((volume / 100) * (price / 100)) / 100000);
154 else if ( volume < (uint64_t)100000 * 10000000000 )
155 return(((volume / 100) * (price / 1000)) / 10000);
156 else if ( volume < (uint64_t)1000000 * 10000000000 )
157 return(((volume / 1000) * (price / 1000)) / 1000);
158 else if ( volume < (uint64_t)10000000 * 10000000000 )
159 return(((volume / 1000) * (price / 10000)) / 100);
160 else return(((volume / 10000) * (price / 10000)) / 10);
161}
162
a4ebaad7 163void pax_rank(uint64_t *ranked,uint32_t *pvals)
164{
165 int32_t i; uint64_t vals[32],sum = 0;
166 for (i=0; i<32; i++)
167 {
168 vals[i] = komodo_paxvol(M1SUPPLY[i] / MINDENOMS[i],pvals[i]);
169 sum += vals[i];
170 }
171 for (i=0; i<32; i++)
172 {
173 ranked[i] = (vals[i] * 1000000000) / sum;
56d91e9c 174 //printf("%.6f ",(double)ranked[i]/1000000000.);
a4ebaad7 175 }
56d91e9c 176 //printf("sum %llu\n",(long long)sum);
a4ebaad7 177};
178
520819e7 179#define BTCFACTOR_HEIGHT 466266
180
b4810651 181double PAX_BTCUSD(int32_t height,uint32_t btcusd)
182{
183 double btcfactor,BTCUSD;
184 if ( height >= BTCFACTOR_HEIGHT )
185 btcfactor = 100000.;
186 else btcfactor = 1000.;
187 BTCUSD = ((double)btcusd / (1000000000. / btcfactor));
f972c717 188 if ( height < 500000 && BTCUSD > 20000 )
189 BTCUSD /= 100;
b4810651 190 return(BTCUSD);
191}
192
193int32_t dpow_readprices(int32_t height,uint8_t *data,uint32_t *timestampp,double *KMDBTCp,double *BTCUSDp,double *CNYUSDp,uint32_t *pvals)
1e81ccb7 194{
1bf82154 195 uint32_t kmdbtc,btcusd,cnyusd; int32_t i,n,nonz,len = 0;
0201d1a6 196 if ( data[0] == 'P' && data[5] == 35 )
197 data++;
1e81ccb7 198 len += iguana_rwnum(0,&data[len],sizeof(uint32_t),(void *)timestampp);
199 len += iguana_rwnum(0,&data[len],sizeof(uint32_t),(void *)&n);
7eca18ee 200 if ( n != 35 )
7d59e5c9 201 {
202 printf("dpow_readprices illegal n.%d\n",n);
203 return(-1);
204 }
1e81ccb7 205 len += iguana_rwnum(0,&data[len],sizeof(uint32_t),(void *)&kmdbtc); // /= 1000
206 len += iguana_rwnum(0,&data[len],sizeof(uint32_t),(void *)&btcusd); // *= 1000
207 len += iguana_rwnum(0,&data[len],sizeof(uint32_t),(void *)&cnyusd);
208 *KMDBTCp = ((double)kmdbtc / (1000000000. * 1000.));
b4810651 209 *BTCUSDp = PAX_BTCUSD(height,btcusd);
1e81ccb7 210 *CNYUSDp = ((double)cnyusd / 1000000000.);
1bf82154 211 for (i=nonz=0; i<n-3; i++)
1e81ccb7 212 {
1bf82154 213 if ( pvals[i] != 0 )
214 nonz++;
49df008c 215 //else if ( nonz != 0 )
216 // printf("pvals[%d] is zero\n",i);
1e81ccb7 217 len += iguana_rwnum(0,&data[len],sizeof(uint32_t),(void *)&pvals[i]);
218 //printf("%u ",pvals[i]);
219 }
32f7d394 220 /*if ( nonz < n-3 )
ef7b1ba6 221 {
49df008c 222 //printf("nonz.%d n.%d retval -1\n",nonz,n);
1bf82154 223 return(-1);
32f7d394 224 }*/
1e81ccb7 225 pvals[i++] = kmdbtc;
226 pvals[i++] = btcusd;
227 pvals[i++] = cnyusd;
228 //printf("OP_RETURN prices\n");
229 return(n);
230}
231
b4810651 232int32_t komodo_pax_opreturn(int32_t height,uint8_t *opret,int32_t maxsize)
d019c447 233{
234 static uint32_t lastcrc;
d351e231 235 FILE *fp; char fname[512]; uint32_t crc32,check,timestamp; int32_t i,n=0,retval,fsize,len=0; uint8_t data[8192];
d019c447 236#ifdef WIN32
237 sprintf(fname,"%s\\%s",GetDataDir(false).string().c_str(),(char *)"komodofeed");
238#else
239 sprintf(fname,"%s/%s",GetDataDir(false).string().c_str(),(char *)"komodofeed");
240#endif
241 if ( (fp= fopen(fname,"rb")) != 0 )
242 {
243 fseek(fp,0,SEEK_END);
244 fsize = (int32_t)ftell(fp);
245 rewind(fp);
246 if ( fsize <= maxsize-4 && fsize <= sizeof(data) && fsize > sizeof(crc32) )
247 {
248 if ( (retval= (int32_t)fread(data,1,fsize,fp)) == fsize )
249 {
250 len = iguana_rwnum(0,data,sizeof(crc32),(void *)&crc32);
251 check = calc_crc32(0,data+sizeof(crc32),(int32_t)(fsize-sizeof(crc32)));
252 if ( check == crc32 )
253 {
254 double KMDBTC,BTCUSD,CNYUSD; uint32_t pvals[128];
b4810651 255 if ( dpow_readprices(height,&data[len],&timestamp,&KMDBTC,&BTCUSD,&CNYUSD,pvals) > 0 )
d019c447 256 {
3764439e 257 if ( 0 && lastcrc != crc32 )
d019c447 258 {
1bf82154 259 for (i=0; i<32; i++)
260 printf("%u ",pvals[i]);
261 printf("t%u n.%d KMD %f BTC %f CNY %f (%f)\n",timestamp,n,KMDBTC,BTCUSD,CNYUSD,CNYUSD!=0?1./CNYUSD:0);
d019c447 262 }
1bf82154 263 if ( timestamp > time(NULL)-600 )
264 {
265 n = komodo_opreturnscript(opret,'P',data+sizeof(crc32),(int32_t)(fsize-sizeof(crc32)));
266 if ( 0 && lastcrc != crc32 )
267 {
268 for (i=0; i<n; i++)
269 printf("%02x",opret[i]);
270 printf(" coinbase opret[%d] crc32.%u:%u\n",n,crc32,check);
271 }
272 } //else printf("t%u too old for %u\n",timestamp,(uint32_t)time(NULL));
273 lastcrc = crc32;
274 }
d019c447 275 } else printf("crc32 %u mismatch %u\n",crc32,check);
276 } else printf("fread.%d error != fsize.%d\n",retval,fsize);
277 } else printf("fsize.%d > maxsize.%d or data[%d]\n",fsize,maxsize,(int32_t)sizeof(data));
278 fclose(fp);
768dccac 279 } //else printf("couldnt open %s\n",fname);
d019c447 280 return(n);
281}
282
1e81ccb7 283/*uint32_t PAX_val32(double val)
284 {
285 uint32_t val32 = 0; struct price_resolution price;
286 if ( (price.Pval= val*1000000000) != 0 )
287 {
288 if ( price.Pval > 0xffffffff )
289 printf("Pval overflow error %lld\n",(long long)price.Pval);
290 else val32 = (uint32_t)price.Pval;
291 }
292 return(val32);
293 }*/
294
57abdbaf 295int32_t PAX_pubkey(int32_t rwflag,uint8_t *pubkey33,uint8_t *addrtypep,uint8_t rmd160[20],char fiat[4],uint8_t *shortflagp,int64_t *fiatoshisp)
d019c447 296{
57abdbaf 297 if ( rwflag != 0 )
298 {
299 memset(pubkey33,0,33);
300 pubkey33[0] = 0x02 | (*shortflagp != 0);
301 memcpy(&pubkey33[1],fiat,3);
302 iguana_rwnum(rwflag,&pubkey33[4],sizeof(*fiatoshisp),(void *)fiatoshisp);
303 pubkey33[12] = *addrtypep;
304 memcpy(&pubkey33[13],rmd160,20);
305 }
306 else
307 {
308 *shortflagp = (pubkey33[0] == 0x03);
4d272ae4 309 memcpy(fiat,&pubkey33[1],3);
4d272ae4 310 fiat[3] = 0;
57abdbaf 311 iguana_rwnum(rwflag,&pubkey33[4],sizeof(*fiatoshisp),(void *)fiatoshisp);
312 if ( *shortflagp != 0 )
313 *fiatoshisp = -(*fiatoshisp);
314 *addrtypep = pubkey33[12];
315 memcpy(rmd160,&pubkey33[13],20);
316 }
d351e231 317 return(33);
d019c447 318}
319
1e81ccb7 320double PAX_val(uint32_t pval,int32_t baseid)
321{
322 //printf("PAX_val baseid.%d pval.%u\n",baseid,pval);
323 if ( baseid >= 0 && baseid < MAX_CURRENCIES )
324 return(((double)pval / 1000000000.) / MINDENOMS[baseid]);
325 return(0.);
326}
327
328void komodo_pvals(int32_t height,uint32_t *pvals,uint8_t numpvals)
329{
5c481612 330 int32_t i,nonz; uint32_t kmdbtc,btcusd,cnyusd; double KMDBTC,BTCUSD,CNYUSD;
1e81ccb7 331 if ( numpvals >= 35 )
332 {
333 for (nonz=i=0; i<32; i++)
334 {
335 if ( pvals[i] != 0 )
336 nonz++;
337 //printf("%u ",pvals[i]);
338 }
339 if ( nonz == 32 )
340 {
341 kmdbtc = pvals[i++];
342 btcusd = pvals[i++];
343 cnyusd = pvals[i++];
5c481612 344 KMDBTC = ((double)kmdbtc / (1000000000. * 1000.));
b4810651 345 BTCUSD = PAX_BTCUSD(height,btcusd);
5c481612 346 CNYUSD = ((double)cnyusd / 1000000000.);
f42f9288 347 portable_mutex_lock(&komodo_mutex);
1e81ccb7 348 PVALS = (uint32_t *)realloc(PVALS,(NUM_PRICES+1) * sizeof(*PVALS) * 36);
349 PVALS[36 * NUM_PRICES] = height;
350 memcpy(&PVALS[36 * NUM_PRICES + 1],pvals,sizeof(*pvals) * 35);
351 NUM_PRICES++;
f42f9288 352 portable_mutex_unlock(&komodo_mutex);
bf75a6e7 353 if ( 0 )
298ca9e5 354 printf("OP_RETURN.%d KMD %.8f BTC %.6f CNY %.6f NUM_PRICES.%d (%llu %llu %llu)\n",height,KMDBTC,BTCUSD,CNYUSD,NUM_PRICES,(long long)kmdbtc,(long long)btcusd,(long long)cnyusd);
1e81ccb7 355 }
356 }
357}
358
8ff56739 359uint64_t komodo_paxcorrelation(uint64_t *votes,int32_t numvotes,uint64_t seed)
a4ebaad7 360{
295e677f 361 int32_t i,j,k,ind,zeroes,wt,nonz; int64_t delta; uint64_t lastprice,tolerance,den,densum,sum=0;
362 for (sum=i=zeroes=nonz=0; i<numvotes; i++)
363 {
364 if ( votes[i] == 0 )
365 zeroes++;
366 else sum += votes[i], nonz++;
367 }
8ea67f05 368 if ( nonz < (numvotes >> 2) )
7851554d 369 return(0);
295e677f 370 sum /= nonz;
371 lastprice = sum;
372 for (i=0; i<numvotes; i++)
373 {
374 if ( votes[i] == 0 )
375 votes[i] = lastprice;
8ff56739 376 else lastprice = votes[i];
295e677f 377 }
b5d53e71 378 tolerance = sum / 50;
295e677f 379 for (k=0; k<numvotes; k++)
380 {
381 ind = Peggy_inds[(k + seed) % numvotes];
382 i = (int32_t)(ind % numvotes);
383 wt = 0;
384 if ( votes[i] != 0 )
385 {
386 for (j=0; j<numvotes; j++)
387 {
388 if ( votes[j] != 0 )
389 {
390 if ( (delta= (votes[i] - votes[j])) < 0 )
391 delta = -delta;
e2ca75ae 392 if ( delta <= tolerance )
393 {
394 wt++;
395 if ( wt > (numvotes >> 1) )
396 break;
397 }
295e677f 398 }
399 }
400 }
401 if ( wt > (numvotes >> 1) )
402 {
403 ind = i;
404 for (densum=sum=j=0; j<numvotes; j++)
405 {
406 den = peggy_smooth_coeffs[j];
407 densum += den;
408 sum += (den * votes[(ind + j) % numvotes]);
8ff56739 409 //printf("(%llu/%llu %.8f) ",(long long)sum,(long long)densum,(double)sum/densum);
295e677f 410 }
8ea67f05 411 if ( densum != 0 )
412 sum /= densum;
8ff56739 413 //sum = (sum * basevolume);
414 //printf("paxprice seed.%llx sum %.8f densum %.8f\n",(long long)seed,dstr(sum),dstr(densum));
295e677f 415 break;
196b41a5 416 }
295e677f 417 }
418 return(sum);
419}
420
5b5af603 421uint64_t komodo_paxcalc(int32_t height,uint32_t *pvals,int32_t baseid,int32_t relid,uint64_t basevolume,uint64_t refkmdbtc,uint64_t refbtcusd)
295e677f 422{
b4810651 423 uint32_t pvalb,pvalr; double BTCUSD; uint64_t price,kmdbtc,btcusd,usdvol,baseusd,usdkmd,baserel,ranked[32];
ac606ad4 424 if ( basevolume > KOMODO_PAXMAX )
97865d36 425 {
426 printf("paxcalc overflow %.8f\n",dstr(basevolume));
2e4514ce 427 return(0);
97865d36 428 }
a4ebaad7 429 if ( (pvalb= pvals[baseid]) != 0 )
430 {
431 if ( relid == MAX_CURRENCIES )
432 {
d2f213b8 433 if ( height < 236000 )
434 {
435 if ( kmdbtc == 0 )
436 kmdbtc = pvals[MAX_CURRENCIES];
437 if ( btcusd == 0 )
438 btcusd = pvals[MAX_CURRENCIES + 1];
439 }
440 else
441 {
442 if ( (kmdbtc= pvals[MAX_CURRENCIES]) == 0 )
443 kmdbtc = refkmdbtc;
444 if ( (btcusd= pvals[MAX_CURRENCIES + 1]) == 0 )
445 btcusd = refbtcusd;
446 }
5fe8a65f 447 if ( kmdbtc < 25000000 )
448 kmdbtc = 25000000;
a4ebaad7 449 if ( pvals[USD] != 0 && kmdbtc != 0 && btcusd != 0 )
450 {
b0c7fb04 451 baseusd = (((uint64_t)pvalb * 1000000000) / pvals[USD]);
445e9606 452 usdvol = komodo_paxvol(basevolume,baseusd);
414bd08b 453 usdkmd = ((uint64_t)kmdbtc * 1000000000) / btcusd;
e2ca75ae 454 if ( height >= 236000-10 )
7b9c2935 455 {
b4810651 456 BTCUSD = PAX_BTCUSD(height,btcusd);
a8256266 457 if ( height < 500000 && BTCUSD > 20000 )
458 usdkmd = ((uint64_t)kmdbtc * btcusd) / 1000000000;
459 else usdkmd = ((uint64_t)kmdbtc * btcusd) / 10000000;
460 ///if ( height >= BTCFACTOR_HEIGHT && BTCUSD >= 43 )
461 // usdkmd = ((uint64_t)kmdbtc * btcusd) / 10000000;
462 //else usdkmd = ((uint64_t)kmdbtc * btcusd) / 1000000000;
b5da879e 463 price = ((uint64_t)10000000000 * MINDENOMS[USD] / MINDENOMS[baseid]) / komodo_paxvol(usdvol,usdkmd);
a8256266 464 fprintf(stderr,"ht.%d %.3f kmdbtc.%llu btcusd.%llu base -> USD %llu, usdkmd %llu usdvol %llu -> %llu\n",height,BTCUSD,(long long)kmdbtc,(long long)btcusd,(long long)baseusd,(long long)usdkmd,(long long)usdvol,(long long)(MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd) / (MINDENOMS[baseid]/100)));
0ce1e753 465 //fprintf(stderr,"usdkmd.%llu basevolume.%llu baseusd.%llu paxvol.%llu usdvol.%llu -> %llu %llu\n",(long long)usdkmd,(long long)basevolume,(long long)baseusd,(long long)komodo_paxvol(basevolume,baseusd),(long long)usdvol,(long long)(MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd) / (MINDENOMS[baseid]/100)),(long long)price);
1049be8e 466 //fprintf(stderr,"usdkmd.%llu basevolume.%llu baseusd.%llu paxvol.%llu usdvol.%llu -> %llu\n",(long long)usdkmd,(long long)basevolume,(long long)baseusd,(long long)komodo_paxvol(basevolume,baseusd),(long long)usdvol,(long long)(MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd) / (MINDENOMS[baseid]/100)));
5ab5e9ff 467 } else price = (MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd) / (MINDENOMS[baseid]/100));
6bb5b220 468 return(price);
ee0744d2 469 } //else printf("zero val in KMD conv %llu %llu %llu\n",(long long)pvals[USD],(long long)kmdbtc,(long long)btcusd);
a4ebaad7 470 }
471 else if ( baseid == relid )
472 {
56d91e9c 473 if ( baseid != MAX_CURRENCIES )
474 {
475 pax_rank(ranked,pvals);
9ef47e29 476 //printf("%s M1 percentage %.8f\n",CURRENCIES[baseid],dstr(10 * ranked[baseid]));
5d299045 477 return(10 * ranked[baseid]); // scaled percentage of M1 total
97865d36 478 } else return(basevolume);
a4ebaad7 479 }
480 else if ( (pvalr= pvals[relid]) != 0 )
481 {
482 baserel = ((uint64_t)pvalb * 1000000000) / pvalr;
4077bfb0 483 //printf("baserel.%lld %lld %lld %.8f %.8f\n",(long long)baserel,(long long)MINDENOMS[baseid],(long long)MINDENOMS[relid],dstr(MINDENOMS[baseid]/MINDENOMS[relid]),dstr(MINDENOMS[relid]/MINDENOMS[baseid]));
b6f95ae6 484 if ( MINDENOMS[baseid] > MINDENOMS[relid] )
fde4e779 485 basevolume /= (MINDENOMS[baseid] / MINDENOMS[relid]);
b6f95ae6 486 else if ( MINDENOMS[baseid] < MINDENOMS[relid] )
fde4e779 487 basevolume *= (MINDENOMS[relid] / MINDENOMS[baseid]);
1a6bc62c 488 return(komodo_paxvol(basevolume,baserel));
a4ebaad7 489 }
97865d36 490 else printf("null pval for %s\n",CURRENCIES[relid]);
491 } else printf("null pval for %s\n",CURRENCIES[baseid]);
08ef004d 492 return(0);
a4ebaad7 493}
494
295e677f 495uint64_t _komodo_paxprice(uint64_t *kmdbtcp,uint64_t *btcusdp,int32_t height,char *base,char *rel,uint64_t basevolume,uint64_t kmdbtc,uint64_t btcusd)
1e81ccb7 496{
298ca9e5 497 int32_t baseid=-1,relid=-1,i; uint32_t *ptr,*pvals;
4307bd89 498 if ( height > 10 )
499 height -= 10;
1e81ccb7 500 if ( (baseid= komodo_baseid(base)) >= 0 && (relid= komodo_baseid(rel)) >= 0 )
501 {
bba30a43 502 //portable_mutex_lock(&komodo_mutex);
1e81ccb7 503 for (i=NUM_PRICES-1; i>=0; i--)
504 {
505 ptr = &PVALS[36 * i];
506 if ( *ptr < height )
295e677f 507 {
298ca9e5 508 pvals = &ptr[1];
9e838b49 509 if ( kmdbtcp != 0 && btcusdp != 0 )
510 {
298ca9e5 511 *kmdbtcp = pvals[MAX_CURRENCIES] / 539;
512 *btcusdp = pvals[MAX_CURRENCIES + 1] / 539;
9e838b49 513 }
bba30a43 514 //portable_mutex_unlock(&komodo_mutex);
295e677f 515 if ( kmdbtc != 0 && btcusd != 0 )
298ca9e5 516 return(komodo_paxcalc(height,pvals,baseid,relid,basevolume,kmdbtc,btcusd));
295e677f 517 else return(0);
518 }
1e81ccb7 519 }
bba30a43 520 //portable_mutex_unlock(&komodo_mutex);
72da1eea 521 } //else printf("paxprice invalid base.%s %d, rel.%s %d\n",base,baseid,rel,relid);
1e81ccb7 522 return(0);
523}
524
e08169c4 525int32_t komodo_kmdbtcusd(int32_t rwflag,uint64_t *kmdbtcp,uint64_t *btcusdp,int32_t height)
526{
703cc8c9 527 static uint64_t *KMDBTCS,*BTCUSDS; static int32_t maxheight = 0; int32_t incr = 10000;
e08169c4 528 if ( height >= maxheight )
529 {
d854fae2 530 //printf("height.%d maxheight.%d incr.%d\n",height,maxheight,incr);
bfadcf9c 531 if ( height >= maxheight+incr )
532 incr = (height - (maxheight+incr) + 1000);
c9da2420 533 KMDBTCS = (uint64_t *)realloc(KMDBTCS,((incr + maxheight) * sizeof(*KMDBTCS)));
e08169c4 534 memset(&KMDBTCS[maxheight],0,(incr * sizeof(*KMDBTCS)));
c9da2420 535 BTCUSDS = (uint64_t *)realloc(BTCUSDS,((incr + maxheight) * sizeof(*BTCUSDS)));
e08169c4 536 memset(&BTCUSDS[maxheight],0,(incr * sizeof(*BTCUSDS)));
537 maxheight += incr;
538 }
539 if ( rwflag == 0 )
540 {
541 *kmdbtcp = KMDBTCS[height];
542 *btcusdp = BTCUSDS[height];
543 }
544 else
545 {
546 KMDBTCS[height] = *kmdbtcp;
547 BTCUSDS[height] = *btcusdp;
548 }
549 if ( *kmdbtcp != 0 && *btcusdp != 0 )
550 return(0);
551 else return(-1);
552}
553
5b5af603 554uint64_t _komodo_paxpriceB(uint64_t seed,int32_t height,char *base,char *rel,uint64_t basevolume)
2e9292fe 555{
571f648d 556 int32_t i,j,k,ind,zeroes,numvotes,wt,nonz; int64_t delta; uint64_t lastprice,tolerance,den,densum,sum=0,votes[sizeof(Peggy_inds)/sizeof(*Peggy_inds)],btcusds[sizeof(Peggy_inds)/sizeof(*Peggy_inds)],kmdbtcs[sizeof(Peggy_inds)/sizeof(*Peggy_inds)],kmdbtc,btcusd;
ac606ad4 557 if ( basevolume > KOMODO_PAXMAX )
77af0879 558 {
559 printf("komodo_paxprice overflow %.8f\n",dstr(basevolume));
560 return(0);
561 }
b0c7fb04 562 if ( strcmp(base,"KMD") == 0 || strcmp(base,"kmd") == 0 )
563 {
564 printf("kmd cannot be base currency\n");
565 return(0);
566 }
2e9292fe 567 numvotes = (int32_t)(sizeof(Peggy_inds)/sizeof(*Peggy_inds));
568 memset(votes,0,sizeof(votes));
fa7d97db 569 //if ( komodo_kmdbtcusd(0,&kmdbtc,&btcusd,height) < 0 ) crashes when via passthru GUI use
a6cd9b28 570 {
e08169c4 571 memset(btcusds,0,sizeof(btcusds));
572 memset(kmdbtcs,0,sizeof(kmdbtcs));
573 for (i=0; i<numvotes; i++)
574 {
4350833c 575 _komodo_paxprice(&kmdbtcs[numvotes-1-i],&btcusds[numvotes-1-i],height-i,base,rel,100000,0,0);
e2ca75ae 576 //printf("(%llu %llu) ",(long long)kmdbtcs[numvotes-1-i],(long long)btcusds[numvotes-1-i]);
e08169c4 577 }
8ff56739 578 kmdbtc = komodo_paxcorrelation(kmdbtcs,numvotes,seed) * 539;
579 btcusd = komodo_paxcorrelation(btcusds,numvotes,seed) * 539;
9f9d5114 580 //komodo_kmdbtcusd(1,&kmdbtc,&btcusd,height);
a6cd9b28 581 }
295e677f 582 for (i=nonz=0; i<numvotes; i++)
68f2120f 583 {
4350833c 584 if ( (votes[numvotes-1-i]= _komodo_paxprice(0,0,height-i,base,rel,100000,kmdbtc,btcusd)) == 0 )
9fd7459c 585 zeroes++;
331b7eed 586 else
587 {
588 nonz++;
589 sum += votes[numvotes-1-i];
8ff56739 590 //if ( (i % 10) == 0 )
196b41a5 591 // fprintf(stderr,"[%llu] ",(long long)votes[numvotes-1-i]);
331b7eed 592 }
68f2120f 593 }
3f0bb976 594 //fprintf(stderr,"kmdbtc %llu btcusd %llu ",(long long)kmdbtc,(long long)btcusd);
595 //fprintf(stderr,"komodo_paxprice nonz.%d of numvotes.%d seed.%llu %.8f\n",nonz,numvotes,(long long)seed,nonz!=0?dstr(1000. * (double)sum/nonz):0);
196b41a5 596 if ( nonz <= (numvotes >> 1) )
b5da879e 597 {
8ff56739 598 return(0);
b5da879e 599 }
8ff56739 600 return(komodo_paxcorrelation(votes,numvotes,seed) * basevolume / 100000);
2e9292fe 601}
602
5b5af603 603uint64_t komodo_paxpriceB(uint64_t seed,int32_t height,char *base,char *rel,uint64_t basevolume)
d4487f05 604{
605 uint64_t baseusd,basekmd,usdkmd; int32_t baseid = komodo_baseid(base);
606 if ( height >= 236000 && strcmp(rel,"kmd") == 0 )
607 {
608 usdkmd = _komodo_paxpriceB(seed,height,(char *)"USD",(char *)"KMD",SATOSHIDEN);
609 if ( strcmp("usd",base) == 0 )
5484ec26 610 return(komodo_paxvol(basevolume,usdkmd) * 10);
d4487f05 611 baseusd = _komodo_paxpriceB(seed,height,base,(char *)"USD",SATOSHIDEN);
612 basekmd = (komodo_paxvol(basevolume,baseusd) * usdkmd) / 10000000;
3f0bb976 613 //if ( strcmp("KMD",base) == 0 )
614 // printf("baseusd.%llu usdkmd.%llu %llu\n",(long long)baseusd,(long long)usdkmd,(long long)basekmd);
d4487f05 615 return(basekmd);
616 } else return(_komodo_paxpriceB(seed,height,base,rel,basevolume));
617}
618
e2ca75ae 619/*uint64_t komodo_paxpriceB(uint64_t seed,int32_t height,char *base,char *rel,uint64_t basevolume)
620{
621 uint64_t baseusd,basekmd,usdkmd; int32_t baseid = komodo_baseid(base);
622 //if ( strcmp(rel,"KMD") != 0 || baseid < 0 || MINDENOMS[baseid] == MINDENOMS[USD] )
623 // return(_komodo_paxpriceB(seed,height,base,rel,basevolume));
624 //else
625 {
626 baseusd = _komodo_paxpriceB(seed,height,base,(char *)"USD",SATOSHIDEN);
627 usdkmd = _komodo_paxpriceB(seed,height,(char *)"USD",(char *)"KMD",SATOSHIDEN);
628 basekmd = (komodo_paxvol(basevolume,baseusd) * usdkmd) / 10000000;
629 if ( strcmp("KMD",base) == 0 )
630 printf("baseusd.%llu usdkmd.%llu %llu\n",(long long)baseusd,(long long)usdkmd,(long long)basekmd);
631 return(basekmd);
632 }
633}*/
634
eea23236 635uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uint64_t basevolume)
636{
acd6ccf4 637 int32_t i,nonz=0; int64_t diff; uint64_t price,seed,sum = 0;
df96c294 638 if ( ASSETCHAINS_SYMBOL[0] == 0 && chainActive.Tip() != 0 && height > chainActive.Tip()->nHeight )
639 {
796bbf8a 640 if ( height < 100000000 )
ee0c53e5 641 printf("komodo_paxprice height.%d vs tip.%d\n",height,chainActive.Tip()->nHeight);
10854282 642 return(0);
df96c294 643 }
b9f308cf 644 *seedp = komodo_seed(height);
bba30a43 645 portable_mutex_lock(&komodo_mutex);
93139074 646 for (i=0; i<17; i++)
eea23236 647 {
b9f308cf 648 if ( (price= komodo_paxpriceB(*seedp,height-i,base,rel,basevolume)) != 0 )
eea23236 649 {
650 sum += price;
651 nonz++;
8ff56739 652 if ( 0 && i == 1 && nonz == 2 )
e8bd824b 653 {
395fae6b 654 diff = (((int64_t)price - (sum >> 1)) * 10000);
e8bd824b 655 if ( diff < 0 )
656 diff = -diff;
395fae6b 657 diff /= price;
6b9b9aca 658 printf("(%llu %llu %lld).%lld ",(long long)price,(long long)(sum>>1),(long long)(((int64_t)price - (sum >> 1)) * 10000),(long long)diff);
659 if ( diff < 33 )
e8bd824b 660 break;
e8bd824b 661 }
93139074 662 else if ( 0 && i == 3 && nonz == 4 )
e8bd824b 663 {
395fae6b 664 diff = (((int64_t)price - (sum >> 2)) * 10000);
e8bd824b 665 if ( diff < 0 )
666 diff = -diff;
395fae6b 667 diff /= price;
6b9b9aca 668 printf("(%llu %llu %lld).%lld ",(long long)price,(long long)(sum>>2),(long long) (((int64_t)price - (sum >> 2)) * 10000),(long long)diff);
669 if ( diff < 20 )
e8bd824b 670 break;
8ff56739 671 }
eea23236 672 }
ce3302c9 673 if ( height < 165000 || height > 236000 )
fa7d97db 674 break;
eea23236 675 }
bba30a43 676 portable_mutex_unlock(&komodo_mutex);
eea23236 677 if ( nonz != 0 )
678 sum /= nonz;
e2ca75ae 679 //printf("-> %lld %s/%s i.%d ht.%d\n",(long long)sum,base,rel,i,height);
eea23236 680 return(sum);
681}
682
d836ec3f 683int32_t komodo_paxprices(int32_t *heights,uint64_t *prices,int32_t max,char *base,char *rel)
a4ebaad7 684{
b20a5d7f 685 int32_t baseid=-1,relid=-1,i,num = 0; uint32_t *ptr;
a4ebaad7 686 if ( (baseid= komodo_baseid(base)) >= 0 && (relid= komodo_baseid(rel)) >= 0 )
687 {
688 for (i=NUM_PRICES-1; i>=0; i--)
689 {
690 ptr = &PVALS[36 * i];
56d91e9c 691 heights[num] = *ptr;
d5f0a866 692 prices[num] = komodo_paxcalc(*ptr,&ptr[1],baseid,relid,COIN,0,0);
56d91e9c 693 num++;
694 if ( num >= max )
695 return(num);
a4ebaad7 696 }
697 }
56d91e9c 698 return(num);
a4ebaad7 699}
700
cd1fcb48 701void komodo_paxpricefeed(int32_t height,uint8_t *pricefeed,int32_t opretlen)
47e5cbc1 702{
703 double KMDBTC,BTCUSD,CNYUSD; uint32_t numpvals,timestamp,pvals[128]; uint256 zero;
b4810651 704 numpvals = dpow_readprices(height,pricefeed,&timestamp,&KMDBTC,&BTCUSD,&CNYUSD,pvals);
47e5cbc1 705 memset(&zero,0,sizeof(zero));
e155dbe9 706 komodo_stateupdate(height,0,0,0,zero,0,0,pvals,numpvals,0,0,0,0,0,0);
bf75a6e7 707 if ( 1 )
3764439e 708 {
709 int32_t i;
710 for (i=0; i<numpvals; i++)
711 printf("%u ",pvals[i]);
768dccac 712 printf("komodo_paxpricefeed vout OP_RETURN.%d prices numpvals.%d opretlen.%d kmdbtc %.8f BTCUSD %.8f CNYUSD %.8f\n",height,numpvals,opretlen,KMDBTC,BTCUSD,CNYUSD);
3764439e 713 }
47e5cbc1 714}
715
0bda6249 716uint64_t PAX_fiatdest(uint64_t *seedp,int32_t tokomodo,char *destaddr,uint8_t pubkey33[33],char *coinaddr,int32_t height,char *origbase,int64_t fiatoshis)
1e81ccb7 717{
fe965b1c 718 uint8_t shortflag = 0; char base[4]; int32_t i,baseid; uint8_t addrtype,rmd160[20]; int64_t komodoshis = 0;
df96c294 719 *seedp = komodo_seed(height);
7c6f8298 720 if ( (baseid= komodo_baseid(origbase)) < 0 || baseid == MAX_CURRENCIES )
c3fa7fad 721 {
106a1d04 722 if ( 0 && origbase[0] != 0 )
e4bef239 723 printf("[%s] PAX_fiatdest illegal base.(%s)\n",ASSETCHAINS_SYMBOL,origbase);
d019c447 724 return(0);
c3fa7fad 725 }
3ba8f923 726 for (i=0; i<3; i++)
727 base[i] = toupper(origbase[i]);
728 base[i] = 0;
30e79ca6 729 if ( fiatoshis < 0 )
730 shortflag = 1, fiatoshis = -fiatoshis;
0bda6249 731 komodoshis = komodo_paxprice(seedp,height,base,(char *)"KMD",(uint64_t)fiatoshis);
8b4d7f27 732 //printf("PAX_fiatdest ht.%d price %s %.8f -> KMD %.8f seed.%llx\n",height,base,(double)fiatoshis/COIN,(double)komodoshis/COIN,(long long)*seedp);
d019c447 733 if ( bitcoin_addr2rmd160(&addrtype,rmd160,coinaddr) == 20 )
1e81ccb7 734 {
7c6f8298 735 PAX_pubkey(1,pubkey33,&addrtype,rmd160,base,&shortflag,tokomodo != 0 ? &komodoshis : &fiatoshis);
d019c447 736 bitcoin_address(destaddr,KOMODO_PUBTYPE,pubkey33,33);
1e81ccb7 737 }
d019c447 738 return(komodoshis);
1e81ccb7 739}
This page took 0.339961 seconds and 4 git commands to generate.