Browse Source

Merge branch 'master' into release/v0.1

release/v0.1
jl777 8 years ago
parent
commit
9c524b0ab7
  1. 4
      basilisk/basilisk.c
  2. 16
      basilisk/basilisk_DEX.c
  3. 4
      basilisk/basilisk_swap.c
  4. 12
      basilisk/basilisk_tradebot.c
  5. 6
      iguana/coins/basilisk
  6. 7
      iguana/iguana777.c
  7. 2
      iguana/iguana777.h
  8. 1
      iguana/iguana_init.c
  9. 5
      iguana/iguana_rpc.c
  10. 11
      iguana/iguana_sign.c
  11. 2
      iguana/iguana_unspents.c
  12. 19
      iguana/main.c
  13. 1
      iguana/tests/LPinit
  14. 2
      iguana/tests/decoderawtransaction
  15. 4
      includes/iguana_structs.h

4
basilisk/basilisk.c

@ -806,7 +806,7 @@ void basilisk_requests_poll(struct supernet_info *myinfo)
memset(&issueR,0,sizeof(issueR)); memset(&issueR,0,sizeof(issueR));
if ( (retstr= InstantDEX_incoming(myinfo,0,0,0,0)) != 0 ) if ( (retstr= InstantDEX_incoming(myinfo,0,0,0,0)) != 0 )
{ {
//printf("poll.(%s)\n",retstr); printf("poll.(%s)\n",retstr);
if ( (retjson= cJSON_Parse(retstr)) != 0 ) if ( (retjson= cJSON_Parse(retstr)) != 0 )
{ {
if ( (outerarray= jarray(&n,retjson,"responses")) != 0 ) if ( (outerarray= jarray(&n,retjson,"responses")) != 0 )
@ -820,7 +820,7 @@ void basilisk_requests_poll(struct supernet_info *myinfo)
} else printf("null incoming\n"); } else printf("null incoming\n");
if ( hwm > 0. ) if ( hwm > 0. )
{ {
if ( bits256_cmp(myinfo->myaddr.persistent,issueR.hash) == 0 ) // my request if ( bits256_cmp(myinfo->myaddr.persistent,issueR.srchash) == 0 ) // my request
{ {
printf("my req hwm %f\n",hwm); printf("my req hwm %f\n",hwm);
if ( (retstr= InstantDEX_accept(myinfo,0,0,0,issueR.requestid,issueR.quoteid)) != 0 ) if ( (retstr= InstantDEX_accept(myinfo,0,0,0,issueR.requestid,issueR.quoteid)) != 0 )

16
basilisk/basilisk_DEX.c

@ -103,7 +103,7 @@ int32_t basilisk_rwDEXquote(int32_t rwflag,uint8_t *serialized,struct basilisk_r
len += iguana_rwnum(rwflag,&serialized[len],sizeof(rp->relaybits),&rp->relaybits); len += iguana_rwnum(rwflag,&serialized[len],sizeof(rp->relaybits),&rp->relaybits);
len += iguana_rwnum(rwflag,&serialized[len],sizeof(rp->srcamount),&rp->srcamount); len += iguana_rwnum(rwflag,&serialized[len],sizeof(rp->srcamount),&rp->srcamount);
len += iguana_rwnum(rwflag,&serialized[len],sizeof(rp->minamount),&rp->minamount); len += iguana_rwnum(rwflag,&serialized[len],sizeof(rp->minamount),&rp->minamount);
len += iguana_rwbignum(rwflag,&serialized[len],sizeof(rp->hash),rp->hash.bytes); len += iguana_rwbignum(rwflag,&serialized[len],sizeof(rp->srchash),rp->srchash.bytes);
len += iguana_rwbignum(rwflag,&serialized[len],sizeof(rp->desthash),rp->desthash.bytes); len += iguana_rwbignum(rwflag,&serialized[len],sizeof(rp->desthash),rp->desthash.bytes);
len += iguana_rwnum(rwflag,&serialized[len],sizeof(rp->destamount),&rp->destamount); len += iguana_rwnum(rwflag,&serialized[len],sizeof(rp->destamount),&rp->destamount);
if ( rwflag != 0 ) if ( rwflag != 0 )
@ -148,7 +148,7 @@ cJSON *basilisk_requestjson(struct basilisk_request *rp)
expand_ipbits(ipaddr,rp->relaybits); expand_ipbits(ipaddr,rp->relaybits);
jaddstr(item,"relay",ipaddr); jaddstr(item,"relay",ipaddr);
} }
jaddbits256(item,"hash",rp->hash); jaddbits256(item,"srchash",rp->srchash);
if ( bits256_nonz(rp->desthash) != 0 ) if ( bits256_nonz(rp->desthash) != 0 )
jaddbits256(item,"desthash",rp->desthash); jaddbits256(item,"desthash",rp->desthash);
jaddstr(item,"src",rp->src); jaddstr(item,"src",rp->src);
@ -189,7 +189,7 @@ cJSON *basilisk_requestjson(struct basilisk_request *rp)
return(item); return(item);
} }
int32_t basilisk_request_create(struct basilisk_request *rp,cJSON *valsobj,bits256 hash,uint32_t timestamp) int32_t basilisk_request_create(struct basilisk_request *rp,cJSON *valsobj,bits256 desthash,uint32_t timestamp)
{ {
char *dest,*src; uint32_t i; char *dest,*src; uint32_t i;
memset(rp,0,sizeof(*rp)); memset(rp,0,sizeof(*rp));
@ -197,7 +197,7 @@ int32_t basilisk_request_create(struct basilisk_request *rp,cJSON *valsobj,bits2
{ {
if ( (rp->destamount= j64bits(valsobj,"destsatoshis")) != 0 ) if ( (rp->destamount= j64bits(valsobj,"destsatoshis")) != 0 )
{ {
rp->desthash = jbits256(valsobj,"desthash"); rp->desthash = desthash;
for (i=0; i<4; i++) for (i=0; i<4; i++)
if ( rp->desthash.ulongs[i] != 0 ) if ( rp->desthash.ulongs[i] != 0 )
break; break;
@ -206,7 +206,7 @@ int32_t basilisk_request_create(struct basilisk_request *rp,cJSON *valsobj,bits2
} }
rp->minamount = j64bits(valsobj,"minamount"); rp->minamount = j64bits(valsobj,"minamount");
rp->timestamp = timestamp; rp->timestamp = timestamp;
rp->hash = hash; rp->srchash = jbits256(valsobj,"srchash");
strncpy(rp->src,src,sizeof(rp->src)-1); strncpy(rp->src,src,sizeof(rp->src)-1);
strncpy(rp->dest,dest,sizeof(rp->dest)-1); strncpy(rp->dest,dest,sizeof(rp->dest)-1);
rp->requestid = basilisk_requestid(rp); rp->requestid = basilisk_requestid(rp);
@ -224,7 +224,7 @@ int32_t basilisk_request_create(struct basilisk_request *rp,cJSON *valsobj,bits2
char *basilisk_start(struct supernet_info *myinfo,struct basilisk_request *rp,uint32_t statebits) char *basilisk_start(struct supernet_info *myinfo,struct basilisk_request *rp,uint32_t statebits)
{ {
cJSON *retjson; cJSON *retjson;
if ( (bits256_cmp(rp->hash,myinfo->myaddr.persistent) == 0 || bits256_cmp(rp->desthash,myinfo->myaddr.persistent) == 0) ) if ( (bits256_cmp(rp->srchash,myinfo->myaddr.persistent) == 0 || bits256_cmp(rp->desthash,myinfo->myaddr.persistent) == 0) )
{ {
printf("START thread to complete %u/%u for (%s %.8f) <-> (%s %.8f) q.%u\n",rp->requestid,rp->quoteid,rp->src,dstr(rp->srcamount),rp->dest,dstr(rp->destamount),rp->quoteid); printf("START thread to complete %u/%u for (%s %.8f) <-> (%s %.8f) q.%u\n",rp->requestid,rp->quoteid,rp->src,dstr(rp->srcamount),rp->dest,dstr(rp->destamount),rp->quoteid);
if ( basilisk_thread_start(myinfo,rp) != 0 ) if ( basilisk_thread_start(myinfo,rp) != 0 )
@ -333,7 +333,7 @@ char *basilisk_respond_requests(struct supernet_info *myinfo,bits256 hash,uint32
for (i=0; i<num; i++) for (i=0; i<num; i++)
{ {
rp = &requests[i]; rp = &requests[i];
if ( quoteid == 0 || (quoteid == rp->quoteid && (bits256_cmp(hash,rp->hash) == 0 || bits256_cmp(hash,rp->desthash) == 0)) ) if ( quoteid == 0 || (quoteid == rp->quoteid && (bits256_cmp(hash,rp->srchash) == 0 || bits256_cmp(hash,rp->desthash) == 0)) )
qflag = 1; qflag = 1;
else qflag = 0; else qflag = 0;
if ( requestid == 0 || (rp->requestid == requestid && qflag != 0) ) if ( requestid == 0 || (rp->requestid == requestid && qflag != 0) )
@ -424,6 +424,8 @@ HASH_ARRAY_STRING(InstantDEX,request,hash,vals,hexstr)
uint8_t serialized[512]; struct basilisk_request R; cJSON *reqjson; uint32_t datalen=0,DEX_channel; uint8_t serialized[512]; struct basilisk_request R; cJSON *reqjson; uint32_t datalen=0,DEX_channel;
myinfo->DEXactive = (uint32_t)time(NULL) + BASILISK_TIMEOUT; myinfo->DEXactive = (uint32_t)time(NULL) + BASILISK_TIMEOUT;
jadd64bits(vals,"minamount",jdouble(vals,"minprice") * jdouble(vals,"amount") * SATOSHIDEN); jadd64bits(vals,"minamount",jdouble(vals,"minprice") * jdouble(vals,"amount") * SATOSHIDEN);
if ( jobj(vals,"srchash") == 0 )
jaddbits256(vals,"srchash",myinfo->myaddr.pubkey);
if ( jobj(vals,"desthash") == 0 ) if ( jobj(vals,"desthash") == 0 )
jaddbits256(vals,"desthash",hash); jaddbits256(vals,"desthash",hash);
jadd64bits(vals,"satoshis",jdouble(vals,"amount") * SATOSHIDEN); jadd64bits(vals,"satoshis",jdouble(vals,"amount") * SATOSHIDEN);

4
basilisk/basilisk_swap.c

@ -751,7 +751,7 @@ struct basilisk_swap *bitcoin_swapinit(struct supernet_info *myinfo,struct basil
swap->choosei %= INSTANTDEX_DECKSIZE; swap->choosei %= INSTANTDEX_DECKSIZE;
swap->otherchoosei = -1; swap->otherchoosei = -1;
swap->myhash = myinfo->myaddr.persistent; swap->myhash = myinfo->myaddr.persistent;
if ( bits256_cmp(swap->myhash,swap->req.hash) == 0 ) if ( bits256_cmp(swap->myhash,swap->req.srchash) == 0 )
{ {
swap->otherhash = swap->req.desthash; swap->otherhash = swap->req.desthash;
if ( strcmp(swap->req.src,swap->bobstr) == 0 ) if ( strcmp(swap->req.src,swap->bobstr) == 0 )
@ -764,7 +764,7 @@ struct basilisk_swap *bitcoin_swapinit(struct supernet_info *myinfo,struct basil
} }
else if ( bits256_cmp(swap->myhash,swap->req.desthash) == 0 ) else if ( bits256_cmp(swap->myhash,swap->req.desthash) == 0 )
{ {
swap->otherhash = swap->req.hash; swap->otherhash = swap->req.srchash;
if ( strcmp(swap->req.dest,swap->bobstr) == 0 ) if ( strcmp(swap->req.dest,swap->bobstr) == 0 )
swap->iambob = 1; swap->iambob = 1;
else if ( strcmp(swap->req.src,swap->alicestr) != 0 ) else if ( strcmp(swap->req.src,swap->alicestr) != 0 )

12
basilisk/basilisk_tradebot.c

@ -29,7 +29,7 @@ uint32_t basilisk_requestid(struct basilisk_request *rp)
for (i=0; i<sizeof(R); i++) for (i=0; i<sizeof(R); i++)
printf("%02x",((uint8_t *)&R)[i]); printf("%02x",((uint8_t *)&R)[i]);
printf(" <- crc.%u\n",calc_crc32(0,(void *)&R,sizeof(R))); printf(" <- crc.%u\n",calc_crc32(0,(void *)&R,sizeof(R)));
char str[65],str2[65]; printf("B REQUESTID: t.%u r.%u q.%u %s %.8f %s -> %s %.8f %s crc.%u\n",R.timestamp,R.requestid,R.quoteid,R.src,dstr(R.srcamount),bits256_str(str,R.hash),R.dest,dstr(R.destamount),bits256_str(str2,R.desthash),calc_crc32(0,(void *)&R,sizeof(R))); char str[65],str2[65]; printf("B REQUESTID: t.%u r.%u q.%u %s %.8f %s -> %s %.8f %s crc.%u\n",R.timestamp,R.requestid,R.quoteid,R.src,dstr(R.srcamount),bits256_str(str,R.srchash),R.dest,dstr(R.destamount),bits256_str(str2,R.desthash),calc_crc32(0,(void *)&R,sizeof(R)));
} }
return(calc_crc32(0,(void *)&R,sizeof(R))); return(calc_crc32(0,(void *)&R,sizeof(R)));
} }
@ -46,7 +46,7 @@ struct basilisk_request *basilisk_parsejson(struct basilisk_request *rp,cJSON *r
{ {
uint32_t requestid,quoteid; uint32_t requestid,quoteid;
memset(rp,0,sizeof(*rp)); memset(rp,0,sizeof(*rp));
rp->hash = jbits256(reqjson,"hash"); rp->srchash = jbits256(reqjson,"srchash");
rp->desthash = jbits256(reqjson,"desthash"); rp->desthash = jbits256(reqjson,"desthash");
rp->srcamount = j64bits(reqjson,"srcamount"); rp->srcamount = j64bits(reqjson,"srcamount");
rp->minamount = j64bits(reqjson,"minamount"); rp->minamount = j64bits(reqjson,"minamount");
@ -102,7 +102,7 @@ struct basilisk_swap *basilisk_request_started(struct supernet_info *myinfo,uint
int32_t basilisk_request_cmpref(struct basilisk_request *ref,struct basilisk_request *rp) int32_t basilisk_request_cmpref(struct basilisk_request *ref,struct basilisk_request *rp)
{ {
if ( bits256_cmp(rp->hash,ref->hash) != 0 || memcmp(rp->src,ref->src,sizeof(ref->src)) != 0 || memcmp(rp->dest,ref->dest,sizeof(ref->dest)) != 0 || rp->srcamount != ref->srcamount || rp->timestamp != ref->timestamp ) if ( bits256_cmp(rp->srchash,ref->srchash) != 0 || memcmp(rp->src,ref->src,sizeof(ref->src)) != 0 || memcmp(rp->dest,ref->dest,sizeof(ref->dest)) != 0 || rp->srcamount != ref->srcamount || rp->timestamp != ref->timestamp )
{ {
printf("basilisk_request_listprocess mismatched hash\n"); printf("basilisk_request_listprocess mismatched hash\n");
return(-1); return(-1);
@ -162,7 +162,7 @@ double basilisk_request_listprocess(struct supernet_info *myinfo,struct basilisk
printf("need to verify null quoteid is list[0] requestid.%u quoteid.%u\n",list[0].requestid,list[0].quoteid); printf("need to verify null quoteid is list[0] requestid.%u quoteid.%u\n",list[0].requestid,list[0].quoteid);
if ( (active= basilisk_request_started(myinfo,list[0].requestid)) != 0 ) if ( (active= basilisk_request_started(myinfo,list[0].requestid)) != 0 )
pendingid = active->req.quoteid; pendingid = active->req.quoteid;
if ( bits256_cmp(myinfo->myaddr.persistent,list[0].hash) == 0 ) // my request if ( bits256_cmp(myinfo->myaddr.persistent,list[0].srchash) == 0 ) // my request
myrequest = 1; myrequest = 1;
for (i=0; i<n; i++) for (i=0; i<n; i++)
{ {
@ -192,6 +192,8 @@ double basilisk_request_listprocess(struct supernet_info *myinfo,struct basilisk
{ {
if ( (aveprice= instantdex_avehbla(myinfo,retvals,list[0].src,list[0].dest,1.3 * dstr(list[0].srcamount))) == 0. || refprice > aveprice ) if ( (aveprice= instantdex_avehbla(myinfo,retvals,list[0].src,list[0].dest,1.3 * dstr(list[0].srcamount))) == 0. || refprice > aveprice )
aveprice = refprice; aveprice = refprice;
if ( fabs(aveprice) < SMALLVAL )
return(0);
destamount = (1.0 - profitmargin) * aveprice * list[0].srcamount; destamount = (1.0 - profitmargin) * aveprice * list[0].srcamount;
if ( (retstr= InstantDEX_available(myinfo,iguana_coinfind(list[0].dest),0,0,list[0].dest)) != 0 ) if ( (retstr= InstantDEX_available(myinfo,iguana_coinfind(list[0].dest),0,0,list[0].dest)) != 0 )
{ {
@ -230,7 +232,7 @@ double basilisk_process_results(struct supernet_info *myinfo,struct basilisk_req
{ {
cJSON *array,*item; int32_t i,n,m,nonz; struct basilisk_request tmpR,R,refR,list[BASILISK_MAXRELAYS]; double metric=0.; cJSON *array,*item; int32_t i,n,m,nonz; struct basilisk_request tmpR,R,refR,list[BASILISK_MAXRELAYS]; double metric=0.;
memset(&refR,0,sizeof(refR)); memset(&refR,0,sizeof(refR));
//printf("process.(%s)\n",jprint(retjson,0)); printf("process.(%s)\n",jprint(retjson,0));
if ( (array= jarray(&n,retjson,"messages")) != 0 ) if ( (array= jarray(&n,retjson,"messages")) != 0 )
{ {
for (i=nonz=m=0; i<n; i++) for (i=nonz=m=0; i<n; i++)

6
iguana/coins/basilisk

@ -1,4 +1,6 @@
curl --url "http://127.0.0.1:7778" --data "{\"poll\":100,\"active\":1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"newcoin\":\"BTCD\",\"startpend\":1,\"endpend\":1,\"services\":128,\"maxpeers\":16,\"RELAY\":0,\"VALIDATE\":0,\"portp2p\":14631,\"rpc\":14632}" #curl --url "http://127.0.0.1:7778" --data "{\"poll\":100,\"active\":1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"newcoin\":\"BTCD\",\"startpend\":1,\"endpend\":1,\"services\":128,\"maxpeers\":16,\"RELAY\":0,\"VALIDATE\":0,\"portp2p\":14631,\"rpc\":14632}"
#curl --url "http://127.0.0.1:7778" --data "{\"prefetchlag\":5,\"poll\":100,\"active\":1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"newcoin\":\"BTC\",\"startpend\":1,\"endpend\":1,\"services\":128,\"maxpeers\":16,\"RELAY\":0,\"VALIDATE\":0,\"portp2p\":8333}" curl --url "http://127.0.0.1:7778" --data "{\"prefetchlag\":5,\"poll\":100,\"active\":1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"newcoin\":\"BTC\",\"startpend\":1,\"endpend\":1,\"services\":128,\"maxpeers\":16,\"RELAY\":0,\"VALIDATE\":0,\"portp2p\":8333}"
#curl --url "http://127.0.0.1:7778" --data "{\"RELAY\":0,\"VALIDATE\":0,\"prefetchlag\":11,\"poll\":100,\"active\":1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"startpend\":1,\"endpend\":1,\"services\":128,\"maxpeers\":16,\"newcoin\":\"LTC\",\"name\":\"Litecoin\",\"hasheaders\":1,\"useaddmultisig\":0,\"netmagic\":\"fbc0b6db\",\"p2p\":9333,\"rpc\":9334,\"pubval\":48,\"p2shval\":5,\"wifval\":176,\"txfee_satoshis\":\"100000\",\"isPoS\":0,\"minoutput\":10000,\"minconfirms\":2,\"genesishash\":\"12a765e31ffd4059bada1e25190f6e98c99d9714d334efa41a195a7e7e04bfe2\",\"genesis\":{\"version\":1,\"timestamp\":1317972665,\"nBits\":\"1e0ffff0\",\"nonce\":2084524493,\"merkle_root\":\"97ddfbbae6be97fd6cdf3e7ca13232a3afff2353e29badfab7f73011edd4ced9\"},\"alertpubkey\":\"040184710fa689ad5023690c80f3a49c8f13f8d45b8c857fbcbc8bc4a8e4d3eb4b10f4d4604fa08dce601aaf0f470216fe1b51850b4acf21b179c45070ac7b03a9\",\"protover\":70002}" #curl --url "http://127.0.0.1:7778" --data "{\"RELAY\":0,\"VALIDATE\":0,\"prefetchlag\":11,\"poll\":100,\"active\":1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"startpend\":1,\"endpend\":1,\"services\":128,\"maxpeers\":16,\"newcoin\":\"LTC\",\"name\":\"Litecoin\",\"hasheaders\":1,\"useaddmultisig\":0,\"netmagic\":\"fbc0b6db\",\"p2p\":9333,\"rpc\":9334,\"pubval\":48,\"p2shval\":5,\"wifval\":176,\"txfee_satoshis\":\"100000\",\"isPoS\":0,\"minoutput\":10000,\"minconfirms\":2,\"genesishash\":\"12a765e31ffd4059bada1e25190f6e98c99d9714d334efa41a195a7e7e04bfe2\",\"genesis\":{\"version\":1,\"timestamp\":1317972665,\"nBits\":\"1e0ffff0\",\"nonce\":2084524493,\"merkle_root\":\"97ddfbbae6be97fd6cdf3e7ca13232a3afff2353e29badfab7f73011edd4ced9\"},\"alertpubkey\":\"040184710fa689ad5023690c80f3a49c8f13f8d45b8c857fbcbc8bc4a8e4d3eb4b10f4d4604fa08dce601aaf0f470216fe1b51850b4acf21b179c45070ac7b03a9\",\"protover\":70002}"
curl --url "http://127.0.0.1:7778" --data "{\"RELAY\":0,\"VALIDATE\":0,\"prefetchlag\":-1,\"poll\":10,\"active\":1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"startpend\":18,\"endpend\":18,\"services\":129,\"maxpeers\":256,\"newcoin\":\"SYS\",\"name\":\"SYScoin\",\"hasheaders\":0,\"useaddmultisig\":0,\"netmagic\":\"f9beb4d9\",\"p2p\":8369,\"rpc\":8370,\"pubval\":0,\"p2shval\":5,\"wifval\":128,\"txfee_satoshis\":\"100000\",\"isPoS\":0,\"minoutput\":10000,\"minconfirms\":2,\"genesishash\":\"0000072d66e51ab87de265765cc8bdd2d229a4307c672a1b3d5af692519cf765\",\"genesis\":{\"version\":1,\"timestamp\":1450473723,\"nBits\":\"1e0ffff0\",\"nonce\":5258726,\"merkle_root\":\"5215c5a2af9b63f2550b635eb2b354bb13645fd8fa31275394eb161944303065\"},\"protover\":70012,\"auxpow\":1,\"fixit\":0}"

7
iguana/iguana777.c

@ -78,6 +78,7 @@ struct iguana_info *iguana_coinadd(char *symbol,char *name,cJSON *argjson,int32_
printf("ADD ALLCOINS.(%s) name.(%s) size %ld numvirts.%d\n",symbol,name,sizeof(*coin),myinfo->allcoins_numvirts); printf("ADD ALLCOINS.(%s) name.(%s) size %ld numvirts.%d\n",symbol,name,sizeof(*coin),myinfo->allcoins_numvirts);
coin->symbolcrc = symbolcrc = calc_crc32(0,symbol,(int32_t)strlen(symbol)); coin->symbolcrc = symbolcrc = calc_crc32(0,symbol,(int32_t)strlen(symbol));
//portable_mutex_lock(&myinfo->allcoins_mutex); //portable_mutex_lock(&myinfo->allcoins_mutex);
coin->coinid = myinfo->totalcoins++;
HASH_ADD(hh,myinfo->allcoins,symbolcrc,sizeof(coin->symbolcrc),coin); HASH_ADD(hh,myinfo->allcoins,symbolcrc,sizeof(coin->symbolcrc),coin);
//portable_mutex_unlock(&myinfo->allcoins_mutex); //portable_mutex_unlock(&myinfo->allcoins_mutex);
struct iguana_info *virt,*tmp; struct iguana_info *virt,*tmp;
@ -755,7 +756,7 @@ void iguana_helper(void *arg)
} }
} }
} }
if ( helperid == 0 ) if ( (helperid % IGUANA_NUMHELPERS) == (coin->coinid % IGUANA_NUMHELPERS) )
iguana_coin_mainiter(myinfo,coin,&numpeers,&MEM,MEMB); iguana_coin_mainiter(myinfo,coin,&numpeers,&MEM,MEMB);
} }
} }
@ -932,11 +933,11 @@ void iguana_coinloop(void *arg)
} }
if ( coin->FULLNODE != 0 || coin->VALIDATENODE != 0 || coin->MAXPEERS == 1 ) if ( coin->FULLNODE != 0 || coin->VALIDATENODE != 0 || coin->MAXPEERS == 1 )
{ {
portable_mutex_lock(&coin->allcoins_mutex); //portable_mutex_lock(&coin->allcoins_mutex);
coin->busy_processing = 1; coin->busy_processing = 1;
flag += iguana_processrecv(myinfo,coin); flag += iguana_processrecv(myinfo,coin);
coin->busy_processing = 0; coin->busy_processing = 0;
portable_mutex_unlock(&coin->allcoins_mutex); //portable_mutex_unlock(&coin->allcoins_mutex);
/*if ( strcmp(coin->symbol,"BTCD") == 0 && coin->RTheight > 0 && coin->RTheight > coin->chain->bundlesize ) /*if ( strcmp(coin->symbol,"BTCD") == 0 && coin->RTheight > 0 && coin->RTheight > coin->chain->bundlesize )
{ {
int32_t hdrsi,nonz,errs; struct iguana_pkhash *refP; struct iguana_bundle *bp; int32_t hdrsi,nonz,errs; struct iguana_pkhash *refP; struct iguana_bundle *bp;

2
iguana/iguana777.h

@ -77,7 +77,7 @@ struct supernet_info
char ipaddr[64],NXTAPIURL[512],secret[4096],password[4096],rpcsymbol[64],handle[1024],permanentfile[1024]; char ipaddr[64],NXTAPIURL[512],secret[4096],password[4096],rpcsymbol[64],handle[1024],permanentfile[1024];
char *decryptstr; char *decryptstr;
int32_t maxdelay,IAMRELAY,IAMNOTARY,IAMLP,publicRPC,basilisk_busy,genesisresults,remoteorigin; int32_t maxdelay,IAMRELAY,IAMNOTARY,IAMLP,publicRPC,basilisk_busy,genesisresults,remoteorigin;
uint32_t expiration,dirty,DEXactive,DEXpoll; uint32_t expiration,dirty,DEXactive,DEXpoll,totalcoins;
uint16_t argport,rpcport; uint16_t argport,rpcport;
struct basilisk_info basilisks; struct basilisk_info basilisks;
struct exchange_info *tradingexchanges[SUPERNET_MAXEXCHANGES]; int32_t numexchanges; struct exchange_info *tradingexchanges[SUPERNET_MAXEXCHANGES]; int32_t numexchanges;

1
iguana/iguana_init.c

@ -68,7 +68,6 @@ void iguana_initcoin(struct iguana_info *coin,cJSON *argjson)
portable_mutex_init(&coin->blocks_mutex); portable_mutex_init(&coin->blocks_mutex);
portable_mutex_init(&coin->special_mutex); portable_mutex_init(&coin->special_mutex);
portable_mutex_init(&coin->allcoins_mutex); portable_mutex_init(&coin->allcoins_mutex);
portable_mutex_init(&coin->allcoins_mutex);
coin->txfee = 10000; coin->txfee = 10000;
iguana_meminit(&coin->blockMEM,"blockMEM",coin->blockspace,coin->blockspacesize,0); iguana_meminit(&coin->blockMEM,"blockMEM",coin->blockspace,coin->blockspacesize,0);
iguana_initQs(coin); iguana_initQs(coin);

5
iguana/iguana_rpc.c

@ -1054,7 +1054,7 @@ char *SuperNET_rpcparse(struct supernet_info *myinfo,char *retbuf,int32_t bufsiz
for (i=0; i<n; i++) for (i=0; i<n; i++)
{ {
argjson = jitem(origargjson,i); argjson = jitem(origargjson,i);
//printf("after urlconv.(%s) argjson.(%s)\n",jprint(json,0),jprint(argjson,0)); //printf("after urlconv.(%s) argjson.(%s)\n",jprint(json,0),jprint(argjson,0));
coin = iguana_coinchoose(myinfo,symbol,argjson,port); coin = iguana_coinchoose(myinfo,symbol,argjson,port);
if ( (retstr= SuperNET_JSON(myinfo,coin,argjson,remoteaddr,port)) != 0 ) if ( (retstr= SuperNET_JSON(myinfo,coin,argjson,remoteaddr,port)) != 0 )
{ {
@ -1072,8 +1072,11 @@ char *SuperNET_rpcparse(struct supernet_info *myinfo,char *retbuf,int32_t bufsiz
coin = iguana_coinchoose(myinfo,symbol,argjson,port); coin = iguana_coinchoose(myinfo,symbol,argjson,port);
retstr = SuperNET_JSON(myinfo,coin,argjson,remoteaddr,port); retstr = SuperNET_JSON(myinfo,coin,argjson,remoteaddr,port);
} }
free_json(argjson);
free_json(json);
return(retstr); return(retstr);
} }
free_json(argjson);
*jsonflagp = 1; *jsonflagp = 1;
return(clonestr("{\"error\":\"couldnt process packet\"}")); return(clonestr("{\"error\":\"couldnt process packet\"}"));
} }

11
iguana/iguana_sign.c

@ -200,6 +200,11 @@ int32_t iguana_parsevinobj(struct supernet_info *myinfo,struct iguana_info *coin
lastbyte = _decode_hex(&spendstr[strlen(spendstr)-2]); lastbyte = _decode_hex(&spendstr[strlen(spendstr)-2]);
if ( lastbyte == SCRIPT_OP_CHECKMULTISIG ) if ( lastbyte == SCRIPT_OP_CHECKMULTISIG )
need_op0 = 1; need_op0 = 1;
if ( V != 0 )
{
V->spendlen = (int32_t)strlen(spendstr) >> 1;
decode_hex(V->spendscript,V->spendlen,spendstr);
}
} }
} }
if ( (redeemstr= jstr(vinobj,"redeemScript")) == 0 || is_hexstr(redeemstr,(int32_t)strlen(redeemstr)) <= 0 ) if ( (redeemstr= jstr(vinobj,"redeemScript")) == 0 || is_hexstr(redeemstr,(int32_t)strlen(redeemstr)) <= 0 )
@ -268,7 +273,11 @@ int32_t iguana_parsevinobj(struct supernet_info *myinfo,struct iguana_info *coin
{ {
if ( vin->vinscript == 0 ) if ( vin->vinscript == 0 )
{ {
<<<<<<< HEAD
//printf("null vinscript case\n"); //printf("null vinscript case\n");
=======
//printf("null vinscript case -> need to sign this tx\n");
>>>>>>> master
vin->vinscript = serialized; vin->vinscript = serialized;
vin->vinscript[0] = 0; vin->vinscript[0] = 0;
vin->scriptlen = 1; vin->scriptlen = 1;
@ -344,7 +353,7 @@ int32_t iguana_parsevinobj(struct supernet_info *myinfo,struct iguana_info *coin
} }
//printf("output sequence.[%d] <- %x\n",len,vin->sequence); //printf("output sequence.[%d] <- %x\n",len,vin->sequence);
len += iguana_rwnum(rwflag,&serialized[len],sizeof(vin->sequence),&vin->sequence); len += iguana_rwnum(rwflag,&serialized[len],sizeof(vin->sequence),&vin->sequence);
if ( spendstr != 0 ) if ( 0 && spendstr != 0 )
{ {
//printf("serialized.%p len.%d\n",serialized,len); //printf("serialized.%p len.%d\n",serialized,len);
n = iguana_parsehexstr(&vin->spendscript,&vin->spendlen,V!=0?V->spendscript:0,V!=0?&V->spendlen:0,&serialized[len],spendstr); n = iguana_parsehexstr(&vin->spendscript,&vin->spendlen,V!=0?V->spendscript:0,V!=0?&V->spendlen:0,&serialized[len],spendstr);

2
iguana/iguana_unspents.c

@ -835,6 +835,8 @@ int32_t iguana_RTunspent_check(struct supernet_info *myinfo,struct iguana_info *
{ {
bits256 txid; int32_t vout,spentheight; bits256 txid; int32_t vout,spentheight;
memset(&txid,0,sizeof(txid)); memset(&txid,0,sizeof(txid));
if ( coin->FULLNODE == 0 && coin->VALIDATENODE == 0 )
return(0);
if ( iguana_RTunspentind2txid(myinfo,coin,&spentheight,&txid,&vout,outpt) == 0 ) if ( iguana_RTunspentind2txid(myinfo,coin,&spentheight,&txid,&vout,outpt) == 0 )
{ {
//char str[65]; printf("verify %s/v%d is not already used\n",bits256_str(str,txid),vout); //char str[65]; printf("verify %s/v%d is not already used\n",bits256_str(str,txid),vout);

19
iguana/main.c

@ -457,8 +457,7 @@ rm BTC.xz; mksquashfs DB/BTC BTC.xz -comp xz -b 1048576 -comp xz -Xdict-size 102
void mainloop(struct supernet_info *myinfo) void mainloop(struct supernet_info *myinfo)
{ {
struct iguana_info *coin,*tmp; int32_t i,counter=0,depth; portable_mutex_t *stack[IGUANA_MAXCOINS]; struct iguana_info *coin; int32_t counter=0,depth; double lastmilli = 0;
double lastmilli = 0;
sleep(3); sleep(3);
printf("mainloop\n"); printf("mainloop\n");
while ( 1 ) while ( 1 )
@ -472,25 +471,9 @@ void mainloop(struct supernet_info *myinfo)
counter++; counter++;
coin = 0; coin = 0;
depth = 0; depth = 0;
if ( 1 )
{
HASH_ITER(hh,myinfo->allcoins,coin,tmp)
{
portable_mutex_lock(&coin->allcoins_mutex);
stack[depth++] = &coin->allcoins_mutex;
}
}
//printf("check jsonQ\n"); //printf("check jsonQ\n");
while ( iguana_jsonQ(myinfo,0) != 0 ) while ( iguana_jsonQ(myinfo,0) != 0 )
; ;
if ( 1 )
{
if ( depth > 0 )
{
for (i=depth-1; i>=0; i--)
portable_mutex_unlock(stack[i]);
}
}
lastmilli = OS_milliseconds(); lastmilli = OS_milliseconds();
} }
usleep(30000); usleep(30000);

1
iguana/tests/LPinit

@ -0,0 +1 @@
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"tradebot\",\"method\":\"liquidity\",\"targetcoin\":\"BTCD\",\"vals\":{\"profit\":0.005}}"

2
iguana/tests/decoderawtransaction

@ -1 +1 @@
curl --url "http://127.0.0.1:7778" --data "{\"coin\":\"BTCD\",\"method\":\"decoderawtransaction\",\"params\":[\"01000000aeefda57019a2aba7f29b3b63732a547f199c7c89cb3b2a7bba23bdc1398772d971573d831010000006a4730440220192e93b9191af641070411ad1945144cf9a1193f9b4263f1b1bf51b558b0b8f202205df39d89e2aa4179d4771966ef38b34e1b570645036cd952c9e91e721b3d23f9012102743d2afdb88ede68fb5938e961b1f41c2b6267b3286516543eb4e4ab87ad0d0affffffff76a9142f4c0f91fc06ac228c120aee41741d0d3909683288ac02c0d40100000000001976a9145da2ae69885741a6946e01ad8aa8b5312eed856088acf0d6e10b000000001976a9142f4c0f91fc06ac228c120aee41741d0d3909683288ac\", 1]}" curl --url "http://127.0.0.1:7778" --data "{\"coin\":\"SYS\",\"method\":\"decoderawtransaction\",\"params\":[\"0100000002836a9affa9b868cd4da9598f9a311bc8315dd0beafcdc4066f7eb4a55d19fae8010000006b483045022100f892c8848a9b9cbc97cc6558b088a4d00ef7da574be31558a252b7ba394d388302205b2a2f9b50bdf7f970fc6c1da5cb4d07a7a1a1e6dfd6f37692f01ad466cade4c012102743d2afdb88ede68fb5938e961b1f41c2b6267b3286516543eb4e4ab87ad0d0affffffffd7bcb83647bdcf661a4e71e96ee0ee84f77f09e278120a9479e19c709238963d000000006a47304402206e9393c76191d9c1383765eae918f91b5977d3eb5dcf63168c14d2a8d37e479c022003a6fd30ee59b9e330b4d18b4c1318ccafde6e0edff836e230bf792f017d73c7012102743d2afdb88ede68fb5938e961b1f41c2b6267b3286516543eb4e4ab87ad0d0affffffff02204e0000000000001976a914d93f7d2bd03a6f9f83ccbd06ec277b4549aff73988accc5d0100000000001976a9142f4c0f91fc06ac228c120aee41741d0d3909683288ac00000000\", 1]}"

4
includes/iguana_structs.h

@ -483,7 +483,7 @@ struct iguana_info
struct OS_memspace RTrawmem,RTmem,RThashmem; // struct iguana_ramchain RTramchain; struct OS_memspace RTrawmem,RTmem,RThashmem; // struct iguana_ramchain RTramchain;
bits256 RThash1; bits256 RThash1;
int32_t numremain,numpendings,zcount,recvcount,bcount,pcount,lastbundle,numsaved,pendbalances,numverified,blockdepth; int32_t numremain,numpendings,zcount,recvcount,bcount,pcount,lastbundle,numsaved,pendbalances,numverified,blockdepth;
uint32_t recvtime,hdrstime,backstoptime,lastbundletime,numreqsent,numbundlesQ,lastbundleitime,lastdisp,RTgenesis,firstRTgenesis,RTstarti,idletime,stucktime,stuckmonitor,maxstuck,lastreqtime,RThdrstime,nextchecked,lastcheckpoint,sigserrs,sigsvalidated; uint32_t recvtime,hdrstime,backstoptime,lastbundletime,numreqsent,numbundlesQ,lastbundleitime,lastdisp,RTgenesis,firstRTgenesis,RTstarti,idletime,stucktime,stuckmonitor,maxstuck,lastreqtime,RThdrstime,nextchecked,lastcheckpoint,sigserrs,sigsvalidated,coinid;
double bandwidth,maxbandwidth,backstopmillis; bits256 backstophash2; int64_t spaceused; double bandwidth,maxbandwidth,backstopmillis; bits256 backstophash2; int64_t spaceused;
int32_t disableUTXO,initialheight,mapflags,minconfirms,numrecv,bindsock,isRT,backstop,blocksrecv,merging,firstRTheight,polltimeout,numreqtxids,allhashes,balanceflush,basilisk_busy,almostRT,busy_processing; bits256 reqtxids[64]; int32_t disableUTXO,initialheight,mapflags,minconfirms,numrecv,bindsock,isRT,backstop,blocksrecv,merging,firstRTheight,polltimeout,numreqtxids,allhashes,balanceflush,basilisk_busy,almostRT,busy_processing; bits256 reqtxids[64];
void *launched,*started,*rpcloop; void *launched,*started,*rpcloop;
@ -548,7 +548,7 @@ struct basilisk_request
{ {
uint32_t requestid,timestamp,quoteid,quotetime; // 0 to 15 uint32_t requestid,timestamp,quoteid,quotetime; // 0 to 15
uint64_t srcamount,minamount; // 16 to 31 uint64_t srcamount,minamount; // 16 to 31
bits256 hash; // 32 to 63 bits256 srchash; // 32 to 63
bits256 desthash; bits256 desthash;
char src[8],dest[8]; char src[8],dest[8];
//char volatile_start,message[43]; //char volatile_start,message[43];

Loading…
Cancel
Save