diff --git a/src/addressindex.cpp b/src/addressindex.cpp index 98459c2e3e..e9eee7850f 100644 --- a/src/addressindex.cpp +++ b/src/addressindex.cpp @@ -29,10 +29,10 @@ bool AddressBytesFromScript(const CScript& script, AddressType& address_type, ui address_type = AddressType::P2SH; address_bytes = uint160(TrimScriptP2SH(script)); } else if (script.IsPayToPublicKeyHash()) { - address_type = AddressType::P2PKH; + address_type = AddressType::P2PK_OR_P2PKH; address_bytes = uint160(TrimScriptP2PKH(script)); } else if (script.IsPayToPublicKey()) { - address_type = AddressType::P2PK; + address_type = AddressType::P2PK_OR_P2PKH; address_bytes = Hash160(TrimScriptP2PK(script)); } else { address_type = AddressType::UNKNOWN; diff --git a/src/addressindex.h b/src/addressindex.h index fec8a66489..42f8227237 100644 --- a/src/addressindex.h +++ b/src/addressindex.h @@ -19,8 +19,7 @@ class CScript; enum class AddressType : uint8_t { - P2PK = 1, - P2PKH = 1, + P2PK_OR_P2PKH = 1, P2SH = 2, UNKNOWN = 0 diff --git a/src/core_write.cpp b/src/core_write.cpp index c6c329479d..65f40b0bbb 100644 --- a/src/core_write.cpp +++ b/src/core_write.cpp @@ -216,7 +216,7 @@ void TxToUniv(const CTransaction& tx, const uint256& hashBlock, UniValue& entry, auto spentInfo = it->second; in.pushKV("value", ValueFromAmount(spentInfo.m_amount)); in.pushKV("valueSat", spentInfo.m_amount); - if (spentInfo.m_address_type == AddressType::P2PK) { + if (spentInfo.m_address_type == AddressType::P2PK_OR_P2PKH) { in.pushKV("address", EncodeDestination(PKHash(spentInfo.m_address_bytes))); } else if (spentInfo.m_address_type == AddressType::P2SH) { in.pushKV("address", EncodeDestination(ScriptHash(spentInfo.m_address_bytes))); diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index 7313af1859..edf09cfb13 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -598,7 +598,7 @@ static bool getAddressFromIndex(const AddressType& type, const uint160 &hash, st { if (type == AddressType::P2SH) { address = EncodeDestination(ScriptHash(hash)); - } else if (type == AddressType::P2PK) { + } else if (type == AddressType::P2PK_OR_P2PKH) { address = EncodeDestination(PKHash(hash)); } else { return false; @@ -615,7 +615,7 @@ static bool getIndexKey(const std::string& str, uint160& hashBytes, AddressType& } const PKHash *pkhash = std::get_if(&dest); const ScriptHash *scriptID = std::get_if(&dest); - type = pkhash ? AddressType::P2PK : AddressType::P2SH; + type = pkhash ? AddressType::P2PK_OR_P2PKH : AddressType::P2SH; hashBytes = pkhash ? uint160(*pkhash) : uint160(*scriptID); return true; }