Fix setpubkey crash
This commit is contained in:
@@ -5306,15 +5306,20 @@ UniValue setpubkey(const UniValue& params, bool fHelp)
|
|||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
char Raddress[18];
|
char Raddress[64];
|
||||||
uint8_t pubkey33[33];
|
uint8_t pubkey33[33];
|
||||||
if ( NOTARY_PUBKEY33[0] == 0 ) {
|
if ( NOTARY_PUBKEY33[0] == 0 )
|
||||||
if (strlen(params[0].get_str().c_str()) == 66) {
|
{
|
||||||
|
if (strlen(params[0].get_str().c_str()) == 66)
|
||||||
|
{
|
||||||
decode_hex(pubkey33,33,(char *)params[0].get_str().c_str());
|
decode_hex(pubkey33,33,(char *)params[0].get_str().c_str());
|
||||||
pubkey2addr((char *)Raddress,(uint8_t *)pubkey33);
|
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."));
|
result.push_back(Pair("error", "pubkey entered is invalid."));
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
CBitcoinAddress address(Raddress);
|
CBitcoinAddress address(Raddress);
|
||||||
bool isValid = address.IsValid();
|
bool isValid = address.IsValid();
|
||||||
if (isValid)
|
if (isValid)
|
||||||
@@ -5331,10 +5336,10 @@ UniValue setpubkey(const UniValue& params, bool fHelp)
|
|||||||
decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str());
|
decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str());
|
||||||
USE_EXTERNAL_PUBKEY = 1;
|
USE_EXTERNAL_PUBKEY = 1;
|
||||||
}
|
}
|
||||||
} else {
|
} else result.push_back(Pair("error", "pubkey is wrong length, must be 66 char hex string."));
|
||||||
result.push_back(Pair("error", "pubkey is wrong length, must be 66 char hex string."));
|
}
|
||||||
}
|
else
|
||||||
} 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."));
|
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);
|
pubkey2addr((char *)Raddress,(uint8_t *)NOTARY_PUBKEY33);
|
||||||
std::string address_ret; address_ret.assign(Raddress);
|
std::string address_ret; address_ret.assign(Raddress);
|
||||||
|
|||||||
Reference in New Issue
Block a user