Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
6ec85b788b
  1. 2
      iguana/exchanges777.h
  2. 4
      iguana/iguana_accept.c
  3. 24
      iguana/iguana_exchanges.c
  4. 3
      iguana/iguana_instantdex.c
  5. 2
      iguana/iguana_msg.c
  6. 26
      iguana/iguana_wallet.c
  7. 10
      iguana/swaps/iguana_BTCswap.c

2
iguana/exchanges777.h

@ -22,7 +22,7 @@
#include <curl/easy.h>
#endif
#define INSTANTDEX_DECKSIZE 2000
#define INSTANTDEX_DECKSIZE 77
#define INSTANTDEX_HOPS 2
#define INSTANTDEX_DURATION 60

4
iguana/iguana_accept.c

@ -339,13 +339,13 @@ int32_t iguana_peeraddrrequest(struct iguana_info *coin,struct iguana_peer *addr
if ( (tmpaddr= coin->peers.ranked[i]) != 0 && ((iter == 0 && tmpaddr->supernet != 0) || (iter == 1 && tmpaddr->supernet == 0)) && tmpaddr->ipaddr[0] != 0 )
{
sendlen += iguana_rwaddr(1,&space[sizeof(H) + sendlen],&tmpaddr->A,(int32_t)tmpaddr->protover);
printf("(%s) ",tmpaddr->ipaddr);
//printf("(%s) ",tmpaddr->ipaddr);
x++;
}
}
}
iguana_rwvarint(1,&space[sizeof(H)],&x);
printf("addrrequest: sendlen.%d x.%d\n",sendlen,(int32_t)x);
//printf("addrrequest: sendlen.%d x.%d\n",sendlen,(int32_t)x);
if ( x == 0 )
return(-1);
return(sendlen);

24
iguana/iguana_exchanges.c

@ -968,6 +968,8 @@ THREE_STRINGS_AND_THREE_INTS(InstantDEX,orderbook,exchange,base,rel,depth,allfie
struct exchange_info *ptr;
if ( remoteaddr == 0 )
{
if ( myinfo->expiration == 0 )
return(clonestr("{\"error\":\"need to unlock wallet\"}"));
if ( exchange != 0 && exchange[0] != 0 )
{
if ( (ptr= exchanges777_info(exchange,1,json,remoteaddr)) != 0 )
@ -982,6 +984,8 @@ THREE_STRINGS_AND_THREE_DOUBLES(InstantDEX,buy,exchange,base,rel,price,volume,do
struct exchange_info *ptr;
if ( remoteaddr == 0 )
{
if ( myinfo->expiration == 0 )
return(clonestr("{\"error\":\"need to unlock wallet\"}"));
if ( (ptr= exchanges777_info(exchange,1,json,remoteaddr)) != 0 )
return(exchanges777_Qtrade(ptr,base,rel,juint(json,"maxseconds"),dotrade,1,price,volume,json));
else return(clonestr("{\"error\":\"cant find or create exchange\"}"));
@ -993,6 +997,8 @@ THREE_STRINGS_AND_THREE_DOUBLES(InstantDEX,sell,exchange,base,rel,price,volume,d
struct exchange_info *ptr;
if ( remoteaddr == 0 )
{
if ( myinfo->expiration == 0 )
return(clonestr("{\"error\":\"need to unlock wallet\"}"));
if ( (ptr= exchanges777_info(exchange,1,json,remoteaddr)) != 0 )
return(exchanges777_Qtrade(ptr,base,rel,juint(json,"maxseconds"),dotrade,-1,price,volume,json));
else return(clonestr("{\"error\":\"cant find or create exchange\"}"));
@ -1004,6 +1010,8 @@ THREE_STRINGS_AND_DOUBLE(InstantDEX,withdraw,exchange,base,destaddr,amount)
struct exchange_info *ptr;
if ( remoteaddr == 0 )
{
if ( myinfo->expiration == 0 )
return(clonestr("{\"error\":\"need to unlock wallet\"}"));
if ( (ptr= exchanges777_info(exchange,1,json,remoteaddr)) != 0 )
return(exchanges777_Qrequest(ptr,'W',base,0,juint(json,"maxseconds"),0,destaddr,amount,json));
else return(clonestr("{\"error\":\"cant find or create exchange\"}"));
@ -1015,6 +1023,8 @@ TWO_STRINGS(InstantDEX,balance,exchange,base)
struct exchange_info *ptr;
if ( remoteaddr == 0 )
{
if ( myinfo->expiration == 0 )
return(clonestr("{\"error\":\"need to unlock wallet\"}"));
if ( (ptr= exchanges777_info(exchange,1,json,remoteaddr)) != 0 )
return(exchanges777_Qrequest(ptr,'B',base,0,juint(json,"maxseconds"),0,0,0,json));
else return(clonestr("{\"error\":\"cant find or create exchange\"}"));
@ -1026,6 +1036,8 @@ TWO_STRINGS(InstantDEX,orderstatus,exchange,orderid)
struct exchange_info *ptr;
if ( remoteaddr == 0 )
{
if ( myinfo->expiration == 0 )
return(clonestr("{\"error\":\"need to unlock wallet\"}"));
if ( (ptr= exchanges777_info(exchange,1,json,remoteaddr)) != 0 )
return(exchanges777_Qrequest(ptr,'P',0,0,juint(json,"maxseconds"),calc_nxt64bits(orderid),0,0,json));
else return(clonestr("{\"error\":\"cant find or create exchange\"}"));
@ -1037,6 +1049,8 @@ TWO_STRINGS(InstantDEX,cancelorder,exchange,orderid)
struct exchange_info *ptr;
if ( remoteaddr == 0 )
{
if ( myinfo->expiration == 0 )
return(clonestr("{\"error\":\"need to unlock wallet\"}"));
if ( (ptr= exchanges777_info(exchange,1,json,remoteaddr)) != 0 )
return(exchanges777_Qrequest(ptr,'C',0,0,juint(json,"maxseconds"),calc_nxt64bits(orderid),0,0,json));
else return(clonestr("{\"error\":\"cant find or create exchange\"}"));
@ -1048,6 +1062,8 @@ STRING_ARG(InstantDEX,openorders,exchange)
struct exchange_info *ptr;
if ( remoteaddr == 0 )
{
if ( myinfo->expiration == 0 )
return(clonestr("{\"error\":\"need to unlock wallet\"}"));
if ( (ptr= exchanges777_info(exchange,1,json,remoteaddr)) != 0 )
return(exchanges777_Qrequest(ptr,'O',0,0,juint(json,"maxseconds"),0,0,0,json));
else return(clonestr("{\"error\":\"cant find or create exchange\"}"));
@ -1059,6 +1075,8 @@ STRING_ARG(InstantDEX,tradehistory,exchange)
struct exchange_info *ptr;
if ( remoteaddr == 0 )
{
if ( myinfo->expiration == 0 )
return(clonestr("{\"error\":\"need to unlock wallet\"}"));
if ( (ptr= exchanges777_info(exchange,1,json,remoteaddr)) != 0 )
return(exchanges777_Qrequest(ptr,'H',0,0,juint(json,"maxseconds"),0,0,0,json));
else return(clonestr("{\"error\":\"cant find or create exchange\"}"));
@ -1070,6 +1088,8 @@ THREE_STRINGS(InstantDEX,apikeypair,exchange,apikey,apisecret)
struct exchange_info *ptr;
if ( remoteaddr == 0 )
{
if ( myinfo->expiration == 0 )
return(clonestr("{\"error\":\"need to unlock wallet\"}"));
if ( (ptr= exchanges777_info(exchange,1,json,remoteaddr)) != 0 )
{
if ( apikey != 0 && apikey[0] != 0 && apisecret != 0 && apisecret[0] != 0 )
@ -1087,6 +1107,8 @@ THREE_STRINGS(InstantDEX,setuserid,exchange,userid,tradepassword)
struct exchange_info *ptr;
if ( remoteaddr == 0 )
{
if ( myinfo->expiration == 0 )
return(clonestr("{\"error\":\"need to unlock wallet\"}"));
if ( (ptr= exchanges777_info(exchange,1,json,remoteaddr)) != 0 )
{
safecopy(ptr->userid,userid,sizeof(ptr->userid));
@ -1101,6 +1123,8 @@ STRING_AND_INT(InstantDEX,pollgap,exchange,pollgap)
struct exchange_info *ptr;
if ( remoteaddr == 0 )
{
if ( myinfo->expiration == 0 )
return(clonestr("{\"error\":\"need to unlock wallet\"}"));
if ( (ptr= exchanges777_info(exchange,1,json,remoteaddr)) != 0 )
{
ptr->pollgap = pollgap;

3
iguana/iguana_instantdex.c

@ -320,7 +320,7 @@ bits256 instantdex_rwoffer(int32_t rwflag,int32_t *lenp,uint8_t *serialized,stru
char *instantdex_sendcmd(struct supernet_info *myinfo,struct instantdex_offer *offer,cJSON *argjson,char *cmdstr,bits256 desthash,int32_t hops,void *extraser,int32_t extralen)
{
char *reqstr; struct instantdex_msghdr *msg; bits256 orderhash; struct iguana_info *coin; struct iguana_peer *addr; int32_t i,j,r,olen,slen,datalen,max=-1; uint8_t serialized[sizeof(*offer) + sizeof(struct iguana_msghdr) + 4096]; uint64_t nxt64bits;
char *reqstr; struct instantdex_msghdr *msg; bits256 orderhash; struct iguana_info *coin; struct iguana_peer *addr; int32_t i,j,r,olen,slen,datalen,max=-1; uint8_t serialized[sizeof(*offer) + sizeof(struct iguana_msghdr) + 4096 + INSTANTDEX_DECKSIZE*33]; uint64_t nxt64bits;
category_subscribe(myinfo,myinfo->instantdex_category,GENESIS_PUBKEY);
jaddstr(argjson,"cmd",cmdstr);
jaddstr(argjson,"agent","SuperNET");
@ -817,7 +817,6 @@ int32_t instantdex_quote(struct supernet_info *myinfo,struct iguana_info *coin,s
if ( (ap= instantdex_quotefind(myinfo,coin,addr,encodedhash)) == 0 )
{
init_hexbytes_noT(hexstr,serialized,recvlen);
printf("quote send\n");
SuperNET_hexmsgadd(myinfo,myinfo->instantdex_category,GENESIS_PUBKEY,hexstr,tai_now(),addr->ipaddr);
}
else

2
iguana/iguana_msg.c

@ -294,7 +294,7 @@ void iguana_gotpong(struct iguana_info *coin,struct iguana_peer *addr,uint64_t n
{
addr->pingtime = (OS_milliseconds() - addr->sendmillis) + 1;
addr->pingsum += addr->pingtime, addr->numpings++;
printf("%s pingtime %.0f numpings.%d [%.3f] ",addr->ipaddr,addr->pingtime,addr->numpings,addr->pingsum/addr->numpings);
//printf("%s pingtime %.0f numpings.%d [%.3f] ",addr->ipaddr,addr->pingtime,addr->numpings,addr->pingsum/addr->numpings);
}
if ( nonce != addr->pingnonce )
{

26
iguana/iguana_wallet.c

@ -89,7 +89,7 @@ struct iguana_waddress *iguana_waddresscreate(struct supernet_info *myinfo,struc
{
HASH_ADD_KEYPTR(hh,wacct->waddr,waddr->coinaddr,len,waddr);
myinfo->dirty = (uint32_t)time(NULL);
printf("create (%s).%d scriptlen.%d -> (%s)\n",coinaddr,len,waddr->scriptlen,wacct->account);
//printf("create (%s).%d scriptlen.%d -> (%s)\n",coinaddr,len,waddr->scriptlen,wacct->account);
} else printf("error iguana_waddressalloc null waddr\n");
} //else printf("have (%s) in (%s)\n",coinaddr,wacct->account);
if ( (ptr= iguana_waddressfind(myinfo,coin,wacct,coinaddr)) != waddr )
@ -107,7 +107,7 @@ struct iguana_waddress *iguana_waddressadd(struct supernet_info *myinfo,struct i
{
HASH_ADD_KEYPTR(hh,wacct->waddr,waddr->coinaddr,len,waddr);
myinfo->dirty = (uint32_t)time(NULL);
printf("add (%s).%d scriptlen.%d -> (%s) wif.(%s)\n",waddr->coinaddr,len,waddr->scriptlen,wacct->account,waddr->wifstr);
//printf("add (%s).%d scriptlen.%d -> (%s) wif.(%s)\n",waddr->coinaddr,len,waddr->scriptlen,wacct->account,waddr->wifstr);
} else printf("error iguana_waddressalloc null waddr\n");
} //else printf("have (%s) in (%s)\n",waddr->coinaddr,wacct->account);
if ( (ptr= iguana_waddressfind(myinfo,coin,wacct,waddr->coinaddr)) != waddr )
@ -185,21 +185,21 @@ struct iguana_waddress *iguana_waddresssearch(struct supernet_info *myinfo,struc
return(0);
}
struct iguana_waddress *iguana_waddresscalc(struct supernet_info *myinfo,uint8_t pubtype,uint8_t wiftype,struct iguana_waddress *addr,bits256 privkey)
struct iguana_waddress *iguana_waddresscalc(struct supernet_info *myinfo,uint8_t pubtype,uint8_t wiftype,struct iguana_waddress *waddr,bits256 privkey)
{
addr->privkey = privkey;
bitcoin_pubkey33(myinfo->ctx,addr->pubkey,addr->privkey);
calc_rmd160_sha256(addr->rmd160,addr->pubkey,33);
bitcoin_address(addr->coinaddr,pubtype,addr->rmd160,sizeof(addr->rmd160));
waddr->privkey = privkey;
bitcoin_address(waddr->coinaddr,pubtype,waddr->rmd160,sizeof(waddr->rmd160));
if ( bits256_nonz(privkey) != 0 )
{
if ( bitcoin_priv2wif(addr->wifstr,addr->privkey,wiftype) > 0 )
bitcoin_pubkey33(myinfo->ctx,waddr->pubkey,waddr->privkey);
calc_rmd160_sha256(waddr->rmd160,waddr->pubkey,33);
if ( bitcoin_priv2wif(waddr->wifstr,waddr->privkey,wiftype) > 0 )
{
addr->wiftype = wiftype;
addr->addrtype = pubtype;
return(addr);
waddr->wiftype = wiftype;
waddr->addrtype = pubtype;
return(waddr);
}
} else printf("waddress_calc null privkey\n");
} else printf("waddress_calc.(%s) null privkey\n",waddr->coinaddr);
return(0);
}
@ -757,7 +757,7 @@ void iguana_walletinitcheck(struct supernet_info *myinfo,struct iguana_info *coi
}
child = child->next;
}
printf("account.(%s)\n",account);
//printf("account.(%s)\n",account);
}
item = item->next;
}

10
iguana/swaps/iguana_BTCswap.c

@ -398,22 +398,22 @@ cJSON *ALICE_claimbtcfunc(struct supernet_info *myinfo,struct exchange_info *exc
return(newjson);
}
bits256 instantdex_derivekeypair(bits256 *newprivp,uint8_t pubkey[33],bits256 privkey,bits256 orderhash)
bits256 instantdex_derivekeypair(struct supernet_info *myinfo,bits256 *newprivp,uint8_t pubkey[33],bits256 privkey,bits256 orderhash)
{
bits256 sharedsecret;
sharedsecret = curve25519_shared(privkey,orderhash);
vcalc_sha256cat(newprivp->bytes,orderhash.bytes,sizeof(orderhash),sharedsecret.bytes,sizeof(sharedsecret));
return(bitcoin_pubkey33(0,pubkey,*newprivp));
return(bitcoin_pubkey33(myinfo->ctx,pubkey,*newprivp));
}
int32_t instantdex_pubkeyargs(struct bitcoin_swapinfo *swap,cJSON *newjson,int32_t numpubs,bits256 privkey,bits256 hash,int32_t firstbyte)
int32_t instantdex_pubkeyargs(struct supernet_info *myinfo,struct bitcoin_swapinfo *swap,cJSON *newjson,int32_t numpubs,bits256 privkey,bits256 hash,int32_t firstbyte)
{
char buf[3]; int32_t i,n,m,len=0; bits256 pubi; uint64_t txid; uint8_t secret160[20],pubkey[33];
sprintf(buf,"%c0",'A' - 0x02 + firstbyte);
printf(">>>>>> start generating %s\n",buf);
for (i=n=m=0; i<numpubs*100 && n<numpubs; i++)
{
pubi = instantdex_derivekeypair(&swap->privkeys[n],pubkey,privkey,hash);
pubi = instantdex_derivekeypair(myinfo,&swap->privkeys[n],pubkey,privkey,hash);
privkey = swap->privkeys[n];
printf("i.%d n.%d numpubs.%d %02x vs %02x\n",i,n,numpubs,pubkey[0],firstbyte);
if ( pubkey[0] != firstbyte )
@ -593,7 +593,7 @@ cJSON *instantdex_parseargjson(struct supernet_info *myinfo,struct exchange_info
if ( juint(argjson,"verified") != 0 )
swap->otherverifiedcut = 1;
jaddnum(newjson,"verified",swap->otherverifiedcut);
if ( instantdex_pubkeyargs(swap,newjson,2 + deckflag*INSTANTDEX_DECKSIZE,myinfo->persistent_priv,swap->myorderhash,0x02+instantdex_isbob(swap)) == 2 + deckflag*INSTANTDEX_DECKSIZE )
if ( instantdex_pubkeyargs(myinfo,swap,newjson,2 + deckflag*INSTANTDEX_DECKSIZE,myinfo->persistent_priv,swap->myorderhash,0x02+instantdex_isbob(swap)) == 2 + deckflag*INSTANTDEX_DECKSIZE )
instantdex_getpubs(swap,argjson,newjson);
else printf("ERROR: couldnt generate pubkeys deckflag.%d\n",deckflag);
}

Loading…
Cancel
Save