示例#1
0
        /// <summary>
        /// Get transaction information by id
        /// </summary>
        /// <param name="parameters"></param>
        /// /// Parameter Index
        /// [0] : Transaction id
        /// <returns></returns>
        public static bool GetTransactionById(string command, string[] parameters)
        {
            string[] usage = new string[] {
                string.Format("{0} [command option] <transaction id>\n", command)
            };

            string[] command_option = new string[] { HelpCommandOption.Help };

            if (parameters == null || parameters.Length != 1)
            {
                OutputHelpMessage(usage, null, command_option, null);
                return(true);
            }

            try
            {
                RpcApiResult result = RpcApi.GetTransactionById(parameters[0], out TransactionExtention transaction);
                if (result.Result)
                {
                    Console.WriteLine(PrintUtil.PrintTransaction(transaction));
                }

                OutputResultMessage(command, result.Result, result.Code, result.Message);
            }
            catch (System.Exception e)
            {
                Console.WriteLine(e.Message + "\n\n" + e.StackTrace);
            }

            return(true);
        }
示例#2
0
        public static Transaction SetPermissionId(ref Transaction transaction)
        {
            if (transaction.Signature.Count != 0 ||
                transaction.RawData.Contract[0].PermissionId != 0)
            {
                return(transaction);
            }

            Console.WriteLine("Your transaction details are as follows, please confirm.");
            Console.WriteLine("transaction hex string is " + transaction.ToByteArray().ToHexString());
            Console.WriteLine(PrintUtil.PrintTransaction(transaction));
            Console.WriteLine("Please confirm and input your permission id," +
                              " if input y or Y means default 0, other non-numeric characters will cancell transaction.");

            int permission_id = InputPermissionid();

            if (permission_id < 0)
            {
                throw new OperationCanceledException("user cancelled.");
            }

            if (permission_id != 0)
            {
                transaction.RawData.Contract[0].PermissionId = permission_id;
            }

            return(transaction);
        }
示例#3
0
        public static RpcApiResult SignatureTransaction(ref Transaction transaction)
        {
            if (transaction.RawData.Timestamp == 0)
            {
                transaction.RawData.Timestamp = Helper.CurrentTimeMillis();
            }

            ProtocolUtil.SetExpirationTime(ref transaction);
            Console.WriteLine("Your transaction details are as follows, please confirm.");
            Console.WriteLine("transaction hex string is " + transaction.ToByteArray().ToHexString());
            Console.WriteLine(PrintUtil.PrintTransaction(transaction));
            Console.WriteLine(
                "Please confirm and input your permission id, if input y or Y means default 0, other non-numeric characters will cancell transaction.");
            ProtocolUtil.SetPermissionId(ref transaction);

            try
            {
                while (true)
                {
                    Console.WriteLine("Please choose keystore for signature.");
                    KeyStore key_store = SelectKeyStore();

                    string password = CommandLineUtil.ReadPasswordString("Please input password");
                    if (KeyStoreService.DecryptKeyStore(password, key_store, out byte[] privatekey))