Browse Source

Test

etomic
jl777 7 years ago
parent
commit
03375ac2f2
  1. 8
      iguana/exchanges/LP_commands.c
  2. 2
      iguana/exchanges/LP_include.h
  3. 7
      iguana/exchanges/LP_nativeDEX.c
  4. 12
      iguana/exchanges/LP_ordermatch.c
  5. 6
      iguana/exchanges/LP_remember.c
  6. 30
      iguana/exchanges/LP_transaction.c
  7. 2
      iguana/exchanges/LP_utxo.c
  8. 4
      iguana/exchanges/LP_utxos.c

8
iguana/exchanges/LP_commands.c

@ -106,6 +106,7 @@ inventory(coin)\n\
bestfit(rel, relvolume)\n\
buy(base, rel, price, relvolume, timeout=10, duration=3600, nonce)\n\
sell(base, rel, price, basevolume, timeout=10, duration=3600, nonce)\n\
withdraw(coin, outputs[])\n\
swapstatus()\n\
swapstatus(requestid, quoteid)\n\
public API:\n \
@ -280,7 +281,12 @@ dividends(coin, height, <args>)\n\
}
else if ( strcmp(method,"withdraw") == 0 )
{
if ( (ptr= LP_coinsearch(coin)) != 0 )
{
if ( jobj(argjson,"outputs") == 0 )
return(clonestr("{\"error\":\"withdraw needs to have outputs\"}"));
else return(LP_withdraw(ptr,argjson));
} else return(clonestr("{\"error\":\"cant find coind\"}"));
}
else if ( strcmp(method,"setconfirms") == 0 )
{

2
iguana/exchanges/LP_include.h

@ -303,7 +303,7 @@ int32_t LP_reserved_msg(char *base,char *rel,bits256 pubkey,char *msg);
struct iguana_info *LP_coinfind(char *symbol);
int32_t LP_crc32find(int32_t *duplicatep,int32_t ind,uint32_t crc32);
char *LP_pricepings(void *ctx,char *myipaddr,int32_t pubsock,char *base,char *rel,double price);
uint64_t LP_txfeecalc(struct iguana_info *coin,uint64_t txfee);
uint64_t LP_txfeecalc(struct iguana_info *coin,uint64_t txfee,int32_t txlen);
struct LP_address *_LP_address(struct iguana_info *coin,char *coinaddr);
struct LP_address *_LP_addressfind(struct iguana_info *coin,char *coinaddr);
struct LP_address *_LP_addressadd(struct iguana_info *coin,char *coinaddr);

7
iguana/exchanges/LP_nativeDEX.c

@ -19,12 +19,11 @@
// LP_nativeDEX.c
// marketmaker
//
// sign packets
// withdraw
// verify portfolio
// stats, fix pricearray
// stats
// sign critical api calls
// dPoW security -> 2: KMD notarized, 3: BTC notarized
// electrum peers
// verify portfolio and pricearray
#include <stdio.h>

12
iguana/exchanges/LP_ordermatch.c

@ -19,18 +19,20 @@
// marketmaker
//
uint64_t LP_txfeecalc(struct iguana_info *coin,uint64_t txfee)
uint64_t LP_txfeecalc(struct iguana_info *coin,uint64_t txfee,int32_t txlen)
{
if ( coin != 0 )
{
if ( strcmp(coin->symbol,"BTC") == 0 )
{
if ( txlen == 0 )
txlen = LP_AVETXSIZE;
coin->rate = LP_getestimatedrate(coin);
if ( (txfee= SATOSHIDEN * coin->rate * LP_AVETXSIZE) <= LP_MIN_TXFEE )
if ( (txfee= SATOSHIDEN * coin->rate * txlen) <= LP_MIN_TXFEE )
{
coin->rate = -1.;
coin->rate = _LP_getestimatedrate(coin);
if ( (txfee= SATOSHIDEN * coin->rate * LP_AVETXSIZE) <= LP_MIN_TXFEE )
if ( (txfee= SATOSHIDEN * coin->rate * txlen) <= LP_MIN_TXFEE )
txfee = LP_MIN_TXFEE;
}
} else txfee = coin->txfee;
@ -42,8 +44,8 @@ uint64_t LP_txfeecalc(struct iguana_info *coin,uint64_t txfee)
void LP_txfees(uint64_t *txfeep,uint64_t *desttxfeep,char *base,char *rel)
{
*txfeep = LP_txfeecalc(LP_coinfind(base),0);
*desttxfeep = LP_txfeecalc(LP_coinfind(rel),0);
*txfeep = LP_txfeecalc(LP_coinfind(base),0,0);
*desttxfeep = LP_txfeecalc(LP_coinfind(rel),0,0);
printf("LP_txfees(%.8f %.8f)\n",dstr(*txfeep),dstr(*desttxfeep));
}

6
iguana/exchanges/LP_remember.c

@ -856,13 +856,13 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti
srcAdest = srcBdest = destAdest = destBdest = 0;
if ( rswap.bobcoin[0] == 0 || rswap.alicecoin[0] == 0 || strcmp(rswap.bobcoin,rswap.src) != 0 || strcmp(rswap.alicecoin,rswap.dest) != 0 )
{
printf("BOB.(%s) Alice.(%s) src.(%s) dest.(%s)\n",rswap.bobcoin,rswap.alicecoin,rswap.src,rswap.dest);
printf("legacy DB SWAPS files BOB.(%s) Alice.(%s) src.(%s) dest.(%s)\n",rswap.bobcoin,rswap.alicecoin,rswap.src,rswap.dest);
return(cJSON_Parse("{\"error\":\"mismatched bob/alice vs src/dest coins??\"}"));
}
alice = LP_coinfind(rswap.alicecoin);
bob = LP_coinfind(rswap.bobcoin);
rswap.Atxfee = LP_txfeecalc(alice,rswap.Atxfee);
rswap.Btxfee = LP_txfeecalc(bob,rswap.Btxfee);
rswap.Atxfee = LP_txfeecalc(alice,rswap.Atxfee,0);
rswap.Btxfee = LP_txfeecalc(bob,rswap.Btxfee,0);
if ( rswap.iambob == 0 )
{
if ( alice != 0 )

30
iguana/exchanges/LP_transaction.c

@ -724,9 +724,34 @@ char *basilisk_swap_bobtxspend(bits256 *signedtxidp,uint64_t txfee,char *name,ch
return(signedtx);
}
/*char *LP_withdraw(struct iguana_info *coin,cJSON *argjson)
{
int32_t iter,i,datalen; char changeaddr[64],*signedtx=0; cJSON *retjson; bits256 signedtxid; uint64_t txfee,newtxfee=10000;
txfee = coin->txfee;
if ( txfee > 0 && txfee < 10000 )
txfee = 10000;
retjson = cJSON_CreateObject();
safecopy(changeaddr,coin->smartaddr,sizeof(changeaddr));
for (iter=0; iter<2; iter++)
{
if ( (signedtx= basilisk_swap_bobtxspend(&signedtxid,iter == 0 ? txfee : newtxfee,str,coin->symbol,coin->wiftaddr,coin->taddr,coin->pubtype,coin->p2shtype,coin->isPoS,coin->wiftype,ctx,privkey,0,0,0,0,0,rawtx->utxotxid,rawtx->utxovout,rawtx->I.destaddr,pubkey33,1,0,&destamount,rawtx->I.amount,changeaddr,vinaddr,rawtx->I.suppress_pubkeys)) != 0 )
{
datalen = (int32_t)strlen(signedtx) / 2;
if ( strcmp(coin->symbol,"BTC") == 0 )
{
newtxfee = LP_txfeecalc(coin,0,datalen);
printf("txfee %.8f -> newtxfee %.8f\n",dstr(txfee),dstr(newtxfee));
} else break;
} else break;
if ( strcmp(str,"myfee") == 0 )
break;
}
return(jprint(retjson,1));
}*/
int32_t basilisk_rawtx_gen(void *ctx,char *str,uint32_t swapstarted,uint8_t *pubkey33,int32_t iambob,int32_t lockinputs,struct basilisk_rawtx *rawtx,uint32_t locktime,uint8_t *script,int32_t scriptlen,int64_t txfee,int32_t minconf,int32_t delay,bits256 privkey,uint8_t *changermd160,char *vinaddr)
{
int32_t retval=-1,len,iter; char *signedtx,*changeaddr = 0,_changeaddr[64]; struct iguana_info *coin; int64_t newtxfee=0,destamount;
int32_t retval=-1,iter; char *signedtx,*changeaddr = 0,_changeaddr[64]; struct iguana_info *coin; int64_t newtxfee=0,destamount;
char str2[65]; printf("%s rawtxgen.(%s/v%d)\n",rawtx->name,bits256_str(str2,rawtx->utxotxid),rawtx->utxovout);
if ( (coin= rawtx->coin) == 0 )
return(-1);
@ -753,8 +778,7 @@ int32_t basilisk_rawtx_gen(void *ctx,char *str,uint32_t swapstarted,uint8_t *pub
free(signedtx);
if ( strcmp(coin->symbol,"BTC") != 0 )
return(retval);
len = rawtx->I.datalen;
newtxfee = LP_txfeecalc(coin,0);
newtxfee = LP_txfeecalc(coin,0,rawtx->I.datalen);
printf("txfee %.8f -> newtxfee %.8f\n",dstr(txfee),dstr(newtxfee));
} else break;
if ( strcmp(str,"myfee") == 0 )

2
iguana/exchanges/LP_utxo.c

@ -828,7 +828,7 @@ int32_t LP_iseligible(uint64_t *valp,uint64_t *val2p,int32_t iambob,char *symbol
return(-2);
if ( (up= LP_address_utxofind(coin,destaddr,txid2,vout2)) != 0 && up->spendheight > 0 )
return(-3);
txfee = LP_txfeecalc(LP_coinfind(symbol),0);
txfee = LP_txfeecalc(LP_coinfind(symbol),0,0);
if ( val >= satoshis && val > (1+LP_MINSIZE_TXFEEMULT)*txfee )
{
threshold = (iambob != 0) ? LP_DEPOSITSATOSHIS(satoshis) : (LP_DEXFEE(satoshis) + txfee);

4
iguana/exchanges/LP_utxos.c

@ -312,7 +312,7 @@ struct LP_utxoinfo *LP_utxoadd(int32_t iambob,char *symbol,bits256 txid,int32_t
//printf("LP_utxoadd reject inactive %s\n",symbol);
return(0);
}
txfee = LP_txfeecalc(coin,0);
txfee = LP_txfeecalc(coin,0,0);
if ( iambob != 0 && value2 < 9 * (value >> 3) + 2*txfee ) // big txfee padding
{
if ( value2 > 2*txfee )
@ -522,7 +522,7 @@ int32_t LP_privkey_init(int32_t mypubsock,struct iguana_info *coin,bits256 mypri
LP_listunspent_issue(coin->symbol,coin->smartaddr,0);
if ( coin->inactive == 0 && (array= LP_listunspent(coin->symbol,coin->smartaddr)) != 0 )
{
txfee = LP_txfeecalc(coin,0);
txfee = LP_txfeecalc(coin,0,0);
if ( is_cJSON_Array(array) != 0 && (n= cJSON_GetArraySize(array)) > 0 )
{
//printf("LP_privkey_init %s %s\n",coin->symbol,jprint(array,0));

Loading…
Cancel
Save