public async Task <string> ResolveBlockchainAddressAsync(string virtualAddress, string assetId) { IVirtualWallet wallet = await _virtualWalletService.FindAsync(virtualAddress); if (wallet == null) { throw new WalletNotFoundException(virtualAddress); } BlockchainWallet bcnWallet = wallet.BlockchainWallets.SingleOrDefault(x => x.AssetId == assetId); return(bcnWallet?.Address); }
public async Task <IVirtualWallet> AddAddressAsync(string merchantId, string walletId, BlockchainWallet blockchainWallet) { IVirtualWallet wallet = await _virtualWalletRepository.GetAsync(merchantId, walletId); if (wallet == null) { throw new WalletNotFoundException(walletId); } bool exists = wallet.BlockchainWallets.Any(x => x.Blockchain == blockchainWallet.Blockchain && x.Address == blockchainWallet.Address); if (exists) { throw new WalletAlreadyExistsException(walletId); } wallet.BlockchainWallets.Add(blockchainWallet); await _virtualWalletRepository.SaveAsync(wallet); return(wallet); }