jl777 7 years ago
parent
commit
d1276db5df
  1. 10
      iguana/exchanges/LP_bitcoin.c
  2. 2
      iguana/exchanges/LP_rpc.c

10
iguana/exchanges/LP_bitcoin.c

@ -2288,7 +2288,7 @@ int32_t bitcoin_wif2priv(char *symbol,uint8_t wiftaddr,uint8_t *addrtypep,bits25
ptr = buf; ptr = buf;
hash = bits256_calcaddrhash(symbol,ptr,len - 4); hash = bits256_calcaddrhash(symbol,ptr,len - 4);
*addrtypep = (wiftaddr == 0) ? *ptr : ptr[1]; *addrtypep = (wiftaddr == 0) ? *ptr : ptr[1];
if ( strcmp(symbol,"GRS") != 0 && (ptr[len - 4]&0xff) == hash.bytes[31] && (ptr[len - 3]&0xff) == hash.bytes[30] &&(ptr[len - 2]&0xff) == hash.bytes[29] && (ptr[len - 1]&0xff) == hash.bytes[28] ) if ( (ptr[len - 4]&0xff) == hash.bytes[31] && (ptr[len - 3]&0xff) == hash.bytes[30] &&(ptr[len - 2]&0xff) == hash.bytes[29] && (ptr[len - 1]&0xff) == hash.bytes[28] )
{ {
//int32_t i; for (i=0; i<len; i++) //int32_t i; for (i=0; i<len; i++)
// printf("%02x ",ptr[i]); // printf("%02x ",ptr[i]);
@ -2296,7 +2296,7 @@ int32_t bitcoin_wif2priv(char *symbol,uint8_t wiftaddr,uint8_t *addrtypep,bits25
//printf("wifstr.(%s) valid len.%d\n",wifstr,len); //printf("wifstr.(%s) valid len.%d\n",wifstr,len);
return(32); return(32);
} }
else if ( strcmp(symbol,"GRS") == 0 && (ptr[len - 4]&0xff) == hash.bytes[0] && (ptr[len - 3]&0xff) == hash.bytes[1] &&(ptr[len - 2]&0xff) == hash.bytes[2] && (ptr[len - 1]&0xff) == hash.bytes[3] ) else if ( (strcmp(symbol,"GRS") == 0 || strcmp(symbol,"SMART") == 0) && (ptr[len - 4]&0xff) == hash.bytes[0] && (ptr[len - 3]&0xff) == hash.bytes[1] &&(ptr[len - 2]&0xff) == hash.bytes[2] && (ptr[len - 1]&0xff) == hash.bytes[3] )
return(32); return(32);
else if ( 0 ) // gets errors when len is 37 else if ( 0 ) // gets errors when len is 37
{ {
@ -2310,16 +2310,16 @@ int32_t bitcoin_wif2priv(char *symbol,uint8_t wiftaddr,uint8_t *addrtypep,bits25
int32_t bitcoin_wif2addr(void *ctx,char *symbol,uint8_t wiftaddr,uint8_t taddr,uint8_t pubtype,char *coinaddr,char *wifstr) int32_t bitcoin_wif2addr(void *ctx,char *symbol,uint8_t wiftaddr,uint8_t taddr,uint8_t pubtype,char *coinaddr,char *wifstr)
{ {
bits256 privkey; uint8_t addrtype,pubkey33[33]; bits256 privkey; int32_t len; uint8_t addrtype,pubkey33[33];
if ( strcmp(symbol,"BCH") == 0 ) if ( strcmp(symbol,"BCH") == 0 )
symbol = "BTC"; symbol = "BTC";
coinaddr[0] = 0; coinaddr[0] = 0;
if ( bitcoin_wif2priv(symbol,wiftaddr,&addrtype,&privkey,wifstr) == sizeof(privkey) ) if ( (len= bitcoin_wif2priv(symbol,wiftaddr,&addrtype,&privkey,wifstr)) == sizeof(privkey) )
{ {
bitcoin_priv2pub(ctx,symbol,pubkey33,coinaddr,privkey,taddr,pubtype); bitcoin_priv2pub(ctx,symbol,pubkey33,coinaddr,privkey,taddr,pubtype);
printf("priv2pub returns.(%s)\n",coinaddr); printf("priv2pub returns.(%s)\n",coinaddr);
return(0); return(0);
} } else printf("wif2priv returns len.%d\n",len);
return(-1); return(-1);
} }

2
iguana/exchanges/LP_rpc.c

@ -541,6 +541,7 @@ int32_t LP_importaddress(char *symbol,char *address)
coin = LP_coinfind(symbol); coin = LP_coinfind(symbol);
if ( coin == 0 ) if ( coin == 0 )
return(-3); return(-3);
printf("import.(%s %s)\n",symbol,address);
if ( coin->electrum != 0 ) if ( coin->electrum != 0 )
{ {
/*if ( (retjson= electrum_address_subscribe(symbol,coin->electrum,&retjson,address)) != 0 ) /*if ( (retjson= electrum_address_subscribe(symbol,coin->electrum,&retjson,address)) != 0 )
@ -592,7 +593,6 @@ cJSON *LP_importprivkey(char *symbol,char *wifstr,char *label,int32_t flag)
ctx = bitcoin_ctx(); ctx = bitcoin_ctx();
bitcoin_wif2addr(ctx,symbol,coin->wiftaddr,coin->taddr,coin->pubtype,address,wifstr); bitcoin_wif2addr(ctx,symbol,coin->wiftaddr,coin->taddr,coin->pubtype,address,wifstr);
#ifdef LP_DONT_IMPORTPRIVKEY #ifdef LP_DONT_IMPORTPRIVKEY
//bitcoin_wif2addr(ctx,symbol,coin->wiftaddr,coin->taddr,coin->pubtype,address,wifstr);
if ( LP_importaddress(symbol,address) < 0 ) if ( LP_importaddress(symbol,address) < 0 )
{ {
printf("%s importaddress %s from %s failed, isvalid.%d\n",symbol,address,wifstr,bitcoin_validaddress(symbol,coin->taddr,coin->pubtype,coin->p2shtype,address)); printf("%s importaddress %s from %s failed, isvalid.%d\n",symbol,address,wifstr,bitcoin_validaddress(symbol,coin->taddr,coin->pubtype,coin->p2shtype,address));

Loading…
Cancel
Save