static void Main(string[] args)
        {
            try
            {
                Console.WriteLine("Opening channel to testnet...");
                Channel channel = new Channel(testnetAddr, ChannelCredentials.Insecure);
                var     client  = new AdmissionControl.AdmissionControl.AdmissionControlClient(channel);
                Console.WriteLine("Client created.  Testing empty UpdateToLatestLedger call...");

                var request = new Types.UpdateToLatestLedgerRequest();
                request.ClientKnownVersion = 0;
                var response = client.UpdateToLatestLedger(request);
                Console.WriteLine();
                Console.WriteLine($"Ledger Version: {response.LedgerInfoWithSigs.LedgerInfo.Version}");
                Console.WriteLine($"Transaction Accumulator Hash: {response.LedgerInfoWithSigs.LedgerInfo.TransactionAccumulatorHash.ToBase64()}");
                Console.WriteLine($"Consensus Data Hash: {response.LedgerInfoWithSigs.LedgerInfo.ConsensusDataHash.ToBase64()}");
                Console.WriteLine($"Consensus Block ID: {response.LedgerInfoWithSigs.LedgerInfo.ConsensusBlockId.ToBase64()}");
                Console.WriteLine($"EpochNum: {response.LedgerInfoWithSigs.LedgerInfo.EpochNum}");
                Console.WriteLine($"Timestamp: {response.LedgerInfoWithSigs.LedgerInfo.TimestampUsecs} (microseconds unix time)");
                Console.WriteLine("Validators:");

                int i = 1;
                foreach (var validator in response.LedgerInfoWithSigs.Signatures)
                {
                    Console.WriteLine($"#{i++}:");
                    Console.WriteLine($"Signature: {validator.Signature.ToBase64()}");
                    Console.WriteLine($"Validator ID: {validator.ValidatorId.ToBase64()}");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Exception encountered: {ex}");
            }
        }
Exemple #2
0
        private static void GetTransaction(AdmissionControl.AdmissionControl.AdmissionControlClient client, string accountHex, UInt64 seqNum)
        {
            Console.WriteLine($"GetTransaction for {accountHex} and seqnum {seqNum}.");

            HexEncoder hex = new HexEncoder();

            Types.UpdateToLatestLedgerRequest updToLatestLedgerReq = new Types.UpdateToLatestLedgerRequest();
            var getTxReq = new Types.GetAccountTransactionBySequenceNumberRequest();

            getTxReq.SequenceNumber = seqNum;
            getTxReq.Account        = Google.Protobuf.ByteString.CopyFrom(hex.DecodeData(accountHex));
            Types.RequestItem reqItem = new Types.RequestItem();
            reqItem.GetAccountTransactionBySequenceNumberRequest = getTxReq;
            updToLatestLedgerReq.RequestedItems.Add(reqItem);
            var reply = client.UpdateToLatestLedger(updToLatestLedgerReq);

            if (reply?.ResponseItems?.Count == 1)
            {
                var resp = reply.ResponseItems[0].GetAccountTransactionBySequenceNumberResponse;

                if (resp.SignedTransactionWithProof == null)
                {
                    Console.WriteLine("GetTransaction request did not return a signed transaction.");
                }
                else
                {
                    var    signedTx           = resp.SignedTransactionWithProof;
                    byte[] result             = signedTx.SignedTransaction.SignedTxn.ToByteArray();
                    var    deserializedResult = LCSCore.LCSDeserialization <RawTransactionLCS>(result);
                }
            }
            else
            {
                Console.WriteLine("GetTransaction did not return a result.");
            }
        }