Browse Source

Test

etomic
jl777 7 years ago
parent
commit
08db8aa6bc
  1. 4
      iguana/exchanges/LP_include.h
  2. 195
      iguana/exchanges/LP_instantdex.c
  3. 2
      iguana/exchanges/LP_nativeDEX.c
  4. 8
      iguana/exchanges/LP_rpc.c
  5. 24
      iguana/exchanges/LP_socket.c
  6. 75
      iguana/exchanges/LP_stats.c
  7. 10
      iguana/exchanges/LP_utxo.c
  8. 49
      iguana/m_notary
  9. 47
      iguana/m_notary_run

4
iguana/exchanges/LP_include.h

@ -403,7 +403,8 @@ struct LP_swapstats
bits256 bobdeposit,alicepayment,bobpayment,paymentspent,Apaymentspent,depositspent;
double qprice;
uint64_t aliceid;
uint32_t ind,methodind,finished,expired,lasttime;
int32_t bobneeds_dPoW,aliceneeds_dPoW,bob_dPoWheight,alice_dPoWheight;
uint32_t ind,methodind,finished,expired,lasttime,dPoWfinished;
char alicegui[32],bobgui[32];
};
@ -489,6 +490,7 @@ int32_t LP_crc32find(int32_t *duplicatep,int32_t ind,uint32_t crc32);
char *LP_pricepings(void *ctx,char *myipaddr,int32_t pubsock,char *base,char *rel,double price);
int32_t LP_merkleproof(struct iguana_info *coin,char *coinaddr,struct electrum_info *ep,bits256 txid,int32_t height);
cJSON *electrum_address_gethistory(char *symbol,struct electrum_info *ep,cJSON **retjsonp,char *addr,bits256 reftxid);
cJSON *LP_myzdebits();
int32_t _LP_utxos_remove(bits256 txid,int32_t vout);
int32_t LP_utxos_remove(bits256 txid,int32_t vout);
struct LP_transaction *LP_transactionadd(struct iguana_info *coin,bits256 txid,int32_t height,int32_t numvouts,int32_t numvins);

195
iguana/exchanges/LP_instantdex.c

@ -202,16 +202,74 @@ int64_t LP_claimtx(void *ctx,struct iguana_info *coin,bits256 *claimtxidp,bits25
return(sum);
}
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; int64_t weeksatoshis,satoshis; uint32_t expiration,claimtime;
if ( (txjson= LP_gettx(coin->symbol,utxotxid,1)) != 0 )
{
if ( (vouts= jarray(&numvouts,txjson,"vout")) != 0 && numvouts >= 3 )
{
vout0 = jitem(vouts,0);
LP_destaddr(vinaddr,vout0);
satoshis = LP_value_extract(vout0,1);
vout2 = jitem(vouts,2);
LP_destaddr(destaddr,vout2);
if ( strcmp(destaddr,coin->smartaddr) == 0 )
{
vout1 = jitem(vouts,1);
weeksatoshis = LP_value_extract(vout1,0);
weeki = (int32_t)(weeksatoshis % 10000);
for (j=28; j<=28; j++)
{
expiration = ((weeki * LP_WEEKMULT + j*3600) + LP_FIRSTWEEKTIME);
redeemlen = LP_deposit_addr(checkaddr,redeemscript,coin->taddr,coin->p2shtype,expiration,G.LP_pubsecp);
if ( strcmp(checkaddr,vinaddr) == 0 )
{
claimtime = (uint32_t)time(NULL)-777;
item = cJSON_CreateObject();
jaddbits256(item,"txid",utxotxid);
jaddnum(item,"deposit",dstr(LP_value_extract(vout0,0)));
if ( coin->electrum == 0 )
jaddnum(item,"interest",dstr(satoshis)-dstr(LP_value_extract(vout0,0)));
else jaddnum(item,"interest",dstr(LP_komodo_interest(utxotxid,satoshis)));
if ( claimtime <= expiration )
{
printf("claimtime.%u vs %u, wait %d seconds to %s claim %.8f\n",claimtime,expiration,(int32_t)expiration-claimtime,bits256_str(str,utxotxid),dstr(satoshis));
jaddnum(item,"waittime",(int32_t)expiration-claimtime);
jaddi(txids,item);
break;
}
else
{
utxovout = 0;
*sump += LP_claimtx(ctx,coin,&claimtxid,utxotxid,utxovout,satoshis,vinaddr,claimtime,redeemscript,redeemlen);
if ( bits256_nonz(claimtxid) != 0 )
{
flagi = 1;
jaddbits256(item,"claimtxid",claimtxid);
jaddi(txids,item);
}
}
} else printf("expiration.%u j.%d checkaddr.(%s) != vinaddr.%s\n",expiration,j,checkaddr,vinaddr);
if ( flagi != 0 )
break;
}
} else printf("vout2 dest.(%s) != %s\n",destaddr,coin->smartaddr);
} else printf("numvouts %d != 3\n",numvouts);
free_json(txjson);
} else printf("cant get transaction\n");
return(flagi);
}
char *LP_instantdex_claim(struct iguana_info *coin)
{
static void *ctx;
uint8_t redeemscript[512]; char vinaddr[64],checkaddr[64],destaddr[64],str[65]; uint32_t now,redeemlen,claimtime,expiration=0; int32_t i,j,n,flagi,flag,weeki,numvouts,utxovout; bits256 utxotxid,claimtxid; int64_t sum,satoshis,weeksatoshis; cJSON *array,*txids,*retjson,*newarray,*txjson,*vouts,*vout0,*vout1,*vout2,*item;
int32_t i,n; cJSON *array,*txids,*newarray,*retjson; int64_t sum; bits256 utxotxid;
printf("inside instantdex claim\n");
if ( ctx == 0 )
ctx = bitcoin_ctx();
if ( strcmp(coin->symbol,"KMD") != 0 )
return(clonestr("{\"error\":\"instantdex deposit must be in KMD\"}"));
now = (uint32_t)time(NULL);
sum = 0;
txids = cJSON_CreateArray();
newarray = cJSON_CreateArray();
@ -220,71 +278,11 @@ char *LP_instantdex_claim(struct iguana_info *coin)
printf("claiming from.(%s)\n",jprint(array,0));
if ( (n= cJSON_GetArraySize(array)) > 0 )
{
flag = 0;
for (i=0; i<n; i++)
{
utxotxid = jbits256i(array,i);
//printf("%d of %d: %s\n",i,n,bits256_str(str,utxotxid));
if ( flag == 1 )
{
jaddibits256(newarray,utxotxid);
continue;
}
flagi = 0;
utxovout = 0;
// make into function, and separate calling path by txid
if ( (txjson= LP_gettx(coin->symbol,utxotxid,1)) != 0 )
{
if ( (vouts= jarray(&numvouts,txjson,"vout")) != 0 && numvouts == 3 )
{
vout0 = jitem(vouts,0);
LP_destaddr(vinaddr,vout0);
satoshis = LP_value_extract(vout0,1);
vout2 = jitem(vouts,2);
LP_destaddr(destaddr,vout2);
if ( strcmp(destaddr,coin->smartaddr) == 0 )
{
vout1 = jitem(vouts,1);
weeksatoshis = LP_value_extract(vout1,0);
weeki = (int32_t)(weeksatoshis % 10000);
for (j=28; j<=28; j++)
{
expiration = ((weeki * LP_WEEKMULT + j*3600) + LP_FIRSTWEEKTIME);
redeemlen = LP_deposit_addr(checkaddr,redeemscript,coin->taddr,coin->p2shtype,expiration,G.LP_pubsecp);
if ( strcmp(checkaddr,vinaddr) == 0 )
{
claimtime = (uint32_t)time(NULL)-777;
item = cJSON_CreateObject();
jaddbits256(item,"txid",utxotxid);
jaddnum(item,"deposit",dstr(LP_value_extract(vout0,0)));
if ( coin->electrum == 0 )
jaddnum(item,"interest",dstr(satoshis)-dstr(LP_value_extract(vout0,0)));
else jaddnum(item,"interest",dstr(LP_komodo_interest(utxotxid,satoshis)));
if ( claimtime <= expiration )
{
printf("claimtime.%u vs %u, wait %d seconds to %s claim %.8f\n",claimtime,expiration,(int32_t)expiration-claimtime,bits256_str(str,utxotxid),dstr(satoshis));
jaddnum(item,"waittime",(int32_t)expiration-claimtime);
jaddi(txids,item);
break;
}
else
{
flagi = 1;
sum += LP_claimtx(ctx,coin,&claimtxid,utxotxid,utxovout,satoshis,vinaddr,claimtime,redeemscript,redeemlen);
jaddbits256(item,"claimtxid",claimtxid);
jaddi(txids,item);
}
} else printf("expiration.%u j.%d checkaddr.(%s) != vinaddr.%s\n",expiration,j,checkaddr,vinaddr);
if ( flagi != 0 )
break;
}
} else printf("vout2 dest.(%s) != %s\n",destaddr,coin->smartaddr);
} else printf("numvouts %d != 3\n",numvouts);
free_json(txjson);
} else printf("cant get transaction\n");
if ( flagi == 0 )
if ( LP_claim_submit(ctx,txids,&sum,coin,utxotxid) == 0 )
jaddibits256(newarray,utxotxid);
else flag++;
}
}
free_json(array);
@ -395,12 +393,12 @@ int64_t LP_dynamictrust(bits256 pubkey,int64_t kmdvalue)
{
DL_FOREACH_SAFE(pubp->bobswaps,ptr,tmp)
{
if ( (sp= ptr->swap) != 0 && sp->finished == 0 && sp->expired == 0 )
if ( (sp= ptr->swap) != 0 && LP_swap_finished(sp,1) == 0 )
swaps_kmdvalue += LP_kmdvalue(sp->Q.srccoin,sp->Q.satoshis);
}
DL_FOREACH_SAFE(pubp->aliceswaps,ptr,tmp)
{
if ( (sp= ptr->swap) != 0 && sp->finished == 0 && sp->expired == 0 )
if ( (sp= ptr->swap) != 0 && LP_swap_finished(sp,1) == 0 )
swaps_kmdvalue += LP_kmdvalue(sp->Q.destcoin,sp->Q.destsatoshis);
}
if ( ap->instantdex_credits != 0 && (swaps_kmdvalue+kmdvalue) > ap->instantdex_credits )
@ -446,3 +444,70 @@ int64_t LP_myzcredits()
}
return(0);
}
cJSON *LP_swapstats_item(struct LP_swapstats *sp,int32_t iambob)
{
cJSON *item = cJSON_CreateObject();
jaddnum(item,"iambob",iambob);
jaddnum(item,"aliceid",sp->aliceid);
jaddnum(item,"requestid",sp->Q.R.requestid);
jaddnum(item,"quoteid",sp->Q.R.quoteid);
jaddstr(item,"base",sp->Q.srccoin);
jaddnum(item,"satoshis",sp->Q.satoshis);
jaddstr(item,"rel",sp->Q.destcoin);
jaddnum(item,"destsatoshis",sp->Q.destsatoshis);
jaddnum(item,"price",sp->Q.destsatoshis/((double)sp->Q.satoshis+1));
if ( LP_swap_finished(sp,1) == 0 )
{
jaddnum(item,"finished",sp->finished);
if ( sp->bobneeds_dPoW != 0 )
{
jaddnum(item,"bobneeds_dPoW",sp->bobneeds_dPoW);
jaddnum(item,"bobdPoW_height",sp->bob_dPoWheight);
}
if ( sp->aliceneeds_dPoW != 0 )
{
jaddnum(item,"aliceneeds_dPoW",sp->aliceneeds_dPoW);
jaddnum(item,"alicedPoW_height",sp->alice_dPoWheight);
}
}
return(item);
}
cJSON *LP_myzdebits()
{
struct LP_pubswap *ptr,*tmp; struct LP_pubkey_info *pubp; struct LP_swapstats *sp; int64_t kmdvalue,swaps_kmdvalue = 0; struct iguana_info *coin; cJSON *retjson,*array,*item;
array = cJSON_CreateArray();
if ( (coin= LP_coinfind("KMD")) != 0 )
{
if ( (pubp= LP_pubkeyfind(G.LP_mypub25519)) != 0 )
{
DL_FOREACH_SAFE(pubp->bobswaps,ptr,tmp)
{
if ( (sp= ptr->swap) != 0 && LP_swap_finished(sp,1) == 0 )
{
kmdvalue = LP_kmdvalue(sp->Q.srccoin,sp->Q.satoshis);
item = LP_swapstats_item(sp,1);
jaddnum(item,"kmdvalue",dstr(kmdvalue));
jaddi(array,item);
swaps_kmdvalue += kmdvalue;
}
}
DL_FOREACH_SAFE(pubp->aliceswaps,ptr,tmp)
{
if ( (sp= ptr->swap) != 0 && LP_swap_finished(sp,1) == 0 )
{
kmdvalue = LP_kmdvalue(sp->Q.destcoin,sp->Q.destsatoshis);
item = LP_swapstats_item(sp,0);
jaddnum(item,"kmdvalue",dstr(kmdvalue));
jaddi(array,item);
swaps_kmdvalue += kmdvalue;
}
}
}
}
retjson = cJSON_CreateObject();
jaddstr(retjson,"result","success");
jadd(retjson,"swaps",array);
jaddnum(retjson,"pendingswaps",dstr(swaps_kmdvalue));
}

2
iguana/exchanges/LP_nativeDEX.c

@ -571,7 +571,7 @@ void LP_coinsloop(void *_coins)
nonz++;
printf("SPV failure for %s %s\n",coin->symbol,bits256_str(str,up->U.txid));
oldht = up->U.height;
LP_txheight_check(coin,ap->coinaddr,up);
LP_txheight_check(coin,ap->coinaddr,up->U.txid);
if ( oldht != up->U.height )
up->SPV = LP_merkleproof(coin,coin->smartaddr,backupep,up->U.txid,up->U.height);
if ( up->SPV <= 0 )

8
iguana/exchanges/LP_rpc.c

@ -157,7 +157,7 @@ cJSON *LP_paxprice(char *fiat)
cJSON *LP_gettx(char *symbol,bits256 txid,int32_t suppress_errors)
{
struct iguana_info *coin; char buf[512],str[65]; cJSON *retjson;
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));
if ( symbol == 0 || symbol[0] == 0 )
return(cJSON_Parse("{\"error\":\"null symbol\"}"));
@ -174,7 +174,7 @@ cJSON *LP_gettx(char *symbol,bits256 txid,int32_t suppress_errors)
}
else
{
if ( (retjson= electrum_transaction(symbol,coin->electrum,&retjson,txid,0)) != 0 )
if ( (retjson= electrum_transaction(&height,symbol,coin->electrum,&retjson,txid,0)) != 0 )
return(retjson);
else if ( suppress_errors == 0 )
printf("failed blockchain.transaction.get %s %s\n",coin->symbol,bits256_str(str,txid));
@ -214,7 +214,7 @@ cJSON *LP_gettxout_json(bits256 txid,int32_t vout,int32_t height,char *coinaddr,
cJSON *LP_gettxout(char *symbol,char *coinaddr,bits256 txid,int32_t vout)
{
char buf[128],str[65]; cJSON *item,*array,*vouts,*txobj,*retjson=0; int32_t i,v,n; bits256 t,zero; struct iguana_info *coin; struct LP_transaction *tx; struct LP_address_utxo *up;
char buf[128],str[65]; cJSON *item,*array,*vouts,*txobj,*retjson=0; int32_t i,v,height,n; bits256 t,zero; struct iguana_info *coin; struct LP_transaction *tx; struct LP_address_utxo *up;
if ( symbol == 0 || symbol[0] == 0 )
return(cJSON_Parse("{\"error\":\"null symbol\"}"));
if ( (coin= LP_coinfind(symbol)) == 0 )
@ -236,7 +236,7 @@ cJSON *LP_gettxout(char *symbol,char *coinaddr,bits256 txid,int32_t vout)
}
if ( coinaddr[0] == 0 )
{
if ( (txobj= electrum_transaction(symbol,coin->electrum,&txobj,txid,0)) != 0 )
if ( (txobj= electrum_transaction(&height,symbol,coin->electrum,&txobj,txid,0)) != 0 )
{
if ( (vouts= jarray(&n,txobj,"vout")) != 0 && n > 0 )
LP_destaddr(coinaddr,jitem(vouts,vout));

24
iguana/exchanges/LP_socket.c

@ -558,12 +558,12 @@ cJSON *electrum_address_gethistory(char *symbol,struct electrum_info *ep,cJSON *
return(retjson);
}
int32_t LP_txheight_check(struct iguana_info *coin,char *coinaddr,struct LP_address_utxo *up)
int32_t LP_txheight_check(struct iguana_info *coin,char *coinaddr,bits256 txid)
{
cJSON *retjson;
if ( coin->electrum != 0 )
{
if ( (retjson= electrum_address_gethistory(coin->symbol,coin->electrum,&retjson,coinaddr,up->U.txid)) != 0 )
if ( (retjson= electrum_address_gethistory(coin->symbol,coin->electrum,&retjson,coinaddr,txid)) != 0 )
free_json(retjson);
}
return(0);
@ -744,14 +744,15 @@ cJSON *_electrum_transaction(char *symbol,struct electrum_info *ep,cJSON **retjs
return(*retjsonp);
}
cJSON *electrum_transaction(char *symbol,struct electrum_info *ep,cJSON **retjsonp,bits256 txid,char *SPVcheck)
cJSON *electrum_transaction(int32_t *heightp,char *symbol,struct electrum_info *ep,cJSON **retjsonp,bits256 txid,char *SPVcheck)
{
cJSON *retjson,*array; bits256 zero; struct LP_transaction *tx; struct iguana_info *coin;
cJSON *retjson,*array; bits256 zero; struct LP_transaction *tx=0; struct iguana_info *coin;
coin = LP_coinfind(symbol);
*heightp = 0;
if ( ep != 0 )
portable_mutex_lock(&ep->txmutex);
retjson = _electrum_transaction(symbol,ep,retjsonp,txid);
if ( ep != 0 && coin != 0 && SPVcheck != 0 && SPVcheck[0] != 0 && (tx= LP_transactionfind(coin,txid)) != 0 )
if ( (tx= LP_transactionfind(coin,txid)) != 0 && ep != 0 && coin != 0 && SPVcheck != 0 && SPVcheck[0] != 0 )
{
if ( tx->height <= 0 )
{
@ -763,9 +764,14 @@ cJSON *electrum_transaction(char *symbol,struct electrum_info *ep,cJSON **retjso
}
}
if ( tx->height > 0 )
tx->SPV = LP_merkleproof(coin,SPVcheck,ep,txid,tx->height);
{
if ( tx->SPV == 0 )
tx->SPV = LP_merkleproof(coin,SPVcheck,ep,txid,tx->height);
*heightp = tx->height;
}
char str[65]; printf("%s %s %s SPV height %d SPV %d\n",coin->symbol,SPVcheck,bits256_str(str,txid),tx->height,tx->SPV);
}
} else if ( tx != 0 )
*heightp = tx->height;
if ( ep != 0 )
portable_mutex_unlock(&ep->txmutex);
return(retjson);
@ -782,7 +788,7 @@ cJSON *electrum_getmerkle(char *symbol,struct electrum_info *ep,cJSON **retjsonp
void electrum_test()
{
cJSON *retjson; bits256 hash,zero; struct electrum_info *ep = 0; char *addr,*script,*symbol = "BTC";
cJSON *retjson; int32_t height; bits256 hash,zero; struct electrum_info *ep = 0; char *addr,*script,*symbol = "BTC";
while ( Num_electrums == 0 )
{
sleep(1);
@ -808,7 +814,7 @@ void electrum_test()
decode_hex(hash.bytes,sizeof(hash),"b967a7d55889fe11e993430921574ec6379bc8ce712a652c3fcb66c6be6e925c");
if ( (retjson= electrum_getmerkle(symbol,ep,0,hash,403000)) != 0 )
printf("electrum_getmerkle %s\n",jprint(retjson,1));
if ( (retjson= electrum_transaction(symbol,ep,0,hash,0)) != 0 )
if ( (retjson= electrum_transaction(&height,symbol,ep,0,hash,0)) != 0 )
printf("electrum_transaction %s\n",jprint(retjson,1));
addr = "14NeevLME8UAANiTCVNgvDrynUPk1VcQKb";
if ( (retjson= electrum_address_gethistory(symbol,ep,0,addr,zero)) != 0 )

75
iguana/exchanges/LP_stats.c

@ -208,10 +208,72 @@ int32_t LP_swapstats_update(struct LP_swapstats *sp,struct LP_quoteinfo *qp,cJSO
return(0);
}
int32_t LP_dPoWheight(struct iguana_info *coin) // get dPoW protected height
{
}
int32_t LP_finished_lastheight(struct LP_swapstats *sp,int32_t iambob)
{
int32_t ht,height = 1; struct iguana_info *coin;
if ( (coin= LP_coinfind(iambob != 0 ? sp->Q.srccoin : sp->Q.destcoin)) != 0 )
{
if ( iambob != 0 )
{
if ( bits256_nonz(sp->bobdeposit) != 0 && (ht= LP_txheight(coin,sp->bobdeposit)) > 1 && ht > height )
height = ht;
if ( bits256_nonz(sp->bobpayment) != 0 && (ht= LP_txheight(coin,sp->bobpayment)) > 1 && ht > height )
height = ht;
if ( bits256_nonz(sp->paymentspent) != 0 && (ht= LP_txheight(coin,sp->paymentspent)) > 1 && ht > height )
height = ht;
if ( bits256_nonz(sp->depositspent) != 0 && (ht= LP_txheight(coin,sp->depositspent)) > 1 && ht > height )
height = ht;
}
else
{
if ( bits256_nonz(sp->alicepayment) != 0 && (ht= LP_txheight(coin,sp->alicepayment)) > 1 && ht > height )
height = ht;
if ( bits256_nonz(sp->Apaymentspent) != 0 && (ht= LP_txheight(coin,sp->Apaymentspent)) > 1 && ht > height )
height = ht;
}
}
return(height);
}
int32_t LP_swap_finished(struct LP_swapstats *sp,int32_t dPoWflag)
{
struct iguana_info *bob,*alice;
bob = LP_coinfind(sp->Q.srccoin);
alice = LP_coinfind(sp->Q.destcoin);
if ( sp->finished == 0 )
{
if ( sp->expired != 0 )
return(1);
if ( dPoWflag != 0 )
{
if ( sp->finished != 0 && sp->dPoWfinished != 0 )
return(1);
else if ( sp->finished != 0 )
{
sp->bob_dPoWheight = LP_dPoWheight(bob);
sp->alice_dPoWheight = LP_dPoWheight(alice);
if ( bob->isassetchain != 0 )
sp->bobneeds_dPoW = LP_finished_lastheight(sp,1);
if ( alice->isassetchain != 0 )
sp->aliceneeds_dPoW = LP_finished_lastheight(sp,0);
printf("bob needs %d @ %d, alice needs %d @ %d\n",sp->bobneeds_dPoW,sp->bob_dPoWheight,sp->aliceneeds_dPoW,sp->alice_dPoWheight);
}
if ( (sp->bobneeds_dPoW == 0 || (sp->bobneeds_dPoW > 1 && sp->bob_dPoWheight >= sp->bobneeds_dPoW)) && (sp->aliceneeds_dPoW == 0 || (sp->aliceneeds_dPoW > 1 && sp->alice_dPoWheight >= sp->aliceneeds_dPoW)) )
return(1);
}
}
return(0);
}
int32_t LP_statslog_parsequote(char *method,cJSON *lineobj)
{
static uint32_t unexpected;
struct LP_swapstats *sp,*tmp; struct LP_pubkey_info *pubp; struct LP_pubswap *ptr; double qprice; uint32_t requestid,quoteid,timestamp; int32_t i,RTflag,flag,numtrades[LP_MAXPRICEINFOS],methodind,destvout,feevout,duplicate=0; char *statusstr,*gui,*base,*rel; uint64_t aliceid,txfee,satoshis,destsatoshis; bits256 desttxid,feetxid; struct LP_quoteinfo Q; uint64_t basevols[LP_MAXPRICEINFOS],relvols[LP_MAXPRICEINFOS];
struct LP_swapstats *sp,*tmp; struct iguana_info *alice,*bob; struct LP_pubkey_info *pubp; struct LP_pubswap *ptr; double qprice; uint32_t requestid,quoteid,timestamp; int32_t i,RTflag,flag,numtrades[LP_MAXPRICEINFOS],methodind,destvout,feevout,duplicate=0; char *statusstr,*gui,*base,*rel; uint64_t aliceid,txfee,satoshis,destsatoshis; bits256 desttxid,feetxid; struct LP_quoteinfo Q; uint64_t basevols[LP_MAXPRICEINFOS],relvols[LP_MAXPRICEINFOS];
memset(numtrades,0,sizeof(numtrades));
memset(basevols,0,sizeof(basevols));
memset(relvols,0,sizeof(relvols));
@ -314,9 +376,18 @@ int32_t LP_statslog_parsequote(char *method,cJSON *lineobj)
sp->methodind = methodind;
sp->ind = LP_aliceids++;
sp->lasttime = (uint32_t)time(NULL);
if ( sp->lasttime > sp->Q.timestamp+LP_atomic_locktime(base,rel)*2)
sp->expired = sp->lasttime;
else
{
if ( (alice= LP_coinfind(rel)) && alice->isassetchain != 0 )
sp->aliceneeds_dPoW = 1;
if ( (bob= LP_coinfind(rel)) && bob->isassetchain != 0 )
sp->bobneeds_dPoW = 1;
}
strcpy(sp->bobgui,"nogui");
strcpy(sp->alicegui,"nogui");
if ( sp->finished == 0 && sp->expired == 0 )
if ( LP_swap_finished(sp,1) == 0 ) //sp->finished == 0 && sp->expired == 0 )
{
if ( (pubp= LP_pubkeyadd(sp->Q.srchash)) != 0 )
{

10
iguana/exchanges/LP_utxo.c

@ -620,7 +620,10 @@ cJSON *LP_address_balance(struct iguana_info *coin,char *coinaddr,int32_t electr
jaddstr(retjson,"address",coinaddr);
jaddnum(retjson,"balance",dstr(balance));
if ( strcmp(coin->symbol,"KMD") == 0 && strcmp(coin->smartaddr,coinaddr) == 0 )
{
jaddnum(retjson,"zcredits",dstr(LP_myzcredits()));
jadd(retjson,"zdebits",LP_myzdebits());
}
return(retjson);
}
@ -763,7 +766,7 @@ 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,*txobj; int32_t height = 0;
bits256 blockhash; struct LP_transaction *tx; cJSON *blockobj,*retjson,*txobj; int32_t height = 0;
if ( coin == 0 )
return(-1);
if ( coin->electrum == 0 )
@ -788,6 +791,11 @@ int32_t LP_txheight(struct iguana_info *coin,bits256 txid)
{
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 )
free_json(retjson);
}
}
return(height);
}

49
iguana/m_notary

@ -2,51 +2,4 @@
pkill -15 iguana
rm -f ../agents/iguana *.o
git pull
cd secp256k1; ./m_unix; cd ..
cd ../crypto777; ./m_LP; cd ../iguana
#gcc -g -fno-aggressive-loop-optimizations -Wno-deprecated -c -O2 -DISNOTARYNODE=1 -DLIQUIDITY_PROVIDER=1 *.c ../basilisk/basilisk.c ../gecko/gecko.c ../datachain/datachain.c
clang -g -Wno-deprecated -c -O2 -DISNOTARYNODE=1 -DLIQUIDITY_PROVIDER=1 *.c ../basilisk/basilisk.c ../gecko/gecko.c ../datachain/datachain.c
#gcc -g -fno-aggressive-loop-optimizations -Wno-deprecated -c -DISNOTARYNODE=1 -DLIQUIDITY_PROVIDER=1 main.c iguana777.c iguana_bundles.c ../basilisk/basilisk.c
clang -g -Wno-deprecated -c -DISNOTARYNODE=1 -DLIQUIDITY_PROVIDER=1 main.c iguana777.c iguana_bundles.c ../basilisk/basilisk.c
clang -g -o ../agents/iguana *.o ../agents/libcrypto777.a -lnanomsg -lcurl -lssl -lcrypto -lpthread -lz -lm
../agents/iguana notary & #> iguana.log 2> error.log &
myip=`curl -s4 checkip.amazonaws.com`
source pubkey.txt
sleep 4
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"SuperNET\",\"method\":\"myipaddr\",\"ipaddr\":\"$myip\"}"
sleep 3
tests/addnotarys_7776
coins/btc_7776
coins/ltc_7776
coins/kmd_7776
coins/chips_7776
./wp_7776
coins/revs_7776
coins/supernet_7776
coins/dex_7776
coins/bet_7776
coins/bots_7776
coins/hodl_7776
coins/shark_7776
coins/mshark_7776
coins/jumblr_7776
coins/crypto_7776
coins/pangea_7776
coins/mgw_7776
#coins/mvp_7776
coins/coqui_7776
coins/wlc_7776
coins/kv_7776
coins/ceal_7776
coins/mesh_7776
coins/mnz_7776
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"passthru\",\"method\":\"paxfiats\",\"timeout\":900000}"
#curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnotary\",\"ipaddr\":\"$myip\"}"
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"KMD\",\"pubkey\":\"$pubkey\"}"
sleep 17
./m_notary_run

47
iguana/m_notary_run

@ -0,0 +1,47 @@
#!/bin/bash
cd secp256k1; ./m_unix; cd ..
cd ../crypto777; ./m_LP; cd ../iguana
#gcc -g -fno-aggressive-loop-optimizations -Wno-deprecated -c -O2 -DISNOTARYNODE=1 -DLIQUIDITY_PROVIDER=1 *.c ../basilisk/basilisk.c ../gecko/gecko.c ../datachain/datachain.c
clang -g -Wno-deprecated -c -O2 -DISNOTARYNODE=1 -DLIQUIDITY_PROVIDER=1 *.c ../basilisk/basilisk.c ../gecko/gecko.c ../datachain/datachain.c
#gcc -g -fno-aggressive-loop-optimizations -Wno-deprecated -c -DISNOTARYNODE=1 -DLIQUIDITY_PROVIDER=1 main.c iguana777.c iguana_bundles.c ../basilisk/basilisk.c
clang -g -Wno-deprecated -c -DISNOTARYNODE=1 -DLIQUIDITY_PROVIDER=1 main.c iguana777.c iguana_bundles.c ../basilisk/basilisk.c
clang -g -o ../agents/iguana *.o ../agents/libcrypto777.a -lnanomsg -lcurl -lssl -lcrypto -lpthread -lz -lm
../agents/iguana notary & #> iguana.log 2> error.log &
myip=`curl -s4 checkip.amazonaws.com`
source pubkey.txt
sleep 4
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"SuperNET\",\"method\":\"myipaddr\",\"ipaddr\":\"$myip\"}"
sleep 3
tests/addnotarys_7776
coins/btc_7776
coins/ltc_7776
coins/kmd_7776
coins/chips_7776
./wp_7776
coins/revs_7776
coins/supernet_7776
coins/dex_7776
coins/bet_7776
coins/bots_7776
coins/hodl_7776
coins/shark_7776
coins/mshark_7776
coins/jumblr_7776
coins/crypto_7776
coins/pangea_7776
coins/mgw_7776
coins/coqui_7776
coins/wlc_7776
coins/kv_7776
coins/ceal_7776
coins/mesh_7776
coins/mnz_7776
#curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"passthru\",\"method\":\"paxfiats\",\"timeout\":900000}"
#curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnotary\",\"ipaddr\":\"$myip\"}"
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"KMD\",\"pubkey\":\"$pubkey\"}"
Loading…
Cancel
Save