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

Method from_scriptPubKey

bitcoin/wallet.py:284–293  ·  view source on GitHub ↗

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

(cls, scriptPubKey)

Source from the content-addressed store, hash-verified

282
283 @classmethod
284 def from_scriptPubKey(cls, scriptPubKey):
285 """Convert a scriptPubKey to a P2WSH address
286
287 Raises CBitcoinAddressError if the scriptPubKey isn't of the correct
288 form.
289 """
290 if scriptPubKey.is_witness_v0_scripthash():
291 return cls.from_bytes(0, scriptPubKey[2:34])
292 else:
293 raise CBitcoinAddressError('not a P2WSH scriptPubKey')
294
295 def to_scriptPubKey(self):
296 """Convert an address to a scriptPubKey"""

Callers

nothing calls this directly

Calls 3

from_bytesMethod · 0.45

Tested by

no test coverage detected