diff --git a/iguana/exchanges/bitcoin.c b/iguana/exchanges/bitcoin.c index 64a01371e..57cc788d4 100755 --- a/iguana/exchanges/bitcoin.c +++ b/iguana/exchanges/bitcoin.c @@ -59,12 +59,12 @@ int32_t bitcoin_addr2rmd160(uint8_t *addrtypep,uint8_t rmd160[20],char *coinaddr return(0); } -char *bitcoin_address(char *coinaddr,uint8_t addrtype,uint8_t *pubkey,int32_t len) +char *bitcoin_address(char *coinaddr,uint8_t addrtype,uint8_t *pubkey_or_rmd160,int32_t len) { int32_t i; uint8_t data[25]; bits256 hash;// char checkaddr[65]; if ( len != 20 ) - calc_rmd160_sha256(data+1,pubkey,len); - else memcpy(data+1,pubkey,20); + calc_rmd160_sha256(data+1,pubkey_or_rmd160,len); + else memcpy(data+1,pubkey_or_rmd160,20); //btc_convrmd160(checkaddr,addrtype,data+1); //for (i=0; i<20; i++) // printf("%02x",data[i+1]); diff --git a/iguana/iguana_wallet.c b/iguana/iguana_wallet.c index 7cedd26cd..1675a6cf4 100755 --- a/iguana/iguana_wallet.c +++ b/iguana/iguana_wallet.c @@ -517,35 +517,32 @@ char *getnewaddress(struct supernet_info *myinfo,struct iguana_waddress **waddrp STRING_ARG(bitcoinrpc,validateaddress,address) { - cJSON *retjson; int32_t i; uint8_t addrtype,rmd160[20],pubkey[65]; struct iguana_info *other; char checkaddr[64],str[256]; + cJSON *retjson; int32_t i; uint8_t addrtype,rmd160[20],pubkey[65]; struct iguana_info *other; char str[256]; if ( remoteaddr != 0 ) return(clonestr("{\"error\":\"no remote\"}")); if ( iguana_addressvalidate(coin,&addrtype,rmd160,address) < 0 ) return(clonestr("{\"error\":\"invalid coin address\"}")); - if ( strcmp(address,checkaddr) == 0 ) + retjson = cJSON_CreateObject(); + jaddstr(retjson,"result","success"); + jaddnum(retjson,"addrtype",addrtype); + init_hexbytes_noT(str,rmd160,sizeof(rmd160)); + jaddstr(retjson,"rmd160",str); + if ( iguana_ismine(myinfo,coin,addrtype,pubkey,rmd160) > 0 ) { - retjson = cJSON_CreateObject(); - jaddstr(retjson,"result","success"); - jaddnum(retjson,"addrtype",addrtype); - init_hexbytes_noT(str,rmd160,sizeof(rmd160)); - jaddstr(retjson,"rmd160",str); - if ( iguana_ismine(myinfo,coin,addrtype,pubkey,rmd160) > 0 ) - { - init_hexbytes_noT(str,pubkey,bitcoin_pubkeylen(pubkey)); - jaddstr(retjson,"pubkey",str); - cJSON_AddTrueToObject(retjson,"ismine"); - } - else cJSON_AddFalseToObject(retjson,"ismine"); - for (i=0; isymbol,coin->symbol) != 0 ) { - if ( (other= Coins[i]) != 0 && strcmp(other->symbol,coin->symbol) != 0 ) - { - iguana_addressconv(coin,str,other,addrtype == coin->chain->p2shtype,rmd160); - jaddstr(retjson,other->symbol,str); - } + iguana_addressconv(coin,str,other,addrtype == coin->chain->p2shtype,rmd160); + jaddstr(retjson,other->symbol,str); } - return(jprint(retjson,1)); - } else return(clonestr("{\"error\":\"couldnt regenerate address\"}")); + } + return(jprint(retjson,1)); } ZERO_ARGS(bitcoinrpc,getinfo)