예제 #1
0
        private object RouteRegisterName(HTTPRequest request)
        {
            var name    = request.GetVariable("name");
            var context = InitContext(request);

            if (AccountContract.ValidateName(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("");
        }
예제 #2
0
        public Address LookUpName(string name)
        {
            if (!AccountContract.ValidateName(name))
            {
                return(Address.Null);
            }

            var chain = RootChain;

            return((Address)chain.InvokeContract("account", "LookUpName", name));
        }