Esempio n. 1
0
        public MarketBase(MetaDaemonApi daemon, MarketRow market, BitsharesWallet bitshares, BitcoinWallet bitcoin, string bitsharesAccount)
        {
            m_daemon = daemon;
            m_market = market;

            m_bitshares = bitshares;
            m_bitcoin = bitcoin;
            m_bitsharesAccount = bitsharesAccount;
        }
Esempio n. 2
0
        /// <summary>	Constructor. </summary>
        ///
        /// <remarks>	Paul, 17/01/2015. </remarks>
        ///
        /// <param name="bitsharesConfig">		 	The bitshares configuration. </param>
        /// <param name="bitcoinConfig">		 	The bitcoin configuration. </param>
        /// <param name="bitsharesAccount">		 	The bitshares account. </param>
        /// <param name="bitsharesAsset">		 	The bitshares asset. </param>
        /// <param name="bitcoinDespositAddress">	The bitcoin desposit address. </param>
        public DaemonBase(	RpcConfig bitsharesConfig, RpcConfig bitcoinConfig, 
							string bitsharesAccount, string adminUsernames)
        {
            m_bitshares = new BitsharesWallet(bitsharesConfig.m_url, bitsharesConfig.m_rpcUser, bitsharesConfig.m_rpcPassword);
            m_bitcoin = new BitcoinWallet(bitcoinConfig.m_url, bitcoinConfig.m_rpcUser, bitcoinConfig.m_rpcPassword, false);

            m_bitsharesAccount = bitsharesAccount;
            m_adminUsernames = adminUsernames.Split(',');

            m_addressByteType = (byte)(bitcoinConfig.m_useTestnet ? AltCoinAddressTypeBytes.BitcoinTestnet : AltCoinAddressTypeBytes.Bitcoin);
        }
Esempio n. 3
0
        /// <summary>
        /// Invoke the chosen method with the entered parameters. Try to convert the parameters
        /// to the appropriate type before invoking the method.
        /// </summary>
        /// <param name="wallet">The wallet to invoke the method on.</param>
        /// <param name="method">The method to invoke.</param>
        /// <param name="inputParts">Parameters to pass to the method.</param>
        private static void InvokeMethode(BitcoinWallet wallet, MethodInfo method, string[] inputParts)
        {
            var parameterInfos = method.GetParameters();

            if (parameterInfos.Count() != inputParts.Length - 1)
            {
                Console.WriteLine("The number of given parameters does not match the number of method parameters.");
                Console.WriteLine("Note: Default parameters have to be entered as well!");
                return;
            }

            object[] parameters = new object[inputParts.Length - 1];
            for (int i = 1; i < inputParts.Length; i++)
            {
                if (parameterInfos[i - 1].ParameterType == typeof(string))
                {
                    parameters[i - 1] = Convert.ToString(inputParts[i]);
                }
                else if (parameterInfos[i - 1].ParameterType == typeof(decimal))
                {
                    parameters[i - 1] = Convert.ToDecimal(inputParts[i]);
                }
                else if (parameterInfos[i - 1].ParameterType == typeof(int))
                {
                    parameters[i - 1] = Convert.ToInt32(inputParts[i]);
                }
                else if (parameterInfos[i - 1].ParameterType == typeof(long))
                {
                    parameters[i - 1] = Convert.ToInt64(inputParts[i]);
                }
                else if (parameterInfos[i - 1].ParameterType == typeof(bool))
                {
                    parameters[i - 1] = Convert.ToBoolean(inputParts[i]);
                }
                else
                {
                    parameters[i - 1] = inputParts[i];
                }
            }

            try
            {
                method.Invoke(wallet, parameters);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Something went wrong while invoking the method on the wallet: " + ex.Message);
                Console.WriteLine();
                Console.WriteLine("Remember that invoking methods from this console application with complex input parameters (lists, object, etc.) is not supported).");
            }
        }
Esempio n. 4
0
        /// <summary>	Constructor. </summary>
        ///
        /// <remarks>	Paul, 17/01/2015. </remarks>
        ///
        /// <param name="bitsharesConfig">		 	The bitshares configuration. </param>
        /// <param name="bitcoinConfig">		 	The bitcoin configuration. </param>
        /// <param name="bitsharesAccount">		 	The bitshares account. </param>
        /// <param name="bitsharesAsset">		 	The bitshares asset. </param>
        /// <param name="bitcoinDespositAddress">	The bitcoin desposit address. </param>
        public DaemonBase(	RpcConfig bitsharesConfig, RpcConfig bitcoinConfig, 
							string bitsharesAccount, string bitsharesAsset,
							string bitcoinDespositAddress)
        {
            m_bitshares = new BitsharesWallet(bitsharesConfig.m_url, bitsharesConfig.m_rpcUser, bitsharesConfig.m_rpcPassword);
            m_bitcoin = new BitcoinWallet(bitcoinConfig.m_url, bitcoinConfig.m_rpcUser, bitcoinConfig.m_rpcPassword, false);

            m_bitsharesAccount = bitsharesAccount;
            m_bitsharesAsset = bitsharesAsset;
            m_bitcoinDespoitAddress = bitcoinDespositAddress;

            m_asset = m_bitshares.BlockchainGetAsset(bitsharesAsset);

            m_addressByteType = (byte)(bitcoinConfig.m_useTestnet ? AltCoinAddressTypeBytes.BitcoinTestnet : AltCoinAddressTypeBytes.Bitcoin);
        }
Esempio n. 5
0
        /// <summary>
        /// Print a list of all public methods in the wallet. The methods can be invoked from the command line, 
        /// except for the ones with complex types (like lists, classes and dictionaries) as input parameters.
        /// </summary>
        /// <param name="wallet">Wallet to list commands for.</param>
        public static void ShowCommands(BitcoinWallet wallet)
        {
            Type type = wallet.GetType();
            var methods = type.GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.Instance)
                .Where(m => m.IsPublic && !m.IsConstructor && !m.IsSpecialName)
                .OrderBy(m => m.Name)
                .ToList();

            string input = "h";
            while (input != "q")
            {
                Console.Clear();

                int index;
                string[] inputParts = input.Split(new[] { "," }, StringSplitOptions.None);
                if (!string.IsNullOrEmpty(input) && int.TryParse(inputParts[0], out index) && methods.Count > index)
                {
                    InvokeMethode(wallet, methods[index], inputParts);
                }
                else
                {
                    Console.WriteLine("[h] Show this menu");
                    Console.WriteLine("===================");

                    for (int methodIndex = 0; methodIndex < methods.Count; methodIndex++)
                    {
                        Console.Write("[{0}] ", methodIndex);
                        PrintMethod(methods[methodIndex]);
                    }

                    Console.WriteLine("===================");
                    Console.WriteLine("[q] Quit");
                }

                input = Console.ReadLine();
            }
        }
Esempio n. 6
0
        static void Main(string[] args)
        {
            BitcoinWallet wallet = new BitcoinWallet(
                ConfigurationManager.AppSettings["rpc_host"],
                ConfigurationManager.AppSettings["rpc_user"],
                ConfigurationManager.AppSettings["rpc_pw"],
                true);

            ShowCommands(wallet);
        }