示例#1
0
        public List <BlockchainAddress> GetAddresses(string walletId, string networkName)
        {
            try
            {
                List <BlockchainAddress> blockchainAddresses = null;
                switch (networkName)
                {
                case CryptoCurrency.BTC:
                    blockchainAddresses = new BitcoinAddressRepository(Connection).FindByWalletId(walletId)
                                          .ToList <BlockchainAddress>();
                    break;

                case CryptoCurrency.ETH:
                    blockchainAddresses = new EthereumAddressRepository(Connection).FindByWalletId(walletId)
                                          .ToList <BlockchainAddress>();
                    break;

                case CryptoCurrency.VAKA:
                    blockchainAddresses = new VakacoinAccountRepository(Connection).FindByWalletId(walletId)
                                          .ToList <BlockchainAddress>();
                    break;

                default:
                    throw new Exception("Network name is not defined!");
                }

                return(blockchainAddresses);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }
示例#2
0
        public List <BlockchainAddress> GetAddressesLimit(out int numberData, string walletId, string networkName,
                                                          int offset = 0, int limit = 0, string filter = "")
        {
            numberData = -1;
            try
            {
                List <BlockchainAddress> blockchainAddresses = null;
                switch (networkName)
                {
                case CryptoCurrency.BTC:
                    blockchainAddresses = new BitcoinAddressRepository(Connection)
                                          .FindByWalletIdLimit(out numberData, walletId, offset, limit, filter)
                                          .ToList <BlockchainAddress>();
                    break;

                case CryptoCurrency.ETH:
                    blockchainAddresses = new EthereumAddressRepository(Connection)
                                          .FindByWalletIdLimit(out numberData, walletId, offset, limit, filter)
                                          .ToList <BlockchainAddress>();
                    break;

                case CryptoCurrency.VAKA:
                    blockchainAddresses = new VakacoinAccountRepository(Connection)
                                          .FindByWalletIdLimit(out numberData, walletId, offset, limit, filter)
                                          .ToList <BlockchainAddress>();
                    break;

                default:
                    throw new Exception("Network name is not defined!");
                }

                return(blockchainAddresses);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }
示例#3
0
//        public Wallet FindByAddress(string address)
//        {
//            try
//            {
//                string query = $"SELECT * FROM {TableName} WHERE Address = '{address}'";
//                List<Wallet> wallets = FindBySql(query);
//                if (wallets == null || wallets.Count == 0)
//                    return null;
//                return wallets[0];
//            }
//            catch (Exception e)
//            {
//                Console.WriteLine(e);
//                return null;
//            }
//        }

        public Wallet FindByAddressAndNetworkName(string address, string networkName)
        {
            try
            {
                var walletId = "";
                BlockchainAddress blockchainAddress = null;
                switch (networkName)
                {
                case CryptoCurrency.BTC:
                    blockchainAddress = new BitcoinAddressRepository(Connection).FindByAddress(address);
                    break;

                case CryptoCurrency.ETH:
                    blockchainAddress = new EthereumAddressRepository(Connection).FindByAddress(address);
                    break;

                case CryptoCurrency.VAKA:
                    blockchainAddress = new VakacoinAccountRepository(Connection).FindByAddress(address);
                    break;
                }

                if (blockchainAddress == null)
                {
                    return(null);
                }

                walletId = blockchainAddress.WalletId;

                return(FindById(walletId));
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }