New listaddresses RPC and z_exportwallet RPC now can be called during RPC warmup
This commit is contained in:
@@ -113,7 +113,7 @@ void WaitForShutdown(boost::thread_group* threadGroup)
|
||||
extern int32_t IS_HUSH_NOTARY,USE_EXTERNAL_PUBKEY;
|
||||
extern uint32_t ASSETCHAIN_INIT;
|
||||
extern std::string NOTARY_PUBKEY;
|
||||
int32_t komodo_is_issuer();
|
||||
int32_t hush_is_issuer();
|
||||
void hush_passport_iteration();
|
||||
|
||||
bool AppInit(int argc, char* argv[])
|
||||
|
||||
@@ -610,7 +610,7 @@ int32_t hush_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notaryi
|
||||
memset(&MoMoMdata,0,sizeof(MoMoMdata));
|
||||
if ( matched == 0 && signedmask != 0 && bitweight(signedmask) >= HUSH_MINRATIFY )
|
||||
notarized = 1;
|
||||
if ( strcmp("PIZZA",ccdata.symbol) == 0 || strncmp("TXSCL",ccdata.symbol,5) == 0 || strcmp("BEER",ccdata.symbol) == 0)
|
||||
if ( strcmp("DPOW",ccdata.symbol) == 0 || strncmp("ZPOW",ccdata.symbol,5) == 0 || strcmp("TUSH",ccdata.symbol) == 0)
|
||||
notarized = 1;
|
||||
if ( 0 && opretlen != 149 )
|
||||
printf("[%s].%d (%s) matched.%d i.%d j.%d notarized.%d %llx opretlen.%d len.%d offset.%d opoffset.%d\n",SMART_CHAIN_SYMBOL,height,ccdata.symbol,matched,i,j,notarized,(long long)signedmask,opretlen,len,offset,opoffset);
|
||||
@@ -726,7 +726,7 @@ int32_t hush_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notaryi
|
||||
if ( k == 32 )
|
||||
{
|
||||
*isratificationp = 1;
|
||||
printf("ISRATIFICATION (%s)\n",(char *)&scriptbuf[len+32*2+4]);
|
||||
printf("%s: ISRATIFICATION (%s)\n",__func__,(char *)&scriptbuf[len+32*2+4]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -809,7 +809,7 @@ int32_t hush_connectblock(bool fJustCheck, CBlockIndex *pindex,CBlock& block)
|
||||
txn_count = block.vtx.size();
|
||||
for (i=0; i<txn_count; i++)
|
||||
{
|
||||
// Notary pay chains need notarisation in position 1, ignore the rest on validation. Check notarisation is 1 on check.
|
||||
// Notary pay chains need notarization in position 1, ignore the rest on validation. Check notarization is 1 on check.
|
||||
if ( !fJustCheck && i > 1 && ASSETCHAINS_NOTARY_PAY[0] != 0 )
|
||||
break;
|
||||
txhash = block.vtx[i].GetHash();
|
||||
|
||||
@@ -408,8 +408,7 @@ int32_t notarizedtxid_height(char *dest,char *txidstr,int32_t *hushnotarized_hei
|
||||
if ( (item= jobj(json,(char *)"result")) != 0 )
|
||||
{
|
||||
height = jint(item,(char *)"blocks");
|
||||
//TODO: which key to use?
|
||||
*hushnotarized_heightp = strcmp(dest,"KMD") == 0 ? jint(item,(char *)"notarized") : height;
|
||||
*hushnotarized_heightp = strcmp(dest,"HUSH3") == 0 ? jint(item,(char *)"notarized") : height;
|
||||
}
|
||||
free_json(json);
|
||||
}
|
||||
@@ -1030,7 +1029,7 @@ int32_t hush_nextheight()
|
||||
else return(hush_longestchain() + 1);
|
||||
}
|
||||
|
||||
int32_t komodo_isrealtime(int32_t *kmdheightp)
|
||||
int32_t hush_isrealtime(int32_t *kmdheightp)
|
||||
{
|
||||
struct hush_state *sp; CBlockIndex *pindex;
|
||||
if ( (sp= hush_stateptrget((char *)"HUSH3")) != 0 )
|
||||
|
||||
@@ -306,7 +306,7 @@ uint64_t komodo_paxtotal()
|
||||
struct pax_transaction *pax,*pax2,*tmp,*tmp2; char symbol[HUSH_SMART_CHAIN_MAXLEN],dest[HUSH_SMART_CHAIN_MAXLEN],*str; int32_t i,ht; int64_t checktoshis; uint64_t seed,total = 0; struct hush_state *basesp;
|
||||
if ( HUSH_PASSPORT_INITDONE == 0 ) //HUSH_PAX == 0 ||
|
||||
return(0);
|
||||
if ( komodo_isrealtime(&ht) == 0 )
|
||||
if ( hush_isrealtime(&ht) == 0 )
|
||||
return(0);
|
||||
else
|
||||
{
|
||||
@@ -369,7 +369,7 @@ uint64_t komodo_paxtotal()
|
||||
{
|
||||
if ( pax->marked == 0 )
|
||||
{
|
||||
if ( komodo_is_issuer() != 0 )
|
||||
if ( hush_is_issuer() != 0 )
|
||||
{
|
||||
if ( pax->validated != 0 && pax->type == 'D' )
|
||||
{
|
||||
@@ -431,7 +431,7 @@ int32_t komodo_pending_withdraws(char *opretstr) // todo: enforce deterministic
|
||||
struct pax_transaction *pax,*pax2,*tmp,*paxes[64]; uint8_t opretbuf[16384*4]; int32_t i,n,ht,len=0; uint64_t total = 0;
|
||||
if ( HUSH_PAX == 0 || HUSH_PASSPORT_INITDONE == 0 )
|
||||
return(0);
|
||||
if ( komodo_isrealtime(&ht) == 0 || SMART_CHAIN_SYMBOL[0] != 0 )
|
||||
if ( hush_isrealtime(&ht) == 0 || SMART_CHAIN_SYMBOL[0] != 0 )
|
||||
return(0);
|
||||
n = 0;
|
||||
HASH_ITER(hh,PAX,pax,tmp)
|
||||
@@ -488,7 +488,7 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to
|
||||
PENDING_HUSH_TX = 0;
|
||||
for (i=0; i<3; i++)
|
||||
{
|
||||
if ( komodo_isrealtime(&ht) != 0 )
|
||||
if ( hush_isrealtime(&ht) != 0 )
|
||||
break;
|
||||
sleep(1);
|
||||
}
|
||||
@@ -843,7 +843,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3
|
||||
memset(rmd160s,0,sizeof(rmd160s));
|
||||
memset(kmdheights,0,sizeof(kmdheights));
|
||||
memset(otherheights,0,sizeof(otherheights));
|
||||
tokomodo = (komodo_is_issuer() == 0);
|
||||
tokomodo = (hush_is_issuer() == 0);
|
||||
if ( opretbuf[0] == 'K' && opretlen != 40 )
|
||||
{
|
||||
komodo_kvupdate(opretbuf,opretlen,value);
|
||||
@@ -867,7 +867,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3
|
||||
if ( 0 && strcmp("NOK",base) == 0 )
|
||||
{
|
||||
printf("[%s] %s paxdeposit height.%d vs kmdheight.%d\n",SMART_CHAIN_SYMBOL,base,height,kmdheight);
|
||||
printf("(%s) (%s) kmdheight.%d vs height.%d check %.8f vs %.8f tokomodo.%d %d seed.%llx\n",SMART_CHAIN_SYMBOL,base,kmdheight,height,dstr(checktoshis),dstr(value),komodo_is_issuer(),strncmp(SMART_CHAIN_SYMBOL,base,strlen(base)) == 0,(long long)seed);
|
||||
printf("(%s) (%s) kmdheight.%d vs height.%d check %.8f vs %.8f tokomodo.%d %d seed.%llx\n",SMART_CHAIN_SYMBOL,base,kmdheight,height,dstr(checktoshis),dstr(value),hush_is_issuer(),strncmp(SMART_CHAIN_SYMBOL,base,strlen(base)) == 0,(long long)seed);
|
||||
for (i=0; i<32; i++)
|
||||
printf("%02x",((uint8_t *)&txid)[i]);
|
||||
printf(" <- txid.v%u ",vout);
|
||||
@@ -1005,7 +1005,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3
|
||||
bitcoin_address(coinaddr,addrtype,rmd160,20);
|
||||
checktoshis = PAX_fiatdest(&seed,tokomodo,destaddr,pubkey33,coinaddr,kmdheight,base,value);
|
||||
typestr = "withdraw";
|
||||
//printf(" [%s] WITHDRAW %s.height.%d vs height.%d check %.8f/%.8f vs %.8f tokomodo.%d %d seed.%llx -> (%s) len.%d\n",SMART_CHAIN_SYMBOL,base,kmdheight,height,dstr(checktoshis),dstr(komodoshis),dstr(value),komodo_is_issuer(),strncmp(SMART_CHAIN_SYMBOL,base,strlen(base)) == 0,(long long)seed,coinaddr,opretlen);
|
||||
//printf(" [%s] WITHDRAW %s.height.%d vs height.%d check %.8f/%.8f vs %.8f tokomodo.%d %d seed.%llx -> (%s) len.%d\n",SMART_CHAIN_SYMBOL,base,kmdheight,height,dstr(checktoshis),dstr(komodoshis),dstr(value),hush_is_issuer(),strncmp(SMART_CHAIN_SYMBOL,base,strlen(base)) == 0,(long long)seed,coinaddr,opretlen);
|
||||
didstats = 0;
|
||||
//if ( komodo_paxcmp(base,kmdheight,komodoshis,checktoshis,seed) == 0 )
|
||||
{
|
||||
@@ -1508,7 +1508,7 @@ void hush_passport_iteration()
|
||||
}
|
||||
lastpos[baseid] = ftell(fp);
|
||||
if ( 0 && lastpos[baseid] == 0 && strcmp(symbol,"HUSH3") == 0 )
|
||||
printf("from.(%s) lastpos[%s] %ld isrt.%d\n",SMART_CHAIN_SYMBOL,CURRENCIES[baseid],lastpos[baseid],komodo_isrealtime(&ht));
|
||||
printf("from.(%s) lastpos[%s] %ld isrt.%d\n",SMART_CHAIN_SYMBOL,CURRENCIES[baseid],lastpos[baseid],hush_isrealtime(&ht));
|
||||
} //else fprintf(stderr,"%s.%ld ",CURRENCIES[baseid],ftell(fp));
|
||||
fclose(fp);
|
||||
} else fprintf(stderr,"load error.(%s) %p\n",fname,sp);
|
||||
@@ -1555,7 +1555,7 @@ void hush_passport_iteration()
|
||||
if ( sp != 0 && isrealtime == 0 )
|
||||
refsp->RTbufs[0][2] = 0;
|
||||
}
|
||||
//komodo_paxtotal(); // calls komodo_isrealtime(), which calls hush_longestchain()
|
||||
//komodo_paxtotal(); // calls hush_isrealtime(), which calls hush_longestchain()
|
||||
refsp->RTmask |= RTmask;
|
||||
if ( expired == 0 && HUSH_PASSPORT_INITDONE == 0 )
|
||||
{
|
||||
|
||||
@@ -26,7 +26,7 @@ int32_t hush_notarizeddata(int32_t nHeight,uint256 *notarized_hashp,uint256 *not
|
||||
char *hush_issuemethod(char *userpass,char *method,char *params,uint16_t port);
|
||||
void hush_init(int32_t height);
|
||||
int32_t hush_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33,uint32_t timestamp);
|
||||
int32_t komodo_isrealtime(int32_t *kmdheightp);
|
||||
int32_t hush_isrealtime(int32_t *kmdheightp);
|
||||
uint64_t komodo_paxtotal();
|
||||
int32_t hush_longestchain();
|
||||
uint64_t komodo_maxallowed(int32_t baseid);
|
||||
|
||||
266
src/hush_pax.h
266
src/hush_pax.h
@@ -234,69 +234,6 @@ int32_t dpow_readprices(int32_t height,uint8_t *data,uint32_t *timestampp,double
|
||||
return(n);
|
||||
}
|
||||
|
||||
int32_t komodo_pax_opreturn(int32_t height,uint8_t *opret,int32_t maxsize)
|
||||
{
|
||||
static uint32_t lastcrc;
|
||||
FILE *fp; char fname[512]; uint32_t crc32,check,timestamp; int32_t i,n=0,retval,fsize,len=0; uint8_t data[8192];
|
||||
#ifdef _WIN32
|
||||
sprintf(fname,"%s\\%s",GetDataDir(false).string().c_str(),(char *)"komodofeed");
|
||||
#else
|
||||
sprintf(fname,"%s/%s",GetDataDir(false).string().c_str(),(char *)"komodofeed");
|
||||
#endif
|
||||
if ( (fp= fopen(fname,"rb")) != 0 )
|
||||
{
|
||||
fseek(fp,0,SEEK_END);
|
||||
fsize = (int32_t)ftell(fp);
|
||||
rewind(fp);
|
||||
if ( fsize <= maxsize-4 && fsize <= sizeof(data) && fsize > sizeof(crc32) )
|
||||
{
|
||||
if ( (retval= (int32_t)fread(data,1,fsize,fp)) == fsize )
|
||||
{
|
||||
len = dragon_rwnum(0,data,sizeof(crc32),(void *)&crc32);
|
||||
check = calc_crc32(0,data+sizeof(crc32),(int32_t)(fsize-sizeof(crc32)));
|
||||
if ( check == crc32 )
|
||||
{
|
||||
double KMDBTC,BTCUSD,CNYUSD; uint32_t pvals[128];
|
||||
if ( dpow_readprices(height,&data[len],×tamp,&KMDBTC,&BTCUSD,&CNYUSD,pvals) > 0 )
|
||||
{
|
||||
if ( 0 && lastcrc != crc32 )
|
||||
{
|
||||
for (i=0; i<32; i++)
|
||||
printf("%u ",pvals[i]);
|
||||
printf("t%u n.%d KMD %f BTC %f CNY %f (%f)\n",timestamp,n,KMDBTC,BTCUSD,CNYUSD,CNYUSD!=0?1./CNYUSD:0);
|
||||
}
|
||||
if ( timestamp > time(NULL)-600 )
|
||||
{
|
||||
n = hush_opreturnscript(opret,'P',data+sizeof(crc32),(int32_t)(fsize-sizeof(crc32)));
|
||||
if ( 0 && lastcrc != crc32 )
|
||||
{
|
||||
for (i=0; i<n; i++)
|
||||
printf("%02x",opret[i]);
|
||||
printf(" coinbase opret[%d] crc32.%u:%u\n",n,crc32,check);
|
||||
}
|
||||
} //else printf("t%u too old for %u\n",timestamp,(uint32_t)time(NULL));
|
||||
lastcrc = crc32;
|
||||
}
|
||||
} else printf("crc32 %u mismatch %u\n",crc32,check);
|
||||
} else printf("fread.%d error != fsize.%d\n",retval,fsize);
|
||||
} else printf("fsize.%d > maxsize.%d or data[%d]\n",fsize,maxsize,(int32_t)sizeof(data));
|
||||
fclose(fp);
|
||||
} //else printf("couldnt open %s\n",fname);
|
||||
return(n);
|
||||
}
|
||||
|
||||
/*uint32_t PAX_val32(double val)
|
||||
{
|
||||
uint32_t val32 = 0; struct price_resolution price;
|
||||
if ( (price.Pval= val*1000000000) != 0 )
|
||||
{
|
||||
if ( price.Pval > 0xffffffff )
|
||||
printf("Pval overflow error %lld\n",(long long)price.Pval);
|
||||
else val32 = (uint32_t)price.Pval;
|
||||
}
|
||||
return(val32);
|
||||
}*/
|
||||
|
||||
int32_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)
|
||||
{
|
||||
if ( rwflag != 0 )
|
||||
@@ -356,7 +293,7 @@ void komodo_pvals(int32_t height,uint32_t *pvals,uint8_t numpvals)
|
||||
NUM_PRICES++;
|
||||
portable_mutex_unlock(&hush_mutex);
|
||||
if ( 0 )
|
||||
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);
|
||||
printf("OP_RETURN.%d HUSH %.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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -497,214 +434,19 @@ uint64_t komodo_paxcalc(int32_t height,uint32_t *pvals,int32_t baseid,int32_t re
|
||||
return(0);
|
||||
}
|
||||
|
||||
uint64_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)
|
||||
{
|
||||
int32_t baseid=-1,relid=-1,i; uint32_t *ptr,*pvals;
|
||||
if ( height > 10 )
|
||||
height -= 10;
|
||||
if ( (baseid= hush_baseid(base)) >= 0 && (relid= hush_baseid(rel)) >= 0 )
|
||||
{
|
||||
//portable_mutex_lock(&hush_mutex);
|
||||
for (i=NUM_PRICES-1; i>=0; i--)
|
||||
{
|
||||
ptr = &PVALS[36 * i];
|
||||
if ( *ptr < height )
|
||||
{
|
||||
pvals = &ptr[1];
|
||||
if ( kmdbtcp != 0 && btcusdp != 0 )
|
||||
{
|
||||
*kmdbtcp = pvals[MAX_CURRENCIES] / 539;
|
||||
*btcusdp = pvals[MAX_CURRENCIES + 1] / 539;
|
||||
}
|
||||
//portable_mutex_unlock(&hush_mutex);
|
||||
if ( kmdbtc != 0 && btcusd != 0 )
|
||||
return(komodo_paxcalc(height,pvals,baseid,relid,basevolume,kmdbtc,btcusd));
|
||||
else return(0);
|
||||
}
|
||||
}
|
||||
//portable_mutex_unlock(&hush_mutex);
|
||||
} //else printf("paxprice invalid base.%s %d, rel.%s %d\n",base,baseid,rel,relid);
|
||||
return(0);
|
||||
}
|
||||
|
||||
int32_t komodo_kmdbtcusd(int32_t rwflag,uint64_t *kmdbtcp,uint64_t *btcusdp,int32_t height)
|
||||
{
|
||||
static uint64_t *KMDBTCS,*BTCUSDS; static int32_t maxheight = 0; int32_t incr = 10000;
|
||||
if ( height >= maxheight )
|
||||
{
|
||||
//printf("height.%d maxheight.%d incr.%d\n",height,maxheight,incr);
|
||||
if ( height >= maxheight+incr )
|
||||
incr = (height - (maxheight+incr) + 1000);
|
||||
KMDBTCS = (uint64_t *)realloc(KMDBTCS,((incr + maxheight) * sizeof(*KMDBTCS)));
|
||||
memset(&KMDBTCS[maxheight],0,(incr * sizeof(*KMDBTCS)));
|
||||
BTCUSDS = (uint64_t *)realloc(BTCUSDS,((incr + maxheight) * sizeof(*BTCUSDS)));
|
||||
memset(&BTCUSDS[maxheight],0,(incr * sizeof(*BTCUSDS)));
|
||||
maxheight += incr;
|
||||
}
|
||||
if ( rwflag == 0 )
|
||||
{
|
||||
*kmdbtcp = KMDBTCS[height];
|
||||
*btcusdp = BTCUSDS[height];
|
||||
}
|
||||
else
|
||||
{
|
||||
KMDBTCS[height] = *kmdbtcp;
|
||||
BTCUSDS[height] = *btcusdp;
|
||||
}
|
||||
if ( *kmdbtcp != 0 && *btcusdp != 0 )
|
||||
return(0);
|
||||
else return(-1);
|
||||
}
|
||||
|
||||
uint64_t _komodo_paxpriceB(uint64_t seed,int32_t height,char *base,char *rel,uint64_t basevolume)
|
||||
{
|
||||
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;
|
||||
if ( basevolume > HUSH_PAXMAX )
|
||||
{
|
||||
printf("komodo_paxprice overflow %.8f\n",dstr(basevolume));
|
||||
return(0);
|
||||
}
|
||||
if ( strcmp(base,"KMD") == 0 || strcmp(base,"kmd") == 0 )
|
||||
{
|
||||
printf("kmd cannot be base currency\n");
|
||||
return(0);
|
||||
}
|
||||
numvotes = (int32_t)(sizeof(Peggy_inds)/sizeof(*Peggy_inds));
|
||||
memset(votes,0,sizeof(votes));
|
||||
//if ( komodo_kmdbtcusd(0,&kmdbtc,&btcusd,height) < 0 ) crashes when via passthru GUI use
|
||||
{
|
||||
memset(btcusds,0,sizeof(btcusds));
|
||||
memset(kmdbtcs,0,sizeof(kmdbtcs));
|
||||
for (i=0; i<numvotes; i++)
|
||||
{
|
||||
_komodo_paxprice(&kmdbtcs[numvotes-1-i],&btcusds[numvotes-1-i],height-i,base,rel,100000,0,0);
|
||||
//printf("(%llu %llu) ",(long long)kmdbtcs[numvotes-1-i],(long long)btcusds[numvotes-1-i]);
|
||||
}
|
||||
kmdbtc = komodo_paxcorrelation(kmdbtcs,numvotes,seed) * 539;
|
||||
btcusd = komodo_paxcorrelation(btcusds,numvotes,seed) * 539;
|
||||
//komodo_kmdbtcusd(1,&kmdbtc,&btcusd,height);
|
||||
}
|
||||
for (i=nonz=0; i<numvotes; i++)
|
||||
{
|
||||
if ( (votes[numvotes-1-i]= _komodo_paxprice(0,0,height-i,base,rel,100000,kmdbtc,btcusd)) == 0 )
|
||||
zeroes++;
|
||||
else
|
||||
{
|
||||
nonz++;
|
||||
sum += votes[numvotes-1-i];
|
||||
//if ( (i % 10) == 0 )
|
||||
// fprintf(stderr,"[%llu] ",(long long)votes[numvotes-1-i]);
|
||||
}
|
||||
}
|
||||
//fprintf(stderr,"kmdbtc %llu btcusd %llu ",(long long)kmdbtc,(long long)btcusd);
|
||||
//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);
|
||||
if ( nonz <= (numvotes >> 1) )
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
return(komodo_paxcorrelation(votes,numvotes,seed) * basevolume / 100000);
|
||||
}
|
||||
|
||||
uint64_t komodo_paxpriceB(uint64_t seed,int32_t height,char *base,char *rel,uint64_t basevolume)
|
||||
{
|
||||
uint64_t baseusd,basekmd,usdkmd; int32_t baseid = hush_baseid(base);
|
||||
if ( height >= 236000 && strcmp(rel,"kmd") == 0 )
|
||||
{
|
||||
usdkmd = _komodo_paxpriceB(seed,height,(char *)"USD",(char *)"KMD",SATOSHIDEN);
|
||||
if ( strcmp("usd",base) == 0 )
|
||||
return(komodo_paxvol(basevolume,usdkmd) * 10);
|
||||
baseusd = _komodo_paxpriceB(seed,height,base,(char *)"USD",SATOSHIDEN);
|
||||
basekmd = (komodo_paxvol(basevolume,baseusd) * usdkmd) / 10000000;
|
||||
//if ( strcmp("KMD",base) == 0 )
|
||||
// printf("baseusd.%llu usdkmd.%llu %llu\n",(long long)baseusd,(long long)usdkmd,(long long)basekmd);
|
||||
return(basekmd);
|
||||
} else return(_komodo_paxpriceB(seed,height,base,rel,basevolume));
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*uint64_t komodo_paxpriceB(uint64_t seed,int32_t height,char *base,char *rel,uint64_t basevolume)
|
||||
{
|
||||
uint64_t baseusd,basekmd,usdkmd; int32_t baseid = hush_baseid(base);
|
||||
//if ( strcmp(rel,"KMD") != 0 || baseid < 0 || MINDENOMS[baseid] == MINDENOMS[USD] )
|
||||
// return(_komodo_paxpriceB(seed,height,base,rel,basevolume));
|
||||
//else
|
||||
{
|
||||
baseusd = _komodo_paxpriceB(seed,height,base,(char *)"USD",SATOSHIDEN);
|
||||
usdkmd = _komodo_paxpriceB(seed,height,(char *)"USD",(char *)"KMD",SATOSHIDEN);
|
||||
basekmd = (komodo_paxvol(basevolume,baseusd) * usdkmd) / 10000000;
|
||||
if ( strcmp("KMD",base) == 0 )
|
||||
printf("baseusd.%llu usdkmd.%llu %llu\n",(long long)baseusd,(long long)usdkmd,(long long)basekmd);
|
||||
return(basekmd);
|
||||
}
|
||||
}*/
|
||||
|
||||
uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uint64_t basevolume)
|
||||
{
|
||||
int32_t i,nonz=0; int64_t diff; uint64_t price,seed,sum = 0;
|
||||
if ( SMART_CHAIN_SYMBOL[0] == 0 && chainActive.LastTip() != 0 && height > chainActive.LastTip()->GetHeight() )
|
||||
{
|
||||
if ( height < 100000000 )
|
||||
{
|
||||
static uint32_t counter;
|
||||
if ( counter++ < 3 )
|
||||
printf("komodo_paxprice height.%d vs tip.%d\n",height,chainActive.LastTip()->GetHeight());
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
*seedp = hush_seed(height);
|
||||
portable_mutex_lock(&hush_mutex);
|
||||
for (i=0; i<17; i++)
|
||||
{
|
||||
if ( (price= komodo_paxpriceB(*seedp,height-i,base,rel,basevolume)) != 0 )
|
||||
{
|
||||
sum += price;
|
||||
nonz++;
|
||||
if ( 0 && i == 1 && nonz == 2 )
|
||||
{
|
||||
diff = (((int64_t)price - (sum >> 1)) * 10000);
|
||||
if ( diff < 0 )
|
||||
diff = -diff;
|
||||
diff /= price;
|
||||
printf("(%llu %llu %lld).%lld ",(long long)price,(long long)(sum>>1),(long long)(((int64_t)price - (sum >> 1)) * 10000),(long long)diff);
|
||||
if ( diff < 33 )
|
||||
break;
|
||||
}
|
||||
else if ( 0 && i == 3 && nonz == 4 )
|
||||
{
|
||||
diff = (((int64_t)price - (sum >> 2)) * 10000);
|
||||
if ( diff < 0 )
|
||||
diff = -diff;
|
||||
diff /= price;
|
||||
printf("(%llu %llu %lld).%lld ",(long long)price,(long long)(sum>>2),(long long) (((int64_t)price - (sum >> 2)) * 10000),(long long)diff);
|
||||
if ( diff < 20 )
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( height < 165000 || height > 236000 )
|
||||
break;
|
||||
}
|
||||
portable_mutex_unlock(&hush_mutex);
|
||||
if ( nonz != 0 )
|
||||
sum /= nonz;
|
||||
//printf("-> %lld %s/%s i.%d ht.%d\n",(long long)sum,base,rel,i,height);
|
||||
return(sum);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t komodo_paxprices(int32_t *heights,uint64_t *prices,int32_t max,char *base,char *rel)
|
||||
{
|
||||
int32_t baseid=-1,relid=-1,i,num = 0; uint32_t *ptr;
|
||||
if ( (baseid= hush_baseid(base)) >= 0 && (relid= hush_baseid(rel)) >= 0 )
|
||||
{
|
||||
for (i=NUM_PRICES-1; i>=0; i--)
|
||||
{
|
||||
ptr = &PVALS[36 * i];
|
||||
heights[num] = *ptr;
|
||||
prices[num] = komodo_paxcalc(*ptr,&ptr[1],baseid,relid,COIN,0,0);
|
||||
num++;
|
||||
if ( num >= max )
|
||||
return(num);
|
||||
}
|
||||
}
|
||||
return(num);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void komodo_paxpricefeed(int32_t height,uint8_t *pricefeed,int32_t opretlen)
|
||||
|
||||
@@ -809,7 +809,7 @@ char *bitcoin_address(char *coinaddr,uint8_t addrtype,uint8_t *pubkey_or_rmd160,
|
||||
return(coinaddr);
|
||||
}
|
||||
|
||||
int32_t komodo_is_issuer()
|
||||
int32_t hush_is_issuer()
|
||||
{
|
||||
if ( SMART_CHAIN_SYMBOL[0] != 0 && hush_baseid(SMART_CHAIN_SYMBOL) >= 0 )
|
||||
return(1);
|
||||
|
||||
@@ -137,7 +137,6 @@ void vcalc_sha256(char deprecated[(256 >> 3) * 2 + 1],uint8_t hash[256 >> 3],uin
|
||||
uint32_t Mining_start,Mining_height;
|
||||
int32_t My_notaryid = -1;
|
||||
int32_t hush_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33,uint32_t timestamp);
|
||||
int32_t komodo_pax_opreturn(int32_t height,uint8_t *opret,int32_t maxsize);
|
||||
int32_t hush_baseid(char *origbase);
|
||||
int32_t hush_longestchain();
|
||||
int64_t hush_block_unlocktime(uint32_t nHeight);
|
||||
|
||||
@@ -252,7 +252,7 @@ UniValue getinfo(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
obj.push_back(Pair("notarizedtxid", notarized_desttxid.ToString()));
|
||||
if ( HUSH_NSPV_FULLNODE )
|
||||
{
|
||||
txid_height = notarizedtxid_height(SMART_CHAIN_SYMBOL[0] != 0 ? (char *)"HUSH3" : (char *)"BTC",(char *)notarized_desttxid.ToString().c_str(),&hushnotarized_height);
|
||||
txid_height = notarizedtxid_height( (char *)"HUSH3" ,(char *)notarized_desttxid.ToString().c_str(),&hushnotarized_height);
|
||||
if ( txid_height > 0 )
|
||||
obj.push_back(Pair("notarizedtxid_height", txid_height));
|
||||
else obj.push_back(Pair("notarizedtxid_height", "mempool"));
|
||||
|
||||
@@ -831,7 +831,8 @@ UniValue CRPCTable::execute(const std::string &strMethod, const UniValue ¶ms
|
||||
// few RPCs means we can see our addresses and make private key backups
|
||||
// while a very long wallet rescan is happening
|
||||
if (pcmd->name != "stop" && pcmd->name != "help" && pcmd->name != "z_listaddresses" && pcmd->name != "z_exportkey" &&
|
||||
pcmd->name != "getaddressesbyaccount" && pcmd->name != "dumpprivkey" && pcmd->name != "getpeerinfo" ) {
|
||||
pcmd->name != "getaddressesbyaccount" && pcmd->name != "listaddresses" && pcmd->name != "z_exportwallet" &&
|
||||
pcmd->name != "dumpprivkey" && pcmd->name != "getpeerinfo" ) {
|
||||
throw JSONRPCError(RPC_IN_WARMUP, rpcWarmupStatus);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -612,9 +612,9 @@ UniValue sendtoaddress(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
uint64_t PAX_fiatdest(uint64_t *seedp,int32_t tokomodo,char *destaddr,uint8_t pubkey37[37],char *coinaddr,int32_t height,char *base,int64_t fiatoshis);
|
||||
int32_t hush_opreturnscript(uint8_t *script,uint8_t type,uint8_t *opret,int32_t opretlen);
|
||||
extern int32_t HUSH_PAX;
|
||||
int32_t komodo_is_issuer();
|
||||
int32_t hush_is_issuer();
|
||||
int32_t dragon_rwnum(int32_t rwflag,uint8_t *serialized,int32_t len,void *endianedp);
|
||||
int32_t komodo_isrealtime(int32_t *kmdheightp);
|
||||
int32_t hush_isrealtime(int32_t *kmdheightp);
|
||||
int32_t pax_fiatstatus(uint64_t *available,uint64_t *deposited,uint64_t *issued,uint64_t *withdrawn,uint64_t *approved,uint64_t *redeemed,char *base);
|
||||
int32_t komodo_kvsearch(uint256 *refpubkeyp,int32_t current_height,uint32_t *flagsp,int32_t *heightp,uint8_t value[DRAGON_MAXSCRIPTSIZE],uint8_t *key,int32_t keylen);
|
||||
int32_t komodo_kvcmp(uint8_t *refvalue,uint16_t refvaluesize,uint8_t *value,uint16_t valuesize);
|
||||
@@ -774,7 +774,7 @@ UniValue paxdeposit(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
{
|
||||
throw runtime_error("paxdeposit disabled without -pax");
|
||||
}
|
||||
if ( komodo_is_issuer() != 0 )
|
||||
if ( hush_is_issuer() != 0 )
|
||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "paxdeposit only from KYC");
|
||||
if (!EnsureWalletIsAvailable(fHelp))
|
||||
throw runtime_error("paxdeposit needs wallet"); //return Value::null;
|
||||
@@ -822,7 +822,7 @@ UniValue paxwithdraw(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
throw runtime_error("paxwithdraw deprecated");
|
||||
if (fHelp || params.size() != 2)
|
||||
throw runtime_error("paxwithdraw address fiatamount");
|
||||
if ( komodo_isrealtime(&kmdheight) == 0 )
|
||||
if ( hush_isrealtime(&kmdheight) == 0 )
|
||||
return(0);
|
||||
LOCK2(cs_main, pwalletMain->cs_wallet);
|
||||
CBitcoinAddress address(params[0].get_str());
|
||||
|
||||
@@ -3061,7 +3061,7 @@ std::vector<uint256> CWallet::ResendWalletTransactionsBefore(int64_t nTime)
|
||||
|
||||
if ( (wtx.nLockTime >= LOCKTIME_THRESHOLD && wtx.nLockTime < now-HUSH_MAXMEMPOOLTIME) )
|
||||
{
|
||||
//LogPrintf("skip Relaying wtx %s nLockTime %u vs now.%u\n", wtx.GetHash().ToString(),(uint32_t)wtx.nLockTime,now);
|
||||
LogPrintf("%s: skip Relaying wtx %s nLockTime %u vs now.%u\n", __func__, wtx.GetHash().ToString(),(uint32_t)wtx.nLockTime,now);
|
||||
//vwtxh.push_back(wtx.GetHash());
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user