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

Allow to store neo address in NNS #42

Open
wants to merge 1 commit into
base: add_header
Choose a base branch
from
Open
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
6 changes: 6 additions & 0 deletions src/neo/SmartContract/Native/NameService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Neo.Persistence;
using Neo.VM;
using Neo.VM.Types;
using Neo.Wallets;
using System;
using System.Collections.Generic;
using System.Linq;
Expand Down Expand Up @@ -172,6 +173,11 @@ private void SetRecord(ApplicationEngine engine, string name, RecordType type, s
if (!nameRegex.IsMatch(name)) throw new ArgumentException(null, nameof(name));
switch (type)
{
case RecordType.NEO:
if (!UInt160.TryParse(data, out var scriptHash))
scriptHash = data.ToScriptHash();
data = scriptHash.ToString();
break;
case RecordType.A:
if (!ipv4Regex.IsMatch(data)) throw new FormatException();
if (!IPAddress.TryParse(data, out IPAddress address)) throw new FormatException();
Expand Down
4 changes: 4 additions & 0 deletions src/neo/SmartContract/Native/RecordType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ namespace Neo.SmartContract.Native
{
public enum RecordType : byte
{
#region
NEO = 0,
#endregion

#region [RFC 1035](https://tools.ietf.org/html/rfc1035)
A = 1,
CNAME = 5,
Expand Down