Browse Source

Merge pull request #492 from jl777/spvdex

bugfixes
etomic
jl777 7 years ago
committed by GitHub
parent
commit
23a9a0dff0
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 17
      iguana/exchanges/LP_nativeDEX.c
  2. 32
      iguana/exchanges/LP_remember.c
  3. 3
      iguana/exchanges/LP_signatures.c
  4. 4
      iguana/exchanges/LP_zeroconf.c
  5. 2
      iguana/exchanges/install

17
iguana/exchanges/LP_nativeDEX.c

@ -18,16 +18,13 @@
// marketmaker
//
// feature requests:
// electrum memleak?
// alice waiting for bestprice
// USD paxprice based USDvalue in portfolio
// cancel bid/ask
// https://github.com/bitcoin/bips/blob/master/bip-0143.mediawiki for signing BCH/BTG
//
// bugs, validations:
// waiting for alice and alice disconnects, can find bobpayment based on Q.txid
// portfolio value based on ask?
// disable basilisk
// verify encrypted destpubkey, broadcast:0 setprice
// improve critical section detection when parallel trades
@ -1047,6 +1044,20 @@ void LPinit(uint16_t myport,uint16_t mypullport,uint16_t mypubport,uint16_t mybu
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);
}
if ( 0 )
{
char *p2sh = "bJVtQF2o8B6sdNjeXupzNw5rnidJUNwPJD",p2shaddr[64]; uint8_t script[512],pub33[33]; uint32_t timestamp;
decode_hex(pub33,33,"03fe754763c176e1339a3f62ee6b9484720e17ee4646b65a119e9f6370c7004abc");
for (timestamp=1510934803-3600*24; timestamp<1510934803+3600*24; timestamp++)
{
LP_deposit_addr(p2shaddr,script,0,85,timestamp,pub33);
if ( strcmp(p2shaddr,p2sh) == 0 )
{
printf("matched timestamp.%u\n",timestamp);
break;
} else printf("%s ",p2shaddr);
}
}
LP_showwif = juint(argjson,"wif");
if ( passphrase == 0 || passphrase[0] == 0 )
{

32
iguana/exchanges/LP_remember.c

@ -255,13 +255,35 @@ bits256 basilisk_swap_privBn_extract(bits256 *bobrefundp,char *bobcoin,bits256 b
bits256 basilisk_swap_spendupdate(int32_t iambob,char *symbol,char *spentaddr,int32_t *sentflags,bits256 *txids,int32_t utxoind,int32_t alicespent,int32_t bobspent,int32_t vout,char *aliceaddr,char *bobaddr,char *Adest,char *dest)
{
bits256 spendtxid,txid; char destaddr[64],str[65]; struct iguana_info *coin; cJSON *histobj;
bits256 spendtxid,txid; char destaddr[64],str[65]; int32_t i,n,m; struct iguana_info *coin; cJSON *array,*txobj,*vins,*vin;
if ( (coin= LP_coinfind(symbol)) != 0 && coin->electrum != 0 )
{
if ( (histobj= electrum_address_gethistory(symbol,coin->electrum,&histobj,spentaddr)) != 0 )
//printf("spentaddr.%s aliceaddr.%s bobaddr.%s Adest.%s Bdest.%s\n",spentaddr,aliceaddr,bobaddr,Adest,dest);
if ( (array= electrum_address_gethistory(symbol,coin->electrum,&array,spentaddr)) != 0 )
{
//printf("processed history.(%s)\n",jprint(histobj,0));
free_json(histobj);
if ( (n= cJSON_GetArraySize(array)) > 0 )
{
for (i=0; i<n; i++)
{
txid = jbits256(jitem(array,i),"tx_hash");
//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)) != 0 )
{
//printf("txobj.(%s)\n",jprint(txobj,0));
if ( (vins= jarray(&m,txobj,"vin")) != 0 )
{
vin = jitem(vins,0);
//printf("vin0.(%s)\n",jprint(vin,0));
}
free_json(txobj);
}
}
}
}
//printf("processed history.(%s) %s\n",jprint(array,0),bits256_str(str,txids[utxoind]));
free_json(array);
}
}
txid = txids[utxoind];
@ -305,7 +327,7 @@ bits256 basilisk_swap_spendupdate(int32_t iambob,char *symbol,char *spentaddr,in
}
}
} //else printf("no spend of %s/v%d detected\n",bits256_str(str,txid),vout);
} else printf("utxoind.%d null txid\n",utxoind);
} //else printf("utxoind.%d null txid\n",utxoind);
return(spendtxid);
}

3
iguana/exchanges/LP_signatures.c

@ -714,7 +714,8 @@ void LP_query(void *ctx,char *myipaddr,int32_t mypubsock,char *method,struct LP_
flag = 1;
jaddbits256(reqjson,"pubkey",qp->srchash);
jaddstr(reqjson,"method",method);
jaddnum(reqjson,"timestamp",time(NULL));
if ( jobj(reqjson,"timestamp") == 0 )
jaddnum(reqjson,"timestamp",time(NULL));
msg = jprint(reqjson,1);
msg2 = clonestr(msg);
printf("QUERY.(%s)\n",msg);

4
iguana/exchanges/LP_zeroconf.c

@ -142,7 +142,7 @@ char *LP_zeroconf_claim(struct iguana_info *coin,char *depositaddr,uint32_t expi
redeemlen = LP_deposit_addr(vinaddr,redeemscript,coin->taddr,coin->p2shtype,timestamp,G.LP_pubsecp);
if ( strcmp(depositaddr,vinaddr) == 0 )
{
claimtime = (uint32_t)time(NULL)-777/2;
claimtime = (uint32_t)time(NULL)-777;
if ( claimtime <= timestamp )
{
printf("claimtime.%u vs locktime.%u, need to wait %d seconds\n",claimtime,timestamp,(int32_t)timestamp-claimtime);
@ -155,12 +155,14 @@ char *LP_zeroconf_claim(struct iguana_info *coin,char *depositaddr,uint32_t expi
userdata[0] = 0x51;
userdatalen = 1;
utxovout = 0;
//printf("unspents.(%s)\n",jprint(array,0));
if ( (n= cJSON_GetArraySize(array)) > 0 )
{
for (i=0; i<n; i++)
{
item = jitem(array,i);
satoshis = LP_listunspent_parseitem(coin,&utxotxid,&utxovout,&height,item);
printf("satoshis %.8f %s/v%d\n",dstr(satoshis),bits256_str(str,utxotxid),utxovout);
if ( (signedtx= basilisk_swap_bobtxspend(&signedtxid,10000,"zeroconfclaim",coin->symbol,coin->wiftaddr,coin->taddr,coin->pubtype,coin->p2shtype,coin->isPoS,coin->wiftype,ctx,G.LP_privkey,0,redeemscript,redeemlen,userdata,userdatalen,utxotxid,utxovout,coin->smartaddr,G.LP_pubsecp,0,claimtime,&destamount,0,0,vinaddr,1,coin->zcash)) != 0 )
{
printf("signedtx.(%s)\n",signedtx);

2
iguana/exchanges/install

@ -1,5 +1,5 @@
#!/bin/bash
cp tradesarray claim deposit invreset sendrawtransaction processfiles stop millis mnzservers bot_buy bot_list bot_statuslist bot_pause bot_resume bot_sell bot_settings bot_status bot_stop guistats pubkeystats pendings coinswaps baserelswaps setpassphrase notarizations getrawtransaction parselog statsdisp m_js trust trusted setconfirms balance listunspent electrum snapshot_balance snapshot_loop secretaddresses dividends snapshot goals goal portfolio autoprice deletemessages getmessages debug buy sell bestfit orderbook client run_osx client_osx run coins disable enable myprice myprices getcoins getpeers getpeersIP getprices help inv setprice status ../dexscripts
cp tradesarray claim deposit deposit1 invreset sendrawtransaction processfiles stop millis mnzservers bot_buy bot_list bot_statuslist bot_pause bot_resume bot_sell bot_settings bot_status bot_stop guistats pubkeystats pendings coinswaps baserelswaps setpassphrase notarizations getrawtransaction parselog statsdisp m_js trust trusted setconfirms balance listunspent electrum snapshot_balance snapshot_loop secretaddresses dividends snapshot goals goal portfolio autoprice deletemessages getmessages debug buy sell bestfit orderbook client run_osx client_osx run coins disable enable myprice myprices getcoins getpeers getpeersIP getprices help inv setprice status ../dexscripts
cp coins.json ..
cd ../dexscripts
#cp ../exchanges/passphrase ../exchanges/userpass .

Loading…
Cancel
Save