Browse Source

Test

etomic
jl777 7 years ago
parent
commit
ae7776d707
  1. 1
      iguana/exchanges/LP_include.h
  2. 4
      iguana/exchanges/LP_ordermatch.c
  3. 1
      iguana/exchanges/LP_prices.c
  4. 23
      iguana/exchanges/LP_statemachine.c
  5. 31
      iguana/exchanges/LP_zeroconf.c

1
iguana/exchanges/LP_include.h

@ -502,6 +502,7 @@ int32_t LP_gettx_presence(char *symbol,bits256 expectedtxid);
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);
int64_t LP_dynamictrust(bits256 pubkey,int64_t kmdvalue);
void LP_listunspent_query(char *symbol,char *coinaddr);
int32_t bitcoin_priv2wif(uint8_t wiftaddr,char *wifstr,bits256 privkey,uint8_t addrtype);

4
iguana/exchanges/LP_ordermatch.c

@ -454,7 +454,7 @@ int32_t LP_connectstartbob(void *ctx,int32_t pubsock,cJSON *argjson,char *base,c
printf("requestid.%u quoteid.%u is already in progres\n",qp->R.requestid,qp->R.quoteid);
return(-1);
}
if ( (swap= LP_swapinit(1,0,privkey,&qp->R,qp,LP_dynamictrust(qp->desthash,LP_kmdvalue(qp->destcoin,qp->destsatoshis)))) == 0 )
if ( (swap= LP_swapinit(1,0,privkey,&qp->R,qp,LP_dynamictrust(qp->desthash,LP_kmdvalue(qp->destcoin,qp->destsatoshis) > 0))) == 0 )
{
printf("cant initialize swap\n");
return(-1);
@ -626,7 +626,7 @@ char *LP_connectedalice(cJSON *argjson) // alice
if ( bits256_nonz(Q.privkey) != 0 )//&& Q.quotetime >= Q.timestamp-3 )
{
retjson = cJSON_CreateObject();
if ( (swap= LP_swapinit(0,0,Q.privkey,&Q.R,&Q,LP_dynamictrust(Q.srchash,LP_kmdvalue(Q.srccoin,Q.satoshis)))) == 0 )
if ( (swap= LP_swapinit(0,0,Q.privkey,&Q.R,&Q,LP_dynamictrust(Q.srchash,LP_kmdvalue(Q.srccoin,Q.satoshis) > 0))) == 0 )
{
jaddstr(retjson,"error","couldnt swapinit");
LP_availableset(Q.desttxid,Q.vout);

1
iguana/exchanges/LP_prices.c

@ -750,6 +750,7 @@ cJSON *LP_orderbookjson(char *symbol,struct LP_orderbookentry *op)
jaddnum(item,"depth",dstr(op->depth)*0.8);
jaddbits256(item,"pubkey",op->pubkey);
jaddnum(item,"age",time(NULL)-op->timestamp);
jaddnum(item,"netcredits",dstr(LP_dynamictrust(op->pubkey,0));
}
return(item);
}

23
iguana/exchanges/LP_statemachine.c

@ -3039,6 +3039,29 @@ if ( (0) )
#undef aptr
#undef bptr
}*/
/*if ( (sobj= jobj(v,"scriptPubKey")) != 0 )
{
if ( (scriptstr= jstr(sobj,"hex")) != 0 )
{
printf("amount64 %.8f vout.%d (%s) weeki.%d %.8f (%s)\n",dstr(amount64),vout,jprint(v,0),weeki,dstr(satoshis),scriptstr);
len = (int32_t)strlen(scriptstr) >> 1;
if ( len <= sizeof(spendscript)/sizeof(*spendscript) )
{
decode_hex(spendscript,len,scriptstr);
if ( spendscript[11] == 33 )
{
pub33 = &spendscript[12];
redeemlen = LP_deposit_addr(p2shaddr,redeemscript,coin->taddr,coin->p2shtype,timestamp,pub33);
if ( len == redeemlen && (timestamp % LP_WEEKMULT) == 0 )
{
bitcoin_address(coinaddr,coin->taddr,coin->pubtype,pub33,33);
printf("%s -> matched %s script t.%u weeki.%d deposit %.8f\n",coinaddr,p2shaddr,timestamp,(timestamp-LP_FIRSTWEEKTIME)/LP_WEEKMULT,dstr(satoshis));
// add to pubp->credits;
}
}
}
}
}*/
/*portable_mutex_lock(&ep->pendingQ.mutex);
if ( ep->pendingQ.list != 0 )

31
iguana/exchanges/LP_zeroconf.c

@ -62,7 +62,7 @@ char *LP_zeroconf_deposit(struct iguana_info *coin,int32_t weeks,double amount,i
jaddnum(item,coin->smartaddr,0.0001);
jaddi(array,item);
jadd(argjson,"outputs",array);
printf("deposit.(%s)\n",jprint(argjson,0));
//printf("deposit.(%s)\n",jprint(argjson,0));
if ( (retstr= LP_withdraw(coin,argjson)) != 0 )
{
if ( (retjson= cJSON_Parse(retstr)) != 0 )
@ -196,7 +196,7 @@ void LP_zeroconf_credit(char *coinaddr,uint64_t satoshis,int32_t weeki,char *p2s
if ( coin != 0 )
{
timestamp = LP_FIRSTWEEKTIME + weeki*LP_WEEKMULT;
if ( (ap= LP_address(coin,coinaddr)) != 0 )
if ( time(NULL) < timestamp-24*3600 && (ap= LP_address(coin,coinaddr)) != 0 )
{
ap->zeroconf_credits += satoshis;
printf("ZEROCONF credit.(%s) %.8f weeki.%d (%s) -> sum %.8f\n",coinaddr,dstr(satoshis),weeki,p2shaddr,dstr(ap->zeroconf_credits));
@ -232,29 +232,6 @@ void LP_zeroconf_deposits(struct iguana_info *coin)
else free_json(txobj);
LP_zeroconf_credit(destaddr,satoshis,weeki,p2shaddr);
}
/*if ( (sobj= jobj(v,"scriptPubKey")) != 0 )
{
if ( (scriptstr= jstr(sobj,"hex")) != 0 )
{
printf("amount64 %.8f vout.%d (%s) weeki.%d %.8f (%s)\n",dstr(amount64),vout,jprint(v,0),weeki,dstr(satoshis),scriptstr);
len = (int32_t)strlen(scriptstr) >> 1;
if ( len <= sizeof(spendscript)/sizeof(*spendscript) )
{
decode_hex(spendscript,len,scriptstr);
if ( spendscript[11] == 33 )
{
pub33 = &spendscript[12];
redeemlen = LP_deposit_addr(p2shaddr,redeemscript,coin->taddr,coin->p2shtype,timestamp,pub33);
if ( len == redeemlen && (timestamp % LP_WEEKMULT) == 0 )
{
bitcoin_address(coinaddr,coin->taddr,coin->pubtype,pub33,33);
printf("%s -> matched %s script t.%u weeki.%d deposit %.8f\n",coinaddr,p2shaddr,timestamp,(timestamp-LP_FIRSTWEEKTIME)/LP_WEEKMULT,dstr(satoshis));
// add to pubp->credits;
}
}
}
}
}*/
}
}
}
@ -264,7 +241,7 @@ void LP_zeroconf_deposits(struct iguana_info *coin)
}
}
int32_t LP_dynamictrust(bits256 pubkey,int64_t kmdvalue)
int64_t LP_dynamictrust(bits256 pubkey,int64_t kmdvalue)
{
struct LP_pubswap *ptr,*tmp; struct LP_swapstats *sp; struct LP_pubkey_info *pubp; struct LP_address *ap; char coinaddr[64]; struct iguana_info *coin; int64_t swaps_kmdvalue = 0;
if ( (coin= LP_coinfind("KMD")) != 0 && (pubp= LP_pubkeyfind(pubkey)) != 0 )
@ -283,7 +260,7 @@ int32_t LP_dynamictrust(bits256 pubkey,int64_t kmdvalue)
}
printf("credits %.8f vs (%.8f + current %.8f)\n",dstr(ap->zeroconf_credits),dstr(swaps_kmdvalue),dstr(kmdvalue));
if ( ap->zeroconf_credits > swaps_kmdvalue+kmdvalue )
return(1);
return(ap->zeroconf_credits - (swaps_kmdvalue+kmdvalue));
}
}
return(0);

Loading…
Cancel
Save