MCPcopy Index your code
hub / github.com/petertodd/python-bitcoinlib / from_scriptPubKey

Method from_scriptPubKey

bitcoin/wallet.py:307–316  ·  view source on GitHub ↗

Convert a scriptPubKey to a P2WPKH address Raises CBitcoinAddressError if the scriptPubKey isn't of the correct form.

(cls, scriptPubKey)

Source from the content-addressed store, hash-verified

305
306 @classmethod
307 def from_scriptPubKey(cls, scriptPubKey):
308 """Convert a scriptPubKey to a P2WPKH address
309
310 Raises CBitcoinAddressError if the scriptPubKey isn't of the correct
311 form.
312 """
313 if scriptPubKey.is_witness_v0_keyhash():
314 return cls.from_bytes(0, scriptPubKey[2:22])
315 else:
316 raise CBitcoinAddressError('not a P2WPKH scriptPubKey')
317
318 def to_scriptPubKey(self):
319 """Convert an address to a scriptPubKey"""

Callers

nothing calls this directly

Calls 3

is_witness_v0_keyhashMethod · 0.80
from_bytesMethod · 0.45

Tested by

no test coverage detected