Fix setpubkey crash

This commit is contained in:
jl777
2019-02-18 03:59:54 -11:00
parent cbe32599e4
commit b4c9cbc661

View File

@@ -5306,15 +5306,20 @@ UniValue setpubkey(const UniValue& params, bool fHelp)
LOCK(cs_main);
#endif
char Raddress[18];
char Raddress[64];
uint8_t pubkey33[33];
if ( NOTARY_PUBKEY33[0] == 0 ) {
if (strlen(params[0].get_str().c_str()) == 66) {
if ( NOTARY_PUBKEY33[0] == 0 )
{
if (strlen(params[0].get_str().c_str()) == 66)
{
decode_hex(pubkey33,33,(char *)params[0].get_str().c_str());
pubkey2addr((char *)Raddress,(uint8_t *)pubkey33);
if (strcmp("RRmWExvapDM9YbLT9X9xAyzDgxomYf63ng",Raddress) == 0) {
if ( 0 && strcmp("RRmWExvapDM9YbLT9X9xAyzDgxomYf63ng",Raddress) == 0) // no idea what this addr is
{
result.push_back(Pair("error", "pubkey entered is invalid."));
} else {
}
else
{
CBitcoinAddress address(Raddress);
bool isValid = address.IsValid();
if (isValid)
@@ -5331,10 +5336,10 @@ UniValue setpubkey(const UniValue& params, bool fHelp)
decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str());
USE_EXTERNAL_PUBKEY = 1;
}
} else {
result.push_back(Pair("error", "pubkey is wrong length, must be 66 char hex string."));
}
} else {
} else result.push_back(Pair("error", "pubkey is wrong length, must be 66 char hex string."));
}
else
{
result.push_back(Pair("error", "Can only set pubkey once, to change it you need to restart your daemon, pubkey in use is below."));
pubkey2addr((char *)Raddress,(uint8_t *)NOTARY_PUBKEY33);
std::string address_ret; address_ret.assign(Raddress);