Esempio n. 1
0
        private TransactionResult FillTransaction(Transaction tx)
        {
            var block = Nexus.FindBlockByTransaction(tx);
            var chain = Nexus.FindChainByAddress(block.ChainAddress);

            var result = new TransactionResult
            {
                hash          = tx.Hash.ToString(),
                chainAddress  = chain.Address.Text,
                timestamp     = block.Timestamp.Value,
                blockHeight   = block.Height,
                blockHash     = block.Hash.ToString(),
                confirmations = Nexus.GetConfirmationsOfBlock(block),
                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);
        }