diff --git a/src/Neo/Network/P2P/Payloads/ReservedAttribute.cs b/src/Neo/Network/P2P/Payloads/ReservedAttribute.cs new file mode 100644 index 0000000000..46e4828194 --- /dev/null +++ b/src/Neo/Network/P2P/Payloads/ReservedAttribute.cs @@ -0,0 +1,45 @@ +// Copyright (C) 2015-2023 The Neo Project. +// +// The neo is free software distributed under the MIT software license, +// see the accompanying file LICENSE in the main directory of the +// project or http://www.opensource.org/licenses/mit-license.php +// for more details. +// +// Redistribution and use in source and binary forms with or without +// modifications are permitted. + +using System; +using System.IO; +using Neo.IO; +using Neo.Json; + +namespace Neo.Network.P2P.Payloads +{ + /// + /// Reserved attribute for dApps. + /// + public class ReservedAttribute : TransactionAttribute + { + private byte[] _reserved; + + public override bool AllowMultiple => true; + public override TransactionAttributeType Type => TransactionAttributeType.ReservedAttribute; + + protected override void DeserializeWithoutType(ref MemoryReader reader) + { + _reserved = reader.ReadVarMemory(ushort.MaxValue).ToArray(); + } + + protected override void SerializeWithoutType(BinaryWriter writer) + { + writer.WriteVarBytes(_reserved); + } + + public override JObject ToJson() + { + var json = base.ToJson(); + json["value"] = Convert.ToBase64String(_reserved); + return json; + } + } +} diff --git a/src/Neo/Network/P2P/Payloads/TransactionAttributeType.cs b/src/Neo/Network/P2P/Payloads/TransactionAttributeType.cs index 41c69b507d..e3a728b19e 100644 --- a/src/Neo/Network/P2P/Payloads/TransactionAttributeType.cs +++ b/src/Neo/Network/P2P/Payloads/TransactionAttributeType.cs @@ -33,6 +33,12 @@ public enum TransactionAttributeType : byte /// Indicates that the transaction is not valid before . /// [ReflectionCache(typeof(NotValidBefore))] - NotValidBefore = 0x20 + NotValidBefore = 0x20, + + /// + /// Indicates that the transaction is a reserved attribute. + /// + [ReflectionCache(typeof(ReservedAttribute))] + ReservedAttribute = 0xf0 } }