コード例 #1
0
        public async Task <Types.TransactionListWithProof> GetTransactionsAsync(
            ulong startVersion, ulong limit)
        {
            var updateToLatestLedgerRequest = new Types.UpdateToLatestLedgerRequest();
            var requestItem       = new Types.RequestItem();
            var tansactionRequest = new GetTransactionsRequest();

            requestItem.GetTransactionsRequest = tansactionRequest;
            tansactionRequest.StartVersion     = startVersion;

            tansactionRequest.Limit = limit;
            // tansactionRequest.FetchEvents = true;

            updateToLatestLedgerRequest.RequestedItems.Add(requestItem);
            var result = await _client.UpdateToLatestLedgerAsync(
                updateToLatestLedgerRequest, new Metadata());

            //Console.WriteLine("result = " + result.ResponseItems.Count);
            //Console.WriteLine("result = " + result.ResponseItems.FirstOrDefault());

            List <CustomRawTransaction> retList = new List <CustomRawTransaction>();

            foreach (var item in result.ResponseItems)
            {
                return(item.GetTransactionsResponse.TxnListWithProof);
            }

            return(null);
        }
コード例 #2
0
        GetTransactionsBySequenceNumberAsync(
            string address, ulong sequenceNumber)
        {
            var updateToLatestLedgerRequest = new Types.UpdateToLatestLedgerRequest();
            var requestItem       = new Types.RequestItem();
            var tansactionRequest = new GetAccountTransactionBySequenceNumberRequest();

            requestItem.GetAccountTransactionBySequenceNumberRequest
                = tansactionRequest;
            tansactionRequest.Account =
                Google.Protobuf.ByteString.CopyFrom(address.HexStringToByteArray());
            tansactionRequest.SequenceNumber = sequenceNumber;
            tansactionRequest.FetchEvents    = true;

            updateToLatestLedgerRequest.RequestedItems.Add(requestItem);
            var result = await _client.UpdateToLatestLedgerAsync(
                updateToLatestLedgerRequest, new Metadata());

            foreach (var item in result.ResponseItems)
            {
                return(item.GetAccountTransactionBySequenceNumberResponse
                       .SignedTransactionWithProof);
            }

            return(null);
        }
コード例 #3
0
        public async Task <Types.AccountStateWithProof> GetAccountInfoAsync(
            string address)
        {
            var updateToLatestLedgerRequest = new Types.UpdateToLatestLedgerRequest();
            var requestItem = new Types.RequestItem();
            var asr         = new Types.GetAccountStateRequest();

            asr.Address = Google.Protobuf.ByteString.CopyFrom(
                address.HexStringToByteArray());
            requestItem.GetAccountStateRequest = asr;
            updateToLatestLedgerRequest.RequestedItems.Add(requestItem);

            var result = await _client.UpdateToLatestLedgerAsync(
                updateToLatestLedgerRequest, new Metadata());

            if (result == null ||
                result.ResponseItems == null ||
                result.ResponseItems != null && !result.ResponseItems.Any())
            {
                throw new System.Exception("No such address.");
            }

            var firest = result.ResponseItems.FirstOrDefault();

            if (firest.GetAccountStateResponse.AccountStateWithProof.Blob == null)
            {
                throw new System.Exception("AccountStateWithProof Blob is empty.");
            }

            return(firest.GetAccountStateResponse.AccountStateWithProof);
        }
コード例 #4
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.");
            }
        }