From 0be7fcf702c1c9c2b8e71d91799d13cdb69505a2 Mon Sep 17 00:00:00 2001 From: lateminer <9951982+lateminer@users.noreply.github.com> Date: Sat, 3 Feb 2024 21:33:28 +0100 Subject: [PATCH] script: Reinterpret P2PK scripts as PKHash --- src/addresstype.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/addresstype.cpp b/src/addresstype.cpp index f199d1b479..3f7b3c6527 100644 --- a/src/addresstype.cpp +++ b/src/addresstype.cpp @@ -54,12 +54,24 @@ bool ExtractDestination(const CScript& scriptPubKey, CTxDestination& addressRet) switch (whichType) { case TxoutType::PUBKEY: { CPubKey pubKey(vSolutions[0]); + + /* if (!pubKey.IsValid()) { addressRet = CNoDestination(scriptPubKey); } else { addressRet = PubKeyDestination(pubKey); } return false; + */ + + // Blackcoin: Reinterpret P2PK scripts as PKHash + // We need to do that because proof-of-stake mechanism uses P2PK outputs + // It partially reverts Bitcoin Core PR#28246 https://github.com/bitcoin/bitcoin/pull/28246 + if (!pubKey.IsValid()) + return false; + + addressRet = PKHash(pubKey); + return true; } case TxoutType::PUBKEYHASH: { addressRet = PKHash(uint160(vSolutions[0]));