|
|
@ -635,107 +635,6 @@ int32_t hush_checkvout(int32_t vout,int32_t k,int32_t indallvouts) |
|
|
|
|
|
|
|
void hush_passport_iteration(); |
|
|
|
|
|
|
|
int32_t hush_check_deposit(int32_t height,const CBlock& block,uint32_t prevtime) // verify above block is valid pax pricing
|
|
|
|
{ |
|
|
|
int32_t i,j,k,n,ht,baseid,txn_count,activation,num,opretlen,offset=1,errs=0,notmatched=0,matched=0,hushheights[256],otherheights[256]; uint256 hash,txids[256]; char symbol[HUSH_SMART_CHAIN_MAXLEN],base[HUSH_SMART_CHAIN_MAXLEN]; uint16_t vouts[256]; int8_t baseids[256]; uint8_t *script,opcode,rmd160s[256*20]; uint64_t total,subsidy,available,deposited,issued,withdrawn,approved,redeemed,seed; int64_t checktoshis,values[256],srcvalues[256]; struct pax_transaction *pax; struct hush_state *sp; CTransaction tx; |
|
|
|
activation = 235300; |
|
|
|
memset(baseids,0xff,sizeof(baseids)); |
|
|
|
memset(values,0,sizeof(values)); |
|
|
|
memset(srcvalues,0,sizeof(srcvalues)); |
|
|
|
memset(rmd160s,0,sizeof(rmd160s)); |
|
|
|
memset(hushheights,0,sizeof(hushheights)); |
|
|
|
memset(otherheights,0,sizeof(otherheights)); |
|
|
|
txn_count = block.vtx.size(); |
|
|
|
|
|
|
|
if ( SMART_CHAIN_SYMBOL[0] == 0 || |
|
|
|
((ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_FOUNDERS_REWARD) && height > 1) || |
|
|
|
NetworkUpgradeActive(height, Params().GetConsensus(), Consensus::UPGRADE_SAPLING) ) |
|
|
|
{ |
|
|
|
n = block.vtx[0].vout.size(); |
|
|
|
int64_t val,prevtotal = 0; int32_t strangeout=0,overflow = 0; |
|
|
|
total = 0; |
|
|
|
for (i=1; i<n; i++) |
|
|
|
{ |
|
|
|
script = (uint8_t *)&block.vtx[0].vout[i].scriptPubKey[0]; |
|
|
|
if ( (val= block.vtx[0].vout[i].nValue) < 0 || val >= MAX_MONEY ) |
|
|
|
{ |
|
|
|
overflow = 1; |
|
|
|
break; |
|
|
|
} |
|
|
|
if ( i > 1 && script[0] != 0x6a && val < 5000 ) |
|
|
|
strangeout++; |
|
|
|
total += val; |
|
|
|
if ( total < prevtotal || (val != 0 && total == prevtotal) ) |
|
|
|
{ |
|
|
|
overflow = 1; |
|
|
|
break; |
|
|
|
} |
|
|
|
prevtotal = total; |
|
|
|
} |
|
|
|
if ( SMART_CHAIN_SYMBOL[0] == 0 ) |
|
|
|
{ |
|
|
|
if ( overflow != 0 || total > COIN/10 ) |
|
|
|
{ |
|
|
|
if ( height >= activation ) |
|
|
|
{ |
|
|
|
if ( height > 800000 ) |
|
|
|
fprintf(stderr,">>>>>>>> <<<<<<<<<< ht.%d illegal nonz output %.8f n.%d\n",height,dstr(block.vtx[0].vout[1].nValue),n); |
|
|
|
return(-1); |
|
|
|
} |
|
|
|
} |
|
|
|
else if ( block.nBits == HUSH_MINDIFF_NBITS && total > 0 ) // to deal with fee stealing
|
|
|
|
{ |
|
|
|
fprintf(stderr,"notary mined ht.%d with extra %.8f\n",height,dstr(total)); |
|
|
|
if ( height > HUSH_NOTARIES_HEIGHT1 ) |
|
|
|
return(-1); |
|
|
|
} |
|
|
|
if ( strangeout != 0 || notmatched != 0 ) |
|
|
|
{ |
|
|
|
if ( 0 && strcmp(NOTARY_PUBKEY.c_str(),"03b7621b44118017a16043f19b30cc8a4cfe068ac4e42417bae16ba460c80f3828") == 0 ) |
|
|
|
fprintf(stderr,">>>>>>>>>>>>> DUST ht.%d strangout.%d notmatched.%d <<<<<<<<<\n",height,strangeout,notmatched); |
|
|
|
if ( height > 1000000 && strangeout != 0 ) |
|
|
|
return(-1); |
|
|
|
} |
|
|
|
else if ( height > 814000 ) |
|
|
|
{ |
|
|
|
script = (uint8_t *)&block.vtx[0].vout[0].scriptPubKey[0]; |
|
|
|
//int32_t notary = hush_electednotary(&num,script+1,height,0);
|
|
|
|
//if ( (-1 * (hush_electednotary(&num,script+1,height,0) >= 0) * (height > 1000000)) < 0 )
|
|
|
|
// fprintf(stderr, ">>>>>>> FAILED BLOCK.%d notary.%d insync.%d\n",height,notary,HUSH_INSYNC);
|
|
|
|
//else
|
|
|
|
// fprintf(stderr, "<<<<<<< VALID BLOCK.%d notary.%d insync.%d\n",height,notary,HUSH_INSYNC);
|
|
|
|
return(-1 * (hush_electednotary(&num,script+1,height,0) >= 0) * (height > 1000000)); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
checktoshis = 0; |
|
|
|
if ( (ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_FOUNDERS_REWARD) && height > 1 ) |
|
|
|
{ |
|
|
|
if ( (checktoshis= hush_checkcommission((CBlock *)&block,height)) < 0 ) |
|
|
|
{ |
|
|
|
fprintf(stderr,"ht.%d checktoshis %.8f overflow.%d total %.8f strangeout.%d\n",height,dstr(checktoshis),overflow,dstr(total),strangeout); |
|
|
|
return(-1); |
|
|
|
} |
|
|
|
} |
|
|
|
if ( height > 1 && checktoshis == 0 ) |
|
|
|
{ |
|
|
|
checktoshis = ((uint64_t)GetBlockSubsidy(height, Params().GetConsensus()) - block.vtx[0].vout[0].nValue); |
|
|
|
// some pools will need to change their pool fee to be (poolfee % - txfees)
|
|
|
|
//checktoshis += txn_count * 0.001; // rely on higher level validations to prevent emitting more coins than actual txfees
|
|
|
|
} |
|
|
|
if ( height >= 2 && (overflow != 0 || total > checktoshis || strangeout != 0) ) |
|
|
|
{ |
|
|
|
fprintf(stderr,"checkdeposit: ht.%d checktoshis %.8f overflow.%d total %.8f strangeout.%d\n",height,dstr(checktoshis),overflow,dstr(total),strangeout); |
|
|
|
if ( strangeout != 0 ) |
|
|
|
fprintf(stderr,">>>>>>>>>>>>> %s DUST ht.%d strangeout.%d notmatched.%d <<<<<<<<<\n",SMART_CHAIN_SYMBOL,height,strangeout,notmatched); |
|
|
|
return(-1); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return(0); |
|
|
|
} |
|
|
|
|
|
|
|
const char *hush_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int32_t opretlen,uint256 txid,uint16_t vout,char *source) |
|
|
|
{ |
|
|
|
uint8_t rmd160[20],rmd160s[64*20],addrtype,shortflag,pubkey33[33]; int32_t didstats,i,j,n,kvheight,len,tokomodo,hushheight,otherheights[64],hushheights[64]; int8_t baseids[64]; char base[4],coinaddr[64],destaddr[64]; uint256 txids[64]; uint16_t vouts[64]; uint64_t convtoshis,seed; int64_t fee,fiatoshis,puposhis,checktoshis,values[64],srcvalues[64]; struct pax_transaction *pax,*pax2; struct hush_state *basesp; double diff; |
|
|
|