Skip to content
This repository was archived by the owner on Apr 2, 2025. It is now read-only.

Commit b22f89f

Browse files
authored
Merge pull request #3 from jl777/master
update
2 parents 5b71917 + dbc9ad1 commit b22f89f

14 files changed

Lines changed: 243 additions & 54 deletions

src/clientversion.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#define CLIENT_VERSION_MAJOR 1
1818
#define CLIENT_VERSION_MINOR 0
1919
#define CLIENT_VERSION_REVISION 5
20-
#define CLIENT_VERSION_BUILD 50
20+
#define CLIENT_VERSION_BUILD 51
2121

2222
//! Set to true for release, false for prerelease or test build
2323
#define CLIENT_VERSION_IS_RELEASE true

src/init.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1244,10 +1244,14 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
12441244
LogPrintf("Prune: pruned datadir may not have more than %d blocks; -checkblocks=%d may fail\n",
12451245
MIN_BLOCKS_TO_KEEP, GetArg("-checkblocks", 288));
12461246
}
1247-
if (!CVerifyDB().VerifyDB(pcoinsdbview, GetArg("-checklevel", 3),
1248-
GetArg("-checkblocks", 288))) {
1249-
strLoadError = _("Corrupted block database detected");
1250-
break;
1247+
extern int32_t KOMODO_REWIND;
1248+
if ( KOMODO_REWIND == 0 )
1249+
{
1250+
if (!CVerifyDB().VerifyDB(pcoinsdbview, GetArg("-checklevel", 3),
1251+
GetArg("-checkblocks", 288))) {
1252+
strLoadError = _("Corrupted block database detected");
1253+
break;
1254+
}
12511255
}
12521256
} catch (const std::exception& e) {
12531257
if (fDebug) LogPrintf("%s\n", e.what());

src/komodo.h

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr
338338
if ( i == 0 && j == 0 && memcmp(NOTARY_PUBKEY33,scriptbuf+1,33) == 0 )
339339
{
340340
printf("%s KOMODO_LASTMINED.%d -> %d\n",ASSETCHAINS_SYMBOL,KOMODO_LASTMINED,height);
341+
prevKOMODO_LASTMINED = KOMODO_LASTMINED;
341342
KOMODO_LASTMINED = height;
342343
}
343344
decode_hex(crypto777,33,(char *)CRYPTO777_PUBSECPSTR);
@@ -415,9 +416,9 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr
415416
}
416417
if ( opretlen > len && scriptbuf[len] == 'A' )
417418
{
418-
for (i=0; i<opretlen-len; i++)
419-
printf("%02x",scriptbuf[len+i]);
420-
printf(" Found extradata.[%d] %d - %d\n",opretlen-len,opretlen,len);
419+
//for (i=0; i<opretlen-len; i++)
420+
// printf("%02x",scriptbuf[len+i]);
421+
//printf(" Found extradata.[%d] %d - %d\n",opretlen-len,opretlen,len);
421422
komodo_stateupdate(height,0,0,0,txhash,0,0,0,0,0,0,value,&scriptbuf[len],opretlen-len+4+3+(scriptbuf[1] == 0x4d),j);
422423
}
423424
}
@@ -545,6 +546,20 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block)
545546
}
546547
for (j=0; j<numvouts; j++)
547548
{
549+
/*if ( i == 0 && j == 0 )
550+
{
551+
uint8_t *script = (uint8_t *)block.vtx[0].vout[numvouts-1].scriptPubKey.data();
552+
if ( numvouts <= 2 || script[0] != 0x6a )
553+
{
554+
if ( numvouts == 2 && block.vtx[0].vout[1].nValue != 0 )
555+
{
556+
fprintf(stderr,"ht.%d numvouts.%d value %.8f\n",height,numvouts,dstr(block.vtx[0].vout[1].nValue));
557+
if ( height >= 235300 && block.vtx[0].vout[1].nValue >= 100000*COIN )
558+
block.vtx[0].vout[1].nValue = 0;
559+
break;
560+
}
561+
}
562+
}*/
548563
len = block.vtx[i].vout[j].scriptPubKey.size();
549564
if ( len >= sizeof(uint32_t) && len <= sizeof(scriptbuf) )
550565
{

src/komodo_bitcoind.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -781,7 +781,7 @@ int32_t komodo_isrealtime(int32_t *kmdheightp)
781781
if ( (sp= komodo_stateptrget((char *)"KMD")) != 0 )
782782
*kmdheightp = sp->CURRENT_HEIGHT;
783783
else *kmdheightp = 0;
784-
if ( (pindex= chainActive.Tip()) != 0 && pindex->nHeight == (int32_t)komodo_longestchain() )
784+
if ( (pindex= chainActive.Tip()) != 0 && pindex->nHeight >= (int32_t)komodo_longestchain() )
785785
return(1);
786786
else return(0);
787787
}

src/komodo_events.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,12 @@ void komodo_event_rewind(struct komodo_state *sp,char *symbol,int32_t height)
116116
struct komodo_event *ep;
117117
if ( sp != 0 )
118118
{
119+
if ( ASSETCHAINS_SYMBOL[0] == 0 && height <= KOMODO_LASTMINED && prevKOMODO_LASTMINED != 0 )
120+
{
121+
printf("undo KOMODO_LASTMINED %d <- %d\n",KOMODO_LASTMINED,prevKOMODO_LASTMINED);
122+
KOMODO_LASTMINED = prevKOMODO_LASTMINED;
123+
prevKOMODO_LASTMINED = 0;
124+
}
119125
while ( sp->Komodo_events != 0 && sp->Komodo_numevents > 0 )
120126
{
121127
if ( (ep= sp->Komodo_events[sp->Komodo_numevents-1]) != 0 )

src/komodo_gateway.h

Lines changed: 83 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -495,9 +495,19 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to
495495
continue;
496496
{
497497
#ifdef KOMODO_ASSETCHAINS_WAITNOTARIZE
498-
if ( kmdsp != 0 && (kmdsp->NOTARIZED_HEIGHT >= pax->height || kmdsp->CURRENT_HEIGHT > pax->height+30) ) // assumes same chain as notarize
499-
pax->validated = pax->komodoshis; //kmdsp->NOTARIZED_HEIGHT;
500-
else pax->validated = pax->ready = 0;
498+
if ( pax->height > 236000 )
499+
{
500+
if ( kmdsp != 0 && kmdsp->NOTARIZED_HEIGHT >= pax->height )
501+
pax->validated = pax->komodoshis;
502+
else if ( kmdsp->CURRENT_HEIGHT > pax->height+30 )
503+
pax->validated = pax->ready = 0;
504+
}
505+
else
506+
{
507+
if ( kmdsp != 0 && (kmdsp->NOTARIZED_HEIGHT >= pax->height || kmdsp->CURRENT_HEIGHT > pax->height+30) ) // assumes same chain as notarize
508+
pax->validated = pax->komodoshis;
509+
else pax->validated = pax->ready = 0;
510+
}
501511
#else
502512
pax->validated = pax->komodoshis;
503513
#endif
@@ -588,20 +598,77 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to
588598
return(0);
589599
}
590600

601+
const char *banned_txids[] =
602+
{
603+
"78cb4e21245c26b015b888b14c4f5096e18137d2741a6de9734d62b07014dfca", //233559
604+
"00697be658e05561febdee1aafe368b821ca33fbb89b7027365e3d77b5dfede5", //234172
605+
"e909465788b32047c472d73e882d79a92b0d550f90be008f76e1edaee6d742ea", //234187
606+
"f56c6873748a327d0b92b8108f8ec8505a2843a541b1926022883678fb24f9dc", //234188
607+
"abf08be07d8f5b3a433ddcca7ef539e79a3571632efd6d0294ec0492442a0204", //234213
608+
"3b854b996cc982fba8c06e76cf507ae7eed52ab92663f4c0d7d10b3ed879c3b0", //234367
609+
"fa9e474c2cda3cb4127881a40eb3f682feaba3f3328307d518589024a6032cc4", //234635
610+
"ca746fa13e0113c4c0969937ea2c66de036d20274efad4ce114f6b699f1bc0f3", //234662
611+
"43ce88438de4973f21b1388ffe66e68fda592da38c6ef939be10bb1b86387041", //234697
612+
"0aeb748de82f209cd5ff7d3a06f65543904c4c17387c9d87c65fd44b14ad8f8c", //234899
613+
"bbd3a3d9b14730991e1066bd7c626ca270acac4127131afe25f877a5a886eb25", //235252
614+
"fa9943525f2e6c32cbc243294b08187e314d83a2870830180380c3c12a9fd33c", //235253
615+
"a01671c8775328a41304e31a6693bbd35e9acbab28ab117f729eaba9cb769461", //235265
616+
"2ef49d2d27946ad7c5d5e4ab5c089696762ff04e855f8ab48e83bdf0cc68726d", //235295
617+
"c85dcffb16d5a45bd239021ad33443414d60224760f11d535ae2063e5709efee", //235296
618+
};
619+
620+
void komodo_bannedset(uint256 *array,int32_t max)
621+
{
622+
int32_t i;
623+
for (i=0; i<sizeof(banned_txids)/sizeof(*banned_txids); i++)
624+
array[i] = uint256S(banned_txids[i]);
625+
if ( i != max )
626+
printf("banned txid array error i.%d != max.%d\n",i,max);
627+
//else printf("set %d banned txids\n",max);
628+
}
629+
591630
int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above block is valid pax pricing
592631
{
593-
int32_t i,j,n,ht,num,opretlen,offset=1,errs=0,matched=0,kmdheights[64],otherheights[64]; uint256 hash,txids[64]; char symbol[16],base[16]; uint16_t vouts[64]; int8_t baseids[64]; uint8_t *script,opcode,rmd160s[64*20]; uint64_t available,deposited,issued,withdrawn,approved,redeemed; int64_t values[64],srcvalues[64]; struct pax_transaction *pax; struct komodo_state *sp;
594-
if ( KOMODO_PAX == 0 || komodo_isrealtime(&ht) == 0 || KOMODO_PASSPORT_INITDONE == 0 )
595-
return(0);
632+
static uint256 array[15];
633+
int32_t i,j,k,n,ht,txn_count,num,opretlen,offset=1,errs=0,matched=0,kmdheights[64],otherheights[64]; uint256 hash,txids[64]; char symbol[16],base[16]; uint16_t vouts[64]; int8_t baseids[64]; uint8_t *script,opcode,rmd160s[64*20]; uint64_t available,deposited,issued,withdrawn,approved,redeemed; int64_t values[64],srcvalues[64]; struct pax_transaction *pax; struct komodo_state *sp;
634+
if ( *(int32_t *)&array[0] == 0 )
635+
komodo_bannedset(array,(int32_t)(sizeof(array)/sizeof(*array)));
596636
memset(baseids,0xff,sizeof(baseids));
597637
memset(values,0,sizeof(values));
598638
memset(srcvalues,0,sizeof(srcvalues));
599639
memset(rmd160s,0,sizeof(rmd160s));
600640
memset(kmdheights,0,sizeof(kmdheights));
601641
memset(otherheights,0,sizeof(otherheights));
642+
txn_count = block.vtx.size();
643+
for (i=0; i<txn_count; i++)
644+
{
645+
n = block.vtx[i].vin.size();
646+
for (j=0; j<n; j++)
647+
{
648+
for (k=0; k<sizeof(array)/sizeof(*array); k++)
649+
{
650+
if ( block.vtx[i].vin[j].prevout.hash == array[k] && block.vtx[i].vin[j].prevout.n == 1 )
651+
{
652+
printf("banned tx.%d being used at ht.%d txi.%d vini.%d\n",k,height,i,j);
653+
return(-1);
654+
}
655+
}
656+
}
657+
}
602658
n = block.vtx[0].vout.size();
603659
script = (uint8_t *)block.vtx[0].vout[n-1].scriptPubKey.data();
604660
if ( n <= 2 || script[0] != 0x6a )
661+
{
662+
if ( n == 2 && block.vtx[0].vout[1].nValue > COIN/10 )
663+
{
664+
//fprintf(stderr,">>>>>>>> <<<<<<<<<< ht.%d illegal nonz output %.8f n.%d\n",height,dstr(block.vtx[0].vout[1].nValue),n);
665+
if ( height >= 235300 )
666+
return(-1);
667+
}
668+
return(0);
669+
}
670+
//fprintf(stderr,"ht.%d n.%d nValue %.8f (%d %d %d)\n",height,n,dstr(block.vtx[0].vout[1].nValue),KOMODO_PAX,komodo_isrealtime(&ht),KOMODO_PASSPORT_INITDONE);
671+
if ( komodo_isrealtime(&ht) == 0 || KOMODO_PASSPORT_INITDONE == 0 ) //KOMODO_PAX == 0 ||
605672
return(0);
606673
offset += komodo_scriptitemlen(&opretlen,&script[offset]);
607674
if ( ASSETCHAINS_SYMBOL[0] == 0 )
@@ -700,8 +767,18 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above
700767
}
701768
}
702769
}
770+
else
771+
{
772+
printf("no opreturn entries to check\n");
773+
return(-1);
774+
}
703775
//printf("opretlen.%d num.%d\n",opretlen,num);
704776
}
777+
else
778+
{
779+
printf("not proper vout with opreturn format\n");
780+
return(-1);
781+
}
705782
return(0);
706783
}
707784

src/komodo_globals.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ int32_t komodo_isrealtime(int32_t *kmdheightp);
2424
uint64_t komodo_paxtotal();
2525
int32_t komodo_longestchain();
2626
uint64_t komodo_maxallowed(int32_t baseid);
27+
void komodo_bannedset(uint256 *array,int32_t max);
2728

2829
pthread_mutex_t komodo_mutex;
2930

@@ -40,7 +41,7 @@ struct komodo_state KOMODO_STATES[34];
4041
int COINBASE_MATURITY = _COINBASE_MATURITY;//100;
4142

4243
int32_t IS_KOMODO_NOTARY,KOMODO_REWIND,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET;
43-
int32_t KOMODO_LASTMINED;
44+
int32_t KOMODO_LASTMINED,prevKOMODO_LASTMINED;
4445
std::string NOTARY_PUBKEY,ASSETCHAINS_NOTARIES;
4546
uint8_t NOTARY_PUBKEY33[33];
4647

@@ -55,4 +56,4 @@ char KMDUSERPASS[4096],BTCUSERPASS[4096]; uint16_t BITCOIND_PORT = 7771;
5556
uint64_t PENDING_KOMODO_TX;
5657

5758
struct komodo_kv *KOMODO_KV;
58-
pthread_mutex_t KOMODO_KV_mutex;
59+
pthread_mutex_t KOMODO_KV_mutex;

src/komodo_notary.h

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ const char *Notaries_elected[][2] =
124124

125125
int32_t komodo_electednotary(uint8_t *pubkey33,int32_t height)
126126
{
127-
char pubkeystr[67]; int32_t i;
127+
char pubkeystr[67]; int32_t i; uint8_t legacy33[33];
128128
for (i=0; i<33; i++)
129129
sprintf(&pubkeystr[i*2],"%02x",pubkey33[i]);
130130
pubkeystr[66] = 0;
@@ -137,6 +137,20 @@ int32_t komodo_electednotary(uint8_t *pubkey33,int32_t height)
137137
return(i);
138138
}
139139
}
140+
/*if ( height < 300000 )
141+
{
142+
for (i=0; i<sizeof(Notaries_genesis)/sizeof(*Notaries_genesis); i++)
143+
{
144+
if ( strcmp(pubkeystr,(char *)Notaries_genesis[i][1]) == 0 )
145+
{
146+
//printf("i.%d -> elected %s\n",i,(char *)Notaries_elected[i][1]);
147+
return(i+64);
148+
}
149+
}
150+
decode_hex(legacy33,33,(char *)"0252b6185bf8ea7efe8bbc345ddc8da87329149f30233088387abd716d4aa9e974");
151+
if ( memcmp(pubkey33,legacy33,33) == 0 )
152+
return(128);
153+
}*/
140154
return(-1);
141155
}
142156

@@ -246,6 +260,8 @@ int32_t komodo_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33)
246260
return(modval);
247261
}
248262
}
263+
if ( height >= 300000 )
264+
return(-1);
249265
htind = height / KOMODO_ELECTION_GAP;
250266
pthread_mutex_lock(&komodo_mutex);
251267
HASH_FIND(hh,Pubkeys[htind].Notaries,pubkey33,33,kp);
@@ -258,7 +274,7 @@ int32_t komodo_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33)
258274
modval = ((height % numnotaries) == kp->notaryid);
259275
//printf("found notary.%d ht.%d modval.%d\n",kp->notaryid,height,modval);
260276
} else printf("unexpected zero notaries at height.%d\n",height);
261-
}
277+
} //else printf("cant find kp at htind.%d ht.%d\n",htind,height);
262278
//int32_t i; for (i=0; i<33; i++)
263279
// printf("%02x",pubkey33[i]);
264280
//printf(" ht.%d notary.%d special.%d htind.%d num.%d\n",height,*notaryidp,modval,htind,numnotaries);
@@ -352,7 +368,7 @@ void komodo_init(int32_t height)
352368
// Minerids[i] = -2;
353369
didinit = 1;
354370
}
355-
else if ( height == KOMODO_MAINNET_START )
371+
else if ( 0 && height == KOMODO_MAINNET_START )
356372
{
357373
n = (int32_t)(sizeof(Notaries_elected)/sizeof(*Notaries_elected));
358374
for (k=0; k<n; k++)

0 commit comments

Comments
 (0)