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

Method from_scriptPubKey

bitcoin/wallet.py:164–174  ·  view source on GitHub ↗

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

(cls, scriptPubKey)

Source from the content-addressed store, hash-verified

162
163 @classmethod
164 def from_scriptPubKey(cls, scriptPubKey):
165 """Convert a scriptPubKey to a P2SH address
166
167 Raises CBitcoinAddressError if the scriptPubKey isn't of the correct
168 form.
169 """
170 if scriptPubKey.is_p2sh():
171 return cls.from_bytes(scriptPubKey[2:22], bitcoin.params.BASE58_PREFIXES['SCRIPT_ADDR'])
172
173 else:
174 raise CBitcoinAddressError('not a P2SH scriptPubKey')
175
176 def to_scriptPubKey(self):
177 """Convert an address to a scriptPubKey"""

Callers

nothing calls this directly

Calls 3

is_p2shMethod · 0.80
from_bytesMethod · 0.45

Tested by

no test coverage detected