Exemplo n.º 1
0
        private object RouteRegisterName(HTTPRequest request)
        {
            var name    = request.GetVariable("name");
            var context = InitContext(request);

            if (AccountContract.ValidateAddressName(name))
            {
                if (context["holdings"] is Holding[] balance)
                {
                    var soulBalance = balance.SingleOrDefault(b => b.Symbol == "SOUL");
                    if (soulBalance.Amount > 0.1m) //RegistrationCost
                    {
                        var keyPair    = GetLoginKey(request);
                        var registerTx = AccountController.RegisterName(keyPair, name).Result;
                        if (SendUtils.IsTxHashValid(registerTx))
                        {
                            return(registerTx);
                        }

                        PushError(request, registerTx);
                    }
                    else
                    {
                        PushError(request, "You need a small drop of SOUL (+0.1) to register a name.");
                    }
                }
            }
            else
            {
                PushError(request, "Error while registering name.");
            }
            return("");
        }
Exemplo n.º 2
0
        public Address LookUpName(string name)
        {
            if (!AccountContract.ValidateAddressName(name))
            {
                return(Address.Null);
            }

            var chain = RootChain;

            return((Address)chain.InvokeContract("account", "LookUpName", name));
        }
Exemplo n.º 3
0
        public IAPIResult LookUpName([APIParameter("Name of account", "blabla")] string name)
        {
            if (!AccountContract.ValidateAddressName(name))
            {
                return(new ErrorResult {
                    error = "invalid name"
                });
            }

            var address = Nexus.LookUpName(name);

            if (address == Address.Null)
            {
                return(new ErrorResult {
                    error = "name not owned"
                });
            }

            return(new SingleResult()
            {
                value = address.Text
            });
        }