本文整理汇总了Python中btctxstore.BtcTxStore.create_wallet方法的典型用法代码示例。如果您正苦于以下问题:Python BtcTxStore.create_wallet方法的具体用法?Python BtcTxStore.create_wallet怎么用?Python BtcTxStore.create_wallet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类btctxstore.BtcTxStore
的用法示例。
在下文中一共展示了BtcTxStore.create_wallet方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestValidateWallet
# 需要导入模块: from btctxstore import BtcTxStore [as 别名]
# 或者: from btctxstore.BtcTxStore import create_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: TestGetWalletKey
# 需要导入模块: from btctxstore import BtcTxStore [as 别名]
# 或者: from btctxstore.BtcTxStore import create_wallet [as 别名]
class TestGetWalletKey(unittest.TestCase):
def setUp(self):
self.api = BtcTxStore(dryrun=True, testnet=True)
def test_standard(self):
hwif = self.api.create_wallet()
wif = self.api.get_key(hwif)
self.assertTrue(validate.is_wif_valid(wif, allowable_netcodes=['XTN']))
def test_input_validation(self):
# test correct types
a = self.api.get_key(S_HWIF)
b = self.api.get_key(B_HWIF)
c = self.api.get_key(U_HWIF)
self.assertEqual(a, b, c)
# TODO invalid types
# TODO invalid input data
def test_standards_compliant(self):
pass # FIXME check generated against expected output from 3rd parties
示例3: TestCreateWallet
# 需要导入模块: from btctxstore import BtcTxStore [as 别名]
# 或者: from btctxstore.BtcTxStore import create_wallet [as 别名]
class TestCreateWallet(unittest.TestCase):
def setUp(self):
self.api = BtcTxStore(dryrun=True, testnet=True)
def test_standard(self):
hwif = self.api.create_wallet()
self.assertTrue(validate.is_private_bip32_valid(
hwif, allowable_netcodes=['XTN']
))
def test_random(self):
a = self.api.create_wallet()
b = self.api.create_wallet()
self.assertTrue(a != b)
def test_master_secret(self):
a = self.api.create_wallet(master_secret="foo")
b = self.api.create_wallet(master_secret="foo")
self.assertEqual(a, b)
def test_input_validation(self):
# correct types
a = self.api.create_wallet(master_secret="foo")
b = self.api.create_wallet(master_secret=b"foo")
c = self.api.create_wallet(master_secret=u"foo")
self.assertEqual(a, b, c)
self.assertTrue(self.api.create_wallet(master_secret="üöä") != None)
self.assertTrue(self.api.create_wallet(master_secret=u"üöä") != None)
# incorrect types
def callback():
self.api.create_wallet(master_secret=None)
self.assertRaises(exceptions.InvalidInput, callback)
def callback():
self.api.create_wallet(master_secret=1)
self.assertRaises(exceptions.InvalidInput, callback)
def callback():
self.api.create_wallet(master_secret=object())
self.assertRaises(exceptions.InvalidInput, callback)
def test_standards_compliant(self):
pass # FIXME check generated against expected output from 3rd parties
示例4: setup
# 需要导入模块: from btctxstore import BtcTxStore [as 别名]
# 或者: from btctxstore.BtcTxStore import create_wallet [as 别名]
import storjnode
import time
from crochet import setup
setup()
# isolate swarm
bootstrap_nodes = [("127.0.0.1", 1337)]
# Create nodes.
node_no = 2
nodes = []
for i in range(0, node_no):
# Create node.
btctxstore = BtcTxStore(testnet=False)
node = storjnode.network.Node(
btctxstore.create_wallet(), port=1339 + i, ksize=8,
bootstrap_nodes=[("127.0.0.1", 1337)],
refresh_neighbours_interval=0.0,
store_config={tempfile.mkdtemp(): None},
nat_type="preserving",
node_type="passive",
wan_ip=get_wan_ip(),
passive_port=10500 + i,
disable_data_transfer=False,
simulate_dht=True
)
# Record node.
nodes.append(node)
示例5: Client
# 需要导入模块: from btctxstore import BtcTxStore [as 别名]
# 或者: from btctxstore.BtcTxStore import create_wallet [as 别名]
class Client(object):
def __init__(self, url=common.DEFAULT_URL, debug=False,
max_size=common.DEFAULT_MAX_SIZE,
store_path=common.DEFAULT_STORE_PATH,
config_path=common.DEFAULT_CONFIG_PATH,
set_master_secret=None, set_payout_address=None,
connection_retry_limit=common.DEFAULT_CONNECTION_RETRY_LIMIT,
connection_retry_delay=common.DEFAULT_CONNECTION_RETRY_DELAY):
# FIXME validate master_secret
self.url = url
self.config = None # lazy
self.messanger = None # lazy
self.debug = debug # TODO validate
self.retry_limit = deserialize.positive_integer(connection_retry_limit)
self.retry_delay = deserialize.positive_integer(connection_retry_delay)
self.max_size = deserialize.byte_count(max_size)
# paths
self.config_path = os.path.realpath(config_path) # TODO validate
self._ensure_path_exists(os.path.dirname(self.config_path))
self.store_path = os.path.realpath(store_path)
self._ensure_path_exists(self.store_path)
# validate payout address
self.btctxstore = BtcTxStore()
if set_payout_address and (not self.btctxstore.validate_address(set_payout_address)):
raise exceptions.InvalidAddress(set_payout_address)
self._initialize_config(set_master_secret, set_payout_address)
def _initialize_config(self, set_master_secret, set_payout_address):
if os.path.exists(self.config_path):
self._load_config()
else: # initialize config
if not set_master_secret: # create random master secret
secret_data = base64.b64encode(os.urandom(256))
set_master_secret = secret_data.decode('utf-8')
if not set_payout_address: # use root address if not given
set_payout_address = self._get_root_address(set_master_secret)
if set_master_secret or set_payout_address:
self.config = {
"version": __version__,
"master_secret": set_master_secret,
"payout_address": set_payout_address,
}
config.save(self.config_path, self.config)
def _ensure_path_exists(self, path):
if not os.path.exists(path):
os.makedirs(path)
def _load_config(self):
if self.config is None:
if not os.path.exists(self.config_path):
raise exceptions.ConfigNotFound(self.config_path)
self.config = config.load(self.config_path)
def _get_root_wif(self, master_secret):
master_secret = base64.b64decode(master_secret)
hwif = self.btctxstore.create_wallet(master_secret=master_secret)
return self.btctxstore.get_key(hwif)
def _get_root_address(self, master_secret):
wif = self._get_root_wif(master_secret)
return self.btctxstore.get_address(wif)
def _init_messanger(self):
if self.messanger is None:
wif = self._get_root_wif(self.config["master_secret"])
self.messanger = messaging.Messaging(self.url, wif,
self.retry_limit,
self.retry_delay)
def version(self):
print(__version__)
return __version__
def register(self):
"""Attempt to register the config address."""
self._init_messanger()
registered = self.messanger.register(self.config["payout_address"])
auth_addr = self.messanger.auth_address()
if registered:
print("Address {0} now registered on {1}.".format(auth_addr,
self.url))
else:
print("Failed to register address {0} on {1}.".format(auth_addr,
self.url))
return True
def show_config(self):
"""Display saved config."""
print(json.dumps(self.config, indent=2))
return self.config
def ping(self):
#.........这里部分代码省略.........