From 4e168fd9a0bc9d162a9516c67b2e5ab68298a022 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 20 Dec 2017 23:48:52 +0700 Subject: [PATCH] Test --- iguana/exchanges/LP_bitcoin.c | 8 +++++++- iguana/exchanges/LP_privkey.c | 4 ++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/iguana/exchanges/LP_bitcoin.c b/iguana/exchanges/LP_bitcoin.c index 2923cefdd..7e1913735 100644 --- a/iguana/exchanges/LP_bitcoin.c +++ b/iguana/exchanges/LP_bitcoin.c @@ -2144,7 +2144,13 @@ 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 - ptr = buf; + if ( len <= 38 ) + ptr = buf; + else if ( buf[0] == 0 ) + { + ptr = buf+1; + len--; + } else ptr = buf; hash = bits256_doublesha256(0,ptr,len - 4); *addrtypep = (wiftaddr == 0) ? *ptr : ptr[1]; memcpy(privkeyp,ptr+offset,32); diff --git a/iguana/exchanges/LP_privkey.c b/iguana/exchanges/LP_privkey.c index 0fb3d8a7b..fb5ffcf4f 100644 --- a/iguana/exchanges/LP_privkey.c +++ b/iguana/exchanges/LP_privkey.c @@ -382,10 +382,10 @@ void LP_privkey_tests() privkey = rand256(0); bitcoin_priv2wif(0,wifstr,privkey,0); bitcoin_wif2priv(0,&tmptype,&checkkey,wifstr); - //if ( bits256_cmp(privkey,checkkey) != 0 ) + if ( bits256_cmp(privkey,checkkey) != 0 ) { printf("i.%d: %s vs %s\n",i,bits256_str(str,privkey),bits256_str(str2,checkkey)); - //exit(-1); + exit(-1); } if ( (i % 1000000) == 0 ) fprintf(stderr,"%.1f%% ",100.*(double)i/10000000);