Ejemplo n.º 1
0
        private void RecordTransferHistory(StoreView snapshot, UInt160 scriptHash, UInt160 from, UInt160 to, BigInteger amount, UInt256 txHash, ref ushort transferIndex)
        {
            if (!_shouldTrackHistory)
            {
                return;
            }

            Header header = snapshot.GetHeader(snapshot.CurrentBlockHash);

            if (_recordNullAddressHistory || from != UInt160.Zero)
            {
                _transfersSent.Add(new Nep5TransferKey(from, header.Timestamp, scriptHash, transferIndex),
                                   new Nep5Transfer
                {
                    Amount         = amount,
                    UserScriptHash = to,
                    BlockIndex     = snapshot.Height,
                    TxHash         = txHash
                });
            }

            if (_recordNullAddressHistory || to != UInt160.Zero)
            {
                _transfersReceived.Add(new Nep5TransferKey(to, header.Timestamp, scriptHash, transferIndex),
                                       new Nep5Transfer
                {
                    Amount         = amount,
                    UserScriptHash = from,
                    BlockIndex     = snapshot.Height,
                    TxHash         = txHash
                });
            }
            transferIndex++;
        }
Ejemplo n.º 2
0
        UInt160[] IVerifiable.GetScriptHashesForVerifying(StoreView snapshot)
        {
            if (PrevHash == UInt256.Zero)
            {
                return new[] { Witness.ScriptHash }
            }
            ;
            Header prev_header = snapshot.GetHeader(PrevHash);

            if (prev_header == null)
            {
                throw new InvalidOperationException();
            }
            return(new[] { prev_header.NextConsensus });
        }
Ejemplo n.º 3
0
        public virtual bool Verify(StoreView snapshot)
        {
            Header prev_header = snapshot.GetHeader(PrevHash);

            if (prev_header == null)
            {
                return(false);
            }
            if (prev_header.Index + 1 != Index)
            {
                return(false);
            }
            if (prev_header.Timestamp >= Timestamp)
            {
                return(false);
            }
            if (!this.VerifyWitnesses(snapshot, 1_00000000))
            {
                return(false);
            }
            return(true);
        }