Browse Source

Merge pull request #647 from jl777/dev

Dev
patch-1
jl777 7 years ago
committed by GitHub
parent
commit
06b06cfcb1
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      iguana/dpow/dpow_fsm.c
  2. 2
      iguana/exchanges/LP_NXT.c
  3. 2
      iguana/exchanges/LP_RTmetrics.c
  4. 13
      iguana/exchanges/LP_bitcoin.c
  5. 5
      iguana/exchanges/LP_coins.c
  6. 59
      iguana/exchanges/LP_commands.c
  7. 10
      iguana/exchanges/LP_include.h
  8. 38
      iguana/exchanges/LP_instantdex.c
  9. 42
      iguana/exchanges/LP_nativeDEX.c
  10. 87
      iguana/exchanges/LP_network.c
  11. 128
      iguana/exchanges/LP_ordermatch.c
  12. 40
      iguana/exchanges/LP_privkey.c
  13. 89
      iguana/exchanges/LP_remember.c
  14. 17
      iguana/exchanges/LP_rpc.c
  15. 6
      iguana/exchanges/LP_scan.c
  16. 5
      iguana/exchanges/LP_secp.c
  17. 15
      iguana/exchanges/LP_signatures.c
  18. 14
      iguana/exchanges/LP_stats.c
  19. 111
      iguana/exchanges/LP_swap.c
  20. 2
      iguana/exchanges/LP_tradebots.c
  21. 57
      iguana/exchanges/LP_transaction.c
  22. 51
      iguana/exchanges/LP_utxo.c
  23. 2
      iguana/exchanges/auto_chipsbtc
  24. 2
      iguana/exchanges/auto_chipskmd
  25. 63
      iguana/exchanges/autoprice
  26. 2
      iguana/exchanges/coins
  27. 3
      iguana/exchanges/convaddress
  28. 3
      iguana/exchanges/getendpoint
  29. 48
      iguana/exchanges/mm.c
  30. 2
      iguana/exchanges/mshark
  31. 8
      iguana/exchanges/prices/autoprice
  32. 32
      iguana/exchanges/stats.c
  33. 2
      iguana/exchanges/supernet
  34. 7
      iguana/exchanges/updateprices
  35. 48
      iguana/m_splitfund

2
iguana/dpow/dpow_fsm.c

@ -132,7 +132,7 @@ int32_t dpow_checkutxo(struct supernet_info *myinfo,struct dpow_info *dp,struct
else
{
minutxo = 49;
n = 10;
n = 50;
}
if ( (haveutxo= dpow_haveutxo(myinfo,coin,txidp,voutp,coinaddr,srccoin)) <= minutxo && time(NULL) > dp->lastsplit+bp->duration && (bp->myind != 0 || dp->ratifying == 0) )
{

2
iguana/exchanges/LP_NXT.c

@ -202,7 +202,7 @@ void NXTventure_liquidation()
cJSON *LP_NXT_redeems()
{
char url[1024],*retstr,*recv,*method,*msgstr,assetname[128]; uint64_t totals[2][sizeof(assetids)/sizeof(*assetids)],mult,txnum,assetid,qty; int32_t i,ind,numtx=0,past_marker=0; cJSON *item,*attach,*decjson,*array,*msgjson,*encjson,*retjson=0;
uint64_t txnum_marker = calc_nxt64bits("4114304329372848717"); // 8537615468620726612"); // set to most recent processed
uint64_t txnum_marker = calc_nxt64bits("2675953695997905027"); // 4114304329372848717, 8537615468620726612"); // set to most recent processed
uint64_t txnum_marker2 = calc_nxt64bits("7256847492742571143"); // dont change, end marker
char *passphrase = "";
char *account = "NXT-MRBN-8DFH-PFMK-A4DBM";

2
iguana/exchanges/LP_RTmetrics.c

@ -132,7 +132,7 @@ void LP_RTmetrics_swapsinfo(char *refbase,char *refrel,cJSON *swaps,int32_t nums
quoteid = juint(item,"quoteid");
LP_RTmetrics_pendingswap(srcpub,LP_kmdvalue(base,basesatoshis));
LP_RTmetrics_pendingswap(destpub,LP_kmdvalue(rel,relsatoshis));
if ( 0 && (retstr= basilisk_swapentry(requestid,quoteid,0)) != 0 ) // no need for this
if ( 0 && (retstr= basilisk_swapentry(1,requestid,quoteid,0)) != 0 ) // no need for this
{
if ( (swapjson= cJSON_Parse(retstr)) != 0 )
{

13
iguana/exchanges/LP_bitcoin.c

@ -2152,7 +2152,12 @@ char *bitcoin_address(char *symbol,char *coinaddr,uint8_t taddr,uint8_t addrtype
coinaddr[0] = 0;
offset = 1 + (taddr != 0);
if ( len != 20 )
{
calc_rmd160_sha256(data+offset,pubkey_or_rmd160,len);
//for (i=0; i<20; i++)
// printf("%02x",data[offset+i]);
//printf(" rmd160\n");
}
else memcpy(data+offset,pubkey_or_rmd160,20);
if ( strcmp(symbol,"BCH") == 0 )
{
@ -3391,7 +3396,7 @@ int32_t iguana_rwmsgtx(char *symbol,uint8_t taddr,uint8_t pubtype,uint8_t p2shty
bits256 bitcoin_sigtxid(char *symbol,uint8_t taddr,uint8_t pubtype,uint8_t p2shtype,uint8_t isPoS,int32_t height,uint8_t *serialized,int32_t maxlen,struct iguana_msgtx *msgtx,int32_t vini,uint8_t *spendscript,int32_t spendlen,uint64_t spendamount,uint32_t hashtype,char *vpnstr,int32_t suppress_pubkeys,int32_t zcash)
{
int32_t i,len,sbtcflag = 0; bits256 sigtxid,txid,revsigtxid; struct iguana_msgtx dest;
int32_t i,len,sbtcflag = 0,btcpflag=0; bits256 sigtxid,txid,revsigtxid; struct iguana_msgtx dest;
dest = *msgtx;
dest.vins = calloc(dest.tx_in,sizeof(*dest.vins));
dest.vouts = calloc(dest.tx_out,sizeof(*dest.vouts));
@ -3400,6 +3405,8 @@ bits256 bitcoin_sigtxid(char *symbol,uint8_t taddr,uint8_t pubtype,uint8_t p2sht
memset(sigtxid.bytes,0,sizeof(sigtxid));
if ( strcmp(symbol,"SBTC") == 0 )
sbtcflag = 1;
else if ( strcmp(symbol,"BTCP") == 0 )
btcpflag = 1;
if ( ((hashtype & ~SIGHASH_FORKID) & 0xff) != SIGHASH_ALL )
{
printf("currently only SIGHASH_ALL supported, not %d\n",hashtype);
@ -3434,6 +3441,8 @@ bits256 bitcoin_sigtxid(char *symbol,uint8_t taddr,uint8_t pubtype,uint8_t p2sht
if ( height >= BTC2_HARDFORK_HEIGHT )
hashtype |= (0x777 << 20);
#endif
if ( btcpflag != 0 )
hashtype = 0x2a41;
len += iguana_rwnum(1,&serialized[len],sizeof(hashtype),&hashtype);
if ( sbtcflag != 0 )
{
@ -3610,7 +3619,7 @@ uint32_t LP_sighash(char *symbol,int32_t zcash)
sighash |= SIGHASH_FORKID;
sighash |= (LP_IS_BITCOINGOLD << 8);
}
else if ( strcmp(symbol,"SBTC") == 0 )
else if ( strcmp(symbol,"SBTC") == 0 || strcmp(symbol,"BTCP") == 0 )
sighash |= SIGHASH_FORKID;
return(sighash);
}

5
iguana/exchanges/LP_coins.c

@ -309,7 +309,7 @@ char *LP_getcoin(char *symbol)
HASH_ITER(hh,LP_coins,coin,tmp)
{
if ( strcmp(symbol,coin->symbol) == 0 )
item = LP_coinjson(coin,0);
item = LP_coinjson(coin,LP_showwif);
if ( coin->inactive == 0 )
numenabled++;
else numdisabled++;
@ -376,7 +376,8 @@ uint16_t LP_coininit(struct iguana_info *coin,char *symbol,char *name,char *asse
if ( assetname != 0 && strcmp(name,assetname) == 0 )
{
//printf("%s is assetchain\n",symbol);
coin->isassetchain = 1;
if ( strcmp(name,"BEER") != 0 && strcmp("PIZZA",name) != 0 )
coin->isassetchain = 1;
}
if ( strcmp(symbol,"KMD") == 0 || (assetname != 0 && assetname[0] != 0) )
name2 = 0;

59
iguana/exchanges/LP_commands.c

@ -120,10 +120,10 @@ 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\
sendrawtransaction(coin, signedtx)\n\
swapstatus(pending=0)\n\
swapstatus(pending=0, fast=0)\n\
swapstatus(coin, limit=10)\n\
swapstatus(base, rel, limit=10)\n\
swapstatus(requestid, quoteid, pending=0)\n\
swapstatus(requestid, quoteid, pending=0, fast=0)\n\
recentswaps(limit=3)\n\
notarizations(coin)\n\
public API:\n \
@ -161,10 +161,12 @@ bot_status(botid)\n\
bot_stop(botid)\n\
bot_pause(botid)\n\
calcaddress(passphrase)\n\
convaddress(coin, address, destcoin)\n\
instantdex_deposit(weeks, amount, broadcast=1)\n\
instantdex_claim()\n\
timelock(coin, duration, destaddr=(tradeaddr), amount)\n\
unlockedspend(coin, txid)\n\
getendpoint()\n\
jpg(srcfile, destfile, power2=7, password, data="", required, ind=0)\n\
\"}"));
//sell(base, rel, price, basevolume, timeout=10, duration=3600)\n\
@ -229,6 +231,41 @@ jpg(srcfile, destfile, power2=7, password, data="", required, ind=0)\n\
}
return(clonestr("{\"error\":\"cant find KMD\"}"));
}
else if ( strcmp(method,"getendpoint") == 0 )
{
int32_t err,mode;
retjson = cJSON_CreateObject();
if ( IPC_ENDPOINT >= 0 )
{
jaddstr(retjson,"error","IPC endpoint already exists");
jaddstr(retjson,"endpoint","ws://*:5555");
jaddnum(retjson,"socket",IPC_ENDPOINT);
}
else
{
if ( (IPC_ENDPOINT= nn_socket(AF_SP,NN_PAIR)) >= 0 )
{
if ( (err= nn_bind(IPC_ENDPOINT,"ws://*:5555")) >= 0 )
{
jaddstr(retjson,"result","success");
jaddstr(retjson,"endpoint","ws://127.0.0.1:5555");
jaddnum(retjson,"socket",IPC_ENDPOINT);
mode = NN_WS_MSG_TYPE_TEXT;
err = nn_setsockopt(IPC_ENDPOINT,NN_SOL_SOCKET,NN_WS_MSG_TYPE,&mode,sizeof(mode));
jaddnum(retjson,"sockopt",err);
}
else
{
jaddstr(retjson,"error",(char *)nn_strerror(nn_errno()));
jaddnum(retjson,"err",err);
jaddnum(retjson,"socket",IPC_ENDPOINT);
nn_close(IPC_ENDPOINT);
IPC_ENDPOINT = -1;
}
} else jaddstr(retjson,"error","couldnt get NN_PAIR socket");
}
return(jprint(retjson,1));
}
else if ( strcmp(method,"instantdex_claim") == 0 )
{
if ( (ptr= LP_coinsearch("KMD")) != 0 )
@ -299,7 +336,7 @@ jpg(srcfile, destfile, power2=7, password, data="", required, ind=0)\n\
}
else if ( strcmp(method,"calcaddress") == 0 )
{
bits256 privkey,pub; uint8_t pubkey33[33]; char *passphrase,coinaddr[64];
bits256 privkey,pub; uint8_t pubkey33[33]; char *passphrase,coinaddr[64],wifstr[64];
if ( (passphrase= jstr(argjson,"passphrase")) != 0 )
{
conv_NXTpassword(privkey.bytes,pub.bytes,(uint8_t *)passphrase,(int32_t)strlen(passphrase));
@ -309,6 +346,8 @@ jpg(srcfile, destfile, power2=7, password, data="", required, ind=0)\n\
jaddstr(retjson,"passphrase",passphrase);
jaddstr(retjson,"coinaddr",coinaddr);
jaddbits256(retjson,"privkey",privkey);
bitcoin_priv2wif("KMD",0,wifstr,privkey,188);
jaddstr(retjson,"wif",wifstr);
return(jprint(retjson,1));
} else return(clonestr("{\"error\":\"need to have passphrase\"}"));
}
@ -331,12 +370,12 @@ jpg(srcfile, destfile, power2=7, password, data="", required, ind=0)\n\
{
uint32_t requestid,quoteid;
if ( (requestid= juint(argjson,"requestid")) != 0 && (quoteid= juint(argjson,"quoteid")) != 0 )
return(basilisk_swapentry(requestid,quoteid,1));
return(basilisk_swapentry(jint(argjson,"fast"),requestid,quoteid,1));
else if ( coin[0] != 0 )
return(basilisk_swapentries(coin,0,jint(argjson,"limit")));
return(basilisk_swapentries(1,coin,0,jint(argjson,"limit")));
else if ( base[0] != 0 && rel[0] != 0 )
return(basilisk_swapentries(base,rel,jint(argjson,"limit")));
else return(basilisk_swaplist(0,0,1,jint(argjson,"pending")));
return(basilisk_swapentries(1,base,rel,jint(argjson,"limit")));
else return(basilisk_swaplist(jint(argjson,"fast"),0,0,1,jint(argjson,"pending")));
}
else if ( strcmp(method,"dynamictrust") == 0 )
{
@ -513,6 +552,10 @@ jpg(srcfile, destfile, power2=7, password, data="", required, ind=0)\n\
{
return(LP_sendrawtransaction(coin,jstr(argjson,"signedtx")));
}
else if ( strcmp(method,"convaddress") == 0 )
{
return(LP_convaddress(coin,jstr(argjson,"address"),jstr(argjson,"destcoin")));
}
else if ( strcmp(method,"timelock") == 0 )
{
return(LP_timelock(coin,juint(argjson,"duration"),jstr(argjson,"destaddr"),jdouble(argjson,"amount")*SATOSHIDEN));
@ -523,7 +566,7 @@ jpg(srcfile, destfile, power2=7, password, data="", required, ind=0)\n\
}
else if ( strcmp(method,"getrawtransaction") == 0 )
{
return(jprint(LP_gettx(coin,jbits256(argjson,"txid"),0),1));
return(jprint(LP_gettx("stats_JSON",coin,jbits256(argjson,"txid"),0),1));
}
else if ( strcmp(method,"withdraw") == 0 )
{

10
iguana/exchanges/LP_include.h

@ -35,7 +35,7 @@ voind dontprintf(char *formatstr,...) {}
#define LP_MAJOR_VERSION "0"
#define LP_MINOR_VERSION "1"
#define LP_BUILD_NUMBER "27770"
#define LP_BUILD_NUMBER "27771"
#define LP_BARTERDEX_VERSION 1
#define LP_MAGICBITS 1
@ -101,7 +101,7 @@ void emscripten_usleep(int32_t x); // returns immediate, no sense for sleeping
#define LP_MINVOL 20
#define LP_MINCLIENTVOL 200
#define LP_MINSIZE_TXFEEMULT 10
#define LP_REQUIRED_TXFEE 0.8
#define LP_REQUIRED_TXFEE 0.75
#define LP_DEXFEE(destsatoshis) ((destsatoshis) / INSTANTDEX_INSURANCEDIV)
#define LP_DEPOSITSATOSHIS(satoshis) ((satoshis) + (satoshis >> 3))
@ -490,6 +490,7 @@ int32_t LP_pullsock_check(void *ctx,char **retstrp,char *myipaddr,int32_t pubsoc
int64_t LP_listunspent_parseitem(struct iguana_info *coin,bits256 *txidp,int32_t *voutp,int32_t *heightp,cJSON *item);
void LP_unspents_cache(char *symbol,char *addr,char *arraystr,int32_t updatedflag);
uint16_t LP_psock_get(char *connectaddr,char *publicaddr,int32_t ispaired,int32_t cmdchannel,char *ipaddr);
void LP_failedmsg(uint32_t requestid,uint32_t quoteid,double val);
//void LP_utxo_clientpublish(struct LP_utxoinfo *utxo);
//int32_t LP_coinbus(uint16_t coin_busport);
int32_t LP_nanomsg_recvs(void *ctx);
@ -528,6 +529,7 @@ void LP_ports(uint16_t *pullportp,uint16_t *pubportp,uint16_t *busportp,uint16_t
int32_t LP_destaddr(char *destaddr,cJSON *item);
int32_t LP_waitmempool(char *symbol,char *coinaddr,bits256 txid,int32_t vout,int32_t duration);
cJSON *LP_statslog_disp(uint32_t starttime,uint32_t endtime,char *refgui,bits256 refpubkey,char *refbase,char *refrel);
uint32_t LP_claimtime(struct iguana_info *coin,uint32_t expiration);
uint32_t LP_heighttime(char *symbol,int32_t height);
uint64_t LP_unspents_load(char *symbol,char *addr);
int32_t LP_validSPV(char *symbol,char *coinaddr,bits256 txid,int32_t vout);
@ -537,7 +539,7 @@ int32_t LP_mempoolscan(char *symbol,bits256 searchtxid);
int32_t LP_txheight(struct iguana_info *coin,bits256 txid);
int32_t LP_numpeers();
double LP_CMCbtcprice(double *price_usdp,char *symbol);
char *basilisk_swapentry(uint32_t requestid,uint32_t quoteid,int32_t forceflag);
char *basilisk_swapentry(int32_t fastflag,uint32_t requestid,uint32_t quoteid,int32_t forceflag);
int64_t LP_KMDvalue(struct iguana_info *coin,int64_t balance);
int32_t LP_address_utxoadd(int32_t skipsearch,uint32_t timestamp,char *debug,struct iguana_info *coin,char *coinaddr,bits256 txid,int32_t vout,uint64_t value,int32_t height,int32_t spendheight);
void LP_smartutxos_push(struct iguana_info *coin);
@ -559,7 +561,7 @@ char *LP_unspents_filestr(char *symbol,char *addr);
cJSON *bitcoin_data2json(char *symbol,uint8_t taddr,uint8_t pubtype,uint8_t p2shtype,uint8_t isPoS,int32_t height,bits256 *txidp,struct iguana_msgtx *msgtx,uint8_t *extraspace,int32_t extralen,uint8_t *serialized,int32_t len,cJSON *vins,int32_t suppress_pubkeys,int32_t zcash);
//int32_t LP_butxo_findeither(bits256 txid,int32_t vout);
cJSON *LP_listunspent(char *symbol,char *coinaddr,bits256 reftxid,bits256 reftxid2);
int32_t LP_gettx_presence(char *symbol,bits256 expectedtxid);
int32_t LP_gettx_presence(int32_t *numconfirmsp,char *symbol,bits256 expectedtxid,char *coinaddr);
double LP_getestimatedrate(struct iguana_info *coin);
struct LP_utxoinfo *_LP_utxofind(int32_t iambob,bits256 txid,int32_t vout);
struct LP_utxoinfo *_LP_utxo2find(int32_t iambob,bits256 txid,int32_t vout);

38
iguana/exchanges/LP_instantdex.c

@ -155,6 +155,19 @@ void LP_instantdex_depositadd(char *coinaddr,bits256 txid)
LP_instantdex_filescreate(coinaddr);
}
uint32_t LP_claimtime(struct iguana_info *coin,uint32_t expiration)
{
uint32_t heighttime,now = (uint32_t)time(NULL);
if ( coin->height > 8 )
{
heighttime = LP_heighttime(coin->symbol,coin->height-8);
printf("claimtime: now %u height.%d heighttime.%u expiration.%u\n",now,coin->height,heighttime,expiration);
if ( heighttime >= expiration )
return(heighttime - 1);
}
return(0);
}
int32_t LP_deposit_addr(char *symbol,char *p2shaddr,uint8_t *script,uint8_t taddr,uint8_t p2shtype,uint32_t timestamp,uint8_t *pubsecp33)
{
uint8_t elsepub33[33],p2sh_rmd160[20]; int32_t n;
@ -285,16 +298,6 @@ int64_t LP_claimtx(void *ctx,struct iguana_info *coin,bits256 *claimtxidp,bits25
return(sum);
}
uint32_t LP_claimtime(struct iguana_info *coin,uint32_t expiration)
{
uint32_t heighttime,now = (uint32_t)time(NULL);
heighttime = LP_heighttime(coin->symbol,coin->height);
printf("claimtime: now %u height.%d heighttime.%u expiration.%u\n",now,coin->height,heighttime,expiration);
if ( heighttime >= expiration )
return(heighttime + 1);
return(0);
}
char *LP_unlockedspend(void *ctx,char *symbol,bits256 utxotxid)
{
cJSON *txjson,*vouts,*vout0,*opret,*sobj,*retjson; uint16_t utxovout; char *signedtx,*opretstr,vinaddr[64],destaddr[64]; uint32_t expiration,claimtime; uint8_t redeemscript[128]; bits256 signedtxid,sendtxid; int32_t numvouts,redeemlen; int64_t satoshis,destamount; struct iguana_info *coin;
@ -303,7 +306,7 @@ char *LP_unlockedspend(void *ctx,char *symbol,bits256 utxotxid)
retjson = cJSON_CreateObject();
utxovout = 0;
memset(&sendtxid,0,sizeof(sendtxid));
if ( (txjson= LP_gettx(coin->symbol,utxotxid,1)) != 0 )
if ( (txjson= LP_gettx("LP_unlockedspend",coin->symbol,utxotxid,1)) != 0 )
{
if ( (vouts= jarray(&numvouts,txjson,"vout")) != 0 && numvouts >= 2 )
{
@ -335,12 +338,12 @@ char *LP_unlockedspend(void *ctx,char *symbol,bits256 utxotxid)
jaddnum(retjson,"expiration",expiration);
claimtime = LP_claimtime(coin,expiration);
jaddnum(retjson,"claimtime",claimtime);
if ( claimtime != 0 && strcmp(destaddr,coin->smartaddr) == 0 && time(NULL) > expiration )
if ( claimtime > expiration && strcmp(destaddr,coin->smartaddr) == 0 )
{
char str[65]; printf("LP_timespend satoshis %.8f %s/v%d\n",dstr(satoshis - coin->txfee),bits256_str(str,utxotxid),utxovout);
char str[65]; //printf("LP_timespend satoshis %.8f %s/v%d\n",dstr(satoshis - coin->txfee),bits256_str(str,utxotxid),utxovout);
if ( (signedtx= basilisk_swap_bobtxspend(&signedtxid,coin->txfee,"timespend",coin->symbol,coin->wiftaddr,coin->taddr,coin->pubtype,coin->p2shtype,coin->isPoS,coin->wiftype,ctx,G.LP_privkey,0,redeemscript+2,redeemlen-2,0,0,utxotxid,utxovout,coin->smartaddr,G.LP_pubsecp,0,claimtime,&destamount,0,0,vinaddr,0,coin->zcash)) != 0 )
{
//sendtxid = LP_broadcast("timespend",symbol,signedtx,signedtxid);
sendtxid = LP_broadcast("timespend",symbol,signedtx,signedtxid);
jaddstr(retjson,"signedtx",signedtx);
jaddbits256(retjson,"txid",signedtxid);
if ( bits256_cmp(sendtxid,signedtxid) == 0 )
@ -394,7 +397,7 @@ char *LP_timelock(char *symbol,uint32_t duration,char *destaddr,uint64_t satoshi
int32_t LP_claim_submit(void *ctx,cJSON *txids,int64_t *sump,struct iguana_info *coin,bits256 utxotxid)
{
uint8_t redeemscript[512]; bits256 claimtxid; cJSON *txjson,*vout0,*vout1,*vout2,*vouts,*item; int32_t numvouts; char str[65],vinaddr[64],destaddr[64],checkaddr[64]; int32_t j,utxovout,flagi = 0,redeemlen,weeki,iter; int64_t weeksatoshis,satoshis; uint32_t expiration,claimtime;
if ( (txjson= LP_gettx(coin->symbol,utxotxid,1)) != 0 )
if ( (txjson= LP_gettx("LP_claim_submit",coin->symbol,utxotxid,1)) != 0 )
{
if ( (vouts= jarray(&numvouts,txjson,"vout")) != 0 && numvouts >= 3 )
{
@ -419,6 +422,7 @@ int32_t LP_claim_submit(void *ctx,cJSON *txids,int64_t *sump,struct iguana_info
{
flagi = 1;
claimtime = (uint32_t)time(NULL)-777;
//claimtime = LP_claimtime(coin,expiration);
item = cJSON_CreateObject();
jaddbits256(item,"txid",utxotxid);
jaddnum(item,"deposit",dstr(LP_value_extract(vout0,0)));
@ -511,7 +515,7 @@ int64_t LP_instantdex_credit(int32_t dispflag,char *coinaddr,int64_t satoshis,in
int64_t LP_instantdex_creditcalc(struct iguana_info *coin,int32_t dispflag,bits256 txid,char *refaddr,char *origcoinaddr)
{
cJSON *txjson,*vouts,*txobj,*item; int64_t satoshis=0,amount64; int32_t weeki,numvouts; char destaddr[64],p2shaddr[64];
if ( (txjson= LP_gettx(coin->symbol,txid,0)) != 0 )
if ( (txjson= LP_gettx("LP_instantdex_creditcalc",coin->symbol,txid,0)) != 0 )
{
// vout0 deposit, vout1 botsfee, vout2 smartaddress
if ( (vouts= jarray(&numvouts,txjson,"vout")) > 0 && numvouts >= 3 && LP_destaddr(destaddr,jitem(vouts,2)) == 0 )
@ -713,7 +717,7 @@ cJSON *LP_swapstats_item(struct LP_swapstats *sp,int32_t iambob)
memset(zero.bytes,0,sizeof(zero));
LP_reserved_msg(0,"","",zero,jprint(reqjson,1));
}
if ( (swapstr= basilisk_swapentry(sp->Q.R.requestid,sp->Q.R.quoteid,0)) != 0 )
if ( (swapstr= basilisk_swapentry(1,sp->Q.R.requestid,sp->Q.R.quoteid,0)) != 0 )
{
if ( (swapjson= cJSON_Parse(swapstr)) != 0 )
{

42
iguana/exchanges/LP_nativeDEX.c

@ -85,7 +85,7 @@ void LP_millistats_update(struct LP_millistats *mp)
}
#include "LP_include.h"
portable_mutex_t LP_peermutex,LP_UTXOmutex,LP_utxomutex,LP_commandmutex,LP_cachemutex,LP_swaplistmutex,LP_forwardmutex,LP_pubkeymutex,LP_networkmutex,LP_psockmutex,LP_coinmutex,LP_messagemutex,LP_portfoliomutex,LP_electrummutex,LP_butxomutex,LP_reservedmutex,LP_nanorecvsmutex,LP_tradebotsmutex,LP_gcmutex,LP_inusemutex,LP_cJSONmutex,LP_logmutex,LP_statslogmutex,LP_tradesmutex,LP_commandQmutex,LP_blockinit_mutex,LP_pendswap_mutex;
portable_mutex_t LP_peermutex,LP_UTXOmutex,LP_utxomutex,LP_commandmutex,LP_cachemutex,LP_swaplistmutex,LP_forwardmutex,LP_pubkeymutex,LP_networkmutex,LP_psockmutex,LP_coinmutex,LP_messagemutex,LP_portfoliomutex,LP_electrummutex,LP_butxomutex,LP_reservedmutex,LP_nanorecvsmutex,LP_tradebotsmutex,LP_gcmutex,LP_inusemutex,LP_cJSONmutex,LP_logmutex,LP_statslogmutex,LP_tradesmutex,LP_commandQmutex,LP_blockinit_mutex,LP_pendswap_mutex,LP_listmutex;
int32_t LP_canbind;
char *Broadcaststr,*Reserved_msgs[2][1000];
int32_t num_Reserved_msgs[2],max_Reserved_msgs[2];
@ -101,7 +101,7 @@ struct LP_trade *LP_trades,*LP_tradesQ;
uint16_t LP_fixed_pairport;//,LP_publicport;
uint32_t LP_lastnonce,LP_swap_endcritical,LP_swap_critical,LP_RTcount,LP_swapscount;
int32_t LP_STOP_RECEIVED,LP_numactive_LP;//,LP_mybussock = -1;
int32_t LP_mypubsock = -1;
int32_t LP_mypubsock = -1,IPC_ENDPOINT = -1;
int32_t LP_cmdcount,LP_mypullsock = -1;
int32_t LP_numfinished,LP_showwif,IAMLP = 0;
double LP_profitratio = 1.;
@ -334,7 +334,7 @@ char *LP_process_message(void *ctx,char *typestr,char *myipaddr,int32_t pubsock,
}
else
{
LP_queuecommand(0,jsonstr,pubsock,0);
LP_queuecommand(0,jsonstr,pubsock,0,0);
//if ( (retstr= LP_command_process(ctx,myipaddr,pubsock,argjson,&((uint8_t *)ptr)[len],recvlen - len)) != 0 )
//{
//}
@ -417,7 +417,7 @@ int32_t LP_sock_check(char *typestr,void *ctx,char *myipaddr,int32_t pubsock,int
//printf("self broadcast.(%s)\n",Broadcaststr);
str = Broadcaststr;
Broadcaststr = 0;
LP_queuecommand(0,str,pubsock,0);
LP_queuecommand(0,str,pubsock,0,0);
/*if ( (argjson= cJSON_Parse(str)) != 0 )
{
//portable_mutex_lock(&LP_commandmutex);
@ -651,7 +651,7 @@ void LP_coinsloop(void *_coins)
nonz++;
if ( strcmp("BTC",coins) == 0 )//&& coin->lastscanht < coin->longestchain-3 )
printf("[%s]: %s ref.%d scan.%d to %d, longest.%d\n",coins,coin->symbol,coin->firstrefht,coin->firstscanht,coin->lastscanht,coin->longestchain);
for (j=0; j<1000; j++)
for (j=0; j<100; j++)
{
if ( LP_blockinit(coin,coin->lastscanht) < 0 )
{
@ -961,7 +961,7 @@ void LP_swapsloop(void *ctx)
char *retstr; cJSON *retjson; uint32_t requestid,quoteid; int32_t nonz; struct LP_pendswap *sp,*tmp;
strcpy(LP_swapsloop_stats.name,"LP_swapsloop");
LP_swapsloop_stats.threshold = 605000.;
if ( (retstr= basilisk_swapentry(0,0,1)) != 0 )
if ( (retstr= basilisk_swapentry(0,0,0,1)) != 0 )
{
if ( (retjson= cJSON_Parse(retstr)) != 0 )
{
@ -1047,7 +1047,6 @@ void queue_loop(void *ctx)
continue;
}
LP_millistats_update(&queue_loop_stats);
//printf("LP_Q.%p next.%p prev.%p\n",LP_Q,LP_Q!=0?LP_Q->next:0,LP_Q!=0?LP_Q->prev:0);
n = nonz = flag = 0;
DL_FOREACH_SAFE(LP_Q,ptr,tmp)
{
@ -1055,6 +1054,7 @@ void queue_loop(void *ctx)
flag = 0;
if ( ptr->sock >= 0 )
{
//printf("sock.%d len.%d notready.%d\n",ptr->sock,ptr->msglen,ptr->notready);
if ( ptr->notready == 0 || (LP_rand() % ptr->notready) == 0 )
{
if ( LP_sockcheck(ptr->sock) > 0 )
@ -1081,27 +1081,38 @@ void queue_loop(void *ctx)
{
if ( (sentbytes= nn_send(ptr->sock,linebuf,k,0)) != k )
printf("%d LP_send mmjson sent %d instead of %d\n",n,sentbytes,k);
else flag++;
else
{
flag++;
ptr->sock = -1;
}
}
//printf("k.%d SEND.(%s) sock.%d\n",k,(char *)ptr->msg,ptr->sock);
//printf("k.%d flag.%d SEND.(%s) sock.%d\n",k,flag,(char *)ptr->msg,ptr->sock);
}
free_json(json);
}
if ( flag == 0 )
{
//printf("len.%d SEND.(%s) sock.%d\n",ptr->msglen,(char *)ptr->msg,ptr->sock);
// printf("non-encoded len.%d SEND.(%s) sock.%d\n",ptr->msglen,(char *)ptr->msg,ptr->sock);
if ( (sentbytes= nn_send(ptr->sock,ptr->msg,ptr->msglen,0)) != ptr->msglen )
printf("%d LP_send sent %d instead of %d\n",n,sentbytes,ptr->msglen);
else flag++;
else
{
flag++;
ptr->sock = -1;
}
}
ptr->sock = -1;
if ( ptr->peerind > 0 )
ptr->starttime = (uint32_t)time(NULL);
}
else
{
if ( ptr->notready++ > 1000 )
if ( ptr->notready++ > 100 )
{
flag = 1;
//printf("queue_loop sock.%d len.%d notready.%d, skip\n",ptr->sock,ptr->msglen,ptr->notready);
ptr->sock = -1;
}
}
}
}
@ -1266,13 +1277,13 @@ void LPinit(uint16_t myport,uint16_t mypullport,uint16_t mypubport,uint16_t mybu
char *myipaddr=0,version[64]; long filesize,n; int32_t valid,timeout; struct LP_peerinfo *mypeer=0; char pushaddr[128],subaddr[128],bindaddr[128],*coins_str=0; cJSON *coinsjson=0; void *ctx = bitcoin_ctx();
sprintf(version,"Marketmaker %s.%s %s rsize.%ld",LP_MAJOR_VERSION,LP_MINOR_VERSION,LP_BUILD_NUMBER,sizeof(struct basilisk_request));
bitcoind_RPC_inittime = 1;
printf("%s %u\n",version,calc_crc32(0,version,(int32_t)strlen(version)));
if ( LP_MAXPRICEINFOS > 256 )
{
printf("LP_MAXPRICEINFOS %d wont fit in a uint8_t, need to increase the width of the baseind and relind for struct LP_pubkey_quote\n",LP_MAXPRICEINFOS);
exit(-1);
}
LP_showwif = juint(argjson,"wif");
printf("showwif.%d %s %u\n",LP_showwif,version,calc_crc32(0,version,(int32_t)strlen(version)));
if ( passphrase == 0 || passphrase[0] == 0 )
{
printf("jeezy says we cant use the nullstring as passphrase and I agree\n");
@ -1342,6 +1353,7 @@ void LPinit(uint16_t myport,uint16_t mypullport,uint16_t mypubport,uint16_t mybu
portable_mutex_init(&LP_commandQmutex);
portable_mutex_init(&LP_blockinit_mutex);
portable_mutex_init(&LP_pendswap_mutex);
portable_mutex_init(&LP_listmutex);
myipaddr = clonestr("127.0.0.1");
#ifndef _WIN32
#ifndef FROM_JS
@ -1592,7 +1604,7 @@ void LP_fromjs_iter()
{
LP_notify_pubkeys(ctx,LP_mypubsock);
LP_privkey_updates(ctx,LP_mypubsock,0);
if ( (retstr= basilisk_swapentry(0,0,0)) != 0 )
if ( (retstr= basilisk_swapentry(0,0,0,0)) != 0 )
free(retstr);
}
}

87
iguana/exchanges/LP_network.c

@ -102,6 +102,7 @@ char *nanomsg_transportname(int32_t bindflag,char *str,char *ipaddr,uint16_t por
return(str);
}
/*char *nanomsg_transportname2(int32_t bindflag,char *str,char *ipaddr,uint16_t port)
{
sprintf(str,"ws://%s:%u",bindflag == 0 ? ipaddr : "*",port+10);
@ -267,22 +268,29 @@ int32_t LP_peerindsock(int32_t *peerindp)
void _LP_queuesend(uint32_t crc32,int32_t sock0,int32_t sock1,uint8_t *msg,int32_t msglen,int32_t needack)
{
int32_t maxind,peerind = 0; //sentbytes,
if ( sock0 < 0 && sock1 < 0 )
int32_t i,maxind,flag = 0,peerind = 0; //sentbytes,
for (i=0; i<2; i++)
{
if ( (maxind= LP_numpeers()) > 0 )
peerind = (LP_rand() % maxind) + 1;
else peerind = 1;
sock0 = LP_peerindsock(&peerind);
if ( (maxind= LP_numpeers()) > 0 )
peerind = (LP_rand() % maxind) + 1;
else peerind = 1;
sock1 = LP_peerindsock(&peerind);
if ( sock0 < 0 && sock1 < 0 )
{
if ( (maxind= LP_numpeers()) > 0 )
peerind = (LP_rand() % maxind) + 1;
else peerind = 1;
sock0 = LP_peerindsock(&peerind);
if ( (maxind= LP_numpeers()) > 0 )
peerind = (LP_rand() % maxind) + 1;
else peerind = 1;
sock1 = LP_peerindsock(&peerind);
flag = 1;
}
if ( sock0 >= 0 )
_LP_sendqueueadd(crc32,sock0,msg,msglen,needack * peerind);
if ( sock1 >= 0 )
_LP_sendqueueadd(crc32,sock1,msg,msglen,needack);
if ( flag == 0 )
break;
sock0 = sock1 = -1;
}
if ( sock0 >= 0 )
_LP_sendqueueadd(crc32,sock0,msg,msglen,needack * peerind);
if ( sock1 >= 0 )
_LP_sendqueueadd(crc32,sock1,msg,msglen,needack);
}
void LP_queuesend(uint32_t crc32,int32_t pubsock,char *base,char *rel,uint8_t *msg,int32_t msglen)
@ -310,7 +318,7 @@ void LP_broadcast_finish(int32_t pubsock,char *base,char *rel,uint8_t *msg,cJSON
#ifdef FROM_MARKETMAKER
if ( (G.LP_IAMLP == 0 || pubsock < 0) && strcmp(method,"psock") != 0 )
#else
if ( (IAMLP == 0 || pubsock < 0 && strcmp(method,"psock") != 0 )
if ( (IAMLP == 0 || pubsock < 0) && strcmp(method,"psock") != 0 )
#endif
{
free(msg);
@ -419,12 +427,13 @@ struct LP_queuedcommand
struct LP_queuedcommand *next,*prev;
char **retstrp;
int32_t responsesock,msglen,stats_JSONonly;
uint32_t queueid;
char msg[];
} *LP_commandQ;
void LP_commandQ_loop(void *ctx)
{
struct LP_queuedcommand *ptr,*tmp; int32_t size,nonz; char *retstr; cJSON *argjson;
struct LP_queuedcommand *ptr,*tmp; int32_t size,nonz; char *retstr; cJSON *argjson,*retjson,*result;
while ( LP_STOP_RECEIVED == 0 )
{
nonz = 0;
@ -434,16 +443,46 @@ void LP_commandQ_loop(void *ctx)
portable_mutex_lock(&LP_commandQmutex);
DL_DELETE(LP_commandQ,ptr);
portable_mutex_unlock(&LP_commandQmutex);
if ( (argjson= cJSON_Parse(ptr->msg)) != 0 )
if ( ptr->stats_JSONonly < 0 )
{
if ( ptr->responsesock >= 0 )
{
if ( (result= cJSON_Parse(ptr->msg)) != 0 )
{
retjson = cJSON_CreateObject();
jaddnum(retjson,"queueid",0);
jadd(retjson,"result",result);
retstr = jprint(retjson,1);
if ( (size= nn_send(ptr->responsesock,retstr,(int32_t)strlen(retstr),0)) <= 0 )
printf("error sending event\n");
}
}
}
else if ( (argjson= cJSON_Parse(ptr->msg)) != 0 )
{
if ( (retstr= LP_command_process(ctx,"127.0.0.1",ptr->responsesock,argjson,(uint8_t *)ptr->msg,ptr->msglen,ptr->stats_JSONonly)) != 0 )
{
//printf("processed.(%s)\n",retstr);
if ( ptr->responsesock >= 0 && (size= nn_send(ptr->responsesock,retstr,(int32_t)strlen(retstr)+1,0)) <= 0 )
printf("error sending result\n");
if ( ptr->retstrp != 0 )
(*ptr->retstrp) = retstr;
else free(retstr);
if ( ptr->responsesock >= 0 )
{
if ( (result= cJSON_Parse(retstr)) != 0 && ptr->queueid != 0 )
{
free(retstr);
retjson = cJSON_CreateObject();
jaddnum(retjson,"queueid",ptr->queueid);
jadd(retjson,"result",result);
retstr = jprint(retjson,1);
}
if ( (size= nn_send(ptr->responsesock,retstr,(int32_t)strlen(retstr)+1,0)) <= 0 )
printf("error sending result\n");
}
if ( retstr != 0 )
{
if ( ptr->retstrp == 0 )
free(retstr);
}
}
else if ( ptr->retstrp != 0 )
(*ptr->retstrp) = clonestr("{\"error\":\"timeout\"}");
@ -456,16 +495,16 @@ void LP_commandQ_loop(void *ctx)
}
}
void LP_queuecommand(char **retstrp,char *buf,int32_t responsesock,int32_t stats_JSONonly)
void LP_queuecommand(char **retstrp,char *buf,int32_t responsesock,int32_t stats_JSONonly,uint32_t queueid)
{
struct LP_queuedcommand *ptr; int32_t msglen;
msglen = (int32_t)strlen(buf) + 1;
portable_mutex_lock(&LP_commandQmutex);
ptr = calloc(1,sizeof(*ptr) + msglen);
ptr = calloc(1,sizeof(*ptr) + msglen + 1);
if ( (ptr->retstrp= retstrp) != 0 )
*retstrp = 0;
ptr->responsesock = responsesock;
ptr->msglen = msglen;
ptr->responsesock = responsesock;
ptr->stats_JSONonly = stats_JSONonly;
memcpy(ptr->msg,buf,msglen);
DL_APPEND(LP_commandQ,ptr);
@ -555,7 +594,7 @@ void LP_psockloop(void *_ptr)
{
sendsock = ptr->sendsock;
break;
} else LP_queuecommand(0,(char *)buf,ptr->publicsock,0);
} else LP_queuecommand(0,(char *)buf,ptr->publicsock,0,0);
}
if ( buf != 0 )
{

128
iguana/exchanges/LP_ordermatch.c

@ -24,6 +24,23 @@ bits256 LP_Alicedestpubkey,LP_bobs_reserved;
uint32_t Alice_expiration,Bob_expiration;
struct { uint64_t aliceid; double bestprice; uint32_t starttime,counter; } Bob_competition[512];
void LP_failedmsg(uint32_t requestid,uint32_t quoteid,double val)
{
char *msg; cJSON *retjson;
if ( IPC_ENDPOINT >= 0 )
{
retjson = cJSON_CreateObject();
jaddstr(retjson,"method","failed");
jaddnum(retjson,"error",val);
jaddnum(retjson,"requestid",requestid);
jaddnum(retjson,"quoteid",quoteid);
msg = jprint(retjson,1);
LP_queuecommand(0,msg,IPC_ENDPOINT,-1,0);
free(msg);
}
}
double LP_bob_competition(int32_t *counterp,uint64_t aliceid,double price,int32_t counter)
{
int32_t i,firsti = -1; uint32_t now = (uint32_t)time(NULL);
@ -71,12 +88,12 @@ uint64_t LP_txfeecalc(struct iguana_info *coin,uint64_t txfee,int32_t txlen)
if ( txlen == 0 )
txlen = LP_AVETXSIZE;
coin->rate = LP_getestimatedrate(coin);
if ( (txfee= SATOSHIDEN * coin->rate * txlen) <= 10000 )
if ( (txfee= SATOSHIDEN * coin->rate * txlen) <= 20000 )
{
//coin->rate = -1.;
coin->rate = _LP_getestimatedrate(coin);
if ( (txfee= SATOSHIDEN * coin->rate * txlen) <= 10000 )
txfee = 10000;
if ( (txfee= SATOSHIDEN * coin->rate * txlen) <= 20000 )
txfee = 20000;
}
} else txfee = coin->txfee;
if ( txfee < LP_MIN_TXFEE )
@ -144,7 +161,7 @@ double LP_quote_validate(struct LP_utxoinfo *autxo,struct LP_utxoinfo *butxo,str
if ( LP_iseligible(&destvalue,&destvalue2,0,destcoin,qp->desttxid,qp->destvout,qp->destsatoshis,qp->feetxid,qp->feevout) == 0 )
{
//alice not eligible 0.36893923 -> dest 0.55020000 1.49130251 (0.61732249 0.00104324) 14b8b74808d2d34a70e5eddd1cad47d855858f8b23cac802576d4d37b5f8af8f/v1 abec6e76169bcb738235ca67fab02cc55390f39e422aa71f1badf8747c290cc4/v1
//char str[65],str2[65]; printf("alice not eligible %.8f -> dest %.8f %.8f (%.8f %.8f) %s/v%d %s/v%d\n",dstr(qp->satoshis),dstr(qp->destsatoshis),(double)qp->destsatoshis/qp->satoshis,dstr(destvalue),dstr(destvalue2),bits256_str(str,qp->desttxid),qp->destvout,bits256_str(str2,qp->feetxid),qp->feevout);
char str[65],str2[65]; printf("alice not eligible %.8f -> dest %.8f %.8f (%.8f %.8f) %s/v%d %s/v%d\n",dstr(qp->satoshis),dstr(qp->destsatoshis),(double)qp->destsatoshis/qp->satoshis,dstr(destvalue),dstr(destvalue2),bits256_str(str,qp->desttxid),qp->destvout,bits256_str(str2,qp->feetxid),qp->feevout);
return(-3);
}
if ( (txout= LP_gettxout(destcoin,qp->destaddr,qp->desttxid,qp->destvout)) != 0 )
@ -465,6 +482,7 @@ int32_t LP_connectstartbob(void *ctx,int32_t pubsock,char *base,char *rel,double
if ( (coin= LP_coinfind(qp->srccoin)) == 0 )
{
printf("cant find coin.%s\n",qp->srccoin);
LP_failedmsg(qp->R.requestid,qp->R.quoteid,-3000);
return(-1);
}
privkey = LP_privkey(coin->symbol,coin->smartaddr,coin->taddr);
@ -476,15 +494,11 @@ 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);
/*if ( LP_pendingswap(qp->R.requestid,qp->R.quoteid) > 0 )
{
printf("requestid.%u quoteid.%u is already in progres\n",qp->R.requestid,qp->R.quoteid);
return(-1);
}*/
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 )
{
printf("cant initialize swap\n");
LP_failedmsg(qp->R.requestid,qp->R.quoteid,-3001);
return(-1);
}
if ( (pair= LP_nanobind(ctx,pairstr)) >= 0 )
@ -493,6 +507,7 @@ int32_t LP_connectstartbob(void *ctx,int32_t pubsock,char *base,char *rel,double
if ( OS_thread_create(malloc(sizeof(pthread_t)),NULL,(void *)LP_bobloop,(void *)swap) == 0 )
{
reqjson = LP_quotejson(qp);
LP_swapsfp_update(qp->R.requestid,qp->R.quoteid);
jaddstr(reqjson,"method","connected");
jaddstr(reqjson,"pair",pairstr);
if ( (kmdcoin= LP_coinfind("KMD")) != 0 )
@ -516,11 +531,28 @@ int32_t LP_connectstartbob(void *ctx,int32_t pubsock,char *base,char *rel,double
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);
if ( IPC_ENDPOINT >= 0 )
LP_queuecommand(0,jprint(reqjson,1),IPC_ENDPOINT,-1,0);
else free_json(reqjson);
retval = 0;
} else printf("error launching swaploop\n");
} else printf("couldnt bind to any port %s\n",pairstr);
} else printf("cant find privkey for %s\n",coin->smartaddr);
}
else
{
LP_failedmsg(qp->R.requestid,qp->R.quoteid,-3002);
printf("error launching swaploop\n");
}
}
else
{
LP_failedmsg(qp->R.requestid,qp->R.quoteid,-3003);
printf("couldnt bind to any port %s\n",pairstr);
}
}
else
{
LP_failedmsg(qp->R.requestid,qp->R.quoteid,-3004);
printf("cant find privkey for %s\n",coin->smartaddr);
}
if ( retval < 0 )
{
if ( pair >= 0 )
@ -586,31 +618,16 @@ int32_t LP_alice_eligible(uint32_t quotetime)
char *LP_connectedalice(struct LP_quoteinfo *qp,char *pairstr) // alice
{
cJSON *retjson; char otheraddr[64]; double bid,ask,price,qprice; int32_t pairsock = -1; int32_t DEXselector = 0; struct LP_utxoinfo *autxo,A,B,*butxo; struct basilisk_swap *swap; struct iguana_info *coin;
/*if ( LP_quoteparse(&Q,argjson) < 0 )
{
LP_aliceid(Q.tradeid,Q.aliceid,"error0",0,0);
clonestr("{\"error\":\"cant parse quote\"}");
}*/
cJSON *retjson; char otheraddr[64],*msg; double bid,ask,price,qprice; int32_t pairsock = -1; int32_t DEXselector = 0; struct LP_utxoinfo *autxo,A,B,*butxo; struct basilisk_swap *swap; struct iguana_info *coin;
if ( bits256_cmp(qp->desthash,G.LP_mypub25519) != 0 )
{
LP_aliceid(qp->tradeid,qp->aliceid,"error1",0,0);
LP_failedmsg(qp->R.requestid,qp->R.quoteid,-4000);
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);
//printf("calculated requestid.%u quoteid.%u\n",qp->R.requestid,qp->R.quoteid);
/*if ( LP_pendingswap(qp->R.requestid,qp->R.quoteid) > 0 )
{
printf("requestid.%u quoteid.%u is already in progres\n",qp->R.requestid,qp->R.quoteid);
retjson = cJSON_CreateObject();
jaddstr(retjson,"error","swap already in progress");
return(jprint(retjson,1));
}*/
/*if ( LP_quotecmp(1,qp,&LP_Alicereserved) == 0 )
{
printf("mismatched between reserved and connected\n");
}*/
memset(&LP_Alicereserved,0,sizeof(LP_Alicereserved));
LP_aliceid(qp->tradeid,qp->aliceid,"connected",qp->R.requestid,qp->R.quoteid);
autxo = &A;
@ -623,6 +640,7 @@ char *LP_connectedalice(struct LP_quoteinfo *qp,char *pairstr) // alice
LP_availableset(qp->desttxid,qp->vout);
LP_availableset(qp->feetxid,qp->feevout);
LP_aliceid(qp->tradeid,qp->aliceid,"error4",0,0);
LP_failedmsg(qp->R.requestid,qp->R.quoteid,qprice);
printf("quote %s/%s validate error %.0f\n",qp->srccoin,qp->destcoin,qprice);
return(clonestr("{\"error\":\"quote validation error\"}"));
}
@ -632,6 +650,7 @@ char *LP_connectedalice(struct LP_quoteinfo *qp,char *pairstr) // alice
LP_availableset(qp->desttxid,qp->vout);
LP_availableset(qp->feetxid,qp->feevout);
LP_aliceid(qp->tradeid,qp->aliceid,"error5",0,0);
LP_failedmsg(qp->R.requestid,qp->R.quoteid,-4002);
return(clonestr("{\"error\":\"no price set\"}"));
}
//LP_RTmetrics_update(qp->srccoin,qp->destcoin);
@ -640,6 +659,7 @@ char *LP_connectedalice(struct LP_quoteinfo *qp,char *pairstr) // alice
if ( (coin= LP_coinfind(qp->destcoin)) == 0 )
{
LP_aliceid(qp->tradeid,qp->aliceid,"error6",0,0);
LP_failedmsg(qp->R.requestid,qp->R.quoteid,-4003);
return(clonestr("{\"error\":\"cant get alicecoin\"}"));
}
qp->privkey = LP_privkey(coin->symbol,qp->destaddr,coin->taddr);
@ -652,11 +672,13 @@ char *LP_connectedalice(struct LP_quoteinfo *qp,char *pairstr) // alice
LP_availableset(qp->desttxid,qp->vout);
LP_availableset(qp->feetxid,qp->feevout);
LP_aliceid(qp->tradeid,qp->aliceid,"error7",qp->R.requestid,qp->R.quoteid);
LP_failedmsg(qp->R.requestid,qp->R.quoteid,-4004);
return(jprint(retjson,1));
}
if ( pairstr == 0 || pairstr[0] == 0 || (pairsock= nn_socket(AF_SP,NN_PAIR)) < 0 )
{
LP_aliceid(qp->tradeid,qp->aliceid,"error8",qp->R.requestid,qp->R.quoteid);
LP_failedmsg(qp->R.requestid,qp->R.quoteid,-4005);
jaddstr(retjson,"error","couldnt create pairsock");
}
else if ( nn_connect(pairsock,pairstr) >= 0 )
@ -677,6 +699,13 @@ char *LP_connectedalice(struct LP_quoteinfo *qp,char *pairstr) // alice
{
retjson = LP_quotejson(qp);
jaddstr(retjson,"result","success");
LP_swapsfp_update(qp->R.requestid,qp->R.quoteid);
if ( IPC_ENDPOINT >= 0 )
{
msg = jprint(retjson,0);
LP_queuecommand(0,msg,IPC_ENDPOINT,-1,0);
free(msg);
}
//jaddnum(retjson,"requestid",qp->R.requestid);
//jaddnum(retjson,"quoteid",qp->R.quoteid);
}
@ -684,12 +713,14 @@ char *LP_connectedalice(struct LP_quoteinfo *qp,char *pairstr) // alice
{
LP_aliceid(qp->tradeid,qp->aliceid,"error9",qp->R.requestid,qp->R.quoteid);
jaddstr(retjson,"error","couldnt aliceloop");
LP_failedmsg(qp->R.requestid,qp->R.quoteid,-4006);
}
}
else
{
LP_aliceid(qp->tradeid,qp->aliceid,"error10",qp->R.requestid,qp->R.quoteid);
printf("connect error %s\n",nn_strerror(nn_errno()));
LP_failedmsg(qp->R.requestid,qp->R.quoteid,-4007);
}
//printf("connected result.(%s)\n",jprint(retjson,0));
if ( jobj(retjson,"error") != 0 )
@ -705,6 +736,7 @@ char *LP_connectedalice(struct LP_quoteinfo *qp,char *pairstr) // alice
LP_availableset(qp->feetxid,qp->feevout);
LP_aliceid(qp->tradeid,qp->aliceid,"error11",0,0);
printf("no privkey found coin.%s %s taddr.%u\n",qp->destcoin,qp->destaddr,coin->taddr);
LP_failedmsg(qp->R.requestid,qp->R.quoteid,-4008);
return(clonestr("{\"error\",\"no privkey\"}"));
}
}
@ -965,9 +997,17 @@ struct LP_quoteinfo *LP_trades_gotrequest(void *ctx,struct LP_quoteinfo *qp,stru
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;
if ( i == 0 && p < myprice )
{
price = qprice;
printf("reset price <- qprice %.8f\n",qprice);
}
else
{
if ( qprice >= p )
break;
price *= 0.995;
}
i++;
}
printf("i.%d qprice %.8f myprice %.8f price %.8f [%.8f]\n",i,qprice,myprice,price,p);
@ -1006,14 +1046,13 @@ struct LP_quoteinfo *LP_trades_gotreserved(void *ctx,struct LP_quoteinfo *qp,str
if ( (retstr= LP_quotereceived(qp)) != 0 )
free(retstr);
return(qp);
}
} else LP_failedmsg(qp->R.requestid,qp->R.quoteid,qprice);
return(0);
}
struct LP_quoteinfo *LP_trades_gotconnect(void *ctx,struct LP_quoteinfo *qp,struct LP_quoteinfo *newqp,char *pairstr)
{
double myprice,qprice,bid,ask; struct iguana_info *coin;
char str[65]; printf("bob %s received CONNECT.(%llu)\n",bits256_str(str,G.LP_mypub25519),(long long)qp->aliceid);
*newqp = *qp;
qp = newqp;
if ( (coin= LP_coinfind(qp->srccoin)) == 0 )
@ -1024,20 +1063,25 @@ struct LP_quoteinfo *LP_trades_gotconnect(void *ctx,struct LP_quoteinfo *qp,stru
return(0);
if ( LP_reservation_check(qp->txid,qp->vout,qp->desthash) == 0 && LP_reservation_check(qp->txid2,qp->vout2,qp->desthash) == 0 )
{
printf("CONNECT STARTBOB!\n");
char str[65]; printf("bob %s received CONNECT.(%llu)\n",bits256_str(str,G.LP_mypub25519),(long long)qp->aliceid);
LP_connectstartbob(ctx,LP_mypubsock,qp->srccoin,qp->destcoin,qprice,qp);
return(qp);
} else printf("connect message from non-reserved (%llu)\n",(long long)qp->aliceid);
}
else
{
LP_failedmsg(qp->R.requestid,qp->R.quoteid,-1);
printf("connect message from non-reserved (%llu)\n",(long long)qp->aliceid);
}
return(0);
}
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; double val;
//char str[65]; printf("alice %s received CONNECTED.(%llu)\n",bits256_str(str,G.LP_mypub25519),(long long)qp->aliceid);
*newqp = *qp;
qp = newqp;
if ( LP_trades_alicevalidate(ctx,qp) > 0. )
if ( (val= LP_trades_alicevalidate(ctx,qp)) > 0. )
{
printf("CONNECTED ALICE\n");
LP_aliceid(qp->tradeid,qp->aliceid,"connected",0,0);
@ -1046,7 +1090,7 @@ struct LP_quoteinfo *LP_trades_gotconnected(void *ctx,struct LP_quoteinfo *qp,st
LP_mypriceset(&changed,qp->destcoin,qp->srccoin,0.);
LP_alicequery_clear();
return(qp);
}
} else LP_failedmsg(qp->R.requestid,qp->R.quoteid,val);
//printf("LP_trades_alicevalidate error\n");
return(0);
}
@ -1279,13 +1323,13 @@ 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_tradecommand_log(argjson);
rq = ((uint64_t)Q.R.requestid << 32) | Q.R.quoteid;
if ( Q.timestamp > 0 && time(NULL) > Q.timestamp + LP_AUTOTRADE_TIMEOUT*20 ) // eat expired packets, some old timestamps floating about?
{
printf("aliceid.%llu is expired by %d\n",(long long)Q.aliceid,(uint32_t)time(NULL) - (Q.timestamp + LP_AUTOTRADE_TIMEOUT*20));
return(1);
}
LP_tradecommand_log(argjson);
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);
@ -1362,6 +1406,8 @@ int32_t LP_tradecommand(void *ctx,char *myipaddr,int32_t pubsock,cJSON *argjson,
}
if ( strcmp(method,"request") == 0 ) // bob
{
//if ( LP_Alicemaxprice != 0. )
// return(retval);
bestprice = LP_bob_competition(&counter,aliceid,qprice,-1);
if ( Qtrades == 0 )//|| (bits256_cmp(Q.srchash,G.LP_mypub25519) == 0 && bits256_cmp(G.LP_mypub25519,Q.desthash) != 0) )
LP_trades_gotrequest(ctx,&Q,&Q2,jstr(argjson,"pair"));

40
iguana/exchanges/LP_privkey.c

@ -251,6 +251,43 @@ int32_t LP_wifstr_valid(char *symbol,char *wifstr)
return(0);
}
char *LP_convaddress(char *symbol,char *address,char *dest)
{
struct iguana_info *coin,*destcoin; cJSON *retjson; char destaddress[64],coinaddr2[64]; uint8_t addrtype,rmd160[20],rmd160b[20];
if ( (coin= LP_coinfind(symbol)) == 0 || (destcoin= LP_coinfind(dest)) == 0 )
return(clonestr("{\"error\":\"both coins must be present\"}"));
retjson = cJSON_CreateObject();
jaddstr(retjson,"result","success");
jaddstr(retjson,"coin",symbol);
jaddstr(retjson,"address",address);
jaddstr(retjson,"destcoin",dest);
bitcoin_addr2rmd160(symbol,coin->taddr,&addrtype,rmd160,address);
if ( addrtype == coin->pubtype )
{
bitcoin_address(destcoin->symbol,destaddress,destcoin->taddr,destcoin->pubtype,rmd160,20);
bitcoin_addr2rmd160(destcoin->symbol,destcoin->taddr,&addrtype,rmd160b,destaddress);
bitcoin_address(coin->symbol,coinaddr2,coin->taddr,coin->pubtype,rmd160b,20);
}
else if ( addrtype == coin->p2shtype )
{
bitcoin_address(destcoin->symbol,destaddress,destcoin->taddr,destcoin->p2shtype,rmd160,20);
bitcoin_addr2rmd160(symbol,coin->taddr,&addrtype,rmd160b,destaddress);
bitcoin_address(destcoin->symbol,coinaddr2,coin->taddr,coin->p2shtype,rmd160b,20);
}
else
{
jaddstr(retjson,"error","invalid base58 prefix");
jaddnum(retjson,"invalid",addrtype);
}
if ( strcmp(address,coinaddr2) != 0 )
{
jaddstr(retjson,"error","checkaddress mismatch");
jaddstr(retjson,"checkaddress",coinaddr2);
}
jaddstr(retjson,"destaddress",destaddress);
return(jprint(retjson,1));
}
bits256 LP_privkeycalc(void *ctx,uint8_t *pubkey33,bits256 *pubkeyp,struct iguana_info *coin,char *passphrase,char *wifstr)
{
//static uint32_t counter;
@ -321,12 +358,13 @@ bits256 LP_privkeycalc(void *ctx,uint8_t *pubkey33,bits256 *pubkeyp,struct iguan
}
#endif
OS_randombytes(tmpkey.bytes,sizeof(tmpkey));
siglen = 0;
if ( bits256_nonz(privkey) == 0 || (siglen= bitcoin_sign(ctx,coin->symbol,sig,tmpkey,privkey,0)) <= 0 )
{
printf("illegal privkey %s\n",bits256_str(str,privkey));
exit(0);
}
if ( bitcoin_verify(ctx,sig,siglen,tmpkey,coin->pubkey33,33) != 0 )
if ( bits256_nonz(privkey) != 0 && bitcoin_verify(ctx,sig,siglen,tmpkey,coin->pubkey33,33) != 0 )
{
printf("signature.[%d] for %s by %s didnt verify\n",siglen,bits256_str(str,tmpkey),bits256_str(str2,privkey));
exit(0);

89
iguana/exchanges/LP_remember.c

@ -235,6 +235,31 @@ void basilisk_dontforget_update(struct basilisk_swap *swap,struct basilisk_rawtx
}
else if ( rawtx == &swap->bobreclaim )
basilisk_dontforget(swap,&swap->bobreclaim,swap->bobpayment.I.locktime,triggertxid);
if ( IPC_ENDPOINT >= 0 )
{
char fname[512],*fstr,*outstr; long fsize; cJSON *reqjson;
sprintf(fname,"%s/SWAPS/%u-%u",GLOBAL_DBDIR,swap->I.req.requestid,swap->I.req.quoteid), OS_compatible_path(fname);
if ( rawtx != 0 )
sprintf(fname+strlen(fname),".%s",rawtx->name);
if ( (fstr= OS_filestr(&fsize,fname)) != 0 )
{
if ( (reqjson= cJSON_Parse(fstr)) != 0 )
{
if ( jobj(reqjson,"method") != 0 )
jdelete(reqjson,"method");
jaddstr(reqjson,"method","update");
if ( jobj(reqjson,"update") != 0 )
jdelete(reqjson,"update");
if ( rawtx != 0 )
jaddstr(reqjson,"update",rawtx->name);
else jaddstr(reqjson,"update","main");
outstr = jprint(reqjson,1);
LP_queuecommand(0,outstr,IPC_ENDPOINT,-1,0);
free(outstr);
}
free(fstr);
}
}
}
bits256 basilisk_swap_privbob_extract(char *symbol,bits256 spendtxid,int32_t vini,int32_t revflag)
@ -290,7 +315,7 @@ bits256 basilisk_swap_spendupdate(int32_t iambob,char *symbol,char *spentaddr,in
printf("i.%d of %d: %s\n",i,n,bits256_str(str,txid));
if ( bits256_cmp(txid,txids[utxoind]) != 0 )
{
if ( (txobj= LP_gettx(symbol,txid,1)) != 0 )
if ( (txobj= LP_gettx("basilisk_swap_spendupdate",symbol,txid,1)) != 0 )
{
if ( (vins= jarray(&numvins,txobj,"vin")) != 0 )
{
@ -934,7 +959,7 @@ int32_t LP_swap_load(struct LP_swap_remember *rswap,int32_t forceflag)
safecopy(rswap->alicecoin,symbol,sizeof(rswap->alicecoin));
if ( rswap->finishedflag == 0 )
{
if ( (sentobj= LP_gettx(symbol,txid,1)) == 0 )
if ( (sentobj= LP_gettx("LP_remember",symbol,txid,1)) == 0 )
{
//char str2[65]; printf("%s %s ready to broadcast %s r%u q%u\n",symbol,bits256_str(str2,txid),txnames[i],rswap->requestid,rswap->quoteid);
}
@ -1030,7 +1055,7 @@ int32_t LP_spends_set(struct LP_swap_remember *rswap)
return(numspent);
}
cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requestid,uint32_t quoteid,int32_t forceflag,int32_t pendingonly)
cJSON *basilisk_remember(int32_t fastflag,int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requestid,uint32_t quoteid,int32_t forceflag,int32_t pendingonly)
{
static void *ctx;
struct LP_swap_remember rswap; int32_t i,j,flag,numspent,len,secretstart,redeemlen; char str[65],*srcAdest,*srcBdest,*destAdest,*destBdest,otheraddr[64],*fstr,fname[512],bobtomic[128],alicetomic[128],bobstr[65],alicestr[65]; cJSON *item,*txoutobj,*retjson; bits256 rev,revAm,signedtxid,zero,deadtxid; uint32_t claimtime; struct iguana_info *bob=0,*alice=0; uint8_t redeemscript[1024],userdata[1024]; long fsize;
@ -1162,19 +1187,20 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti
printf("Bob.%p is null or Alice.%p is null\n",bob,alice);
return(cJSON_Parse("{\"error\":\"null bob or alice coin\"}"));
}
if ( alice->inactive != 0 || bob->inactive != 0 )
{
printf("Alice.%s inactive.%u or Bob.%s inactive.%u\n",rswap.alicecoin,alice->inactive,rswap.bobcoin,bob->inactive);
return(cJSON_Parse("{\"error\":\"inactive bob or alice coin\"}"));
}
//printf("src.(Adest %s, Bdest %s), dest.(Adest %s, Bdest %s)\n",srcAdest,srcBdest,destAdest,destBdest);
//printf("iambob.%d finishedflag.%d %s %.8f txfee, %s %.8f txfee\n",rswap.iambob,rswap.finishedflag,rswap.alicecoin,dstr(rswap.Atxfee),rswap.bobcoin,dstr(rswap.Btxfee));
//printf("privAm.(%s) %p/%p\n",bits256_str(str,rswap.privAm),Adest,AAdest);
//printf("privBn.(%s) %p/%p\n",bits256_str(str,rswap.privBn),Bdest,ABdest);
if ( rswap.finishedflag == 0 && rswap.bobcoin[0] != 0 && rswap.alicecoin[0] != 0 )
if ( fastflag == 0 && rswap.finishedflag == 0 && rswap.bobcoin[0] != 0 && rswap.alicecoin[0] != 0 )
{
//printf("ALICE.(%s) 1st refht %s <- %d, scan %d %d\n",rswap.Adestaddr,alice->symbol,alice->firstrefht,alice->firstscanht,alice->lastscanht);
portable_mutex_lock(&LP_swaplistmutex);
//printf("ALICE.(%s) 1st refht %s <- %d, scan %d %d\n",rswap.Adestaddr,alice->symbol,alice->firstrefht,alice->firstscanht,alice->lastscanht);
//printf("BOB.(%s) 1st refht %s <- %d, scan %d %d\n",rswap.destaddr,bob->symbol,bob->firstrefht,bob->firstscanht,bob->lastscanht);
if ( alice->inactive != 0 || bob->inactive != 0 )
{
printf("Alice.%s inactive.%u or Bob.%s inactive.%u\n",rswap.alicecoin,alice->inactive,rswap.bobcoin,bob->inactive);
return(cJSON_Parse("{\"error\":\"inactive bob or alice coin\"}"));
}
LP_rswap_checktx(&rswap,rswap.alicecoin,BASILISK_ALICEPAYMENT);
LP_rswap_checktx(&rswap,rswap.bobcoin,BASILISK_BOBPAYMENT);
LP_rswap_checktx(&rswap,rswap.bobcoin,BASILISK_BOBDEPOSIT);
@ -1220,7 +1246,8 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti
printf("%02x",secretAm[j]);
printf(" secretAm, privAm %s alicespend len.%d redeemlen.%d\n",bits256_str(str,rswap.privAm),len,redeemlen);
}
if ( (rswap.txbytes[BASILISK_ALICESPEND]= basilisk_swap_bobtxspend(&signedtxid,rswap.Btxfee,"alicespend",rswap.bobcoin,bob->wiftaddr,bob->taddr,bob->pubtype,bob->p2shtype,bob->isPoS,bob->wiftype,ctx,rswap.myprivs[0],0,redeemscript,redeemlen,userdata,len,rswap.txids[BASILISK_BOBPAYMENT],0,0,rswap.pubkey33,1,rswap.expiration,&rswap.values[BASILISK_ALICESPEND],0,0,rswap.bobpaymentaddr,1,bob->zcash)) != 0 )
claimtime = LP_claimtime(bob,rswap.plocktime - 777);
if ( (rswap.txbytes[BASILISK_ALICESPEND]= basilisk_swap_bobtxspend(&signedtxid,rswap.Btxfee,"alicespend",rswap.bobcoin,bob->wiftaddr,bob->taddr,bob->pubtype,bob->p2shtype,bob->isPoS,bob->wiftype,ctx,rswap.myprivs[0],0,redeemscript,redeemlen,userdata,len,rswap.txids[BASILISK_BOBPAYMENT],0,0,rswap.pubkey33,1,claimtime,&rswap.values[BASILISK_ALICESPEND],0,0,rswap.bobpaymentaddr,1,bob->zcash)) != 0 )
{
//printf("alicespend.(%s)\n",rswap.txbytes[BASILISK_ALICESPEND]);
#ifndef NOTETOMIC
@ -1264,7 +1291,8 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti
for (i=0; i<32; i++)
revAm.bytes[i] = rswap.privAm.bytes[31-i];
len = basilisk_swapuserdata(userdata,revAm,1,rswap.myprivs[0],redeemscript,redeemlen);
if ( (rswap.txbytes[BASILISK_ALICECLAIM]= basilisk_swap_bobtxspend(&signedtxid,rswap.Btxfee,"aliceclaim",rswap.bobcoin,bob->wiftaddr,bob->taddr,bob->pubtype,bob->p2shtype,bob->isPoS,bob->wiftype,ctx,rswap.myprivs[0],0,redeemscript,redeemlen,userdata,len,rswap.txids[BASILISK_BOBDEPOSIT],0,0,rswap.pubkey33,0,rswap.dlocktime+777,&rswap.values[BASILISK_ALICECLAIM],0,0,rswap.bobdepositaddr,1,bob->zcash)) != 0 )
claimtime = LP_claimtime(bob,rswap.dlocktime);
if ( (rswap.txbytes[BASILISK_ALICECLAIM]= basilisk_swap_bobtxspend(&signedtxid,rswap.Btxfee,"aliceclaim",rswap.bobcoin,bob->wiftaddr,bob->taddr,bob->pubtype,bob->p2shtype,bob->isPoS,bob->wiftype,ctx,rswap.myprivs[0],0,redeemscript,redeemlen,userdata,len,rswap.txids[BASILISK_BOBDEPOSIT],0,0,rswap.pubkey33,0,claimtime,&rswap.values[BASILISK_ALICECLAIM],0,0,rswap.bobdepositaddr,1,bob->zcash)) != 0 )
{
//printf("dlocktime.%u claimtime.%u aliceclaim.(%s)\n",rswap.dlocktime,claimtime,rswap.txbytes[BASILISK_ALICECLAIM]);
#ifndef NOTETOMIC
@ -1369,7 +1397,8 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti
if ( redeemlen > 0 )
{
len = basilisk_swapuserdata(userdata,zero,1,rswap.myprivs[1],redeemscript,redeemlen);
if ( (rswap.txbytes[BASILISK_BOBRECLAIM]= basilisk_swap_bobtxspend(&signedtxid,rswap.Btxfee,"bobreclaim",rswap.bobcoin,bob->wiftaddr,bob->taddr,bob->pubtype,bob->p2shtype,bob->isPoS,bob->wiftype,ctx,rswap.myprivs[1],0,redeemscript,redeemlen,userdata,len,rswap.txids[BASILISK_BOBPAYMENT],0,0,rswap.pubkey33,0,rswap.plocktime+777,&rswap.values[BASILISK_BOBRECLAIM],0,0,rswap.bobpaymentaddr,1,bob->zcash)) != 0 )
claimtime = LP_claimtime(bob,rswap.plocktime - 777);
if ( (rswap.txbytes[BASILISK_BOBRECLAIM]= basilisk_swap_bobtxspend(&signedtxid,rswap.Btxfee,"bobreclaim",rswap.bobcoin,bob->wiftaddr,bob->taddr,bob->pubtype,bob->p2shtype,bob->isPoS,bob->wiftype,ctx,rswap.myprivs[1],0,redeemscript,redeemlen,userdata,len,rswap.txids[BASILISK_BOBPAYMENT],0,0,rswap.pubkey33,0,claimtime,&rswap.values[BASILISK_BOBRECLAIM],0,0,rswap.bobpaymentaddr,1,bob->zcash)) != 0 )
{
#ifndef NOTETOMIC
if ( rswap.bobtomic[0] != 0 )
@ -1401,7 +1430,7 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti
free_json(txoutobj), flag = 0;
else flag = -1, rswap.depositspent = deadtxid;
}
if ( flag == 0 && (bits256_nonz(rswap.Apaymentspent) != 0 || time(NULL) > rswap.dlocktime-777 || (bits256_nonz(rswap.txids[BASILISK_ALICEPAYMENT]) == 0 && time(NULL) > rswap.dlocktime-2*INSTANTDEX_LOCKTIME+777) || (bits256_nonz(rswap.txids[BASILISK_BOBPAYMENT]) == 0 && time(NULL) > rswap.dlocktime-3*INSTANTDEX_LOCKTIME/2)) )
if ( flag == 0 && (bits256_nonz(rswap.Apaymentspent) != 0 || time(NULL) > rswap.dlocktime-777 || (bits256_nonz(rswap.txids[BASILISK_ALICEPAYMENT]) == 0 && time(NULL) > rswap.plocktime-777) || (bits256_nonz(rswap.txids[BASILISK_BOBPAYMENT]) == 0 && time(NULL) > rswap.dlocktime-3*INSTANTDEX_LOCKTIME/2)) )
{
//printf("do the refund! paymentspent.%s now.%u vs expiration.%u\n",bits256_str(str,rswap.paymentspent),(uint32_t)time(NULL),rswap.expiration);
//if ( txbytes[BASILISK_BOBREFUND] == 0 )
@ -1410,7 +1439,8 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti
vcalc_sha256(0,rswap.secretBn256,rswap.privBn.bytes,sizeof(rswap.privBn));
redeemlen = basilisk_swap_bobredeemscript(1,&secretstart,redeemscript,rswap.dlocktime,rswap.pubA0,rswap.pubB0,rswap.pubB1,rswap.privAm,rswap.privBn,rswap.secretAm,rswap.secretAm256,rswap.secretBn,rswap.secretBn256);
len = basilisk_swapuserdata(userdata,rswap.privBn,0,rswap.myprivs[0],redeemscript,redeemlen);
if ( (rswap.txbytes[BASILISK_BOBREFUND]= basilisk_swap_bobtxspend(&signedtxid,rswap.Btxfee,"bobrefund",rswap.bobcoin,bob->wiftaddr,bob->taddr,bob->pubtype,bob->p2shtype,bob->isPoS,bob->wiftype,ctx,rswap.myprivs[0],0,redeemscript,redeemlen,userdata,len,rswap.txids[BASILISK_BOBDEPOSIT],0,0,rswap.pubkey33,1,rswap.expiration,&rswap.values[BASILISK_BOBREFUND],0,0,rswap.bobdepositaddr,1,bob->zcash)) != 0 )
claimtime = LP_claimtime(bob,rswap.plocktime - 777);
if ( (rswap.txbytes[BASILISK_BOBREFUND]= basilisk_swap_bobtxspend(&signedtxid,rswap.Btxfee,"bobrefund",rswap.bobcoin,bob->wiftaddr,bob->taddr,bob->pubtype,bob->p2shtype,bob->isPoS,bob->wiftype,ctx,rswap.myprivs[0],0,redeemscript,redeemlen,userdata,len,rswap.txids[BASILISK_BOBDEPOSIT],0,0,rswap.pubkey33,1,claimtime,&rswap.values[BASILISK_BOBREFUND],0,0,rswap.bobdepositaddr,1,bob->zcash)) != 0 )
{
#ifndef NOTETOMIC
if ( rswap.bobtomic[0] != 0 )
@ -1428,6 +1458,7 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti
printf("bobrefund's time %u vs expiration %u\n",(uint32_t)time(NULL),rswap.expiration);
}
}
portable_mutex_unlock(&LP_swaplistmutex);
}
//printf("finish.%d iambob.%d REFUND %d %d %d %d\n",finishedflag,iambob,sentflags[BASILISK_BOBREFUND] == 0,sentflags[BASILISK_BOBDEPOSIT] != 0,bits256_nonz(txids[BASILISK_BOBDEPOSIT]) != 0,bits256_nonz(depositspent) == 0);
if ( rswap.sentflags[BASILISK_ALICESPEND] != 0 || rswap.sentflags[BASILISK_BOBRECLAIM] != 0 )
@ -1511,10 +1542,10 @@ void for_satinder()
} else printf("error with satinder tx\n");
}
char *basilisk_swaplist(uint32_t origrequestid,uint32_t origquoteid,int32_t forceflag,int32_t pendingonly)
char *basilisk_swaplist(int32_t fastflag,uint32_t origrequestid,uint32_t origquoteid,int32_t forceflag,int32_t pendingonly)
{
uint64_t ridqids[4096],ridqid; char fname[512]; FILE *fp; cJSON *item,*retjson,*array,*totalsobj; uint32_t r,q,quoteid,requestid; int64_t KMDtotals[LP_MAXPRICEINFOS],BTCtotals[LP_MAXPRICEINFOS],Btotal,Ktotal; int32_t i,j,count=0;
portable_mutex_lock(&LP_swaplistmutex);
//portable_mutex_lock(&LP_swaplistmutex);
memset(ridqids,0,sizeof(ridqids));
memset(KMDtotals,0,sizeof(KMDtotals));
memset(BTCtotals,0,sizeof(BTCtotals));
@ -1524,7 +1555,7 @@ char *basilisk_swaplist(uint32_t origrequestid,uint32_t origquoteid,int32_t forc
if ( origrequestid != 0 && origquoteid != 0 )
{
//printf("orig req.%u q.%u\n",origrequestid,origquoteid);
if ( (item= basilisk_remember(KMDtotals,BTCtotals,origrequestid,origquoteid,forceflag,0)) != 0 )
if ( (item= basilisk_remember(fastflag,KMDtotals,BTCtotals,origrequestid,origquoteid,forceflag,0)) != 0 )
jaddi(array,item);
//printf("got.(%s)\n",jprint(item,0));
}
@ -1566,7 +1597,7 @@ char *basilisk_swaplist(uint32_t origrequestid,uint32_t origquoteid,int32_t forc
{
if ( count < sizeof(ridqids)/sizeof(*ridqids) )
ridqids[count++] = ridqid;
if ( (item= basilisk_remember(KMDtotals,BTCtotals,requestid,quoteid,0,pendingonly)) != 0 )
if ( (item= basilisk_remember(fastflag,KMDtotals,BTCtotals,requestid,quoteid,0,pendingonly)) != 0 )
jaddi(array,item);
}
}
@ -1595,16 +1626,16 @@ char *basilisk_swaplist(uint32_t origrequestid,uint32_t origquoteid,int32_t forc
else if ( Ktotal < 0 && Btotal > 0 )
jaddnum(retjson,"avesell",(double)-Btotal/Ktotal);
}
portable_mutex_unlock(&LP_swaplistmutex);
//portable_mutex_unlock(&LP_swaplistmutex);
return(jprint(retjson,1));
}
char *basilisk_swapentry(uint32_t requestid,uint32_t quoteid,int32_t forceflag)
char *basilisk_swapentry(int32_t fastflag,uint32_t requestid,uint32_t quoteid,int32_t forceflag)
{
cJSON *item; int64_t KMDtotals[LP_MAXPRICEINFOS],BTCtotals[LP_MAXPRICEINFOS];
memset(KMDtotals,0,sizeof(KMDtotals));
memset(BTCtotals,0,sizeof(BTCtotals));
if ( (item= basilisk_remember(KMDtotals,BTCtotals,requestid,quoteid,forceflag,0)) != 0 )
if ( (item= basilisk_remember(fastflag,KMDtotals,BTCtotals,requestid,quoteid,forceflag,0)) != 0 )
return(jprint(item,1));
else return(clonestr("{\"error\":\"cant find requestid-quoteid\"}"));
}
@ -1639,7 +1670,7 @@ char *LP_recent_swaps(int32_t limit)
item = cJSON_CreateArray();
jaddinum(item,requestid);
jaddinum(item,quoteid);
if ( (retstr= basilisk_swapentry(requestid,quoteid,0)) != 0 )
if ( (retstr= basilisk_swapentry(1,requestid,quoteid,0)) != 0 )
{
if ( (swapjson= cJSON_Parse(retstr)) != 0 )
{
@ -1731,14 +1762,14 @@ uint64_t basilisk_swap_addarray(cJSON *item,char *refbase,char *refrel)
return(ridqid);
}
char *basilisk_swapentries(char *refbase,char *refrel,int32_t limit)
char *basilisk_swapentries(int32_t fastflag,char *refbase,char *refrel,int32_t limit)
{
uint64_t ridqids[1024],ridqid; char *liststr,*retstr2; cJSON *retjson,*array,*pending,*swapjson,*item,*retarray; int32_t i,j,n,count = 0; uint32_t requestid,quoteid;
if ( limit <= 0 )
limit = 10;
memset(ridqids,0,sizeof(ridqids));
retarray = cJSON_CreateArray();
if ( (liststr= basilisk_swaplist(0,0,0,0)) != 0 )
if ( (liststr= basilisk_swaplist(fastflag,0,0,0,0)) != 0 )
{
//printf("swapentry.(%s)\n",liststr);
if ( (retjson= cJSON_Parse(liststr)) != 0 )
@ -1760,6 +1791,7 @@ char *basilisk_swapentries(char *refbase,char *refrel,int32_t limit)
}
}
free_json(retjson);
retjson = 0;
}
free(liststr);
}
@ -1778,10 +1810,10 @@ char *basilisk_swapentries(char *refbase,char *refrel,int32_t limit)
for (j=0; j<count; j++)
if ( ridqid == ridqids[j] )
break;
//printf("j.%d count.%d %u %u ridqid.%16llx\n",j,count,requestid,quoteid,(long long)ridqid);
if ( j == count )
{
if ( (retstr2= basilisk_swapentry(requestid,quoteid,0)) != 0 )
printf("j.%d count.%d %u %u ridqid.%16llx\n",j,count,requestid,quoteid,(long long)ridqid);
if ( (retstr2= basilisk_swapentry(1,requestid,quoteid,0)) != 0 )
{
if ( (swapjson= cJSON_Parse(retstr2)) != 0 )
{
@ -1812,8 +1844,7 @@ char *basilisk_swapentries(char *refbase,char *refrel,int32_t limit)
{
if ( basilisk_swap_addarray(pending,refbase,refrel) > 0 )
jaddi(retarray,jduplicate(pending));
else free_json(pending);
} else free_json(pending);
}
}
free_json(retjson);
}

17
iguana/exchanges/LP_rpc.c

@ -179,10 +179,10 @@ cJSON *LP_paxprice(char *fiat)
return(bitcoin_json(coin,"paxprice",buf));
}
cJSON *LP_gettx(char *symbol,bits256 txid,int32_t suppress_errors)
cJSON *LP_gettx(char *debug,char *symbol,bits256 txid,int32_t suppress_errors)
{
struct iguana_info *coin; char buf[512],str[65]; int32_t height; cJSON *retjson;
//printf("LP_gettx %s %s\n",symbol,bits256_str(str,txid));
//printf("%s LP_gettx %s %s\n",debug,symbol,bits256_str(str,txid));
if ( symbol == 0 || symbol[0] == 0 )
return(cJSON_Parse("{\"error\":\"null symbol\"}"));
coin = LP_coinfind(symbol);
@ -209,7 +209,7 @@ cJSON *LP_gettx(char *symbol,bits256 txid,int32_t suppress_errors)
uint32_t LP_locktime(char *symbol,bits256 txid)
{
cJSON *txobj; uint32_t locktime = 0;
if ( (txobj= LP_gettx(symbol,txid,0)) != 0 )
if ( (txobj= LP_gettx("LP_locktime",symbol,txid,0)) != 0 )
{
locktime = juint(txobj,"locktime");
free_json(txobj);
@ -468,6 +468,7 @@ cJSON *LP_listreceivedbyaddress(char *symbol,char *coinaddr)
}
}
}
free_json(array);
}
return(cJSON_Parse("[]"));
} else return(electrum_address_gethistory(symbol,coin->electrum,&retjson,coinaddr,zero));
@ -689,8 +690,6 @@ again:
//rate *= 1.25;
if ( rate < 0.00000005 )
rate = 0.00000005;
//if ( coin->electrum != 0 )
// rate *= 1.5;
if ( fabs(rate - coin->rate) > SMALLVAL )
printf("%u t%u estimated rate.(%s) (%s) -> %.8f %.8f\n",(uint32_t)time(NULL),coin->ratetime,coin->symbol,retstr,rate,coin->rate);
coin->rate = rate;
@ -926,9 +925,9 @@ uint32_t LP_heighttime(char *symbol,int32_t height)
{
if ( (blockhashstr= LP_blockhashstr(symbol,height)) != 0 )
{
if ( (retjson= cJSON_Parse(blockhashstr)) != 0 )
if ( (retjson= LP_getblockhashstr(symbol,blockhashstr)) != 0 )
{
//printf("height.(%s)\n",jprint(retjson,0));
//printf("%s -> height.(%s)\n",blockhashstr,jprint(retjson,0));
timestamp = juint(retjson,"time");
free_json(retjson);
}
@ -1055,7 +1054,7 @@ int32_t LP_txhasnotarization(bits256 *notarizedhashp,struct iguana_info *coin,bi
{
cJSON *txobj,*vins,*vin,*vouts,*vout,*spentobj,*sobj; char *hexstr; uint8_t script[1024]; bits256 spenttxid; uint64_t notarymask; int32_t i,j,numnotaries,len,spentvout,numvins,numvouts,hasnotarization = 0;
memset(notarizedhashp,0,sizeof(*notarizedhashp));
if ( (txobj= LP_gettx(coin->symbol,txid,0)) != 0 )
if ( (txobj= LP_gettx("LP_txhasnotarization",coin->symbol,txid,0)) != 0 )
{
if ( (vins= jarray(&numvins,txobj,"vin")) != 0 )
{
@ -1067,7 +1066,7 @@ int32_t LP_txhasnotarization(bits256 *notarizedhashp,struct iguana_info *coin,bi
vin = jitem(vins,i);
spenttxid = jbits256(vin,"txid");
spentvout = jint(vin,"vout");
if ( (spentobj= LP_gettx(coin->symbol,spenttxid,0)) != 0 )
if ( (spentobj= LP_gettx("LP_txhasnotarization",coin->symbol,spenttxid,0)) != 0 )
{
if ( (vouts= jarray(&numvouts,spentobj,"vout")) != 0 )
{

6
iguana/exchanges/LP_scan.c

@ -448,7 +448,7 @@ int32_t LP_mempoolscan(char *symbol,bits256 searchtxid)
int32_t LP_waitmempool(char *symbol,char *coinaddr,bits256 txid,int32_t vout,int32_t duration)
{
struct iguana_info *coin; bits256 zero; cJSON *array,*item; uint32_t expiration,i,n; int32_t numconfirms = -1;
struct iguana_info *coin; bits256 zero; cJSON *array,*item; uint32_t expiration,i,n; int32_t num,numconfirms = -1;
if ( (coin= LP_coinfind(symbol)) == 0 || coin->inactive != 0 )
{
printf("LP_waitmempool missing coin.%p or inactive\n",coin);
@ -457,8 +457,8 @@ int32_t LP_waitmempool(char *symbol,char *coinaddr,bits256 txid,int32_t vout,int
expiration = (uint32_t)time(NULL) + duration;
while ( LP_STOP_RECEIVED == 0 )
{
if ( LP_gettx_presence(symbol,txid) != 0 )
numconfirms = 0;
if ( LP_gettx_presence(&num,symbol,txid,coinaddr) != 0 )
numconfirms = num;
else
{
if ( coin->electrum == 0 )

5
iguana/exchanges/LP_secp.c

@ -86,7 +86,7 @@ bits256 bitcoin_pub256(void *ctx,bits256 *privkeyp,uint8_t odd_even)
int32_t bitcoin_sign(void *ctx,char *symbol,uint8_t *sig,bits256 txhash2,bits256 privkey,int32_t recoverflag)
{
int32_t fCompressed = 1;
secp256k1_ecdsa_signature SIG; void *funcp; secp256k1_ecdsa_recoverable_signature rSIG; bits256 extra_entropy,seed; uint8_t *entropy; int32_t recid,retval = -1; size_t siglen = 72; secp256k1_pubkey SECPUB,CHECKPUB;
secp256k1_ecdsa_signature SIG,SIGOUT; void *funcp; secp256k1_ecdsa_recoverable_signature rSIG; bits256 extra_entropy,seed; uint8_t *entropy; int32_t recid,retval = -1; size_t siglen = 72; secp256k1_pubkey SECPUB,CHECKPUB;
seed = rand256(0);
extra_entropy = rand256(0);
SECP_ENSURE_CTX
@ -134,7 +134,8 @@ int32_t bitcoin_sign(void *ctx,char *symbol,uint8_t *sig,bits256 txhash2,bits256
{
if ( secp256k1_ecdsa_sign(ctx,&SIG,txhash2.bytes,privkey.bytes,funcp,entropy) != 0 )
{
if ( secp256k1_ecdsa_signature_serialize_der(ctx,sig,&siglen,&SIG) != 0 )
secp256k1_ecdsa_signature_normalize(ctx,&SIGOUT,&SIG);
if ( secp256k1_ecdsa_signature_serialize_der(ctx,sig,&siglen,&SIGOUT) != 0 )
retval = (int32_t)siglen;
}
}

15
iguana/exchanges/LP_signatures.c

@ -458,7 +458,7 @@ char *LP_pricepings(void *ctx,char *myipaddr,int32_t pubsock,char *base,char *re
char *LP_postprice_recv(cJSON *argjson)
{
bits256 pubkey; double price; char *base,*rel;
bits256 pubkey; double price; char *base,*rel,*argstr;
//printf("PRICE POSTED.(%s)\n",jprint(argjson,0));
if ( (base= jstr(argjson,"base")) != 0 && (rel= jstr(argjson,"rel")) != 0 && (price= jdouble(argjson,"price")) > SMALLVAL )
{
@ -467,6 +467,14 @@ char *LP_postprice_recv(cJSON *argjson)
{
if ( LP_price_sigcheck(juint(argjson,"timestamp"),jstr(argjson,"sig"),jstr(argjson,"pubsecp"),pubkey,base,rel,j64bits(argjson,"price64")) == 0 )
{
if ( IPC_ENDPOINT >= 0 )
{
if ( (argstr= jprint(argjson,0)) != 0 )
{
LP_queuecommand(0,argstr,IPC_ENDPOINT,-1,0);
free(argstr);
}
}
//printf("call pricefeed update\n");
LP_pricefeedupdate(pubkey,base,rel,price,jstr(argjson,"utxocoin"),jint(argjson,"n"),jdouble(argjson,"bal")*SATOSHIDEN,jdouble(argjson,"min")*SATOSHIDEN,jdouble(argjson,"max")*SATOSHIDEN,jdouble(argjson,"credits")*SATOSHIDEN);
return(clonestr("{\"result\":\"success\"}"));
@ -698,11 +706,12 @@ void LP_query(void *ctx,char *myipaddr,int32_t mypubsock,char *method,struct LP_
jadd(reqjson,"proof",LP_instantdex_txids(0,coin->smartaddr));
}
msg = jprint(reqjson,1);
//printf("etomicdest.(%s) QUERY.(%s)\n",qp->etomicdest,msg);
//printf("QUERY.(%s)\n",msg);
if ( IPC_ENDPOINT >= 0 )
LP_queuecommand(0,msg,IPC_ENDPOINT,-1,0);
memset(&zero,0,sizeof(zero));
if ( bits256_nonz(qp->srchash) != 0 )
LP_reserved_msg(1,qp->srccoin,qp->destcoin,qp->srchash,clonestr(msg));
printf("QUERY.(%s)\n",msg);
LP_reserved_msg(1,qp->srccoin,qp->destcoin,zero,clonestr(msg));
free(msg);
}

14
iguana/exchanges/LP_stats.c

@ -110,10 +110,14 @@ void LP_tradecommand_log(cJSON *argjson)
}
if ( logfp != 0 )
{
jsonstr = jprint(argjson,0);
fprintf(logfp,"%s\n",jsonstr);
free(jsonstr);
fflush(logfp);
if ( (jsonstr= jprint(argjson,0)) != 0 )
{
if ( IPC_ENDPOINT >= 0 )
LP_queuecommand(0,jsonstr,IPC_ENDPOINT,-1,0);
fprintf(logfp,"%s\n",jsonstr);
free(jsonstr);
fflush(logfp);
}
}
}
@ -674,7 +678,7 @@ char *LP_gettradestatus(uint64_t aliceid,uint32_t requestid,uint32_t quoteid)
return(clonestr("{\"result\":\"success\"}"));
}
}
if ( (swapstr= basilisk_swapentry(requestid,quoteid,0)) != 0 )
if ( (swapstr= basilisk_swapentry(1,requestid,quoteid,0)) != 0 )
{
if ( (swapjson= cJSON_Parse(swapstr)) != 0 )
{

111
iguana/exchanges/LP_swap.c

@ -208,7 +208,7 @@ int32_t LP_pubkeys_data(struct basilisk_swap *swap,uint8_t *data,int32_t maxlen)
data[datalen++] = swap->persistent_pubkey33[i];
for (i=0; i<sizeof(swap->deck)/sizeof(swap->deck[0][0]); i++)
datalen += iguana_rwnum(1,&data[datalen],sizeof(swap->deck[i>>1][i&1]),&swap->deck[i>>1][i&1]);
printf("send >>>>>>>>> r.%u q.%u datalen.%d\n",swap->I.req.requestid,swap->I.req.quoteid,datalen);
//printf("send >>>>>>>>> r.%u q.%u datalen.%d\n",swap->I.req.requestid,swap->I.req.quoteid,datalen);
return(datalen);
}
@ -269,7 +269,7 @@ int32_t LP_pubkeys_verify(struct basilisk_swap *swap,uint8_t *data,int32_t datal
int32_t LP_choosei_data(struct basilisk_swap *swap,uint8_t *data,int32_t maxlen)
{
int32_t i,datalen; char str[65];
int32_t i,datalen; //char str[65];
datalen = iguana_rwnum(1,data,sizeof(swap->I.choosei),&swap->I.choosei);
if ( swap->I.iambob != 0 )
{
@ -277,7 +277,7 @@ int32_t LP_choosei_data(struct basilisk_swap *swap,uint8_t *data,int32_t maxlen)
data[datalen++] = swap->I.pubB0.bytes[i];
for (i=0; i<32; i++)
data[datalen++] = swap->I.pubB1.bytes[i];
printf("SEND pubB0/1 %s\n",bits256_str(str,swap->I.pubB0));
//printf("SEND pubB0/1 %s\n",bits256_str(str,swap->I.pubB0));
}
else
{
@ -285,7 +285,7 @@ int32_t LP_choosei_data(struct basilisk_swap *swap,uint8_t *data,int32_t maxlen)
data[datalen++] = swap->I.pubA0.bytes[i];
for (i=0; i<32; i++)
data[datalen++] = swap->I.pubA1.bytes[i];
printf("SEND pubA0/1 %s\n",bits256_str(str,swap->I.pubA0));
//printf("SEND pubA0/1 %s\n",bits256_str(str,swap->I.pubA0));
}
return(datalen);
}
@ -554,9 +554,10 @@ int32_t LP_sendwait(char *statename,int32_t timeout,int32_t pairsock,struct basi
return(retval);
}
void LP_swapsfp_update(struct basilisk_request *rp)
void LP_swapsfp_update(uint32_t requestid,uint32_t quoteid)
{
static FILE *swapsfp;
portable_mutex_lock(&LP_listmutex);
if ( swapsfp == 0 )
{
char fname[512];
@ -568,10 +569,11 @@ void LP_swapsfp_update(struct basilisk_request *rp)
}
if ( swapsfp != 0 )
{
fwrite(&rp->requestid,1,sizeof(rp->requestid),swapsfp);
fwrite(&rp->quoteid,1,sizeof(rp->quoteid),swapsfp);
fwrite(&requestid,1,sizeof(requestid),swapsfp);
fwrite(&quoteid,1,sizeof(quoteid),swapsfp);
fflush(swapsfp);
}
portable_mutex_unlock(&LP_listmutex);
}
struct basilisk_rawtx *LP_swapdata_rawtx(struct basilisk_swap *swap,uint8_t *data,int32_t maxlen,struct basilisk_rawtx *rawtx)
@ -784,20 +786,19 @@ uint32_t LP_swapwait(uint32_t expiration,uint32_t requestid,uint32_t quoteid,int
}
while ( expiration == 0 || time(NULL) < expiration )
{
if ( (retstr= basilisk_swapentry(requestid,quoteid,1)) != 0 )
if ( (retstr= basilisk_swapentry(0,requestid,quoteid,1)) != 0 )
{
if ( (retjson= cJSON_Parse(retstr)) != 0 )
{
if ( jstr(retjson,"status") != 0 && strcmp(jstr(retjson,"status"),"finished") == 0 )
{
finished = (uint32_t)time(NULL);
free(retstr);
free(retstr), retstr = 0;
break;
}
else if ( expiration != 0 && time(NULL) > expiration )
printf("NOT FINISHED.(%s)\n",jprint(retjson,0));
free_json(retjson);
retjson = 0;
free_json(retjson), retjson = 0;
}
free(retstr);
}
@ -809,7 +810,7 @@ uint32_t LP_swapwait(uint32_t expiration,uint32_t requestid,uint32_t quoteid,int
if ( retjson != 0 )
{
free_json(retjson);
if ( (retstr= basilisk_swapentry(requestid,quoteid,1)) != 0 )
if ( (retstr= basilisk_swapentry(0,requestid,quoteid,1)) != 0 )
{
printf("\n>>>>>>>>>>>>>>>>>>>>>>>>>\nSWAP completed! %u-%u %s\n",requestid,quoteid,retstr);
free(retstr);
@ -828,9 +829,9 @@ uint32_t LP_swapwait(uint32_t expiration,uint32_t requestid,uint32_t quoteid,int
void LP_bobloop(void *_swap)
{
uint8_t *data; char bobstr[65],alicestr[65]; int32_t maxlen,m,n; uint32_t expiration; struct basilisk_swap *swap = _swap;
uint8_t *data; char bobstr[65],alicestr[65]; int32_t maxlen,m,n,err=0; uint32_t expiration; struct basilisk_swap *swap = _swap;
G.LP_pendingswaps++;
printf("start swap iambob\n");
//printf("start swap iambob\n");
LP_etomicsymbol(bobstr,swap->I.bobtomic,swap->I.bobstr);
LP_etomicsymbol(alicestr,swap->I.alicetomic,swap->I.alicestr);
maxlen = 1024*1024 + sizeof(*swap);
@ -839,13 +840,13 @@ void LP_bobloop(void *_swap)
if ( swap != 0 )
{
if ( LP_waitsend("pubkeys",120,swap->N.pair,swap,data,maxlen,LP_pubkeys_verify,LP_pubkeys_data) < 0 )
printf("error waitsend pubkeys\n");
err = -2000, printf("error waitsend pubkeys\n");
else if ( LP_waitsend("choosei",LP_SWAPSTEP_TIMEOUT,swap->N.pair,swap,data,maxlen,LP_choosei_verify,LP_choosei_data) < 0 )
printf("error waitsend choosei\n");
err = -2001, printf("error waitsend choosei\n");
else if ( LP_waitsend("mostprivs",LP_SWAPSTEP_TIMEOUT,swap->N.pair,swap,data,maxlen,LP_mostprivs_verify,LP_mostprivs_data) < 0 )
printf("error waitsend mostprivs\n");
err = -2002, printf("error waitsend mostprivs\n");
else if ( basilisk_bobscripts_set(swap,1,1) < 0 )
printf("error bobscripts deposit\n");
err = -2003, printf("error bobscripts deposit\n");
else
{
uint8_t error = 0;
@ -853,45 +854,46 @@ void LP_bobloop(void *_swap)
swap->bobrefund.utxotxid = swap->bobdeposit.I.signedtxid;
basilisk_bobdeposit_refund(swap,swap->I.putduration);
//printf("depositlen.%d\n",swap->bobdeposit.I.datalen);
LP_swapsfp_update(&swap->I.req);
//LP_swapsfp_update(&swap->I.req);
LP_swap_critical = (uint32_t)time(NULL);
LP_unavailableset(swap->bobdeposit.utxotxid,swap->bobdeposit.utxovout,(uint32_t)time(NULL)+60,swap->I.otherhash);
if ( LP_waitfor(swap->N.pair,swap,LP_SWAPSTEP_TIMEOUT*10,LP_verify_otherfee) < 0 )
{
error = 1;
printf("error waiting for alicefee\n");
err = -2004, printf("error waiting for alicefee\n");
}
if ( error == 0 ) {
if ( LP_swapdata_rawtxsend(swap->N.pair,swap,0x200,data,maxlen,&swap->bobdeposit,0x100,0) == 0 ) {
if ( error == 0 )
{
if ( LP_swapdata_rawtxsend(swap->N.pair,swap,0x200,data,maxlen,&swap->bobdeposit,0x100,0) == 0 )
{
error = 1;
printf("error sending bobdeposit\n");
err = -2005, printf("error sending bobdeposit\n");
}
}
LP_unavailableset(swap->bobpayment.utxotxid,swap->bobpayment.utxovout,(uint32_t)time(NULL)+60,swap->I.otherhash);
if ( error == 0 && LP_waitfor(swap->N.pair,swap,1800,LP_verify_alicepayment) < 0 )
{
error = 1;
printf("error waiting for alicepayment\n");
err = -2006, printf("error waiting for alicepayment\n");
}
if (error == 0)
{
LP_swap_critical = (uint32_t)time(NULL);
if ( basilisk_bobscripts_set(swap,0,1) < 0 )
printf("error bobscripts payment\n");
err = -2007, printf("error bobscripts payment\n");
else
{
m = swap->I.aliceconfirms;
while ( (n= LP_numconfirms(alicestr,swap->alicepayment.I.destaddr,swap->alicepayment.I.signedtxid,0,1)) < m ) // sync with alice
{
LP_unavailableset(swap->bobpayment.utxotxid,swap->bobpayment.utxovout,(uint32_t)time(NULL)+60,swap->I.otherhash);
LP_swap_critical = (uint32_t)time(NULL);
char str[65];printf("%d wait for alicepayment %s numconfs.%d %s %s\n",n,swap->alicepayment.I.destaddr,m,alicestr,bits256_str(str,swap->alicepayment.I.signedtxid));
sleep(10);
}
LP_swap_critical = (uint32_t)time(NULL);
if ( LP_swapdata_rawtxsend(swap->N.pair,swap,0x8000,data,maxlen,&swap->bobpayment,0x4000,0) == 0 ) {
printf("error sending bobpayment\n");
err = -2008, printf("error sending bobpayment\n");
}
//if ( LP_waitfor(swap->N.pair,swap,10,LP_verify_alicespend) < 0 )
// printf("error waiting for alicespend\n");
@ -906,6 +908,9 @@ void LP_bobloop(void *_swap)
}
} else printf("swap timed out\n");
LP_swap_endcritical = (uint32_t)time(NULL);
if ( err < 0 )
LP_failedmsg(swap->I.req.requestid,swap->I.req.quoteid,err);
sleep(13);
LP_pendswap_add(swap->I.expiration,swap->I.req.requestid,swap->I.req.quoteid);
//swap->I.finished = LP_swapwait(swap->I.expiration,swap->I.req.requestid,swap->I.req.quoteid,LP_atomic_locktime(swap->I.bobstr,swap->I.alicestr)*3,swap->I.aliceconfirms == 0 ? 3 : 30);
basilisk_swap_finished(swap);
@ -916,7 +921,7 @@ void LP_bobloop(void *_swap)
void LP_aliceloop(void *_swap)
{
uint8_t *data; char bobstr[65],alicestr[65]; int32_t maxlen,n,m; uint32_t expiration; struct basilisk_swap *swap = _swap;
uint8_t *data; char bobstr[65],alicestr[65]; int32_t maxlen,n,m,err=0; uint32_t expiration; struct basilisk_swap *swap = _swap;
G.LP_pendingswaps++;
LP_etomicsymbol(bobstr,swap->I.bobtomic,swap->I.bobstr);
LP_etomicsymbol(alicestr,swap->I.alicetomic,swap->I.alicestr);
@ -927,24 +932,25 @@ void LP_aliceloop(void *_swap)
{
printf("start swap iamalice pair.%d\n",swap->N.pair);
if ( LP_sendwait("pubkeys",120,swap->N.pair,swap,data,maxlen,LP_pubkeys_verify,LP_pubkeys_data) < 0 )
printf("error LP_sendwait pubkeys\n");
err = -1000, printf("error LP_sendwait pubkeys\n");
else if ( LP_sendwait("choosei",LP_SWAPSTEP_TIMEOUT,swap->N.pair,swap,data,maxlen,LP_choosei_verify,LP_choosei_data) < 0 )
printf("error LP_sendwait choosei\n");
err = -1001, printf("error LP_sendwait choosei\n");
else if ( LP_sendwait("mostprivs",LP_SWAPSTEP_TIMEOUT,swap->N.pair,swap,data,maxlen,LP_mostprivs_verify,LP_mostprivs_data) < 0 )
printf("error LP_sendwait mostprivs\n");
err = -1002, printf("error LP_sendwait mostprivs\n");
else if ( basilisk_alicetxs(swap->N.pair,swap,data,maxlen) != 0 )
printf("basilisk_alicetxs error\n");
err = -1003, printf("basilisk_alicetxs error\n");
else
{
LP_swapsfp_update(&swap->I.req);
//LP_swapsfp_update(&swap->I.req);
LP_swap_critical = (uint32_t)time(NULL);
if ( LP_swapdata_rawtxsend(swap->N.pair,swap,0x80,data,maxlen,&swap->myfee,0x40,0) == 0 )
printf("error sending alicefee\n");
err = -1004, printf("error sending alicefee\n");
else if ( LP_waitfor(swap->N.pair,swap,1800,LP_verify_bobdeposit) < 0 )
printf("error waiting for bobdeposit\n");
err = -1005, printf("error waiting for bobdeposit\n");
else
{
m = swap->I.bobconfirms;
LP_unavailableset(swap->alicepayment.utxotxid,swap->alicepayment.utxovout,(uint32_t)time(NULL)+60,swap->I.otherhash);
while ( (n= LP_numconfirms(bobstr,swap->bobdeposit.I.destaddr,swap->bobdeposit.I.signedtxid,0,1)) < m )
{
LP_swap_critical = (uint32_t)time(NULL);
@ -952,7 +958,7 @@ void LP_aliceloop(void *_swap)
sleep(10);
}
if ( LP_swapdata_rawtxsend(swap->N.pair,swap,0x1000,data,maxlen,&swap->alicepayment,0x800,0) == 0 )
printf("error sending alicepayment\n");
err = -1006, printf("error sending alicepayment\n");
else
{
m = swap->I.aliceconfirms;
@ -965,13 +971,9 @@ void LP_aliceloop(void *_swap)
//swap->sentflag = 1;
LP_swap_critical = (uint32_t)time(NULL);
if ( LP_waitfor(swap->N.pair,swap,1800,LP_verify_bobpayment) < 0 )
printf("error waiting for bobpayment\n");
err = -1007, printf("error waiting for bobpayment\n");
else
{
if ( swap->I.alicetomic[0] != 0 )
{
// artem: do stuff alice needs to do after bobpayment comes in
}
LP_swap_endcritical = (uint32_t)time(NULL);
while ( (n= LP_numconfirms(bobstr,swap->bobpayment.I.destaddr,swap->bobpayment.I.signedtxid,0,1)) < swap->I.bobconfirms )
{
@ -986,6 +988,9 @@ void LP_aliceloop(void *_swap)
}
}
LP_swap_endcritical = (uint32_t)time(NULL);
if ( err < 0 )
LP_failedmsg(swap->I.req.requestid,swap->I.req.quoteid,err);
sleep(13);
LP_pendswap_add(swap->I.expiration,swap->I.req.requestid,swap->I.req.quoteid);
//swap->I.finished = LP_swapwait(swap->I.expiration,swap->I.req.requestid,swap->I.req.quoteid,LP_atomic_locktime(swap->I.bobstr,swap->I.alicestr)*3,swap->I.aliceconfirms == 0 ? 3 : 30);
basilisk_swap_finished(swap);
@ -1205,10 +1210,6 @@ struct basilisk_swap *bitcoin_swapinit(bits256 privkey,uint8_t *pubkey33,bits256
swap->I.bobconfirms = BASILISK_DEFAULT_NUMCONFIRMS;
swap->I.aliceconfirms = BASILISK_DEFAULT_NUMCONFIRMS;
}
if ( bobcoin->isassetchain != 0 )
swap->I.bobconfirms = 1;
if ( alicecoin->isassetchain != 0 )
swap->I.aliceconfirms = 1;
if ( bobcoin->userconfirms > 0 )
swap->I.bobconfirms = bobcoin->userconfirms;
if ( alicecoin->userconfirms > 0 )
@ -1221,13 +1222,18 @@ struct basilisk_swap *bitcoin_swapinit(bits256 privkey,uint8_t *pubkey33,bits256
swap->I.bobconfirms = swap->I.bobmaxconfirms;
if ( swap->I.aliceconfirms > swap->I.alicemaxconfirms )
swap->I.aliceconfirms = swap->I.alicemaxconfirms;
if ( bobcoin->isassetchain != 0 )
swap->I.bobconfirms = BASILISK_DEFAULT_MAXCONFIRMS/2;
if ( alicecoin->isassetchain != 0 )
swap->I.aliceconfirms = BASILISK_DEFAULT_MAXCONFIRMS/2;
if ( strcmp("BAY",swap->I.req.src) != 0 && strcmp("BAY",swap->I.req.dest) != 0 )
{
swap->I.bobconfirms *= !swap->I.bobistrusted;
swap->I.aliceconfirms *= !swap->I.aliceistrusted;
}
printf(">>>>>>>>>> jumblrflag.%d <<<<<<<<< r.%u q.%u, %.8f bobconfs.%d, %.8f aliceconfs.%d taddr.%d %d\n",jumblrflag,swap->I.req.requestid,swap->I.req.quoteid,dstr(swap->I.bobsatoshis),swap->I.bobconfirms,dstr(swap->I.alicesatoshis),swap->I.aliceconfirms,bobcoin->taddr,alicecoin->taddr);
printf("etomic src (%s %s) dest (%s %s)\n",swap->I.bobtomic,swap->I.etomicsrc,swap->I.alicetomic,swap->I.etomicdest);
if ( swap->I.etomicsrc[0] != 0 || swap->I.etomicdest[0] != 0 )
printf("etomic src (%s %s) dest (%s %s)\n",swap->I.bobtomic,swap->I.etomicsrc,swap->I.alicetomic,swap->I.etomicdest);
if ( swap->I.iambob != 0 )
{
basilisk_rawtx_setparms("myfee",swap->I.req.quoteid,&swap->myfee,bobcoin,0,0,LP_DEXFEE(swap->I.bobsatoshis) + 0*bobcoin->txfee,0,0,jumblrflag);
@ -1279,17 +1285,20 @@ struct basilisk_swap *bitcoin_swapinit(bits256 privkey,uint8_t *pubkey33,bits256
struct basilisk_swap *LP_swapinit(int32_t iambob,int32_t optionduration,bits256 privkey,struct basilisk_request *rp,struct LP_quoteinfo *qp,int32_t dynamictrust)
{
static void *ctx;
struct basilisk_swap *swap; bits256 pubkey25519; uint8_t pubkey33[33];
if ( ctx == 0 )
ctx = bitcoin_ctx();
swap = calloc(1,sizeof(*swap));
swap->aliceid = LP_aliceid_calc(qp->desttxid,qp->destvout,qp->feetxid,qp->feevout);
swap->I.req.quoteid = rp->quoteid;
swap->ctx = bitcoin_ctx();
swap->ctx = ctx;
vcalc_sha256(0,swap->I.orderhash.bytes,(uint8_t *)rp,sizeof(*rp));
swap->I.req = *rp;
G.LP_skipstatus[G.LP_numskips] = ((uint64_t)rp->requestid << 32) | rp->quoteid;
if ( G.LP_numskips < sizeof(G.LP_skipstatus)/sizeof(*G.LP_skipstatus) )
G.LP_numskips++;
printf("LP_swapinit request.%u iambob.%d (%s/%s) quoteid.%u\n",rp->requestid,iambob,rp->src,rp->dest,rp->quoteid);
//printf("LP_swapinit request.%u iambob.%d (%s/%s) quoteid.%u\n",rp->requestid,iambob,rp->src,rp->dest,rp->quoteid);
bitcoin_pubkey33(swap->ctx,pubkey33,privkey);
pubkey25519 = curve25519(privkey,curve25519_basepoint9());
swap->persistent_pubkey = pubkey25519;

2
iguana/exchanges/LP_tradebots.c

@ -52,7 +52,7 @@ void LP_tradebot_pauseall()
void LP_tradebot_updatestats(struct LP_tradebot *bot,struct LP_tradebot_trade *tp)
{
char *swapstr,*status; int32_t flag; cJSON *swapjson;
if ( (swapstr= basilisk_swapentry(tp->requestid,tp->quoteid,1)) != 0 )
if ( (swapstr= basilisk_swapentry(0,tp->requestid,tp->quoteid,1)) != 0 )
{
flag = 0;
if ( (swapjson= cJSON_Parse(swapstr)) != 0 )

57
iguana/exchanges/LP_transaction.c

@ -60,15 +60,42 @@ bits256 LP_pubkey(bits256 privkey)
return(pubkey);
}
int32_t LP_gettx_presence(char *symbol,bits256 expectedtxid)
int32_t LP_gettx_presence(int32_t *numconfirmsp,char *symbol,bits256 expectedtxid,char *coinaddr)
{
cJSON *txobj; bits256 txid; int32_t flag = 0;
if ( (txobj= LP_gettx(symbol,expectedtxid,0)) != 0 )
cJSON *txobj,*retjson,*item; bits256 txid; struct iguana_info *coin; int32_t height=-1,i,n,flag = 0;
if ( numconfirmsp != 0 )
*numconfirmsp = -1;
if ( (txobj= LP_gettx("LP_gettx_presence",symbol,expectedtxid,0)) != 0 )
{
txid = jbits256(txobj,"txid");
if ( jobj(txobj,"error") == 0 && bits256_cmp(txid,expectedtxid) == 0 )
{
//char str[65]; printf("%s already in gettx (%s)\n",bits256_str(str,txid),jprint(txobj,0));
if ( numconfirmsp != 0 )
*numconfirmsp = 0;
if ( numconfirmsp != 0 && coinaddr != 0 && (coin= LP_coinfind(symbol)) != 0 && coin->electrum != 0 )
{
//char str[65]; printf("%s %s already in gettx (%s)\n",coinaddr,bits256_str(str,txid),jprint(txobj,0));
if ( (retjson= electrum_address_gethistory(symbol,coin->electrum,&retjson,coinaddr,expectedtxid)) != 0 )
{
if ( (n= cJSON_GetArraySize(retjson)) > 0 )
{
for (i=0; i<n; i++)
{
item = jitem(retjson,i);
if ( bits256_cmp(txid,jbits256(item,"tx_hash")) == 0 )
{
height = jint(item,"height");
//printf("found txid at height.%d\n",height);
if ( height <= coin->height )
*numconfirmsp = (coin->height - height + 1);
break;
}
}
}
free_json(retjson);
//printf("got %s history height.%d vs coin.%d -> numconfirms.%d\n",coin->symbol,height,coin->height,*numconfirmsp);
}
}
flag = 1;
}
free_json(txobj);
@ -93,8 +120,8 @@ bits256 LP_broadcast(char *txname,char *symbol,char *txbytes,bits256 expectedtxi
}
for (i=0; i<2; i++)
{
//char str[65]; printf("LP_broadcast.%d (%s) %s i.%d sentflag.%d\n",i,symbol,bits256_str(str,expectedtxid),i,sentflag);
if ( sentflag == 0 && LP_gettx_presence(symbol,expectedtxid) != 0 )
//char str[65]; printf("LP_broadcast.%d %s (%s) %s i.%d sentflag.%d %s\n",i,txname,symbol,bits256_str(str,expectedtxid),i,sentflag,txbytes);
if ( sentflag == 0 && LP_gettx_presence(0,symbol,expectedtxid,0) != 0 )
sentflag = 1;
if ( sentflag == 0 && (retstr= LP_sendrawtransaction(symbol,txbytes)) != 0 )
{
@ -764,7 +791,7 @@ char *basilisk_swap_bobtxspend(bits256 *signedtxidp,uint64_t txfee,char *name,ch
if ( txfee > 0 && txfee < coin->txfee )
txfee = coin->txfee;
#ifndef BASILISK_DISABLESENDTX
if ( (txobj= LP_gettx(symbol,utxotxid,0)) != 0 )
if ( (txobj= LP_gettx("basilisk_swap_bobtxspend",symbol,utxotxid,0)) != 0 )
{
if ( (vouts= jarray(&n,txobj,"vout")) != 0 && utxovout < n )
{
@ -1006,7 +1033,7 @@ uint64_t _komodo_interestnew(uint64_t nValue,uint32_t nLockTime,uint32_t tiptime
if ( tiptime > nLockTime && (minutes= (tiptime - nLockTime) / 60) >= 60 )
{
//minutes.71582779 tiptime.1511292969 locktime.1511293505
printf("minutes.%d tiptime.%u locktime.%u\n",minutes,tiptime,nLockTime);
//printf("minutes.%d tiptime.%u locktime.%u\n",minutes,tiptime,nLockTime);
if ( minutes > 365 * 24 * 60 )
minutes = 365 * 24 * 60;
minutes -= 59;
@ -1615,7 +1642,7 @@ int32_t LP_swap_getcoinaddr(char *symbol,char *coinaddr,bits256 txid,int32_t vou
{
cJSON *retjson;
coinaddr[0] = 0;
if ( (retjson= LP_gettx(symbol,txid,0)) != 0 )
if ( (retjson= LP_gettx("LP_swap_getcoinaddr",symbol,txid,0)) != 0 )
{
LP_txdestaddr(coinaddr,txid,vout,retjson);
free_json(retjson);
@ -1627,7 +1654,7 @@ int32_t basilisk_swap_getsigscript(char *symbol,uint8_t *script,int32_t maxlen,b
{
cJSON *retjson,*vins,*item,*skey; int32_t n,scriptlen = 0; char *hexstr;
//char str[65]; printf("getsigscript %s %s/v%d\n",symbol,bits256_str(str,txid),vini);
if ( bits256_nonz(txid) != 0 && (retjson= LP_gettx(symbol,txid,0)) != 0 )
if ( bits256_nonz(txid) != 0 && (retjson= LP_gettx("basilisk_swap_getsigscript",symbol,txid,0)) != 0 )
{
//printf("gettx.(%s)\n",jprint(retjson,0));
if ( (vins= jarray(&n,retjson,"vin")) != 0 && vini < n )
@ -1720,7 +1747,7 @@ bits256 LP_swap_spendtxid(char *symbol,char *destaddr,bits256 utxotxid,int32_t u
for (i=0; i<n; i++)
{
txid = jbits256i(array,i);
if ( (txobj= LP_gettx(symbol,txid,1)) != 0 )
if ( (txobj= LP_gettx("LP_swap_spendtxid",symbol,txid,1)) != 0 )
{
if ( (vins= jarray(&m,txobj,"vin")) != 0 )
{
@ -1950,9 +1977,9 @@ int32_t basilisk_bobscripts_set(struct basilisk_swap *swap,int32_t depositflag,i
bitcoin_address(coin->symbol,swap->bobpayment.p2shaddr,coin->taddr,coin->p2shtype,swap->bobpayment.redeemscript,swap->bobpayment.I.redeemlen);
strcpy(swap->bobpayment.I.destaddr,swap->bobpayment.p2shaddr);
//LP_importaddress(coin->symbol,swap->bobpayment.I.destaddr);
int32_t i; for (i=0; i<swap->bobpayment.I.redeemlen; i++)
printf("%02x",swap->bobpayment.redeemscript[i]);
printf(" <- bobpayment redeem %d %s\n",i,swap->bobpayment.I.destaddr);
//int32_t i; for (i=0; i<swap->bobpayment.I.redeemlen; i++)
// printf("%02x",swap->bobpayment.redeemscript[i]);
//printf(" <- bobpayment redeem %d %s\n",i,swap->bobpayment.I.destaddr);
if ( genflag != 0 && bits256_nonz(*(bits256 *)swap->I.secretBn256) != 0 && swap->bobpayment.I.datalen == 0 )
{
basilisk_rawtx_gen(swap->ctx,"payment",swap->I.started,swap->persistent_pubkey33,1,1,&swap->bobpayment,swap->bobpayment.I.locktime,swap->bobpayment.spendscript,swap->bobpayment.I.spendlen,coin->txfee,1,0,swap->persistent_privkey,swap->changermd160,coinaddr);
@ -2061,7 +2088,7 @@ int32_t basilisk_alicetxs(int32_t pairsock,struct basilisk_swap *swap,uint8_t *d
swap->I.statebits |= LP_swapdata_rawtxsend(pairsock,swap,0x80,data,maxlen,&swap->myfee,0x40,0);
LP_unspents_mark(swap->I.iambob!=0?coin->symbol:coin->symbol,swap->myfee.vins);
//basilisk_txlog(swap,&swap->myfee,-1);
//for (i=0; i<swap->myfee.I.datalen; i++)
//int32_t i; for (i=0; i<swap->myfee.I.datalen; i++)
// printf("%02x",swap->myfee.txbytes[i]);
//printf(" <- fee state.%x\n",swap->I.statebits);
swap->I.statebits |= 0x40;

51
iguana/exchanges/LP_utxo.c

@ -124,7 +124,7 @@ struct LP_inuse_info *_LP_inuse_add(uint32_t expiration,bits256 otherpub,bits256
//if ( expiration > lp->expiration || expiration == 0 )
lp->expiration = expiration;
}
char str[65]; printf("set inuse until %u lag.%d for %s/v%d\n",expiration,(int32_t)(expiration-(uint32_t)time(NULL)),bits256_str(str,txid),vout);
//char str[65]; printf("set inuse until %u lag.%d for %s/v%d\n",expiration,(int32_t)(expiration-(uint32_t)time(NULL)),bits256_str(str,txid),vout);
return(lp);
} else printf("_LP_inuse_add [%d] overflow\n",LP_numinuse);
return(0);
@ -486,7 +486,7 @@ struct LP_address *LP_address_utxo_reset(struct iguana_info *coin)
portable_mutex_lock(&coin->addressutxo_mutex);
if ( (array= LP_listunspent(coin->symbol,coin->smartaddr,zero,zero)) != 0 )
{
printf("reset %s ap->utxos\n",coin->symbol);
//printf("reset %s ap->utxos\n",coin->symbol);
portable_mutex_lock(&coin->addrmutex);
portable_mutex_lock(&LP_gcmutex);
DL_FOREACH_SAFE(ap->utxos,up,tmp)
@ -811,7 +811,7 @@ cJSON *LP_transactioninit(struct iguana_info *coin,bits256 txid,int32_t iter,cJS
struct LP_transaction *tx; int32_t i,height,numvouts,numvins,spentvout; cJSON *vins,*vouts,*vout,*vin; bits256 spenttxid; char str[65];
if ( coin->inactive != 0 )
return(0);
if ( txobj != 0 || (txobj= LP_gettx(coin->symbol,txid,0)) != 0 )
if ( txobj != 0 || (txobj= LP_gettx("LP_transactioninit",coin->symbol,txid,0)) != 0 )
{
if ( coin->electrum == 0 )
height = LP_txheight(coin,txid);
@ -868,12 +868,16 @@ cJSON *LP_transactioninit(struct iguana_info *coin,bits256 txid,int32_t iter,cJS
int32_t LP_txheight(struct iguana_info *coin,bits256 txid)
{
bits256 blockhash; struct LP_transaction *tx; cJSON *blockobj,*retjson,*txobj; int32_t height = 0;
bits256 blockhash; struct LP_transaction *tx=0; cJSON *blockobj,*retjson,*txobj,*txobj2; int32_t height = 0;
if ( coin == 0 )
return(-1);
if ( (tx= LP_transactionfind(coin,txid)) != 0 )
height = tx->height;
if ( height > 0 )
return(height);
if ( coin->electrum == 0 )
{
if ( (txobj= LP_gettx(coin->symbol,txid,0)) != 0 )
if ( (txobj= LP_gettx("LP_txheight",coin->symbol,txid,0)) != 0 )
{
//*timestampp = juint(txobj,"locktime");
//*blocktimep = juint(txobj,"blocktime");
@ -881,6 +885,17 @@ int32_t LP_txheight(struct iguana_info *coin,bits256 txid)
if ( bits256_nonz(blockhash) != 0 && (blockobj= LP_getblock(coin->symbol,blockhash)) != 0 )
{
height = jint(blockobj,"height");
if ( tx != 0 )
tx->height = height;
else if ( 0 )
{
txobj2 = LP_transactioninit(coin,txid,0,0);
txobj2 = LP_transactioninit(coin,txid,1,txobj2);
if ( txobj2 != 0 )
free_json(txobj2);
if ( (tx= LP_transactionfind(coin,txid)) != 0 )
tx->height = height;
}
//char str[65];
//if ( strcmp(coin->symbol,"CHIPS") != 0 && strcmp(coin->symbol,"BTC") != 0 )
// printf("%s %s LP_txheight.%d\n",coin->symbol,bits256_str(str,txid),height);
@ -891,8 +906,8 @@ int32_t LP_txheight(struct iguana_info *coin,bits256 txid)
}
else
{
if ( (tx= LP_transactionfind(coin,txid)) != 0 )
height = tx->height;
//if ( (tx= LP_transactionfind(coin,txid)) != 0 )
// height = tx->height;
if ( height == 0 )
{
if ( (retjson= electrum_transaction(&height,coin->symbol,coin->electrum,&retjson,txid,0)) != 0 )
@ -923,7 +938,7 @@ int32_t LP_numconfirms(char *symbol,char *coinaddr,bits256 txid,int32_t vout,int
}
else if ( mempool != 0 && LP_mempoolscan(symbol,txid) >= 0 )
numconfirms = 0;
else if ( (txobj= LP_gettx(symbol,txid,1)) != 0 )
else if ( (txobj= LP_gettx("LP_numconfirms",symbol,txid,1)) != 0 )
{
numconfirms = jint(txobj,"confirmations");
free_json(txobj);
@ -941,6 +956,18 @@ int32_t LP_numconfirms(char *symbol,char *coinaddr,bits256 txid,int32_t vout,int
numconfirms = 0;
}
}
/*if ( numconfirms == BASILISK_DEFAULT_MAXCONFIRMS )
{
if ( coin->isassetchain != 0 || strcmp(coin->symbol,"KMD") == 0 )
{
numconfirms--;
if ( coin->notarized >= coin->height-numconfirms )
{
printf("%s notarized.%d current ht.%d - numconfirms.%d -> txheight.%d\n",coin->symbol,coin->notarized,coin->height,numconfirms,coin->height - numconfirms);
numconfirms = BASILISK_DEFAULT_MAXCONFIRMS;
}
}
}*/
return(numconfirms);
}
@ -1025,20 +1052,20 @@ uint64_t LP_txvalue(char *coinaddr,char *symbol,bits256 txid,int32_t vout)
}
else if ( coin->electrum == 0 )
{
uint64_t value;
uint64_t value; char str[65];
if ( (txobj= LP_gettxout(coin->symbol,coinaddr,txid,vout)) != 0 )
{
value = LP_value_extract(txobj,0);//SATOSHIDEN * (jdouble(txobj,"value") + jdouble(txobj,"interest"));
if ( coinaddr != 0 )
LP_destaddr(coinaddr,txobj);
//printf("pruned node? LP_txvalue couldnt find %s tx %s, but gettxout %.8f\n",coin->symbol,bits256_str(str,txid),dstr(value));
//printf("LP_txvalue %s tx %s/v%d value %.8f\n",coin->symbol,bits256_str(str,txid),vout,dstr(value));
if ( value != 0 )
{
free_json(txobj);
return(value);
}
}
//printf("pruned node? LP_txvalue couldnt find %s tx %s/v%d (%s)\n",coin->symbol,bits256_str(str,txid),vout,txobj!=0?jprint(txobj,0):"");
printf("pruned node? LP_txvalue couldnt find %s tx %s/v%d (%s)\n",coin->symbol,bits256_str(str,txid),vout,txobj!=0?jprint(txobj,0):"");
if ( txobj != 0 )
free_json(txobj);
}
@ -1052,7 +1079,7 @@ int64_t LP_outpoint_amount(char *symbol,bits256 txid,int32_t vout)
return(amount);
else
{
if ( (txjson= LP_gettx(symbol,txid,1)) != 0 )
if ( (txjson= LP_gettx("LP_outpoint_amount",symbol,txid,1)) != 0 )
{
if ( (vouts= jarray(&numvouts,txjson,"vout")) != 0 && vout < numvouts )
amount = LP_value_extract(jitem(vouts,vout),0);

2
iguana/exchanges/auto_chipsbtc

@ -1,2 +1,2 @@
source userpass
curl --url "http://127.0.0.1:7783" --data "{\"minprice\":0.0001,\"maxprice\":0.0002,\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"base\":\"CHIPS\",\"rel\":\"BTC\",\"margin\":0.05,\"refbase\":\"chips\",\"refrel\":\"coinmarketcap\"}"
curl --url "http://127.0.0.1:7783" --data "{\"minprice\":0.00006,\"maxprice\":0.0002,\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"base\":\"CHIPS\",\"rel\":\"BTC\",\"margin\":0.05,\"refbase\":\"chips\",\"refrel\":\"coinmarketcap\"}"

2
iguana/exchanges/auto_chipskmd

@ -1,2 +1,2 @@
source userpass
curl --url "http://127.0.0.1:7783" --data "{\"minprice\":0.2,\"maxprice\":0.4,\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"base\":\"CHIPS\",\"rel\":\"KMD\",\"margin\":0.05,\"refbase\":\"chips\",\"refrel\":\"coinmarketcap\"}"
curl --url "http://127.0.0.1:7783" --data "{\"minprice\":0.15,\"maxprice\":0.4,\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"base\":\"CHIPS\",\"rel\":\"KMD\",\"margin\":0.05,\"refbase\":\"chips\",\"refrel\":\"coinmarketcap\"}"

63
iguana/exchanges/autoprice

@ -1,12 +1,55 @@
#!/bin/bash
margin=0.05
source userpass
#curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"base\":\"KMD\",\"rel\":\"BTC\",\"margin\":0.03}"
#curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"base\":\"BTC\",\"rel\":\"KMD\",\"margin\":0.03}"
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"base\":\"KMD\",\"rel\":\"HUSH\",\"margin\":0.01}"
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"base\":\"HUSH\",\"rel\":\"KMD\",\"margin\":0.01}"
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"base\":\"KMD\",\"rel\":\"USD\",\"margin\":0.01}"
#curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"base\":\"USD\",\"rel\":\"KMD\",\"margin\":0.01}"
#curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"base\":\"KMD\",\"rel\":\"JUMBLR\",\"margin\":0.01}"
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"base\":\"JUMBLR\",\"rel\":\"KMD\",\"margin\":0.01}"
#curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"base\":\"MNZ\",\"rel\":\"KMD\",\"offset\":0.0,\"refbase\":\"BTC\",\"refrel\":\"KMD\",\"factor\":0.00006667,\"margin\":-0.2}"
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"base\":\"KMD\",\"rel\":\"MNZ\",\"offset\":0.0,\"refbase\":\"KMD\",\"refrel\":\"BTC\",\"factor\":15000,\"margin\":-0.2}"
# KMD/BTC must be first as other prices depend on it
#curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"base\":\"KMD\",\"rel\":\"BTC\",\"margin\":$margin,\"refbase\":\"komodo\",\"refrel\":\"coinmarketcap\"}"
#curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"base\":\"BTC\",\"rel\":\"KMD\",\"fixed\":0.00025,\"margin\":$margin}"
#curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"base\":\"KMD\",\"rel\":\"BTC\",\"fixed\":4000,\"margin\":$margin}"
curl --url "http://127.0.0.1:7783" --data "{\"minprice\":0.0003,\"maxprice\":0.001,\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"base\":\"KMD\",\"rel\":\"BTC\",\"margin\":0.05,\"refbase\":\"komodo\",\"refrel\":\"coinmarketcap\"}"
./auto_chipskmd
./auto_chipsbtc
#curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"base\":\"KMD\",\"rel\":\"MNZ\",\"offset\":0.0,\"refbase\":\"KMD\",\"refrel\":\"BTC\",\"factor\":15000,\"margin\":-0.2}"
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"base\":\"HUSH\",\"rel\":\"KMD\",\"margin\":$margin,\"refbase\":\"hush\",\"refrel\":\"coinmarketcap\"}"
#curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"base\":\"KMD\",\"rel\":\"BTCH\",\"offset\":0.0,\"refbase\":\"KMD\",\"refrel\":\"HUSH\",\"factor\":1.44,\"buymargin\":0.05,\"sellmargin\":0.05}"
#curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"base\":\"BTCH\",\"rel\":\"KMD\",\"offset\":0.0,\"refbase\":\"HUSH\",\"refrel\":\"KMD\",\"factor\":0.7,\"buymargin\":0.05,\"sellmargin\":0.05}"
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"base\":\"BEER\",\"rel\":\"PIZZA\",\"fixed\":0.0001,\"margin\":0.00001}"
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"base\":\"BEER\",\"rel\":\"ETOMIC\",\"fixed\":10,\"margin\":0.00001}"
source crypto
source trackbtc
#source jumblr
#source trackbtc
source pangea
source trackbtc
source bet
source trackbtc
#source revs
#source trackbtc
sharkholdings="{\"coin\":\"iota\",\"balance\":1500000}, {\"coin\":\"komodo\",\"balance\":120000}, {\"coin\":\"bitcoin-cash\",\"balance\":1200}, {\"coin\":\"bitcoin\",\"balance\":100}"
curl --url "http://127.0.0.1:7783" --data "{\"base\":\"MSHARK\",\"rel\":\"KMD\",\"fundvalue_bid\":\"NAV_KMD\",\"fundvalue_ask\":\"assetNAV_KMD\",\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"margin\":$margin,\"address\":\"RTu3JZZKLJTcfNwBa19dWRagEfQq49STqC\",\"holdings\":[$sharkholdings],\"divisor\":1400000}"
curl --url "http://127.0.0.1:7783" --data "{\"margin\":$margin,\"base\":\"SUPERNET\",\"rel\":\"KMD\",\"fundvalue_bid\":\"NAV_KMD\",\"fundvalue_ask\":\"NAV_KMD\",\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"address\":\"RRyyejME7LRTuvdziWsXkAbSW1fdiohGwK\",\"holdings\":[{\"coin\":\"iota\",\"balance\":11000000}, {\"coin\":\"stratis\",\"balance\":1300000}, {\"coin\":\"zcash\",\"balance\":10000}, {\"coin\":\"syscoin\",\"balance\":20000000}, {\"coin\":\"waves\",\"balance\":700000}, {\"coin\":\"bitcoin\",\"balance\":625}, {\"coin\":\"bitcoin-cash\",\"balance\":1500}, {\"coin\":\"heat-ledger\",\"balance\":2323851 }, {\"coin\":\"decred\",\"balance\":20000}, {\"coin\":\"vericoin\",\"balance\":2199368 }, {\"coin\":\"byteball\",\"balance\":4238}, {\"coin\":\"iocoin\",\"balance\":150000}, {\"coin\":\"quantum-resistant-ledger\",\"balance\":375000}, {\"coin\":\"chips\",\"balance\":2577006 }, {\"coin\":\"hush\",\"balance\":100000 }, {\"coin\":\"mobilego\",\"balance\":100000 }],\"divisor\":1000000}"
curl --url "http://127.0.0.1:7783" --data "{\"margin\":$margin,\"base\":\"HODL\",\"rel\":\"KMD\",\"fundvalue_bid\":\"assetNAV_KMD\",\"fundvalue_ask\":\"assetNAV_KMD\",\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"address\":\"RNcUaMUEFLxVwtTo7rgruhwYanGk1jTkeU\",\"holdings\":[{\"coin\":\"siacoin\",\"balance\":185000000,\"comment\":\"using siafunds equal to million siacoin\"}],\"divisor\":10000000}"
dexholdings="{\"coin\":\"blocknet\",\"balance\":3000000}"
curl --url "http://127.0.0.1:7783" --data "{\"base\":\"DEX\",\"rel\":\"KMD\",\"margin\":$margin,\"fundvalue_bid\":\"assetNAV_KMD\",\"fundvalue_ask\":\"assetNAV_KMD\",\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"address\":\"RThtXup6Zo7LZAi8kRWgjAyi1s4u6U9Cpf\",\"holdings\":[$dexholdings],\"divisor\":1000000}"
curl --url "http://127.0.0.1:7783" --data "{\"base\":\"BOTS\",\"rel\":\"KMD\",\"margin\":$margin,\"fundvalue_bid\":\"assetNAV_KMD\",\"fundvalue_ask\":\"assetNAV_KMD\",\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"address\":\"RNdqHx26GWy9bk8MtmH1UiXjQcXE4RKK2P\",\"holdings\":[$dexholdings],\"divisor\":3333333}"
curl --url "http://127.0.0.1:7783" --data "{\"base\":\"JUMBLR\",\"rel\":\"KMD\",\"margin\":$margin,\"fundvalue_bid\":\"assetNAV_KMD\",\"fundvalue_ask\":\"assetNAV_KMD\",\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"address\":\"RGhxXpXSSBTBm9EvNsXnTQczthMCxHX91t\",\"holdings\":[$dexholdings],\"divisor\":3333333}"
curl --url "http://127.0.0.1:7783" --data "{\"base\":\"MGW\",\"rel\":\"KMD\",\"margin\":$margin,\"fundvalue_bid\":\"assetNAV_KMD\",\"fundvalue_ask\":\"assetNAV_KMD\",\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"holdings\":[$dexholdings],\"divisor\":13000000}"
curl --url "http://127.0.0.1:7783" --data "{\"base\":\"REVS\",\"rel\":\"KMD\",\"margin\":$margin,\"fundvalue_bid\":\"assetNAV_KMD\",\"fundvalue_ask\":\"assetNAV_KMD\",\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"holdings\":[$dexholdings],\"divisor\":9000000}"

2
iguana/exchanges/coins

File diff suppressed because one or more lines are too long

3
iguana/exchanges/convaddress

@ -0,0 +1,3 @@
#!/bin/bash
source userpass
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"convaddress\",\"coin\":\"BTC\",\"address\":\"1KPctPk4Zs4Qbe1x32A5bC1roAnmpvi9Fy\",\"destcoin\":\"KMD\"}"

3
iguana/exchanges/getendpoint

@ -0,0 +1,3 @@
#!/bin/bash
source userpass
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"getendpoint\"}"

48
iguana/exchanges/mm.c

@ -58,7 +58,8 @@ void LP_priceupdate(char *base,char *rel,double price,double avebid,double aveas
#include "../../crypto777/nanosrc/pipeline.h"
#include "../../crypto777/nanosrc/reqrep.h"
#include "../../crypto777/nanosrc/tcp.h"
#include "../../crypto777/nanosrc/pair.h"
#include "../../crypto777/nanosrc/pair.h"
#include "../../crypto777/nanosrc/ws.h"
#else
#include "/usr/local/include/nanomsg/nn.h"
#include "/usr/local/include/nanomsg/bus.h"
@ -66,7 +67,8 @@ void LP_priceupdate(char *base,char *rel,double price,double avebid,double aveas
#include "/usr/local/include/nanomsg/pipeline.h"
#include "/usr/local/include/nanomsg/reqrep.h"
#include "/usr/local/include/nanomsg/tcp.h"
#include "/usr/local/include/nanomsg/pair.h"
#include "/usr/local/include/nanomsg/pair.h"
#include "/usr/local/include/nanomsg/ws.h"
#endif
#endif
@ -161,25 +163,41 @@ int main(int argc, const char * argv[])
OS_init();
if ( strstr(argv[0],"btc2kmd") != 0 && argv[1] != 0 )
{
uint8_t addrtype,rmd160[20],rmd160b[20]; char coinaddr[64],coinaddr2[64];
bitcoin_addr2rmd160("BTC",0,&addrtype,rmd160,(char *)argv[1]);
if ( addrtype == 0 )
bits256 privkey,checkkey; uint8_t tmptype; char kmdwif[64],str[65],str2[65],*retstr;
if ( LP_wifstr_valid("BTC",(char *)argv[1]) > 0 )
{
bitcoin_address("KMD",coinaddr,0,60,rmd160,20);
bitcoin_addr2rmd160("KMD",0,&addrtype,rmd160b,coinaddr);
bitcoin_address("BTC",coinaddr2,0,0,rmd160b,20);
bitcoin_wif2priv("BTC",0,&tmptype,&privkey,(char *)argv[1]);
bitcoin_priv2wif("KMD",0,kmdwif,privkey,188);
bitcoin_wif2priv("KMD",0,&tmptype,&checkkey,kmdwif);
if ( bits256_cmp(privkey,checkkey) == 0 )
printf("BTC %s -> KMD %s: privkey %s\n",argv[1],kmdwif,bits256_str(str,privkey));
else printf("ERROR BTC %s %s != KMD %s %s\n",argv[1],bits256_str(str,privkey),kmdwif,bits256_str(str2,checkkey));
}
else if ( addrtype == 60 )
else
{
bitcoin_address("BTC",coinaddr,0,0,rmd160,20);
bitcoin_addr2rmd160("BTC",0,&addrtype,rmd160b,coinaddr);
bitcoin_address("KMD",coinaddr2,0,60,rmd160b,20);
if ( (retstr= LP_convaddress("BTC",(char *)argv[1],"KMD")) != 0 )
printf("%s\n",retstr);
}
printf("(%s) -> %s -> %s\n",(char *)argv[1],coinaddr,coinaddr2);
if ( strcmp((char *)argv[1],coinaddr2) != 0 )
printf("ERROR\n");
exit(0);
}
else if ( argv[1] != 0 && strcmp(argv[1],"events") == 0 )
{
int32_t len; void *ptr;
if ( (IPC_ENDPOINT= nn_socket(AF_SP,NN_PAIR)) >= 0 )
{
if ( nn_connect(IPC_ENDPOINT,"ws://127.0.0.1:5555") >= 0 )
{
while ( 1 )
{
if ( (len= nn_recv(IPC_ENDPOINT,&ptr,NN_MSG,0)) > 0 )
{
printf("%s\n",(char *)ptr);
nn_freemsg(ptr);
}
}
}
}
}
else if ( argv[1] != 0 && strcmp(argv[1],"hush") == 0 )
{
uint32_t timestamp; char str[65],wifstr[128]; bits256 privkey; int32_t i;

2
iguana/exchanges/mshark

@ -1,4 +1,4 @@
#!/bin/bash
source userpass
# this will only work for watchonly addresses that have been rescanned and with active coins
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"fundvalue\",\"address\":\"RTu3JZZKLJTcfNwBa19dWRagEfQq49STqC\",\"holdings\":[{\"coin\":\"iota\",\"balance\":1500000}, {\"coin\":\"bitcoin-cash\",\"balance\":1200}, {\"coin\":\"bitcoin\",\"balance\":137}, {\"coin\":\"chips\",\"balance\":100000}],\"divisor\":1400000}"
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"fundvalue\",\"address\":\"RTu3JZZKLJTcfNwBa19dWRagEfQq49STqC\",\"holdings\":[{\"coin\":\"iota\",\"balance\":1500000}, {\"coin\":\"bitcoin-cash\",\"balance\":1200}, {\"coin\":\"bitcoin\",\"balance\":100}, {\"coin\":\"komodo\",\"balance\":100000}, {\"coin\":\"chips\",\"balance\":100000}],\"divisor\":1400000}"

8
iguana/exchanges/prices/autoprice

@ -11,8 +11,6 @@ curl --url "http://127.0.0.1:7783" --data "{\"minprice\":0.0003,\"maxprice\":0.0
./auto_chipskmd
./auto_chipsbtc
#curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"base\":\"KMD\",\"rel\":\"MNZ\",\"offset\":0.0,\"refbase\":\"KMD\",\"refrel\":\"BTC\",\"factor\":15000,\"margin\":-0.2}"
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"base\":\"HUSH\",\"rel\":\"KMD\",\"margin\":$margin,\"refbase\":\"hush\",\"refrel\":\"coinmarketcap\"}"
@ -37,15 +35,15 @@ source trackbtc
#source revs
#source trackbtc
sharkholdings="{\"coin\":\"iota\",\"balance\":1500000}, {\"coin\":\"bitcoin-cash\",\"balance\":1200}, {\"coin\":\"bitcoin\",\"balance\":145}"
sharkholdings="{\"coin\":\"iota\",\"balance\":1500000}, {\"coin\":\"komodo\",\"balance\":120000}, {\"coin\":\"bitcoin-cash\",\"balance\":1200}, {\"coin\":\"bitcoin\",\"balance\":100}"
curl --url "http://127.0.0.1:7783" --data "{\"base\":\"MSHARK\",\"rel\":\"KMD\",\"fundvalue_bid\":\"NAV_KMD\",\"fundvalue_ask\":\"assetNAV_KMD\",\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"margin\":$margin,\"address\":\"RTu3JZZKLJTcfNwBa19dWRagEfQq49STqC\",\"holdings\":[$sharkholdings],\"divisor\":1400000}"
curl --url "http://127.0.0.1:7783" --data "{\"margin\":$margin,\"base\":\"SUPERNET\",\"rel\":\"KMD\",\"fundvalue_bid\":\"NAV_KMD\",\"fundvalue_ask\":\"assetNAV_KMD\",\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"address\":\"RRyyejME7LRTuvdziWsXkAbSW1fdiohGwK\",\"holdings\":[{\"coin\":\"iota\",\"balance\":11000000}, {\"coin\":\"stratis\",\"balance\":1300000}, {\"coin\":\"zcash\",\"balance\":10000}, {\"coin\":\"syscoin\",\"balance\":20000000}, {\"coin\":\"waves\",\"balance\":700000}, {\"coin\":\"bitcoin\",\"balance\":625}, {\"coin\":\"bitcoin-cash\",\"balance\":1500}, {\"coin\":\"heat-ledger\",\"balance\":2323851 }, {\"coin\":\"decred\",\"balance\":20000}, {\"coin\":\"vericoin\",\"balance\":2199368 }, {\"coin\":\"byteball\",\"balance\":4238}, {\"coin\":\"iocoin\",\"balance\":150000}, {\"coin\":\"quantum-resistant-ledger\",\"balance\":375000}, {\"coin\":\"chips\",\"balance\":2577006 }, {\"coin\":\"hush\",\"balance\":100000 }, {\"coin\":\"mobilego\",\"balance\":100000 }],\"divisor\":816016}"
curl --url "http://127.0.0.1:7783" --data "{\"margin\":$margin,\"base\":\"SUPERNET\",\"rel\":\"KMD\",\"fundvalue_bid\":\"NAV_KMD\",\"fundvalue_ask\":\"NAV_KMD\",\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"address\":\"RRyyejME7LRTuvdziWsXkAbSW1fdiohGwK\",\"holdings\":[{\"coin\":\"iota\",\"balance\":11000000}, {\"coin\":\"stratis\",\"balance\":1300000}, {\"coin\":\"zcash\",\"balance\":10000}, {\"coin\":\"syscoin\",\"balance\":20000000}, {\"coin\":\"waves\",\"balance\":700000}, {\"coin\":\"bitcoin\",\"balance\":625}, {\"coin\":\"bitcoin-cash\",\"balance\":1500}, {\"coin\":\"heat-ledger\",\"balance\":2323851 }, {\"coin\":\"decred\",\"balance\":20000}, {\"coin\":\"vericoin\",\"balance\":2199368 }, {\"coin\":\"byteball\",\"balance\":4238}, {\"coin\":\"iocoin\",\"balance\":150000}, {\"coin\":\"quantum-resistant-ledger\",\"balance\":375000}, {\"coin\":\"chips\",\"balance\":2577006 }, {\"coin\":\"hush\",\"balance\":100000 }, {\"coin\":\"mobilego\",\"balance\":100000 }],\"divisor\":612529}"
curl --url "http://127.0.0.1:7783" --data "{\"margin\":$margin,\"base\":\"HODL\",\"rel\":\"KMD\",\"fundvalue_bid\":\"assetNAV_KMD\",\"fundvalue_ask\":\"assetNAV_KMD\",\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"address\":\"RNcUaMUEFLxVwtTo7rgruhwYanGk1jTkeU\",\"holdings\":[{\"coin\":\"siacoin\",\"balance\":185000000,\"comment\":\"using siafunds equal to million siacoin\"}],\"divisor\":10000000}"
dexholdings="{\"coin\":\"blocknet\",\"balance\":4000000}"
dexholdings="{\"coin\":\"blocknet\",\"balance\":2500000}"
curl --url "http://127.0.0.1:7783" --data "{\"base\":\"DEX\",\"rel\":\"KMD\",\"margin\":$margin,\"fundvalue_bid\":\"assetNAV_KMD\",\"fundvalue_ask\":\"assetNAV_KMD\",\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"address\":\"RThtXup6Zo7LZAi8kRWgjAyi1s4u6U9Cpf\",\"holdings\":[$dexholdings],\"divisor\":1000000}"
curl --url "http://127.0.0.1:7783" --data "{\"base\":\"BOTS\",\"rel\":\"KMD\",\"margin\":$margin,\"fundvalue_bid\":\"assetNAV_KMD\",\"fundvalue_ask\":\"assetNAV_KMD\",\"userpass\":\"$userpass\",\"method\":\"autoprice\",\"address\":\"RNdqHx26GWy9bk8MtmH1UiXjQcXE4RKK2P\",\"holdings\":[$dexholdings],\"divisor\":3333333}"

32
iguana/exchanges/stats.c

@ -29,7 +29,7 @@
#define STATS_DEST "/var/www/html/DEXstats.json"
#include "DEXstats.h"
char *stats_JSON(void *ctx,char *myipaddr,int32_t mypubsock,cJSON *argjson,char *remoteaddr,uint16_t port);
void LP_queuecommand(char **retstrp,char *buf,int32_t responsesock,int32_t stats_JSONonly);
void LP_queuecommand(char **retstrp,char *buf,int32_t responsesock,int32_t stats_JSONonly,uint32_t queueid);
extern uint32_t DOCKERFLAG;
char *stats_validmethods[] =
@ -330,11 +330,12 @@ cJSON *SuperNET_urlconv(char *value,int32_t bufsize,char *urlstr)
}
extern void *bitcoin_ctx();
extern int32_t IPC_ENDPOINT;
char *stats_rpcparse(char *retbuf,int32_t bufsize,int32_t *jsonflagp,int32_t *postflagp,char *urlstr,char *remoteaddr,char *filetype,uint16_t port)
{
static void *ctx;
cJSON *tokens,*argjson,*origargjson,*tmpjson=0,*json = 0; long filesize; char symbol[64],buf[4096],*userpass=0,urlmethod[16],*data,url[8192],furl[8192],*retstr=0,*filestr,*token = 0; int32_t i,j,n,num=0;
cJSON *tokens,*argjson,*origargjson,*tmpjson=0,*json = 0; long filesize; char symbol[64],buf[4096],*userpass=0,urlmethod[16],*data,url[8192],furl[8192],*retstr=0,*filestr,*token = 0; int32_t i,j,n,num=0; uint32_t queueid;
if ( ctx == 0 )
ctx = bitcoin_ctx();
for (i=0; i<sizeof(urlmethod)-1&&urlstr[i]!=0&&urlstr[i]!=' '; i++)
@ -556,7 +557,7 @@ char *stats_rpcparse(char *retbuf,int32_t bufsize,int32_t *jsonflagp,int32_t *po
}
else
{
cJSON *arg; //char *buf;
cJSON *arg; char *buf;
if ( jstr(argjson,"agent") != 0 && strcmp(jstr(argjson,"agent"),"bitcoinrpc") != 0 && jobj(argjson,"params") != 0 )
{
arg = jobj(argjson,"params");
@ -569,20 +570,21 @@ char *stats_rpcparse(char *retbuf,int32_t bufsize,int32_t *jsonflagp,int32_t *po
#ifdef FROM_MARKETMAKER
if ( strcmp(remoteaddr,"127.0.0.1") == 0 || LP_valid_remotemethod(arg) > 0 )
{
//buf = jprint(arg,0);
//LP_queuecommand(&retstr,buf,-1,1);
//free(buf);
//while ( retstr == 0 )
// usleep(10000);
retstr = stats_JSON(ctx,"127.0.0.1",-1,arg,remoteaddr,port);
if ( IPC_ENDPOINT >= 0 && (queueid= juint(arg,"queueid")) > 0 )
{
buf = jprint(arg,0);
LP_queuecommand(&retstr,buf,IPC_ENDPOINT,1,queueid);
free(buf);
retstr = clonestr("{\"result\":\"success\",\"status\":\"queued\"}");
} else retstr = stats_JSON(ctx,"127.0.0.1",-1,arg,remoteaddr,port);
} else retstr = clonestr("{\"error\":\"invalid remote method\"}");
#else
//buf = jprint(arg,0);
//LP_queuecommand(&retstr,buf,-1,1);
//free(buf);
//while ( retstr == 0 )
// usleep(10000);
retstr = stats_JSON(ctx,myipaddr,-1,arg,remoteaddr,port);
if ( IPC_ENDPOINT >= 0 && (queueid= juint(arg,"queueid")) > 0 )
{
buf = jprint(arg,0);
LP_queuecommand(&retstr,buf,IPC_ENDPOINT,1,queueid);
free(buf);
} else retstr = stats_JSON(ctx,myipaddr,-1,arg,remoteaddr,port);
#endif
}
free_json(argjson);

2
iguana/exchanges/supernet

@ -15,6 +15,6 @@ echo supernet
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"balances\",\"address\":\"RRyyejME7LRTuvdziWsXkAbSW1fdiohGwK\"}"
echo supernet
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"fundvalue\",\"address\":\"RRyyejME7LRTuvdziWsXkAbSW1fdiohGwK\",\"holdings\":[{\"coin\":\"iota\",\"balance\":11000000}, {\"coin\":\"stratis\",\"balance\":1300000}, {\"coin\":\"zcash\",\"balance\":10000}, {\"coin\":\"syscoin\",\"balance\":20000000}, {\"coin\":\"waves\",\"balance\":700000}, {\"coin\":\"bitcoin\",\"balance\":625}, {\"coin\":\"bitcoin-cash\",\"balance\":1500}, {\"coin\":\"heat-ledger\",\"balance\":2323851 }, {\"coin\":\"decred\",\"balance\":20000}, {\"coin\":\"vericoin\",\"balance\":2199368 }, {\"coin\":\"byteball\",\"balance\":4238}, {\"coin\":\"iocoin\",\"balance\":150000}, {\"coin\":\"quantum-resistant-ledger\",\"balance\":375000}, {\"coin\":\"hush\",\"balance\":100000 }, {\"coin\":\"mobilego\",\"balance\":100000 }],\"divisor\":816016}"
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"fundvalue\",\"address\":\"RRyyejME7LRTuvdziWsXkAbSW1fdiohGwK\",\"holdings\":[{\"coin\":\"iota\",\"balance\":11000000}, {\"coin\":\"stratis\",\"balance\":1300000}, {\"coin\":\"zcash\",\"balance\":10000}, {\"coin\":\"syscoin\",\"balance\":20000000}, {\"coin\":\"waves\",\"balance\":700000}, {\"coin\":\"bitcoin\",\"balance\":625}, {\"coin\":\"bitcoin-cash\",\"balance\":1500}, {\"coin\":\"heat-ledger\",\"balance\":2323851 }, {\"coin\":\"decred\",\"balance\":20000}, {\"coin\":\"vericoin\",\"balance\":2199368 }, {\"coin\":\"byteball\",\"balance\":4238}, {\"coin\":\"iocoin\",\"balance\":150000}, {\"coin\":\"quantum-resistant-ledger\",\"balance\":375000}, {\"coin\":\"hush\",\"balance\":100000 }, {\"coin\":\"mobilego\",\"balance\":100000 }],\"divisor\":612529}"
#curl --url "http://5.9.253.196:7782" --data "{\"userpass\":\"$userpass\",\"method\":\"fundvalue\",\"address\":\"RRyyejME7LRTuvdziWsXkAbSW1fdiohGwK\",\"holdings\":[{\"coin\":\"iota\",\"balance\":11000000}, {\"coin\":\"stratis\",\"balance\":1300000}, {\"coin\":\"zcash\",\"balance\":10000}, {\"coin\":\"syscoin\",\"balance\":20000000}, {\"coin\":\"waves\",\"balance\":700000}, {\"coin\":\"bitcoin\",\"balance\":625}, {\"coin\":\"bitcoin-cash\",\"balance\":1500}, {\"coin\":\"heat-ledger\",\"balance\":2323851 }, {\"coin\":\"decred\",\"balance\":20000}, {\"coin\":\"vericoin\",\"balance\":2199368 }, {\"coin\":\"byteball\",\"balance\":4238}, {\"coin\":\"iocoin\",\"balance\":150000}, {\"coin\":\"quantum-resistant-ledger\",\"balance\":375000}, {\"coin\":\"chips\",\"balance\":2577006 }, {\"coin\":\"hush\",\"balance\":100000 }, {\"coin\":\"mobilego\",\"balance\":100000 }],\"divisor\":816016}"

7
iguana/exchanges/updateprices

@ -0,0 +1,7 @@
cp ../exchanges/auto_* .
cp ../exchanges/prices/autoprice .
cp ../exchanges/prices/crypto .
cp ../exchanges/prices/jumblr .
cp ../exchanges/prices/pangea .
cp ../exchanges/prices/bet .
cp ../exchanges/prices/revs .

48
iguana/m_splitfund

@ -3,28 +3,28 @@
set -x
curl --url "http://127.0.0.1:7776" --data "{\"coin\":\"BTC\",\"agent\":\"iguana\",\"method\":\"splitfunds\",\"satoshis\":\"50000\",\"sendflag\":1,\"duplicates\":10}"
curl --url "http://127.0.0.1:7776" --data "{\"coin\":\"KMD\",\"agent\":\"iguana\",\"method\":\"splitfunds\",\"satoshis\":\"50000\",\"sendflag\":1,\"duplicates\":10}"
curl --url "http://127.0.0.1:7776" --data "{\"coin\":\"KMD\",\"agent\":\"iguana\",\"method\":\"splitfunds\",\"satoshis\":\"50000\",\"sendflag\":1,\"duplicates\":50}"
curl --url "http://127.0.0.1:7776" --data "{\"coin\":\"REVS\",\"agent\":\"iguana\",\"method\":\"splitfunds\",\"satoshis\":\"50000\",\"sendflag\":1,\"duplicates\":10}"
curl --url "http://127.0.0.1:7776" --data "{\"coin\":\"SUPERNET\",\"agent\":\"iguana\",\"method\":\"splitfunds\",\"satoshis\":\"50000\",\"sendflag\":1,\"duplicates\":10}"
curl --url "http://127.0.0.1:7776" --data "{\"coin\":\"DEX\",\"agent\":\"iguana\",\"method\":\"splitfunds\",\"satoshis\":\"50000\",\"sendflag\":1,\"duplicates\":10}"
curl --url "http://127.0.0.1:7776" --data "{\"coin\":\"PANGEA\",\"agent\":\"iguana\",\"method\":\"splitfunds\",\"satoshis\":\"50000\",\"sendflag\":1,\"duplicates\":10}"
curl --url "http://127.0.0.1:7776" --data "{\"coin\":\"JUMBLR\",\"agent\":\"iguana\",\"method\":\"splitfunds\",\"satoshis\":\"50000\",\"sendflag\":1,\"duplicates\":10}"
curl --url "http://127.0.0.1:7776" --data "{\"coin\":\"BET\",\"agent\":\"iguana\",\"method\":\"splitfunds\",\"satoshis\":\"50000\",\"sendflag\":1,\"duplicates\":10}"
curl --url "http://127.0.0.1:7776" --data "{\"coin\":\"CRYPTO\",\"agent\":\"iguana\",\"method\":\"splitfunds\",\"satoshis\":\"50000\",\"sendflag\":1,\"duplicates\":10}"
curl --url "http://127.0.0.1:7776" --data "{\"coin\":\"HODL\",\"agent\":\"iguana\",\"method\":\"splitfunds\",\"satoshis\":\"50000\",\"sendflag\":1,\"duplicates\":10}"
curl --url "http://127.0.0.1:7776" --data "{\"coin\":\"MSHARK\",\"agent\":\"iguana\",\"method\":\"splitfunds\",\"satoshis\":\"50000\",\"sendflag\":1,\"duplicates\":10}"
curl --url "http://127.0.0.1:7776" --data "{\"coin\":\"BOTS\",\"agent\":\"iguana\",\"method\":\"splitfunds\",\"satoshis\":\"50000\",\"sendflag\":1,\"duplicates\":10}"
curl --url "http://127.0.0.1:7776" --data "{\"coin\":\"MGW\",\"agent\":\"iguana\",\"method\":\"splitfunds\",\"satoshis\":\"50000\",\"sendflag\":1,\"duplicates\":10}"
curl --url "http://127.0.0.1:7776" --data "{\"coin\":\"COQUI\",\"agent\":\"iguana\",\"method\":\"splitfunds\",\"satoshis\":\"50000\",\"sendflag\":1,\"duplicates\":10}"
curl --url "http://127.0.0.1:7776" --data "{\"coin\":\"WLC\",\"agent\":\"iguana\",\"method\":\"splitfunds\",\"satoshis\":\"50000\",\"sendflag\":1,\"duplicates\":10}"
curl --url "http://127.0.0.1:7776" --data "{\"coin\":\"KV\",\"agent\":\"iguana\",\"method\":\"splitfunds\",\"satoshis\":\"50000\",\"sendflag\":1,\"duplicates\":10}"
curl --url "http://127.0.0.1:7776" --data "{\"coin\":\"CEAL\",\"agent\":\"iguana\",\"method\":\"splitfunds\",\"satoshis\":\"50000\",\"sendflag\":1,\"duplicates\":10}"
curl --url "http://127.0.0.1:7776" --data "{\"coin\":\"MESH\",\"agent\":\"iguana\",\"method\":\"splitfunds\",\"satoshis\":\"50000\",\"sendflag\":1,\"duplicates\":10}"
curl --url "http://127.0.0.1:7776" --data "{\"coin\":\"MNZ\",\"agent\":\"iguana\",\"method\":\"splitfunds\",\"satoshis\":\"50000\",\"sendflag\":1,\"duplicates\":10}"
curl --url "http://127.0.0.1:7776" --data "{\"coin\":\"AXO\",\"agent\":\"iguana\",\"method\":\"splitfunds\",\"satoshis\":\"50000\",\"sendflag\":1,\"duplicates\":10}"
curl --url "http://127.0.0.1:7776" --data "{\"coin\":\"BTCH\",\"agent\":\"iguana\",\"method\":\"splitfunds\",\"satoshis\":\"50000\",\"sendflag\":1,\"duplicates\":10}"
curl --url "http://127.0.0.1:7776" --data "{\"coin\":\"ETOMIC\",\"agent\":\"iguana\",\"method\":\"splitfunds\",\"satoshis\":\"50000\",\"sendflag\":1,\"duplicates\":10}"
curl --url "http://127.0.0.1:7776" --data "{\"coin\":\"VOTE2018\",\"agent\":\"iguana\",\"method\":\"splitfunds\",\"satoshis\":\"50000\",\"sendflag\":1,\"duplicates\":10}"
curl --url "http://127.0.0.1:7776" --data "{\"coin\":\"CHIPS\",\"agent\":\"iguana\",\"method\":\"splitfunds\",\"satoshis\":\"50000\",\"sendflag\":1,\"duplicates\":10}"
curl --url "http://127.0.0.1:7776" --data "{\"coin\":\"NINJA\",\"agent\":\"iguana\",\"method\":\"splitfunds\",\"satoshis\":\"50000\",\"sendflag\":1,\"duplicates\":10}"
curl --url "http://127.0.0.1:7776" --data "{\"coin\":\"REVS\",\"agent\":\"iguana\",\"method\":\"splitfunds\",\"satoshis\":\"50000\",\"sendflag\":1,\"duplicates\":50}"
curl --url "http://127.0.0.1:7776" --data "{\"coin\":\"SUPERNET\",\"agent\":\"iguana\",\"method\":\"splitfunds\",\"satoshis\":\"50000\",\"sendflag\":1,\"duplicates\":50}"
curl --url "http://127.0.0.1:7776" --data "{\"coin\":\"DEX\",\"agent\":\"iguana\",\"method\":\"splitfunds\",\"satoshis\":\"50000\",\"sendflag\":1,\"duplicates\":50}"
curl --url "http://127.0.0.1:7776" --data "{\"coin\":\"PANGEA\",\"agent\":\"iguana\",\"method\":\"splitfunds\",\"satoshis\":\"50000\",\"sendflag\":1,\"duplicates\":50}"
curl --url "http://127.0.0.1:7776" --data "{\"coin\":\"JUMBLR\",\"agent\":\"iguana\",\"method\":\"splitfunds\",\"satoshis\":\"50000\",\"sendflag\":1,\"duplicates\":50}"
curl --url "http://127.0.0.1:7776" --data "{\"coin\":\"BET\",\"agent\":\"iguana\",\"method\":\"splitfunds\",\"satoshis\":\"50000\",\"sendflag\":1,\"duplicates\":50}"
curl --url "http://127.0.0.1:7776" --data "{\"coin\":\"CRYPTO\",\"agent\":\"iguana\",\"method\":\"splitfunds\",\"satoshis\":\"50000\",\"sendflag\":1,\"duplicates\":50}"
curl --url "http://127.0.0.1:7776" --data "{\"coin\":\"HODL\",\"agent\":\"iguana\",\"method\":\"splitfunds\",\"satoshis\":\"50000\",\"sendflag\":1,\"duplicates\":50}"
curl --url "http://127.0.0.1:7776" --data "{\"coin\":\"MSHARK\",\"agent\":\"iguana\",\"method\":\"splitfunds\",\"satoshis\":\"50000\",\"sendflag\":1,\"duplicates\":50}"
curl --url "http://127.0.0.1:7776" --data "{\"coin\":\"BOTS\",\"agent\":\"iguana\",\"method\":\"splitfunds\",\"satoshis\":\"50000\",\"sendflag\":1,\"duplicates\":50}"
curl --url "http://127.0.0.1:7776" --data "{\"coin\":\"MGW\",\"agent\":\"iguana\",\"method\":\"splitfunds\",\"satoshis\":\"50000\",\"sendflag\":1,\"duplicates\":50}"
curl --url "http://127.0.0.1:7776" --data "{\"coin\":\"COQUI\",\"agent\":\"iguana\",\"method\":\"splitfunds\",\"satoshis\":\"50000\",\"sendflag\":1,\"duplicates\":50}"
curl --url "http://127.0.0.1:7776" --data "{\"coin\":\"WLC\",\"agent\":\"iguana\",\"method\":\"splitfunds\",\"satoshis\":\"50000\",\"sendflag\":1,\"duplicates\":50}"
curl --url "http://127.0.0.1:7776" --data "{\"coin\":\"KV\",\"agent\":\"iguana\",\"method\":\"splitfunds\",\"satoshis\":\"50000\",\"sendflag\":1,\"duplicates\":50}"
curl --url "http://127.0.0.1:7776" --data "{\"coin\":\"CEAL\",\"agent\":\"iguana\",\"method\":\"splitfunds\",\"satoshis\":\"50000\",\"sendflag\":1,\"duplicates\":50}"
curl --url "http://127.0.0.1:7776" --data "{\"coin\":\"MESH\",\"agent\":\"iguana\",\"method\":\"splitfunds\",\"satoshis\":\"50000\",\"sendflag\":1,\"duplicates\":50}"
curl --url "http://127.0.0.1:7776" --data "{\"coin\":\"MNZ\",\"agent\":\"iguana\",\"method\":\"splitfunds\",\"satoshis\":\"50000\",\"sendflag\":1,\"duplicates\":50}"
curl --url "http://127.0.0.1:7776" --data "{\"coin\":\"AXO\",\"agent\":\"iguana\",\"method\":\"splitfunds\",\"satoshis\":\"50000\",\"sendflag\":1,\"duplicates\":50}"
curl --url "http://127.0.0.1:7776" --data "{\"coin\":\"BTCH\",\"agent\":\"iguana\",\"method\":\"splitfunds\",\"satoshis\":\"50000\",\"sendflag\":1,\"duplicates\":50}"
curl --url "http://127.0.0.1:7776" --data "{\"coin\":\"ETOMIC\",\"agent\":\"iguana\",\"method\":\"splitfunds\",\"satoshis\":\"50000\",\"sendflag\":1,\"duplicates\":50}"
curl --url "http://127.0.0.1:7776" --data "{\"coin\":\"VOTE2018\",\"agent\":\"iguana\",\"method\":\"splitfunds\",\"satoshis\":\"50000\",\"sendflag\":1,\"duplicates\":50}"
curl --url "http://127.0.0.1:7776" --data "{\"coin\":\"CHIPS\",\"agent\":\"iguana\",\"method\":\"splitfunds\",\"satoshis\":\"50000\",\"sendflag\":1,\"duplicates\":50}"
curl --url "http://127.0.0.1:7776" --data "{\"coin\":\"NINJA\",\"agent\":\"iguana\",\"method\":\"splitfunds\",\"satoshis\":\"50000\",\"sendflag\":1,\"duplicates\":50}"

Loading…
Cancel
Save