@ -71,12 +71,12 @@ uint64_t LP_txfeecalc(struct iguana_info *coin,uint64_t txfee,int32_t txlen)
if ( txlen = = 0 )
if ( txlen = = 0 )
txlen = LP_AVETXSIZE ;
txlen = LP_AVETXSIZE ;
coin - > rate = LP_getestimatedrate ( coin ) ;
coin - > rate = LP_getestimatedrate ( coin ) ;
if ( ( txfee = SATOSHIDEN * coin - > rate * txlen ) < = LP_MIN_TXFEE )
if ( ( txfee = SATOSHIDEN * coin - > rate * txlen ) < = 10000 )
{
{
coin - > rate = - 1. ;
//coin->rate = -1.;
coin - > rate = _LP_getestimatedrate ( coin ) ;
coin - > rate = _LP_getestimatedrate ( coin ) ;
if ( ( txfee = SATOSHIDEN * coin - > rate * txlen ) < = LP_MIN_TXFEE )
if ( ( txfee = SATOSHIDEN * coin - > rate * txlen ) < = 10000 )
txfee = LP_MIN_TXFEE ;
txfee = 10000 ;
}
}
} else txfee = coin - > txfee ;
} else txfee = coin - > txfee ;
if ( txfee < LP_MIN_TXFEE )
if ( txfee < LP_MIN_TXFEE )
@ -182,16 +182,19 @@ double LP_quote_validate(struct LP_utxoinfo *autxo,struct LP_utxoinfo *butxo,str
printf ( " srcvalue %.8f [%.8f] satoshis %.8f is too small txfee %.8f? \n " , dstr ( srcvalue ) , dstr ( srcvalue ) - dstr ( qp - > txfee + qp - > satoshis ) , dstr ( qp - > satoshis ) , dstr ( qp - > txfee ) ) ;
printf ( " srcvalue %.8f [%.8f] satoshis %.8f is too small txfee %.8f? \n " , dstr ( srcvalue ) , dstr ( srcvalue ) - dstr ( qp - > txfee + qp - > satoshis ) , dstr ( qp - > satoshis ) , dstr ( qp - > txfee ) ) ;
return ( - 33 ) ;
return ( - 33 ) ;
}
}
if ( qp - > satoshis ! = 0 )
qprice = ( ( double ) qp - > destsatoshis / ( qp - > satoshis - qp - > txfee ) ) ;
LP_txfees ( & txfee , & desttxfee , qp - > srccoin , qp - > destcoin ) ;
LP_txfees ( & txfee , & desttxfee , qp - > srccoin , qp - > destcoin ) ;
if ( txfee < qp - > txfee )
if ( txfee < qp - > txfee )
txfee = qp - > txfee ;
txfee = qp - > txfee ;
if ( desttxfee < qp - > desttxfee )
if ( desttxfee < qp - > desttxfee )
desttxfee = qp - > desttxfee ;
desttxfee = qp - > desttxfee ;
if ( qp - > satoshis ! = 0 )
qprice = ( ( double ) qp - > destsatoshis / ( qp - > satoshis - qp - > txfee ) ) ;
//printf("qprice %.8f <- %.8f/%.8f txfees.(%.8f %.8f) vs (%.8f %.8f)\n",qprice,dstr(qp->destsatoshis),dstr(qp->satoshis),dstr(qp->txfee),dstr(qp->desttxfee),dstr(txfee),dstr(desttxfee));
//printf("qprice %.8f <- %.8f/%.8f txfees.(%.8f %.8f) vs (%.8f %.8f)\n",qprice,dstr(qp->destsatoshis),dstr(qp->satoshis),dstr(qp->txfee),dstr(qp->desttxfee),dstr(txfee),dstr(desttxfee));
if ( qp - > txfee < LP_REQUIRED_TXFEE * txfee | | qp - > desttxfee < LP_REQUIRED_TXFEE * desttxfee )
if ( qp - > txfee < LP_REQUIRED_TXFEE * txfee | | qp - > desttxfee < LP_REQUIRED_TXFEE * desttxfee )
{
printf ( " error -14: txfee %.8f < %.8f or desttxfee %.8f < %.8f \n " , dstr ( qp - > txfee ) , dstr ( LP_REQUIRED_TXFEE * txfee ) , dstr ( qp - > desttxfee ) , dstr ( LP_REQUIRED_TXFEE * desttxfee ) ) ;
return ( - 14 ) ;
return ( - 14 ) ;
}
if ( butxo ! = 0 )
if ( butxo ! = 0 )
{
{
if ( qp - > satoshis < ( srcvalue / LP_MINVOL ) | | srcvalue < qp - > txfee * LP_MINSIZE_TXFEEMULT )
if ( qp - > satoshis < ( srcvalue / LP_MINVOL ) | | srcvalue < qp - > txfee * LP_MINSIZE_TXFEEMULT )
@ -449,14 +452,15 @@ struct LP_utxoinfo *LP_address_myutxopair(struct LP_utxoinfo *butxo,int32_t iamb
if ( targetval = = 0 | | mini < 0 )
if ( targetval = = 0 | | mini < 0 )
break ;
break ;
}
}
} else printf ( " no %s %s utxos pass LP_address_utxo_ptrs filter targets %.8f %.8f \n " , coin - > symbol , coinaddr , dstr ( targetval ) , dstr ( targetval2 ) ) ;
} //else printf("no %s %s utxos pass LP_address_utxo_ptrs filter %.8f %.8f\n",coin->symbol,coinaddr,dstr(targetval),dstr(targetval2));
} else printf ( " address_myutxopair couldnt find %s %s \n " , coin - > symbol , coinaddr ) ;
}
printf ( " address_myutxopair couldnt find %s %s targets %.8f %.8f \n " , coin - > symbol , coinaddr , dstr ( targetval ) , dstr ( targetval2 ) ) ;
return ( 0 ) ;
return ( 0 ) ;
}
}
int32_t LP_connectstartbob ( void * ctx , int32_t pubsock , char * base , char * rel , double price , struct LP_quoteinfo * qp )
int32_t LP_connectstartbob ( void * ctx , int32_t pubsock , char * base , char * rel , double price , struct LP_quoteinfo * qp )
{
{
char pairstr [ 512 ] , otheraddr [ 64 ] ; cJSON * reqjson ; bits256 privkey ; int32_t pair = - 1 , retval = - 1 , DEXselector = 0 ; int64_t dtrust ; struct basilisk_swap * swap ; struct iguana_info * ecoin , * coin , * kmdcoin ;
char pairstr [ 512 ] , otheraddr [ 64 ] ; cJSON * reqjson ; bits256 privkey ; int32_t i , pair = - 1 , retval = - 1 , DEXselector = 0 ; int64_t dtrust ; struct basilisk_swap * swap ; struct iguana_info * ecoin , * coin , * kmdcoin ;
qp - > quotetime = ( uint32_t ) time ( NULL ) ;
qp - > quotetime = ( uint32_t ) time ( NULL ) ;
if ( ( coin = LP_coinfind ( qp - > srccoin ) ) = = 0 )
if ( ( coin = LP_coinfind ( qp - > srccoin ) ) = = 0 )
{
{
@ -496,12 +500,17 @@ int32_t LP_connectstartbob(void *ctx,int32_t pubsock,char *base,char *rel,double
//char str[65]; printf("BOB pubsock.%d binds to %d (%s)\n",pubsock,pair,bits256_str(str,qp->desthash));
//char str[65]; printf("BOB pubsock.%d binds to %d (%s)\n",pubsock,pair,bits256_str(str,qp->desthash));
bits256 zero ;
bits256 zero ;
memset ( zero . bytes , 0 , sizeof ( zero ) ) ;
memset ( zero . bytes , 0 , sizeof ( zero ) ) ;
for ( i = 0 ; i < 10 ; i + + )
{
LP_reserved_msg ( 1 , qp - > srccoin , qp - > destcoin , qp - > desthash , jprint ( reqjson , 0 ) ) ;
LP_reserved_msg ( 1 , qp - > srccoin , qp - > destcoin , qp - > desthash , jprint ( reqjson , 0 ) ) ;
LP_reserved_msg ( 1 , qp - > srccoin , qp - > destcoin , zero , jprint ( reqjson , 0 ) ) ;
sleep ( 3 ) ;
if ( 0 )
if ( swap - > received ! = 0 )
{
{
LP_reserved_msg ( 1 , base , rel , zero , jprint ( reqjson , 0 ) ) ;
printf ( " swap %u-%u has started t%u \n " , swap - > I . req . requestid , swap - > I . req . quoteid , swap - > received ) ;
LP_reserved_msg ( 0 , base , rel , zero , jprint ( reqjson , 0 ) ) ;
break ;
}
printf ( " bob tries %u-%u again i.%d \n " , swap - > I . req . requestid , swap - > I . req . quoteid , i ) ;
LP_reserved_msg ( 1 , qp - > srccoin , qp - > destcoin , zero , jprint ( reqjson , 0 ) ) ;
}
}
free_json ( reqjson ) ;
free_json ( reqjson ) ;
LP_importaddress ( qp - > destcoin , qp - > destaddr ) ;
LP_importaddress ( qp - > destcoin , qp - > destaddr ) ;
@ -841,7 +850,7 @@ double LP_trades_pricevalidate(struct LP_quoteinfo *qp,struct iguana_info *coin,
}
}
if ( qprice < ( price - 0.00000001 ) * 0.998 )
if ( qprice < ( price - 0.00000001 ) * 0.998 )
{
{
printf ( " quote price %.8f too low vs %.8f for %s/%s %.8f < %.8f \n " , qprice , price , qp - > srccoin , qp - > destcoin , q price, ( price - 0.00000001 ) * 0.998 ) ;
printf ( " quote price %.8f (%llu/%llu %.8f) too low vs %.8f for %s/%s price %.8f %.8f \n " , qprice , ( long long ) qp - > destsatoshis , ( long long ) ( qp - > satoshis - qp - > txfee ) , ( double ) qp - > destsatoshis / ( qp - > satoshis - qp - > txfee ) , price , qp - > srccoin , qp - > destcoin , price , ( price - 0.00000001 ) * 0.998 ) ;
return ( - 77 ) ;
return ( - 77 ) ;
}
}
return ( qprice ) ;
return ( qprice ) ;
@ -849,7 +858,7 @@ double LP_trades_pricevalidate(struct LP_quoteinfo *qp,struct iguana_info *coin,
struct LP_quoteinfo * LP_trades_gotrequest ( void * ctx , struct LP_quoteinfo * qp , struct LP_quoteinfo * newqp , char * pairstr )
struct LP_quoteinfo * LP_trades_gotrequest ( void * ctx , struct LP_quoteinfo * qp , struct LP_quoteinfo * newqp , char * pairstr )
{
{
double price , qprice , myprice , bestprice , range , bid , ask ; struct iguana_info * coin , * othercoin ; struct LP_utxoinfo A , B , * autxo , * butxo ; cJSON * reqjson ; char str [ 65 ] ; struct LP_address_utxo * utxos [ 1000 ] ; int32_t r , counter , max = ( int32_t ) ( sizeof ( utxos ) / sizeof ( * utxos ) ) ;
double price = 0. , p = 0. , qprice , myprice , bestprice , range , bid , ask ; struct iguana_info * coin , * othercoin ; struct LP_utxoinfo A , B , * autxo , * butxo ; cJSON * reqjson ; char str [ 65 ] ; struct LP_address_utxo * utxos [ 1000 ] ; int32_t i , r , counter , max = ( int32_t ) ( sizeof ( utxos ) / sizeof ( * utxos ) ) ;
* newqp = * qp ;
* newqp = * qp ;
qp = newqp ;
qp = newqp ;
printf ( " bob %s received REQUEST.(%llu) \n " , bits256_str ( str , G . LP_mypub25519 ) , ( long long ) qp - > aliceid ) ;
printf ( " bob %s received REQUEST.(%llu) \n " , bits256_str ( str , G . LP_mypub25519 ) , ( long long ) qp - > aliceid ) ;
@ -892,17 +901,21 @@ struct LP_quoteinfo *LP_trades_gotrequest(void *ctx,struct LP_quoteinfo *qp,stru
memset ( & qp - > txid2 , 0 , sizeof ( qp - > txid2 ) ) ;
memset ( & qp - > txid2 , 0 , sizeof ( qp - > txid2 ) ) ;
qp - > vout = qp - > vout2 = - 1 ;
qp - > vout = qp - > vout2 = - 1 ;
} else return ( 0 ) ;
} else return ( 0 ) ;
printf ( " qprice %.8f vs myprice %.8f \n " , qprice , myprice ) ;
if ( qprice > = myprice )
if ( qprice > myprice )
{
{
r = ( LP_rand ( ) % 100 ) ;
r = ( LP_rand ( ) % 90 ) + 10 ;
range = ( qprice - myprice ) ;
range = ( qprice - myprice ) ;
price = myprice + ( r * range ) / 100. ;
price = myprice + ( ( r * range ) / 100. ) ;
bestprice = LP_bob_competition ( & counter , qp - > aliceid , price , 0 ) ;
bestprice = LP_bob_competition ( & counter , qp - > aliceid , price , 0 ) ;
printf ( " %llu >>>>>>> qprice %.8f r.%d range %.8f -> %.8f, bestprice %.8f counter.%d \n " , ( long long ) qp - > aliceid , qprice , r , range , price , bestprice , counter ) ;
printf ( " %llu >>>>>>> myprice %.8f qprice %.8f r.%d range %.8f -> %.8f, bestprice %.8f counter.%d \n " , ( long long ) qp - > aliceid , myprice , qprice , r , range , price , bestprice , counter ) ;
if ( counter > 3 & & price > bestprice + SMALLVAL ) // skip if late or bad price
if ( counter > 3 & & price > bestprice + SMALLVAL ) // skip if late or bad price
return ( 0 ) ;
return ( 0 ) ;
} else return ( 0 ) ;
}
else
{
printf ( " ignore as qprice %.8f vs myprice %.8f \n " , qprice , myprice ) ;
return ( 0 ) ;
}
//LP_RTmetrics_update(qp->srccoin,qp->destcoin);
//LP_RTmetrics_update(qp->srccoin,qp->destcoin);
if ( LP_RTmetrics_blacklisted ( qp - > desthash ) > = 0 )
if ( LP_RTmetrics_blacklisted ( qp - > desthash ) > = 0 )
{
{
@ -927,10 +940,13 @@ struct LP_quoteinfo *LP_trades_gotrequest(void *ctx,struct LP_quoteinfo *qp,stru
return ( 0 ) ;
return ( 0 ) ;
}
}
}
}
i = 0 ;
while ( i < 33 & & price > = myprice )
{
if ( ( butxo = LP_address_myutxopair ( butxo , 1 , utxos , max , LP_coinfind ( qp - > srccoin ) , qp - > coinaddr , qp - > txfee , dstr ( qp - > destsatoshis ) , price , qp - > desttxfee ) ) ! = 0 )
if ( ( butxo = LP_address_myutxopair ( butxo , 1 , utxos , max , LP_coinfind ( qp - > srccoin ) , qp - > coinaddr , qp - > txfee , dstr ( qp - > destsatoshis ) , price , qp - > desttxfee ) ) ! = 0 )
{
{
strcpy ( qp - > gui , G . gui ) ;
strcpy ( qp - > gui , G . gui ) ;
//strcpy(qp->coinaddr,coin->smartaddr);
strcpy ( qp - > coinaddr , coin - > smartaddr ) ;
qp - > srchash = G . LP_mypub25519 ;
qp - > srchash = G . LP_mypub25519 ;
qp - > txid = butxo - > payment . txid ;
qp - > txid = butxo - > payment . txid ;
qp - > vout = butxo - > payment . vout ;
qp - > vout = butxo - > payment . vout ;
@ -941,13 +957,23 @@ struct LP_quoteinfo *LP_trades_gotrequest(void *ctx,struct LP_quoteinfo *qp,stru
}
}
else
else
{
{
printf ( " cant find utxopair aliceid.%llu %s/%s %.8f -> relvol %.8f \n " , ( long long ) qp - > aliceid , qp - > srccoin , qp - > destcoin , dstr ( LP_basesatoshis ( dstr ( qp - > destsatoshis ) , price , qp - > txfee , qp - > desttxfee ) ) , dstr ( qp - > destsatoshis ) ) ;
printf ( " i.%d cant find utxopair aliceid.%llu %s/%s %.8f -> relvol %.8f\n " , i , ( long long ) qp - > aliceid , qp - > srccoin , qp - > destcoin , dstr ( LP_basesatoshis ( dstr ( qp - > destsatoshis ) , price , qp - > txfee , qp - > desttxfee ) ) , dstr ( qp - > destsatoshis ) ) ;
return ( 0 ) ;
return ( 0 ) ;
}
}
if ( ( qprice = LP_trades_pricevalidate ( qp , coin , myprice ) ) < 0. )
if ( qp - > satoshis < = qp - > txfee )
return ( 0 ) ;
return ( 0 ) ;
p = ( double ) qp - > destsatoshis / ( qp - > satoshis - qp - > txfee ) ;
if ( LP_trades_pricevalidate ( qp , coin , p ) < 0. )
return ( 0 ) ;
if ( p > = qprice )
break ;
price / = 0.99 ;
i + + ;
}
printf ( " i.%d qprice %.8f myprice %.8f price %.8f [%.8f] \n " , i , qprice , myprice , price , p ) ;
if ( LP_allocated ( qp - > txid , qp - > vout ) = = 0 & & LP_allocated ( qp - > txid2 , qp - > vout2 ) = = 0 )
if ( LP_allocated ( qp - > txid , qp - > vout ) = = 0 & & LP_allocated ( qp - > txid2 , qp - > vout2 ) = = 0 )
{
{
printf ( " found unallocated txids \n " ) ;
reqjson = LP_quotejson ( qp ) ;
reqjson = LP_quotejson ( qp ) ;
LP_unavailableset ( qp - > txid , qp - > vout , qp - > timestamp + LP_RESERVETIME , qp - > desthash ) ;
LP_unavailableset ( qp - > txid , qp - > vout , qp - > timestamp + LP_RESERVETIME , qp - > desthash ) ;
LP_unavailableset ( qp - > txid2 , qp - > vout2 , qp - > timestamp + LP_RESERVETIME , qp - > desthash ) ;
LP_unavailableset ( qp - > txid2 , qp - > vout2 , qp - > timestamp + LP_RESERVETIME , qp - > desthash ) ;
@ -956,12 +982,12 @@ struct LP_quoteinfo *LP_trades_gotrequest(void *ctx,struct LP_quoteinfo *qp,stru
jaddnum ( reqjson , " quotetime " , qp - > quotetime ) ;
jaddnum ( reqjson , " quotetime " , qp - > quotetime ) ;
jaddnum ( reqjson , " pending " , qp - > timestamp + LP_RESERVETIME ) ;
jaddnum ( reqjson , " pending " , qp - > timestamp + LP_RESERVETIME ) ;
jaddstr ( reqjson , " method " , " reserved " ) ;
jaddstr ( reqjson , " method " , " reserved " ) ;
//LP_reserved_msg(1,qp->srccoin,qp->destcoin,qp->desthash,jprint(reqjson,0));
LP_reserved_msg ( 1 , qp - > srccoin , qp - > destcoin , qp - > desthash , jprint ( reqjson , 0 ) ) ;
bits256 zero ;
bits256 zero ;
memset ( zero . bytes , 0 , sizeof ( zero ) ) ;
memset ( zero . bytes , 0 , sizeof ( zero ) ) ;
LP_reserved_msg ( 1 , qp - > srccoin , qp - > destcoin , zero , jprint ( reqjson , 0 ) ) ;
LP_reserved_msg ( 1 , qp - > srccoin , qp - > destcoin , zero , jprint ( reqjson , 0 ) ) ;
free_json ( reqjson ) ;
free_json ( reqjson ) ;
//printf("Send RESERVED id.%llu\n",(long long)qp->aliceid);
printf ( " Send RESERVED id.%llu \n " , ( long long ) qp - > aliceid ) ;
return ( qp ) ;
return ( qp ) ;
} else printf ( " request processing selected ineligible utxos? \n " ) ;
} else printf ( " request processing selected ineligible utxos? \n " ) ;
return ( 0 ) ;
return ( 0 ) ;
@ -969,12 +995,13 @@ struct LP_quoteinfo *LP_trades_gotrequest(void *ctx,struct LP_quoteinfo *qp,stru
struct LP_quoteinfo * LP_trades_gotreserved ( void * ctx , struct LP_quoteinfo * qp , struct LP_quoteinfo * newqp )
struct LP_quoteinfo * LP_trades_gotreserved ( void * ctx , struct LP_quoteinfo * qp , struct LP_quoteinfo * newqp )
{
{
char * retstr ;
char * retstr ; double qprice ;
//char str[65]; printf("alice %s received RESERVED.(%llu) %.8f\n",bits256_str(str,G.LP_mypub25519),(long long)qp->aliceid,(double)qp->destsatoshis/(qp->satoshis+1));
char str [ 65 ] ; printf ( " alice %s received RESERVED.(%llu) %.8f \n " , bits256_str ( str , G . LP_mypub25519 ) , ( long long ) qp - > aliceid , ( double ) qp - > destsatoshis / ( qp - > satoshis + 1 ) ) ;
* newqp = * qp ;
* newqp = * qp ;
qp = newqp ;
qp = newqp ;
if ( LP_trades_alicevalidate ( ctx , qp ) > 0. )
if ( ( qprice = LP_trades_alicevalidate ( ctx , qp ) ) > 0. )
{
{
printf ( " got qprice %.8f \n " , qprice ) ;
LP_aliceid ( qp - > tradeid , qp - > aliceid , " reserved " , 0 , 0 ) ;
LP_aliceid ( qp - > tradeid , qp - > aliceid , " reserved " , 0 , 0 ) ;
if ( ( retstr = LP_quotereceived ( qp ) ) ! = 0 )
if ( ( retstr = LP_quotereceived ( qp ) ) ! = 0 )
free ( retstr ) ;
free ( retstr ) ;
@ -1007,7 +1034,7 @@ struct LP_quoteinfo *LP_trades_gotconnect(void *ctx,struct LP_quoteinfo *qp,stru
struct LP_quoteinfo * LP_trades_gotconnected ( void * ctx , struct LP_quoteinfo * qp , struct LP_quoteinfo * newqp , char * pairstr )
struct LP_quoteinfo * LP_trades_gotconnected ( void * ctx , struct LP_quoteinfo * qp , struct LP_quoteinfo * newqp , char * pairstr )
{
{
char * retstr ; int32_t changed ;
char * retstr ; int32_t changed ;
char str [ 65 ] ; printf ( " alice %s received CONNECTED.(%llu) \n " , bits256_str ( str , G . LP_mypub25519 ) , ( long long ) qp - > aliceid ) ;
//char str[65]; printf("alice %s received CONNECTED.(%llu)\n",bits256_str(str,G.LP_mypub25519),(long long)qp->aliceid);
* newqp = * qp ;
* newqp = * qp ;
qp = newqp ;
qp = newqp ;
if ( LP_trades_alicevalidate ( ctx , qp ) > 0. )
if ( LP_trades_alicevalidate ( ctx , qp ) > 0. )
@ -1249,6 +1276,8 @@ int32_t LP_tradecommand(void *ctx,char *myipaddr,int32_t pubsock,cJSON *argjson,
printf ( " ERROR parsing.(%s) \n " , jprint ( argjson , 0 ) ) ;
printf ( " ERROR parsing.(%s) \n " , jprint ( argjson , 0 ) ) ;
return ( 1 ) ;
return ( 1 ) ;
}
}
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 ) ;
LP_tradecommand_log ( argjson ) ;
LP_tradecommand_log ( argjson ) ;
rq = ( ( uint64_t ) Q . R . requestid < < 32 ) | Q . R . quoteid ;
rq = ( ( uint64_t ) Q . R . requestid < < 32 ) | Q . R . quoteid ;
@ -1257,10 +1286,11 @@ int32_t LP_tradecommand(void *ctx,char *myipaddr,int32_t pubsock,cJSON *argjson,
printf ( " aliceid.%llu is expired by %d \n " , ( long long ) Q . aliceid , ( uint32_t ) time ( NULL ) - ( Q . timestamp + LP_AUTOTRADE_TIMEOUT * 20 ) ) ;
printf ( " aliceid.%llu is expired by %d \n " , ( long long ) Q . aliceid , ( uint32_t ) time ( NULL ) - ( Q . timestamp + LP_AUTOTRADE_TIMEOUT * 20 ) ) ;
return ( 1 ) ;
return ( 1 ) ;
}
}
printf ( " %-4d (%-10u %10u) %12s id.%-20llu %5s/%-5s %12.8f -> %12.8f (%11.8f) | RT.%d %d n%d \n " , ( uint32_t ) time ( NULL ) % 3600 , Q . R . requestid , Q . R . quoteid , method , ( long long ) Q . aliceid , Q . srccoin , Q . destcoin , dstr ( Q . satoshis ) , dstr ( Q . destsatoshis ) , ( double ) Q . destsatoshis / Q . satoshis , LP_RTcount , LP_swapscount , G . netid ) ;
qprice = ( double ) Q . destsatoshis / ( Q . satoshis - Q . txfee ) ; //jdouble(argjson,"price");
//printf("%s\n",jprint(argjson,0));
printf ( " %-4d (%-10u %10u) %12s id.%-20llu %5s/%-5s %12.8f -> %12.8f (%11.8f) | RT.%d %d n%d \n " , ( uint32_t ) time ( NULL ) % 3600 , Q . R . requestid , Q . R . quoteid , method , ( long long ) Q . aliceid , Q . srccoin , Q . destcoin , dstr ( Q . satoshis ) , dstr ( Q . destsatoshis ) , qprice , LP_RTcount , LP_swapscount , G . netid ) ;
retval = 1 ;
retval = 1 ;
aliceid = j64bits ( argjson , " aliceid " ) ;
aliceid = j64bits ( argjson , " aliceid " ) ;
qprice = jdouble ( argjson , " price " ) ;
if ( strcmp ( method , " reserved " ) = = 0 )
if ( strcmp ( method , " reserved " ) = = 0 )
{
{
bestprice = LP_bob_competition ( & counter , aliceid , qprice , 1 ) ;
bestprice = LP_bob_competition ( & counter , aliceid , qprice , 1 ) ;
@ -1432,7 +1462,7 @@ char *LP_autobuy(void *ctx,char *myipaddr,int32_t mypubsock,char *base,char *rel
if ( destsatoshis < ( autxo - > payment . value / LP_MINCLIENTVOL ) | | autxo - > payment . value < desttxfee * LP_MINSIZE_TXFEEMULT )
if ( destsatoshis < ( autxo - > payment . value / LP_MINCLIENTVOL ) | | autxo - > payment . value < desttxfee * LP_MINSIZE_TXFEEMULT )
{
{
printf ( " destsatoshis %.8f vs utxo %.8f this would have triggered an quote error -13 \n " , dstr ( destsatoshis ) , dstr ( autxo - > payment . value ) ) ;
printf ( " destsatoshis %.8f vs utxo %.8f this would have triggered an quote error -13 \n " , dstr ( destsatoshis ) , dstr ( autxo - > payment . value ) ) ;
return ( clonestr ( " { \" error \" : \" cant find a deposit that is close enough in size. make another deposit that is just a bit larger than what you want to trade \" } " ) ) ;
return ( clonestr ( " { \" error \" : \" cant find a deposit that is close enough in size. make another deposit that is a bit larger than what you want to trade \" } " ) ) ;
}
}
bestsatoshis = 1.001 * LP_basesatoshis ( dstr ( destsatoshis ) , maxprice , txfee , desttxfee ) ;
bestsatoshis = 1.001 * LP_basesatoshis ( dstr ( destsatoshis ) , maxprice , txfee , desttxfee ) ;
memset ( & B , 0 , sizeof ( B ) ) ;
memset ( & B , 0 , sizeof ( B ) ) ;