Browse Source

Merge pull request #806 from jl777/dev

Dev
patch-6
jl777 7 years ago
committed by GitHub
parent
commit
229cdf2d98
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      basilisk/basilisk_bitcoin.c
  2. 2
      iguana/acsplit
  3. 4
      iguana/dPoW.h
  4. 1
      iguana/dpow/dpow_fsm.c
  5. 24
      iguana/dpow/dpow_network.c
  6. 16
      iguana/dpow/dpow_rpc.c
  7. 1
      iguana/elected
  8. 2
      iguana/exchanges/LP_rpc.c
  9. 2
      iguana/iguana777.c
  10. 2
      iguana/iguana777.h
  11. 40
      iguana/iguana_notary.c
  12. 2
      iguana/tests/active
  13. 2
      includes/iguana_structs.h

2
basilisk/basilisk_bitcoin.c

@ -585,7 +585,7 @@ char *iguana_utxoduplicates(struct supernet_info *myinfo,struct iguana_info *coi
if ( signedtxidp != 0 )
memset(signedtxidp,0,sizeof(*signedtxidp));
bitcoin_address(changeaddr,coin->chain->pubtype,myinfo->persistent_pubkey33,33);
txfee = (coin->txfee + duplicates*coin->txfee*2);
txfee = (coin->txfee + duplicates*coin->txfee/10);
if ( (txobj= bitcoin_txcreate(coin->symbol,coin->chain->isPoS,0,1,0)) != 0 )
{
if ( duplicates <= 0 )

2
iguana/acsplit

@ -1 +1 @@
curl --url "http://127.0.0.1:7776" --data "{\"coin\":\""${1}"\",\"agent\":\"iguana\",\"method\":\"splitfunds\",\"satoshis\":\"50000\",\"sendflag\":1,\"duplicates\":"${2}"}"
curl --url "http://127.0.0.1:7776" --data "{\"coin\":\""${1}"\",\"agent\":\"iguana\",\"method\":\"splitfunds\",\"satoshis\":\"10000\",\"sendflag\":1,\"duplicates\":"${2}"}"

4
iguana/dPoW.h

@ -29,7 +29,7 @@
#define DPOW_VERSION 0x1782
#define DPOW_UTXOSIZE 10000//50000
#define DPOW_MINOUTPUT 6000
#define DPOW_DURATION 600
#define DPOW_DURATION 1200
#define DPOW_RATIFYDURATION (3600 * 24)
//#define DPOW_ENTRIESCHANNEL ('e' | ('n' << 8) | ('t' << 16) | ('r' << 24))
@ -142,7 +142,7 @@ struct dpow_info
struct pax_transaction *PAX;
portable_mutex_t paxmutex,dexmutex;
uint32_t ipbits[128],numipbits;
struct dpow_block **blocks;
struct dpow_block **blocks,*currentbp;
};
struct komodo_ccdatapair { int32_t notarization_height; uint32_t MoMoMoffset; };

1
iguana/dpow/dpow_fsm.c

@ -360,6 +360,7 @@ void dpow_statemachinestart(void *ptr)
}
bp->bestk = -1;
dp->blocks[checkpoint.blockhash.height] = bp;
dp->currentbp = bp;
bp->beacon = rand256(0);
vcalc_sha256(0,bp->commit.bytes,bp->beacon.bytes,sizeof(bp->beacon));
}

24
iguana/dpow/dpow_network.c

@ -1778,6 +1778,30 @@ void dpow_ratify_update(struct supernet_info *myinfo,struct dpow_info *dp,struct
}
}
cJSON *dpow_recvmasks(struct supernet_info *myinfo,struct dpow_info *dp,struct dpow_block *bp)
{
int32_t i,j; cJSON *retjson,*item; char hexstr[64];
retjson = cJSON_CreateArray();
if ( dp == 0 || bp == 0 )
return(retjson);
for (i=0; i<bp->numnotaries; i++)
{
item = cJSON_CreateObject();
jaddstr(item,"notary",Notaries_elected[i][0]);
jaddnum(item,"bestk",bp->notaries[i].bestk);
for (j=7; j>=0; j--)
sprintf(hexstr,"%02x",((uint8_t *)&bp->notaries[i].recvmask)[j]);
hexstr[16] = 0;
jaddstr(item,"recvmask",hexstr);
for (j=7; j>=0; j--)
sprintf(hexstr,"%02x",((uint8_t *)&bp->notaries[i].bestmask)[j]);
hexstr[16] = 0;
jaddstr(item,"bestmask",hexstr);
jaddi(retjson,item);
}
return(retjson);
}
void dpow_notarize_update(struct supernet_info *myinfo,struct dpow_info *dp,struct dpow_block *bp,uint8_t senderind,int8_t bestk,uint64_t bestmask,uint64_t recvmask,bits256 srcutxo,uint16_t srcvout,bits256 destutxo,uint16_t destvout,uint8_t siglens[2],uint8_t sigs[2][DPOW_MAXSIGLEN],uint32_t paxwdcrc)
{
bits256 srchash; int32_t i,flag,bestmatches = 0,matches = 0,paxmatches = 0,paxbestmatches = 0;

16
iguana/dpow/dpow_rpc.c

@ -375,11 +375,23 @@ cJSON *dpow_getblock(struct supernet_info *myinfo,struct iguana_info *coin,bits2
char *dpow_validateaddress(struct supernet_info *myinfo,struct iguana_info *coin,char *address)
{
char buf[128],*retstr=0;
char buf[128],*retstr=0; cJSON *retjson;
if ( coin->FULLNODE < 0 )
{
sprintf(buf,"\"%s\"",address);
retstr = bitcoind_passthru(coin->symbol,coin->chain->serverport,coin->chain->userpass,"validateaddress",buf);
retstr = bitcoind_passthru(coin->symbol,coin->chain->serverport,coin->chain->userpass,coin->validateaddress,buf);
if ( (retjson= cJSON_Parse(retstr)) != 0 )
{
if ( strcmp(coin->symbol,"BTC") == 0 && jobj(retjson,"error") == 0 && jobj(retjson,"ismine") == 0 && strcmp(coin->validateaddress,"validateaddress") == 0 )
{
printf("autochange %s validateaddress -> getaddressinfo\n",coin->symbol);
strcpy(coin->validateaddress,"getaddressinfo");
free_json(retjson);
free(retjson);
return(bitcoind_passthru(coin->symbol,coin->chain->serverport,coin->chain->userpass,coin->validateaddress,buf));
}
free_json(retjson);
}
usleep(10000);
}
else if ( coin->FULLNODE > 0 || coin->VALIDATENODE > 0 )

1
iguana/elected

@ -7,6 +7,7 @@
"37.9.62.186",
"145.239.204.33",
"185.169.229.64",
"164.132.202.176",
"163.172.100.144",
"139.60.161.30",
"209.58.190.117",

2
iguana/exchanges/LP_rpc.c

@ -348,7 +348,7 @@ cJSON *LP_validateaddress(char *symbol,char *address)
strcpy(coin->validateaddress,"validateaddress");
if ( (retjson= bitcoin_json(coin,coin->validateaddress,buf)) != 0 )
{
if ( jobj(retjson,"error") == 0 && jobj(retjson,"ismine") == 0 && strcmp(coin->validateaddress,"validateaddress") == 0 )
if ( strcmp(coin->symbol,"BTC") == 0 && jobj(retjson,"error") == 0 && jobj(retjson,"ismine") == 0 && strcmp(coin->validateaddress,"validateaddress") == 0 )
{
printf("autochange %s validateaddress -> getaddressinfo\n",coin->symbol);
strcpy(coin->validateaddress,"getaddressinfo");

2
iguana/iguana777.c

@ -49,6 +49,8 @@ struct iguana_info *iguana_coinadd(char *symbol,char *name,cJSON *argjson,int32_
myinfo->allcoins_being_added = 1;
coin = mycalloc('C',1,sizeof(*coin));
strcpy(coin->getinfostr,"getinfo");
strcpy(coin->validateaddress,"validateaddress");
strcpy(coin->estimatefeestr,"estimatefee");
coin->blockspacesize = IGUANA_MAXPACKETSIZE + 8192;
coin->blockspace = calloc(1,coin->blockspacesize);
if ( virtcoin != 0 || ((privatechain= jstr(argjson,"geckochain")) != 0 && privatechain[0] != 0) )

2
iguana/iguana777.h

@ -180,7 +180,7 @@ struct supernet_info
#ifdef NOTARY_TESTMODE
char dexseed_ipaddrs[1][64];
#else
char dexseed_ipaddrs[4][64];
char dexseed_ipaddrs[8][64];
#endif
uint32_t dexipbits[128]; int32_t numdexipbits; portable_mutex_t dexmutex;
// compatibility

40
iguana/iguana_notary.c

@ -148,6 +148,8 @@ void dpow_srcupdate(struct supernet_info *myinfo,struct dpow_info *dp,int32_t he
{
if ( (i % DPOW_MAXFREQ) != 0 && (bp= dp->blocks[i]) != 0 && bp->state == 0xffffffff )
{
if ( dp->currentbp == dp->blocks[i] )
dp->currentbp = 0;
dp->blocks[i] = 0;
Numallocated--;
free(bp);
@ -857,9 +859,14 @@ STRING_AND_INT(dpow,fundnotaries,symbol,numblocks)
return(clonestr("{\"result\":\"success\"}"));
}
extern char *Notaries_elected[65][2];
cJSON *dpow_recvmasks(struct supernet_info *myinfo,struct dpow_info *dp,struct dpow_block *bp);
STRING_ARG(dpow,active,maskhex)
{
uint8_t data[8],revdata[8],pubkeys[64][33]; char pubkeystr[67]; int32_t i,len,current,n; uint64_t mask; cJSON *infojson,*retjson,*array = cJSON_CreateArray();
uint8_t data[8],revdata[8],pubkeys[64][33]; int32_t i,len,current,n; uint64_t mask; cJSON *infojson,*retjson,*array,*notarray;
array = cJSON_CreateArray();
notarray = cJSON_CreateArray();
if ( (infojson= dpow_getinfo(myinfo,coin)) != 0 )
{
current = jint(infojson,"blocks");
@ -868,22 +875,24 @@ STRING_ARG(dpow,active,maskhex)
n = komodo_notaries("KMD",pubkeys,current);
if ( maskhex == 0 || maskhex[0] == 0 )
{
mask = myinfo->DPOWS[0]->lastrecvmask;
return(jprint(dpow_recvmasks(myinfo,myinfo->DPOWS[0],myinfo->DPOWS[0]->currentbp),1));
/*mask = myinfo->DPOWS[0]->lastrecvmask;
for (i=0; i<n; i++)
{
if ( ((1LL << i) & mask) != 0 )
{
init_hexbytes_noT(pubkeystr,pubkeys[i],33);
printf("(%d %llx %s) ",i,(long long)(1LL << i),pubkeystr);
//printf("(%d %llx %s) ",i,(long long)(1LL << i),pubkeystr);
jaddistr(array,pubkeystr);
}
}
retjson = cJSON_CreateObject();
jadd64bits(retjson,"recvmask",mask);
jadd(retjson,"notaries",array);
return(jprint(retjson,1));
return(jprint(retjson,1));*/
}
printf("dpow active (%s)\n",maskhex);
//printf("dpow active (%s)\n",maskhex);
if ( (len= (int32_t)strlen(maskhex)) <= 16 )
{
len >>= 1;
@ -893,17 +902,24 @@ STRING_ARG(dpow,active,maskhex)
revdata[i] = data[len-1-i];
mask = 0;
memcpy(&mask,revdata,sizeof(revdata));
for (i=0; i<len; i++)
printf("%02x",data[i]);
printf(" <- hex mask.%llx\n",(long long)mask);
//for (i=0; i<len; i++)
// printf("%02x",data[i]);
//printf(" <- hex mask.%llx\n",(long long)mask);
for (i=0; i<(len<<3); i++)
{
if ( ((1LL << i) & mask) != 0 )
{
init_hexbytes_noT(pubkeystr,pubkeys[i],33);
printf("(%d %llx %s) ",i,(long long)(1LL << i),pubkeystr);
jaddistr(array,pubkeystr);
//init_hexbytes_noT(pubkeystr,pubkeys[i],33);
//printf("(%d %llx %s) ",i,(long long)(1LL << i),pubkeystr);
jaddistr(array,Notaries_elected[i][0]);
}
return(jprint(array,1));
else jaddistr(notarray,Notaries_elected[i][0]);
}
retjson = cJSON_CreateObject();
jaddstr(retjson,"maskhex",maskhex);
jadd(retjson,"set",array);
jadd(retjson,"not",notarray);
return(jprint(retjson,1));
} else return(clonestr("{\"error\":\"maskhex too long\"}"));
}

2
iguana/tests/active

@ -0,0 +1,2 @@
#!/bin/bash
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"dpow\",\"method\":\"active\",\"maskhex\":\"7fc27f67df27e619\"}"

2
includes/iguana_structs.h

@ -528,7 +528,7 @@ struct iguana_info
#ifdef DEPRECATED_HHUTXO
struct iguana_hhaccount *accountstable;
#endif
char lastdispstr[2048],getinfostr[64];
char lastdispstr[2048],getinfostr[64],validateaddress[64],estimatefeestr[64];
double txidfind_totalmillis,txidfind_num,spendtxid_totalmillis,spendtxid_num;
struct iguana_monitorinfo monitoring[256];
int32_t notarychain,didaddresses;

Loading…
Cancel
Save