Convert a scriptPubKey to a subclass of CBitcoinAddress
(cls, scriptPubKey)
| 41 | |
| 42 | @classmethod |
| 43 | def from_scriptPubKey(cls, scriptPubKey): |
| 44 | """Convert a scriptPubKey to a subclass of CBitcoinAddress""" |
| 45 | try: |
| 46 | return CBech32BitcoinAddress.from_scriptPubKey(scriptPubKey) |
| 47 | except CBitcoinAddressError: |
| 48 | pass |
| 49 | |
| 50 | try: |
| 51 | return CBase58BitcoinAddress.from_scriptPubKey(scriptPubKey) |
| 52 | except CBitcoinAddressError: |
| 53 | pass |
| 54 | |
| 55 | raise CBitcoinAddressError('scriptPubKey is not in a recognized address format') |
| 56 | |
| 57 | |
| 58 | class CBitcoinAddressError(Exception): |