mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 12:02:48 +01:00
refactor: consolidate P2PK{H} types to P2PK_OR_P2PKH
This commit is contained in:
parent
f011c31b1a
commit
93ddd3f7e8
@ -29,10 +29,10 @@ bool AddressBytesFromScript(const CScript& script, AddressType& address_type, ui
|
|||||||
address_type = AddressType::P2SH;
|
address_type = AddressType::P2SH;
|
||||||
address_bytes = uint160(TrimScriptP2SH(script));
|
address_bytes = uint160(TrimScriptP2SH(script));
|
||||||
} else if (script.IsPayToPublicKeyHash()) {
|
} else if (script.IsPayToPublicKeyHash()) {
|
||||||
address_type = AddressType::P2PKH;
|
address_type = AddressType::P2PK_OR_P2PKH;
|
||||||
address_bytes = uint160(TrimScriptP2PKH(script));
|
address_bytes = uint160(TrimScriptP2PKH(script));
|
||||||
} else if (script.IsPayToPublicKey()) {
|
} else if (script.IsPayToPublicKey()) {
|
||||||
address_type = AddressType::P2PK;
|
address_type = AddressType::P2PK_OR_P2PKH;
|
||||||
address_bytes = Hash160(TrimScriptP2PK(script));
|
address_bytes = Hash160(TrimScriptP2PK(script));
|
||||||
} else {
|
} else {
|
||||||
address_type = AddressType::UNKNOWN;
|
address_type = AddressType::UNKNOWN;
|
||||||
|
@ -19,8 +19,7 @@
|
|||||||
class CScript;
|
class CScript;
|
||||||
|
|
||||||
enum class AddressType : uint8_t {
|
enum class AddressType : uint8_t {
|
||||||
P2PK = 1,
|
P2PK_OR_P2PKH = 1,
|
||||||
P2PKH = 1,
|
|
||||||
P2SH = 2,
|
P2SH = 2,
|
||||||
|
|
||||||
UNKNOWN = 0
|
UNKNOWN = 0
|
||||||
|
@ -216,7 +216,7 @@ void TxToUniv(const CTransaction& tx, const uint256& hashBlock, UniValue& entry,
|
|||||||
auto spentInfo = it->second;
|
auto spentInfo = it->second;
|
||||||
in.pushKV("value", ValueFromAmount(spentInfo.m_amount));
|
in.pushKV("value", ValueFromAmount(spentInfo.m_amount));
|
||||||
in.pushKV("valueSat", 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)));
|
in.pushKV("address", EncodeDestination(PKHash(spentInfo.m_address_bytes)));
|
||||||
} else if (spentInfo.m_address_type == AddressType::P2SH) {
|
} else if (spentInfo.m_address_type == AddressType::P2SH) {
|
||||||
in.pushKV("address", EncodeDestination(ScriptHash(spentInfo.m_address_bytes)));
|
in.pushKV("address", EncodeDestination(ScriptHash(spentInfo.m_address_bytes)));
|
||||||
|
@ -598,7 +598,7 @@ static bool getAddressFromIndex(const AddressType& type, const uint160 &hash, st
|
|||||||
{
|
{
|
||||||
if (type == AddressType::P2SH) {
|
if (type == AddressType::P2SH) {
|
||||||
address = EncodeDestination(ScriptHash(hash));
|
address = EncodeDestination(ScriptHash(hash));
|
||||||
} else if (type == AddressType::P2PK) {
|
} else if (type == AddressType::P2PK_OR_P2PKH) {
|
||||||
address = EncodeDestination(PKHash(hash));
|
address = EncodeDestination(PKHash(hash));
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
@ -615,7 +615,7 @@ static bool getIndexKey(const std::string& str, uint160& hashBytes, AddressType&
|
|||||||
}
|
}
|
||||||
const PKHash *pkhash = std::get_if<PKHash>(&dest);
|
const PKHash *pkhash = std::get_if<PKHash>(&dest);
|
||||||
const ScriptHash *scriptID = std::get_if<ScriptHash>(&dest);
|
const ScriptHash *scriptID = std::get_if<ScriptHash>(&dest);
|
||||||
type = pkhash ? AddressType::P2PK : AddressType::P2SH;
|
type = pkhash ? AddressType::P2PK_OR_P2PKH : AddressType::P2SH;
|
||||||
hashBytes = pkhash ? uint160(*pkhash) : uint160(*scriptID);
|
hashBytes = pkhash ? uint160(*pkhash) : uint160(*scriptID);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user