本文整理汇总了Python中indy.wallet.delete_wallet方法的典型用法代码示例。如果您正苦于以下问题:Python wallet.delete_wallet方法的具体用法?Python wallet.delete_wallet怎么用?Python wallet.delete_wallet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类indy.wallet
的用法示例。
在下文中一共展示了wallet.delete_wallet方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setup
# 需要导入模块: from indy import wallet [as 别名]
# 或者: from indy.wallet import delete_wallet [as 别名]
def setup(self, config):
if not 'ledger_name' in config:
raise Exception(
"The Indy provider requires a 'ledger_name' value in config.toml")
self.pool_name = config['ledger_name']
if not 'ledger_url' in config:
raise Exception(
"The Indy provider requires a 'ledger_url' value in config.toml")
self.ledger_url = config['ledger_url']
if not 'ledger_apts_seed' in config:
raise Exception(
"The Indy provider requires a 'ledger_apts_seed' value in config.toml")
seed = config['ledger_apts_seed']
id = config.get('name', 'test')
key = config.get('pass', 'testpw')
self.cfg = json.dumps({'id': id})
self.creds = json.dumps({'key': key})
self.seed = json.dumps({'seed': seed})
try:
await wallet.delete_wallet(self.cfg, self.creds)
except Exception as e:
pass
await wallet.create_wallet(self.cfg, self.creds)
self.wallet = await wallet.open_wallet(self.cfg, self.creds)
self.master_secret_id = await anoncreds.prover_create_master_secret(self.wallet, None)
(self.did, self.verkey) = await did.create_and_store_my_did(self.wallet, self.seed)
# Download the genesis file
resp = await aiohttp.ClientSession().get(self.ledger_url)
genesis = await resp.read()
genesisFileName = "genesis.apts"
with open(genesisFileName, 'wb') as output:
output.write(genesis)
await self._open_pool({'genesis_txn': genesisFileName})
示例2: wallet_handle
# 需要导入模块: from indy import wallet [as 别名]
# 或者: from indy.wallet import delete_wallet [as 别名]
def wallet_handle(config, logger):
wallet_config = (
json.dumps({
'id': config.wallet_name,
'storage_config': {
'path': config.wallet_path
}
}),
json.dumps({'key': 'test-agent'})
)
# Initialization steps
# -- Create wallet
logger.debug('Creating wallet: {}'.format(config.wallet_name))
try:
await wallet.create_wallet(*wallet_config)
except:
pass
# -- Open a wallet
logger.debug('Opening wallet: {}'.format(config.wallet_name))
wallet_handle = await wallet.open_wallet(*wallet_config)
yield wallet_handle
# Cleanup
if config.clear_wallets:
logger.debug("Closing wallet")
await wallet.close_wallet(wallet_handle)
logger.debug("deleting wallet")
await wallet.delete_wallet(*wallet_config)
logger.debug("removing wallet directory")
os.rmdir(config.wallet_path)
示例3: wallet_destructor
# 需要导入模块: from indy import wallet [as 别名]
# 或者: from indy.wallet import delete_wallet [as 别名]
def wallet_destructor(wallet_handle, wallet_config, wallet_credentials):
await wallet.close_wallet(wallet_handle)
await wallet.delete_wallet(wallet_config, wallet_credentials)
示例4: connect_wallet
# 需要导入模块: from indy import wallet [as 别名]
# 或者: from indy.wallet import delete_wallet [as 别名]
def connect_wallet(self, agent_name, passphrase, ephemeral=False):
""" Create if not already exists and open wallet.
"""
self.owner = agent_name
wallet_suffix = "wallet"
if ephemeral:
wallet_suffix = "ephemeral_wallet"
wallet_name = '{}-{}'.format(self.owner, wallet_suffix)
wallet_config = json.dumps({"id": wallet_name})
wallet_credentials = json.dumps({"key": passphrase})
# Handle ephemeral wallets
if ephemeral:
try:
await wallet.delete_wallet(wallet_config, wallet_credentials)
print("Removing ephemeral wallet.")
except error.IndyError as e:
if e.error_code is error.ErrorCode.WalletNotFoundError:
pass # This is ok, and expected.
else:
print("Unexpected Indy Error: {}".format(e))
except Exception as e:
print(e)
# pylint: disable=bare-except
try:
await wallet.create_wallet(wallet_config, wallet_credentials)
except error.IndyError as e:
if e.error_code is error.ErrorCode.WalletAlreadyExistsError:
pass # This is ok, and expected.
else:
print("Unexpected Indy Error: {}".format(e))
except Exception as e:
print(e)
try:
if self.wallet_handle:
await wallet.close_wallet(self.wallet_handle)
self.wallet_handle = await wallet.open_wallet(
wallet_config,
wallet_credentials
)
(_, self.endpoint_vk) = await did.create_and_store_my_did(self.wallet_handle, "{}")
self.initialized = True
except Exception as e:
print(e)
print("Could not open wallet!")
raise WalletConnectionException