本文整理汇总了Python中btctxstore.BtcTxStore.validate_wallet方法的典型用法代码示例。如果您正苦于以下问题:Python BtcTxStore.validate_wallet方法的具体用法?Python BtcTxStore.validate_wallet怎么用?Python BtcTxStore.validate_wallet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类btctxstore.BtcTxStore
的用法示例。
在下文中一共展示了BtcTxStore.validate_wallet方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestValidateWallet
# 需要导入模块: from btctxstore import BtcTxStore [as 别名]
# 或者: from btctxstore.BtcTxStore import validate_wallet [as 别名]
class TestValidateWallet(unittest.TestCase):
def setUp(self):
self.testnet_api = BtcTxStore(dryrun=True, testnet=True)
self.mainnet_api = BtcTxStore(dryrun=True, testnet=False)
self.testnet_wallet = self.testnet_api.create_wallet()
self.mainnet_wallet = self.mainnet_api.create_wallet()
self.testnet_key = self.testnet_api.get_key(self.testnet_wallet)
self.mainnet_key = self.mainnet_api.get_key(self.mainnet_wallet)
def test_checks_networks(self):
self.assertTrue(self.testnet_api.validate_wallet(self.testnet_wallet))
self.assertTrue(self.mainnet_api.validate_wallet(self.mainnet_wallet))
self.assertFalse(self.testnet_api.validate_wallet(self.mainnet_wallet))
self.assertFalse(self.mainnet_api.validate_wallet(self.testnet_wallet))
def test_doesnt_validate_keys(self):
self.assertFalse(self.testnet_api.validate_wallet(self.testnet_key))
self.assertFalse(self.mainnet_api.validate_wallet(self.testnet_key))
self.assertFalse(self.testnet_api.validate_wallet(self.mainnet_key))
self.assertFalse(self.mainnet_api.validate_wallet(self.mainnet_key))
def test_correct_types(self):
self.assertTrue(self.testnet_api.validate_wallet(S_HWIF))
self.assertTrue(self.testnet_api.validate_wallet(B_HWIF))
self.assertTrue(self.testnet_api.validate_wallet(U_HWIF))
示例2: Client
# 需要导入模块: from btctxstore import BtcTxStore [as 别名]
# 或者: from btctxstore.BtcTxStore import validate_wallet [as 别名]
class Client(object):
def __init__(self, url=common.DEFAULT_URL, debug=False, quiet=False,
use_folder_tree=False, max_size=common.DEFAULT_MAX_SIZE,
min_free_size=common.DEFAULT_MIN_FREE_SIZE,
store_path=common.DEFAULT_STORE_PATH,
config_path=common.DEFAULT_CONFIG_PATH,
connection_retry_limit=common.DEFAULT_CONNECTION_RETRY_LIMIT,
connection_retry_delay=common.DEFAULT_CONNECTION_RETRY_DELAY):
debug = deserialize.flag(debug)
quiet = deserialize.flag(quiet)
self.url = deserialize.url(url)
self.use_folder_tree = deserialize.flag(use_folder_tree)
self.max_size = deserialize.byte_count(max_size)
self.min_free_size = deserialize.byte_count(min_free_size)
self.messenger = None # lazy
self.btctxstore = BtcTxStore()
self.retry_limit = deserialize.positive_integer(connection_retry_limit)
self.retry_delay = deserialize.positive_integer(connection_retry_delay)
# paths
self.cfg_path = os.path.realpath(config_path)
storjnode.util.ensure_path_exists(os.path.dirname(self.cfg_path))
self.store_path = os.path.realpath(store_path)
storjnode.util.ensure_path_exists(self.store_path)
# check for vfat partions
try:
fstype = storjnode.util.get_fs_type(self.store_path)
# FileNotFoundError: [Errno 2] No such file or directory: '/etc/mtab'
# psutil: https://code.google.com/p/psutil/issues/detail?id=434
except EnvironmentError as e:
logger.warning(e)
fstype = None
if fstype == "vfat":
logger.info("Detected vfat partition, using folder tree.")
self.use_folder_tree = True
if fstype is None:
msg = "Couldn't detected partition type for '{0}'"
logger.warning(msg.format(self.store_path))
self.cfg = storjnode.config.get(self.btctxstore, self.cfg_path)
@staticmethod
def version():
print(__version__)
return __version__
def _init_messenger(self):
"""Make sure messenger exists."""
if self.messenger is None:
wif = self.btctxstore.get_key(self.cfg["wallet"])
self.messenger = messaging.Messaging(self.url, wif,
self.retry_limit,
self.retry_delay)
def register(self):
"""Attempt to register the config address."""
self._init_messenger()
payout_address = self.cfg["payout_address"]
self.messenger.register(payout_address)
logger.info("Registered on server '{0}'.".format(self.url))
return True
def config(self, set_wallet=None, set_payout_address=None):
"""
Set and then show the config settings.
:param set_wallet: Set the HWIF for registration/auth address.
:param set_payout_address: Set the payout address.
:return: Configuation object.
"""
if((set_payout_address is not None) and
(not self.btctxstore.validate_address(set_payout_address))):
raise exceptions.InvalidAddress(set_payout_address)
if((set_wallet is not None) and
(not self.btctxstore.validate_wallet(set_wallet))):
raise exceptions.InvalidHWIF(set_wallet)
self._init_messenger()
config_updated = False
# update payout address if requested
if set_payout_address:
self.cfg["payout_address"] = set_payout_address
config_updated = True
# update wallet if requested
if set_wallet:
self.cfg["wallet"] = set_wallet
config_updated = True
# save config if updated
if config_updated:
storjnode.config.save(self.btctxstore, self.cfg_path, self.cfg)
#.........这里部分代码省略.........
示例3: Client
# 需要导入模块: from btctxstore import BtcTxStore [as 别名]
# 或者: from btctxstore.BtcTxStore import validate_wallet [as 别名]
class Client(object):
def __init__(self, url=common.DEFAULT_URL, debug=False, quiet=False,
use_folder_tree=False, max_size=common.DEFAULT_MAX_SIZE,
store_path=common.DEFAULT_STORE_PATH,
config_path=common.DEFAULT_CONFIG_PATH,
connection_retry_limit=common.DEFAULT_CONNECTION_RETRY_LIMIT,
connection_retry_delay=common.DEFAULT_CONNECTION_RETRY_DELAY):
debug = deserialize.flag(debug)
quiet = deserialize.flag(quiet)
self.url = deserialize.url(url)
self.use_folder_tree = deserialize.flag(use_folder_tree)
self.max_size = deserialize.byte_count(max_size)
self.messenger = None # lazy
self.btctxstore = BtcTxStore()
self.retry_limit = deserialize.positive_integer(connection_retry_limit)
self.retry_delay = deserialize.positive_integer(connection_retry_delay)
# paths
self.cfg_path = os.path.realpath(config_path)
control.util.ensure_path_exists(os.path.dirname(self.cfg_path))
self.store_path = os.path.realpath(store_path)
control.util.ensure_path_exists(self.store_path)
# check for vfat partions
if control.util.get_fs_type(self.store_path) == "vfat":
self.use_folder_tree = True
self.cfg = control.config.get(self.btctxstore, self.cfg_path)
@staticmethod
def version():
print(__version__)
return __version__
def _init_messenger(self):
"""Make sure messenger exists."""
if self.messenger is None:
wif = self.btctxstore.get_key(self.cfg["wallet"])
self.messenger = messaging.Messaging(self.url, wif,
self.retry_limit,
self.retry_delay)
def register(self):
"""Attempt to register the config address."""
self._init_messenger()
payout_address = self.cfg["payout_address"]
self.messenger.register(payout_address)
logger.info("Registered on server '{0}'.".format(self.url))
return True
def config(self, set_wallet=None, set_payout_address=None):
"""
Set and then show the config settings.
:param set_wallet: Set the HWIF for registration/auth address.
:param set_payout_address: Set the payout address.
:return: Configuation object.
"""
if((set_payout_address is not None) and
(not self.btctxstore.validate_address(set_payout_address))):
raise exceptions.InvalidAddress(set_payout_address)
if((set_wallet is not None) and
(not self.btctxstore.validate_wallet(set_wallet))):
raise exceptions.InvalidHWIF(set_wallet)
self._init_messenger()
config_updated = False
# update payout address if requested
if set_payout_address:
self.cfg["payout_address"] = set_payout_address
config_updated = True
# update wallet if requested
if set_wallet:
self.cfg["wallet"] = set_wallet
config_updated = True
# save config if updated
if config_updated:
control.config.save(self.btctxstore, self.cfg_path, self.cfg)
# display config
print(SHOW_CONFIG_TEMPLATE.format(
self.messenger.auth_address(),
self.cfg["payout_address"]
))
return self.cfg
def ping(self):
"""Attempt one keep-alive with the server."""
self._init_messenger()
msg = "Pinging server '{0}' at {1:%Y-%m-%d %H:%M:%S}."
logger.info(msg.format(self.messenger.server_url(), datetime.now()))
self.messenger.ping()
#.........这里部分代码省略.........