Ejemplo n.º 1
0
 protected override void OnPluginsLoaded()
 {
     walletProvider = GetService <IWalletProvider>();
     if (Settings.Default.AutoStart)
     {
         walletProvider.WalletOpened += WalletProvider_WalletOpened;
     }
 }
Ejemplo n.º 2
0
 public ReportController(
     ILogger <InternalController> logger,
     UserManager <ApplicationUser> userManager,
     ApplicationDbContext context,
     IWalletProvider walletProvider,
     IOptions <KycSettings> kycSettings,
     IOptions <ExchangeSettings> settings) : base(logger, userManager, context, settings, walletProvider, kycSettings)
 {
 }
Ejemplo n.º 3
0
 public BaseWalletController(
     ILogger logger,
     UserManager <ApplicationUser> userManager,
     ApplicationDbContext context,
     IOptions <ExchangeSettings> settings,
     IWalletProvider walletProvider,
     IOptions <KycSettings> kycSettings) : base(logger, userManager, context, settings)
 {
     _walletProvider = walletProvider;
     _kycSettings    = kycSettings.Value;
 }
Ejemplo n.º 4
0
 public WalletController(
     IWalletProvider walletProvider,
     IPersistedCheckoutContextProvider persistedCheckoutContextProvider,
     NoticeProvider noticeProvider,
     ISkinProvider skinProvider)
 {
     WalletProvider = walletProvider;
     PersistedCheckoutContextProvider = persistedCheckoutContextProvider;
     NoticeProvider = noticeProvider;
     SkinProvider   = skinProvider;
 }
Ejemplo n.º 5
0
 public Operator(Blockchain blockchain,
                 IHashProvider hashProvider,
                 IWalletProvider walletProvider,
                 IOptions <CoinSettings> coinSettings,
                 ILogger <Operator> logger)
 {
     _blockchain     = blockchain;
     _hashProvider   = hashProvider;
     _walletProvider = walletProvider;
     _coinSettings   = coinSettings.Value;
     _logger         = logger;
 }
Ejemplo n.º 6
0
 private void NeoSystem_ServiceAdded(object sender, object service)
 {
     if (service is IWalletProvider)
     {
         walletProvider       = service as IWalletProvider;
         System.ServiceAdded -= NeoSystem_ServiceAdded;
         if (Settings.Default.AutoStart)
         {
             walletProvider.WalletChanged += WalletProvider_WalletChanged;
         }
     }
 }
Ejemplo n.º 7
0
 private void NeoSystem_ServiceAdded(object sender, object service)
 {
     if (service is not IWalletProvider provider)
     {
         return;
     }
     walletProvider          = provider;
     neoSystem.ServiceAdded -= NeoSystem_ServiceAdded;
     if (settings.AutoStart)
     {
         walletProvider.WalletChanged += WalletProvider_WalletChanged;
     }
 }
Ejemplo n.º 8
0
        public WalletService(IUserSession userSession, IWalletProvider walletProvider)
        {
            if (userSession == null)
            {
                throw new ArgumentNullException("userSession");
            }
            if (walletProvider == null)
            {
                throw new ArgumentNullException("walletProvider");
            }

            this.userSession    = userSession;
            this.walletProvider = walletProvider;
        }
Ejemplo n.º 9
0
 public CheckoutCreditCardController(
     CreditCardTypeProvider creditCardTypeProvider,
     ICreditCardValidationProvider creditCardValidationProvider,
     NoticeProvider noticeProvider,
     IPaymentOptionProvider paymentOptionProvider,
     IPersistedCheckoutContextProvider persistedCheckoutContextProvider,
     IWalletProvider walletProvider)
 {
     CreditCardTypeProvider       = creditCardTypeProvider;
     CreditCardValidationProvider = creditCardValidationProvider;
     NoticeProvider                   = noticeProvider;
     PaymentOptionProvider            = paymentOptionProvider;
     PersistedCheckoutContextProvider = persistedCheckoutContextProvider;
     WalletProvider                   = walletProvider;
 }
Ejemplo n.º 10
0
 public WalletController(
     ILogger <WalletController> logger,
     UserManager <ApplicationUser> userManager,
     ApplicationDbContext context,
     IOptions <ExchangeSettings> settings,
     IWalletProvider walletProvider,
     IOptions <KycSettings> kycSettings,
     IEmailSender emailSender,
     ITripwire tripwire,
     IUserLocks userLocks) : base(logger, userManager, context, settings, walletProvider, kycSettings)
 {
     _emailSender = emailSender;
     _tripwire    = tripwire;
     _userLocks   = userLocks;
 }
Ejemplo n.º 11
0
 public InternalController(
     ILogger <InternalController> logger,
     UserManager <ApplicationUser> userManager,
     ApplicationDbContext context,
     IOptions <ExchangeSettings> settings,
     IOptions <WalletSettings> walletSettings,
     IWalletProvider walletProvider,
     IOptions <KycSettings> kycSettings,
     IWebsocketTokens websocketTokens,
     ITripwire tripwire,
     IOptions <TripwireSettings> tripwireSettings) : base(logger, userManager, context, settings, walletProvider, kycSettings)
 {
     _walletSettings   = walletSettings.Value;
     _websocketTokens  = websocketTokens;
     _tripwire         = tripwire;
     _tripwireSettings = tripwireSettings.Value;
 }
Ejemplo n.º 12
0
 public ManageController(
     UserManager <ApplicationUser> userManager,
     SignInManager <ApplicationUser> signInManager,
     IEmailSender emailSender,
     ILogger <ManageController> logger,
     UrlEncoder urlEncoder,
     ApplicationDbContext context,
     IOptions <ExchangeSettings> settings,
     IOptions <GeneralSettings> gen,
     IOptions <KycSettings> kyc,
     IWalletProvider walletProvider) : base(logger, userManager, context, settings)
 {
     _signInManager  = signInManager;
     _emailSender    = emailSender;
     _urlEncoder     = urlEncoder;
     _genSettings    = gen.Value;
     _kycSettings    = kyc.Value;
     _walletProvider = walletProvider;
 }
Ejemplo n.º 13
0
 public Broker(ILogger <Broker> logger,
               ApplicationDbContext context,
               IWalletProvider walletProvider,
               IOptions <ApiSettings> apiSettings,
               UserManager <ApplicationUser> userManager,
               IOptions <ExchangeSettings> settings,
               ITripwire tripwire,
               IOptions <FiatProcessorSettings> fiatSettings,
               IEmailSender emailSender)
 {
     _logger         = logger;
     _context        = context;
     _walletProvider = walletProvider;
     _apiSettings    = apiSettings.Value;
     _userManager    = userManager;
     _settings       = settings.Value;
     _tripwire       = tripwire;
     _fiatSettings   = fiatSettings.Value;
     _emailSender    = emailSender;
 }
Ejemplo n.º 14
0
 public DevApiController(
     IWebHostEnvironment webhostEnvironment,
     ILogger <ApiController> logger,
     UserManager <ApplicationUser> userManager,
     SignInManager <ApplicationUser> signInManager,
     ApplicationDbContext context,
     IEmailSender emailSender,
     IOptions <ExchangeSettings> settings,
     IOptions <ApiSettings> apiSettings,
     RoleManager <IdentityRole> roleManager,
     IOptions <KycSettings> kycSettings,
     IWalletProvider walletProvider,
     ITripwire tripwire) : base(logger, userManager, context, settings, walletProvider, kycSettings)
 {
     _webhostEnvironment = webhostEnvironment;
     _signInManager      = signInManager;
     _emailSender        = emailSender;
     _roleManager        = roleManager;
     _apiSettings        = apiSettings.Value;
     _tripwire           = tripwire;
 }
Ejemplo n.º 15
0
        public Transaction AddTransaction(string from, string to, decimal amount, IWalletProvider walletProvider)
        {
            this.CalculateBalances(0);

            if (balances.ContainsKey(from) && balances[from] < amount)
            {
                Console.WriteLine("Not enought coins...");
                return(null);
            }

            var publicKeyHex = CryptographyUtilities.BytesToHex(walletProvider.PublicKey.GetEncoded());
            var transaction  = new Transaction()
            {
                From            = from,
                To              = to,
                Value           = amount,
                SenderPublicKey = publicKeyHex
            };

            string transactionJson = JsonConvert.SerializeObject(transaction, new JsonSerializerSettings()
            {
                ReferenceLoopHandling = ReferenceLoopHandling.Ignore
            });

            var transactionHash = CryptographyUtilities.BytesToHex(CryptographyUtilities.CalcSHA256(transactionJson));

            var signiture = walletProvider.SignTransaction(Encoding.UTF8.GetBytes(transactionHash));

            transaction.TransactionHash = transactionHash;
            transaction.SenderSignature = signiture;

            this.pendingTransactions.Add(transaction);

            StorageFileProvider <Transaction[]> .SetModel(Constants.PendingTransactionsFilePath, this.pendingTransactions.ToArray());

            Console.WriteLine("Transaction is pending...");

            return(transaction);
        }
Ejemplo n.º 16
0
 public FaucetController()
 {
     this.blockchain           = new Blockchain();
     this.faucetWalletProvider = new FaucetWalletProvider();
 }
Ejemplo n.º 17
0
 public WalletController(IWalletProvider walletProvider)
 {
     this.walletProvider = walletProvider;
 }
        public override ITransactionSelectionMethod CreateTransactionSelectionMethod(TransactionSelectionMethodType type, long blockId, BlockElectionDistillate blockElectionDistillate, IWalletProvider walletProvider, BlockChainConfigurations blockChainConfigurations, BlockchainServiceSet serviceSet)
        {
            if (blockElectionDistillate.electionContext is INeuraliumElectionContext neuraliumElectionContext)
            {
                if (type == TransactionSelectionMethodTypes.Instance.Automatic)
                {
                    // ok, this one is meant to be automatic. we wlil try to find the best method
                    //TODO: make this more elaborate. Try to response to the various cues we can use like the declared bounty allocator
                    if (neuraliumElectionContext.BountyAllocationMethod.Version.Type.Value == BountyAllocationMethodTypes.Instance.EqualSplit)
                    {
                        type = NeuraliumTransactionSelectionMethodTypes.Instance.HighestTips;
                    }

                    // the default automatic best choice
                    type = NeuraliumTransactionSelectionMethodTypes.Instance.HighestTips;
                }

                if (type == NeuraliumTransactionSelectionMethodTypes.Instance.HighestTips)
                {
                    // ok, nothing special here, lets just maximize profits by choosing the highest paying transactions
                    return(new NeuraliumHighestTipTransactionSelectionMethod(blockId, neuraliumElectionContext.TransactionTipsAllocationMethod, (INeuraliumWalletProviderProxy)walletProvider, blockElectionDistillate.electionContext.MaximumElectedTransactionCount, ((NeuraliumBlockChainConfigurations)blockChainConfigurations).HighestTipTransactionSelectionStrategySettings, serviceSet.BlockchainTimeService));
                }
            }

            return(base.CreateTransactionSelectionMethod(type, blockId, blockElectionDistillate, walletProvider, blockChainConfigurations, serviceSet));
        }
Ejemplo n.º 19
0
        static async Task Main()
        {
            IConfigurationRoot configuration = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory())
                                               .AddJsonFile("appsettings.json", true, false)
                                               .Build();


            ServiceProvider services = new ServiceCollection().AddLogging(builder => builder.SetMinimumLevel(LogLevel.Trace).AddFile(configuration.GetSection("Logging:File")))
                                       .AddWalletManager(configuration)
                                       .BuildServiceProvider();


            IWalletProvider walletProvider = services.GetService <IWalletProvider>();


            string walletName            = "TestnetDemoWallet" + Guid.NewGuid().ToString();
            string walletPassword        = "******";
            string walletPasswordUpdated = "1234567890";
            string walletRecoverySeed    = @"tackle cousin pet true inner exhibit cradle crazy exact segment hard smooth loan beef crystal speak usage life weekend remove come sock just elite";

            // Create a wallet
            {
                IWalletProviderResult <WalletInfo> walletProviderResult = await walletProvider.CreateWalletAsync(walletName, walletPassword, walletPassword);

                WalletInfo walletInfo = walletProviderResult.Result;
                walletInfo.Dump("Create a wallet"); // `.Dump`  >>>> Prints to console
            }

            // Update a password on a wallet
            {
                IWalletProviderResult walletResult = await walletProvider.UpdateWalletAsync(walletName, walletPassword, walletPasswordUpdated, walletPasswordUpdated);

                walletResult.Dump("Updated password on wallet");
            }

            // GetAsync all wallets
            {
                IWalletProviderResult <IEnumerable <WalletInfo> > walletProviderResult = await walletProvider.GetAllWalletsAsync();

                IEnumerable <WalletInfo> wallets = walletProviderResult.Result;
                wallets.Dump("GetAsync all wallets");
            }

            // Remove the wallet
            {
                IWalletProviderResult walletResult = await walletProvider.RemoveWalletAsync(walletName, walletPasswordUpdated);

                walletResult.Dump("Remove the wallet");
            }

            // Import wallet
            {
                IWalletProviderResult <WalletInfo> walletProviderResult = await walletProvider.ImportWalletAsync(walletName, walletPassword, walletPassword, walletRecoverySeed);

                WalletInfo walletInfo = walletProviderResult.Result;
                walletInfo.Dump("Import wallet");
            }

            // Find an individual wallet
            {
                IWalletProviderResult <WalletInfo> walletProviderResult = await walletProvider.FindWalletAsync(walletName);

                WalletInfo walletInfo = walletProviderResult.Result;
                walletInfo.Dump("Finding an individual wallet");
            }

            // Cleaning up
            {
                IWalletProviderResult walletResult = await walletProvider.RemoveWalletAsync(walletName, walletPassword);

                walletResult.Dump("Cleaned up");
            }
        }