예제 #1
0
        /// <summary>
        /// Get a transaction in the mempool by its Transaction Identifier.
        /// This is a separate request than fetching a block transaction (/block/transaction) because some blockchain nodes need to know that a transaction query
        /// is for something in the mempool instead of a transaction in a block.
        /// Transactions may not be fully parsable until they are in a block (ex: may not be possible to determine the fee to pay before a transaction is executed).
        /// On this endpoint, it is ok that returned transactions are only estimates of what may actually be included in a block.
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public JObject MempoolTransaction(MempoolTransactionRequest request)
        {
            if (request.NetworkIdentifier?.Blockchain?.ToLower() != "neo n3")
            {
                return(Error.NETWORK_IDENTIFIER_INVALID.ToJson());
            }
            if (request.NetworkIdentifier?.Network?.ToLower() != network)
            {
                return(Error.NETWORK_IDENTIFIER_INVALID.ToJson());
            }
            // check tx
            if (request.TransactionIdentifier == null)
            {
                return(Error.TX_IDENTIFIER_INVALID.ToJson());
            }
            if (!UInt256.TryParse(request.TransactionIdentifier.Hash, out UInt256 txHash))
            {
                return(Error.TX_HASH_INVALID.ToJson());
            }
            NeoTransaction neoTx = system.MemPool.ToArray().FirstOrDefault(p => p.Hash == txHash);

            if (neoTx == default(NeoTransaction))
            {
                return(Error.TX_NOT_FOUND.ToJson());
            }

            Transaction tx = ConvertTx(neoTx);
            MempoolTransactionResponse response = new MempoolTransactionResponse(tx);

            return(response.ToJson());
        }
예제 #2
0
        public JObject MempoolTransaction(MempoolTransactionRequest request)
        {
            // check tx
            if (request.TransactionIdentifier == null)
            {
                return(Error.TX_IDENTIFIER_INVALID.ToJson());
            }
            if (!UInt256.TryParse(request.TransactionIdentifier.Hash, out UInt256 txHash))
            {
                return(Error.TX_HASH_INVALID.ToJson());
            }
            NeoTransaction neoTx = Blockchain.Singleton.MemPool.ToArray().FirstOrDefault(p => p.Hash == txHash);

            if (neoTx == default(NeoTransaction))
            {
                return(Error.TX_NOT_FOUND.ToJson());
            }

            Transaction tx = ConvertTx(neoTx);
            MempoolTransactionResponse response = new MempoolTransactionResponse(tx);

            return(response.ToJson());
        }