Browse Source

Test

etomic
jl777 7 years ago
parent
commit
30828f5fc2
  1. 13
      iguana/exchanges/LP_cache.c
  2. 6
      iguana/exchanges/LP_coins.c
  3. 5
      iguana/exchanges/LP_commands.c
  4. 4
      iguana/exchanges/LP_include.h
  5. 2
      iguana/exchanges/LP_instantdex.c
  6. 31
      iguana/exchanges/LP_nativeDEX.c
  7. 4
      iguana/exchanges/LP_ordermatch.c
  8. 4
      iguana/exchanges/LP_privkey.c
  9. 4
      iguana/exchanges/LP_rpc.c
  10. 8
      iguana/exchanges/LP_stats.c
  11. 8
      iguana/exchanges/LP_utxo.c

13
iguana/exchanges/LP_cache.c

@ -229,17 +229,24 @@ bits256 LP_merkleroot(struct iguana_info *coin,struct electrum_info *ep,int32_t
int32_t LP_merkleproof(struct iguana_info *coin,char *coinaddr,struct electrum_info *ep,bits256 txid,int32_t height)
{
struct LP_transaction *tx=0; cJSON *merkobj,*merkles,*retjson; bits256 roothash,merkleroot; int32_t m,SPV = 0;
struct LP_transaction *tx=0; cJSON *merkobj,*merkles,*retjson; bits256 roothash,merkleroot; int32_t m,ht=0,SPV = 0;
if ( height <= 0 )
return(0);
if ( (tx= LP_transactionfind(coin,txid)) == 0 && strcmp(coinaddr,coin->smartaddr) == 0 )
{
if ( (retjson= electrum_transaction(coin->symbol,ep,&retjson,txid,0)) != 0 )
if ( (retjson= electrum_transaction(&ht,coin->symbol,ep,&retjson,txid,0)) != 0 )
free_json(retjson);
}
if ( tx != 0 )
{
tx->height = height;
if ( tx->height == 0 )
{
if ( height != 0 )
tx->height = height;
else if ( ht != 0 )
tx->height = ht;
height = tx->height;
}
if ( tx->SPV > 0 )
return(tx->SPV);
}

6
iguana/exchanges/LP_coins.c

@ -214,7 +214,7 @@ uint16_t LP_userpass(char *userpass,char *symbol,char *assetname,char *confroot,
cJSON *LP_coinjson(struct iguana_info *coin,int32_t showwif)
{
struct electrum_info *ep; uint64_t balance; char wifstr[128],ipaddr[64]; uint8_t tmptype; bits256 checkkey; cJSON *item = cJSON_CreateObject();
struct electrum_info *ep; int32_t notarized; uint64_t balance; char wifstr[128],ipaddr[64]; uint8_t tmptype; bits256 checkkey; cJSON *item = cJSON_CreateObject();
jaddstr(item,"coin",coin->symbol);
if ( showwif != 0 )
{
@ -227,7 +227,9 @@ cJSON *LP_coinjson(struct iguana_info *coin,int32_t showwif)
jadd(item,"installed",coin->userpass[0] == 0 ? jfalse() : jtrue());
if ( coin->userpass[0] != 0 )
{
jaddnum(item,"height",LP_getheight(coin));
jaddnum(item,"height",LP_getheight(&notarized,coin));
if ( notarized > 0 )
jaddnum(item,"notarized",notarized);
if ( coin->electrum != 0 )
balance = LP_unspents_load(coin->symbol,coin->smartaddr);
else balance = LP_RTsmartbalance(coin);

5
iguana/exchanges/LP_commands.c

@ -124,6 +124,7 @@ swapstatus(coin, limit=10)\n\
swapstatus(base, rel, limit=10)\n\
swapstatus(requestid, quoteid)\n\
recentswaps(limit=3)\n\
notarizations(coin)\n\
public API:\n \
getcoins()\n\
getcoin(coin)\n\
@ -419,8 +420,8 @@ instantdex_claim()\n\
if ( LP_conflicts_find(ptr) == 0 )
{
ptr->inactive = 0;
cJSON *array;
if ( LP_getheight(ptr) <= 0 )
cJSON *array; int32_t notarized;
if ( LP_getheight(&notarized,ptr) <= 0 )
{
ptr->inactive = (uint32_t)time(NULL);
return(clonestr("{\"error\":\"coin cant be activated till synced\"}"));

4
iguana/exchanges/LP_include.h

@ -289,7 +289,7 @@ struct iguana_info
UT_hash_handle hh;
portable_mutex_t txmutex,addrmutex; struct LP_transaction *transactions; struct LP_address *addresses;
uint64_t txfee;
int32_t numutxos,longestchain,firstrefht,firstscanht,lastscanht,bussock,height; uint16_t busport;
int32_t numutxos,notarized,longestchain,firstrefht,firstscanht,lastscanht,bussock,height; uint16_t busport;
uint32_t loadedcache,electrumlist,lastunspent,importedprivkey,lastpushtime,lastutxosync,addr_listunspent_requested,lastutxos,updaterate,counter,inactive,lastmempool,lastgetinfo,ratetime,heighttime,lastmonitor,obooktime;
uint8_t pubtype,p2shtype,isPoS,wiftype,wiftaddr,taddr,noimportprivkey_flag,userconfirms,isassetchain,maxconfirms;
char symbol[128],smartaddr[64],userpass[1024],serverport[128];
@ -483,7 +483,7 @@ void LP_aliceid(uint32_t tradeid,uint64_t aliceid,char *event,uint32_t requestid
cJSON *LP_cache_transaction(struct iguana_info *coin,bits256 txid,uint8_t *serialized,int32_t len);
cJSON *LP_transaction_fromdata(struct iguana_info *coin,bits256 txid,uint8_t *serialized,int32_t len);
uint64_t LP_RTsmartbalance(struct iguana_info *coin);
int32_t LP_getheight(struct iguana_info *coin);
int32_t LP_getheight(int32_t *notarizedp,struct iguana_info *coin);
int32_t LP_reserved_msg(int32_t priority,char *base,char *rel,bits256 pubkey,char *msg);
struct iguana_info *LP_coinfind(char *symbol);
int32_t LP_crc32find(int32_t *duplicatep,int32_t ind,uint32_t crc32);

2
iguana/exchanges/LP_instantdex.c

@ -507,7 +507,7 @@ cJSON *LP_myzdebits()
}
}
retjson = cJSON_CreateObject();
jaddstr(retjson,"result","success");
jadd(retjson,"swaps",array);
jaddnum(retjson,"pendingswaps",dstr(swaps_kmdvalue));
return(retjson);
}

31
iguana/exchanges/LP_nativeDEX.c

@ -483,7 +483,7 @@ void command_rpcloop(void *ctx)
void LP_coinsloop(void *_coins)
{
struct LP_address *ap=0,*atmp; struct LP_transaction *tx; cJSON *retjson; struct LP_address_utxo *up,*tmp; struct iguana_info *coin,*ctmp; char str[65]; struct electrum_info *ep,*backupep=0; bits256 zero; int32_t oldht,j,nonz; char *coins = _coins;
struct LP_address *ap=0,*atmp; struct LP_transaction *tx; cJSON *retjson; struct LP_address_utxo *up,*tmp; struct iguana_info *coin,*ctmp; char str[65]; struct electrum_info *ep,*backupep=0; bits256 zero; int32_t notarized,oldht,j,nonz; char *coins = _coins;
if ( strcmp("BTC",coins) == 0 )
{
strcpy(LP_coinsloopBTC_stats.name,"BTC coin loop");
@ -528,7 +528,7 @@ void LP_coinsloop(void *_coins)
if ( coin->inactive != 0 )
continue;
if ( coin->longestchain == 1 ) // special init value
coin->longestchain = LP_getheight(coin);
coin->longestchain = LP_getheight(&notarized,coin);
if ( (ep= coin->electrum) != 0 )
{
/*if ( strcmp("KMD",coin->symbol) == 0 && coin->electrumzeroconf == 0 )
@ -645,7 +645,7 @@ void LP_coinsloop(void *_coins)
int32_t LP_mainloop_iter(void *ctx,char *myipaddr,struct LP_peerinfo *mypeer,int32_t pubsock,char *pushaddr,uint16_t myport)
{
static uint32_t counter;//,didinstantdex;
struct iguana_info *coin,*ctmp; char *origipaddr; uint32_t now; int32_t height,nonz = 0;
struct iguana_info *coin,*ctmp; char *origipaddr; uint32_t now; int32_t notarized,height,nonz = 0; bits256 zero; cJSON *reqjson;
if ( (origipaddr= myipaddr) == 0 )
origipaddr = "127.0.0.1";
if ( mypeer == 0 )
@ -660,19 +660,32 @@ int32_t LP_mainloop_iter(void *ctx,char *myipaddr,struct LP_peerinfo *mypeer,int
didinstantdex = now;
}
#endif
if ( (coin->addr_listunspent_requested != 0 && now > coin->lastpushtime+LP_ORDERBOOK_DURATION*.5) || now > coin->lastpushtime+LP_ORDERBOOK_DURATION*5 )
/*if ( (coin->addr_listunspent_requested != 0 && now > coin->lastpushtime+LP_ORDERBOOK_DURATION*.5) || now > coin->lastpushtime+LP_ORDERBOOK_DURATION*5 )
{
//printf("PUSH addr_listunspent_requested %u\n",coin->addr_listunspent_requested);
coin->lastpushtime = (uint32_t)now;
LP_smartutxos_push(coin);
coin->addr_listunspent_requested = 0;
}
}*/
if ( coin->electrum == 0 && coin->inactive == 0 && now > coin->lastgetinfo+LP_GETINFO_INCR )
{
nonz++;
if ( (height= LP_getheight(coin)) > coin->longestchain )
if ( (height= LP_getheight(&notarized,coin)) > coin->longestchain )
{
coin->longestchain = height;
if ( notarized != 0 && notarized > coin->notarized )
{
coin->notarized = notarized;
if ( IAMLP != 0 )
{
reqjson = cJSON_CreateObject();
jaddstr(reqjson,"method","dPoW");
jaddstr(reqjson,"coin",coin->symbol);
jaddnum(reqjson,"notarized",coin->notarized);
memset(zero.bytes,0,sizeof(zero));
LP_reserved_msg(0,coin->symbol,coin->symbol,zero,jprint(reqjson,1));
}
}
if ( 0 && coin->firstrefht != 0 )
printf(">>>>>>>>>> set %s longestchain %d (ref.%d [%d, %d])\n",coin->symbol,height,coin->firstrefht,coin->firstscanht,coin->lastscanht);
} //else LP_mempoolscan(coin->symbol,zero);
@ -685,7 +698,7 @@ int32_t LP_mainloop_iter(void *ctx,char *myipaddr,struct LP_peerinfo *mypeer,int
void LP_initcoins(void *ctx,int32_t pubsock,cJSON *coins)
{
int32_t i,n; cJSON *item; char *symbol; struct iguana_info *coin;
int32_t i,n,notarized; cJSON *item; char *symbol; struct iguana_info *coin;
for (i=0; i<sizeof(activecoins)/sizeof(*activecoins); i++)
{
printf("%s ",activecoins[i]);
@ -696,7 +709,7 @@ void LP_initcoins(void *ctx,int32_t pubsock,cJSON *coins)
//getchar();
if ( (coin= LP_coinfind(activecoins[i])) != 0 )
{
if ( LP_getheight(coin) <= 0 )
if ( LP_getheight(&notarized,coin) <= 0 )
coin->inactive = (uint32_t)time(NULL);
else
{
@ -720,7 +733,7 @@ void LP_initcoins(void *ctx,int32_t pubsock,cJSON *coins)
LP_priceinfoadd(jstr(item,"coin"));
if ( (coin= LP_coinfind(symbol)) != 0 )
{
if ( LP_getheight(coin) <= 0 )
if ( LP_getheight(&notarized,coin) <= 0 )
coin->inactive = (uint32_t)time(NULL);
else LP_unspents_load(coin->symbol,coin->smartaddr);
if ( coin->txfee == 0 && strcmp(coin->symbol,"BTC") != 0 )

4
iguana/exchanges/LP_ordermatch.c

@ -696,13 +696,13 @@ int32_t LP_aliceonly(char *symbol)
int32_t LP_validSPV(char *symbol,char *coinaddr,bits256 txid,int32_t vout)
{
struct electrum_info *ep,*backupep; cJSON *txobj; struct LP_address_utxo *up; struct iguana_info *coin; struct LP_transaction *tx;
struct electrum_info *ep,*backupep; cJSON *txobj; struct LP_address_utxo *up; struct iguana_info *coin; int32_t height; struct LP_transaction *tx;
coin = LP_coinfind(symbol);
if ( coin != 0 && (ep= coin->electrum) != 0 )
{
if ( (up= LP_address_utxofind(coin,coinaddr,txid,vout)) == 0 )
{
if ( (txobj= electrum_transaction(symbol,ep,&txobj,txid,coinaddr)) != 0 )
if ( (txobj= electrum_transaction(&height,symbol,ep,&txobj,txid,coinaddr)) != 0 )
free_json(txobj);
if ( (tx= LP_transactionfind(coin,txid)) != 0 )
{

4
iguana/exchanges/LP_privkey.c

@ -205,7 +205,7 @@ char *LP_secretaddresses(void *ctx,char *prefix,char *passphrase,int32_t n,uint8
bits256 LP_privkeycalc(void *ctx,uint8_t *pubkey33,bits256 *pubkeyp,struct iguana_info *coin,char *passphrase,char *wifstr)
{
//static uint32_t counter;
bits256 privkey,userpub,zero,userpass,checkkey; char tmpstr[128]; cJSON *retjson; uint8_t tmptype;
bits256 privkey,userpub,zero,userpass,checkkey; char tmpstr[128]; cJSON *retjson; uint8_t tmptype; int32_t notarized;
if ( passphrase != 0 && passphrase[0] != 0 )
{
calc_NXTaddr(G.LP_NXTaddr,userpub.bytes,(uint8_t *)passphrase,(int32_t)strlen(passphrase));
@ -252,7 +252,7 @@ bits256 LP_privkeycalc(void *ctx,uint8_t *pubkey33,bits256 *pubkeyp,struct iguan
printf("userpass.(%s)\n",bits256_str(G.USERPASS,userpub));
}
}
if ( coin->importedprivkey == 0 && coin->electrum == 0 && coin->userpass[0] != 0 && LP_getheight(coin) > 0 )
if ( coin->importedprivkey == 0 && coin->electrum == 0 && coin->userpass[0] != 0 && LP_getheight(&notarized,coin) > 0 )
{
memset(zero.bytes,0,sizeof(zero));
LP_listunspent_issue(coin->symbol,coin->smartaddr,0,zero,zero);

4
iguana/exchanges/LP_rpc.c

@ -86,9 +86,10 @@ void LP_unspents_mark(char *symbol,cJSON *vins)
//printf("LOCK (%s)\n",jprint(vins,0));
}
int32_t LP_getheight(struct iguana_info *coin)
int32_t LP_getheight(int32_t *notarizedp,struct iguana_info *coin)
{
cJSON *retjson; char *retstr,*method = "getinfo"; int32_t height;
*notarizedp = 0;
if ( coin == 0 )
return(-1);
height = coin->height;
@ -101,6 +102,7 @@ int32_t LP_getheight(struct iguana_info *coin)
{
retjson = cJSON_Parse(retstr);
coin->height = height = jint(retjson,"blocks");
*notarizedp = jint(retjson,"notarized");
free_json(retjson);
if ( coin->height > 0 )
coin->heighttime = (uint32_t)time(NULL);

8
iguana/exchanges/LP_stats.c

@ -210,7 +210,9 @@ int32_t LP_swapstats_update(struct LP_swapstats *sp,struct LP_quoteinfo *qp,cJSO
int32_t LP_dPoWheight(struct iguana_info *coin) // get dPoW protected height
{
int32_t notarized;
coin->height = LP_getheight(&notarized,coin);
return(notarized);
}
int32_t LP_finished_lastheight(struct LP_swapstats *sp,int32_t iambob)
@ -380,9 +382,9 @@ int32_t LP_statslog_parsequote(char *method,cJSON *lineobj)
sp->expired = sp->lasttime;
else
{
if ( (alice= LP_coinfind(rel)) && alice->isassetchain != 0 )
if ( (alice= LP_coinfind(rel)) != 0 && (alice->isassetchain != 0 || strcmp("KMD",alice->symbol) == 0) )
sp->aliceneeds_dPoW = 1;
if ( (bob= LP_coinfind(rel)) && bob->isassetchain != 0 )
if ( (bob= LP_coinfind(rel)) != 0 && (bob->isassetchain != 0 || strcmp(bob->symbol,"KMD") == 0) )
sp->bobneeds_dPoW = 1;
}
strcpy(sp->bobgui,"nogui");

8
iguana/exchanges/LP_utxo.c

@ -495,13 +495,13 @@ struct LP_address *LP_address_utxo_reset(struct iguana_info *coin)
cJSON *LP_address_item(struct iguana_info *coin,struct LP_address_utxo *up,int32_t electrumret)
{
cJSON *item = cJSON_CreateObject();
int32_t notarized; cJSON *item = cJSON_CreateObject();
if ( electrumret == 0 )
{
jaddbits256(item,"txid",up->U.txid);
jaddnum(item,"vout",up->U.vout);
if ( up->U.height > 0 )
jaddnum(item,"confirmations",LP_getheight(coin) - up->U.height + 1);
jaddnum(item,"confirmations",LP_getheight(&notarized,coin) - up->U.height + 1);
jaddnum(item,"amount",dstr(up->U.value));
jaddstr(item,"scriptPubKey","");
}
@ -802,7 +802,7 @@ int32_t LP_txheight(struct iguana_info *coin,bits256 txid)
int32_t LP_numconfirms(char *symbol,char *coinaddr,bits256 txid,int32_t vout,int32_t mempool)
{
struct iguana_info *coin; bits256 zero; int32_t ht,numconfirms = 100;
struct iguana_info *coin; bits256 zero; int32_t ht,notarized,numconfirms = 100;
cJSON *txobj;
if ( (coin= LP_coinfind(symbol)) == 0 || coin->inactive != 0 )
return(-1);
@ -827,7 +827,7 @@ int32_t LP_numconfirms(char *symbol,char *coinaddr,bits256 txid,int32_t vout,int
memset(zero.bytes,0,sizeof(zero));
LP_listunspent_issue(symbol,coinaddr,1,txid,zero);
if ( (ht= LP_txheight(coin,txid)) > 0 && ht <= coin->height )
numconfirms = (LP_getheight(coin) - ht + 1);
numconfirms = (LP_getheight(&notarized,coin) - ht + 1);
else if ( mempool != 0 )
{
if ( LP_waitmempool(symbol,coinaddr,txid,vout,30) >= 0 )

Loading…
Cancel
Save