Browse Source

Test

etomic
jl777 7 years ago
parent
commit
05053f2502
  1. 15
      iguana/exchanges/LP_bitcoin.c
  2. 11
      iguana/exchanges/LP_privkey.c

15
iguana/exchanges/LP_bitcoin.c

@ -2144,21 +2144,6 @@ int32_t bitcoin_wif2priv(uint8_t wiftaddr,uint8_t *addrtypep,bits256 *privkeyp,c
if ( (len= bitcoin_base58decode(buf,wifstr)) >= 4 )
{
// validate with trailing hash, then remove hash
/*if ( len < 38 )
{
memset(pbuf,0,sizeof(pbuf));
n = 1 + (wiftaddr!=0);
memcpy(pbuf,buf,n);
for (i=0; i<len-n; i++)
pbuf[37-i] = buf[len-1-i];
ptr = pbuf;
len = 38;
for (i=0; i<38; i++)
printf("%02x",pbuf[i]);
printf(" len.%d -> 38\n",len);
} else*/
//if ( len < 38 )
// len = 38;
ptr = buf;
hash = bits256_doublesha256(0,ptr,len - 4);
*addrtypep = (wiftaddr == 0) ? *ptr : ptr[1];

11
iguana/exchanges/LP_privkey.c

@ -204,18 +204,21 @@ char *LP_secretaddresses(void *ctx,char *prefix,char *passphrase,int32_t n,uint8
int32_t LP_wifstr_valid(char *wifstr)
{
bits256 privkey; uint8_t wiftype; char cmpstr[128]; int32_t iter;
bits256 privkey,cmpkey; uint8_t wiftype; char cmpstr[128]; int32_t iter;
for (iter=0; iter<2; iter++)
{
bitcoin_wif2priv(0,&wiftype,&privkey,wifstr);
bitcoin_priv2wif(0,cmpstr,privkey,wiftype);
char str[65]; printf("%s -> %s -> %s\n",wifstr,bits256_str(str,privkey),cmpstr);
return(1);
if ( strcmp(cmpstr,wifstr) == 0 )
{
//printf("%s is valid wif\n",wifstr);
return(1);
} else printf("invalid wifstr.(%s) wiftype.%d cmpstr.%s\n",wifstr,wiftype,cmpstr);
}
else
{
bitcoin_wif2priv(0,&wiftype,&cmpkey,cmpstr);
char str[65],str2[65]; printf("invalid wifstr %s -> %s -> %s %s\n",wifstr,bits256_str(str,privkey),cmpstr,bits256_str(str2,cmpkey));
}
}
return(0);
}

Loading…
Cancel
Save