本文整理匯總了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