コード例 #1
0
ファイル: VaultWallet.cs プロジェクト: prestwich/nethermind
        public async Task <Address> CreateAccount()
        {
            Key key = new Key();

            key.Name        = "name";
            key.Description = "description";
            key.Type        = "asymmetric";
            key.Spec        = "secp256k1";
            key.Usage       = "sign/verify";

            Key createdKey = await _vaultService.CreateKey(_vaultId, key);

            if (createdKey is null)
            {
                throw new ApplicationException("Failed to create vault key.");
            }

            if (createdKey.Id is null)
            {
                throw new ApplicationException($"Failed to create vault key with a valid {nameof(key.Id)}.");
            }

            if (_logger.IsTrace)
            {
                _logger.Trace(
                    $"Created key {createdKey.Address} {createdKey.Id} in vault {createdKey.VaultId}");
            }

            Address account = new Address(createdKey.Address);

            if (!_accounts.TryAdd(account, createdKey.Id.Value))
            {
                throw new ApplicationException("New key created with an address collision.");
            }

            return(account);
        }
コード例 #2
0
ファイル: VaultModule.cs プロジェクト: prestwich/nethermind
        public async Task <ResultWrapper <Key> > vault_createKey(string vaultId, Key key)
        {
            Key result = await _vaultService.CreateKey(Guid.Parse(vaultId), key);

            return(ResultWrapper <Key> .Success(result));
        }