Browse Source

Merge pull request #174 from jl777/dev

Dev
win-cross
jl777 8 years ago
committed by GitHub
parent
commit
b8efad1b38
  1. 5
      basilisk/basilisk.c
  2. 4
      basilisk/basilisk_tradebot.c
  3. 2
      crypto777/bitcoind_RPC.c
  4. 2
      iguana/dpow/dpow_rpc.c
  5. 2
      iguana/iguana777.h
  6. 58
      iguana/iguana_notary.c
  7. 2
      iguana/iguana_unspents.c
  8. 2
      iguana/tests/fundBTC
  9. 2
      includes/iguana_apideclares.h

5
basilisk/basilisk.c

@ -883,15 +883,18 @@ void basilisks_loop(void *arg)
basilisk_ping_send(myinfo,relay); basilisk_ping_send(myinfo,relay);
counter++; counter++;
if ( myinfo->numdpows == 1 ) if ( myinfo->numdpows == 1 )
{
iguana_dPoWupdate(myinfo,&myinfo->DPOWS[0]); iguana_dPoWupdate(myinfo,&myinfo->DPOWS[0]);
endmilli = startmilli + 50;
}
else if ( myinfo->numdpows > 1 ) else if ( myinfo->numdpows > 1 )
{ {
dp = &myinfo->DPOWS[counter % myinfo->numdpows]; dp = &myinfo->DPOWS[counter % myinfo->numdpows];
iguana_dPoWupdate(myinfo,dp); iguana_dPoWupdate(myinfo,dp);
if ( (counter % myinfo->numdpows) != 0 ) if ( (counter % myinfo->numdpows) != 0 )
iguana_dPoWupdate(myinfo,&myinfo->DPOWS[0]); iguana_dPoWupdate(myinfo,&myinfo->DPOWS[0]);
endmilli = startmilli + 10;
} }
endmilli = startmilli + 50;
} }
else else
{ {

4
basilisk/basilisk_tradebot.c

@ -343,7 +343,9 @@ void tradebot_liquidity_command(struct supernet_info *myinfo,char *base,bits256
{ {
strcpy(li.base,refli.base); strcpy(li.base,refli.base);
strcpy(li.rel,refli.rel); strcpy(li.rel,refli.rel);
li.refprice = (1. / li.refprice); if ( fabs(li.refprice) > SMALLVAL )
li.refprice = (1. / li.refprice);
else li.refprice = 0.;
printf("Set rev linfo[%d] (%s/%s) %.6f %.8f\n",i,li.base,li.rel,li.profit,li.refprice); printf("Set rev linfo[%d] (%s/%s) %.6f %.8f\n",i,li.base,li.rel,li.profit,li.refprice);
myinfo->linfos[i] = li; myinfo->linfos[i] = li;
return; return;

2
crypto777/bitcoind_RPC.c

@ -89,7 +89,7 @@ char *post_process_bitcoind_RPC(char *debugstr,char *command,char *rpcstr,char *
} }
else if ( (error->type&0xff) != cJSON_NULL || (result->type&0xff) != cJSON_NULL ) else if ( (error->type&0xff) != cJSON_NULL || (result->type&0xff) != cJSON_NULL )
{ {
if ( strcmp(command,"signrawtransaction") != 0 ) if ( strcmp(command,"signrawtransaction") != 0 && strcmp(command,"sendrawtransaction") != 0 )
printf("<<<<<<<<<<< bitcoind_RPC: %s post_process_bitcoind_RPC (%s) error.%s\n",debugstr,command,rpcstr); printf("<<<<<<<<<<< bitcoind_RPC: %s post_process_bitcoind_RPC (%s) error.%s\n",debugstr,command,rpcstr);
retstr = rpcstr; retstr = rpcstr;
rpcstr = 0; rpcstr = 0;

2
iguana/dpow/dpow_rpc.c

@ -409,7 +409,7 @@ char *dpow_sendrawtransaction(struct supernet_info *myinfo,struct iguana_info *c
jaddistr(array,signedtx); jaddistr(array,signedtx);
paramstr = jprint(array,1); paramstr = jprint(array,1);
retstr = bitcoind_passthru(coin->symbol,coin->chain->serverport,coin->chain->userpass,"sendrawtransaction",paramstr); retstr = bitcoind_passthru(coin->symbol,coin->chain->serverport,coin->chain->userpass,"sendrawtransaction",paramstr);
printf(">>>>>>>>>>> %s sendrawtransaction.(%s) -> %s\n",coin->symbol,paramstr,retstr); //printf(">>>>>>>>>>> %s sendrawtransaction.(%s) -> %s\n",coin->symbol,paramstr,retstr);
free(paramstr); free(paramstr);
return(retstr); return(retstr);
} }

2
iguana/iguana777.h

@ -116,7 +116,7 @@ struct supernet_info
// fadedreamz // fadedreamz
struct peggy_info *PEGS; struct peggy_info *PEGS;
void *PAXDATA; void *PAXDATA;
struct liquidity_info linfos[64]; struct liquidity_info linfos[512];
struct komodo_notaries NOTARY; struct komodo_notaries NOTARY;
char seedipaddr[64]; uint32_t dpowipbits[128]; int32_t numdpowipbits; portable_mutex_t notarymutex,dpowmutex; char seedipaddr[64]; uint32_t dpowipbits[128]; int32_t numdpowipbits; portable_mutex_t notarymutex,dpowmutex;
char dexseed_ipaddr[64]; uint32_t dexipbits[128]; int32_t numdexipbits; portable_mutex_t dexmutex; char dexseed_ipaddr[64]; uint32_t dexipbits[128]; int32_t numdexipbits; portable_mutex_t dexmutex;

58
iguana/iguana_notary.c

@ -157,7 +157,7 @@ void iguana_dPoWupdate(struct supernet_info *myinfo,struct dpow_info *dp)
dp->numdesttx = sizeof(dp->desttx)/sizeof(*dp->desttx); dp->numdesttx = sizeof(dp->desttx)/sizeof(*dp->desttx);
if ( (height= dpow_getchaintip(myinfo,&blockhash,&blocktime,dp->desttx,&dp->numdesttx,dest)) != dp->destchaintip.blockhash.height && height >= 0 ) if ( (height= dpow_getchaintip(myinfo,&blockhash,&blocktime,dp->desttx,&dp->numdesttx,dest)) != dp->destchaintip.blockhash.height && height >= 0 )
{ {
char str[65]; printf("%s %s height.%d vs last.%d\n",dp->dest,bits256_str(str,blockhash),height,dp->destchaintip.blockhash.height); char str[65]; printf("[%s] %s %s height.%d vs last.%d\n",dp->symbol,dp->dest,bits256_str(str,blockhash),height,dp->destchaintip.blockhash.height);
if ( height <= dp->destchaintip.blockhash.height ) if ( height <= dp->destchaintip.blockhash.height )
{ {
printf("iguana_dPoWupdate dest.%s reorg detected %d vs %d\n",dp->dest,height,dp->destchaintip.blockhash.height); printf("iguana_dPoWupdate dest.%s reorg detected %d vs %d\n",dp->dest,height,dp->destchaintip.blockhash.height);
@ -170,7 +170,7 @@ void iguana_dPoWupdate(struct supernet_info *myinfo,struct dpow_info *dp)
{ {
if ( strcmp(dp->dest,"KMD") == 0 ) if ( strcmp(dp->dest,"KMD") == 0 )
dp->SRCHEIGHT = dpow_issuer_iteration(dp,src,dp->SRCHEIGHT,&dp->SRCREALTIME); dp->SRCHEIGHT = dpow_issuer_iteration(dp,src,dp->SRCHEIGHT,&dp->SRCREALTIME);
char str[65]; printf("%s %s height.%d vs last.%d\n",dp->symbol,bits256_str(str,blockhash),height,dp->last.blockhash.height); char str[65]; printf("[%s] %s %s height.%d vs last.%d\n",dp->dest,dp->symbol,bits256_str(str,blockhash),height,dp->last.blockhash.height);
if ( dp->lastheight == 0 ) if ( dp->lastheight == 0 )
dp->lastheight = height-1; dp->lastheight = height-1;
if ( height < dp->last.blockhash.height ) if ( height < dp->last.blockhash.height )
@ -425,14 +425,64 @@ STRING_ARG(iguana,addnotary,ipaddr)
return(clonestr("{\"result\":\"notary node added\"}")); return(clonestr("{\"result\":\"notary node added\"}"));
} }
STRING_ARG(dpow,fundnotaries,symbol) STRING_AND_INT(dpow,fundnotaries,symbol,numblocks)
{ {
int32_t komodo_notaries(char *symbol,uint8_t pubkeys[64][33],int32_t height); int32_t komodo_notaries(char *symbol,uint8_t pubkeys[64][33],int32_t height);
char CURRENCIES[][16] = { "USD", "EUR", "JPY", "GBP", "AUD", "CAD", "CHF", "NZD", // major currencies char CURRENCIES[][16] = { "USD", "EUR", "JPY", "GBP", "AUD", "CAD", "CHF", "NZD", // major currencies
"CNY", "RUB", "MXN", "BRL", "INR", "HKD", "TRY", "ZAR", "PLN", "NOK", "SEK", "DKK", "CZK", "HUF", "ILS", "KRW", "MYR", "PHP", "RON", "SGD", "THB", "BGN", "IDR", "HRK", "CNY", "RUB", "MXN", "BRL", "INR", "HKD", "TRY", "ZAR", "PLN", "NOK", "SEK", "DKK", "CZK", "HUF", "ILS", "KRW", "MYR", "PHP", "RON", "SGD", "THB", "BGN", "IDR", "HRK",
"REVS", "SUPERNET", "DEX", "PANGEA", "JUMBLR", "BET", "CRYPTO", "HODL", "SHARK", "BOTS", "MGW" }; "REVS", "SUPERNET", "DEX", "PANGEA", "JUMBLR", "BET", "CRYPTO", "HODL", "SHARK", "BOTS", "MGW" };
uint8_t pubkeys[64][33]; char coinaddr[64],cmd[1024]; int32_t i,j; double val = 0.01; uint8_t pubkeys[64][33]; cJSON *infojson; char coinaddr[64],cmd[1024]; uint64_t signedmask; int32_t i,j,sendflag=0,current=0,height; FILE *fp; double vals[64],sum,val = 0.01;
int32_t n = komodo_notaries("KMD",pubkeys,114000); int32_t n = komodo_notaries("KMD",pubkeys,114000);
if ( symbol != 0 && strcmp(symbol,"BTC") == 0 && (coin= iguana_coinfind("KMD")) != 0 )
{
if ( numblocks == 0 )
numblocks = 10000;
else sendflag = 1;
memset(vals,0,sizeof(vals));
if ( (infojson= dpow_getinfo(myinfo,coin)) != 0 )
{
current = jint(infojson,"blocks");
free_json(infojson);
} else return(clonestr("{\"error\":\"cant get current height\"}"));
if ( (coin= iguana_coinfind("BTC")) != 0 )
{
if ( (fp= fopen("signedmasks","rb")) != 0 )
{
while ( 1 )
{
if ( fread(&height,1,sizeof(height),fp) == sizeof(height) && fread(&signedmask,1,sizeof(signedmask),fp) == sizeof(signedmask) )
{
if ( height > current - numblocks )
{
printf("ht.%d %llx vs current.%d - %d\n",height,(long long)signedmask,current,numblocks);
for (j=0; j<64; j++)
if ( ((1LL << j) & signedmask) != 0 )
vals[j] += (double)DPOW_UTXOSIZE / SATOSHIDEN;
}
} else break;
}
fclose(fp);
} else return(clonestr("{\"error\":\"cant open signedmasks\"}"));
for (sum=j=0; j<n; j++)
{
if ( (val= vals[j]) > 0. )
{
bitcoin_address(coinaddr,60,pubkeys[j],33);
sprintf(cmd,"bicoin-cli sendtoaddress %s %f\n",coinaddr,val);
if ( sendflag != 0 && system(cmd) != 0 )
printf("ERROR with (%s)\n",cmd);
else
{
printf("(%d %f) ",j,val);
sum += val;
}
}
}
printf("%s sent %.8f BTC\n",sendflag!=0?"":"would have",sum);
return(clonestr("{\"result\":\"success\"}"));
}
else return(clonestr("{\"error\":\"cant find BTC\"}"));
}
for (i=0; i<sizeof(CURRENCIES)/sizeof(*CURRENCIES); i++) for (i=0; i<sizeof(CURRENCIES)/sizeof(*CURRENCIES); i++)
{ {
if ( symbol == 0 || symbol[0] == 0 || strcmp(symbol,CURRENCIES[i]) == 0 ) if ( symbol == 0 || symbol[0] == 0 || strcmp(symbol,CURRENCIES[i]) == 0 )

2
iguana/iguana_unspents.c

@ -1223,7 +1223,7 @@ int32_t iguana_RTunspentslists(struct supernet_info *myinfo,struct iguana_info *
item = jitem(array,i); item = jitem(array,i);
if ( is_cJSON_False(jobj(item,"spendable")) != 0 ) if ( is_cJSON_False(jobj(item,"spendable")) != 0 )
{ {
printf("skip unspendable.(%s)\n",jprint(item,0)); //printf("skip unspendable.(%s)\n",jprint(item,0));
continue; continue;
} }
if ( (spendscriptstr= jstr(item,"scriptPubKey")) == 0 ) if ( (spendscriptstr= jstr(item,"scriptPubKey")) == 0 )

2
iguana/tests/fundBTC

@ -0,0 +1,2 @@
#!/bin/bash
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"dpow\",\"method\":\"fundnotaries\",\"symbol\":\"BTC\",\"numblocks\":0}"

2
includes/iguana_apideclares.h

@ -20,7 +20,7 @@ TWOINTS_AND_ARRAY(dpow,ratify,minsigs,timestamp,ratified);
ZERO_ARGS(dpow,cancelratify); ZERO_ARGS(dpow,cancelratify);
THREE_STRINGS(iguana,passthru,asset,function,hex); THREE_STRINGS(iguana,passthru,asset,function,hex);
STRING_ARG(dpow,bindaddr,ipaddr); STRING_ARG(dpow,bindaddr,ipaddr);
STRING_ARG(dpow,fundnotaries,symbol); STRING_AND_INT(dpow,fundnotaries,symbol,numblocks);
TWO_STRINGS(dex,send,hex,handler); TWO_STRINGS(dex,send,hex,handler);
HASH_AND_STRING(dex,gettransaction,txid,symbol); HASH_AND_STRING(dex,gettransaction,txid,symbol);

Loading…
Cancel
Save