Beispiel #1
0
        public override async Task Execute()
        {
            var walletId   = walletService.NewID(16);
            var passphrase = walletService.Passphrase();
            var pkSk       = walletService.CreatePkSk();

            walletId.MakeReadOnly();
            passphrase.MakeReadOnly();

            try
            {
                await vaultService.CreateUserAsync(walletId, passphrase);

                // TODO: Add list for multiple store keys.
                //var dic = new Dictionary<string, object>
                //{
                //    { "storeKeys", new List<PkSkDto> { pkSk } }
                //};

                var dic = new Dictionary <string, object>
                {
                    { "storeKeys", pkSk }
                };

                await vaultService.SaveDataAsync(
                    walletId,
                    passphrase,
                    $"wallets/{walletId.ToUnSecureString()}/wallet",
                    dic);

                console.WriteLine($"Created Wallet {walletId.ToUnSecureString()} with password: {passphrase.ToUnSecureString()}");
            }
            catch (Exception)
            {
                console.WriteLine("Failed to create wallet. Is the vault unsealed?");
                throw;
            }
            finally
            {
                walletId.Dispose();
                passphrase.Dispose();
            }
        }