Browse Source

Merge pull request #534 from jl777/spvdex

support BCH for autoprice coinmarketcap and fix wif based passphrase
etomic
jl777 7 years ago
committed by GitHub
parent
commit
7a2ff4e40a
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      iguana/exchanges/LP_coins.c
  2. 5
      iguana/exchanges/LP_portfolio.c
  3. 12
      iguana/exchanges/LP_privkey.c
  4. 2
      iguana/exchanges/coins
  5. 5
      iguana/exchanges/coins.json

2
iguana/exchanges/LP_coins.c

@ -101,7 +101,7 @@ void LP_statefname(char *fname,char *symbol,char *assetname,char *str,char *name
{
#if defined(NATIVE_WINDOWS)
// need to do something with "confpath":"`${process.env.HOME}`/.muecore/mue.conf" under Windows
char *ht = "`${process.env.HOME}`", *ht_start, *p_ht;
char *ht = "`${process.env.USERHOME}`", *ht_start, *p_ht;
char ht_symbol[2];
ht_start = strstr(confpath, ht);

5
iguana/exchanges/LP_portfolio.c

@ -443,7 +443,7 @@ double LP_tickered_price(int32_t bidask,char *base,char *rel,double price,cJSON
void LP_autoprice_iter(void *ctx,struct LP_priceinfo *btcpp)
{
static cJSON *tickerjson; static uint32_t lasttime;
char *retstr,*base,*rel; cJSON *retjson,*bid,*ask,*fundjson,*argjson; uint64_t bidsatoshis,asksatoshis; int32_t i,changed; double nxtkmd,price,factor,offset,newprice,margin,price_btc,price_usd,kmd_btc,kmd_usd; struct LP_priceinfo *kmdpp,*fiatpp,*nxtpp,*basepp,*relpp;
char *retstr,*base,*rel; cJSON *retjson,*bid,*ask,*fundjson,*argjson; uint64_t bidsatoshis,asksatoshis; int32_t i,changed; double bch_usd,bch_btc,nxtkmd,price,factor,offset,newprice,margin,price_btc,price_usd,kmd_btc,kmd_usd; struct LP_priceinfo *kmdpp,*fiatpp,*nxtpp,*basepp,*relpp;
if ( (retstr= issue_curlt("https://bittrex.com/api/v1.1/public/getmarketsummaries",LP_HTTP_TIMEOUT*10)) == 0 )
{
printf("trex error getting marketsummaries\n");
@ -513,6 +513,7 @@ void LP_autoprice_iter(void *ctx,struct LP_priceinfo *btcpp)
}
}
kmd_btc = LP_CMCbtcprice(&kmd_usd,"komodo");
bch_btc = LP_CMCbtcprice(&bch_usd,"bitcoin-cash");
for (i=0; i<num_LP_autorefs; i++)
{
rel = LP_autorefs[i].rel;
@ -564,6 +565,8 @@ void LP_autoprice_iter(void *ctx,struct LP_priceinfo *btcpp)
{
if ( strcmp(rel,"KMD") == 0 )
price = kmd_btc / price_btc;
else if ( strcmp(rel,"BCH") == 0 )
price = bch_btc / price_btc;
else if ( strcmp(rel,"BTC") == 0 )
price = 1. / price_btc;
else continue;

12
iguana/exchanges/LP_privkey.c

@ -213,7 +213,7 @@ int32_t LP_wifstr_valid(char *wifstr)
{
//printf("%s is valid wif\n",wifstr);
return(1);
}
} //else printf("invalid wifstr.(%s) wiftype.%d cmpstr.%s\n",wifstr,wiftype,cmpstr);
}
return(0);
}
@ -221,7 +221,7 @@ int32_t LP_wifstr_valid(char *wifstr)
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; int32_t notarized;
bits256 privkey,userpub,zero,userpass,checkkey,tmpkey; char tmpstr[128]; cJSON *retjson; uint8_t tmptype; int32_t notarized; uint64_t nxtaddr;
if ( (wifstr == 0 || wifstr[0] == 0) && LP_wifstr_valid(passphrase) > 0 )
{
wifstr = passphrase;
@ -231,6 +231,7 @@ bits256 LP_privkeycalc(void *ctx,uint8_t *pubkey33,bits256 *pubkeyp,struct iguan
{
calc_NXTaddr(G.LP_NXTaddr,userpub.bytes,(uint8_t *)passphrase,(int32_t)strlen(passphrase));
conv_NXTpassword(privkey.bytes,pubkeyp->bytes,(uint8_t *)passphrase,(int32_t)strlen(passphrase));
privkey.bytes[0] &= 248, privkey.bytes[31] &= 127, privkey.bytes[31] |= 64;
//vcalc_sha256(0,checkkey.bytes,(uint8_t *)passphrase,(int32_t)strlen(passphrase));
//printf("SHA256.(%s) ",bits256_str(pstr,checkkey));
//printf("privkey.(%s)\n",bits256_str(pstr,privkey));
@ -238,8 +239,13 @@ bits256 LP_privkeycalc(void *ctx,uint8_t *pubkey33,bits256 *pubkeyp,struct iguan
else
{
bitcoin_wif2priv(coin->wiftaddr,&tmptype,&privkey,wifstr);
bitcoin_priv2wif(coin->wiftaddr,tmpstr,privkey,tmptype);
if ( strcmp(tmpstr,wifstr) != 0 )
printf("converted %s != %s\n",tmpstr,wifstr);
tmpkey = privkey;
nxtaddr = conv_NXTpassword(tmpkey.bytes,pubkeyp->bytes,0,0);
RS_encode(G.LP_NXTaddr,nxtaddr);
}
privkey.bytes[0] &= 248, privkey.bytes[31] &= 127, privkey.bytes[31] |= 64;
bitcoin_priv2pub(ctx,coin->pubkey33,coin->smartaddr,privkey,coin->taddr,coin->pubtype);
if ( coin->counter == 0 )
{

2
iguana/exchanges/coins

File diff suppressed because one or more lines are too long

5
iguana/exchanges/coins.json

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save