@ -494,7 +494,7 @@ int32_t LP_connectstartbob(void *ctx,int32_t pubsock,char *base,char *rel,double
}
if ( bits256_nonz ( privkey ) ! = 0 & & bits256_cmp ( G . LP_mypub25519 , qp - > srchash ) = = 0 )
{
LP_requestinit ( & qp - > R , qp - > srchash , qp - > desthash , base , qp - > satoshis - qp - > txfee , rel , qp - > destsatoshis - qp - > desttxfee , qp - > timestamp , qp - > quotetime , DEXselector ) ;
LP_requestinit ( & qp - > R , qp - > srchash , qp - > desthash , base , qp - > satoshis - qp - > txfee , rel , qp - > destsatoshis - qp - > desttxfee , qp - > timestamp , qp - > quotetime , DEXselector , qp - > fill , qp - > gtc ) ;
dtrust = LP_dynamictrust ( qp - > othercredits , qp - > desthash , LP_kmdvalue ( qp - > destcoin , qp - > destsatoshis ) ) ;
if ( ( swap = LP_swapinit ( 1 , 0 , privkey , & qp - > R , qp , dtrust > 0 ) ) = = 0 )
{
@ -653,7 +653,7 @@ char *LP_connectedalice(struct LP_quoteinfo *qp,char *pairstr) // alice
return ( clonestr ( " { \" result \" , \" update stats \" } " ) ) ;
}
printf ( " CONNECTED numpending.%d tradeid.%u requestid.%u quoteid.%u pairstr.%s \n " , G . LP_pendingswaps , qp - > tradeid , qp - > R . requestid , qp - > R . quoteid , pairstr ! = 0 ? pairstr : " " ) ;
LP_requestinit ( & qp - > R , qp - > srchash , qp - > desthash , qp - > srccoin , qp - > satoshis - qp - > txfee , qp - > destcoin , qp - > destsatoshis - qp - > desttxfee , qp - > timestamp , qp - > quotetime , DEXselector ) ;
LP_requestinit ( & qp - > R , qp - > srchash , qp - > desthash , qp - > srccoin , qp - > satoshis - qp - > txfee , qp - > destcoin , qp - > destsatoshis - qp - > desttxfee , qp - > timestamp , qp - > quotetime , DEXselector , qp - > fill , qp - > gtc ) ;
//printf("calculated requestid.%u quoteid.%u\n",qp->R.requestid,qp->R.quoteid);
memset ( & LP_Alicereserved , 0 , sizeof ( LP_Alicereserved ) ) ;
LP_aliceid ( qp - > tradeid , qp - > aliceid , " connected " , qp - > R . requestid , qp - > R . quoteid ) ;
@ -1380,7 +1380,7 @@ int32_t LP_tradecommand(void *ctx,char *myipaddr,int32_t pubsock,cJSON *argjson,
}
if ( Q . satoshis < Q . txfee )
return ( 1 ) ;
LP_requestinit ( & Q . R , Q . srchash , Q . desthash , Q . srccoin , Q . satoshis - Q . txfee , Q . destcoin , Q . destsatoshis - Q . desttxfee , Q . timestamp , Q . quotetime , DEXselector ) ;
LP_requestinit ( & Q . R , Q . srchash , Q . desthash , Q . srccoin , Q . satoshis - Q . txfee , Q . destcoin , Q . destsatoshis - Q . desttxfee , Q . timestamp , Q . quotetime , DEXselector , Q . fill , Q . gtc ) ;
rq = ( ( uint64_t ) Q . R . requestid < < 32 ) | Q . R . quoteid ;
if ( Q . uuidstr [ 0 ] = = 0 | | ( Q . timestamp > 0 & & time ( NULL ) > Q . timestamp + LP_AUTOTRADE_TIMEOUT * 20 ) ) // eat expired packets, some old timestamps floating about?
{
@ -1390,7 +1390,7 @@ int32_t LP_tradecommand(void *ctx,char *myipaddr,int32_t pubsock,cJSON *argjson,
LP_tradecommand_log ( argjson ) ;
qprice = ( double ) Q . destsatoshis / ( Q . satoshis - Q . txfee ) ; //jdouble(argjson,"price");
//printf("%s\n",jprint(argjson,0));
printf ( " %-4d uuid.%32s %12s %5s/%-5s %12.8f -> %12.8f (%11.8f) | RT.%d %d n%d \n " , ( uint32_t ) time ( NULL ) % 3600 , Q . uuidstr + 32 , method , Q . srccoin , Q . destcoin , dstr ( Q . satoshis ) , dstr ( Q . destsatoshis ) , qprice , LP_RTcount , LP_swapscount , G . netid ) ;
printf ( " %-4d uuid.%32s g.%d f.%d %12s %5s/%-5s %12.8f -> %12.8f (%11.8f) | RT.%d %d n%d \n " , ( uint32_t ) time ( NULL ) % 3600 , Q . uuidstr + 32 , Q . gtc , Q . fill , method , Q . srccoin , Q . destcoin , dstr ( Q . satoshis ) , dstr ( Q . destsatoshis ) , qprice , LP_RTcount , LP_swapscount , G . netid ) ;
retval = 1 ;
aliceid = j64bits ( argjson , " aliceid " ) ;
if ( strcmp ( method , " reserved " ) = = 0 )
@ -1503,7 +1503,7 @@ int32_t LP_tradecommand(void *ctx,char *myipaddr,int32_t pubsock,cJSON *argjson,
return ( retval ) ;
}
char * LP_autobuy ( void * ctx , int32_t fomoflag , char * myipaddr , int32_t mypubsock , char * base , char * rel , double maxprice , double relvolume , int32_t timeout , int32_t duration , char * gui , uint32_t nonce , bits256 destpubkey , uint32_t tradeid , char * uuidstr )
char * LP_autobuy ( void * ctx , int32_t fomoflag , char * myipaddr , int32_t mypubsock , char * base , char * rel , double maxprice , double relvolume , int32_t timeout , int32_t duration , char * gui , uint32_t nonce , bits256 destpubkey , uint32_t tradeid , char * uuidstr , int32_t fillflag , int32_t gtcflag )
{
uint64_t desttxfee , txfee , balance ; uint32_t lastnonce ; int64_t bestsatoshis = 0 , destsatoshis ; struct iguana_info * basecoin , * relcoin ; struct LP_utxoinfo * autxo , B , A ; struct LP_quoteinfo Q ; bits256 pubkeys [ 100 ] ; struct LP_address_utxo * utxos [ 4096 ] ; int32_t num = 0 , maxiters = 100 , i , max = ( int32_t ) ( sizeof ( utxos ) / sizeof ( * utxos ) ) ; char _uuidstr [ 65 ] ;
basecoin = LP_coinfind ( base ) ;
@ -1590,6 +1590,10 @@ char *LP_autobuy(void *ctx,int32_t fomoflag,char *myipaddr,int32_t mypubsock,cha
memset ( & A , 0 , sizeof ( A ) ) ;
if ( ( autxo = LP_address_myutxopair ( & A , 0 , utxos , max , relcoin , relcoin - > smartaddr , txfee , dstr ( destsatoshis ) , maxprice , desttxfee ) ) ! = 0 )
break ;
if ( fillflag ! = 0 )
{
return ( clonestr ( " { \" error \" : \" cant find a deposit that is big enough in size. make another deposit that is just a bit larger than what you want to trade \" } " ) ) ;
}
destsatoshis * = 0.98 ;
if ( destsatoshis < desttxfee * LP_MINSIZE_TXFEEMULT )
break ;
@ -1641,6 +1645,8 @@ char *LP_autobuy(void *ctx,int32_t fomoflag,char *myipaddr,int32_t mypubsock,cha
}
}
int32_t changed ;
Q . gtcflag = gtcflag ;
Q . fillflag = fillflag ;
LP_mypriceset ( & changed , rel , base , 1. / maxprice ) ;
LP_mypriceset ( & changed , base , rel , 0. ) ;
if ( uuidstr = = 0 | | uuidstr [ 0 ] = = 0 )