def connect_to_local(filename=None):
    """
    Connect to default dogecoin instance owned by this user, on this machine.

    Returns a :class:`~dogecoinrpc.connection.DogecoinConnection` object.

    Arguments:

        - `filename`: Path to a configuration file in a non-standard location (optional)
    """
    from dogecoinrpc.connection import DogecoinConnection
    from dogecoinrpc.config import read_default_config

    cfg = read_default_config(filename)
    if cfg is None:
        cfg = {}
    #port = int(cfg.get('rpcport', '18332' if cfg.get('testnet') else '22555'))
    port = int(cfg.get('rpcport', '22555'))
    rpcuser = cfg.get('rpcuser', '')
    rpcpassword = cfg.get('rpcpassword', '')

    return DogecoinConnection(rpcuser, rpcpassword, 'localhost', port)
Exemple #2
0
def connect_to_local(filename=None):
    """
    Connect to default dogecoin instance owned by this user, on this machine.

    Returns a :class:`~dogecoinrpc.connection.DogecoinConnection` object.

    Arguments:

        - `filename`: Path to a configuration file in a non-standard location (optional)
    """
    from dogecoinrpc.connection import DogecoinConnection
    from dogecoinrpc.config import read_default_config

    cfg = read_default_config(filename)
    if cfg is None:
        cfg = {}
    #port = int(cfg.get('rpcport', '18332' if cfg.get('testnet') else '22555'))
    port = int(cfg.get('rpcport', '22555'))
    rpcuser = cfg.get('rpcuser', '')
    rpcpassword = cfg.get('rpcpassword', '')

    return DogecoinConnection(rpcuser, rpcpassword, 'localhost', port)
Exemple #3
0
parser.add_argument('--nolocal',
                    help="Don't use connect_to_local",
                    action='store_true')
parser.add_argument('--noremote',
                    help="Don't use connect_to_remote",
                    action='store_true')
args = parser.parse_args()

if __name__ == "__main__":

    if args.config:
        from dogecoinrpc.config import read_config_file
        cfg = read_config_file(args.config)
    else:
        from dogecoinrpc.config import read_default_config
        cfg = read_default_config(None)
    port = int(cfg.get('rpcport', '22555'))
    rpcuser = cfg.get('rpcuser', '')

    connections = []
    if not args.nolocal:
        local_conn = dogecoinrpc.connect_to_local(
        )  # will use read_default_config
        connections.append(local_conn)
    if not args.noremote:
        remote_conn = dogecoinrpc.connect_to_remote(
            user=rpcuser,
            password=cfg['rpcpassword'],
            host='localhost',
            port=port,
            use_https=False)
parser = argparse.ArgumentParser()
parser.add_argument('--config', help="Specify configuration file")
parser.add_argument('--nolocal', help="Don't use connect_to_local",
                    action='store_true')
parser.add_argument('--noremote', help="Don't use connect_to_remote",
                    action='store_true')
args = parser.parse_args()

if __name__ == "__main__":

    if args.config:
        from dogecoinrpc.config import read_config_file
        cfg = read_config_file(args.config)
    else:
        from dogecoinrpc.config import read_default_config
        cfg = read_default_config(None)
    port = int(cfg.get('rpcport', '22555'))
    rpcuser = cfg.get('rpcuser', '')

    connections = []
    if not args.nolocal:
        local_conn = dogecoinrpc.connect_to_local()  # will use read_default_config
        connections.append(local_conn)
    if not args.noremote:
        remote_conn = dogecoinrpc.connect_to_remote(
                user=rpcuser, password=cfg['rpcpassword'], host='localhost',
                port=port, use_https=False)
        connections.append(remote_conn)

    for conn in connections:
        assert(conn.getinfo().testnet) # don't test on prodnet