Browse Source

Test

etomic
jl777 8 years ago
parent
commit
b309937f47
  1. 3
      basilisk/basilisk.c
  2. 83
      basilisk/basilisk_DEX.c
  3. 14
      basilisk/basilisk_swap.c
  4. 14
      basilisk/basilisk_tradebot.c
  5. 2
      basilisk/jumblr.c
  6. 81
      basilisk/smartaddress.c
  7. 6
      iguana/dpow/dpow_network.c
  8. 7
      iguana/iguana777.h
  9. 3
      iguana/iguana_wallet.c
  10. 1
      iguana/tests/loop
  11. 6
      includes/iguana_funcs.h

3
basilisk/basilisk.c

@ -482,6 +482,7 @@ int32_t basilisk_relayid(struct supernet_info *myinfo,uint32_t ipbits)
#include "basilisk_ether.c" #include "basilisk_ether.c"
#include "basilisk_waves.c" #include "basilisk_waves.c"
#include "basilisk_lisk.c" #include "basilisk_lisk.c"
#include "smartaddress.c"
#include "basilisk_MSG.c" #include "basilisk_MSG.c"
#include "tradebots_marketmaker.c" #include "tradebots_marketmaker.c"
@ -924,7 +925,7 @@ void basilisks_loop(void *arg)
if ( myinfo->expiration != 0 && (myinfo->dexsock >= 0 || myinfo->IAMLP != 0 || myinfo->DEXactive > time(NULL)) ) if ( myinfo->expiration != 0 && (myinfo->dexsock >= 0 || myinfo->IAMLP != 0 || myinfo->DEXactive > time(NULL)) )
{ {
//fprintf(stderr,"H "); //fprintf(stderr,"H ");
basilisk_requests_poll(myinfo,myinfo->persistent_priv); basilisk_requests_poll(myinfo);
} }
//printf("RELAYID.%d endmilli %f vs now %f\n",myinfo->NOTARY.RELAYID,endmilli,startmilli); //printf("RELAYID.%d endmilli %f vs now %f\n",myinfo->NOTARY.RELAYID,endmilli,startmilli);
while ( OS_milliseconds() < endmilli ) while ( OS_milliseconds() < endmilli )

83
basilisk/basilisk_DEX.c

@ -237,8 +237,8 @@ char *basilisk_start(struct supernet_info *myinfo,bits256 privkey,struct basilis
//printf("filter duplicate r%u\n",_rp->requestid); //printf("filter duplicate r%u\n",_rp->requestid);
return(clonestr("{\"error\":\"filter duplicate requestid\"}")); return(clonestr("{\"error\":\"filter duplicate requestid\"}"));
} }
srcmatch = (bits256_cmp(_rp->srchash,myinfo->myaddr.persistent) == 0 || bits256_cmp(_rp->srchash,myinfo->jumblr_pubkey) == 0 || bits256_cmp(_rp->srchash,myinfo->jumblr_depositkey) == 0); srcmatch = smartaddress_pubkey(myinfo,&privkey,_rp->srchash) >= 0;
destmatch = (bits256_cmp(_rp->desthash,myinfo->myaddr.persistent) == 0 || bits256_cmp(_rp->desthash,myinfo->jumblr_pubkey) == 0 || bits256_cmp(_rp->desthash,myinfo->jumblr_depositkey) == 0); destmatch = smartaddress_pubkey(myinfo,&privkey,_rp->desthash) >= 0;
if ( srcmatch != 0 || destmatch != 0 ) if ( srcmatch != 0 || destmatch != 0 )
{ {
for (i=0; i<myinfo->numswaps; i++) for (i=0; i<myinfo->numswaps; i++)
@ -274,10 +274,10 @@ char *basilisk_start(struct supernet_info *myinfo,bits256 privkey,struct basilis
} else return(clonestr("{\"error\":\"unexpected basilisk_start not mine and amrelay\"}")); } else return(clonestr("{\"error\":\"unexpected basilisk_start not mine and amrelay\"}"));
} }
void basilisk_requests_poll(struct supernet_info *myinfo,bits256 privkey) void basilisk_requests_poll(struct supernet_info *myinfo)
{ {
static uint32_t lastpoll; static uint32_t lastpoll;
char *retstr,BTCaddr[64],KMDaddr[64]; uint8_t data[32768]; cJSON *outerarray,*retjson; uint32_t msgid,channel; int32_t datalen,i,n; struct basilisk_request issueR; double hwm = 0.; char *retstr; uint8_t data[32768]; cJSON *outerarray,*retjson; uint32_t msgid,channel; int32_t datalen,i,n; struct basilisk_request issueR; bits256 privkey; double hwm = 0.;
if ( myinfo->IAMNOTARY != 0 || time(NULL) < lastpoll+20 || (myinfo->IAMLP == 0 && myinfo->DEXactive < time(NULL)) ) if ( myinfo->IAMNOTARY != 0 || time(NULL) < lastpoll+20 || (myinfo->IAMLP == 0 && myinfo->DEXactive < time(NULL)) )
return; return;
lastpoll = (uint32_t)time(NULL); lastpoll = (uint32_t)time(NULL);
@ -301,62 +301,16 @@ void basilisk_requests_poll(struct supernet_info *myinfo,bits256 privkey)
channel = 'D' + ((uint32_t)'E' << 8) + ((uint32_t)'X' << 16); channel = 'D' + ((uint32_t)'E' << 8) + ((uint32_t)'X' << 16);
if ( hwm > 0. ) if ( hwm > 0. )
{ {
//printf("hwm %f\n",hwm);
//for (i=0; i<sizeof(issueR); i++)
// printf("%02x",((uint8_t *)&issueR)[i]);
//printf("\n");
myinfo->DEXaccept = issueR; myinfo->DEXaccept = issueR;
/*issueR.quoteid = basilisk_quoteid(&issueR); if ( smartaddress_pubkey(myinfo,&privkey,issueR.srchash) >= 0 )
datalen = basilisk_rwDEXquote(1,data,&issueR);
msgid = (uint32_t)time(NULL);
keylen = basilisk_messagekey(key,0,msgid,issueR.srchash,issueR.desthash);
if ( (retstr= basilisk_respond_addmessage(myinfo,key,keylen,data,datalen,0,BASILISK_DEXDURATION)) != 0 )
free(retstr);*/
if ( bits256_cmp(myinfo->myaddr.persistent,issueR.srchash) == 0 ) // my request
{
printf("matched persistent\n");
dex_channelsend(myinfo,issueR.srchash,issueR.desthash,channel,0x4000000,(void *)&issueR.requestid,sizeof(issueR.requestid)); // 60
dpow_nanomsg_update(myinfo);
dex_updateclient(myinfo);
if ( (retstr= basilisk_start(myinfo,myinfo->persistent_priv,&issueR,1,issueR.optionhours * 3600)) != 0 )
free(retstr);
}
else if ( bits256_cmp(myinfo->jumblr_pubkey,issueR.srchash) == 0 )
{ {
printf("matched jumblr_pubkey\n"); printf("matched dex_smartpubkey\n");
dex_channelsend(myinfo,issueR.srchash,issueR.desthash,channel,0x4000000,(void *)&issueR.requestid,sizeof(issueR.requestid)); // 60 dex_channelsend(myinfo,issueR.srchash,issueR.desthash,channel,0x4000000,(void *)&issueR.requestid,sizeof(issueR.requestid)); // 60
dpow_nanomsg_update(myinfo); dpow_nanomsg_update(myinfo);
dex_updateclient(myinfo); dex_updateclient(myinfo);
if ( (retstr= basilisk_start(myinfo,jumblr_privkey(myinfo,BTCaddr,KMDaddr,""),&issueR,1,issueR.optionhours * 3600)) != 0 ) if ( (retstr= basilisk_start(myinfo,privkey,&issueR,1,issueR.optionhours * 3600)) != 0 )
free(retstr); free(retstr);
} }
else if ( bits256_cmp(myinfo->jumblr_depositkey,issueR.srchash) == 0 )
{
printf("matched jumblr_depositkey\n");
dex_channelsend(myinfo,issueR.srchash,issueR.desthash,channel,0x4000000,(void *)&issueR.requestid,sizeof(issueR.requestid)); // 60
dpow_nanomsg_update(myinfo);
dex_updateclient(myinfo);
if ( (retstr= basilisk_start(myinfo,jumblr_privkey(myinfo,BTCaddr,KMDaddr,JUMBLR_DEPOSITPREFIX),&issueR,1,issueR.optionhours * 3600)) != 0 )
free(retstr);
/*if ( (retstr= InstantDEX_accept(myinfo,0,0,0,issueR.requestid,issueR.quoteid)) != 0 )
free(retstr);
printf("my req hwm %f -> %u\n",hwm,issueR.requestid);
basilisk_channelsend(myinfo,issueR.srchash,issueR.desthash,channel,0x4000000,(void *)&issueR.requestid,sizeof(issueR.requestid),60);
numiters = crc = 0;
while ( numiters < 10 && (crc= basilisk_crcsend(myinfo,0,buf,sizeof(buf),issueR.srchash,issueR.desthash,channel,0x4000000,(void *)&issueR.requestid,sizeof(issueR.requestid),crcs)) == 0 )
{
printf("didnt get back what was sent\n");
sleep(3);
basilisk_channelsend(myinfo,issueR.srchash,issueR.desthash,channel,0x4000000,(void *)&issueR.requestid,sizeof(issueR.requestid),60);
numiters++;
}
if ( crc != 0 )
{
printf("crc.%08x -> basilisk_starta\n",crc);
if ( (retstr= basilisk_start(myinfo,&issueR,1,issueR.optionhours * 3600)) != 0 )
free(retstr);
} // else printf("couldnt accept offer\n");*/
}
else if ( issueR.requestid != myinfo->lastdexrequestid )//if ( issueR.quoteid == 0 ) else if ( issueR.requestid != myinfo->lastdexrequestid )//if ( issueR.quoteid == 0 )
{ {
issueR.quoteid = basilisk_quoteid(&issueR); issueR.quoteid = basilisk_quoteid(&issueR);
@ -369,22 +323,6 @@ void basilisk_requests_poll(struct supernet_info *myinfo,bits256 privkey)
dex_updateclient(myinfo); dex_updateclient(myinfo);
if ( (retstr= basilisk_start(myinfo,myinfo->persistent_priv,&issueR,0,issueR.optionhours * 3600)) != 0 ) if ( (retstr= basilisk_start(myinfo,myinfo->persistent_priv,&issueR,0,issueR.optionhours * 3600)) != 0 )
free(retstr); free(retstr);
/*crcs[0] = crcs[1] = 0;
numiters = 0;
basilisk_channelsend(myinfo,issueR.desthash,issueR.srchash,channel,msgid,data,datalen,INSTANTDEX_LOCKTIME*2);
while ( numiters < 10 && (crc= basilisk_crcsend(myinfo,0,buf,sizeof(buf),issueR.desthash,issueR.srchash,channel,msgid,data,datalen,crcs)) == 0 )
{
//printf("didnt get back what was sent\n");
sleep(3);
basilisk_channelsend(myinfo,issueR.desthash,issueR.srchash,channel,msgid,data,datalen,INSTANTDEX_LOCKTIME*2);
numiters++;
}
if ( crc != 0 )
{
printf("crc.%08x -> basilisk_start\n",crc);
if ( (retstr= basilisk_start(myinfo,&issueR,0,issueR.optionhours * 3600)) != 0 )
free(retstr);
}*/
} //else printf("basilisk_requests_poll unexpected hwm issueR\n"); } //else printf("basilisk_requests_poll unexpected hwm issueR\n");
} }
} }
@ -658,7 +596,7 @@ STRING_ARG(InstantDEX,available,source)
HASH_ARRAY_STRING(InstantDEX,request,hash,vals,hexstr) HASH_ARRAY_STRING(InstantDEX,request,hash,vals,hexstr)
{ {
uint8_t serialized[512]; bits256 privkey; char buf[512],BTCaddr[64],KMDaddr[64]; struct basilisk_request R; int32_t iambob,optionhours; cJSON *reqjson; uint32_t datalen=0,DEX_channel; struct iguana_info *bobcoin,*alicecoin; uint8_t serialized[512]; bits256 privkey; char buf[512],BTCaddr[64],KMDaddr[64]; struct basilisk_request R; int32_t jumblr,iambob,optionhours; cJSON *reqjson; uint32_t datalen=0,DEX_channel; struct iguana_info *bobcoin,*alicecoin;
myinfo->DEXactive = (uint32_t)time(NULL) + 3*BASILISK_TIMEOUT + 60; myinfo->DEXactive = (uint32_t)time(NULL) + 3*BASILISK_TIMEOUT + 60;
jadd64bits(vals,"minamount",jdouble(vals,"minprice") * jdouble(vals,"amount") * SATOSHIDEN * SATOSHIDEN); jadd64bits(vals,"minamount",jdouble(vals,"minprice") * jdouble(vals,"amount") * SATOSHIDEN * SATOSHIDEN);
if ( jobj(vals,"desthash") == 0 ) if ( jobj(vals,"desthash") == 0 )
@ -666,11 +604,10 @@ HASH_ARRAY_STRING(InstantDEX,request,hash,vals,hexstr)
jadd64bits(vals,"satoshis",jdouble(vals,"amount") * SATOSHIDEN); jadd64bits(vals,"satoshis",jdouble(vals,"amount") * SATOSHIDEN);
jadd64bits(vals,"destsatoshis",jdouble(vals,"destamount") * SATOSHIDEN); jadd64bits(vals,"destsatoshis",jdouble(vals,"destamount") * SATOSHIDEN);
jaddnum(vals,"timestamp",time(NULL)); jaddnum(vals,"timestamp",time(NULL));
if ( jint(vals,"usejumblr") != 0 ) if ( (jumblr= jint(vals,"usejumblr")) != 0 )
privkey = jumblr_privkey(myinfo,BTCaddr,KMDaddr,JUMBLR_DEPOSITPREFIX); privkey = jumblr_privkey(myinfo,BTCaddr,KMDaddr,jumblr == 1 ? JUMBLR_DEPOSITPREFIX : "");
else privkey = myinfo->persistent_priv; else privkey = myinfo->persistent_priv;
hash = curve25519(privkey,curve25519_basepoint9()); hash = curve25519(privkey,curve25519_basepoint9());
//hash = myinfo->myaddr.persistent;
if ( jobj(vals,"srchash") == 0 ) if ( jobj(vals,"srchash") == 0 )
jaddbits256(vals,"srchash",hash); jaddbits256(vals,"srchash",hash);
printf("service.(%s)\n",jprint(vals,0)); printf("service.(%s)\n",jprint(vals,0));

14
basilisk/basilisk_swap.c

@ -13,6 +13,10 @@
* * * *
******************************************************************************/ ******************************************************************************/
/*use external privkey to sign
make sure to broadcast deposit before claiming refund, or to just skip it if neither is done
*/
#define DEX_SLEEP 1 #define DEX_SLEEP 1
// Todo: monitor blockchains, ie complete extracting scriptsig // Todo: monitor blockchains, ie complete extracting scriptsig
@ -628,7 +632,7 @@ int32_t basilisk_verify_pubpair(int32_t *wrongfirstbytep,struct basilisk_swap *s
cJSON *basilisk_privkeyarray(struct supernet_info *myinfo,struct iguana_info *coin,cJSON *vins) cJSON *basilisk_privkeyarray(struct supernet_info *myinfo,struct iguana_info *coin,cJSON *vins)
{ {
cJSON *privkeyarray,*item,*sobj; struct iguana_waddress *waddr; struct iguana_waccount *wacct; char coinaddr[64],account[128],wifstr[64],str[65],*hexstr; uint8_t script[1024]; int32_t i,n,len,vout; bits256 txid; cJSON *privkeyarray,*item,*sobj; struct iguana_waddress *waddr; struct iguana_waccount *wacct; char coinaddr[64],account[128],wifstr[64],str[65],*hexstr; uint8_t script[1024]; int32_t i,n,len,vout; bits256 txid,privkey;
privkeyarray = cJSON_CreateArray(); privkeyarray = cJSON_CreateArray();
//printf("%s persistent.(%s) (%s) change.(%s) scriptstr.(%s)\n",coin->symbol,myinfo->myaddr.BTC,coinaddr,coin->changeaddr,scriptstr); //printf("%s persistent.(%s) (%s) change.(%s) scriptstr.(%s)\n",coin->symbol,myinfo->myaddr.BTC,coinaddr,coin->changeaddr,scriptstr);
if ( (n= cJSON_GetArraySize(vins)) > 0 ) if ( (n= cJSON_GetArraySize(vins)) > 0 )
@ -657,7 +661,13 @@ cJSON *basilisk_privkeyarray(struct supernet_info *myinfo,struct iguana_info *co
{ {
bitcoin_priv2wif(wifstr,waddr->privkey,coin->chain->wiftype); bitcoin_priv2wif(wifstr,waddr->privkey,coin->chain->wiftype);
jaddistr(privkeyarray,waddr->wifstr); jaddistr(privkeyarray,waddr->wifstr);
} else printf("cant find (%s) in wallet\n",coinaddr); }
else if ( smartaddress(myinfo,&privkey,coinaddr) > 0 )
{
bitcoin_priv2wif(wifstr,waddr->privkey,coin->chain->wiftype);
jaddistr(privkeyarray,waddr->wifstr);
}
else printf("cant find (%s) in wallet\n",coinaddr);
} else printf("cant coinaddr from (%s).v%d\n",bits256_str(str,txid),vout); } else printf("cant coinaddr from (%s).v%d\n",bits256_str(str,txid),vout);
} else printf("invalid txid/vout %d of %d\n",i,n); } else printf("invalid txid/vout %d of %d\n",i,n);
} }

14
basilisk/basilisk_tradebot.c

@ -279,7 +279,7 @@ int32_t basilisk_request_cmpref(struct basilisk_request *ref,struct basilisk_req
double basilisk_request_listprocess(struct supernet_info *myinfo,struct basilisk_request *issueR,struct basilisk_request *list,int32_t n) double basilisk_request_listprocess(struct supernet_info *myinfo,struct basilisk_request *issueR,struct basilisk_request *list,int32_t n)
{ {
int32_t i,noquoteflag=0,havequoteflag=0,myrequest=0,maxi=-1; int64_t balance=0,destamount,minamount = 0,maxamount = 0; uint32_t pendingid=0; struct basilisk_swap *active; double metric = 0.; int32_t i,noquoteflag=0,havequoteflag=0,myrequest=0,maxi=-1; int64_t balance=0,destamount,minamount = 0,maxamount = 0; bits256 privkey; uint32_t pendingid=0; struct basilisk_swap *active; double metric = 0.;
memset(issueR,0,sizeof(*issueR)); memset(issueR,0,sizeof(*issueR));
minamount = list[0].minamount; minamount = list[0].minamount;
//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);
@ -289,11 +289,7 @@ double basilisk_request_listprocess(struct supernet_info *myinfo,struct basilisk
return(0.); return(0.);
pendingid = active->I.req.quoteid; pendingid = active->I.req.quoteid;
} }
if ( bits256_cmp(myinfo->myaddr.persistent,list[0].srchash) == 0 ) // my request if ( smartaddress_pubkey(myinfo,&privkey,list[0].srchash) >= 0 )
myrequest = 1;
else if ( bits256_cmp(myinfo->jumblr_pubkey,list[0].srchash) == 0 ) // my request
myrequest = 1;
else if ( bits256_cmp(myinfo->jumblr_depositkey,list[0].srchash) == 0 ) // my request
myrequest = 1; myrequest = 1;
for (i=0; i<n; i++) for (i=0; i<n; i++)
{ {
@ -301,11 +297,7 @@ double basilisk_request_listprocess(struct supernet_info *myinfo,struct basilisk
return(-1); return(-1);
if ( list[i].quoteid != 0 ) if ( list[i].quoteid != 0 )
{ {
if ( bits256_cmp(myinfo->myaddr.persistent,list[i].desthash) == 0 ) // my quoteid if ( smartaddress_pubkey(myinfo,&privkey,list[i].desthash) >= 0 )
myrequest |= 2;
else if ( bits256_cmp(myinfo->jumblr_pubkey,list[i].desthash) == 0 ) // my quoteid
myrequest |= 2;
else if ( bits256_cmp(myinfo->jumblr_depositkey,list[i].desthash) == 0 ) // my quoteid
myrequest |= 2; myrequest |= 2;
havequoteflag++; havequoteflag++;
if ( pendingid == 0 ) if ( pendingid == 0 )

2
basilisk/jumblr.c

@ -506,6 +506,7 @@ STRING_ARG(jumblr,setpassphrase,passphrase)
retjson = cJSON_CreateObject(); retjson = cJSON_CreateObject();
jaddstr(retjson,"result","success"); jaddstr(retjson,"result","success");
privkey = jumblr_privkey(myinfo,BTCaddr,KMDaddr,JUMBLR_DEPOSITPREFIX); privkey = jumblr_privkey(myinfo,BTCaddr,KMDaddr,JUMBLR_DEPOSITPREFIX);
smartaddress_add(myinfo,privkey);
myinfo->jumblr_depositkey = curve25519(privkey,curve25519_basepoint9()); myinfo->jumblr_depositkey = curve25519(privkey,curve25519_basepoint9());
bitcoin_priv2wif(wifstr,privkey,coin->chain->wiftype); bitcoin_priv2wif(wifstr,privkey,coin->chain->wiftype);
if ( coin->FULLNODE < 0 ) if ( coin->FULLNODE < 0 )
@ -520,6 +521,7 @@ STRING_ARG(jumblr,setpassphrase,passphrase)
jaddnum(retjson,"BTCdeposits",dstr(jumblr_balance(myinfo,coinbtc,BTCaddr))); jaddnum(retjson,"BTCdeposits",dstr(jumblr_balance(myinfo,coinbtc,BTCaddr)));
} }
privkey = jumblr_privkey(myinfo,BTCaddr,KMDaddr,""); privkey = jumblr_privkey(myinfo,BTCaddr,KMDaddr,"");
smartaddress_add(myinfo,privkey);
myinfo->jumblr_pubkey = curve25519(privkey,curve25519_basepoint9()); myinfo->jumblr_pubkey = curve25519(privkey,curve25519_basepoint9());
jaddstr(retjson,"KMDjumblr",KMDaddr); jaddstr(retjson,"KMDjumblr",KMDaddr);
jaddstr(retjson,"BTCjumblr",BTCaddr); jaddstr(retjson,"BTCjumblr",BTCaddr);

81
basilisk/smartaddress.c

@ -0,0 +1,81 @@
/******************************************************************************
* Copyright © 2014-2017 The SuperNET Developers. *
* *
* See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at *
* the top-level directory of this distribution for the individual copyright *
* holder information and the developer policies on copyright and licensing. *
* *
* Unless otherwise agreed in a custom licensing agreement, no part of the *
* SuperNET software, including this file may be copied, modified, propagated *
* or distributed except according to the terms contained in the LICENSE file *
* *
* Removal or modification of this copyright notice is prohibited. *
* *
******************************************************************************/
// included from basilisk.c
int32_t smartaddress_add(struct supernet_info *myinfo,bits256 privkey)
{
struct smartaddress *ap;
int32_t i;
if ( myinfo->numsmartaddrs < sizeof(myinfo->smartaddrs)/sizeof(*myinfo->smartaddrs) )
{
for (i=0; i<myinfo->numsmartaddrs; i++)
if ( bits256_cmp(myinfo->smartaddrs[i].privkey,privkey) == 0 )
return(-1);
ap = &myinfo->smartaddrs[myinfo->numsmartaddrs++];
ap->privkey = privkey;
bitcoin_pubkey33(myinfo->ctx,ap->pubkey33,privkey);
ap->pubkey = curve25519(privkey,curve25519_basepoint9());
calc_rmd160(0,ap->rmd160,ap->pubkey33,33);
}
printf("too many smartaddresses\n");
return(-1);
}
int32_t smartaddress(struct supernet_info *myinfo,bits256 *privkeyp,char *coinaddr)
{
int32_t i; uint8_t addrtype,rmd160[20];
memset(privkeyp,0,sizeof(*privkeyp));
bitcoin_addr2rmd160(&addrtype,rmd160,coinaddr);
for (i=0; i<myinfo->numsmartaddrs; i++)
if ( memcmp(myinfo->smartaddrs[i].rmd160,rmd160,20) == 0 )
{
*privkeyp = myinfo->smartaddrs[i].privkey;
return(i);
}
return(-1);
}
int32_t smartaddress_pubkey(struct supernet_info *myinfo,bits256 *privkeyp,bits256 pubkey)
{
int32_t i;
memset(privkeyp,0,sizeof(*privkeyp));
for (i=0; i<myinfo->numsmartaddrs; i++)
if ( bits256_cmp(myinfo->smartaddrs[i].pubkey,pubkey) == 0 )
{
*privkeyp = myinfo->smartaddrs[i].privkey;
return(i);
}
return(-1);
}
int32_t smartaddress_pubkey33(struct supernet_info *myinfo,bits256 *privkeyp,uint8_t *pubkey33)
{
int32_t i;
memset(privkeyp,0,sizeof(*privkeyp));
for (i=0; i<myinfo->numsmartaddrs; i++)
if ( memcmp(myinfo->smartaddrs[i].pubkey33,pubkey33,33) == 0 )
{
*privkeyp = myinfo->smartaddrs[i].privkey;
return(i);
}
return(0);
}
#include "../includes/iguana_apidefs.h"
#include "../includes/iguana_apideclares.h"
#include "../includes/iguana_apiundefs.h"

6
iguana/dpow/dpow_network.c

@ -515,14 +515,14 @@ char *_dex_reqsend(struct supernet_info *myinfo,char *handler,uint8_t *key,int32
printf("%d: subscribe connect (%s)\n",myinfo->numdexipbits,str); printf("%d: subscribe connect (%s)\n",myinfo->numdexipbits,str);
} }
} }
//#ifndef __APPLE__ #ifndef __APPLE__
if ( 0 && (rand() % 100) < 40 ) if ( (rand() % 100) < 40 )
{ {
nanomsg_tcpname(0,str,ipaddr,REP_SOCK); nanomsg_tcpname(0,str,ipaddr,REP_SOCK);
nn_connect(myinfo->reqsock,str); nn_connect(myinfo->reqsock,str);
printf("%d: req connect (%s)\n",myinfo->numdexipbits,str); printf("%d: req connect (%s)\n",myinfo->numdexipbits,str);
} }
//#endif #endif
} }
} }
if ( freeptr != 0 ) if ( freeptr != 0 )

7
iguana/iguana777.h

@ -90,6 +90,12 @@ struct supernet_address
char NXTADDR[32],BTC[64],BTCD[64]; char NXTADDR[32],BTC[64],BTCD[64];
}; };
struct smartaddress
{
bits256 privkey,pubkey;
uint8_t pubkey33[33],rmd160[20];
};
struct pending_trade { UT_hash_handle hh; double basevolume,relvolume,dir; char base[32],rel[32]; }; struct pending_trade { UT_hash_handle hh; double basevolume,relvolume,dir; char base[32],rel[32]; };
#define PSOCK_IDLETIMEOUT 600 #define PSOCK_IDLETIMEOUT 600
@ -156,6 +162,7 @@ struct supernet_info
double *svmfeatures; double *svmfeatures;
uint16_t psockport,numpsocks; struct psock *PSOCKS; portable_mutex_t psockmutex; uint16_t psockport,numpsocks; struct psock *PSOCKS; portable_mutex_t psockmutex;
uint8_t notaries[64][33]; int32_t numnotaries,DEXEXPLORER; uint8_t notaries[64][33]; int32_t numnotaries,DEXEXPLORER;
struct smartaddress smartaddrs[64]; int32_t numsmartaddrs;
}; };
struct basilisk_swapmessage struct basilisk_swapmessage

3
iguana/iguana_wallet.c

@ -1367,6 +1367,9 @@ TWOSTRINGS_AND_INT(bitcoinrpc,walletpassphrase,password,permanentfile,timeout)
jumblr_importprivkey(myinfo,coin,wifstr); jumblr_importprivkey(myinfo,coin,wifstr);
} }
} }
if ( bits256_nonz(myinfo->persistent_priv) != 0 )
smartaddress_add(myinfo,myinfo->persistent_priv);
//basilisk_unspents_update(myinfo,coin); //basilisk_unspents_update(myinfo,coin);
return(retstr); return(retstr);
} }

1
iguana/tests/loop

@ -1,7 +1,6 @@
#!/bin/bash #!/bin/bash
while true while true
do do
./dexlistunspent
./dexgetinfo ./dexgetinfo
done done

6
includes/iguana_funcs.h

@ -595,8 +595,12 @@ int32_t iguana_scriptdata(struct iguana_info *coin,uint8_t *scriptspace,long fil
void basilisk_ensurerelay(struct supernet_info *myinfo,struct iguana_info *notaries,uint32_t ipbits); void basilisk_ensurerelay(struct supernet_info *myinfo,struct iguana_info *notaries,uint32_t ipbits);
void dpow_nanomsginit(struct supernet_info *myinfo,char *ipaddr); void dpow_nanomsginit(struct supernet_info *myinfo,char *ipaddr);
int32_t iguana_datachain_scan(struct supernet_info *myinfo,struct iguana_info *coin,uint8_t rmd160[20]); int32_t iguana_datachain_scan(struct supernet_info *myinfo,struct iguana_info *coin,uint8_t rmd160[20]);
void basilisk_requests_poll(struct supernet_info *myinfo,bits256 privkey); void basilisk_requests_poll(struct supernet_info *myinfo);
void dpow_psockloop(void *_ptr); void dpow_psockloop(void *_ptr);
int32_t smartaddress_add(struct supernet_info *myinfo,bits256 privkey);
int32_t smartaddress(struct supernet_info *myinfo,bits256 *privkeyp,char *coinaddr);
int32_t smartaddress_pubkey(struct supernet_info *myinfo,bits256 *privkeyp,bits256 pubkey);
int32_t smartaddress_pubkey33(struct supernet_info *myinfo,bits256 *privkeyp,uint8_t *pubkey33);
void iguana_RTreset(struct iguana_info *coin); void iguana_RTreset(struct iguana_info *coin);
void iguana_RTpurge(struct iguana_info *coin,int32_t lastheight); void iguana_RTpurge(struct iguana_info *coin,int32_t lastheight);

Loading…
Cancel
Save