From 4f0087bd280793beb701139975742a5bfefe0f9e Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 27 Jun 2016 15:37:25 -0300 Subject: [PATCH] test --- basilisk/basilisk_CMD.c | 11 ++++++++--- iguana/iguana_instantdex.c | 8 +++++++- iguana/iguana_unspents.c | 8 ++++---- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/basilisk/basilisk_CMD.c b/basilisk/basilisk_CMD.c index fa67a5e94..51e857a47 100755 --- a/basilisk/basilisk_CMD.c +++ b/basilisk/basilisk_CMD.c @@ -126,9 +126,14 @@ void basilisk_request_goodbye(struct supernet_info *myinfo) char *basilisk_respond_instantdex(struct supernet_info *myinfo,char *CMD,void *addr,char *remoteaddr,uint32_t basilisktag,cJSON *valsobj,uint8_t *data,int32_t datalen,bits256 hash,int32_t from_basilisk) { - char *retstr=0; - printf("from.(%s) DEX.(%s) datalen.%d\n",remoteaddr,jprint(valsobj,0),datalen); - instantdex_quotep2p(myinfo,0,addr,data,datalen); + char *dest,*src,*retstr=0; uint64_t satoshis; + if ( (dest= jstr(valsobj,"dest")) != 0 && (src= jstr(valsobj,"src")) != 0 && (satoshis= j64bits(valsobj,"satoshis")) != 0 ) + { + char str[65]; printf("DEX.(%s %.8f) -> %s %s\n",src,dstr(satoshis),dest,bits256_str(str,hash)); + + retstr = clonestr("{\"result\":\"DEX quote added\"}"); + } + //instantdex_quotep2p(myinfo,0,addr,data,datalen); return(retstr); } diff --git a/iguana/iguana_instantdex.c b/iguana/iguana_instantdex.c index a118dfcac..0c8c468a3 100755 --- a/iguana/iguana_instantdex.c +++ b/iguana/iguana_instantdex.c @@ -1735,7 +1735,13 @@ STRING_ARG(InstantDEX,available,source) THREE_STRINGS_AND_DOUBLE(InstantDEX,request,message,dest,source,amount) { - return(clonestr("{\"result\":\"this will request converting amount worth of source into dest\"}")); + char *retstr; cJSON *vals = cJSON_CreateObject(); + jaddstr(vals,"dest",dest); + jaddstr(vals,"src",source); + jadd64bits(vals,"satoshis",amount * SATOSHIDEN); + retstr = basilisk_standardservice("DEX",myinfo,0,myinfo->myaddr.persistent,vals,"",1); + free_json(vals); + return(retstr); } INT_ARG(InstantDEX,incoming,requestid) diff --git a/iguana/iguana_unspents.c b/iguana/iguana_unspents.c index d142f87b7..7bf34f394 100755 --- a/iguana/iguana_unspents.c +++ b/iguana/iguana_unspents.c @@ -40,7 +40,7 @@ int32_t iguana_unspentindfind(struct iguana_info *coin,char *coinaddr,uint8_t *s { RTspend = 0; flag++; - if ( iguana_spentflag(coin,&RTspend,&spentheight,&bp->ramchain,bp->hdrsi,unspentind,0,1,coin->longestchain,U[unspentind].value) == 0 ) //bp == coin->current ? &coin->RTramchain : + if ( iguana_spentflag(coin,&RTspend,&spentheight,bp == coin->current ? &coin->RTramchain : &bp->ramchain,bp->hdrsi,unspentind,0,1,coin->longestchain,U[unspentind].value) == 0 ) // { if ( valuep != 0 ) *valuep = U[unspentind].value; @@ -161,7 +161,7 @@ struct iguana_pkhash *iguana_pkhashfind(struct iguana_info *coin,struct iguana_r printf("iguana_pkhashfind: unexpected access when RTramchain_busy\n"); return(0); } - ramchain = &bp->ramchain;//(bp != coin->current) ? &bp->ramchain : &coin->RTramchain; + ramchain = (bp != coin->current) ? &bp->ramchain : &coin->RTramchain; if ( (rdata= ramchain->H.data) != 0 ) { numpkinds = rdata->numpkinds; @@ -457,7 +457,7 @@ int32_t iguana_uvaltxid(struct supernet_info *myinfo,bits256 *txidp,struct iguan struct iguana_bundle *bp; struct iguana_unspent *U,*u; struct iguana_txid *T; struct iguana_ramchain *ramchain; struct iguana_ramchaindata *rdata; if ( (bp= coin->bundles[hdrsi]) == 0 ) return(-1); - ramchain = &bp->ramchain;//(bp == coin->current) ? &coin->RTramchain : &bp->ramchain; + ramchain = (bp == coin->current) ? &coin->RTramchain : &bp->ramchain; if ( (rdata= ramchain->H.data) != 0 ) { U = RAMCHAIN_PTR(rdata,Uoffset); @@ -482,7 +482,7 @@ int64_t iguana_unspentavail(struct iguana_info *coin,uint64_t hdrsi_unspentind,i return(-1); hdrsi = (int16_t)(hdrsi_unspentind >> 32); unspentind = (uint32_t)hdrsi_unspentind; - ramchain = &bp->ramchain;//(bp == coin->current) ? &coin->RTramchain : &bp->ramchain; + ramchain = (bp == coin->current) ? &coin->RTramchain : &bp->ramchain; if ( (rdata= ramchain->H.data) == 0 ) return(0); if ( (spentflag= iguana_spentflag(coin,&RTspend,&spentheight,ramchain,hdrsi,unspentind,0,minconf,maxconf,0)) > 0 )