示例#1
0
        private TransactionResult FillTransaction(Transaction tx)
        {
            var block = Nexus.FindBlockForTransaction(tx);
            var chain = Nexus.FindChainForBlock(block.Hash);

            var result = new TransactionResult
            {
                hash         = tx.Hash.ToString(),
                chainAddress = chain.Address.Text,
                timestamp    = block.Timestamp.Value,
                blockHeight  = block.Height,
                script       = tx.Script.Encode()
            };

            var eventList = new List <EventResult>();

            var evts = block.GetEventsForTransaction(tx.Hash);

            foreach (var evt in evts)
            {
                var eventEntry = new EventResult
                {
                    address = evt.Address.Text,
                    data    = evt.Data.Encode(),
                    kind    = evt.Kind.ToString()
                };
                eventList.Add(eventEntry);
            }
            result.events = eventList.ToArray();

            var txResult = block.GetResultForTransaction(tx.Hash);

            result.result = txResult != null?Base16.Encode(txResult) : "";

            return(result);
        }