public byte[] GetAddressWallet(TypeNet typeNet) { byte[] bytesPub64 = PublicKeyShort; byte[] computeHash = Sha256Keccak.Hash(bytesPub64); //computeHash.ToHexString2(); byte[] computeHash20 = computeHash.SubArray(11, 21); //computeHash20.ToHexString2(); if (typeNet == TypeNet.Main) { computeHash20[0] = 65; } else { computeHash20[0] = 160; } //string hexString2 = computeHash20.ToHexString2(); byte[] secondSha = Sha256.HashTwice(computeHash20); byte[] checkSum = secondSha.SubArray(0, 4); //string SecondSHAhexString2 = secondSha.ToHexString2(); byte[] address = new byte[computeHash20.Length + 4]; Array.Copy(computeHash20, 0, address, 0, computeHash20.Length); Array.Copy(checkSum, 0, address, 21, 4); //string hexString = address.ToHexString2(); //string encode = Base_58.Encode(address); return(address); }
public void BalanceZero(string adrressBase58, StringType stringType, TypeNet typeNet) { ProtocolConfiguration protocolConfiguration = new ProtocolConfiguration(typeNet); CurrencyProvider.Protocol.Tron.CurrencyProvider currencyProvider = new CurrencyProvider.Protocol.Tron.CurrencyProvider(protocolConfiguration); long balance = currencyProvider.balanceByAddress(adrressBase58); Console.WriteLine($"{adrressBase58}:{balance}"); Assert.IsTrue(balance == 0); }
public void TestAddressECKeyTest(string privateKeyHex, string publicKeyHes, TypeNet typeNet, string address) { KeyTriple keyTriple = new KeyTriple(privateKeyHex); byte[] addressWallet = keyTriple.GetAddressWallet(typeNet); if (!string.IsNullOrEmpty(publicKeyHes)) { string publicKeyBase58 = keyTriple.PublicKey.ToHexString2(); Assert.IsTrue(String.Equals(publicKeyHes, publicKeyBase58, StringComparison.CurrentCultureIgnoreCase)); } string base58 = Base58.Encode(addressWallet); Assert.IsTrue(String.Equals(address, base58, StringComparison.CurrentCultureIgnoreCase)); }
public ProtocolConfiguration(TypeNet typeNet, string host, int port, int?maxConcurrentStreams, int timeOutMilliSeconds) { TypeNet = typeNet; Host = host; Port = port; MaxConcurrentStreams = maxConcurrentStreams; TimeOutMs = TimeSpan.FromMilliseconds(timeOutMilliSeconds); Channel = new Channel(Host, Port, ChannelCredentials.Insecure, new List <ChannelOption>() { new ChannelOption(ChannelOptions.MaxConcurrentStreams, maxConcurrentStreams == null?22: maxConcurrentStreams.Value) }); }
public NetStashLog(string logstashIp, int logstashPort, string currentAppVersion, string User, TypeNet typeNet) { if (string.IsNullOrWhiteSpace(logstashIp)) { throw new ArgumentNullException("logstashIp"); } if (string.IsNullOrWhiteSpace(currentAppVersion)) { throw new ArgumentNullException("system"); } TypeNet = typeNet; Worker.TcpWorker.Initialize(logstashIp, logstashPort, currentAppVersion, User); this.logstashIp = logstashIp; this.logstashPort = logstashPort; this.currentAppVersion = currentAppVersion; this.user = User; }
// [DataRow("TMy3cNNSZHY5d6F39BUbwUExJR93QDpGeh", StringType.Base58, TypeNet.Main)] public void DockerConnectTest(string addressBase58, StringType stringType, TypeNet typeNet) { // ProtocolConfiguration protocolConfiguration = new ProtocolConfiguration(typeNet, "172.17.0.2", 50051); // ProtocolConfiguration protocolConfiguration = new ProtocolConfiguration(typeNet); // ProtocolConfiguration protocolConfiguration = new ProtocolConfiguration(typeNet, "10.0.75.1", 50041); ProtocolConfiguration protocolConfiguration = new ProtocolConfiguration(typeNet, "10.0.75.1", 50051); // ProtocolConfiguration protocolConfiguration = new ProtocolConfiguration(typeNet, "18.184.238.21", 50051); Wallet.WalletClient walletClient = new Latoken.CurrencyProvider.Protocol.Tron.Grpc.Api.Wallet.WalletClient(protocolConfiguration.Channel); NodeList listNodes = walletClient.ListNodes(new EmptyMessage()); CurrencyProvider.Protocol.Tron.CurrencyProvider currencyProvider = new CurrencyProvider.Protocol.Tron.CurrencyProvider(protocolConfiguration); var rr = BitConverter.GetBytes(152948); var ddd = rr.ToHexString2(); BytesMessage numberMessa = new BytesMessage(); numberMessa.Value = Google.Protobuf.ByteString.CopyFrom(ddd.FromHexToByteArray2()); var dd = walletClient.GetBlockById(numberMessa); var block = walletClient.GetNowBlock(new EmptyMessage()); // long balance = currencyProvider.balanceByAddress(addressBase58); // Console.WriteLine($"{addressBase58}:{balance}"); // Assert.IsTrue(balance > 0); List <TransactionAtom> transferContractList = new List <TransactionAtom>(); int startPosition = 1; int endPosition = 1600000; int step = 100; int currentPosition = startPosition; while (currentPosition <= endPosition) { int currentStartPosition = currentPosition; int currentEndPosition = currentStartPosition + step; var blocklimit = new BlockLimit(); blocklimit.StartNum = currentStartPosition; blocklimit.EndNum = currentEndPosition; BlockList qqqq = walletClient.GetBlockByLimitNext(blocklimit); foreach (Block block1 in qqqq.Block) { foreach (Transaction transaction in block1.Transactions) { foreach (Transaction.Types.Contract contract1 in transaction.RawData.Contract) { if (contract1.Type == Transaction.Types.Contract.Types.ContractType.TransferContract) { ByteString parameterValue = contract1.Parameter.Value; TransferContract transferContract = TransferContract.Parser.ParseFrom(parameterValue.ToByteArray()); TronAddress fromAccount = new TronAddress(transferContract.OwnerAddress.ToByteArray()); TronAddress toAccount = new TronAddress(transferContract.ToAddress.ToByteArray()); TransactionAtom ta = new TransactionAtom(fromAccount, toAccount, transferContract.Amount, new TransactionHelper().GetTransactionHash(transaction)); transferContractList.Add(ta); } } } } currentPosition = currentEndPosition; } // var eeede = qqqq.Block[0].Transactions[0]; // var contract = eeede.RawData.Contract[0].Parameter; }
// [DataRow("TMy3cNNSZHY5d6F39BUbwUExJR93QDpGeh", StringType.Base58, TypeNet.Main)] public void SolidityDockerConnectTest(string addressBase58, StringType stringType, TypeNet typeNet) { // ProtocolConfiguration protocolConfiguration = new ProtocolConfiguration(typeNet, "172.17.0.2", 50051); // ProtocolConfiguration protocolConfiguration = new ProtocolConfiguration(typeNet); // ProtocolConfiguration protocolConfiguration = new ProtocolConfiguration(typeNet, "10.0.75.1", 50041); ProtocolConfiguration protocolConfiguration = new ProtocolConfiguration(typeNet, "10.0.75.1", 50052); // ProtocolConfiguration protocolConfiguration = new ProtocolConfiguration(typeNet, "18.184.238.21", 50051); var walletClient = new Latoken.CurrencyProvider.Protocol.Tron.Grpc.Api.WalletSolidity.WalletSolidityClient(protocolConfiguration.Channel); var sol = new Latoken.CurrencyProvider.Protocol.Tron.Grpc.Api.WalletSolidity.WalletSolidityClient(protocolConfiguration.Channel); byte[] addressBytes = StringHelper.GetBytesAdressFromString(addressBase58); Account account = new Account(); account.Address = ByteString.CopyFrom(addressBytes.SubArray(0, 21)); var dddd = sol.GetAccount(account); // NodeList listNodes = walletClient.GetPaginatedAssetIssueList ListNodes(new EmptyMessage()); var we = new Latoken.CurrencyProvider.Protocol.Tron.Grpc.Api.WalletExtension.WalletExtensionClient(protocolConfiguration.Channel); var ap = new AccountPaginated(); ap.Account = account; ap.Offset = 0; ap.Limit = 100; var t = we.GetTransactionsFromThis2(ap); CurrencyProvider.Protocol.Tron.CurrencyProvider currencyProvider = new CurrencyProvider.Protocol.Tron.CurrencyProvider(protocolConfiguration); var rr = BitConverter.GetBytes(1502948); BytesMessage numberMessa = new BytesMessage(); numberMessa.Value = Google.Protobuf.ByteString.CopyFrom(rr); }
public ProtocolConfiguration(TypeNet typeNet, string host, int port) : this(typeNet, host, port, 20, 5000) { TypeNet = typeNet; Host = host; Port = port; }
public ProtocolConfiguration(TypeNet typeNet) : this(typeNet, typeNet == TypeNet.Main ? "13.125.249.129" : "39.105.72.181", typeNet == TypeNet.Main ? 50051 : 18888) { TypeNet = typeNet; }