From dd692fe5ef8218f31f7e5997abb39d50e762354a Mon Sep 17 00:00:00 2001 From: tecnovert Date: Wed, 24 Jul 2019 19:26:04 +0200 Subject: [PATCH] Add namecoin chainparams. --- basicswap/basicswap.py | 14 +++++++------- basicswap/chainparams.py | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 7 deletions(-) diff --git a/basicswap/basicswap.py b/basicswap/basicswap.py index d10a9ab..0c39ab0 100644 --- a/basicswap/basicswap.py +++ b/basicswap/basicswap.py @@ -496,9 +496,8 @@ class BasicSwap(): # Defaults self.coin_clients = {} - self.coin_clients[Coins.PART] = self.setDefaultConnectParams(Coins.PART) - self.coin_clients[Coins.BTC] = self.setDefaultConnectParams(Coins.BTC) - self.coin_clients[Coins.LTC] = self.setDefaultConnectParams(Coins.LTC) + for c in Coins: + self.coin_clients[c] = self.setDefaultConnectParams(c) if self.chain == 'regtest': SMSG_SECONDS_IN_DAY = 600 @@ -557,9 +556,10 @@ class BasicSwap(): elif 'rpcpassword' in chain_client_settings: rpcauth = chain_client_settings['rpcuser'] + ':' + chain_client_settings['rpcpassword'] if rpcauth is None: - testnet_name = '' if self.chain == 'mainnet' else self.chain - if testnet_name == 'testnet' and coin != Coins.PART: - testnet_name += '4' + if self.chain == 'mainnet': + testnet_name = '' + else: + testnet_name = chainparams[coin][self.chain].get('name', self.chain) authcookiepath = os.path.join(datadir, testnet_name, '.cookie') # Wait for daemon to start for i in range(10): @@ -891,7 +891,7 @@ class BasicSwap(): if override_feerate: return override_feerate try: - return self.callcoinrpc(coin_type, 'estimatesmartfee', [1])['feerate'] + return self.callcoinrpc(coin_type, 'estimatesmartfee', [2])['feerate'] except Exception: try: fee_rate = self.callcoinrpc(coin_type, 'getwalletinfo')['paytxfee'] diff --git a/basicswap/chainparams.py b/basicswap/chainparams.py index ecc6f3d..aa5bf41 100644 --- a/basicswap/chainparams.py +++ b/basicswap/chainparams.py @@ -15,6 +15,7 @@ class Coins(IntEnum): BTC = 2 LTC = 3 # DCR = 4 + NMC = 5 chainparams = { @@ -74,6 +75,7 @@ chainparams = { 'bip44': 1, 'min_amount': 1000, 'max_amount': 100000 * COIN, + 'name': 'testnet4', }, 'regtest': { 'rpcport': 18443, @@ -106,6 +108,7 @@ chainparams = { 'bip44': 1, 'min_amount': 1000, 'max_amount': 100000 * COIN, + 'name': 'testnet4', }, 'regtest': { 'rpcport': 19443, @@ -116,5 +119,38 @@ chainparams = { 'min_amount': 1000, 'max_amount': 100000 * COIN, } + }, + Coins.NMC: { + 'name': 'namecoin', + 'ticker': 'NMC', + 'message_magic': 'Namecoin Signed Message:\n', + 'mainnet': { + 'rpcport': 8336, + 'pubkey_address': 52, + 'script_address': 13, + 'hrp': 'nc', + 'bip44': 7, + 'min_amount': 1000, + 'max_amount': 100000 * COIN, + }, + 'testnet': { + 'rpcport': 18336, + 'pubkey_address': 111, + 'script_address': 196, + 'hrp': 'tn', + 'bip44': 1, + 'min_amount': 1000, + 'max_amount': 100000 * COIN, + 'name': 'testnet3', + }, + 'regtest': { + 'rpcport': 18443, + 'pubkey_address': 111, + 'script_address': 196, + 'hrp': 'ncrt', + 'bip44': 1, + 'min_amount': 1000, + 'max_amount': 100000 * COIN, + } } }