Browse Source

fix validateaddress RPC

release/v0.1
jl777 9 years ago
parent
commit
b441d98910
  1. 6
      iguana/exchanges/bitcoin.c
  2. 41
      iguana/iguana_wallet.c

6
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]);

41
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; i<IGUANA_MAXCOINS; i++)
init_hexbytes_noT(str,pubkey,bitcoin_pubkeylen(pubkey));
jaddstr(retjson,"pubkey",str);
cJSON_AddTrueToObject(retjson,"ismine");
}
else cJSON_AddFalseToObject(retjson,"ismine");
for (i=0; i<IGUANA_MAXCOINS; i++)
{
if ( (other= Coins[i]) != 0 && strcmp(other->symbol,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)

Loading…
Cancel
Save