1 /******************************************************************************
2 * Copyright © 2014-2017 The SuperNET Developers. *
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. *
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 *
12 * Removal or modification of this copyright notice is prohibited. *
14 ******************************************************************************/
16 #define KOMODO_MAINNET_START 178999
18 const char *Notaries_genesis[][2] =
20 { "jl777_testA", "03b7621b44118017a16043f19b30cc8a4cfe068ac4e42417bae16ba460c80f3828" },
21 { "jl777_testB", "02ebfc784a4ba768aad88d44d1045d240d47b26e248cafaf1c5169a42d7a61d344" },
22 { "pondsea_SH", "02209073bc0943451498de57f802650311b1f12aa6deffcd893da198a544c04f36" },
23 { "crackers_EU", "0340c66cf2c41c41efb420af57867baa765e8468c12aa996bfd816e1e07e410728" },
24 { "pondsea_EU", "0225aa6f6f19e543180b31153d9e6d55d41bc7ec2ba191fd29f19a2f973544e29d" },
25 { "locomb_EU", "025c6d26649b9d397e63323d96db42a9d3caad82e1d6076970efe5056c00c0779b" },
26 { "fullmoon_AE", "0204a908350b8142698fdb6fabefc97fe0e04f537adc7522ba7a1e8f3bec003d4a" },
27 { "movecrypto_EU", "021ab53bc6cf2c46b8a5456759f9d608966eff87384c2b52c0ac4cc8dd51e9cc42" },
28 { "badass_EU", "0209d48554768dd8dada988b98aca23405057ac4b5b46838a9378b95c3e79b9b9e" },
29 { "crackers_NA", "029e1c01131974f4cd3f564cc0c00eb87a0f9721043fbc1ca60f9bd0a1f73f64a1" },
30 { "proto_EU", "03681ffdf17c8f4f0008cefb7fa0779c5e888339cdf932f0974483787a4d6747c1" }, // 10
31 { "jeezy_EU", "023cb3e593fb85c5659688528e9a4f1c4c7f19206edc7e517d20f794ba686fd6d6" },
32 { "farl4web_EU", "035caa40684ace968677dca3f09098aa02b70e533da32390a7654c626e0cf908e1" },
33 { "nxtswe_EU", "032fb104e5eaa704a38a52c126af8f67e870d70f82977e5b2f093d5c1c21ae5899" },
34 { "traderbill_EU", "03196e8de3e2e5d872f31d79d6a859c8704a2198baf0af9c7b21e29656a7eb455f" },
35 { "vanbreuk_EU", "024f3cad7601d2399c131fd070e797d9cd8533868685ddbe515daa53c2e26004c3" }, // 15
36 { "titomane_EU", "03517fcac101fed480ae4f2caf775560065957930d8c1facc83e30077e45bdd199" },
37 { "supernet_AE", "029d93ef78197dc93892d2a30e5a54865f41e0ca3ab7eb8e3dcbc59c8756b6e355" },
38 { "supernet_EU", "02061c6278b91fd4ac5cab4401100ffa3b2d5a277e8f71db23401cc071b3665546" },
39 { "supernet_NA", "033c073366152b6b01535e15dd966a3a8039169584d06e27d92a69889b720d44e1" },
40 { "yassin_EU", "033fb7231bb66484081952890d9a03f91164fb27d392d9152ec41336b71b15fbd0" }, // 20
41 { "durerus_EU", "02bcbd287670bdca2c31e5d50130adb5dea1b53198f18abeec7211825f47485d57" },
42 { "badass_SH", "026b49dd3923b78a592c1b475f208e23698d3f085c4c3b4906a59faf659fd9530b" },
43 { "badass_NA", "02afa1a9f948e1634a29dc718d218e9d150c531cfa852843a1643a02184a63c1a7" },
44 { "pondsea_NA", "031bcfdbb62268e2ff8dfffeb9ddff7fe95fca46778c77eebff9c3829dfa1bb411" },
45 { "rnr_EU", "0287aa4b73988ba26cf6565d815786caf0d2c4af704d7883d163ee89cd9977edec" },
46 { "crackers_SH", "02313d72f9a16055737e14cfc528dcd5d0ef094cfce23d0348fe974b6b1a32e5f0" },
47 { "grewal_SH", "03212a73f5d38a675ee3cdc6e82542a96c38c3d1c79d25a1ed2e42fcf6a8be4e68" },
48 { "polycryptoblock_NA", "02708dcda7c45fb54b78469673c2587bfdd126e381654819c4c23df0e00b679622" },
49 { "titomane_NA", "0387046d9745414fb58a0fa3599078af5073e10347e4657ef7259a99cb4f10ad47" },
50 { "titomane_AE", "03cda6ca5c2d02db201488a54a548dbfc10533bdc275d5ea11928e8d6ab33c2185" },
51 { "kolo_EU", "03f5c08dadffa0ffcafb8dd7ffc38c22887bd02702a6c9ac3440deddcf2837692b" },
52 { "artik_NA", "0224e31f93eff0cc30eaf0b2389fbc591085c0e122c4d11862c1729d090106c842" },
53 { "eclips_EU", "0339369c1f5a2028d44be7be6f8ec3b907fdec814f87d2dead97cab4edb71a42e9" },
54 { "titomane_SH", "035f49d7a308dd9a209e894321f010d21b7793461b0c89d6d9231a3fe5f68d9960" },
57 const char *Notaries_elected[][2] =
59 { "0_jl777_testA", "03b7621b44118017a16043f19b30cc8a4cfe068ac4e42417bae16ba460c80f3828" },
60 { "0_jl777_testB", "02ebfc784a4ba768aad88d44d1045d240d47b26e248cafaf1c5169a42d7a61d344" },
61 { "0_kolo_testA", "0287aa4b73988ba26cf6565d815786caf0d2c4af704d7883d163ee89cd9977edec" },
62 { "artik_AR", "029acf1dcd9f5ff9c455f8bb717d4ae0c703e089d16cf8424619c491dff5994c90" },
63 { "artik_EU", "03f54b2c24f82632e3cdebe4568ba0acf487a80f8a89779173cdb78f74514847ce" },
64 { "artik_NA", "0224e31f93eff0cc30eaf0b2389fbc591085c0e122c4d11862c1729d090106c842" },
65 { "artik_SH", "02bdd8840a34486f38305f311c0e2ae73e84046f6e9c3dd3571e32e58339d20937" },
66 { "badass_EU", "0209d48554768dd8dada988b98aca23405057ac4b5b46838a9378b95c3e79b9b9e" },
67 { "badass_NA", "02afa1a9f948e1634a29dc718d218e9d150c531cfa852843a1643a02184a63c1a7" },
68 { "badass_SH", "026b49dd3923b78a592c1b475f208e23698d3f085c4c3b4906a59faf659fd9530b" },
69 { "crackers_EU", "03bc819982d3c6feb801ec3b720425b017d9b6ee9a40746b84422cbbf929dc73c3" }, // 10
70 { "crackers_NA", "03205049103113d48c7c7af811b4c8f194dafc43a50d5313e61a22900fc1805b45" },
71 { "crackers_SH", "02be28310e6312d1dd44651fd96f6a44ccc269a321f907502aae81d246fabdb03e" },
72 { "durerus_EU", "02bcbd287670bdca2c31e5d50130adb5dea1b53198f18abeec7211825f47485d57" },
73 { "etszombi_AR", "031c79168d15edabf17d9ec99531ea9baa20039d0cdc14d9525863b83341b210e9" },
74 { "etszombi_EU", "0281b1ad28d238a2b217e0af123ce020b79e91b9b10ad65a7917216eda6fe64bf7" }, // 15
75 { "etszombi_SH", "025d7a193c0757f7437fad3431f027e7b5ed6c925b77daba52a8755d24bf682dde" },
76 { "farl4web_EU", "0300ecf9121cccf14cf9423e2adb5d98ce0c4e251721fa345dec2e03abeffbab3f" },
77 { "farl4web_SH", "0396bb5ed3c57aa1221d7775ae0ff751e4c7dc9be220d0917fa8bbdf670586c030" },
78 { "fullmoon_AR", "0254b1d64840ce9ff6bec9dd10e33beb92af5f7cee628f999cb6bc0fea833347cc" },
79 { "fullmoon_NA", "031fb362323b06e165231c887836a8faadb96eda88a79ca434e28b3520b47d235b" }, // 20
80 { "fullmoon_SH", "030e12b42ec33a80e12e570b6c8274ce664565b5c3da106859e96a7208b93afd0d" },
81 { "grewal_NA", "03adc0834c203d172bce814df7c7a5e13dc603105e6b0adabc942d0421aefd2132" },
82 { "grewal_SH", "03212a73f5d38a675ee3cdc6e82542a96c38c3d1c79d25a1ed2e42fcf6a8be4e68" },
83 { "indenodes_AR", "02ec0fa5a40f47fd4a38ea5c89e375ad0b6ddf4807c99733c9c3dc15fb978ee147" },
84 { "indenodes_EU", "0221387ff95c44cb52b86552e3ec118a3c311ca65b75bf807c6c07eaeb1be8303c" },
85 { "indenodes_NA", "02698c6f1c9e43b66e82dbb163e8df0e5a2f62f3a7a882ca387d82f86e0b3fa988" },
86 { "indenodes_SH", "0334e6e1ec8285c4b85bd6dae67e17d67d1f20e7328efad17ce6fd24ae97cdd65e" },
87 { "jeezy_EU", "023cb3e593fb85c5659688528e9a4f1c4c7f19206edc7e517d20f794ba686fd6d6" },
88 { "jsgalt_NA", "027b3fb6fede798cd17c30dbfb7baf9332b3f8b1c7c513f443070874c410232446" },
89 { "karasugoi_NA", "02a348b03b9c1a8eac1b56f85c402b041c9bce918833f2ea16d13452309052a982" }, // 30
90 { "kashifali_EU", "033777c52a0190f261c6f66bd0e2bb299d30f012dcb8bfff384103211edb8bb207" },
91 { "kolo_AR", "03016d19344c45341e023b72f9fb6e6152fdcfe105f3b4f50b82a4790ff54e9dc6" },
92 { "kolo_SH", "02aa24064500756d9b0959b44d5325f2391d8e95c6127e109184937152c384e185" },
93 { "metaphilibert_AR", "02adad675fae12b25fdd0f57250b0caf7f795c43f346153a31fe3e72e7db1d6ac6" },
94 { "movecrypto_AR", "022783d94518e4dc77cbdf1a97915b29f427d7bc15ea867900a76665d3112be6f3" },
95 { "movecrypto_EU", "021ab53bc6cf2c46b8a5456759f9d608966eff87384c2b52c0ac4cc8dd51e9cc42" },
96 { "movecrypto_NA", "02efb12f4d78f44b0542d1c60146738e4d5506d27ec98a469142c5c84b29de0a80" },
97 { "movecrypto_SH", "031f9739a3ebd6037a967ce1582cde66e79ea9a0551c54731c59c6b80f635bc859" },
98 { "muros_AR", "022d77402fd7179335da39479c829be73428b0ef33fb360a4de6890f37c2aa005e" },
99 { "noashh_AR", "029d93ef78197dc93892d2a30e5a54865f41e0ca3ab7eb8e3dcbc59c8756b6e355" }, // 40
100 { "noashh_EU", "02061c6278b91fd4ac5cab4401100ffa3b2d5a277e8f71db23401cc071b3665546" },
101 { "noashh_NA", "033c073366152b6b01535e15dd966a3a8039169584d06e27d92a69889b720d44e1" },
102 { "nxtswe_EU", "032fb104e5eaa704a38a52c126af8f67e870d70f82977e5b2f093d5c1c21ae5899" },
103 { "polycryptoblog_NA", "02708dcda7c45fb54b78469673c2587bfdd126e381654819c4c23df0e00b679622" },
104 { "pondsea_AR", "032e1c213787312099158f2d74a89e8240a991d162d4ce8017d8504d1d7004f735" },
105 { "pondsea_EU", "0225aa6f6f19e543180b31153d9e6d55d41bc7ec2ba191fd29f19a2f973544e29d" },
106 { "pondsea_NA", "031bcfdbb62268e2ff8dfffeb9ddff7fe95fca46778c77eebff9c3829dfa1bb411" },
107 { "pondsea_SH", "02209073bc0943451498de57f802650311b1f12aa6deffcd893da198a544c04f36" },
108 { "popcornbag_AR", "02761f106fb34fbfc5ddcc0c0aa831ed98e462a908550b280a1f7bd32c060c6fa3" },
109 { "popcornbag_NA", "03c6085c7fdfff70988fda9b197371f1caf8397f1729a844790e421ee07b3a93e8" }, // 50
110 { "ptytrader_NA", "0328c61467148b207400b23875234f8a825cce65b9c4c9b664f47410b8b8e3c222" },
111 { "ptytrader_SH", "0250c93c492d8d5a6b565b90c22bee07c2d8701d6118c6267e99a4efd3c7748fa4" },
112 { "rnr_AR", "029bdb08f931c0e98c2c4ba4ef45c8e33a34168cb2e6bf953cef335c359d77bfcd" },
113 { "rnr_EU", "03f5c08dadffa0ffcafb8dd7ffc38c22887bd02702a6c9ac3440deddcf2837692b" },
114 { "rnr_NA", "02e17c5f8c3c80f584ed343b8dcfa6d710dfef0889ec1e7728ce45ce559347c58c" },
115 { "rnr_SH", "037536fb9bdfed10251f71543fb42679e7c52308bcd12146b2568b9a818d8b8377" },
116 { "titomane_AR", "03cda6ca5c2d02db201488a54a548dbfc10533bdc275d5ea11928e8d6ab33c2185" },
117 { "titomane_EU", "02e41feded94f0cc59f55f82f3c2c005d41da024e9a805b41105207ef89aa4bfbd" },
118 { "titomane_SH", "035f49d7a308dd9a209e894321f010d21b7793461b0c89d6d9231a3fe5f68d9960" },
119 { "vanbreuk_EU", "024f3cad7601d2399c131fd070e797d9cd8533868685ddbe515daa53c2e26004c3" }, // 60
120 { "xrobesx_NA", "03f0cc6d142d14a40937f12dbd99dbd9021328f45759e26f1877f2a838876709e1" },
121 { "xxspot1_XX", "02ef445a392fcaf3ad4176a5da7f43580e8056594e003eba6559a713711a27f955" },
122 { "xxspot2_XX", "03d85b221ea72ebcd25373e7961f4983d12add66a92f899deaf07bab1d8b6f5573" }
125 int32_t komodo_electednotary(uint8_t *pubkey33,int32_t height)
127 char pubkeystr[67]; int32_t i; uint8_t legacy33[33];
129 sprintf(&pubkeystr[i*2],"%02x",pubkey33[i]);
131 //printf("%s vs\n",pubkeystr);
132 for (i=0; i<sizeof(Notaries_elected)/sizeof(*Notaries_elected); i++)
134 if ( strcmp(pubkeystr,(char *)Notaries_elected[i][1]) == 0 )
136 //printf("i.%d -> elected %s\n",i,(char *)Notaries_elected[i][1]);
140 /*if ( height < 300000 )
142 for (i=0; i<sizeof(Notaries_genesis)/sizeof(*Notaries_genesis); i++)
144 if ( strcmp(pubkeystr,(char *)Notaries_genesis[i][1]) == 0 )
146 //printf("i.%d -> elected %s\n",i,(char *)Notaries_elected[i][1]);
150 decode_hex(legacy33,33,(char *)"0252b6185bf8ea7efe8bbc345ddc8da87329149f30233088387abd716d4aa9e974");
151 if ( memcmp(pubkey33,legacy33,33) == 0 )
157 int32_t komodo_ratify_threshold(int32_t height,uint64_t signedmask)
159 int32_t htind,numnotaries,i,wt = 0;
160 htind = height / KOMODO_ELECTION_GAP;
161 numnotaries = Pubkeys[htind].numnotaries;
162 for (i=0; i<numnotaries; i++)
163 if ( ((1LL << i) & signedmask) != 0 )
165 if ( wt > (numnotaries >> 1) || (wt > 7 && (signedmask & 1) != 0) )
170 int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height)
172 int32_t i,htind,n; uint64_t mask = 0; struct knotary_entry *kp,*tmp;
173 if ( height >= 180000 )
175 n = (int32_t)(sizeof(Notaries_elected)/sizeof(*Notaries_elected));
177 decode_hex(pubkeys[i],33,(char *)Notaries_elected[i][1]);
180 htind = height / KOMODO_ELECTION_GAP;
181 pthread_mutex_lock(&komodo_mutex);
182 n = Pubkeys[htind].numnotaries;
183 HASH_ITER(hh,Pubkeys[htind].Notaries,kp,tmp)
185 if ( kp->notaryid < n )
187 mask |= (1LL << kp->notaryid);
188 memcpy(pubkeys[kp->notaryid],kp->pubkey,33);
189 } else printf("illegal notaryid.%d vs n.%d\n",kp->notaryid,n);
191 pthread_mutex_unlock(&komodo_mutex);
192 if ( (n < 64 && mask == ((1LL << n)-1)) || (n == 64 && mask == 0xffffffffffffffffLL) )
194 printf("error retrieving notaries ht.%d got mask.%llx for n.%d\n",height,(long long)mask,n);
198 void komodo_notarysinit(int32_t origheight,uint8_t pubkeys[64][33],int32_t num)
200 static int32_t hwmheight;
201 int32_t k,i,htind,nonz,height; struct knotary_entry *kp; struct knotaries_entry N;
203 Pubkeys = (struct knotaries_entry *)calloc(KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP,sizeof(*Pubkeys));
204 memset(&N,0,sizeof(N));
205 if ( origheight > 0 )
207 height = (origheight + KOMODO_ELECTION_GAP/2);
208 height /= KOMODO_ELECTION_GAP;
209 height = ((height + 1) * KOMODO_ELECTION_GAP);
210 htind = (height / KOMODO_ELECTION_GAP);
211 //printf("htind.%d activation %d from %d vs %d | hwmheight.%d %s\n",htind,height,origheight,(((origheight+KOMODO_ELECTION_GAP/2)/KOMODO_ELECTION_GAP)+1)*KOMODO_ELECTION_GAP,hwmheight,ASSETCHAINS_SYMBOL);
213 pthread_mutex_lock(&komodo_mutex);
214 for (k=0; k<num; k++)
216 kp = (struct knotary_entry *)calloc(1,sizeof(*kp));
217 memcpy(kp->pubkey,pubkeys[k],33);
219 HASH_ADD_KEYPTR(hh,N.Notaries,kp->pubkey,33,kp);
220 if ( 1 && height > 10000 )
223 printf("%02x",pubkeys[k][i]);
224 printf(" notarypubs.[%d] ht.%d active at %d\n",k,origheight,htind*KOMODO_ELECTION_GAP);
228 for (i=htind; i<KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP; i++)
230 if ( Pubkeys[i].height != 0 && origheight < hwmheight )
232 printf("Pubkeys[%d].height %d < %d hwmheight, origheight.%d\n",i,Pubkeys[i].height,hwmheight,origheight);
236 Pubkeys[i].height = i * KOMODO_ELECTION_GAP;
238 pthread_mutex_unlock(&komodo_mutex);
239 if ( origheight > hwmheight )
240 hwmheight = origheight;
243 int32_t komodo_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33)
245 // -1 if not notary, 0 if notary, 1 if special notary
246 struct knotary_entry *kp; int32_t numnotaries=0,htind,modval = -1;
249 if ( height < 0 || height >= KOMODO_MAXBLOCKS )
251 printf("komodo_chosennotary ht.%d illegal\n",height);
254 if ( height >= 180000 )
256 if ( (*notaryidp= komodo_electednotary(pubkey33,height)) >= 0 )
258 numnotaries = (int32_t)(sizeof(Notaries_elected)/sizeof(*Notaries_elected));
259 modval = ((height % numnotaries) == *notaryidp);
263 if ( height >= 300000 )
265 htind = height / KOMODO_ELECTION_GAP;
266 pthread_mutex_lock(&komodo_mutex);
267 HASH_FIND(hh,Pubkeys[htind].Notaries,pubkey33,33,kp);
268 pthread_mutex_unlock(&komodo_mutex);
271 if ( (numnotaries= Pubkeys[htind].numnotaries) > 0 )
273 *notaryidp = kp->notaryid;
274 modval = ((height % numnotaries) == kp->notaryid);
275 //printf("found notary.%d ht.%d modval.%d\n",kp->notaryid,height,modval);
276 } else printf("unexpected zero notaries at height.%d\n",height);
277 } //else printf("cant find kp at htind.%d ht.%d\n",htind,height);
278 //int32_t i; for (i=0; i<33; i++)
279 // printf("%02x",pubkey33[i]);
280 //printf(" ht.%d notary.%d special.%d htind.%d num.%d\n",height,*notaryidp,modval,htind,numnotaries);
284 void komodo_notarized_update(struct komodo_state *sp,int32_t nHeight,int32_t notarized_height,uint256 notarized_hash,uint256 notarized_desttxid)
286 struct notarized_checkpoint *np;
287 if ( notarized_height > nHeight )
289 printf("komodo_notarized_update REJECT notarized_height %d > %d nHeight\n",notarized_height,nHeight);
292 portable_mutex_lock(&komodo_mutex);
293 sp->NPOINTS = (struct notarized_checkpoint *)realloc(sp->NPOINTS,(sp->NUM_NPOINTS+1) * sizeof(*sp->NPOINTS));
294 np = &sp->NPOINTS[sp->NUM_NPOINTS++];
295 memset(np,0,sizeof(*np));
296 np->nHeight = nHeight;
297 sp->NOTARIZED_HEIGHT = np->notarized_height = notarized_height;
298 sp->NOTARIZED_HASH = np->notarized_hash = notarized_hash;
299 sp->NOTARIZED_DESTTXID = np->notarized_desttxid = notarized_desttxid;
300 portable_mutex_unlock(&komodo_mutex);
303 //struct komodo_state *komodo_stateptr(char *symbol,char *dest);
304 int32_t komodo_notarized_height(uint256 *hashp,uint256 *txidp)
306 char symbol[16],dest[16]; struct komodo_state *sp;
307 if ( (sp= komodo_stateptr(symbol,dest)) != 0 )
309 *hashp = sp->NOTARIZED_HASH;
310 *txidp = sp->NOTARIZED_DESTTXID;
311 return(sp->NOTARIZED_HEIGHT);
315 memset(hashp,0,sizeof(*hashp));
316 memset(txidp,0,sizeof(*txidp));
321 int32_t komodo_notarizeddata(int32_t nHeight,uint256 *notarized_hashp,uint256 *notarized_desttxidp)
323 struct notarized_checkpoint *np = 0; int32_t i; char symbol[16],dest[16]; struct komodo_state *sp;
324 if ( (sp= komodo_stateptr(symbol,dest)) != 0 )
326 if ( sp->NUM_NPOINTS > 0 )
328 for (i=0; i<sp->NUM_NPOINTS; i++)
330 if ( sp->NPOINTS[i].nHeight >= nHeight )
332 np = &sp->NPOINTS[i];
337 *notarized_hashp = np->notarized_hash;
338 *notarized_desttxidp = np->notarized_desttxid;
339 return(np->notarized_height);
342 memset(notarized_hashp,0,sizeof(*notarized_hashp));
346 void komodo_init(int32_t height)
348 static int didinit; uint256 zero; int32_t i,k,n; uint8_t pubkeys[64][33];
349 if ( 0 && height != 0 )
350 printf("komodo_init ht.%d didinit.%d\n",height,didinit);
353 pthread_mutex_init(&komodo_mutex,NULL);
354 decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str());
357 n = (int32_t)(sizeof(Notaries_genesis)/sizeof(*Notaries_genesis));
360 if ( Notaries_genesis[k][0] == 0 || Notaries_genesis[k][1] == 0 || Notaries_genesis[k][0][0] == 0 || Notaries_genesis[k][1][0] == 0 )
362 decode_hex(pubkeys[k],33,(char *)Notaries_genesis[k][1]);
364 komodo_notarysinit(0,pubkeys,k);
366 memset(&zero,0,sizeof(zero));
367 //for (i=0; i<sizeof(Minerids); i++)
371 else if ( 0 && height == KOMODO_MAINNET_START )
373 n = (int32_t)(sizeof(Notaries_elected)/sizeof(*Notaries_elected));
376 if ( Notaries_elected[k][0] == 0 || Notaries_elected[k][1] == 0 || Notaries_elected[k][0][0] == 0 || Notaries_elected[k][1][0] == 0 )
378 decode_hex(pubkeys[k],33,(char *)Notaries_elected[k][1]);
380 printf("set MAINNET notaries.%d\n",k);
381 komodo_notarysinit(KOMODO_MAINNET_START,pubkeys,k);
383 komodo_stateupdate(0,0,0,0,zero,0,0,0,0,0,0,0,0,0,0);
386 void komodo_assetchain_pubkeys(char *jsonstr)
388 cJSON *array; int32_t i,n; uint8_t pubkeys[64][33]; char *hexstr;
389 memset(pubkeys,0,sizeof(pubkeys));
390 if ( (array= cJSON_Parse(jsonstr)) != 0 )
392 if ( (n= cJSON_GetArraySize(array)) > 0 )
396 if ( (hexstr= jstri(array,i)) != 0 && is_hexstr(hexstr,0) == 66 )
398 decode_hex(pubkeys[i],33,hexstr);
399 fprintf(stderr,"i.%d of n.%d pubkey.(%s)\n",i,n,hexstr);
403 fprintf(stderr,"illegal hexstr.(%s) i.%d of n.%d\n",hexstr,i,n);
410 komodo_notarysinit(0,pubkeys,n);
411 KOMODO_EXTERNAL_NOTARIES = 1;
412 //printf("initialize pubkeys[%d]\n",n);
413 } else fprintf(stderr,"komodo_assetchain_pubkeys i.%d vs n.%d\n",i,n);
414 } else fprintf(stderr,"assetchain pubkeys n.%d\n",n);
416 //else if ( jsonstr != 0 )
417 // fprintf(stderr,"assetchain pubkeys couldnt parse.(%s)\n",jsonstr);