From b999ac2d53b8f5467dfd717dd846f2bc441adbbe Mon Sep 17 00:00:00 2001 From: Jesus Christ <120573631+Gudnessuche@users.noreply.github.com> Date: Sat, 30 Nov 2024 16:26:47 +0000 Subject: [PATCH] Add support for Pay-to-Anchor (P2A) address type in get_pubkey_from_input function This commit adds a conditional statement to the get_pubkey_from_input function to handle Pay-to-Anchor (P2A) address types. The function now checks if the previous output is a P2A address type and extracts the public key from the anchor_script. This update ensures compatibility with the Bitcoin protocol for P2A address types and enhances the function's versatility in processing various address types. --- bip-0352/reference.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/bip-0352/reference.py b/bip-0352/reference.py index b4eaf94560..2f212f6de4 100755 --- a/bip-0352/reference.py +++ b/bip-0352/reference.py @@ -78,6 +78,11 @@ def get_pubkey_from_input(vin: VinInfo) -> ECPubKey: pubkey = ECPubKey().set(vin.prevout[2:]) if (pubkey.valid) & (pubkey.compressed): return pubkey + if is_p2a(vin.prevout): + anchor_script = vin.scriptSig[1:] + pubkey = ECPubKey().set(anchor_script) + if (pubkey.valid) & (pubkey.compressed): + return pubkey return ECPubKey()