Browse Source

Merge pull request #474 from jl777/spvdex

fix withdraw api (thanks! @decker)
etomic
jl777 7 years ago
committed by GitHub
parent
commit
516e839d23
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      iguana/exchanges/LP_nativeDEX.c
  2. 19
      iguana/exchanges/LP_network.c
  3. 6
      iguana/exchanges/LP_ordermatch.c
  4. 6
      iguana/exchanges/LP_transaction.c

12
iguana/exchanges/LP_nativeDEX.c

@ -17,8 +17,10 @@
// LP_nativeDEX.c
// marketmaker
//
// single utxo allocations, reject result, latency
// single utxo allocations alice, reject result, latency
// alice waiting for bestprice
//if ( G.LP_pendingswaps != 0 )
//return(-1);
// bot safe to exit?
//
// BCH signing
@ -313,8 +315,9 @@ char *LP_process_message(void *ctx,char *typestr,char *myipaddr,int32_t pubsock,
}
//printf("%.3f %s LP_command_process\n",OS_milliseconds()-millis,jstr(argjson,"method"));
}
free_json(argjson);
}
if ( argjson != 0 )
free_json(argjson);
}
} //else printf("DUPLICATE.(%s)\n",(char *)ptr);
portable_mutex_unlock(&LP_commandmutex);
@ -336,6 +339,7 @@ int32_t LP_sock_check(char *typestr,void *ctx,char *myipaddr,int32_t pubsock,int
pfd.events = NN_POLLIN;
if ( nn_poll(&pfd,1,1) != 1 )
break;
ptr = 0;
if ( (recvlen= nn_recv(sock,&ptr,NN_MSG,0)) > 0 )
{
methodstr[0] = 0;
@ -385,9 +389,9 @@ int32_t LP_sock_check(char *typestr,void *ctx,char *myipaddr,int32_t pubsock,int
free(str);
}
}
if ( ptr != 0 )
nn_freemsg(ptr), ptr = 0;
}
if ( ptr != 0 )
nn_freemsg(ptr), ptr = 0;
}
}
return(nonz);

19
iguana/exchanges/LP_network.c

@ -574,12 +574,19 @@ void LP_psockloop(void *_ptr) // printouts seem to be needed for forwarding to w
else if ( (pfds[n].revents & POLLIN) != 0 )
{
printf("publicsock.%d %s has pollin\n",ptr->publicsock,ptr->publicaddr);
buf = 0;
if ( (size= nn_recv(ptr->publicsock,&buf,NN_MSG,0)) > 0 )
{
ptr->lasttime = now;
sendsock = ptr->sendsock;
break;
}
else if ( buf != 0 )
{
nn_freemsg(buf);
buf = 0;
size = 0;
}
}
}
n++;
@ -606,12 +613,12 @@ void LP_psockloop(void *_ptr) // printouts seem to be needed for forwarding to w
sendsock = ptr->publicsock;
break;
}
else
{
nn_freemsg(buf);
buf = 0;
size = 0;
}
}
if ( buf != 0 )
{
nn_freemsg(buf);
buf = 0;
size = 0;
}
}
}

6
iguana/exchanges/LP_ordermatch.c

@ -799,7 +799,7 @@ int32_t LP_tradecommand(void *ctx,char *myipaddr,int32_t pubsock,cJSON *argjson,
return(retval);
}
LP_aliceid(Q.tradeid,Q.aliceid,"reserved",0,0);
printf("alice %s received RESERVED.(%s)\n",bits256_str(str,G.LP_mypub25519),jprint(argjson,0));
//printf("alice %s received RESERVED.(%s)\n",bits256_str(str,G.LP_mypub25519),jprint(argjson,0));
if ( (retstr= LP_quotereceived(argjson)) != 0 )
free(retstr);
LP_reserved(ctx,myipaddr,pubsock,&Q);
@ -929,7 +929,9 @@ int32_t LP_tradecommand(void *ctx,char *myipaddr,int32_t pubsock,cJSON *argjson,
printf("(%.8f %.8f) quote price %.8f too low vs %.8f for %s/%s %.8f < %.8f\n",bid,ask,qprice,price,Q.srccoin,Q.destcoin,qprice,(ask - 0.00000001) * 0.998);
return(retval);
}
char str[65],str2[65]; printf("(%s/v%d %s/v%d) TRADECOMMAND.(%s)\n",bits256_str(str,Q.txid),Q.vout,bits256_str(str2,Q.txid2),Q.vout2,jprint(argjson,0));
char *astr = jprint(argjson,0);
char str[65],str2[65]; printf("(%s/v%d %s/v%d) TRADECOMMAND.(%s)\n",bits256_str(str,Q.txid),Q.vout,bits256_str(str2,Q.txid2),Q.vout2,astr);
free(astr);
if ( strcmp(method,"request") == 0 ) // bob needs apayment + fee tx's
{
if ( LP_allocated(Q.txid,Q.vout) == 0 && LP_allocated(Q.txid2,Q.vout2) == 0 )

6
iguana/exchanges/LP_transaction.c

@ -1047,13 +1047,13 @@ char *LP_createrawtransaction(cJSON **txobjp,int32_t *numvinsp,struct iguana_inf
return(0);
}
}
if ( bits256_nonz(utxotxid) == 0 )
//if ( bits256_nonz(utxotxid) == 0 )
{
if ( (ap= LP_address_utxo_reset(coin)) == 0 )
return(0);
}
else if ( (ap= LP_address(coin,coin->smartaddr)) == 0 )
return(0);
//else if ( (ap= LP_address(coin,coin->smartaddr)) == 0 )
// return(0);
memset(utxos,0,sizeof(utxos));
if ( (numutxos= LP_address_utxo_ptrs(coin,0,utxos,max,ap,coin->smartaddr)) <= 0 )
{

Loading…
Cancel
Save