diff --git a/iguana/exchanges/bitcoin.c b/iguana/exchanges/bitcoin.c index b23d59864..452c8c075 100755 --- a/iguana/exchanges/bitcoin.c +++ b/iguana/exchanges/bitcoin.c @@ -139,10 +139,27 @@ int32_t bitcoin_priv2wif(char *wifstr,bits256 privkey,uint8_t addrtype) { uint8_t data[128]; int32_t len = 32; memcpy(data+1,privkey.bytes,sizeof(privkey)); - if ( addrtype != 176 ) // not LTC - data[1 + len++] = 1; + data[1 + len++] = 1; + len = base58encode_checkbuf(addrtype,data,len); + if ( bitcoin_base58encode(wifstr,data,len) == 0 ) + return(-1); + if ( 1 ) + { + uint8_t checktype; bits256 checkpriv; char str[65],str2[65]; + if ( bitcoin_wif2priv(&checktype,&checkpriv,wifstr) == sizeof(bits256) ) + { + if ( checktype != addrtype || bits256_cmp(checkpriv,privkey) != 0 ) + printf("(%s) -> wif.(%s) addrtype.%02x -> %02x (%s)\n",bits256_str(str,privkey),wifstr,addrtype,checktype,bits256_str(str2,checkpriv)); + } + } + return((int32_t)strlen(wifstr)); +} + +int32_t bitcoin_priv2wiflong(char *wifstr,bits256 privkey,uint8_t addrtype) +{ + uint8_t data[128]; int32_t len = 32; + memcpy(data+1,privkey.bytes,sizeof(privkey)); len = base58encode_checkbuf(addrtype,data,len); - if ( bitcoin_base58encode(wifstr,data,len) == 0 ) return(-1); if ( 1 ) diff --git a/iguana/iguana_wallet.c b/iguana/iguana_wallet.c index e17538201..e125aea2a 100755 --- a/iguana/iguana_wallet.c +++ b/iguana/iguana_wallet.c @@ -1435,6 +1435,8 @@ THREE_STRINGS(bitcoinrpc,encryptwallet,passphrase,password,permanentfile) { bitcoin_priv2wif(wifstr,waddr.privkey,coin->chain->wiftype); jaddstr(retjson,"LTCwif",wifstr); + bitcoin_priv2wiflong(wifstr,waddr.privkey,coin->chain->wiftype); + jaddstr(retjson,"LTCwiflong",wifstr); } if ( need_BTC != 0 ) { diff --git a/includes/iguana_funcs.h b/includes/iguana_funcs.h index 8ca911a49..ceb086e22 100755 --- a/includes/iguana_funcs.h +++ b/includes/iguana_funcs.h @@ -287,6 +287,7 @@ int32_t SuperNET_sendmsg(struct supernet_info *myinfo,struct iguana_info *coin,s int32_t category_peer(struct supernet_info *myinfo,struct iguana_peer *addr,bits256 category,bits256 subhash); int32_t bitcoin_wif2priv(uint8_t *addrtypep,bits256 *privkeyp,char *wifstr); int32_t bitcoin_priv2wif(char *wifstr,bits256 privkey,uint8_t addrtype); +int32_t bitcoin_priv2wiflong(char *wifstr,bits256 privkey,uint8_t addrtype); bits256 iguana_chaingenesis(struct supernet_info *myinfo,char *symbol,uint8_t zcash,uint8_t auxpow,int32_t (*hashalgo)(uint8_t *blockhashp,uint8_t *serialized,int32_t len),bits256 genesishash,char *genesisblock,char *hashalgostr,int32_t version,uint32_t timestamp,uint32_t bits,uint32_t nonce,bits256 merkle_root); int32_t iguana_send_ConnectTo(struct iguana_info *coin,struct iguana_peer *addr); cJSON *iguana_txjson(struct iguana_info *coin,struct iguana_txid *tx,int32_t height,struct vin_info *V);