Skip to content

Commit

Permalink
Add p2wpkh
Browse files Browse the repository at this point in the history
  • Loading branch information
davidchocholaty committed Nov 8, 2024
1 parent 0497eb8 commit 0e0b23d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
1 change: 0 additions & 1 deletion src/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import hashlib
import ecdsa
from src.op_codes import OP_CODES
from src.verify import parse_der_signature_bytes
from src.serialize import serialize_transaction

class InvalidScriptException(Exception):
Expand Down
8 changes: 2 additions & 6 deletions src/transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,17 +112,13 @@ def valid_input(self, vin_idx, vin):

if scriptpubkey_type == "p2pkh":
return self.validate_p2pkh(vin_idx, vin)
#pass
elif scriptpubkey_type == "p2sh":
return self.validate_p2sh(vin_idx, vin)
#pass
pass
elif scriptpubkey_type == "v0_p2wsh":
#self.has_witness = True
pass
elif scriptpubkey_type == "v1_p2tr":
pass
elif scriptpubkey_type == "v0_p2wpkh":
#pass
self.has_witness = True
return self.validate_p2wpkh(vin_idx, vin)

Expand Down Expand Up @@ -231,7 +227,7 @@ def validate_p2wpkh(self, vin_idx, vin):
return False

scriptpubkey = bytes.fromhex(prevout.get("scriptpubkey", ""))

# Verify that the scriptPubKey matches the P2WPKH format (OP_0 <20-byte-key-hash>)
if len(scriptpubkey) != 22 or scriptpubkey[0] != 0x00 or scriptpubkey[1] != 0x14:
return False
Expand Down

0 comments on commit 0e0b23d

Please sign in to comment.