Skip to content

Commit

Permalink
Merge pull request #115 from WadeBarnes/feature/new-cli-scripts
Browse files Browse the repository at this point in the history
Feature/new cli scripts
  • Loading branch information
swcurran authored Jun 14, 2020
2 parents 2b81b90 + bca171d commit a2f1407
Show file tree
Hide file tree
Showing 12 changed files with 179 additions and 68 deletions.
6 changes: 3 additions & 3 deletions cli-scripts/attach-wallet
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
# - Example; myorg_issuer
#
# storageType:
# - The wallet storage type.
# - Optional - The wallet storage type. Defaults to 'default'.
# - Remote Wallet Example; postgres_storage
# - Local Wallet Example; default
#
# storageConfig:
# - The wallet storage configuration.
# - Optional - The wallet storage configuration. Defaults to '{}'.
# - Remote Wallet Example; '{"url":"192.168.65.3:5435"}'
# - Local Wallet Example; '{}'
# ===================================================================================

wallet attach ${walletName} storage_type=${storageType} storage_config=${storageConfig}
-wallet attach ${walletName} storage_type=${storageType} storage_config=${storageConfig}
exit
22 changes: 17 additions & 5 deletions cli-scripts/create-signed-cred-def
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,19 @@
# signed by the author. This can all be done in a single command, it does not need
# to be done multiple steps.
#
# Example:
# Examples:
# ./manage \
# indy-cli create-signed-cred-def \
# walletName=myorg_issuer \
# poolName=localpool \
# authorDid=NFP8kaWvCupbDQHQhErwXb \
# endorserDid=DFuDqCYpeDNXLuc3MKooX3 \
# schemaId=10 \
# signatureType=CL \
# tag=tag \
# primaryKey='<primary-from-cred_def.py/>' \
# outputFile=/tmp/ian-permit.ian-co_author_signed_cred_def.txn
#
# ./manage \
# indy-cli create-signed-cred-def \
# walletName=myorg_issuer \
Expand All @@ -40,17 +52,17 @@
# - Example; myorg_issuer
#
# storageType:
# - The wallet storage type.
# - Optional - The wallet storage type. Defaults to 'default'.
# - Remote Wallet Example; postgres_storage
# - Local Wallet Example; default
#
# storageConfig:
# - The wallet storage configuration.
# - Optional - The wallet storage configuration. Defaults to '{}'.
# - Remote Wallet Example; '{"url":"192.168.65.3:5435"}'
# - Local Wallet Example; '{}'
#
# storageCredentials:
# - The wallet storage credentials.
# - Optional - The wallet storage credentials. Defaults to '{}'.
# - Remote Wallet Example; '{"account":"DB_USER","password":"DB_PASSWORD","admin_account":"postgres","admin_password":"mysecretpassword"}'
# - Local Wallet Example; '{}'
#
Expand Down Expand Up @@ -96,7 +108,7 @@ load-plugin library=libindystrgpostgres.so initializer=postgresstorage_init
# Nothing is actually being written or read from the ledger by this script.
pool connect ${poolName}

wallet attach ${walletName} storage_type=${storageType} storage_config=${storageConfig}
-wallet attach ${walletName} storage_type=${storageType} storage_config=${storageConfig}
wallet open ${walletName} key storage_credentials=${storageCredentials}
did use ${authorDid}
ledger cred-def sign=true endorser=${endorserDid} schema_id=${schemaId} signature_type=${signatureType} tag=${tag} primary=${primaryKey}
Expand Down
21 changes: 16 additions & 5 deletions cli-scripts/create-signed-schema
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,18 @@
# signed by the author. This can all be done in a single command, it does not need
# to be done multiple steps.
#
# Example:
# Examples:
# ./manage \
# indy-cli create-signed-schema \
# walletName=myorg_issuer \
# poolName=localpool \
# authorDid=NFP8kaWvCupbDQHQhErwXb \
# endorserDid=DFuDqCYpeDNXLuc3MKooX3 \
# schemaName=ian-permit.ian-co \
# schemaVersion=1.0.0 \
# schemaAttributes=corp_num,legal_name,permit_id,permit_type,permit_issued_date,permit_status,effective_date \
# outputFile=/tmp/ian-permit.ian-co_author_signed_schema.txn
#
# ./manage \
# indy-cli create-signed-schema \
# walletName=myorg_issuer \
Expand All @@ -39,17 +50,17 @@
# - Example; myorg_issuer
#
# storageType:
# - The wallet storage type.
# - Optional - The wallet storage type. Defaults to 'default'.
# - Remote Wallet Example; postgres_storage
# - Local Wallet Example; default
#
# storageConfig:
# - The wallet storage configuration.
# - Optional - The wallet storage configuration. Defaults to '{}'.
# - Remote Wallet Example; '{"url":"192.168.65.3:5435"}'
# - Local Wallet Example; '{}'
#
# storageCredentials:
# - The wallet storage credentials.
# - Optional - The wallet storage credentials. Defaults to '{}'.
# - Remote Wallet Example; '{"account":"DB_USER","password":"DB_PASSWORD","admin_account":"postgres","admin_password":"mysecretpassword"}'
# - Local Wallet Example; '{}'
#
Expand Down Expand Up @@ -90,7 +101,7 @@ load-plugin library=libindystrgpostgres.so initializer=postgresstorage_init
# Nothing is actually being written or read from the ledger by this script.
pool connect ${poolName}

wallet attach ${walletName} storage_type=${storageType} storage_config=${storageConfig}
-wallet attach ${walletName} storage_type=${storageType} storage_config=${storageConfig}
wallet open ${walletName} key storage_credentials=${storageCredentials}
did use ${authorDid}
ledger schema sign=true endorser=${endorserDid} name=${schemaName} version=${schemaVersion} attr_names=${schemaAttributes}
Expand Down
32 changes: 17 additions & 15 deletions cli-scripts/create-wallet
Original file line number Diff line number Diff line change
@@ -1,47 +1,49 @@
# ===================================================================================
# Create remote wallet
# Create wallet
# -----------------------------------------------------------------------------------
# Creates a remote wallet and initializes it with a DID.
# Creates a wallet and initializes it with a DID.
# The user will be prompted for the DID's seed during the process.
# The seed should be a unique 32 character string. It's best if it's randomly
# generated.
#
# Examples:
# ./manage \
# indy-cli create-wallet \
# walletName=endorser_wallet
#
# Example:
# ./manage \
# indy-cli create-wallet \
# walletName=endorser_wallet \
# storageType=default \
# storageConfig='{}' \
# storageCredentials='{}' \
# walletSeed=ENDORSER123450000000000000000000
# storageType=postgres_storage \
# storageConfig='{"url":"192.168.65.3:5435"}' \
# storageCredentials='{"account":"DB_USER","password":"DB_PASSWORD","admin_account":"postgres","admin_password":"mysecretpassword"}'
#
# Params:
# walletName:
# - The name of the wallet to be imported.
# - Example; endorser_wallet
#
# storageType:
# - The wallet storage type.
# - Optional - The wallet storage type. Defaults to 'default'.
# - Remote Wallet Example; postgres_storage
# - Local Wallet Example; default
#
# storageConfig:
# - The wallet storage configuration.
# - Optional - The wallet storage configuration. Defaults to '{}'.
# - Remote Wallet Example; '{"url":"192.168.65.3:5435"}'
# - Local Wallet Example; '{}'
#
# storageCredentials:
# - The wallet storage credentials.
# - Optional - The wallet storage credentials. Defaults to '{}'.
# - Remote Wallet Example; '{"account":"DB_USER","password":"DB_PASSWORD","admin_account":"postgres","admin_password":"mysecretpassword"}'
# - Local Wallet Example; '{}'
#
# walletSeed:
# - The seed to use for initializing the wallet.
# - Example; ENDORSER123450000000000000000000
# ===================================================================================

load-plugin library=libindystrgpostgres.so initializer=postgresstorage_init

wallet create ${walletName} key storage_type=${storageType} storage_config=${storageConfig} storage_credentials=${storageCredentials}
wallet open ${walletName} key storage_credentials=${storageCredentials}
did new seed=${walletSeed}
did new seed
did list
wallet close
wallet detach ${walletName}
Expand Down
15 changes: 9 additions & 6 deletions cli-scripts/did-list
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
# -----------------------------------------------------------------------------------
# List the DID(s) in a wallet
#
# Example:
#
# Examples:
# ./manage \
# indy-cli did-list \
# walletName=myorg_issuer
#
# ./manage \
# indy-cli did-list \
# walletName=myorg_issuer \
Expand All @@ -18,24 +21,24 @@
# - Example; myorg_issuer
#
# storageType:
# - The wallet storage type.
# - Optional - The wallet storage type. Defaults to 'default'.
# - Remote Wallet Example; postgres_storage
# - Local Wallet Example; default
#
# storageConfig:
# - The wallet storage configuration.
# - Optional - The wallet storage configuration. Defaults to '{}'.
# - Remote Wallet Example; '{"url":"192.168.65.3:5435"}'
# - Local Wallet Example; '{}'
#
# storageCredentials:
# - The wallet storage credentials.
# - Optional - The wallet storage credentials. Defaults to '{}'.
# - Remote Wallet Example; '{"account":"DB_USER","password":"DB_PASSWORD","admin_account":"postgres","admin_password":"mysecretpassword"}'
# - Local Wallet Example; '{}'
# ===================================================================================

load-plugin library=libindystrgpostgres.so initializer=postgresstorage_init

wallet attach ${walletName} storage_type=${storageType} storage_config=${storageConfig}
-wallet attach ${walletName} storage_type=${storageType} storage_config=${storageConfig}
wallet open ${walletName} key storage_credentials=${storageCredentials}
did list
wallet close
Expand Down
24 changes: 16 additions & 8 deletions cli-scripts/endorse-transaction
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,21 @@
#
# - A wallet containing the endorser's DID MUST be attacted and open.
#
# Example:
# Examples:
# ./manage \
# indy-cli endorse-transaction \
# walletName=endorser_wallet \
# storageType=default \
# storageConfig='{}' \
# storageCredentials='{}' \
# poolName=localpool \
# endorserDid=DFuDqCYpeDNXLuc3MKooX3 \
# inputFile=/tmp/ian-permit.ian-co_author_signed_schema.txn \
# outputFile=/tmp/ian-permit.ian-co_endorser_signed_schema.txn
#
# ./manage \
# indy-cli endorse-transaction \
# walletName=endorser_wallet \
# storageType=postgres_storage \
# storageConfig='{"url":"192.168.65.3:5435"}' \
# storageCredentials='{"account":"DB_USER","password":"DB_PASSWORD","admin_account":"postgres","admin_password":"mysecretpassword"}' \
# poolName=localpool \
# endorserDid=DFuDqCYpeDNXLuc3MKooX3 \
# inputFile=/tmp/ian-permit.ian-co_author_signed_schema.txn \
Expand All @@ -31,17 +39,17 @@
# - Example; endorser_wallet
#
# storageType:
# - The wallet storage type.
# - Optional - The wallet storage type. Defaults to 'default'.
# - Remote Wallet Example; postgres_storage
# - Local Wallet Example; default
#
# storageConfig:
# - The wallet storage configuration.
# - Optional - The wallet storage configuration. Defaults to '{}'.
# - Remote Wallet Example; '{"url":"192.168.65.3:5435"}'
# - Local Wallet Example; '{}'
#
# storageCredentials:
# - The wallet storage credentials.
# - Optional - The wallet storage credentials. Defaults to '{}'.
# - Remote Wallet Example; '{"account":"DB_USER","password":"DB_PASSWORD","admin_account":"postgres","admin_password":"mysecretpassword"}'
# - Local Wallet Example; '{}'
#
Expand All @@ -67,7 +75,7 @@ load-plugin library=libindystrgpostgres.so initializer=postgresstorage_init

pool connect ${poolName}

wallet attach ${walletName} storage_type=${storageType} storage_config=${storageConfig}
-wallet attach ${walletName} storage_type=${storageType} storage_config=${storageConfig}
wallet open ${walletName} key storage_credentials=${storageCredentials}
did use ${endorserDid}
ledger load-transaction file=${inputFile}
Expand Down
15 changes: 10 additions & 5 deletions cli-scripts/export-wallet
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@
# Exports a wallet to a file.
# - The exported data is encrypted using a user supplied key.
#
# Example:
# Examples:
# ./manage \
# indy-cli export-wallet \
# walletName=myorg_issuer \
# exportPath=/tmp/myorg_issuer_wallet_initialized_with_did.export
#
# ./manage \
# indy-cli export-wallet \
# walletName=myorg_issuer \
Expand All @@ -19,17 +24,17 @@
# - Example; myorg_issuer
#
# storageType:
# - The wallet storage type.
# - Optional - The wallet storage type. Defaults to 'default'.
# - Remote Wallet Example; postgres_storage
# - Local Wallet Example; default
#
# storageConfig:
# - The wallet storage configuration.
# - Optional - The wallet storage configuration. Defaults to '{}'.
# - Remote Wallet Example; '{"url":"192.168.65.3:5435"}'
# - Local Wallet Example; '{}'
#
# storageCredentials:
# - The wallet storage credentials.
# - Optional - The wallet storage credentials. Defaults to '{}'.
# - Remote Wallet Example; '{"account":"DB_USER","password":"DB_PASSWORD","admin_account":"postgres","admin_password":"mysecretpassword"}'
# - Local Wallet Example; '{}'
#
Expand All @@ -40,7 +45,7 @@

load-plugin library=libindystrgpostgres.so initializer=postgresstorage_init

wallet attach ${walletName} storage_type=${storageType} storage_config=${storageConfig}
-wallet attach ${walletName} storage_type=${storageType} storage_config=${storageConfig}
wallet open ${walletName} key storage_credentials=${storageCredentials}
wallet export export_path=${exportPath} export_key
wallet close
Expand Down
13 changes: 9 additions & 4 deletions cli-scripts/import-wallet
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@
# -----------------------------------------------------------------------------------
# Imports a wallet from a file.
#
# Example:
# Examples:
# ./manage \
# indy-cli import-wallet \
# walletName=lcrb_wallet \
# importPath=/tmp/lcrb_wallet_with_schemas_cred_defs_and_metadata.export
#
# ./manage \
# indy-cli import-wallet \
# walletName=lcrb_wallet \
Expand All @@ -18,17 +23,17 @@
# - Example; myorg_issuer
#
# storageType:
# - The wallet storage type.
# - Optional - The wallet storage type. Defaults to 'default'.
# - Remote Wallet Example; postgres_storage
# - Local Wallet Example; default
#
# storageConfig:
# - The wallet storage configuration.
# - Optional - The wallet storage configuration. Defaults to '{}'.
# - Remote Wallet Example; '{"url":"192.168.65.3:5435"}'
# - Local Wallet Example; '{}'
#
# storageCredentials:
# - The wallet storage credentials.
# - Optional - The wallet storage credentials. Defaults to '{}'.
# - Remote Wallet Example; '{"account":"DB_USER","password":"DB_PASSWORD","admin_account":"postgres","admin_password":"mysecretpassword"}'
# - Local Wallet Example; '{}'
#
Expand Down
4 changes: 2 additions & 2 deletions cli-scripts/set_did_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
wallet_credentials = json.dumps({"key": wallet_key, "storage_credentials": wallet_storage_credentials})

wallet_did = os.getenv('walletDid', 'VePGZfzvcgmT3GTdYgpDiT')
wallet_seed = os.getenv('walletSeed', '0000000000000000000000000MyAgent')
did_seed = os.getenv('didSeed', '0000000000000000000000000MyAgent')

metadata = json.loads(os.getenv('didMetadata', '{}'))

Expand All @@ -36,7 +36,7 @@ async def set_did_metadata():
wallet_handle = await wallet.open_wallet(wallet_config, wallet_credentials)

print_log('\nGenerating seed hash ...')
seed_hash = sha256(wallet_seed.encode()).hexdigest()
seed_hash = sha256(did_seed.encode()).hexdigest()
did_metadata = {**(metadata or {}), 'public': True, 'seed_hash': seed_hash}

print_log('\nWriting metadata for DID ...')
Expand Down
Loading

0 comments on commit a2f1407

Please sign in to comment.