Example #1
0
        public IRpcMethodResult SetDefaultAccount(string address)
        {
            try
            {
                var accountComponent = new AccountComponent();
                var account          = accountComponent.GetAccountById(address);

                if (account != null)
                {
                    accountComponent.SetDefaultAccount(account.Id);
                }
                else
                {
                    throw new CommonException(ErrorCode.Service.Account.ACCOUNT_NOT_FOUND);
                }

                return(Ok());
            }
            catch (CommonException ce)
            {
                return(Error(ce.ErrorCode, ce.Message, ce));
            }
            catch (Exception ex)
            {
                return(Error(ErrorCode.UNKNOWN_ERROR, ex.Message, ex));
            }
        }
Example #2
0
        public static void Initialize()
        {
            var notify = new NotifyComponent();
            BlockchainComponent blockChainComponent = new BlockchainComponent();
            AccountComponent    accountComponent    = new AccountComponent();
            UtxoComponent       utxoComponent       = new UtxoComponent();

            //从配置文件中读取
            ConfigurationTool tool   = new ConfigurationTool();
            NodeConfig        config = tool.GetAppSettings <NodeConfig>("NodeConfig");

            notify.SetCallbackApp(config.WalletNotify);

            if (GlobalActions.TransactionNotifyAction == null)
            {
                GlobalActions.TransactionNotifyAction = NewTransactionNotify;
            }

            blockChainComponent.Initialize();
            var accounts = accountComponent.GetAllAccounts();

            if (accounts.Count == 0)
            {
                var account = accountComponent.GenerateNewAccount();
                accountComponent.SetDefaultAccount(account.Id);
            }

            BlockchainJob.Current = new BlockchainJob();
            utxoComponent.Initialize();
        }
Example #3
0
        public static void Initialize()
        {
            BlockchainComponent blockChainComponent = new BlockchainComponent();
            AccountComponent    accountComponent    = new AccountComponent();
            UtxoComponent       utxoComponent       = new UtxoComponent();

            blockChainComponent.Initialize();
            var accounts = accountComponent.GetAllAccounts();

            if (accounts.Count == 0)
            {
                var account = accountComponent.GenerateNewAccount();
                accountComponent.SetDefaultAccount(account.Id);
            }

            BlockchainJob.Current = new BlockchainJob();
            utxoComponent.Initialize();
        }
Example #4
0
        public static void Initialize()
        {
            var notify = new NotifyComponent();
            BlockchainComponent blockChainComponent = new BlockchainComponent();
            AccountComponent    accountComponent    = new AccountComponent();

            BlockchainJob.Current = new BlockchainJob();

            BlockDac.Default.GetAccountByLockScript = BlockchainJob.Current.GetAccountByLockScript;

            //从配置文件中读取
            ConfigurationTool tool = new ConfigurationTool();

            config = tool.GetAppSettings <NodeConfig>("NodeConfig");
            if (config == null)
            {
                GlobalParameters.IsPool = false;
                config = new NodeConfig();
            }
            else
            {
                notify.SetCallbackApp(config.WalletNotify);
                BlockchainJob.Current.P2PJob.LocalIP = config.LocalIP;
                GlobalParameters.IsPool = config.IsPool;
            }

            ConfigCenter.ConfigNode = config;



            //TODO 待验证删除
            //if (config != null)
            //{
            //    notify.SetCallbackApp(config.WalletNotify);
            //    BlockchainJob.Current.P2PJob.IPAddress = config.Ip;
            //    GlobalParameters.IsPool = config.IsPool;
            //}
            //else
            //{
            //    GlobalParameters.IsPool = false;
            //}

            if (GlobalActions.TransactionNotifyAction == null)
            {
                GlobalActions.TransactionNotifyAction = NewTransactionNotify;
            }

            blockChainComponent.Initialize();
            var accounts = AccountDac.Default.GetAccountBook();

            if (accounts.Count == 0)
            {
                var account = accountComponent.GenerateNewAccount(false);
                accountComponent.SetDefaultAccount(account.Id);
            }

            var defaultAccount = AppDac.Default.GetDefaultAccount();

            if (string.IsNullOrEmpty(defaultAccount))
            {
                var first = AccountDac.Default.GetAccountBook().FirstOrDefault();
                UserSettingComponent component = new UserSettingComponent();
                component.SetDefaultAccount(first);
            }

            TransactionPool.Instance.Load();
        }