basicswap_miserver/basicswap/chainparams.py

201 lines
5.2 KiB
Python
Raw Normal View History

2019-07-17 15:12:06 +00:00
# -*- coding: utf-8 -*-
# Copyright (c) 2019 tecnovert
# Distributed under the MIT software license, see the accompanying
2020-10-30 08:55:45 +00:00
# file LICENSE or http://www.opensource.org/licenses/mit-license.php.
2019-07-17 15:12:06 +00:00
from enum import IntEnum
from .util import (
COIN,
2020-11-28 23:04:26 +00:00
format_amount
2019-07-17 15:12:06 +00:00
)
2020-11-07 11:08:07 +00:00
XMR_COIN = 10 ** 12
2019-07-17 15:12:06 +00:00
class Coins(IntEnum):
PART = 1
BTC = 2
LTC = 3
2020-11-27 17:52:26 +00:00
# DCR = 4
2019-07-24 17:26:04 +00:00
NMC = 5
2020-10-31 20:08:30 +00:00
XMR = 6
2019-07-17 15:12:06 +00:00
chainparams = {
Coins.PART: {
'name': 'particl',
'ticker': 'PART',
'message_magic': 'Bitcoin Signed Message:\n',
2019-07-25 09:29:48 +00:00
'blocks_target': 60 * 2,
2020-11-07 11:08:07 +00:00
'decimal_places': 8,
2019-07-17 15:12:06 +00:00
'mainnet': {
'rpcport': 51735,
'pubkey_address': 0x38,
'script_address': 0x3c,
'key_prefix': 0x6c,
'hrp': 'pw',
'bip44': 44,
'min_amount': 1000,
'max_amount': 100000 * COIN,
},
'testnet': {
'rpcport': 51935,
'pubkey_address': 0x76,
'script_address': 0x7a,
'key_prefix': 0x2e,
'hrp': 'tpw',
'bip44': 1,
'min_amount': 1000,
'max_amount': 100000 * COIN,
},
'regtest': {
'rpcport': 51936,
'pubkey_address': 0x76,
'script_address': 0x7a,
'key_prefix': 0x2e,
'hrp': 'rtpw',
'bip44': 1,
'min_amount': 1000,
'max_amount': 100000 * COIN,
}
},
Coins.BTC: {
'name': 'bitcoin',
'ticker': 'BTC',
'message_magic': 'Bitcoin Signed Message:\n',
2019-07-25 09:29:48 +00:00
'blocks_target': 60 * 10,
2020-11-07 11:08:07 +00:00
'decimal_places': 8,
2019-07-17 15:12:06 +00:00
'mainnet': {
'rpcport': 8332,
'pubkey_address': 0,
'script_address': 5,
'hrp': 'bc',
'bip44': 0,
'min_amount': 1000,
'max_amount': 100000 * COIN,
},
'testnet': {
'rpcport': 18332,
'pubkey_address': 111,
'script_address': 196,
'hrp': 'tb',
'bip44': 1,
'min_amount': 1000,
'max_amount': 100000 * COIN,
'name': 'testnet3',
2019-07-17 15:12:06 +00:00
},
'regtest': {
'rpcport': 18443,
'pubkey_address': 111,
'script_address': 196,
'hrp': 'bcrt',
'bip44': 1,
'min_amount': 1000,
'max_amount': 100000 * COIN,
}
},
Coins.LTC: {
'name': 'litecoin',
'ticker': 'LTC',
'message_magic': 'Litecoin Signed Message:\n',
2019-07-25 09:29:48 +00:00
'blocks_target': 60 * 1,
2020-11-07 11:08:07 +00:00
'decimal_places': 8,
2019-07-17 15:12:06 +00:00
'mainnet': {
'rpcport': 9332,
'pubkey_address': 48,
'script_address': 50,
'hrp': 'ltc',
'bip44': 2,
'min_amount': 1000,
'max_amount': 100000 * COIN,
},
'testnet': {
'rpcport': 19332,
'pubkey_address': 111,
'script_address': 58,
'hrp': 'tltc',
'bip44': 1,
'min_amount': 1000,
'max_amount': 100000 * COIN,
2019-07-24 17:26:04 +00:00
'name': 'testnet4',
2019-07-17 15:12:06 +00:00
},
'regtest': {
'rpcport': 19443,
'pubkey_address': 111,
'script_address': 58,
'hrp': 'rltc',
'bip44': 1,
'min_amount': 1000,
'max_amount': 100000 * COIN,
}
2019-07-24 17:26:04 +00:00
},
Coins.NMC: {
'name': 'namecoin',
'ticker': 'NMC',
'message_magic': 'Namecoin Signed Message:\n',
2019-07-25 09:29:48 +00:00
'blocks_target': 60 * 10,
2020-11-07 11:08:07 +00:00
'decimal_places': 8,
2019-07-24 17:26:04 +00:00
'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,
}
2020-10-31 20:08:30 +00:00
},
Coins.XMR: {
'name': 'monero',
'ticker': 'XMR',
'client': 'xmr',
2020-11-07 11:08:07 +00:00
'decimal_places': 12,
2020-10-31 20:08:30 +00:00
'mainnet': {
'rpcport': 18081,
'walletrpcport': 18082,
2020-11-07 11:08:07 +00:00
'min_amount': 100000,
'max_amount': 10000 * XMR_COIN,
2020-10-31 20:08:30 +00:00
},
'testnet': {
'rpcport': 28081,
'walletrpcport': 28082,
2020-11-07 11:08:07 +00:00
'min_amount': 100000,
'max_amount': 10000 * XMR_COIN,
2020-10-31 20:08:30 +00:00
},
'regtest': {
'rpcport': 18081,
'walletrpcport': 18082,
2020-11-07 11:08:07 +00:00
'min_amount': 100000,
'max_amount': 10000 * XMR_COIN,
2020-10-31 20:08:30 +00:00
}
2019-07-17 15:12:06 +00:00
}
}
2020-10-31 20:08:30 +00:00
2020-11-27 17:52:26 +00:00
2020-10-31 20:08:30 +00:00
class CoinInterface:
2020-11-27 22:20:35 +00:00
def format_amount(self, amount_int):
2020-11-28 23:04:26 +00:00
return format_amount(amount_int, self.exp())
2020-11-27 22:20:35 +00:00
def coin_name(self):
return chainparams[self.coin_type()]['name'].capitalize()