From b4c9cbc661f35e298814b6b910c56583b421c966 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 18 Feb 2019 03:59:54 -1100 Subject: [PATCH] Fix setpubkey crash --- src/wallet/rpcwallet.cpp | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index f945b82fc..47f7d3004 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -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);