示例#1
0
        public static bool VerifyToken(string operation, object[] token)
        {
            byte[] address = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6 };

            VerifyTokenParam param = new VerifyTokenParam {
            };

            param.ContractAddr = ExecutionEngine.ExecutingScriptHash;
            param.Fn           = operation;
            param.Caller       = (byte[])token[0];
            param.KeyNo        = (int)token[1];

            byte[] ret = Native.Invoke(0, address, "verifyToken", param);
            return(ret[0] == 1);
        }
        public static int VerifyToken(string funcName, string callerOntID, int callerPubKeyNo)
        {
            byte[] kAUTH_CONTRACT = new byte[]
            {
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x06
            };
            VerifyTokenParam param = new VerifyTokenParam
            {
                contractAddr = ontsys.ExecutionEngine.ExecutingScriptHash,
                funcName     = funcName,
                calllerOntID = callerOntID.AsByteArray(),
                keyNo        = callerPubKeyNo
            };

            byte[] ret = ont.Native.Invoke(0, kAUTH_CONTRACT, "verifyToken", param);
            if (ret[0] == 1)
            {
                return(Errors.SUCCESS);
            }
            return(Errors.UNAUTHORIZED);
        }