def __init__(self, import_config=None): self.store_conn = store.DataStoreConnection("wallet.db") self.wallet_config = store.PersistentDictStore(self.store_conn.conn, "wallet") if import_config: self.import_config(import_config) self.wallet_model = None
def init_colordata(self): from coloredcoinlib import agent from coloredcoinlib import blockchain from coloredcoinlib import builder from coloredcoinlib import colordef from coloredcoinlib import store # Ripped from test.py config = None with open("config.json", "r") as fp: config = json.load(fp) blockchain_state = blockchain.BlockchainState(config['url']) self.store_conn = store.DataStoreConnection("color.db") cdstore = store.ColorDataStore(self.store_conn.conn) metastore = store.ColorMetaStore(self.store_conn.conn) genesis = config['genesis'] colordef1 = colordef.OBColorDefinition(1, genesis) colordefman = agent.ColorDefinitionManager() cdbuilder = builder.FullScanColorDataBuilder(cdstore, blockchain_state, colordef1, metastore) mempoolcd = agent.MempoolColorData(blockchain_state) self.colordata = agent.ThickColorData(cdbuilder, mempoolcd, blockchain_state, colordefman, cdstore) self.colordata.update()
def __init__(self, config): params = config.get('ccc', {}) self.testnet = config.get('testnet', False) from coloredcoinlib import blockchain from coloredcoinlib import builder from coloredcoinlib import store from coloredcoinlib import colormap from coloredcoinlib import colordata from electrum import EnhancedBlockchainState if self.testnet: self.blockchain_state = blockchain.BlockchainState( None, self.testnet) else: self.blockchain_state = EnhancedBlockchainState( "btc.it-zone.org", 50001) self.store_conn = store.DataStoreConnection( params.get("color.db", "color.db")) self.cdstore = store.ColorDataStore(self.store_conn.conn) self.metastore = store.ColorMetaStore(self.store_conn.conn) self.colormap = colormap.ColorMap(self.metastore) cdbuilder = builder.ColorDataBuilderManager( self.colormap, self.blockchain_state, self.cdstore, self.metastore, builder.FullScanColorDataBuilder) self.colordata = colordata.ThickColorData(cdbuilder, self.blockchain_state, self.cdstore)
def __init__(self, wallet_path=None, import_config=None): """Create a persistent wallet. If a configuration is passed in, put that configuration into the db by overwriting the relevant data, never deleting. Otherwise, load with the configuration from the persistent data-store. """ if wallet_path is None: wallet_path = "wallet.db" self.store_conn = store.DataStoreConnection(wallet_path, True) self.store_conn.conn.row_factory = sqlite3.Row self.wallet_config = store.PersistentDictStore( self.store_conn.conn, "wallet") if import_config: self.import_config(import_config) self.wallet_model = None
def __init__(self, config): params = config.get('ccc') from coloredcoinlib import agent from coloredcoinlib import blockchain from coloredcoinlib import builder from coloredcoinlib import colordef from coloredcoinlib import store from coloredcoinlib import colormap self.blockchain_state = blockchain.BlockchainState( params.get('bitcoind_url')) self.store_conn = store.DataStoreConnection( params.get("color.db", "color.db")) self.cdstore = store.ColorDataStore(self.store_conn.conn) self.metastore = store.ColorMetaStore(self.store_conn.conn) self.colormap = colormap.ColorMap(self.metastore)
def __init__(self, wallet_path, testnet): """Create a persistent wallet. If a configuration is passed in, put that configuration into the db by overwriting the relevant data, never deleting. Otherwise, load with the configuration from the persistent data-store. """ if wallet_path is None: if testnet: wallet_path = "testnet.wallet" else: wallet_path = "mainnet.wallet" new_wallet = not os.path.exists(wallet_path) self.store_conn = store.DataStoreConnection(wallet_path, True) self.store_conn.conn.row_factory = sqlite3.Row self.wallet_config = store.PersistentDictStore(self.store_conn.conn, "wallet") if new_wallet: self.initialize_new_wallet(testnet) if testnet and not self.wallet_config['testnet']: raise Exception("not a testnet wallet") self.wallet_model = None
def __init__(self, config): """Creates a Colored Coin Context given a config <config> """ params = config.get('ccc', {}) self.testnet = config.get('testnet', False) self.klass = TestnetAddress if self.testnet else Address self.blockchain_state = blockchain.BlockchainState.from_url( None, self.testnet) if not self.testnet: ok = False try: # try fetching transaction from the second block of # the bitcoin blockchain to see whether txindex works self.blockchain_state.bitcoind.getrawtransaction( "9b0fc92260312ce44e74ef369f5c66bbb85848f2eddd5" "a7a1cde251e54ccfdd5") ok = True except Exception as e: pass if not ok: # use Electrum to request transactions self.blockchain_state = EnhancedBlockchainState( "electrum.cafebitcoin.com", 50001) self.store_conn = store.DataStoreConnection( params.get("colordb_path", "color.db")) self.cdstore = store.ColorDataStore(self.store_conn.conn) self.metastore = store.ColorMetaStore(self.store_conn.conn) self.colormap = colormap.ColorMap(self.metastore) cdbuilder = builder.ColorDataBuilderManager( self.colormap, self.blockchain_state, self.cdstore, self.metastore, builder.FullScanColorDataBuilder) self.colordata = colordata.ThickColorData(cdbuilder, self.blockchain_state, self.cdstore)
def test_coloredcoin(self): blockchain_state = blockchain.BlockchainState.from_url( "http://*****:*****@localhost:18332/") # FIXME: this should be mocked, or should use test data store_conn = store.DataStoreConnection("color.db") cdstore = store.ColorDataStore(store_conn.conn) metastore = store.ColorMetaStore(store_conn.conn) genesis = { 'txhash': 'b1586cd10b32f78795b86e9a3febe58dcb59189175fad884a7f4a6623b77486e', 'outindex': 0, 'height': 46442 } colordef1 = colordef.OBColorDefinition(1, genesis) cdbuilder = builder.FullScanColorDataBuilder(cdstore, blockchain_state, colordef1, metastore) cdata = colordata.ThickColorData(cdbuilder, blockchain_state, cdstore)