<s> from pycoin . encoding import hash160_sec_to_bitcoin_address <EOL> from coloredcoinlib import ( ColorDataBuilderManager , <EOL> AidedColorDataBuilder , <EOL> FullScanColorDataBuilder , DataStoreConnection , <EOL> ColorDataStore , ColorMetaStore , ColorMap , <EOL> ThickColorData , ThinColorData ) <EOL> from services . electrum import EnhancedBlockchainState <EOL> class ColoredCoinContext ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , config , blockchain_state ) : <EOL> """<STR_LIT>""" <EOL> params = config . get ( '<STR_LIT>' , { } ) <EOL> self . blockchain_state = blockchain_state <EOL> self . testnet = config . get ( '<STR_LIT>' , False ) <EOL> thin = config . get ( '<STR_LIT>' , True ) <EOL> if thin : <EOL> color_data_class = ThinColorData <EOL> color_data_builder = AidedColorDataBuilder <EOL> else : <EOL> color_data_class = ThickColorData <EOL> color_data_builder = FullScanColorDataBuilder <EOL> self . store_conn = DataStoreConnection ( <EOL> params . get ( "<STR_LIT>" , "<STR_LIT>" ) ) <EOL> self . cdstore = ColorDataStore ( self . store_conn . conn ) <EOL> self . metastore = ColorMetaStore ( self . store_conn . conn ) <EOL> self . colormap = ColorMap ( self . metastore ) <EOL> cdbuilder = ColorDataBuilderManager ( <EOL> self . colormap , self . blockchain_state , self . cdstore , <EOL> self . metastore , color_data_builder ) <EOL> self . colordata = color_data_class ( <EOL> cdbuilder , self . blockchain_state , self . cdstore , self . colormap ) <EOL> def raw_to_address ( self , raw_address ) : <EOL> prefix = self . testnet and b'<STR_LIT>' or b"<STR_LIT>" <EOL> return hash160_sec_to_bitcoin_address ( raw_address , <EOL> address_prefix = prefix ) </s>
