Ejemplo n.º 1
0
        private static Transaction FromRawDataStream(MemoryStream stream)
        {
            using (var reader = new NearBinaryReader(stream, true))
            {
                var signerId   = reader.ReadString();
                var publicKey  = PublicKey.FromStream(ref stream);
                var nonce      = reader.ReadULong();
                var receiverId = reader.ReadString();
                var blockHash  = new ByteArray32()
                {
                    Buffer = reader.ReadBytes(32)
                };
                var actionsCount = reader.ReadUInt();
                var actions      = new List <Action>();

                for (var i = 0; i < actionsCount; i++)
                {
                    actions.Add(Action.FromStream(ref stream));
                }

                return(new Transaction()
                {
                    SignerId = signerId,
                    PublicKey = publicKey,
                    Nonce = nonce,
                    ReceiverId = receiverId,
                    BlockHash = blockHash,
                    Actions = actions.ToArray()
                });
            }
        }
Ejemplo n.º 2
0
        private static NearSignature FromRawDataStream(MemoryStream stream)
        {
            using (var reader = new NearBinaryReader(stream, true))
            {
                KeyType keyType;
                switch ((int)reader.ReadByte())
                {
                case 0:
                {
                    keyType = KeyType.Ed25519;
                    break;
                }

                default:
                {
                    throw new NotSupportedException("Invalid key type in raw bytes for public key");
                }
                }

                var data = new ByteArray64
                {
                    Buffer = reader.ReadBytes(64)
                };

                return(new NearSignature(keyType, data));
            }
        }