Browse Source

Test

etomic
jl777 8 years ago
parent
commit
34ca17cc9f
  1. 11
      iguana/exchanges/LP_commands.c
  2. 3
      iguana/exchanges/LP_include.h
  3. 3
      iguana/exchanges/LP_nativeDEX.c

11
iguana/exchanges/LP_commands.c

@ -64,13 +64,14 @@ void LP_command(struct LP_peerinfo *mypeer,int32_t pubsock,cJSON *argjson,uint8_
jaddbits256(retjson,"txid",txid); jaddbits256(retjson,"txid",txid);
pubkey = LP_pubkey(LP_privkey(utxo->coinaddr)); pubkey = LP_pubkey(LP_privkey(utxo->coinaddr));
jaddbits256(retjson,"srchash",pubkey); jaddbits256(retjson,"srchash",pubkey);
txfee = LP_txfee(base); if ( (txfee= LP_getestimatedrate(base)*LP_AVETXSIZE) < 10000 )
txfee = 10000;
jadd64bits(retjson,"txfee",txfee); jadd64bits(retjson,"txfee",txfee);
jadd64bits(retjson,"satoshis",utxo->satoshis - txfee); jadd64bits(retjson,"satoshis",utxo->satoshis - txfee);
jadd64bits(retjson,"destsatoshis",price * (utxo->satoshis-txfee)); jadd64bits(retjson,"destsatoshis",price * (utxo->satoshis-txfee));
if ( strcmp(method,"request") == 0 ) if ( strcmp(method,"request") == 0 )
{ {
utxo->swappending = (uint32_t)(time(NULL) + 60); utxo->swappending = (uint32_t)(time(NULL) + LP_RESERVETIME);
utxo->otherpubkey = jbits256(argjson,"pubkey"); utxo->otherpubkey = jbits256(argjson,"pubkey");
jaddstr(retjson,"result","reserved"); jaddstr(retjson,"result","reserved");
jaddnum(retjson,"pending",utxo->swappending); jaddnum(retjson,"pending",utxo->swappending);
@ -87,9 +88,9 @@ void LP_command(struct LP_peerinfo *mypeer,int32_t pubsock,cJSON *argjson,uint8_
if ( (price= LP_price(base,rel)) != 0. ) if ( (price= LP_price(base,rel)) != 0. )
{ {
price *= (1. + profitmargin); price *= (1. + profitmargin);
txfee = LP_txfee(base); txfee = j64bits(argjson,"txfee");
satoshis = j64bits(argjson,"satoshis"); satoshis = j64bits(argjson,"satoshis");
desttxfee = LP_txfee(rel); desttxfee = LP_getestimatedrate(rel) * LP_AVETXSIZE;
desttxid = jbits256(argjson,"desttxid"); desttxid = jbits256(argjson,"desttxid");
destvout = jint(argjson,"destvout"); destvout = jint(argjson,"destvout");
timestamp = juint(argjson,"timestamp"); timestamp = juint(argjson,"timestamp");
@ -98,7 +99,7 @@ void LP_command(struct LP_peerinfo *mypeer,int32_t pubsock,cJSON *argjson,uint8_
pubkey = LP_pubkey(privkey); pubkey = LP_pubkey(privkey);
srchash = jbits256(argjson,"srchash"); srchash = jbits256(argjson,"srchash");
value = j64bits(argjson,"destsatoshis"); value = j64bits(argjson,"destsatoshis");
if ( timestamp == utxo->swappending-60 && quotetime >= timestamp && quotetime < utxo->swappending && bits256_cmp(pubkey,srchash) == 0 && (destsatoshis= LP_txvalue(rel,desttxid,destvout)) > price*(utxo->satoshis-txfee)+desttxfee && value <= destsatoshis-desttxfee ) if ( timestamp == utxo->swappending-LP_RESERVETIME && quotetime >= timestamp && quotetime < utxo->swappending && bits256_cmp(pubkey,srchash) == 0 && (destsatoshis= LP_txvalue(rel,desttxid,destvout)) > price*(utxo->satoshis-txfee)+desttxfee && value <= destsatoshis-desttxfee )
{ {
destsatoshis = value; destsatoshis = value;
if ( (utxo->pair= nn_socket(AF_SP,NN_PAIR)) < 0 ) if ( (utxo->pair= nn_socket(AF_SP,NN_PAIR)) < 0 )

3
iguana/exchanges/LP_include.h

@ -24,6 +24,9 @@
#define BASILISK_DISABLEWAITTX #define BASILISK_DISABLEWAITTX
#define BASILISK_DISABLESENDTX #define BASILISK_DISABLESENDTX
#define LP_RESERVETIME 60
#define LP_AVETXSIZE 500
#define BASILISK_DEFAULT_NUMCONFIRMS 5 #define BASILISK_DEFAULT_NUMCONFIRMS 5
#define DEX_SLEEP 3 #define DEX_SLEEP 3
#define BASILISK_DEXDURATION 300 #define BASILISK_DEXDURATION 300

3
iguana/exchanges/LP_nativeDEX.c

@ -771,6 +771,9 @@ void LP_mainloop(struct LP_peerinfo *mypeer,uint16_t mypubport,int32_t pubsock,i
jaddstr(reqjson,"method","price"); jaddstr(reqjson,"method","price");
//5.9.253.196:7779 [{"ipaddr":"5.9.253.196","port":7779,"profit":0.01064000,"coin":"KMD","address":"RFQn4gNG555woQWQV1wPseR47spCduiJP5","script":"76a914434009423522682bd7cc1b18a614c3096d19683188ac","txid":"f5d5e2eb4ef85c78f95076d0d2d99af9e1b85968e57b3c7bdb282bd005f7c341","vout":1,"value":100,"deposit":"07902a65d11f0f577a0346432bcd2b6b53de5554c314209d1964693962524d69","dvout":1,"dvalue":120}] //5.9.253.196:7779 [{"ipaddr":"5.9.253.196","port":7779,"profit":0.01064000,"coin":"KMD","address":"RFQn4gNG555woQWQV1wPseR47spCduiJP5","script":"76a914434009423522682bd7cc1b18a614c3096d19683188ac","txid":"f5d5e2eb4ef85c78f95076d0d2d99af9e1b85968e57b3c7bdb282bd005f7c341","vout":1,"value":100,"deposit":"07902a65d11f0f577a0346432bcd2b6b53de5554c314209d1964693962524d69","dvout":1,"dvalue":120}]
LP_send(peer->pushsock,jprint(reqjson,0),1);
jdelete(reqjson,"method");
jaddstr(reqjson,"method","request");
LP_send(peer->pushsock,jprint(reqjson,1),1); LP_send(peer->pushsock,jprint(reqjson,1),1);
nonz = 1; nonz = 1;
} }

Loading…
Cancel
Save