From fa91d57de36d74168e01909ae97d85bfdce2e0f1 Mon Sep 17 00:00:00 2001 From: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> Date: Thu, 15 May 2025 14:50:11 +0200 Subject: [PATCH] remove unused AddrToPubKey --- src/rpc/util.cpp | 23 +---------------------- src/rpc/util.h | 3 +-- src/test/fuzz/key.cpp | 3 --- 3 files changed, 2 insertions(+), 27 deletions(-) diff --git a/src/rpc/util.cpp b/src/rpc/util.cpp index 4c83517c8d..ab92587188 100644 --- a/src/rpc/util.cpp +++ b/src/rpc/util.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2022 The Bitcoin Core developers +// Copyright (c) 2017-present The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. @@ -234,27 +234,6 @@ CPubKey HexToPubKey(const std::string& hex_in) return vchPubKey; } -// Retrieves a public key for an address from the given FillableSigningProvider -CPubKey AddrToPubKey(const FillableSigningProvider& keystore, const std::string& addr_in) -{ - CTxDestination dest = DecodeDestination(addr_in); - if (!IsValidDestination(dest)) { - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid address: " + addr_in); - } - CKeyID key = GetKeyForDestination(keystore, dest); - if (key.IsNull()) { - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, strprintf("'%s' does not refer to a key", addr_in)); - } - CPubKey vchPubKey; - if (!keystore.GetPubKey(key, vchPubKey)) { - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, strprintf("no full public key for address %s", addr_in)); - } - if (!vchPubKey.IsFullyValid()) { - throw JSONRPCError(RPC_INTERNAL_ERROR, "Wallet contains an invalid public key"); - } - return vchPubKey; -} - // Creates a multisig address from a given list of public keys, number of signatures required, and the address type CTxDestination AddAndGetMultisigDestination(const int required, const std::vector& pubkeys, OutputType type, FlatSigningProvider& keystore, CScript& script_out) { diff --git a/src/rpc/util.h b/src/rpc/util.h index 4eafa1eb6e..df36bc73cc 100644 --- a/src/rpc/util.h +++ b/src/rpc/util.h @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2022 The Bitcoin Core developers +// Copyright (c) 2017-present The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. @@ -132,7 +132,6 @@ std::string HelpExampleRpc(const std::string& methodname, const std::string& arg std::string HelpExampleRpcNamed(const std::string& methodname, const RPCArgList& args); CPubKey HexToPubKey(const std::string& hex_in); -CPubKey AddrToPubKey(const FillableSigningProvider& keystore, const std::string& addr_in); CTxDestination AddAndGetMultisigDestination(const int required, const std::vector& pubkeys, OutputType type, FlatSigningProvider& keystore, CScript& script_out); UniValue DescribeAddress(const CTxDestination& dest); diff --git a/src/test/fuzz/key.cpp b/src/test/fuzz/key.cpp index c7ff2f3a28..92cf04c0ee 100644 --- a/src/test/fuzz/key.cpp +++ b/src/test/fuzz/key.cpp @@ -186,9 +186,6 @@ FUZZ_TARGET(key, .init = initialize_key) const std::string destination_address = EncodeDestination(tx_destination); assert(DecodeDestination(destination_address) == tx_destination); - const CPubKey pubkey_from_address_string = AddrToPubKey(fillable_signing_provider, destination_address); - assert(pubkey_from_address_string == pubkey); - CKeyID key_id = pubkey.GetID(); assert(!key_id.IsNull()); assert(key_id == CKeyID{key_id});