private string GetUncoloredAddress(string address) { if (BitcoinAddressHelper.IsBitcoinColoredAddress(address, _network)) { var coloredAddress = new BitcoinColoredAddress(address, _network); return(coloredAddress.Address.ToString()); } return(address); }
public async Task <CommandResult> CreateReport([FromBody] AddressTransactionsReportsRequest input) { if (!ModelState.IsValid) { return(CommandResultBuilder.Fail(ModelState.GetErrorsList().ToArray())); } if (!BitcoinAddressHelper.IsAddress(input.BitcoinAddress, _bcnReportsSettings.UsedNetwork())) { return(CommandResultBuilder.Fail("Invalid base58 address string.")); } await _addressTransactionsReportMetadataRepository.InsertOrReplace(ReportMetadata.Create(input.BitcoinAddress, queuedAt: DateTime.UtcNow)); await _commandProducer.CreateCommand(input.BitcoinAddress, input.Email); return(CommandResultBuilder.Ok()); }
public async Task <IAddressMainInfo> GetMainInfoAsync(string id) { if (BitcoinAddressHelper.IsBitcoinColoredAddress(id, _appSettings.BcnExploler.UsedNetwork())) { var result = new BitcoinColoredAddress(id, _appSettings.BcnExploler.UsedNetwork()); return(new AddressMainInfo { AddressId = id, ColoredAddress = result.ToWif(), UncoloredAddress = result.Address.ToString(), IsColored = true }); } if (BitcoinAddressHelper.IsBitcoinPubKeyAddress(id, _appSettings.BcnExploler.UsedNetwork())) { var result = new BitcoinPubKeyAddress(id, _appSettings.BcnExploler.UsedNetwork()); return(new AddressMainInfo { AddressId = id, ColoredAddress = result.ToColoredAddress().ToWif(), UncoloredAddress = result.ToString(), IsColored = false }); } if (BitcoinAddressHelper.IsBitcoinScriptAddress(id, _appSettings.BcnExploler.UsedNetwork())) { var result = new BitcoinScriptAddress(id, _appSettings.BcnExploler.UsedNetwork()); return(new AddressMainInfo { AddressId = id, ColoredAddress = result.ToColoredAddress().ToWif(), UncoloredAddress = result.ToString(), IsColored = false }); } return(null); }
public async Task <SearchResultType?> GetTypeAsync(string id) { if (BitcoinAddressHelper.IsAddress(id, _baseSettings.BcnExploler.UsedNetwork())) { return(SearchResultType.Address); } var result = await GetFromNinja(id); if (result == null) { var asset = await _assetProvider.GetAssetAsync(id); result = asset != null ? (SearchResultType?)SearchResultType.Asset : null; } if (await _offchainNotificationsService.OffchainTransactionExistsAsync(id)) { return(SearchResultType.OffchainTransaction); } return(result); }