public async Task <IBcnCredentialsRecord> GenerateWallets(Guid clientId) { var network = _btcSettings.NetworkType == NetworkType.Main ? Network.Main : Network.TestNet; var wallets = await GetWalletsForPubKey(); IBcnCredentialsRecord bcnCreds; var currentWalletCreds = await _walletCredentialsRepository.GetAsync(clientId); if (currentWalletCreds == null) { var btcConvertionWallet = GetNewAddressAndPrivateKey(network); IWalletCredentials walletCreds = WalletCredentials.Create( clientId.ToString(), null, null, null, wallets.ColoredMultiSigAddress, btcConvertionWallet.PrivateKey, btcConvertionWallet.Address, encodedPk: "", pubKey: ""); bcnCreds = BcnCredentialsRecord.Create(SpecialAssetIds.BitcoinAssetId, clientId.ToString(), null, wallets.SegwitAddress, ""); await Task.WhenAll( _walletCredentialsRepository.SaveAsync(walletCreds), _walletCredentialsRepository.SaveAsync(bcnCreds) ); } else { //walletCreds = WalletCredentials.Create( // clientId.ToString(), // null, // null, // null, // wallets.ColoredMultiSigAddress, // null, // null, // encodedPk: "", // pubKey: ""); bcnCreds = await _walletCredentialsRepository.GetBcnCredsAsync(SpecialAssetIds.BitcoinAssetId, clientId); if (bcnCreds == null) { bcnCreds = BcnCredentialsRecord.Create( SpecialAssetIds.BitcoinAssetId, clientId.ToString(), null, wallets.SegwitAddress, "" ); await _walletCredentialsRepository.SaveAsync(bcnCreds); } //await _walletCredentialsHistoryRepository.InsertHistoryRecord(currentWalletCreds); //await _walletCredentialsRepository.Merge(walletCreds); } return(bcnCreds); }
public async Task SetSolarCoinWallet(Guid clientId, string address) { await SaveAsync(BcnCredentialsRecord.Create(SpecialAssetIds.SolarAssetId, clientId.ToString(), null, address, null)); }