diff --git a/electrum/transaction.py b/electrum/transaction.py index 37b342aad..35af9fef2 100644 --- a/electrum/transaction.py +++ b/electrum/transaction.py @@ -421,6 +421,7 @@ def is_instance(cls, item): opcodes.OP_EQUALVERIFY, opcodes.OP_CHECKSIG] SCRIPTPUBKEY_TEMPLATE_P2SH = [opcodes.OP_HASH160, OPPushDataGeneric(lambda x: x == 20), opcodes.OP_EQUAL] SCRIPTPUBKEY_TEMPLATE_WITNESS_V0 = [opcodes.OP_0, OPPushDataGeneric(lambda x: x in (20, 32))] +SCRIPTPUBKEY_TEMPLATE_P2PK = [OPPushDataGeneric(lambda x: x in (33, 65)), opcodes.OP_CHECKSIG] def match_script_against_template(script, template) -> bool: @@ -470,6 +471,10 @@ def get_address_from_output_script(_bytes: bytes, *, net=None) -> Optional[str]: if match_script_against_template(decoded, match): return hash_to_segwit_addr(decoded[1][1], witver=witver, net=net) + # p2pk + if match_script_against_template(decoded, SCRIPTPUBKEY_TEMPLATE_P2PK): + return bitcoin.pubkey_to_address('p2pkh', decoded[0][1].hex(), net=net) + return None