Example #1
0
def test_get_rpc_creds():
    dash_config = dash_conf()
    creds = DashConfig.get_rpc_creds(dash_config, 'testnet')

    for key in ('user', 'password', 'port'):
        assert key in creds
    assert creds.get('user') == 'rpc_ruxcrypto'
    assert creds.get('password') == 'kuw05sqio7bcm8z96o7redv17xws1lw6xpd1qf33'
    assert creds.get('port') == 23505

    dash_config = dash_conf(
        rpcpassword='******', rpcport=23505)
    creds = DashConfig.get_rpc_creds(dash_config, 'testnet')

    for key in ('user', 'password', 'port'):
        assert key in creds
    assert creds.get('user') == 'rpc_ruxcrypto'
    assert creds.get('password') == 'kuw05sqio7bcm8z96o7redv17xws1lw6xpd1qf33'
    assert creds.get('port') == 23505

    no_port_specified = re.sub('\nrpcport=.*?\n', '\n', dash_conf(), re.M)
    creds = DashConfig.get_rpc_creds(no_port_specified, 'testnet')

    for key in ('user', 'password', 'port'):
        assert key in creds
    assert creds.get('user') == 'rpc_ruxcrypto'
    assert creds.get('password') == 'kuw05sqio7bcm8z96o7redv17xws1lw6xpd1qf33'
    assert creds.get('port') == 33505
Example #2
0
def test_dashd():
    config_text = DashConfig.slurp_config_file(config.dash_conf)
    creds = DashConfig.get_rpc_creds(config_text, 'testnet')

    dashd = DashDaemon(
        user     = creds.get('user'),
        password = creds.get('password'),
        port     = creds.get('port')
    )
    assert dashd.rpc_command != None

    assert hasattr(dashd, 'rpc_connection') == True

    # Dash testnet block 0 hash == 00000bafbc94add76cb75e2ec92894837288a481e5c005f6563d91623bf8bc2c
    # test commands without arguments
    info  = dashd.rpc_command('getinfo')

    info_keys = [
        'blocks',
        'connections',
        'difficulty',
        'errors',
        'protocolversion',
        'proxy',
        'testnet',
        'timeoffset',
        'version',
    ]
    for key in info_keys:
        assert key in info
    assert info['testnet'] == True

    # test commands with args
    assert dashd.rpc_command('getblockhash', 0)   == u'00000bafbc94add76cb75e2ec92894837288a481e5c005f6563d91623bf8bc2c'
Example #3
0
def test_get_rpc_creds():
    dash_config = dash_conf()
    creds = DashConfig.get_rpc_creds(dash_config, 'testnet')

    for key in ('user', 'password', 'port'):
        assert key in creds
    assert creds.get('user') == 'dashrpc'
    assert creds.get(
        'password') == 'EwJeV3fZTyTVozdECF627BkBMnNDwQaVLakG3A4wXYyk'
    assert creds.get('port') == 29241

    dash_config = dash_conf(rpcpassword='******', rpcport=8000)
    creds = DashConfig.get_rpc_creds(dash_config, 'testnet')

    for key in ('user', 'password', 'port'):
        assert key in creds
    assert creds.get('user') == 'dashrpc'
    assert creds.get('password') == 's00pers33kr1t'
    assert creds.get('port') == 8000

    no_port_specified = re.sub('\nrpcport=.*?\n', '\n', dash_conf(), re.M)
    creds = DashConfig.get_rpc_creds(no_port_specified, 'testnet')

    for key in ('user', 'password', 'port'):
        assert key in creds
    assert creds.get('user') == 'dashrpc'
    assert creds.get(
        'password') == 'EwJeV3fZTyTVozdECF627BkBMnNDwQaVLakG3A4wXYyk'
    assert creds.get('port') == 18801
Example #4
0
    def from_dash_conf(self, dash_dot_conf):
        from dash_config import DashConfig
        config_text = DashConfig.slurp_config_file(dash_dot_conf)
        creds = DashConfig.get_rpc_creds(config_text, config.network)

        return self(user=creds.get('user'),
                    password=creds.get('password'),
                    port=creds.get('port'))
Example #5
0
    def from_dash_conf(self, dash_dot_conf):
        from dash_config import DashConfig
        config_text = DashConfig.slurp_config_file(dash_dot_conf)
        creds = DashConfig.get_rpc_creds(config_text, config.network)

        creds[u'host'] = config.rpc_host

        return self(**creds)
def main():
    # Get dash.conf location and load key values
    config_text = DashConfig.slurp_config_file(config.dash_conf)

    # Get valid addresses and determine networks used (Main and/or Test)
    addresses = load_address_file(config.address_file)
    networks = get_used_networks(addresses)
    print('Addresses found on {} network(s)'.format(networks))

    # Establish connections to used network(s)
    rpc_connections = {}
    for network in networks:
        rpc_params = DashConfig.get_rpc_creds(config_text, network)
        rpc_connections[network] = RPCHost(rpc_params['user'],
                                           rpc_params['password'],
                                           rpc_params['port'])

    print(rpc_connections)

    poll_addresses(rpc_connections, addresses)
Example #7
0
def test_dashd():
    config_text = DashConfig.slurp_config_file(config.dash_conf)
    network = 'mainnet'
    is_testnet = False
    genesis_hash = u'000001f47616c621df9a832559b9e562176656bc5d7e753018983ad8c0b2d284'
    for line in config_text.split("\n"):
        if line.startswith('testnet=1'):
            network = 'testnet'
            is_testnet = True
            genesis_hash = u'0000095981c16c629ffafa06d096d686486a7698d9ba14db7dfa72fd4a6a36de'

    creds = DashConfig.get_rpc_creds(config_text, network)
    dashd = DashDaemon(**creds)
    assert dashd.rpc_command is not None

    assert hasattr(dashd, 'rpc_connection')

    # Dash testnet block 0 hash == 00000bafbc94add76cb75e2ec92894837288a481e5c005f6563d91623bf8bc2c
    # test commands without arguments
    info = dashd.rpc_command('getinfo')
    info_keys = [
        'blocks',
        'connections',
        'difficulty',
        'errors',
        'protocolversion',
        'proxy',
        'testnet',
        'timeoffset',
        'version',
    ]
    for key in info_keys:
        assert key in info
    assert info['testnet'] is is_testnet

    # test commands with args
    assert dashd.rpc_command('getblockhash', 0) == genesis_hash
Example #8
0
def test_dashd():
    config_text = DashConfig.slurp_config_file(config.dash_conf)
    network = 'mainnet'
    is_testnet = False
    genesis_hash = u'00000ee6635b617e6b850ba638411c956bc5e0b977c2aa466a2116b4b767599c'
    for line in config_text.split("\n"):
        if line.startswith('testnet=1'):
            network = 'testnet'
            is_testnet = True
            genesis_hash = u'000004d72c95dada076575d05dddfb8be794c5ff8e6fa983e18b509995a03740'

    creds = DashConfig.get_rpc_creds(config_text, network)
    dashd = DashDaemon(**creds)
    assert dashd.rpc_command is not None

    assert hasattr(dashd, 'rpc_connection')

    # LUSO testnet block 0 hash == 000004d72c95dada076575d05dddfb8be794c5ff8e6fa983e18b509995a03740
    # test commands without arguments
    info = dashd.rpc_command('getinfo')
    info_keys = [
        'blocks',
        'connections',
        'difficulty',
        'errors',
        'protocolversion',
        'proxy',
        'testnet',
        'timeoffset',
        'version',
    ]
    for key in info_keys:
        assert key in info
    assert info['testnet'] is is_testnet

    # test commands with args
    assert dashd.rpc_command('getblockhash', 0) == genesis_hash
Example #9
0
def test_dashd():
    config_text = DashConfig.slurp_config_file(config.dash_conf)
    network = 'mainnet'
    is_testnet = False
    genesis_hash = u'00000c63f5826a523923939a5adf28657c2a6b76764f1af99bb39437006489d3'
    for line in config_text.split("\n"):
        if line.startswith('testnet=1'):
            network = 'testnet'
            is_testnet = True
            genesis_hash = u'00000341adf1dd4375bef8ff8059b4268fe0282d8a66f8cf5419bd6b13fbb77b'

    creds = DashConfig.get_rpc_creds(config_text, network)
    dashd = DashDaemon(**creds)
    assert dashd.rpc_command is not None

    assert hasattr(dashd, 'rpc_connection')

    # Dash testnet block 0 hash == 00000bafbc94add76cb75e2ec92894837288a481e5c005f6563d91623bf8bc2c
    # test commands without arguments
    info = dashd.rpc_command('getinfo')
    info_keys = [
        'blocks',
        'connections',
        'difficulty',
        'errors',
        'protocolversion',
        'proxy',
        'testnet',
        'timeoffset',
        'version',
    ]
    for key in info_keys:
        assert key in info
    assert info['testnet'] is is_testnet

    # test commands with args
    assert dashd.rpc_command('getblockhash', 0) == genesis_hash
Example #10
0
def test_dashd():
    config_text = DashConfig.slurp_config_file(config.dash_conf)
    network = 'mainnet'
    is_testnet = False
    genesis_hash = u'00000ffd590b1485b3caadc19b22e6379c733355108f107a430458cdf3407ab6'
    for line in config_text.split("\n"):
        if line.startswith('testnet=1'):
            network = 'testnet'
            is_testnet = True
            genesis_hash = u'00000bafbc94add76cb75e2ec92894837288a481e5c005f6563d91623bf8bc2c'

    creds = DashConfig.get_rpc_creds(config_text, network)
    dashd = DashDaemon(**creds)
    assert dashd.rpc_command is not None

    assert hasattr(dashd, 'rpc_connection')

    # Dash testnet block 0 hash == 00000bafbc94add76cb75e2ec92894837288a481e5c005f6563d91623bf8bc2c
    # test commands without arguments
    info = dashd.rpc_command('getinfo')
    info_keys = [
        'blocks',
        'connections',
        'difficulty',
        'errors',
        'protocolversion',
        'proxy',
        'testnet',
        'timeoffset',
        'version',
    ]
    for key in info_keys:
        assert key in info
    assert info['testnet'] is is_testnet

    # test commands with args
    assert dashd.rpc_command('getblockhash', 0) == genesis_hash
Example #11
0
def send_zero_fee_trx(address_to,  amount):
    dashd = DashdApi.from_dash_conf(DashConfig.get_default_dash_conf())

    unspent = dashd.get_unspent_amount()
    if len(unspent) == 0:
        raise Exception("No unspent inputs")
    address_from = unspent[0]["address"]
    tx_in = unspent[0]["txid"]
    vin = unspent[0]["vout"]
    full_amount = float(unspent[0]["amount"])
    change = full_amount - amount
    raw_trx = dashd.create_raw_trx(tx_in, vin, amount, address_to, change, address_from)
    signed = dashd.sign_raw_trx(raw_trx)
    tx_id = dashd.send_raw_trx(signed)

    print tx_id
Example #12
0
def test_slurp_config_file():
    import tempfile

    dash_config = """# basic settings
#testnet=1 # TESTNET
server=1
printtoconsole=1
txindex=1 # enable transaction index
"""

    expected_stripped_config = """server=1
printtoconsole=1
txindex=1 # enable transaction index
"""

    with tempfile.NamedTemporaryFile(mode='w') as temp:
        temp.write(dash_config)
        temp.flush()
        conf = DashConfig.slurp_config_file(temp.name)
        assert conf == expected_stripped_config
Example #13
0
#!/usr/bin/env python
"""
    Set up defaults and read sentinel.conf
"""

import sys, os
sys.path.append(os.path.join(os.path.dirname(__file__), '.'))
sys.path.append(os.path.join(os.path.dirname(__file__), '.', 'lib'))
from dash_config import DashConfig

sentinel_cfg = DashConfig.tokenize('sentinel.conf')


def get_dash_conf():
    home = os.environ.get('HOME')

    dash_conf = os.path.join(home, ".dashcore/dash.conf")
    if sys.platform == 'darwin':
        dash_conf = os.path.join(
            home, "Library/Application Support/DashCore/dash.conf")

    dash_conf = sentinel_cfg.get('dash_conf', dash_conf)

    return dash_conf


def get_network():
    return sentinel_cfg.get('network', 'mainnet')


def get_db_conn():
Example #14
0
"""
    Set up defaults and read dash-address-monitor.conf
"""
import sys
import os
from dash_config import DashConfig

default_config = os.path.normpath(
    os.path.join(os.path.dirname(__file__), '../dash-address-monitor.conf')
)
config_file = os.environ.get('DASH_ADDRESS_MONITOR_CONFIG', default_config)
cfg = DashConfig.tokenize(config_file)


def get_dash_conf():
    home = os.environ.get('HOME')

    dash_conf = os.path.join(home, ".dashcore/dash.conf")
    if sys.platform == 'darwin':
        dash_conf = os.path.join(home, "Library/Application Support/DashCore/dash.conf")

    dash_conf = cfg.get('dash_conf', dash_conf)

    return dash_conf

def get_address_file():
    return cfg.get('address_file', 'addresses.txt')

def get_db_name():
    return cfg.get('db_name', 'balances.dat')
Example #15
0
def instant_send_block():
    dashd = DashdApi.from_dash_conf(DashConfig.get_default_dash_conf())

    for i in range(0, 3):
        tx_id = dashd.instant_send("ye5F5rfx44YqvqCpVvi1SfFS4dvqaqyuDr", 0.1)
        print(tx_id)
Example #16
0
 def from_dash_conf(self, dash_dot_conf):
     from dash_config import DashConfig
     config = DashConfig(DashConfig.get_default_dash_conf())
     creds = config.get_rpc_creds()
     return self(**creds)
Example #17
0
"""
    Set up defaults and read sentinel.conf
"""
import sys
import os
from dash_config import DashConfig

default_sentinel_config = os.path.normpath(
    os.path.join(os.path.dirname(__file__), '../sentinel.conf'))
sentinel_config_file = os.environ.get('SENTINEL_CONFIG',
                                      default_sentinel_config)
sentinel_cfg = DashConfig.tokenize(sentinel_config_file)
sentinel_version = "1.3.0"
min_dashd_proto_version_with_sentinel_ping = 9999  #70207


def get_dash_conf():
    if sys.platform == 'win32':
        dash_conf = os.path.join(os.getenv('APPDATA'), "ScopeCoin/scope.conf")
    else:
        home = os.environ.get('HOME')

        dash_conf = os.path.join(home, ".scopecoin/scope.conf")
        if sys.platform == 'darwin':
            dash_conf = os.path.join(
                home, "Library/Application Support/ScopeCoin/scope.conf")

    dash_conf = sentinel_cfg.get('scope_conf', dash_conf)

    return dash_conf