Example #1
0
def balance_calc(take=100):
    Config.load([
        "config_bitshares_connection.yaml", "config_bitshares.yaml",
        "config_operation_storage.yaml"
    ])

    pprint(factory.get_operation_storage()._get_balances_recalculate(take))
Example #2
0
def only_blockchain_monitor(start, stop):
    Config.load([
        "config_bitshares_connection.yaml", "config_bitshares_memo_keys.yaml",
        "config_bitshares.yaml", "config_operation_storage.yaml"
    ])
    logging.getLogger(__name__).info(
        "Starting BitShares blockchain monitor ...")
    start_block_monitor(start, stop)
    def setUp(self):
        if Config.data:
            connection.reset()

        Config.load()
        Config.load("../tests/config_test.yaml")
        Config.data["operation_storage"]["use"] = "azuretest"
        Config.data["network_type"] = "Test"
        Config.data["bitshares"]["connection"]["Test"]["nobroadcast"] = True
    def test_wallets(self):
        address = implementations.create_address()

        if Config.get("bitshares", "keep_keys_private", True):
            assert address["privateKey"] == "keep_keys_private"
        else:
            assert address["privateKey"] == Config.get_config(
            )["bitshares"]["exchange_account_active_key"]
        assert Config.get("bitshares",
                          "exchange_account_name") in address["publicAddress"]
Example #5
0
def tracked():
    Config.load([
        "config_bitshares_connection.yaml", "config_bitshares.yaml",
        "config_operation_storage.yaml"
    ])

    storage = factory.get_operation_storage()

    pprint(
        list(
            storage._service.query_entities(
                storage._azure_config["address_table"] + "balance")))
Example #6
0
    def _short_digit_hash(self, value):
        hash_type = Config.get("operation_storage", "key_hash", "type", default="crc32")

        if hash_type == "crc32":
            short_hash = hex(zlib.crc32(value.encode(encoding='UTF-8')))
            short_hash = short_hash[2:len(short_hash)]

        elif hash_type == "sha256":
            checker = hashlib.sha256()
            checker.update(value.encode(encoding='UTF-8'))
            short_hash = checker.hexdigest()
        return short_hash[0:Config.get("operation_storage", "key_hash", "digits", 3)]
    def setUp(self):
        # only load the config we want (no active keys!)
        if Config.data and Config.data.get("network_type", None) != "Test":
            connection.reset()

        Config.load(["config_bitshares_connection.yaml",
                     "config_bitshares_memo_keys.yaml",
                     "config_bitshares.yaml",
                     "config_operation_storage.yaml",
                     "../tests/config_test.yaml"])
        Config.data["operation_storage"]["use"] = "mongodbtest"
        Config.data["network_type"] = "Test"
        Config.data["bitshares"]["connection"]["Test"]["nobroadcast"] = True
Example #8
0
    def test_wallet(self):
        response = self.client.post(url_for('Blockchain.SignService.wallets'))

        response = response.json

        if Config.get("bitshares", "keep_keys_private", True):
            self.assertEqual(response["privateKey"], "keep_keys_private")
        else:
            self.assertEqual(
                response["privateKey"],
                Config.get("bitshares", "exchange_account_active_key"))

        addrs = split_unique_address(response["publicAddress"])

        self.assertEqual(addrs["account_id"],
                         Config.get("bitshares", "exchange_account_id"))

        self.assertEqual(len(addrs["customer_id"]), 36)
Example #9
0
        def flag_completed(block_num):
            network = Config.get("network_type")
            connection = Config.get("bitshares", "connection", network)
            #             connection["keys"] = key
            instance = BitShares(**connection)

            irr = instance.rpc.get_dynamic_global_properties().get(
                "last_irreversible_block_num")
            head = instance.rpc.get_dynamic_global_properties().get(
                "head_block_number")

            print("Blockchain Monitor: Looking for block " + str(block_num),
                  ", current head=" + str(head) + ", irreversible=" + str(irr))

            monitor = BlockchainMonitor(storage=store,
                                        bitshares_instance=instance)
            monitor.start_block = block_num - 1
            monitor.stop_block = block_num + 1
            monitor.listen()
 def test_not_reachable_via_os(self):
     mongodb_config = Config.get_config(
     )["operation_storage"]["mongodbtest"]
     mongodb_config["seeds"] = ["unreachable:1234"]
     client = MongoClient(host=mongodb_config["seeds"],
                          socketTimeoutMS=100,
                          connectTimeoutMS=100,
                          serverSelectionTimeoutMS=100,
                          waitQueueTimeoutMS=100,
                          heartbeatFrequencyMS=500)
     self.assertRaises(OperationStorageLostException,
                       MongoDBOperationsStorage,
                       mongodb_config=mongodb_config,
                       mongodb_client=client)
Example #11
0
def find(txid, customerid, contains, status, incidentid):
    Config.load([
        "config_bitshares_connection.yaml", "config_bitshares.yaml",
        "config_operation_storage.yaml"
    ])

    storage = factory.get_operation_storage()

    def get_all():
        return (storage.get_operations_completed() +
                storage.get_operations_in_progress() +
                storage.get_operations_failed())

    operations = []

    if contains:
        for op in get_all():
            print(op)
            if status is not None and not status == op["status"]:
                continue

            if contains in str(op):
                operations.append(op)

    if incidentid:
        for op in list(
                storage._service.query_entities(
                    storage._operation_tables["incident"])):
            if incidentid in str(op):
                operations.append(op)

    print("---------- finding transfers ---------------")
    print("found: " + str(len(operations)))

    for op in operations:
        pprint(op)
    def test_sign(self):
        tx = {
            "ref_block_num":
            49506,
            "ref_block_prefix":
            2292772274,
            "expiration":
            "2018-01-25T08:29:00",
            "operations": [[
                2, {
                    "fee": {
                        "amount": 9,
                        "asset_id": "1.3.0"
                    },
                    "fee_paying_account": "1.2.126225",
                    "order": "1.7.49956139",
                    "extensions": []
                }
            ]],
            "extensions": [],
            "signatures": [],
        }
        stx = implementations.sign(
            tx,
            [Config.get_config()["bitshares"]["exchange_account_active_key"]])
        stx = json.loads(stx["signedTransaction"])
        self.assertIn("signatures", stx)
        self.assertEqual(len(stx["signatures"]), 1)

        stx = implementations.sign(tx, [
            Config.get_config()["bitshares"]["exchange_account_active_key"],
            self.get_customer_active_key()
        ])
        stx = json.loads(stx["signedTransaction"])
        self.assertIn("signatures", stx)
        self.assertEqual(len(stx["signatures"]), 2)
 def tearDown(self):
     Config.reset()
 def _get_db_config(self):
     config = Config.get_config()["operation_storage"]
     mongodb_config = config["mongodbtest"]
     mongodb_config["operation_collection"] = mongodb_config.get(
         "operation_collection", "operations")
     return mongodb_config
 def setUp(self):
     Config.load()
 def get_customer_memo_key(self):
     """ reads the test account configuration from config_test.yaml
     """
     return Config.get_config()["bitshares"]["customer_account_memo_key"]
Example #17
0
#!/usr/bin/env python3
import click
import time
from bexi import Config, factory
from bexi.connection import requires_blockchain

import logging
import threading
import json
from pprint import pprint
from bexi.operation_storage.exceptions import OperationNotFoundException

config = Config.get("wsgi")


@click.group()
def main():
    pass


@main.command()
@click.option("--host")
@click.option("--port")
def wsgi(host, port):
    host = host or config["host"]
    port = port or config["port"]

    from bexi.wsgi.app import get_manage_service_app, get_sign_service_app

    app = get_manage_service_app()
    app = get_sign_service_app(app)