Browse Source

Merge branch 'dev' of https://github.com/jl777/SuperNET into etomic

pass-iguana-arg
Artem Pikulin 7 years ago
parent
commit
d3256087a3
  1. 2
      basilisk/basilisk_bitcoin.c
  2. 9
      crypto777/bitcoind_RPC.c
  3. 6
      iguana/SuperNET_keys.c
  4. 2
      iguana/acsplit
  5. 15
      iguana/dPoW.h
  6. 5
      iguana/dpow/dpow_fsm.c
  7. 186
      iguana/dpow/dpow_network.c
  8. 18
      iguana/dpow/dpow_rpc.c
  9. 9
      iguana/dpow/dpow_tx.c
  10. 3
      iguana/elected
  11. 8
      iguana/exchanges/LP_commands.c
  12. 4
      iguana/exchanges/LP_ordermatch.c
  13. 8
      iguana/exchanges/LP_remember.c
  14. 2
      iguana/exchanges/coins
  15. 2
      iguana/exchanges/kickstart
  16. 2
      iguana/exchanges/prices/autoprice
  17. 2
      iguana/exchanges/supernet
  18. 2
      iguana/iguana777.c
  19. 2
      iguana/iguana777.h
  20. 54
      iguana/iguana_notary.c
  21. 2
      iguana/iguana_wallet.c
  22. 5
      iguana/m_notary_run
  23. 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 )

9
crypto777/bitcoind_RPC.c

@ -80,13 +80,13 @@ char *post_process_bitcoind_RPC(char *debugstr,char *command,char *rpcstr,char *
if ( command == 0 || rpcstr == 0 || rpcstr[0] == 0 )
{
if ( strcmp(command,"signrawtransaction") != 0 && strcmp(command,"getrawtransaction") != 0 )
printf("<<<<<<<<<<< A bitcoind_RPC: %s post_process_bitcoind_RPC.%s.[%s]\n",debugstr,command,params);
printf("<<<<<<<<<<< A bitcoind_RPC: %s post_process_bitcoind_RPC.%s\n",debugstr,command);
return(rpcstr);
}
json = cJSON_Parse(rpcstr);
if ( json == 0 )
{
printf("<<<<<<<<<<< B bitcoind_RPC: %s post_process_bitcoind_RPC.%s can't parse.(%s) params.(%s)\n",debugstr,command,rpcstr,params);
printf("<<<<<<<<<<< B bitcoind_RPC: %s post_process_bitcoind_RPC.%s can't parse.(%s)\n",debugstr,command,rpcstr);
free(rpcstr);
return(0);
}
@ -143,14 +143,15 @@ char *Jay_NXTrequest(char *command,char *params)
char *bitcoind_RPC(char **retstrp,char *debugstr,char *url,char *userpass,char *command,char *params,int32_t timeout)
{
static int didinit,count,count2; static double elapsedsum,elapsedsum2; extern int32_t USE_JAY;
CURL *curl_handle; static int didinit,count,count2; static double elapsedsum,elapsedsum2; extern int32_t USE_JAY;
struct MemoryStruct chunk;
struct curl_slist *headers = NULL; struct return_string s; CURLcode res; CURL *curl_handle;
struct curl_slist *headers = NULL; struct return_string s; CURLcode res;
char *bracket0,*bracket1,*retstr,*databuf = 0; long len; int32_t specialcase,numretries; double starttime;
if ( didinit == 0 )
{
didinit = 1;
curl_global_init(CURL_GLOBAL_ALL); //init the curl session
//curl_handle = curl_easy_init();
}
if ( (0) && (USE_JAY != 0 && (strncmp(url,"http://127.0.0.1:7876/nxt",strlen("http://127.0.0.1:7876/nxt")) == 0 || strncmp(url,"https://127.0.0.1:7876/nxt",strlen("https://127.0.0.1:7876/nxt")) == 0)) )
{

6
iguana/SuperNET_keys.c

@ -339,7 +339,7 @@ int32_t iguana_wifstr_valid(char *wifstr)
return(0);
if ( A > 5*a || a > 5*A || a > n*20 || A > n*20 ) // unlikely it is a real wif
{
printf("reject wif %s due to n.%d a.%d A.%d (%d %d %d %d)\n",wifstr,n,a,A,A > 5*a,a < 5*A,a > n*20,A > n*20);
//printf("reject wif %s due to n.%d a.%d A.%d (%d %d %d %d)\n",wifstr,n,a,A,A > 5*a,a < 5*A,a > n*20,A > n*20);
return(0);
}
bitcoin_wif2priv(&wiftype,&privkey,wifstr);
@ -355,9 +355,9 @@ int32_t iguana_wifstr_valid(char *wifstr)
bitcoin_priv2wiflong(cmpstr2,privkey,wiftype);
if ( bits256_cmp(privkey,cmpkey) == 0 )
return(1);
char str[65],str2[65]; printf("mismatched wifstr %s -> %s -> %s %s %s\n",wifstr,bits256_str(str,privkey),cmpstr,bits256_str(str2,cmpkey),cmpstr2);
// char str[65],str2[65]; printf("mismatched wifstr %s -> %s -> %s %s %s\n",wifstr,bits256_str(str,privkey),cmpstr,bits256_str(str2,cmpkey),cmpstr2);
}
char str[65]; printf("%s is not a wif, privkey.%s\n",wifstr,bits256_str(str,privkey));
//char str[65]; printf("%s is not a wif, privkey.%s\n",wifstr,bits256_str(str,privkey));
return(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}"}"

15
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))
@ -49,7 +49,7 @@
#define DPOW_MAXRELAYS 64
#define DPOW_MAXSIGLEN 128
#define DEX_VERSION 0x0105
#define DEX_VERSION 0x0106
#define DPOW_SOCKPORT 7775
#define DEX_SOCK 7774
#define PUB_SOCK 7773
@ -105,16 +105,19 @@ struct dpow_checkpoint
bits256 miner; uint32_t blocktime,timestamp;
};
struct dpow_recvdata { uint64_t recvmask,bestmask; int8_t bestk; };
struct dpow_block
{
bits256 hashmsg,desttxid,srctxid,beacon,commit,MoM;
struct iguana_info *srccoin,*destcoin; char *opret_symbol;
uint64_t destsigsmasks[DPOW_MAXRELAYS],srcsigsmasks[DPOW_MAXRELAYS];
uint64_t recvmask,bestmask,ratifybestmask,ratifyrecvmask,pendingbestmask,pendingratifybestmask,ratifysigmasks[2];
struct dpow_recvdata recv[64];
struct dpow_entry notaries[DPOW_MAXRELAYS];
uint32_t MoMdepth,state,starttime,timestamp,waiting,sigcrcs[2],txidcrcs[2],utxocrcs[2],lastepoch,paxwdcrc;
uint32_t MoMdepth,state,starttime,timestamp,waiting,sigcrcs[2],txidcrcs[2],utxocrcs[2],lastepoch,paxwdcrc,lastnanosend;
int32_t rawratifiedlens[2],height,numnotaries,numerrors,completed,minsigs,duration,numratified,isratify,require0,scores[DPOW_MAXRELAYS];
int8_t myind,bestk,ratifybestk,pendingbestk,pendingratifybestk;
int8_t myind,bestk,ratifybestk,pendingbestk,pendingratifybestk,matches,bestmatches;
cJSON *ratified;
uint8_t ratified_pubkeys[DPOW_MAXRELAYS][33],ratifysigs[2][DPOW_MAXSIGLEN],ratifysiglens[2];
char handles[DPOW_MAXRELAYS][32];
@ -138,11 +141,11 @@ struct dpow_info
struct dpow_hashheight approved[DPOW_FIFOSIZE],notarized[DPOW_FIFOSIZE];
bits256 activehash,lastnotarized,srctx[DPOW_MAXTX],desttx[DPOW_MAXTX];
uint32_t SRCREALTIME,lastsrcupdate,destupdated,srcconfirms,numdesttx,numsrctx,lastsplit,cancelratify;
int32_t lastheight,maxblocks,SRCHEIGHT,SHORTFLAG,ratifying,minsigs,freq;
int32_t lastheight,maxblocks,SRCHEIGHT,DESTHEIGHT,prevDESTHEIGHT,SHORTFLAG,ratifying,minsigs,freq;
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; };

5
iguana/dpow/dpow_fsm.c

@ -305,6 +305,8 @@ void dpow_statemachinestart(void *ptr)
bp->srccoin = src;
bp->destcoin = dest;
bp->myind = -1;
for (i=0; i<sizeof(bp->notaries)/sizeof(*bp->notaries); i++)
bp->notaries[i].bestk = -1;
bp->opret_symbol = dp->symbol;
if ( jsonstr != 0 && (ratified= cJSON_Parse(jsonstr)) != 0 )
{
@ -358,8 +360,9 @@ void dpow_statemachinestart(void *ptr)
}
free_json(ratified);
}
bp->bestk = -1;
bp->pendingbestk = 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));
}

186
iguana/dpow/dpow_network.c

@ -16,6 +16,7 @@
extern uint16_t Notaries_port;
extern int32_t Notaries_numseeds;
extern char *Notaries_seeds[];
extern char *Notaries_elected[65][2];
struct signed_nnpacket
{
@ -80,10 +81,22 @@ int32_t signed_nn_send(struct supernet_info *myinfo,void *ctx,bits256 privkey,in
//printf(" signed pubkey\n");
if ( memcmp(pubkey33,signpubkey33,33) == 0 )
{
sentbytes = nn_send(sock,sigpacket,size + sizeof(*sigpacket),0);
sentbytes = 0;
for (j=0; j<100; j++)
{
struct nn_pollfd pfd;
pfd.fd = sock;
pfd.events = NN_POLLOUT;
if ( nn_poll(&pfd,1,10) > 0 )
{
sentbytes = nn_send(sock,sigpacket,size + sizeof(*sigpacket),0);
break;
}
usleep(1000);
}
//for (i=0; i<size+sizeof(*sigpacket); i++)
// printf("%02x",((uint8_t *)sigpacket)[i]);
//printf(" <- nnsend\n");
//printf(" <- nnsend.%d\n",sock);
free(sigpacket);
return(sentbytes - siglen);
}
@ -1449,13 +1462,34 @@ void dpow_nanomsginit(struct supernet_info *myinfo,char *ipaddr)
dpow_addnotary(myinfo,0,ipaddr);
}
void dpow_bestconsensus(struct dpow_block *bp)
void dpow_bestconsensus(struct dpow_info *dp,struct dpow_block *bp)
{
int8_t bestks[64]; int32_t counts[64],i,j,numcrcs=0,numdiff,besti,best,bestmatches = 0,matches = 0; uint64_t masks[64],matchesmask,recvmask; uint32_t crcval=0; char srcaddr[64],destaddr[64];
int8_t bestks[64]; uint32_t sortbuf[64],wts[64],owts[64],counts[64]; int32_t i,j,median,numcrcs=0,numdiff,besti,bestmatches = 0,matches = 0; uint64_t masks[64],matchesmask,recvmask,topmask; uint32_t crcval=0; char srcaddr[64],destaddr[64];
memset(wts,0,sizeof(wts));
memset(owts,0,sizeof(owts));
for (i=0; i<bp->numnotaries; i++)
{
recvmask = bp->notaries[i].recvmask;
wts[i] = bitweight(recvmask);
for (j=0; j<bp->numnotaries; j++)
if ( ((1LL << j) & recvmask) != 0 )
owts[j]++;
}
topmask = 0xffffffffffffffffLL;
recvmask = 0;
for (i=0; i<bp->numnotaries; i++)
sortbuf[i] = (wts[i] * owts[i]);
revsort32(sortbuf,bp->numnotaries,sizeof(*sortbuf));
median = sortbuf[bp->numnotaries / 2];
if ( ((bp->height / dp->freq) % 10) == 0 )
{
for (i=0; i<bp->numnotaries; i++)
if ( wts[i]*owts[i] < median )
topmask &= ~(1LL << i);
}
memset(masks,0,sizeof(masks));
memset(bestks,0xff,sizeof(bestks));
memset(counts,0,sizeof(counts));
recvmask = 0;
for (numdiff=i=0; i<bp->numnotaries; i++)
{
if ( bits256_nonz(bp->notaries[i].src.prev_hash) != 0 && bits256_nonz(bp->notaries[i].dest.prev_hash) != 0 )
@ -1465,7 +1499,7 @@ void dpow_bestconsensus(struct dpow_block *bp)
//if ( bp->require0 != 0 && (bp->notaries[i].bestmask & 1) == 0 )
// continue;
for (j=0; j<numdiff; j++)
if ( bp->notaries[i].bestk == bestks[j] && bp->notaries[i].bestmask == masks[j] )
if ( bp->notaries[i].bestk == bestks[j] && bp->notaries[i].bestmask == masks[j] && bitweight(bp->notaries[i].bestmask) == bp->minsigs )
{
counts[j]++;
break;
@ -1479,27 +1513,46 @@ void dpow_bestconsensus(struct dpow_block *bp)
numdiff++;
}
}
besti = -1, best = 0;
besti = -1, matches = 0;
for (i=0; i<numdiff; i++)
{
//printf("(%d %llx).%d ",bestks[i],(long long)masks[i],counts[i]);
if ( counts[i] > best && bitweight(masks[i]) >= bp->minsigs )
if ( counts[i] > matches && bitweight(masks[i]) == bp->minsigs )
{
best = counts[i];
matches = counts[i];
besti = i;
}
}
if ( besti >= 0 && bestks[besti] >= 0 && masks[besti] != 0 && (recvmask & masks[besti]) == masks[besti] )
for (i=0; i<bp->numnotaries; i++)
{
if ( ((1LL << i) & masks[besti]) != 0 )
{
if ( bp->notaries[i].bestmask == masks[besti] )
bestmatches++;
}
}
if ( (bestmatches > bp->bestmatches || (bestmatches == bp->bestmatches && matches > bp->matches)) && besti >= 0 && bestks[besti] >= 0 && masks[besti] != 0 && (recvmask & masks[besti]) == masks[besti] )
{
bp->matches = matches;
bp->bestmatches = bestmatches;
bp->notaries[bp->myind].bestmask = bp->bestmask = masks[besti];
bp->notaries[bp->myind].bestk = bp->bestk = bestks[besti];
//printf("set best.%d to (%d %llx) recv.%llx\n",best,bp->bestk,(long long)bp->bestmask,(long long)recvmask);
if ( bp->myind == 0 )
{
for (i=0; i<bp->numnotaries; i++)
printf("%d:%d%s ",wts[i],owts[i],wts[i]*owts[i]>median?"*":"");
printf("median.%d %s.%d set matches.%d best.%d to (%d %llx) recv.%llx topmask.%llx\n",sortbuf[bp->numnotaries/2],dp->symbol,bp->height,bp->matches,bp->bestmatches,bp->bestk,(long long)bp->bestmask,(long long)recvmask,(long long)topmask);
for (i=0; i<bp->numnotaries; i++)
if ( wts[i] == 0 || owts[i] == 0 )
printf("%s.%d:%d ",Notaries_elected[i][0],wts[i],owts[i]);
printf(" <- problem nodes.%s\n",dp->symbol);
}
}
bp->recvmask |= recvmask;
if ( bp->bestmask == 0 )//|| (time(NULL) / 180) != bp->lastepoch )
{
bp->bestmask = dpow_notarybestk(bp->recvmask,bp,&bp->bestk);
if ( 0 && (time(NULL) / 180) != bp->lastepoch )
if ( 0 && (time(NULL) / 180) != bp->lastepoch ) // diverges too fast
{
bp->lastepoch = (uint32_t)(time(NULL) / 180);
printf("epoch %u\n",bp->lastepoch % bp->numnotaries);
@ -1575,7 +1628,7 @@ void dpow_nanoutxoset(struct supernet_info *myinfo,struct dpow_info *dp,struct d
}
else
{
dpow_bestconsensus(bp);
dpow_bestconsensus(dp,bp);
np->srcutxo = bp->notaries[bp->myind].src.prev_hash;
np->srcvout = bp->notaries[bp->myind].src.prev_vout;
np->destutxo = bp->notaries[bp->myind].dest.prev_hash;
@ -1715,7 +1768,7 @@ void dpow_ratify_update(struct supernet_info *myinfo,struct dpow_info *dp,struct
}
}
//printf("crcval.%x numcrcs.%d bestmatches.%d matchesmask.%llx\n",crcval,numcrcs,bestmatches,(long long)matchesmask);
if ( bestmatches >= bp->minsigs )//&& numcrcs >= bp->minsigs )
if ( bestmatches == bp->minsigs )//&& numcrcs == bp->minsigs )
{
if ( bp->pendingratifybestk != bp->ratifybestk || bp->pendingratifybestmask != bp->ratifybestmask )
{
@ -1778,9 +1831,29 @@ 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; 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);
sprintf(hexstr,"%16llx",(long long)bp->notaries[i].recvmask);
jaddstr(item,"recvmask",hexstr);
sprintf(hexstr,"%16llx",(long long)bp->notaries[i].bestmask);
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;
bits256 srchash; uint32_t now; int32_t i,flag,bestmatches = 0,matches = 0,paxmatches = 0,paxbestmatches = 0;
if ( bp->myind < 0 )
return;
if ( bp->isratify == 0 && bp->state != 0xffffffff && senderind >= 0 && senderind < bp->numnotaries && bits256_nonz(srcutxo) != 0 && bits256_nonz(destutxo) != 0 )
@ -1803,8 +1876,9 @@ void dpow_notarize_update(struct supernet_info *myinfo,struct dpow_info *dp,stru
{
//fprintf(stderr,"{%d %x} ",senderind,paxwdcrc);
}
if ( (bp->notaries[senderind].bestk= bestk) >= 0 )
if ( bestk >= 0 || bp->notaries[senderind].bestk < 0 )
{
bp->notaries[senderind].bestk = bestk;
if ( (bp->notaries[senderind].src.siglens[bestk]= siglens[0]) != 0 )
{
memcpy(bp->notaries[senderind].src.sigs[bestk],sigs[0],siglens[0]);
@ -1826,7 +1900,7 @@ void dpow_notarize_update(struct supernet_info *myinfo,struct dpow_info *dp,stru
bp->recvmask |= (1LL << senderind) | (1LL << bp->myind);
bp->bestmask = dpow_maskmin(bp->recvmask,bp,&bp->bestk);
}
dpow_bestconsensus(bp);
dpow_bestconsensus(dp,bp);
if ( bp->bestk >= 0 )
bp->notaries[bp->myind].bestk = bp->bestk;
if ( bp->bestmask != 0 )
@ -1836,6 +1910,7 @@ void dpow_notarize_update(struct supernet_info *myinfo,struct dpow_info *dp,stru
if ( bp->bestk >= 0 )
{
flag = -1;
now = (uint32_t)time(NULL);
for (i=0; i<bp->numnotaries; i++)
{
if ( bp->paxwdcrc == bp->notaries[i].paxwdcrc )
@ -1852,38 +1927,42 @@ void dpow_notarize_update(struct supernet_info *myinfo,struct dpow_info *dp,stru
} //else printf("?%x ",bp->notaries[i].paxwdcrc);
}
}
else if ( i == senderind && ((1LL << bp->myind) & bp->bestmask) != 0 && ((1LL << i) & bp->bestmask) != 0 && ((1LL << bp->myind) & bp->notaries[i].recvmask) == 0 )
flag = senderind;
else if ( i != bp->myind && i == senderind && ((1LL << bp->myind) & bp->bestmask) != 0 && ((1LL << i) & bp->bestmask) != 0 && ((1LL << bp->myind) & bp->notaries[i].recvmask) == 0 )
{
if ( now > bp->lastnanosend+1 )
flag = senderind;
}
if ( 0 && bp->myind <= 1 && bp->notaries[i].paxwdcrc != 0 )
printf("%d.(%x %d %llx r%llx) ",i,bp->notaries[i].paxwdcrc,bp->notaries[i].bestk,(long long)bp->notaries[i].bestmask,(long long)bp->notaries[i].recvmask);
}
if ( flag >= 0 )
if ( flag >= 0 || now > bp->lastnanosend+13 )
{
//printf("flag.%d -> send\n",flag);
for (i=0; i<sizeof(srchash); i++)
srchash.bytes[i] = dp->minerkey33[i+1];
dpow_send(myinfo,dp,bp,srchash,bp->hashmsg,0,bp->height,(void *)"ping",0);
bp->lastnanosend = now;
}
if ( 0 && bp->myind <= 1 )
printf("recv.%llx best.(%d %llx) m.%d p.%d:%d b.%d\n",(long long)bp->recvmask,bp->bestk,(long long)bp->bestmask,matches,paxmatches,paxbestmatches,bestmatches);
if ( bestmatches >= bp->minsigs && paxbestmatches >= bp->minsigs )
if ( bestmatches == bp->minsigs && paxbestmatches == bp->minsigs && bp->bestk >= 0 && bp->bestmask != 0 )
{
if ( bp->pendingbestk != bp->bestk || bp->pendingbestmask != bp->bestmask )
if ( bp->pendingbestk < 0 )//bp->pendingbestk != bp->bestk || bp->pendingbestmask != bp->bestmask )
{
printf("new PENDING BESTK (%d %llx) state.%d\n",bp->bestk,(long long)bp->bestmask,bp->state);
bp->pendingbestk = bp->bestk;
bp->pendingbestmask = bp->bestmask;
dpow_signedtxgen(myinfo,dp,bp->destcoin,bp,bp->bestk,bp->bestmask,bp->myind,DPOW_SIGBTCCHANNEL,1,0);
dpow_signedtxgen(myinfo,dp,bp->destcoin,bp,bp->pendingbestk,bp->pendingbestmask,bp->myind,DPOW_SIGBTCCHANNEL,1,0);
//printf("finished signing\n");
}
if ( bp->destsigsmasks[bp->bestk] == bp->bestmask ) // have all sigs
if ( bp->destsigsmasks[bp->pendingbestk] == bp->pendingbestmask ) // have all sigs
{
if ( bp->state < 1000 )
dpow_sigscheck(myinfo,dp,bp,bp->myind,1,bp->bestk,bp->bestmask,0,0);
if ( bp->srcsigsmasks[bp->bestk] == bp->bestmask ) // have all sigs
dpow_sigscheck(myinfo,dp,bp,bp->myind,1,bp->pendingbestk,bp->pendingbestmask,0,0);
if ( bp->srcsigsmasks[bp->pendingbestk] == bp->pendingbestmask ) // have all sigs
{
if ( bp->state != 0xffffffff )
dpow_sigscheck(myinfo,dp,bp,bp->myind,0,bp->bestk,bp->bestmask,0,0);
dpow_sigscheck(myinfo,dp,bp,bp->myind,0,bp->pendingbestk,bp->pendingbestmask,0,0);
} //else printf("srcmask.%llx != bestmask.%llx\n",(long long)bp->srcsigsmasks[bp->bestk],(long long)bp->bestmask);
} //else printf("destmask.%llx != bestmask.%llx\n",(long long)bp->destsigsmasks[bp->bestk],(long long)bp->bestmask);
}
@ -1914,20 +1993,46 @@ void dpow_nanoutxoget(struct supernet_info *myinfo,struct dpow_info *dp,struct d
}
else
{
int32_t i,bestmatches=0,matches = 0,dispflag = 0;
dpow_notarize_update(myinfo,dp,bp,senderind,(int8_t)np->bestk,np->bestmask,np->recvmask,np->srcutxo,np->srcvout,np->destutxo,np->destvout,np->siglens,np->sigs,np->paxwdcrc);
if ( 0 && bp->myind <= 2 )
printf("lag.[%d] RECV.%d r%llx (%d %llx) %llx/%llx\n",(int32_t)(time(NULL)-channel),senderind,(long long)np->recvmask,(int8_t)np->bestk,(long long)np->bestmask,(long long)np->srcutxo.txid,(long long)np->destutxo.txid);
if ( np->bestk >= 0 )
{
if ( bp->recv[senderind].recvmask != np->recvmask || bp->recv[senderind].bestk != np->bestk || bp->recv[senderind].bestmask != np->bestmask )
dispflag = 1;
bp->recv[senderind].recvmask = np->recvmask;
bp->recv[senderind].bestk = np->bestk;
bp->recv[senderind].bestmask = np->bestmask;
for (i=0; i<bp->numnotaries; i++)
{
if ( bp->recv[i].recvmask == np->recvmask && bp->recv[i].bestmask == np->bestmask && bp->recv[i].bestk == np->bestk )
{
matches++;
if ( ((1LL << i) & np->bestmask) != 0 )
bestmatches++;
}
}
}
if ( 0 && bp->myind == 0 && dispflag != 0 )
{
printf("%s.%d RECV.%-2d %llx (%2d %llx) %llx/%llx matches.%-2d best.%-2d %s\n",dp->symbol,bp->height,senderind,(long long)np->recvmask,(int8_t)np->bestk,(long long)np->bestmask,(long long)np->srcutxo.txid,(long long)np->destutxo.txid,matches,bestmatches,Notaries_elected[senderind][0]);
}
}
//dpow_bestmask_update(myinfo,dp,bp,nn_senderind,nn_bestk,nn_bestmask,nn_recvmask);
}
void dpow_send(struct supernet_info *myinfo,struct dpow_info *dp,struct dpow_block *bp,bits256 srchash,bits256 desthash,uint32_t channel,uint32_t msgbits,uint8_t *data,int32_t datalen)
{
struct dpow_nanomsghdr *np; int32_t i,src_or_dest,size,extralen=0,sentbytes = 0; uint32_t crc32,paxwdcrc; uint8_t extras[10000];
struct dpow_nanomsghdr *np; int32_t i,maxiters,src_or_dest,size,extralen=0,sentbytes = 0; uint32_t crc32,paxwdcrc; uint8_t extras[10000];
if ( bp->myind < 0 )
{
printf("bp->myind.%d error\n",bp->myind);
return;
}
if ( time(NULL) < myinfo->nanoinit+5 )
{
printf("dpow_send waiting for init\n");
return;
}
crc32 = calc_crc32(0,data,datalen);
//dp->crcs[firstz] = crc32;
size = (int32_t)(sizeof(*np) + datalen);
@ -1949,7 +2054,7 @@ void dpow_send(struct supernet_info *myinfo,struct dpow_info *dp,struct dpow_blo
else src_or_dest = 1;
extralen = dpow_paxpending(extras,sizeof(extras),&paxwdcrc,bp->MoM,bp->MoMdepth,src_or_dest,bp);
bp->paxwdcrc = bp->notaries[bp->myind].paxwdcrc = np->notarize.paxwdcrc = paxwdcrc;
//dpow_bestconsensus(bp);
//dpow_bestconsensus(dp,bp);
dpow_nanoutxoset(myinfo,dp,&np->notarize,bp,0);
}
else
@ -1974,22 +2079,25 @@ void dpow_send(struct supernet_info *myinfo,struct dpow_info *dp,struct dpow_blo
memcpy(np->packet,data,datalen);
sentbytes = -1;
// deadlocks! portable_mutex_lock(&myinfo->dpowmutex);
for (i=0; i<100; i++)
maxiters = 100;
for (i=0; i<maxiters; i++)
{
struct nn_pollfd pfd;
pfd.fd = myinfo->dpowsock;
pfd.events = NN_POLLOUT;
if ( nn_poll(&pfd,1,100) > 0 )
if ( nn_poll(&pfd,1,10) > 0 )
{
sentbytes = signed_nn_send(myinfo,myinfo->ctx,myinfo->persistent_priv,myinfo->dpowsock,np,size);
break;
}
usleep(1000);
}
if ( i == maxiters )
printf("maxiters expired for signed_nn_send dpowsock.%d\n",myinfo->dpowsock);
//portable_mutex_unlock(&myinfo->dpowmutex);
free(np);
if ( 0 && bp->myind <= 2 )
printf("%d NANOSEND.%d ht.%d channel.%08x (%d) pax.%08x datalen.%d (%d %llx) (%d %llx) recv.%llx\n",i,sentbytes,np->height,np->channel,size,np->notarize.paxwdcrc,datalen,(int8_t)np->notarize.bestk,(long long)np->notarize.bestmask,bp->notaries[bp->myind].bestk,(long long)bp->notaries[bp->myind].bestmask,(long long)bp->recvmask);
if ( 0 && bp->myind == 0 )
printf("%d NANOSEND.%d %s.%d channel.%08x (%d) pax.%08x datalen.%d (%d %llx) (%d %llx) recv.%llx\n",i,sentbytes,dp->symbol,np->height,np->channel,size,np->notarize.paxwdcrc,datalen,(int8_t)np->notarize.bestk,(long long)np->notarize.bestmask,bp->notaries[bp->myind].bestk,(long long)bp->notaries[bp->myind].bestmask,(long long)bp->recvmask);
}
void dpow_ipbitsadd(struct supernet_info *myinfo,struct dpow_info *dp,uint32_t *ipbits,int32_t numipbits,int32_t maxipbits,int32_t fromid,uint32_t senderipbits)
@ -2102,7 +2210,7 @@ int32_t dpow_nanomsg_update(struct supernet_info *myinfo)
} else flags |= 1;
if ( freeptr != 0 )
nn_freemsg(freeptr), np = 0, freeptr = 0;
if ( 0 && myinfo->dexsock >= 0 ) // from servers
/*if ( 0 && myinfo->dexsock >= 0 ) // from servers
{
freeptr = 0;
if ( (flags & 2) == 0 && (size= signed_nn_recv(&freeptr,myinfo,myinfo->notaries,myinfo->numnotaries,myinfo->dexsock,&dexp)) > 0 )
@ -2119,8 +2227,8 @@ int32_t dpow_nanomsg_update(struct supernet_info *myinfo)
} else flags |= 2;
if ( freeptr != 0 )
nn_freemsg(freeptr), dexp = 0, freeptr = 0;
}
if ( 0 && myinfo->repsock >= 0 ) // from clients
}*/
/*if ( 0 && myinfo->repsock >= 0 ) // from clients
{
dexp = 0;
if ( (flags & 4) == 0 && (size= nn_recv(myinfo->repsock,&dexp,NN_MSG,0)) > 0 )
@ -2163,7 +2271,7 @@ int32_t dpow_nanomsg_update(struct supernet_info *myinfo)
} else flags |= 4;
if ( dexp != 0 )
nn_freemsg(dexp), dexp = 0;
}
}*/
if ( (num + n + num2) != lastval )
{
//printf("lastval.%d: num.%d n.%d num2.%d rep packets\n",lastval,num,n,num2);

18
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 )
@ -596,7 +608,7 @@ char *dpow_signrawtransaction(struct supernet_info *myinfo,struct iguana_info *c
}
}
retstr = bitcoinrpc_signrawtransaction(myinfo,coin,0,0,rawtx,vins,privkeys,"ALL");
printf("call sign.(%s) vins.(%s) privs.(%s) -> (%s)\n",rawtx,jprint(vins,0),jprint(privkeys,0),retstr);
//printf("call sign.(%s) vins.(%s) privs.(%s) -> (%s)\n",rawtx,jprint(vins,0),jprint(privkeys,0),retstr);
free_json(privkeys);
return(retstr);
}

9
iguana/dpow/dpow_tx.c

@ -54,7 +54,7 @@ uint64_t dpow_lastk_mask(struct dpow_block *bp,int8_t *lastkp)
{
bp->recvmask |= (1LL << k);
mask |= (1LL << k);
if ( ++m >= bp->minsigs )
if ( ++m == bp->minsigs )
{
*lastkp = k;
break;
@ -101,9 +101,8 @@ uint64_t dpow_ratifybest(uint64_t refmask,struct dpow_block *bp,int8_t *lastkp)
uint64_t dpow_notarybestk(uint64_t refmask,struct dpow_block *bp,int8_t *lastkp)
{
int32_t m,j,k; uint64_t bestmask,mask = 0;//bp->require0;
int32_t m,j,k; int8_t bestk = -1; uint64_t bestmask,mask = 0;//bp->require0;
bestmask = 0;
*lastkp = -1;
for (m=j=0; j<bp->numnotaries; j++)
{
//k = (j + ((uint32_t)time(NULL) / 180)) % bp->numnotaries;
@ -115,12 +114,14 @@ uint64_t dpow_notarybestk(uint64_t refmask,struct dpow_block *bp,int8_t *lastkp)
mask |= (1LL << k);
if ( ++m == bp->minsigs )//-bp->require0 )
{
*lastkp = k;
bestk = k;
bestmask = mask;// | bp->require0;
//printf("m.%d == minsigs.%d (%d %llx)\n",m,bp->minsigs,k,(long long)bestmask);
}
}
}
if ( bestk >= 0 )
*lastkp = bestk;
return(bestmask);
}

3
iguana/elected

@ -1,12 +1,13 @@
{
"port": 17775,
"BTCminsigs": 14,
"BTCminsigs": 13,
"minsigs": 13,
"seeds": [
"78.47.196.146",
"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",

8
iguana/exchanges/LP_commands.c

@ -127,6 +127,7 @@ swapstatus(coin, limit=10)\n\
swapstatus(base, rel, limit=10)\n\
swapstatus(requestid, quoteid, pending=0, fast=0)\n\
recentswaps(limit=3)\n\
kickstart(requestid, quoteid)\n\
notarizations(coin)\n\
public API:\n \
getcoins()\n\
@ -413,6 +414,13 @@ jpg(srcfile, destfile, power2=7, password, data="", required, ind=0)\n\
taddr = (jobj(argjson,"taddr") == 0) ? 0 : juint(argjson,"taddr");
return(LP_secretaddresses(ctx,jstr(argjson,"prefix"),jstr(argjson,"passphrase"),juint(argjson,"num"),taddr,pubtype));
}
else if ( strcmp(method,"kickstart") == 0 )
{
uint32_t requestid,quoteid;
if ( (requestid= juint(argjson,"requestid")) != 0 && (quoteid= juint(argjson,"quoteid")) != 0 )
return(LP_kickstart(requestid,quoteid));
else return(clonestr("{\"error\":\"kickstart needs requestid and quoteid\"}"));
}
else if ( strcmp(method,"swapstatus") == 0 )
{
uint32_t requestid,quoteid;

4
iguana/exchanges/LP_ordermatch.c

@ -770,9 +770,7 @@ char *LP_connectedalice(struct LP_quoteinfo *qp,char *pairstr) // alice
int32_t LP_aliceonly(char *symbol)
{
if ( strcmp(symbol,"GAME") == 0 )
return(1);
else return(0);
return(0);
}
int32_t LP_validSPV(char *symbol,char *coinaddr,bits256 txid,int32_t vout)

8
iguana/exchanges/LP_remember.c

@ -1687,6 +1687,14 @@ char *basilisk_swapentry(int32_t fastflag,uint32_t requestid,uint32_t quoteid,in
else return(clonestr("{\"error\":\"cant find requestid-quoteid\"}"));
}
char *LP_kickstart(uint32_t requestid,uint32_t quoteid)
{
char fname[512];
sprintf(fname,"%s/SWAPS/%u-%u.finished",GLOBAL_DBDIR,requestid,quoteid), OS_compatible_path(fname);
OS_portable_removefile(fname);
return(basilisk_swapentry(0,requestid,quoteid,1));
}
extern struct LP_quoteinfo LP_Alicequery;
extern uint32_t Alice_expiration;

2
iguana/exchanges/coins

File diff suppressed because one or more lines are too long

2
iguana/exchanges/kickstart

@ -1,3 +1,3 @@
#!/bin/bash
source userpass
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"electrum\",\"coin\":\"KMD\",\"ipaddr\":\"\",\"port\":0}"
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"kickstart\",\"requestid\":772275036,\"quoteid\":1846027555}"

2
iguana/exchanges/prices/autoprice

@ -39,7 +39,7 @@ sharkholdings="{\"coin\":\"iota\",\"balance\":1500000}, {\"coin\":\"komodo\",\"b
curl --url "http://127.0.0.1:7783" --data "{\"base\":\"MSHARK\",\"rel\":\"KMD\",\"fundvalue_bid\":\"NAV_KMD\",\"fundvalue_ask\":\"assetNAV_KMD\",\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"margin\":$margin,\"address\":\"RTu3JZZKLJTcfNwBa19dWRagEfQq49STqC\",\"holdings\":[$sharkholdings],\"divisor\":1400000}"
curl --url "http://127.0.0.1:7783" --data "{\"margin\":$margin,\"base\":\"SUPERNET\",\"rel\":\"KMD\",\"fundvalue_bid\":\"NAV_KMD\",\"fundvalue_ask\":\"NAV_KMD\",\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"address\":\"RRyyejME7LRTuvdziWsXkAbSW1fdiohGwK\",\"holdings\":[{\"coin\":\"iota\",\"balance\":11000000}, {\"coin\":\"stratis\",\"balance\":1300000}, {\"coin\":\"zcash\",\"balance\":0.10000}, {\"coin\":\"syscoin\",\"balance\":20000000}, {\"coin\":\"waves\",\"balance\":700000}, {\"coin\":\"bitcoin\",\"balance\":570}, {\"coin\":\"bitcoin-cash\",\"balance\":1500}, {\"coin\":\"heat-ledger\",\"balance\":2323851 }, {\"coin\":\"decred\",\"balance\":0.20000}, {\"coin\":\"vericoin\",\"balance\":2199368 }, {\"coin\":\"byteball\",\"balance\":4238}, {\"coin\":\"iocoin\",\"balance\":0.150000}, {\"coin\":\"quantum-resistant-ledger\",\"balance\":0.375000}, {\"coin\":\"chips\",\"balance\":2577006 }, {\"coin\":\"hush\",\"balance\":100000 }, {\"coin\":\"mobilego\",\"balance\":100000 }],\"divisor\":612529}"
curl --url "http://127.0.0.1:7783" --data "{\"margin\":$margin,\"base\":\"SUPERNET\",\"rel\":\"KMD\",\"fundvalue_bid\":\"NAV_KMD\",\"fundvalue_ask\":\"NAV_KMD\",\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"address\":\"RRyyejME7LRTuvdziWsXkAbSW1fdiohGwK\",\"holdings\":[{\"coin\":\"iota\",\"balance\":11000000}, {\"coin\":\"stratis\",\"balance\":1300000}, {\"coin\":\"zcash\",\"balance\":0.10000}, {\"coin\":\"syscoin\",\"balance\":20000000}, {\"coin\":\"waves\",\"balance\":700000}, {\"coin\":\"bitcoin\",\"balance\":570}, {\"coin\":\"bitcoin-cash\",\"balance\":1500}, {\"coin\":\"heat-ledger\",\"balance\":2323851 }, {\"coin\":\"decred\",\"balance\":0.20000}, {\"coin\":\"vericoin\",\"balance\":2199368 }, {\"coin\":\"byteball\",\"balance\":4238}, {\"coin\":\"iocoin\",\"balance\":0.150000}, {\"coin\":\"quantum-resistant-ledger\",\"balance\":0.375000}, {\"coin\":\"chips\",\"balance\":2577006 }, {\"coin\":\"hush\",\"balance\":100000 }, {\"coin\":\"mobilego\",\"balance\":100000 }, {\"coin\":\"utrum\",\"balance\":2100000}],\"divisor\":612529}"
curl --url "http://127.0.0.1:7783" --data "{\"margin\":$margin,\"base\":\"HODL\",\"rel\":\"KMD\",\"fundvalue_bid\":\"assetNAV_KMD\",\"fundvalue_ask\":\"assetNAV_KMD\",\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"address\":\"RNcUaMUEFLxVwtTo7rgruhwYanGk1jTkeU\",\"holdings\":[{\"coin\":\"siacoin\",\"balance\":185000000,\"comment\":\"using siafunds equal to million siacoin\"}],\"divisor\":10000000}"

2
iguana/exchanges/supernet

@ -15,5 +15,5 @@ echo supernet
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"balances\",\"address\":\"RRyyejME7LRTuvdziWsXkAbSW1fdiohGwK\"}"
echo supernet
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"fundvalue\",\"address\":\"RRyyejME7LRTuvdziWsXkAbSW1fdiohGwK\",\"holdings\":[{\"coin\":\"iota\",\"balance\":11000000}, {\"coin\":\"stratis\",\"balance\":1300000}, {\"coin\":\"zcash\",\"balance\":0.10000}, {\"coin\":\"syscoin\",\"balance\":20000000}, {\"coin\":\"waves\",\"balance\":700000}, {\"coin\":\"bitcoin\",\"balance\":570}, {\"coin\":\"bitcoin-cash\",\"balance\":1500}, {\"coin\":\"heat-ledger\",\"balance\":2323851 }, {\"coin\":\"decred\",\"balance\":0.20000}, {\"coin\":\"vericoin\",\"balance\":2199368 }, {\"coin\":\"byteball\",\"balance\":4238}, {\"coin\":\"iocoin\",\"balance\":0.150000}, {\"coin\":\"quantum-resistant-ledger\",\"balance\":0.375000}, {\"coin\":\"hush\",\"balance\":100000 }, {\"coin\":\"mobilego\",\"balance\":100000 }],\"divisor\":612529}"
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"fundvalue\",\"address\":\"RRyyejME7LRTuvdziWsXkAbSW1fdiohGwK\",\"holdings\":[{\"coin\":\"iota\",\"balance\":11000000}, {\"coin\":\"stratis\",\"balance\":1300000}, {\"coin\":\"zcash\",\"balance\":0.10000}, {\"coin\":\"syscoin\",\"balance\":20000000}, {\"coin\":\"waves\",\"balance\":700000}, {\"coin\":\"bitcoin\",\"balance\":570}, {\"coin\":\"bitcoin-cash\",\"balance\":1500}, {\"coin\":\"heat-ledger\",\"balance\":2323851 }, {\"coin\":\"decred\",\"balance\":0.20000}, {\"coin\":\"vericoin\",\"balance\":2199368 }, {\"coin\":\"byteball\",\"balance\":4238}, {\"coin\":\"iocoin\",\"balance\":0.150000}, {\"coin\":\"quantum-resistant-ledger\",\"balance\":0.375000}, {\"coin\":\"hush\",\"balance\":100000 }, {\"coin\":\"mobilego\",\"balance\":100000 }, {\"coin\":\"utrum\",\"balance\":2100000}],\"divisor\":612529}"

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

54
iguana/iguana_notary.c

@ -61,22 +61,18 @@ void dpow_checkpointset(struct supernet_info *myinfo,struct dpow_checkpoint *che
void dpow_srcupdate(struct supernet_info *myinfo,struct dpow_info *dp,int32_t height,bits256 hash,uint32_t timestamp,uint32_t blocktime)
{
//struct komodo_ccdataMoMoM mdata; cJSON *blockjson; uint64_t signedmask; struct iguana_info *coin;
void **ptrs; char str[65]; struct dpow_checkpoint checkpoint; int32_t i,ht; struct dpow_block *bp;
void **ptrs; char str[65]; struct dpow_checkpoint checkpoint; int32_t i,ht,suppress=0; struct dpow_block *bp;
dpow_checkpointset(myinfo,&dp->last,height,hash,timestamp,blocktime);
checkpoint = dp->srcfifo[dp->srcconfirms];
/*if ( strcmp("BTC",dp->dest) == 0 )
dpow_fifoupdate(myinfo,dp->srcfifo,dp->last);
if ( strcmp(dp->dest,"KMD") == 0 )
{
freq = DPOW_CHECKPOINTFREQ;
minsigs = Notaries_BTCminsigs; //DPOW_MINSIGS;
if ( dp->DESTHEIGHT < dp->prevDESTHEIGHT+DPOW_CHECKPOINTFREQ )
{
suppress = 1;
//fprintf(stderr,"suppress %s -> KMD\n",dp->symbol);
}
}
else
{
minsigs = Notaries_minsigs; //DPOW_MIN_ASSETCHAIN_SIGS;
if ( strcmp("CHIPS",dp->symbol) == 0 || strncmp("TEST",dp->symbol,4) == 0)
freq = DPOW_MAXFREQ;
else freq = 1;
}*/
dpow_fifoupdate(myinfo,dp->srcfifo,dp->last);
/*if ( strcmp(dp->dest,"KMD") == 0 )//|| strcmp(dp->dest,"CHAIN") == 0 )
{
//if ( dp->SRCREALTIME == 0 )
@ -121,11 +117,12 @@ void dpow_srcupdate(struct supernet_info *myinfo,struct dpow_info *dp,int32_t he
}*/
if ( dp->freq <= 0 )
dp->freq = 1;
if ( bits256_nonz(checkpoint.blockhash.hash) != 0 && (checkpoint.blockhash.height % dp->freq) == 0 )
if ( suppress == 0 && bits256_nonz(checkpoint.blockhash.hash) != 0 && (checkpoint.blockhash.height % dp->freq) == 0 )
{
if ( (0) && strcmp("KMD",dp->symbol) == 0 )
printf("%s/%s src ht.%d dest.%u nonz.%d %s minsigs.%d freq.%d\n",dp->symbol,dp->dest,checkpoint.blockhash.height,dp->destupdated,bits256_nonz(checkpoint.blockhash.hash),bits256_str(str,dp->last.blockhash.hash),dp->minsigs,dp->freq);
dpow_heightfind(myinfo,dp,checkpoint.blockhash.height + 1000);
dp->prevDESTHEIGHT = dp->DESTHEIGHT;
ptrs = calloc(1,sizeof(void *)*5 + sizeof(struct dpow_checkpoint) + sizeof(pthread_t));
ptrs[0] = (void *)myinfo;
ptrs[1] = (void *)dp;
@ -148,6 +145,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);
@ -194,6 +193,7 @@ void dpow_destconfirm(struct supernet_info *myinfo,struct dpow_info *dp,struct d
void dpow_destupdate(struct supernet_info *myinfo,struct dpow_info *dp,int32_t height,bits256 hash,uint32_t timestamp,uint32_t blocktime)
{
dp->destupdated = timestamp;
dp->DESTHEIGHT = height;
dpow_checkpointset(myinfo,&dp->destchaintip,height,hash,timestamp,blocktime);
dpow_approvedset(myinfo,dp,&dp->destchaintip,dp->desttx,dp->numdesttx);
dpow_fifoupdate(myinfo,dp->destfifo,dp->destchaintip);
@ -232,17 +232,18 @@ void iguana_dPoWupdate(struct supernet_info *myinfo,struct dpow_info *dp)
} else dpow_destupdate(myinfo,dp,height,blockhash,(uint32_t)time(NULL),blocktime);
} // else printf("error getchaintip for %s\n",dp->dest);
dp->numsrctx = sizeof(dp->srctx)/sizeof(*dp->srctx);
if ( (strcmp(dp->dest,"KMD") == 0 || strcmp(dp->dest,"CHAIN") == 0) && dp->SRCHEIGHT < src->longestchain )
/*if ( (strcmp(dp->dest,"KMD") == 0 || strcmp(dp->dest,"CHAIN") == 0) && dp->SRCHEIGHT < src->longestchain )
{
//fprintf(stderr,"[I ");
dp->SRCHEIGHT = dpow_issuer_iteration(dp,src,dp->SRCHEIGHT,&dp->SRCREALTIME);
//fprintf(stderr," %d] ",dp->SRCHEIGHT);
}
if ( (height= dpow_getchaintip(myinfo,&merkleroot,&blockhash,&blocktime,dp->srctx,&dp->numsrctx,src)) != dp->last.blockhash.height && height >= 0 )
}*/
if ( (height= dpow_getchaintip(myinfo,&merkleroot,&blockhash,&blocktime,dp->srctx,&dp->numsrctx,src)) != dp->last.blockhash.height && height > 0 )
{
//char str[65]; printf("[%s].%d %s %s height.%d vs last.%d\n",dp->dest,dp->SRCHEIGHT,dp->symbol,bits256_str(str,blockhash),height,dp->last.blockhash.height);
char str[65]; printf("[%s].%d %s %s height.%d vs last.%d\n",dp->dest,dp->SRCHEIGHT,dp->symbol,bits256_str(str,blockhash),height,dp->last.blockhash.height);
if ( dp->lastheight == 0 )
dp->lastheight = height-1;
dp->SRCHEIGHT = height;
if ( height < dp->last.blockhash.height )
{
printf("iguana_dPoWupdate src.%s reorg detected %d vs %d approved.%d notarized.%d\n",dp->symbol,height,dp->last.blockhash.height,dp->approved[0].height,dp->notarized[0].height);
@ -255,6 +256,7 @@ void iguana_dPoWupdate(struct supernet_info *myinfo,struct dpow_info *dp)
{
while ( dp->lastheight <= height )
{
printf("dp->lastheight.%d <= height.%d\n",dp->lastheight,height);
blockhash = dpow_getblockhash(myinfo,src,dp->lastheight);
dpow_srcupdate(myinfo,dp,dp->lastheight++,blockhash,(uint32_t)time(NULL),blocktime);
}
@ -334,9 +336,9 @@ THREE_STRINGS_AND_DOUBLE(iguana,dpow,symbol,dest,pubkey,freq)
return(clonestr("{\"error\":\"cant dPoW KMD without BTC\"}"));
else if ( iguana_coinfind(dest) == 0 )
return(clonestr("{\"error\":\"cant dPoW without KMD (dest)\"}"));
if ( myinfo->numdpows > 1 )
if ( myinfo->numdpows > 0 )
{
for (i=1; i<myinfo->numdpows; i++)
for (i=0; i<myinfo->numdpows; i++)
if ( strcmp(symbol,myinfo->DPOWS[i]->symbol) == 0 )
{
dp->symbol[0] = 0;
@ -366,9 +368,9 @@ THREE_STRINGS_AND_DOUBLE(iguana,dpow,symbol,dest,pubkey,freq)
dp->minsigs = Notaries_minsigs; //DPOW_MIN_ASSETCHAIN_SIGS;
if ( strcmp("CHIPS",dp->symbol) == 0 || strncmp("TEST",dp->symbol,4) == 0)
dp->freq = DPOW_MAXFREQ;
else if ( freq >= 2 )
else if ( freq > 2 )
dp->freq = freq;
else dp->freq = 1;
else dp->freq = 2;
}
src = iguana_coinfind(dp->symbol);
destcoin = iguana_coinfind(dp->dest);
@ -858,10 +860,11 @@ STRING_AND_INT(dpow,fundnotaries,symbol,numblocks)
}
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,*notarray;
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 )
@ -872,7 +875,9 @@ 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 )
@ -885,7 +890,7 @@ STRING_ARG(dpow,active,maskhex)
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);
if ( (len= (int32_t)strlen(maskhex)) <= 16 )
@ -911,6 +916,7 @@ STRING_ARG(dpow,active,maskhex)
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));

2
iguana/iguana_wallet.c

@ -980,7 +980,7 @@ cJSON *iguana_privkeysjson(struct supernet_info *myinfo,struct iguana_info *coin
if ( address != 0 )
{
strcpy(&addresses[64 * n++],address);
} else printf("cant get address from.(%s)\n",jprint(item,0));
} //else printf("cant get address from.(%s)\n",jprint(item,0));
}
for (i=0; i<n; i++)
{

5
iguana/m_notary_run

@ -17,6 +17,11 @@ sleep 4
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"SuperNET\",\"method\":\"myipaddr\",\"ipaddr\":\"$myip\"}"
sleep 3
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnotary\",\"ipaddr\":\"78.47.196.146\"}"
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnotary\",\"ipaddr\":\"82.202.193.98\"}"
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnotary\",\"ipaddr\":\"54.95.68.31\"}"
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnotary\",\"ipaddr\":\"142.54.164.114\"}"
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnotary\",\"ipaddr\":\"45.7.229.33\"}"
#tests/addnotarys_7776
coins/btc_7776
#coins/ltc_7776

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