Skip to content

Commit 682b05e

Browse files
authored
Merge pull request #403 from jl777/beta
beta update
2 parents d798982 + 7571195 commit 682b05e

14 files changed

+136
-36
lines changed

src/assetchains

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ echo $pubkey
1616
./komodod -pubkey=$pubkey -ac_name=BOTS -ac_supply=999999 -addnode=78.47.196.146 $1 &
1717
./komodod -pubkey=$pubkey -ac_name=MGW -ac_supply=999999 -addnode=78.47.196.146 $1 &
1818
./komodod -pubkey=$pubkey -ac_name=MVP -ac_supply=1000000 -addnode=78.47.196.146 $1 &
19-
./komodod -pubkey=$pubkey -ac_name=WIRELESS -ac_supply=21000000 -addnode=78.47.196.146 $1 &
19+
#./komodod -pubkey=$pubkey -ac_name=WIRELESS -ac_supply=21000000 -addnode=78.47.196.146 $1 &
20+
./komodod -pubkey=$pubkey -ac_name=WLC -ac_supply=210000000 -addnode=148.251.190.89 $1 &
2021
./komodod -pubkey=$pubkey -ac_name=KV -ac_supply=1000000 -addnode=78.47.196.146 $1 &
2122
./komodod -pubkey=$pubkey -ac_name=CEAL -ac_supply=366666666 -addnode=78.47.196.146 $1 &
2223
./komodod -pubkey=$pubkey -ac_name=MESH -ac_supply=1000000 -addnode=78.47.196.146 $1 &

src/dpowassets

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dp
1717
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"BOTS\",\"pubkey\":\"$pubkey\"}"
1818
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"MGW\",\"pubkey\":\"$pubkey\"}"
1919
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"MVP\",\"pubkey\":\"$pubkey\"}"
20-
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"WIRELESS\",\"pubkey\":\"$pubkey\"}"
20+
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"WLC\",\"pubkey\":\"$pubkey\"}"
2121
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"KV\",\"pubkey\":\"$pubkey\"}"
2222
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"CEAL\",\"pubkey\":\"$pubkey\"}"
2323
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"MESH\",\"pubkey\":\"$pubkey\"}"

src/fiat-cli

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ echo shark; fiat/shark $1 $2 $3 $4
4444
echo bots; fiat/bots $1 $2 $3 $4
4545
echo mgw; fiat/mgw $1 $2 $3 $4
4646
echo mvp; fiat/mvp $1 $2 $3 $4
47-
echo wireless; fiat/wireless $1 $2 $3 $4
47+
echo wlc; fiat/wlc $1 $2 $3 $4
4848
echo kv; fiat/kv $1 $2 $3 $4
4949
echo ceal; fiat/ceal $1 $2 $3 $4
5050
echo mesh; fiat/mesh $1 $2 $3 $4

src/fiat/wireless

-2
This file was deleted.

src/fiat/wlc

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/bash
2+
./komodo-cli -ac_name=WLC $1 $2 $3 $4 $5 $6

src/komodo_bitcoind.h

+54
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,60 @@ char *komodo_issuemethod(char *userpass,char *method,char *params,uint16_t port)
341341
return(retstr2);
342342
}
343343

344+
int32_t notarizedtxid_height(char *dest,char *txidstr,int32_t *kmdnotarized_heightp)
345+
{
346+
char *jsonstr,params[256],*userpass; uint16_t port; cJSON *json,*item; int32_t height = 0,txid_height = 0,txid_confirmations = 0;
347+
params[0] = 0;
348+
*kmdnotarized_heightp = 0;
349+
if ( strcmp(dest,"KMD") == 0 )
350+
{
351+
port = 7771;
352+
userpass = KMDUSERPASS;
353+
}
354+
else if ( strcmp(dest,"BTC") == 0 )
355+
{
356+
port = 8332;
357+
userpass = BTCUSERPASS;
358+
}
359+
else return(0);
360+
if ( userpass[0] != 0 )
361+
{
362+
if ( (jsonstr= komodo_issuemethod(userpass,(char *)"getinfo",params,port)) != 0 )
363+
{
364+
//printf("(%s)\n",jsonstr);
365+
if ( (json= cJSON_Parse(jsonstr)) != 0 )
366+
{
367+
if ( (item= jobj(json,(char *)"result")) != 0 )
368+
{
369+
height = jint(item,(char *)"blocks");
370+
*kmdnotarized_heightp = strcmp(dest,"KMD") == 0 ? jint(item,(char *)"notarized") : height;
371+
}
372+
free_json(json);
373+
}
374+
free(jsonstr);
375+
}
376+
sprintf(params,"[\"%s\", 1]",txidstr);
377+
if ( (jsonstr= komodo_issuemethod(userpass,(char *)"getrawtransaction",params,port)) != 0 )
378+
{
379+
//printf("(%s)\n",jsonstr);
380+
if ( (json= cJSON_Parse(jsonstr)) != 0 )
381+
{
382+
if ( (item= jobj(json,(char *)"result")) != 0 )
383+
{
384+
txid_confirmations = jint(item,(char *)"confirmations");
385+
if ( txid_confirmations > 0 && height > txid_confirmations )
386+
txid_height = height - txid_confirmations;
387+
else txid_height = height;
388+
//printf("height.%d tconfs.%d txid_height.%d\n",height,txid_confirmations,txid_height);
389+
}
390+
free_json(json);
391+
}
392+
free(jsonstr);
393+
}
394+
}
395+
return(txid_height);
396+
}
397+
344398
int32_t komodo_verifynotarizedscript(int32_t height,uint8_t *script,int32_t len,uint256 NOTARIZED_HASH)
345399
{
346400
int32_t i; uint256 hash; char params[256];

src/komodo_events.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@ void komodo_eventadd_notarized(struct komodo_state *sp,char *symbol,int32_t heig
4040
{
4141
struct komodo_event_notarized N;
4242
if ( komodo_verifynotarization(symbol,dest,height,notarizedheight,notarized_hash,notarized_desttxid) != 0 )
43-
printf("[%s] error validating notarization ht.%d notarized_height.%d\n",ASSETCHAINS_SYMBOL,height,notarizedheight);
43+
{
44+
if ( height > 50000 )
45+
printf("[%s] error validating notarization ht.%d notarized_height.%d\n",ASSETCHAINS_SYMBOL,height,notarizedheight);
46+
}
4447
else
4548
{
4649
memset(&N,0,sizeof(N));

src/komodo_gateway.h

+22-10
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to
584584
PENDING_KOMODO_TX += pax->komodoshis;
585585
printf(" len.%d vout.%u DEPOSIT %.8f <- pax.%s pending ht %d %d %.8f | ",len,pax->vout,(double)txNew->vout[numvouts].nValue/COIN,symbol,pax->height,pax->otherheight,dstr(PENDING_KOMODO_TX));
586586
}
587-
if ( numvouts++ >= 64 )
587+
if ( numvouts++ >= 64 || sum > COIN )
588588
break;
589589
}
590590
if ( numvouts > 1 )
@@ -652,7 +652,8 @@ void komodo_passport_iteration();
652652
int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above block is valid pax pricing
653653
{
654654
static uint256 array[64]; static int32_t numbanned,indallvouts;
655-
int32_t i,j,k,n,ht,baseid,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 total,available,deposited,issued,withdrawn,approved,redeemed; int64_t values[64],srcvalues[64]; struct pax_transaction *pax; struct komodo_state *sp;
655+
int32_t i,j,k,n,ht,baseid,txn_count,activation,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 total,available,deposited,issued,withdrawn,approved,redeemed,checktoshis,seed; int64_t values[64],srcvalues[64]; struct pax_transaction *pax; struct komodo_state *sp;
656+
activation = 235300;
656657
if ( *(int32_t *)&array[0] == 0 )
657658
numbanned = komodo_bannedset(&indallvouts,array,(int32_t)(sizeof(array)/sizeof(*array)));
658659
memset(baseids,0xff,sizeof(baseids));
@@ -706,7 +707,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above
706707
if ( overflow != 0 || total > COIN/10 )
707708
{
708709
//fprintf(stderr,">>>>>>>> <<<<<<<<<< ht.%d illegal nonz output %.8f n.%d\n",height,dstr(block.vtx[0].vout[1].nValue),n);
709-
if ( height >= 235300 )
710+
if ( height >= activation )
710711
return(-1);
711712
}
712713
}
@@ -938,7 +939,17 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above
938939
{
939940
}
940941
if ( strcmp(ASSETCHAINS_SYMBOL,CURRENCIES[baseids[i-1]]) == 0 )
941-
printf("check deposit validates %s.%d [%d] %.8f -> %.8f (%.8f %.8f %.8f)\n",CURRENCIES[baseids[i-1]],height,i,dstr(srcvalues[i-1]),dstr(values[i-1]),dstr(pax->komodoshis),dstr(pax->fiatoshis),dstr(block.vtx[0].vout[i].nValue));
942+
{
943+
//check deposit validates AUD.1047 [3] 0.14585530 -> 0.01000000 (0.14585530 0.01000000 0.01000000)
944+
char destaddr[64],coinaddr[64]; uint8_t pubkey33[33];
945+
checktoshis = PAX_fiatdest(&seed,0,destaddr,pubkey33,coinaddr,pax->height,CURRENCIES[baseids[i-1]],pax->fiatoshis);
946+
//checktoshis = komodo_paxprice(&seed,pax->height,CURRENCIES[baseids[i-1]],(char *)"KMD",(uint64_t)pax->komodoshis);
947+
if ( komodo_paxcmp(CURRENCIES[baseids[i-1]],pax->height,pax->komodoshis,checktoshis,seed) < 0 )
948+
{
949+
printf("paxcmp FAIL when check deposit validates %s.%d [%d] %.8f -> %.8f (%.8f %.8f %.8f)\n",CURRENCIES[baseids[i-1]],height,i,dstr(srcvalues[i-1]),dstr(values[i-1]),dstr(pax->komodoshis),dstr(pax->fiatoshis),dstr(block.vtx[0].vout[i].nValue));
950+
return(-1);
951+
} //else printf("check deposit validates %s.%d [%d] %.8f -> %.8f (%.8f %.8f %.8f)\n",CURRENCIES[baseids[i-1]],height,i,dstr(srcvalues[i-1]),dstr(values[i-1]),dstr(pax->komodoshis),dstr(pax->fiatoshis),dstr(block.vtx[0].vout[i].nValue));
952+
}
942953
}
943954
else if ( strcmp(ASSETCHAINS_SYMBOL,CURRENCIES[baseids[i-1]]) == 0 )
944955
{
@@ -955,12 +966,13 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above
955966
for (j=0; j<32; j++)
956967
printf("%02x",((uint8_t *)&hash)[j]);
957968
printf(" kht.%d ht.%d %.8f %.8f blockhash couldnt find vout.[%d] ht.%d %s for [%s]\n",kmdheights[i-1],otherheights[i-1],dstr(values[i-1]),dstr(srcvalues[i]),i,height,ASSETCHAINS_SYMBOL,CURRENCIES[baseids[i-1]]);
958-
return(-1);
969+
if ( ASSETCHAINS_SYMBOL[0] != 0 || height >= activation )
970+
return(-1);
959971
}
960972
}
961973
if ( ASSETCHAINS_SYMBOL[0] == 0 )
962974
{
963-
if ( height > 0 && (height < chainActive.Tip()->nHeight || (height >= chainActive.Tip()->nHeight && komodo_isrealtime(&ht) != 0)) && matched != num )
975+
/*if ( height > 0 && (height < chainActive.Tip()->nHeight || (height >= chainActive.Tip()->nHeight && komodo_isrealtime(&ht) != 0)) && matched != num )
964976
{
965977
printf("WOULD REJECT %s: ht.%d (%c) matched.%d vs num.%d tip.%d isRT.%d\n",symbol,height,opcode,matched,num,(int32_t)chainActive.Tip()->nHeight,komodo_isrealtime(&ht));
966978
// can easily happen depending on order of loading
@@ -969,7 +981,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above
969981
printf("REJECT: ht.%d (%c) matched.%d vs num.%d\n",height,opcode,matched,num);
970982
return(-1);
971983
}
972-
}
984+
}*/ // disabled 'X' path
973985
}
974986
else
975987
{
@@ -985,7 +997,8 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above
985997
for (i=0; i<n; i++)
986998
printf("%.8f ",dstr(block.vtx[0].vout[i].nValue));
987999
printf("no opreturn entries to check ht.%d %s\n",height,ASSETCHAINS_SYMBOL);
988-
return(-1);
1000+
if ( ASSETCHAINS_SYMBOL[0] != 0 || height >= activation )
1001+
return(-1);
9891002
}
9901003
//printf("opretlen.%d num.%d\n",opretlen,num);
9911004
}
@@ -995,7 +1008,6 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above
9951008
printf("%02x",script[i]);
9961009
printf(" height.%d checkdeposit n.%d [%02x] [%c] %d len.%d ",height,n,script[0],script[offset],script[offset],opretlen);
9971010
printf("not proper vout with opreturn format %s ht.%d\n",ASSETCHAINS_SYMBOL,height);
998-
exit(-1);
9991011
return(-1);
10001012
}
10011013
return(0);
@@ -1090,7 +1102,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3
10901102
{
10911103
basesp->issued += pax2->fiatoshis;
10921104
pax2->didstats = 1;
1093-
if ( 1 && strcmp(base,"USD") == 0 )
1105+
if ( 0 && strcmp(base,"USD") == 0 )
10941106
printf("########### %p issueda %s += %.8f kmdheight.%d %.8f other.%d [%d]\n",basesp,base,dstr(pax2->fiatoshis),pax2->height,dstr(pax2->komodoshis),pax2->otherheight,height);
10951107
}
10961108
}

src/komodo_interest.h

+22-5
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ uint64_t komodo_moneysupply(int32_t height)
6666

6767
uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uint32_t tiptime)
6868
{
69-
int32_t minutes,exception; uint64_t numerator,denominator,interest = 0;
69+
int32_t minutes,exception; uint64_t numerator,denominator,interest = 0; uint32_t activation;
70+
activation = 1491350400; // 1491350400 5th April
7071
if ( ASSETCHAINS_SYMBOL[0] != 0 )
7172
return(0);
7273
if ( komodo_moneysupply(txheight) < MAX_MONEY && nLockTime >= LOCKTIME_THRESHOLD && tiptime != 0 && nLockTime < tiptime && nValue >= 10*COIN )
@@ -118,12 +119,28 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin
118119
}
119120
else
120121
{
122+
/* 250000 algo
123+
numerator = (nValue * KOMODO_INTEREST);
124+
if ( txheight < 250000 || numerator * minutes < 365 * 24 * 60 )
125+
interest = (numerator / denominator) / COIN;
126+
else interest = ((numerator * minutes) / ((uint64_t)365 * 24 * 60)) / COIN;
127+
*/
121128
numerator = (nValue * KOMODO_INTEREST);
122-
if ( txheight < 250000 || numerator * minutes < 365 * 24 * 60 )
123-
interest = (numerator / denominator) / COIN;
124-
else interest = ((numerator * minutes) / ((uint64_t)365 * 24 * 60)) / COIN;
129+
if ( txheight < 250000 || tiptime < activation )
130+
{
131+
if ( txheight < 250000 || numerator * minutes < 365 * 24 * 60 )
132+
interest = (numerator / denominator) / COIN;
133+
else interest = ((numerator * minutes) / ((uint64_t)365 * 24 * 60)) / COIN;
134+
}
135+
else
136+
{
137+
numerator = (nValue / 20); // assumes 5%!
138+
interest = ((numerator * minutes) / ((uint64_t)365 * 24 * 60));
139+
//fprintf(stderr,"interest %llu %.8f <- numerator.%llu minutes.%d\n",(long long)interest,(double)interest/COIN,(long long)numerator,(int32_t)minutes);
140+
}
125141
}
126-
//fprintf(stderr,"komodo_interest %lld %.8f nLockTime.%u tiptime.%u minutes.%d interest %lld %.8f (%llu / %llu)\n",(long long)nValue,(double)nValue/COIN,nLockTime,tiptime,minutes,(long long)interest,(double)interest/COIN,(long long)numerator,(long long)denominator);
142+
if ( 0 && numerator == (nValue * KOMODO_INTEREST) )
143+
fprintf(stderr,"komodo_interest.%d %lld %.8f nLockTime.%u tiptime.%u minutes.%d interest %lld %.8f (%llu / %llu) prod.%llu\n",txheight,(long long)nValue,(double)nValue/COIN,nLockTime,tiptime,minutes,(long long)interest,(double)interest/COIN,(long long)numerator,(long long)denominator,(long long)(numerator * minutes));
127144
}
128145
}
129146
return(interest);

src/komodo_utils.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1355,7 +1355,7 @@ void komodo_configfile(char *symbol,uint16_t port)
13551355
komodo_userpass(username,password,fp);
13561356
sprintf(KMDUSERPASS,"%s:%s",username,password);
13571357
fclose(fp);
1358-
//printf("KOMODO.(%s) -> userpass.(%s)\n",fname,KMDUSERPASS);
1358+
//printf("KOMODO.(%s) -> userpass.(%s)\n",fname,KMDUSERPASS);
13591359
} else printf("couldnt open.(%s)\n",fname);
13601360
}
13611361

src/miner.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -650,14 +650,14 @@ void static BitcoinMiner(CWallet *pwallet)
650650
CBlock *pblock = &pblocktemplate->block;
651651
if ( ASSETCHAINS_SYMBOL[0] != 0 )
652652
{
653-
if ( pblock->vtx[0].vout.size() == 1 && Mining_height > ASSETCHAINS_MINHEIGHT )
653+
if ( pblock->vtx.size() == 1 && Mining_height > ASSETCHAINS_MINHEIGHT )
654654
{
655655
static uint32_t counter;
656656
if ( counter++ < 10 )
657657
fprintf(stderr,"skip generating %s on-demand block, no tx avail\n",ASSETCHAINS_SYMBOL);
658658
sleep(10);
659659
continue;
660-
} else fprintf(stderr,"vouts.%d mining.%d vs %d\n",(int32_t)pblock->vtx[0].vout.size(),Mining_height,ASSETCHAINS_MINHEIGHT);
660+
} else fprintf(stderr,"%s vouts.%d mining.%d vs %d\n",ASSETCHAINS_SYMBOL,(int32_t)pblock->vtx[0].vout.size(),Mining_height,ASSETCHAINS_MINHEIGHT);
661661
}
662662
IncrementExtraNonce(pblock, pindexPrev, nExtraNonce);
663663
LogPrintf("Running KomodoMiner.%s with %u transactions in block (%u bytes)\n",solver.c_str(),pblock->vtx.size(),::GetSerializeSize(*pblock,SER_NETWORK,PROTOCOL_VERSION));
@@ -703,11 +703,11 @@ void static BitcoinMiner(CWallet *pwallet)
703703
if ( mids[j] == -1 )
704704
gpucount++;
705705
}
706-
if ( gpucount > j/3 )
706+
if ( gpucount > j/2 )
707707
{
708708
double delta;
709709
i = ((Mining_height + notaryid) % 64);
710-
delta = sqrt((double)gpucount - j/3) / 2.;
710+
delta = sqrt((double)gpucount - j/2) / 2.;
711711
roundrobin_delay += ((delta * i) / 64) - delta;
712712
//fprintf(stderr,"delta.%f %f %f\n",delta,(double)(gpucount - j/3) / 2,(delta * i) / 64);
713713
}

src/pow.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned in
175175
fprintf(stderr,"pow error height.%d loading.%d notaryid.%d\n",height,KOMODO_LOADINGBLOCKS,notaryid);
176176
return error("CheckProofOfWork(): hash doesn't match nBits");
177177
} else fprintf(stderr,"skip return error height.%d loading.%d\n",height,KOMODO_LOADINGBLOCKS);
178-
} else fprintf(stderr,"skip height.%d loading.%d\n",height,KOMODO_LOADINGBLOCKS);
178+
} //else fprintf(stderr,"skip height.%d loading.%d\n",height,KOMODO_LOADINGBLOCKS);
179179
}
180180
if ( 0 && height > 248000 )
181181
{

0 commit comments

Comments
 (0)