diff --git a/iguana/iguana_instantdex.c b/iguana/iguana_instantdex.c index 1ba320bf8..34f18e652 100755 --- a/iguana/iguana_instantdex.c +++ b/iguana/iguana_instantdex.c @@ -74,7 +74,7 @@ struct instantdex_msghdr *instantdex_msgcreate(struct supernet_info *myinfo,stru return(0); } -bits256 instantdex_rwoffer(int32_t rwflag,uint8_t *serialized,struct instantdex_offer *offer) +bits256 instantdex_rwoffer(int32_t rwflag,int32_t *lenp,uint8_t *serialized,struct instantdex_offer *offer) { bits256 orderhash; int32_t len = 0; if ( rwflag == 0 ) @@ -97,17 +97,18 @@ bits256 instantdex_rwoffer(int32_t rwflag,uint8_t *serialized,struct instantdex_ if ( rwflag != 0 ) { int32_t i; - for (i=0; ihandle); jaddbits256(argjson,"categoryhash",instantdexhash); jaddbits256(argjson,"traderpub",myinfo->myaddr.persistent); + jadd64bits(argjson,"id",orderhash.txid); + orderhash = instantdex_rwoffer(1,&olen,serialized,offer); nxt64bits = acct777_nxt64bits(myinfo->myaddr.persistent); reqstr = jprint(argjson,0); - datalen = (int32_t)(strlen(reqstr) + 1 + extralen + sizeof(*offer)); - msg = calloc(1,sizeof(*msg) + datalen + extralen + sizeof(*offer)); - orderhash = instantdex_rwoffer(1,serialized,offer); - jadd64bits(argjson,"id",orderhash.txid); + datalen = (int32_t)(strlen(reqstr) + 1 + extralen + olen); + msg = calloc(1,sizeof(*msg) + datalen + extralen + olen); for (i=0; icmd); i++) if ( (msg->cmd[i]= cmdstr[i]) == 0 ) break; memcpy(msg->serialized,reqstr,datalen); - memcpy(&msg->serialized[datalen],serialized,sizeof(serialized)); - memcpy(&msg->serialized[datalen + sizeof(serialized)],extraser,extralen); + memcpy(&msg->serialized[datalen],serialized,olen); + memcpy(&msg->serialized[datalen + olen],extraser,extralen); free(reqstr); if ( instantdex_msgcreate(myinfo,msg,datalen) != 0 ) { @@ -515,7 +516,7 @@ char *instantdex_parse(struct supernet_info *myinfo,struct instantdex_msghdr *ms char *InstantDEX_hexmsg(struct supernet_info *myinfo,void *ptr,int32_t len,char *remoteaddr) { - struct instantdex_msghdr *msg = ptr; cJSON *argjson; int32_t i,slen,num,datalen,newlen,flag = 0; + struct instantdex_msghdr *msg = ptr; cJSON *argjson; int32_t i,olen,slen,num,datalen,newlen,flag = 0; uint8_t *serdata; struct supernet_info *myinfos[64]; struct instantdex_offer rawoffer; bits256 orderhash; uint64_t signerbits; uint8_t tmp[sizeof(msg->sig)]; char *retstr = 0; cJSON *retjson,*item; acct777_rwsig(0,(void *)&msg->sig,(void *)tmp); @@ -544,9 +545,9 @@ char *InstantDEX_hexmsg(struct supernet_info *myinfo,void *ptr,int32_t len,char } if ( newlen >= sizeof(rawoffer) ) { - orderhash = instantdex_rwoffer(0,&msg->serialized[slen],&rawoffer); + orderhash = instantdex_rwoffer(0,&olen,&msg->serialized[slen],&rawoffer); printf("received orderhash.%llu\n",(long long)orderhash.txid); - newlen -= sizeof(rawoffer); + newlen -= olen; } if ( newlen <= 0 ) serdata = 0, newlen = 0; diff --git a/iguana/swaps/iguana_BTCswap.c b/iguana/swaps/iguana_BTCswap.c index ef24237ca..49a112cea 100755 --- a/iguana/swaps/iguana_BTCswap.c +++ b/iguana/swaps/iguana_BTCswap.c @@ -522,7 +522,7 @@ char *instantdex_BTCswap(struct supernet_info *myinfo,struct exchange_info *exch { if ( A->offer.expiration < (time(NULL) + INSTANTDEX_DURATION) ) return(clonestr("{\"error\":\"instantdex_BTCswap offer too close to expiration\"}")); - if ( (ap= instantdex_acceptable(myinfo,exchange,A,traderpub.txid,minperc)) != 0 ) + if ( (ap= instantdex_acceptable(myinfo,exchange,A,acct777_nxt64bits(traderpub),minperc)) != 0 ) { char str[65]; printf("FOUND MATCH! %p (%s/%s) other.%s\n",A->info,A->offer.base,A->offer.rel,bits256_str(str,traderpub)); if ( A->info == 0 )