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()); }
private Transaction CreateTransaction(Wallet.WalletClient wallet, byte[] fromBytes, byte[] toBytes, long amount) { Transaction transactionBuilder = new Transaction(); Block newestBlock = wallet.GetNowBlockAsync(GetEmptyMessage).GetAwaiter().GetResult(); Transaction.Types.Contract contractBuilder = new Transaction.Types.Contract(); TransferContract transferContractBuilder = new TransferContract(); transferContractBuilder.Amount = amount; transferContractBuilder.ToAddress = ByteString.CopyFrom(toBytes); transferContractBuilder.OwnerAddress = ByteString.CopyFrom(fromBytes); try { Any any = Any.Pack(transferContractBuilder.Clone()); contractBuilder.Parameter = any; } catch (Exception) { return(null); } contractBuilder.Type = Transaction.Types.Contract.Types.ContractType.TransferContract; transactionBuilder.RawData = new Transaction.Types.raw(); transactionBuilder.RawData.Contract.Add(contractBuilder); transactionBuilder.RawData.Timestamp = DateTimeOffset.Now.ToUnixTimeMilliseconds(); transactionBuilder.RawData.Expiration = newestBlock.BlockHeader.RawData.Timestamp + 10 * 60 * 60 * 1000; Transaction transaction = transactionBuilder.Clone(); var refTransaction = SetReference(transaction, newestBlock); return(refTransaction); }
public static Transaction createTransaction(Wallet.WalletClient wallet, byte[] from, byte[] to, long amount) { Transaction transactionBuilder = new Transaction(); transactionBuilder.RawData = new Transaction.Types.raw(); Block newestBlock = wallet.GetNowBlockAsync(new EmptyMessage()).GetAwaiter().GetResult(); TransferContract transferContract = new TransferContract { Amount = amount, OwnerAddress = ByteString.CopyFrom(@from), ToAddress = ByteString.CopyFrom(to) }; // Transaction transactionNet = wallet.CreateTransactionAsync(transferContract).GetAwaiter().GetResult(); Transaction.Types.Contract contract = new Transaction.Types.Contract(); try { Any any = Any.Pack(transferContract); contract.Parameter = any; } catch (Exception) { return(null); } contract.Type = Transaction.Types.Contract.Types.ContractType.TransferContract; transactionBuilder.RawData.Contract.Add(contract); transactionBuilder.RawData.Timestamp = DateTime.Now.Ticks; transactionBuilder.RawData.Expiration = newestBlock.BlockHeader.RawData.Timestamp + 10 * 60 * 60 * 1000; Transaction refTransaction = setReference(transactionBuilder, newestBlock); return(refTransaction); }