def main(runmode=TESTNET): data_directory = "data_testnet" if runmode == TESTNET else "data_main" params = ClientParams(data_directory, runmode=runmode, port=8080, nonce=random.randint(0, 2**64), sub_version_num="/coinpy:0.0.1/", targetpeers=5) reactor = Reactor() client = BitcoinClient(reactor, log.createlogger(), params) client.start()
def get_config_params(params): """Get configuration parameters as ClientParams() object from default_value, configuration file, command_line or function argument """ default_args = ClientParams(data_directory="", logfilename="coinpy.log", runmode=MAIN, port=BITCOIN_PORT[MAIN], nonce=random.randint(0, 2**64), sub_version_num="/coinpy:0.0.1/", targetpeers=10, seeds=[]) client_params = ClientParams() client_params.load(default_args) if params: client_params.load(params) client_params.load(command_line_parameters()) return client_params
def command_line_parameters(): parser = OptionParser() parser.add_option("-d", "--data_directory", dest="data_directory", help="location of data directory", metavar="DIR") parser.add_option("-m", "--runmode", dest="runmode") parser.add_option("-p", "--port", dest="port") parser.add_option("-s", "--seeds", dest="seeds") parser.add_option("-b", "--no-bootstrap", action="store_true", dest="no_bootstrap") parser.add_option("-f", "--no-findpeers", action="store_true", dest="no_findpeers") options, args = parser.parse_args() params = ClientParams() if options.data_directory: params.set(data_directory=options.data_directory) if options.runmode: params.set(runmode={"MAIN" : MAIN, "TESTNET" : TESTNET}[options.runmode]) if options.port: params.set(port=int(options.port)) if options.seeds: params.set(seeds=[SockAddr(ip, int(port)) for ip, port in [addrstr.split(":") for addrstr in options.seeds.split(",")]]) if options.no_bootstrap: params.set(bootstrap=False) if options.no_findpeers: params.set(findpeers=False) return params
presenter.run() if __name__ == '__main__': # testnet faucet: mhFwRrjRNt8hYeWtm9LwqCpCgXjF38RJqn # old peer : 88.114.198.141:18333 mode = 1 if mode == 1: runmode = TESTNET3 data_directory = r"C:\dev\data\data_testnet_3" seeds = [] #seeds = [SockAddr("96.241.176.56", 18333)] #seeds = [SockAddr("69.64.46.74", 18333)] findpeers = True if mode == 2: runmode = TESTNET data_directory = "C:\\dev\\data\\data_testnet" #seeds = [SockAddr("96.241.176.56", 18333)] seeds = [] findpeers = True params = ClientParams( runmode=runmode, port=2000, #BITCOIN_PORT[runmode], data_directory=data_directory, findpeers=findpeers, #seeds = [SockAddr("178.79.163.96", 18333)]) seeds=seeds) #SockAddr("127.0.0.1", 18333) coinpy_gui_client(get_config_params(params))
from coinpy_client.bitcoin_gui_client import coinpy_gui_client from coinpy.model.protocol.runmode import TESTNET from coinpy_client.model.client_params import ClientParams from coinpy_client.config_params import get_config_params def main(params=None): coinpy_gui_client(get_config_params(params)) if __name__ == '__main__': runmode = TESTNET data_directory = "data_testnet" if runmode == TESTNET else "data_main" params = ClientParams(runmode=runmode, data_directory=data_directory) main(params)