public void getTransactionFromTestNetTesst() { Wallet.WalletClient wallet = GetMainNetWalletClient; // wallet.tra byte[] hashTransaction = StringHelper.HexStringToByteArray("d2e635f7c2d85cbcd343721047447b122a3c19e86f30651d8ec6ee76f744d065"); BytesMessage bytesMessage = new BytesMessage(); bytesMessage.Value = ByteString.CopyFrom(hashTransaction); // Transaction transactionLoad = wallet.GetTransactionByIdAsync(bytesMessage).GetAwaiter().GetResult(); // Transaction transactionLoad = wallet.GetTransactionByIdAsync(bytesMessage).GetAwaiter().GetResult(); NodeList nodeList = wallet.ListNodes(GetEmptyMessage); Block result = wallet.GetNowBlockAsync(GetEmptyMessage).GetAwaiter().GetResult(); //TK4BAeF72P3gop24RsoqPJynWgBBDv9fXX var keyTriple = new KeyTriple("B7E85CA5910922C49DCCB92EE48DFEC13A60674845CB7152C86B88F31DA6DC67"); byte[] addressWallet = keyTriple.GetAddressWallet(TypeNet.Main); string encode = Base58.Encode(addressWallet); Account account = new Account(); account.Address = ByteString.CopyFrom(addressWallet); Account account1 = wallet.GetAccountAsync(account).GetAwaiter().GetResult(); // new WalletExtension byte[] hashTransaction1 = StringHelper.HexStringToByteArray("a7e974c6e69fb7741bf5e08de8a2d8f6617826c59422b440de22e0612b03c393"); BytesMessage bytesMessage1 = new BytesMessage(); bytesMessage1.Value = ByteString.CopyFrom(hashTransaction1); Transaction transactionLoad1 = wallet.GetTransactionByIdAsync(bytesMessage1).GetAwaiter().GetResult(); TransferContract transferContract = TransferContract.Parser.ParseFrom(transactionLoad1.RawData.Contract[0].Parameter.Value.ToByteArray()); }
public Int64 balanceByAddress(String address) { byte[] addressBytes = StringHelper.GetBytesAdressFromString(address); Account account = new Account(); account.Address = ByteString.CopyFrom(addressBytes.SubArray(0, 21)); Account result = _walletClient.GetAccountAsync(account).GetAwaiter().GetResult(); return(result.Balance); }
public void MainTest() { Wallet.WalletClient wallet = GetMainNetWalletClient; string privateStrFrom = "D95611A9AF2A2A45359106222ED1AFED48853D9A44DEFF8DC7913F5CBA727366"; //TJCnKsPa7y5okkXvQAidZBzqx3QyQ6sxMW KeyTriple keyTripleFrom = new KeyTriple(privateStrFrom); string encode = Base58.Encode(keyTripleFrom.GetAddressWallet(TypeNet.Main)); string encode1 = Base58.Encode(keyTripleFrom.GetAddressWallet(TypeNet.Test)); string privateStrTo = "443A94E9EA11A10FB9E40E239ACD005F6FC4FFC43F302484281F804A76EB9419"; //TYJ6pQuVDYc7ZFDf2xDjmUNidDeEEmXgBP KeyTriple keyTripleTo = new KeyTriple(privateStrTo); byte[] decode = Base58.Decode("TPwJS5eC5BPGyMGtYTHNhPTB89sUWjDSSu"); byte[] subArray = decode.SubArray(0, 21); subArray[0] = 160; Account account = new Account(); // account.a // account.Address = ByteString.CopyFrom(keyTripleFrom.GetAddressWallet(TypeNet.Test).SubArray(0,21)); // account.Address = ByteString.CopyFrom(keyTripleFrom.GetAddressWallet(TypeNet.Main)); account.Address = ByteString.CopyFrom(keyTripleFrom.GetAddressWallet(TypeNet.Main).SubArray(0, 21)); // account.Address = ByteString.CopyFrom(subArray); TaskAwaiter <Account> taskAwaiter = wallet.GetAccountAsync(account).GetAwaiter(); Account result = taskAwaiter.GetResult(); AccountNetMessage accountNetMessage = wallet.GetAccountNetAsync(account).GetAwaiter().GetResult(); BytesMessage bytesMessage1 = new BytesMessage(); bytesMessage1.Value = ByteString.CopyFrom(BitConverter.GetBytes(43586L)); Block block = wallet.GetBlockByIdAsync(bytesMessage1).GetAwaiter().GetResult(); byte[] privateBytes = keyTripleFrom.PrivateKey; byte[] fromBytes = keyTripleFrom.GetAddressWallet(TypeNet.Main).SubArray(1, 20); byte[] toBytes = keyTripleTo.GetAddressWallet(TypeNet.Main).SubArray(1, 20); long amount = 24071978L; //100 TRX, api only receive trx in drop, and 1 trx = 1000000 drop Transaction transaction = CreateTransaction(wallet, fromBytes, toBytes, amount); byte[] transactionBytes = transaction.ToByteArray(); //sign a transaction Transaction transaction1 = Sign(transaction, keyTripleFrom); //get byte transaction byte[] transaction2 = transaction1.ToByteArray(); Console.WriteLine("transaction2 ::::: " + transaction2.ToHexString2()); //sign a transaction in byte format and return a Transaction object var transaction3 = signTransaction2Object(transactionBytes, keyTripleFrom); Console.WriteLine("transaction3 ::::: " + transaction3.ToByteArray().ToHexString2()); //sign a transaction in byte format and return a Transaction in byte format var transaction4 = signTransaction2Byte(transactionBytes, keyTripleFrom); Console.WriteLine("transaction4 ::::: " + transaction4.ToHexString2()); // Transaction transactionSigned = // Wallet.WalletClient.signTransactionByApi(transaction, ecKey.getPrivKeyBytes()); // byte[] // transaction5 = transactionSigned.toByteArray(); // Console.WriteLine("transaction5 ::::: " + ByteArray.toHexString(transaction5)); // if (!Arrays.equals(transaction4, transaction5)) // Console.WriteLine("transaction4 is not equals to transaction5 !!!!!"); // boolean result = broadcast(transaction4); // Console.WriteLine(result); broadcast(wallet, transaction1); }