Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add reserved attribute #2868

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions src/Neo/Network/P2P/Payloads/ReservedAttribute.cs
Original file line number Diff line number Diff line change
@@ -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
{
/// <summary>
/// Reserved attribute for dApps.
/// </summary>
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;
}
}
}
8 changes: 7 additions & 1 deletion src/Neo/Network/P2P/Payloads/TransactionAttributeType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ public enum TransactionAttributeType : byte
/// Indicates that the transaction is not valid before <see cref="NotValidBefore.Height"/>.
/// </summary>
[ReflectionCache(typeof(NotValidBefore))]
NotValidBefore = 0x20
NotValidBefore = 0x20,

/// <summary>
/// Indicates that the transaction is a reserved attribute.
/// </summary>
[ReflectionCache(typeof(ReservedAttribute))]
ReservedAttribute = 0xf0
}
}