示例#1
0
class TestElectrum(unittest.TestCase):

    def setUp(self):
        self.server_url = "electrum.cafebitcoin.com"
        self.ei = ElectrumInterface(self.server_url, 50001)
        self.bcs = EnhancedBlockchainState(self.server_url, 50001)
        self.txhash = 'b1c68049c1349399fb867266fa146a854c16cd8a18a01d3cd7921ab9d5af1a8b'
        self.height = 277287
        self.raw_tx = '01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff4803273b04062f503253482f049fe1bd5208ee5f364f06648bae2e522cfabe6d6de0a3e574e400f64403ea10de4ff3bc0dcb42d49549e273a9faa4eac33b04734804000000000000000000000001cde08d95000000001976a91480ad90d403581fa3bf46086a91b2d9d4125db6c188ac00000000'
        self.address = '1CC3X2gu58d6wXUWMffpuzN9JAfTUWu4Kj'

    def test_connect(self):
        self.assertRaises(ConnectionError, ElectrumInterface, 'cnn.com', 50001)

    def test_get_utxo(self):
        self.assertEqual(self.ei.get_utxo(self.address), [])

    def test_get_version(self):
        self.assertTrue(float(self.ei.get_version()) >= 0.8)

    def test_get_raw_transaction(self):
        self.assertEqual(self.ei.get_raw_transaction(self.txhash, self.height),
                         self.raw_tx)

        self.assertEqual(self.bcs.get_raw_transaction(self.txhash), self.raw_tx)

    def test_get_height(self):
        self.assertEqual(self.bcs.get_tx_block_height(self.txhash)[0], self.height)

    def test_get_tx(self):
        self.assertEqual(self.bcs.get_tx(self.txhash).hash, self.txhash)
示例#2
0
class TestElectrum(unittest.TestCase):
    def setUp(self):
        self.server_url = "electrum.cafebitcoin.com"
        self.ei = ElectrumInterface(self.server_url, 50001)
        self.bcs = EnhancedBlockchainState(self.server_url, 50001)
        self.txhash = 'b1c68049c1349399fb867266fa146a854c16cd8a18a01d3cd7921ab9d5af1a8b'
        self.height = 277287
        self.raw_tx = '01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff4803273b04062f503253482f049fe1bd5208ee5f364f06648bae2e522cfabe6d6de0a3e574e400f64403ea10de4ff3bc0dcb42d49549e273a9faa4eac33b04734804000000000000000000000001cde08d95000000001976a91480ad90d403581fa3bf46086a91b2d9d4125db6c188ac00000000'
        self.address = '1CC3X2gu58d6wXUWMffpuzN9JAfTUWu4Kj'

    def test_connect(self):
        self.assertRaises(ConnectionError, ElectrumInterface, 'cnn.com', 50001)

    def test_get_utxo(self):
        self.assertEqual(self.ei.get_utxo(self.address), [])

    def test_get_version(self):
        self.assertTrue(float(self.ei.get_version()) >= 0.8)

    def test_get_raw_transaction(self):
        self.assertEqual(self.ei.get_raw_transaction(self.txhash, self.height),
                         self.raw_tx)

        self.assertEqual(self.bcs.get_raw_transaction(self.txhash),
                         self.raw_tx)

    def test_get_height(self):
        self.assertEqual(
            self.bcs.get_tx_block_height(self.txhash)[0], self.height)

    def test_get_tx(self):
        self.assertEqual(self.bcs.get_tx(self.txhash).hash, self.txhash)
示例#3
0
 def setUp(self):
     self.server_url = "electrum.pdmc.net"
     self.ei = ElectrumInterface(self.server_url, 50001)
     self.bcs = EnhancedBlockchainState(self.server_url, 50001)
     self.txhash = 'b1c68049c1349399fb867266fa146a854c16cd8a18a01d3cd7921ab9d5af1a8b'
     self.height = 277287
     self.raw_tx = '01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff4803273b04062f503253482f049fe1bd5208ee5f364f06648bae2e522cfabe6d6de0a3e574e400f64403ea10de4ff3bc0dcb42d49549e273a9faa4eac33b04734804000000000000000000000001cde08d95000000001976a91480ad90d403581fa3bf46086a91b2d9d4125db6c188ac00000000'
     self.address = '1CC3X2gu58d6wXUWMffpuzN9JAfTUWu4Kj'
示例#4
0
class TestElectrum(unittest.TestCase):
    def setUp(self):
        self.server_url = "electrum.pdmc.net"
        self.ei = ElectrumInterface(self.server_url, 50001)
        self.bcs = EnhancedBlockchainState(self.server_url, 50001)
        self.txhash = 'b1c68049c1349399fb867266fa146a854c16cd8a18a01d3cd7921ab9d5af1a8b'
        self.height = 277287
        self.raw_tx = '01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff4803273b04062f503253482f049fe1bd5208ee5f364f06648bae2e522cfabe6d6de0a3e574e400f64403ea10de4ff3bc0dcb42d49549e273a9faa4eac33b04734804000000000000000000000001cde08d95000000001976a91480ad90d403581fa3bf46086a91b2d9d4125db6c188ac00000000'
        self.address = '1CC3X2gu58d6wXUWMffpuzN9JAfTUWu4Kj'

    def test_connect(self):
        self.assertRaises(ConnectionError, ElectrumInterface, 'cnn.com', 50001)

    def test_get_utxo(self):
        self.assertEqual(self.ei.get_utxo(self.address), [])

    def test_get_version(self):
        self.assertTrue(float(self.ei.get_version()) >= 0.8)

    def test_get_height(self):
        self.assertTrue(self.ei.get_height() > 296217)

    def test_get_header(self):
        result = self.bcs.get_header(self.height)
        self.assertEqual(
            result['merkle_root'],
            'abe428044058494733596dc9477bb4f55a90e5144c122cacb71fa99d85c10d2c')

    def test_get_merkle(self):
        result = self.bcs.get_merkle(self.txhash)
        self.assertEqual(
            result['merkle'][0],
            '6a6daeb0dd244abe80ee740ec8752d18fcdd60247304fd7e2ede371eade2f756')
        self.assertEqual(
            result['merkle'][-1],
            '0a00d7c8fadc81c033c3c8604c4a151186bf733f10948d785a748def401ce3f7')
        self.assertEqual(result['pos'], 0)
        self.assertEqual(result['block_height'], self.height)

    def test_get_raw_transaction(self):
        self.assertEqual(self.ei.get_raw_transaction(self.txhash, self.height),
                         self.raw_tx)

        self.assertEqual(self.bcs.get_raw_transaction(self.txhash),
                         self.raw_tx)

    def test_get_block_height(self):
        self.assertEqual(
            self.bcs.get_tx_block_height(self.txhash)[0], self.height)

    def test_get_tx(self):
        self.assertEqual(self.bcs.get_tx(self.txhash).hash, self.txhash)
示例#5
0
class TestElectrum(unittest.TestCase):

    def setUp(self):
        self.server_url = "electrum.pdmc.net"
        self.ei = ElectrumInterface(self.server_url, 50001)
        self.bcs = EnhancedBlockchainState(self.server_url, 50001)
        self.txhash = 'b1c68049c1349399fb867266fa146a854c16cd8a18a01d3cd7921ab9d5af1a8b'
        self.height = 277287
        self.raw_tx = '01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff4803273b04062f503253482f049fe1bd5208ee5f364f06648bae2e522cfabe6d6de0a3e574e400f64403ea10de4ff3bc0dcb42d49549e273a9faa4eac33b04734804000000000000000000000001cde08d95000000001976a91480ad90d403581fa3bf46086a91b2d9d4125db6c188ac00000000'
        self.address = '1CC3X2gu58d6wXUWMffpuzN9JAfTUWu4Kj'

    def test_connect(self):
        self.assertRaises(ConnectionError, ElectrumInterface, 'cnn.com', 50001)

    def test_get_utxo(self):
        self.assertEqual(self.ei.get_utxo(self.address), [])

    def test_get_version(self):
        self.assertTrue(Decimal(self.ei.get_version()) >= 0.8)

    def test_get_height(self):
        self.assertTrue(self.ei.get_height() > 296217)

    def test_get_header(self):
        result = self.bcs.get_header(self.height)
        self.assertEqual(
            result['merkle_root'],
            'abe428044058494733596dc9477bb4f55a90e5144c122cacb71fa99d85c10d2c')

    def test_get_merkle(self):
        result = self.bcs.get_merkle(self.txhash)
        self.assertEqual(
            result['merkle'][0],
            '6a6daeb0dd244abe80ee740ec8752d18fcdd60247304fd7e2ede371eade2f756')
        self.assertEqual(
            result['merkle'][-1],
            '0a00d7c8fadc81c033c3c8604c4a151186bf733f10948d785a748def401ce3f7')
        self.assertEqual(result['pos'], 0)
        self.assertEqual(result['block_height'], self.height)

    def test_get_raw_transaction(self):
        self.assertEqual(self.ei.get_raw_transaction(self.txhash, self.height),
                         self.raw_tx)

        self.assertEqual(self.bcs.get_raw_transaction(self.txhash), self.raw_tx)

    def test_get_block_height(self):
        self.assertEqual(self.bcs.get_tx_block_height(self.txhash)[0], self.height)

    def test_get_tx(self):
        self.assertEqual(self.bcs.get_tx(self.txhash).hash, self.txhash)
示例#6
0
 def test_random_merkle(self):
     server_url = "electrum.pdmc.net"
     ei = ElectrumInterface(server_url, 50001)
     bcs = EnhancedBlockchainState(server_url, 50001)
     self.verifier.blockchain_state = bcs
     h = '265db1bc122c4dae20dd0b55d55c7b270fb1378054fe624457b73bc28b5edd55'
     self.verifier.verify_merkle(h)
     self.assertTrue(self.verifier.get_confirmations(h) > 3)
示例#7
0
 def setUp(self):
     self.server_url = "electrum.cafebitcoin.com"
     self.ei = ElectrumInterface(self.server_url, 50001)
     self.bcs = EnhancedBlockchainState(self.server_url, 50001)
     self.txhash = 'b1c68049c1349399fb867266fa146a854c16cd8a18a01d3cd7921ab9d5af1a8b'
     self.height = 277287
     self.raw_tx = '01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff4803273b04062f503253482f049fe1bd5208ee5f364f06648bae2e522cfabe6d6de0a3e574e400f64403ea10de4ff3bc0dcb42d49549e273a9faa4eac33b04734804000000000000000000000001cde08d95000000001976a91480ad90d403581fa3bf46086a91b2d9d4125db6c188ac00000000'
     self.address = '1CC3X2gu58d6wXUWMffpuzN9JAfTUWu4Kj'
示例#8
0
    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)
示例#9
0
 def get_blockchain_state(self):
     server_url = "electrum.pdmc.net"
     ei = ElectrumInterface(server_url, 50001)
     return EnhancedBlockchainState(server_url, 50001)