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

Method from_scriptPubKey

bitcoin/wallet.py:123–140  ·  view source on GitHub ↗

Convert a scriptPubKey to a CBitcoinAddress Returns a CBitcoinAddress subclass, either P2SHBitcoinAddress or P2PKHBitcoinAddress. If the scriptPubKey is not recognized CBitcoinAddressError will be raised.

(cls, scriptPubKey)

Source from the content-addressed store, hash-verified

121
122 @classmethod
123 def from_scriptPubKey(cls, scriptPubKey):
124 """Convert a scriptPubKey to a CBitcoinAddress
125
126 Returns a CBitcoinAddress subclass, either P2SHBitcoinAddress or
127 P2PKHBitcoinAddress. If the scriptPubKey is not recognized
128 CBitcoinAddressError will be raised.
129 """
130 try:
131 return P2SHBitcoinAddress.from_scriptPubKey(scriptPubKey)
132 except CBitcoinAddressError:
133 pass
134
135 try:
136 return P2PKHBitcoinAddress.from_scriptPubKey(scriptPubKey)
137 except CBitcoinAddressError:
138 pass
139
140 raise CBitcoinAddressError('scriptPubKey not a valid base58-encoded address')
141
142
143class P2SHBitcoinAddress(CBase58BitcoinAddress):

Callers

nothing calls this directly

Calls 2

from_scriptPubKeyMethod · 0.45

Tested by

no test coverage detected