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

Class CBitcoinAddress

bitcoin/wallet.py:27–55  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25
26
27class CBitcoinAddress(object):
28
29 def __new__(cls, s):
30 try:
31 return CBech32BitcoinAddress(s)
32 except bitcoin.bech32.Bech32Error:
33 pass
34
35 try:
36 return CBase58BitcoinAddress(s)
37 except bitcoin.base58.Base58Error:
38 pass
39
40 raise CBitcoinAddressError('Unrecognized encoding for bitcoin address')
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
58class CBitcoinAddressError(Exception):

Callers 12

getaccountaddressMethod · 0.90
getnewaddressMethod · 0.90
getrawchangeaddressMethod · 0.90
listunspentMethod · 0.90
validateaddressMethod · 0.90
make_txoutFunction · 0.90
getnewaddressMethod · 0.90
TMethod · 0.85
test_wrong_nVersionMethod · 0.85

Calls

no outgoing calls

Tested by 2

TMethod · 0.68
test_wrong_nVersionMethod · 0.68