Browse Source

Test

etomic
jl777 8 years ago
parent
commit
57d6528c20
  1. 6
      basilisk/basilisk_swap.c
  2. 37
      basilisk/jumblr.c

6
basilisk/basilisk_swap.c

@ -550,7 +550,7 @@ int32_t _basilisk_rawtx_gen(char *str,struct supernet_info *myinfo,uint32_t swap
free(retarray);
} else printf("error parsing.(%s)\n",retstr);
free(retstr);
} else printf("error creating %s feetx\n",iambob != 0 ? "BOB" : "ALICE");
} else printf("error creating %s %s\n",iambob != 0 ? "BOB" : "ALICE",rawtx->name);
free_json(valsobj);
free(V);
return(retval);
@ -790,7 +790,7 @@ int32_t basilisk_alicepayment_spend(struct supernet_info *myinfo,struct basilisk
return(-1);
}
int32_t basilisk_bobpayment_spendclone(struct supernet_info *myinfo,struct iguana_info *bobcoin,struct basilisk_rawtx *dest,struct basilisk_rawtx *src,uint32_t swapstarted,uint8_t *changepubkey33,uint32_t quoteid,uint64_t amount,bits256 privAm,bits256 myprivs0,uint8_t *data,int32_t datalen,int32_t jumblrflag)
/*int32_t basilisk_bobpayment_spendclone(struct supernet_info *myinfo,struct iguana_info *bobcoin,struct basilisk_rawtx *dest,struct basilisk_rawtx *src,uint32_t swapstarted,uint8_t *changepubkey33,uint32_t quoteid,uint64_t amount,bits256 privAm,bits256 myprivs0,uint8_t *data,int32_t datalen,int32_t jumblrflag)
{
bits256 revAm; uint8_t userdata[512]; int32_t i,len,numconfirms = 0,retval = -1; uint32_t sequenceid = 0xffffffff;
basilisk_rawtx_setparms("bobpayment",quoteid,src,bobcoin,numconfirms,0,amount,3,0,jumblrflag);
@ -878,7 +878,7 @@ int32_t basilisk_alicepayment_spendclone(struct supernet_info *myinfo,struct igu
}
return(retval);
}
}*/
int32_t basilisk_verify_alicepaid(struct supernet_info *myinfo,void *ptr,uint8_t *data,int32_t datalen)
{

37
basilisk/jumblr.c

@ -577,9 +577,9 @@ int32_t jumblr_utxotxidpending(struct supernet_info *myinfo,bits256 *splittxidp,
return(-1);
}
void jumblr_utxotxidpendingadd(struct supernet_info *myinfo,struct iguana_info *coin,bits256 txid,int32_t vout,bits256 splittxid,int32_t ind)
void jumblr_utxotxidpendingadd(struct supernet_info *myinfo,char *dest,struct iguana_info *coin,bits256 txid,int32_t vout,uint64_t value,bits256 splittxid,int32_t ind,double price,double estfee)
{
struct jumblr_pending pend;
struct jumblr_pending pend; cJSON *vals,*retjson; bits256 hash; char *retstr;
memset(&pend,0,sizeof(pend));
pend.splittxid = splittxid;
pend.txid = txid;
@ -587,9 +587,32 @@ void jumblr_utxotxidpendingadd(struct supernet_info *myinfo,struct iguana_info *
pend.ind = ind;
coin->DEXinfo.pending = realloc(coin->DEXinfo.pending,sizeof(*coin->DEXinfo.pending) * (1 + coin->DEXinfo.numpending));
coin->DEXinfo.pending[coin->DEXinfo.numpending++] = pend;
if ( ind < 3 )
{
if ( price > SMALLVAL )
{
vals = cJSON_CreateObject();
jaddstr(vals,"source",coin->symbol);
jaddstr(vals,"dest",dest);
jaddnum(vals,"amount",dstr(value));
jaddnum(vals,"minprice",price);
jaddnum(vals,"usejumblr",1);
memset(hash.bytes,0,sizeof(hash));
if ( (retstr= InstantDEX_request(myinfo,coin,0,0,hash,vals,"")) != 0 )
{
if ( (retjson= cJSON_Parse(retstr)) != 0 )
{
printf("request.(%s) -> (%s)\n",jprint(vals,0),retstr);
free_json(retjson);
}
free(retstr);
}
free_json(vals);
}
}
}
void jumblr_utxoupdate(struct supernet_info *myinfo,struct iguana_info *coin,double price,char *coinaddr,bits256 privkey,double estfee)
void jumblr_utxoupdate(struct supernet_info *myinfo,char *dest,struct iguana_info *coin,double price,char *coinaddr,bits256 privkey,double estfee)
{
char *retstr; cJSON *array,*item; int32_t i,n,vout,ind; bits256 txid,splittxid; uint64_t value;
if ( (retstr= jumblr_listunspent(myinfo,coin,coinaddr)) != 0 )
@ -609,7 +632,7 @@ void jumblr_utxoupdate(struct supernet_info *myinfo,struct iguana_info *coin,dou
if ( jumblr_utxotxidpending(myinfo,&splittxid,&ind,coin,txid,vout) < 0 )
{
ind = jumblr_DEXutxoupdate(myinfo,coin,&splittxid,coinaddr,privkey,txid,vout,value,myinfo->IAMLP,price,estfee);
jumblr_utxotxidpendingadd(myinfo,coin,txid,vout,splittxid,ind);
jumblr_utxotxidpendingadd(myinfo,dest,coin,txid,vout,value,splittxid,ind,price,estfee);
} //else printf("already have txid\n");
}
}
@ -655,14 +678,14 @@ void jumblr_DEXupdate(struct supernet_info *myinfo,struct iguana_info *coin,char
ptr->kmdprice = 1.;
ptr->KMDavail = ptr->avail;
if ( (btccoin= iguana_coinfind("BTC")) != 0 )
jumblr_utxoupdate(myinfo,btccoin,ptr->btcprice,ptr->depositaddr,ptr->deposit_privkey,estbtcfee);
jumblr_utxoupdate(myinfo,kmdcoin,1.,ptr->KMDdepositaddr,ptr->deposit_privkey,estfee);
jumblr_utxoupdate(myinfo,"KMD",btccoin,ptr->btcprice,ptr->depositaddr,ptr->deposit_privkey,estbtcfee);
jumblr_utxoupdate(myinfo,"BTC",kmdcoin,1.,ptr->KMDdepositaddr,ptr->deposit_privkey,estfee);
}
else if ( (ptr->BTC2KMD= BTC2KMD) > SMALLVAL )
{
ptr->kmdprice = ptr->btcprice / BTC2KMD;
ptr->KMDavail = KMDavail;
jumblr_utxoupdate(myinfo,ptr->coin,ptr->kmdprice,ptr->depositaddr,ptr->deposit_privkey,estfee);
jumblr_utxoupdate(myinfo,"KMD",ptr->coin,ptr->kmdprice,ptr->depositaddr,ptr->deposit_privkey,estfee);
}
ptr->lasttime = (uint32_t)time(NULL);
} // else printf("skip\n");

Loading…
Cancel
Save