mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-10 11:57:28 -03:00
[rpc] Remove deprecated validateaddress usage.
This commit is contained in:
parent
f180e81d57
commit
df905e390e
2 changed files with 8 additions and 30 deletions
|
@ -19,11 +19,6 @@
|
||||||
#include <timedata.h>
|
#include <timedata.h>
|
||||||
#include <util.h>
|
#include <util.h>
|
||||||
#include <utilstrencodings.h>
|
#include <utilstrencodings.h>
|
||||||
#ifdef ENABLE_WALLET
|
|
||||||
#include <wallet/rpcwallet.h>
|
|
||||||
#include <wallet/wallet.h>
|
|
||||||
#include <wallet/walletdb.h>
|
|
||||||
#endif
|
|
||||||
#include <warnings.h>
|
#include <warnings.h>
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
@ -67,29 +62,18 @@ static UniValue validateaddress(const JSONRPCRequest& request)
|
||||||
ret.pushKV("isvalid", isValid);
|
ret.pushKV("isvalid", isValid);
|
||||||
if (isValid)
|
if (isValid)
|
||||||
{
|
{
|
||||||
|
std::string currentAddress = EncodeDestination(dest);
|
||||||
|
ret.pushKV("address", currentAddress);
|
||||||
|
|
||||||
#ifdef ENABLE_WALLET
|
CScript scriptPubKey = GetScriptForDestination(dest);
|
||||||
if (HasWallets() && IsDeprecatedRPCEnabled("validateaddress")) {
|
ret.pushKV("scriptPubKey", HexStr(scriptPubKey.begin(), scriptPubKey.end()));
|
||||||
ret.pushKVs(getaddressinfo(request));
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
if (ret["address"].isNull()) {
|
|
||||||
std::string currentAddress = EncodeDestination(dest);
|
|
||||||
ret.pushKV("address", currentAddress);
|
|
||||||
|
|
||||||
CScript scriptPubKey = GetScriptForDestination(dest);
|
UniValue detail = DescribeAddress(dest);
|
||||||
ret.pushKV("scriptPubKey", HexStr(scriptPubKey.begin(), scriptPubKey.end()));
|
ret.pushKVs(detail);
|
||||||
|
|
||||||
UniValue detail = DescribeAddress(dest);
|
|
||||||
ret.pushKVs(detail);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Needed even with !ENABLE_WALLET, to pass (ignored) pointers around
|
|
||||||
class CWallet;
|
|
||||||
|
|
||||||
static UniValue createmultisig(const JSONRPCRequest& request)
|
static UniValue createmultisig(const JSONRPCRequest& request)
|
||||||
{
|
{
|
||||||
if (request.fHelp || request.params.size() < 2 || request.params.size() > 3)
|
if (request.fHelp || request.params.size() < 2 || request.params.size() > 3)
|
||||||
|
@ -461,7 +445,7 @@ static const CRPCCommand commands[] =
|
||||||
// --------------------- ------------------------ ----------------------- ----------
|
// --------------------- ------------------------ ----------------------- ----------
|
||||||
{ "control", "getmemoryinfo", &getmemoryinfo, {"mode"} },
|
{ "control", "getmemoryinfo", &getmemoryinfo, {"mode"} },
|
||||||
{ "control", "logging", &logging, {"include", "exclude"}},
|
{ "control", "logging", &logging, {"include", "exclude"}},
|
||||||
{ "util", "validateaddress", &validateaddress, {"address"} }, /* uses wallet if enabled */
|
{ "util", "validateaddress", &validateaddress, {"address"} },
|
||||||
{ "util", "createmultisig", &createmultisig, {"nrequired","keys"} },
|
{ "util", "createmultisig", &createmultisig, {"nrequired","keys"} },
|
||||||
{ "util", "verifymessage", &verifymessage, {"address","signature","message"} },
|
{ "util", "verifymessage", &verifymessage, {"address","signature","message"} },
|
||||||
{ "util", "signmessagewithprivkey", &signmessagewithprivkey, {"privkey","message"} },
|
{ "util", "signmessagewithprivkey", &signmessagewithprivkey, {"privkey","message"} },
|
||||||
|
|
|
@ -18,13 +18,7 @@ class DeprecatedRpcTest(BitcoinTestFramework):
|
||||||
# self.log.info("Make sure that -deprecatedrpc=createmultisig allows it to take addresses")
|
# self.log.info("Make sure that -deprecatedrpc=createmultisig allows it to take addresses")
|
||||||
# assert_raises_rpc_error(-5, "Invalid public key", self.nodes[0].createmultisig, 1, [self.nodes[0].getnewaddress()])
|
# assert_raises_rpc_error(-5, "Invalid public key", self.nodes[0].createmultisig, 1, [self.nodes[0].getnewaddress()])
|
||||||
# self.nodes[1].createmultisig(1, [self.nodes[1].getnewaddress()])
|
# self.nodes[1].createmultisig(1, [self.nodes[1].getnewaddress()])
|
||||||
|
pass
|
||||||
self.log.info("Test validateaddress deprecation")
|
|
||||||
SOME_ADDRESS = "mnvGjUy3NMj67yJ6gkK5o9e5RS33Z2Vqcu" # This is just some random address to pass as a parameter to validateaddress
|
|
||||||
dep_validate_address = self.nodes[0].validateaddress(SOME_ADDRESS)
|
|
||||||
assert "ismine" not in dep_validate_address
|
|
||||||
not_dep_val = self.nodes[1].validateaddress(SOME_ADDRESS)
|
|
||||||
assert "ismine" in not_dep_val
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
DeprecatedRpcTest().main()
|
DeprecatedRpcTest().main()
|
||||||
|
|
Loading…
Reference in a new issue