コード例 #1
0
ファイル: nns_user.cs プロジェクト: wqq1991/neo-thinsdk-cs
        async Task test_config_resolve_1_xxx_yyy()
        {
            subPrintLine("config resolve 1.[xxx].[yyy]  input xxx.yyy:");
            var readline = Console.ReadLine().Split(".");
            var subname  = readline[0];
            var rootname = readline[1];

            var testhash = nns_common.nameHash(rootname);
            var subhash  = nns_common.nameHashSub(testhash, subname);

            var _result = await nns_common.api_InvokeScript(Config.sc_nns, "getOwnerInfo",
                                                            "(hex256)" + subhash.ToString());

            var resolver = new Hash160(_result.value.subItem[0].subItem[2].data);

            subPrintLine("resolver=" + resolver.ToString());

            var owner = new Hash160(_result.value.subItem[0].subItem[0].data);

            //string testwif = nnc_1.testwif;
            byte[]  prikey = ThinNeo.Helper.GetPrivateKeyFromWIF(Config.test_wif);
            byte[]  pubkey = ThinNeo.Helper.GetPublicKeyFromPrivateKey(prikey);
            Hash160 hash   = ThinNeo.Helper.GetScriptHashFromPublicKey(pubkey);

            if (owner.Equals(hash) == false)
            {
                subPrintLine("this is not your domain.");
                return;
            }
            var newowner = ThinNeo.Helper.GetPublicKeyHashFromAddress("ALjSnMZidJqd18iQaoCgFun6iqWRm2cVtj");
            var result   = await nns_common.api_SendTransaction(prikey, resolver, "setResolveData",
                                                                "(hex160)" + hash.ToString(),    //参数1 所有者
                                                                "(hex256)" + subhash.ToString(), //参数2 域名fullhash
                                                                "(string)" + "1",                //参数3 要设置的子域名
                                                                "(string)" + "text",             //参数4 协议
                                                                "(string)" + "hello world"       //解析内容
                                                                );

            subPrintLine("result=" + result);
        }