コード例 #1
0
        public IActionResult RequestWallet()
        {
            int userId = int.Parse(_userService.GetUserId(User));

            var registrant = _registrantService.GetRegistrantByUserId(userId, includeWallets: true);

            if (registrant.Wallets.Count >= Constants.maxWalletsPerUser)
            {
                TempData["Message"] = "You are at your max wallet count (" + Constants.maxWalletsPerUser + ")";
                return(RedirectToAction("UserWallets"));
            }

            var newWallet = new WalletServiceModel
            {
                Number         = new Random().Next(100, 999999999),
                RegistrantId   = registrant.Id,
                IsVerified     = false,
                CreatedById    = userId,
                WalletStatusId = (int)StatusEnum.Status.Okay
            };

            _walletService.CreateWallet(newWallet);

            TempData["Message"] = "A new wallet has been requested for creation!";

            return(RedirectToAction("UserWallets"));
        }
コード例 #2
0
        public async Task <Response> MobileCheckIn(string organisationId, MobileUpdateCountRequest payload)
        {
            var walletRequest = new CreateWalletRequest
            {
                MobileNumber = payload.MobileNumber
            };

            var wallet = await _walletService.CreateWallet(walletRequest, true);

            var session = await _sessionService.CreateSession(payload.MobileNumber, wallet);

            var organisation = await _organisationRepository.GetAsync(Guid.Parse(organisationId));

            if (organisation == default)
            {
                throw new NotFoundException(Messages.Org_NotExists);
            }

            await _smsService.SendWelcomeSms(payload.MobileNumber, organisation.Name, session.ExpireAt.Value, session.Id);

            var updateCounterRequest = new UpdateCountRequest
            {
                Latitude  = payload.Latitude,
                Longitude = payload.Longitude,
                WalletId  = wallet.Id.ToString()
            };

            var counterResponse = await UpdateCountAsync(organisationId, updateCounterRequest, ScanType.CheckIn, true);

            return(counterResponse);
        }
コード例 #3
0
        public async Task <IActionResult> Create(string mnemonic = null, string passphrase = null)
        {
            string[] mnemonicDefault = await _walletService.CreateMnemonic(Language.English, WordCount.TwentyFour);

            string[] passphraseDefault = await _walletService.CreateMnemonic(Language.English, WordCount.Twelve);

            string joinMmnemonic  = string.Join(" ", mnemonic ?? string.Join(' ', mnemonicDefault));
            string joinPassphrase = string.Join(" ", passphrase ?? string.Join(' ', passphraseDefault));
            string id             = _walletService.CreateWallet(joinMmnemonic.ToSecureString(), joinPassphrase.ToSecureString());
            var    session        = _walletService.SessionAddOrUpdate(new Session(id.ToSecureString(),
                                                                                  joinPassphrase.ToSecureString()));

            var request = _walletService.Addresses(session.SessionId);

            if (!request.Success)
            {
                return(new BadRequestObjectResult(request.NonSuccessMessage));
            }

            if (request.Result.Any() != true)
            {
                return(new NotFoundResult());
            }

            return(new OkObjectResult(new
            {
                path = Util.WalletPath(id),
                identifier = id,
                mnemonic = joinMmnemonic,
                passphrase = joinPassphrase,
                address = request.Result
            }));
        }
コード例 #4
0
        public IActionResult CreateWallet(Wallet wallet)
        {
            if (_walletService.CreateWallet(wallet))
            {
                return(Created(string.Empty, wallet));
            }

            return(BadRequest());
        }
コード例 #5
0
        public async Task <IActionResult> CreateNew([FromBody] AddWalletDto addWalletDto)
        {
            var result = await _walletService.CreateWallet(addWalletDto, UserId);

            if (!result.Succedeed)
            {
                return(BadRequest());
            }
            return(Ok(result.Value));
        }
コード例 #6
0
        public ActionResult <WalletResponse> CreateWallet()
        {
            var wallet = _walletService.CreateWallet();

            return(new WalletResponse
            {
                PrivateKey = wallet.PrivateKey,
                PublicAddress = Address.AddChecksum(wallet.Address)
            });
        }
コード例 #7
0
        public ActionResult Create([Bind(Include = "Id,Balance,Name")] WalletModel walletModel)
        {
            if (ModelState.IsValid)
            {
                walletService.CreateWallet(mapper.Map <WalletModel, WalletDTO>(walletModel));
                return(RedirectToAction("Index"));
            }


            return(View(mapper.Map <WalletModel, WalletDTO>(walletModel)));
        }
コード例 #8
0
        public static void CreateWalletFromKnownMnemonic(IConsole console, IWalletService walletService)
        {
            using var mnemonic   = Prompt.GetPasswordAsSecureString("Mnemonic:", ConsoleColor.Yellow);
            using var passphrase = Prompt.GetPasswordAsSecureString("Passphrase:", ConsoleColor.Yellow);

            var id   = walletService.CreateWallet(mnemonic, passphrase);
            var path = Util.WalletPath(id);

            console.WriteLine($"Wallet ID: {id}");
            console.WriteLine($"Wallet Path: {path}");
        }
コード例 #9
0
        public IActionResult CreateWallet(WalletModel item)
        {
            if (!ModelState.IsValid)
            {
                return(View("CreateWalletView", item));
            }

            int newId;

            newId = _walletService.CreateWallet(item);

            return(RedirectToAction("DetailsWallet", "Wallet", new { id = newId }));
        }
コード例 #10
0
        public void OnPost(CreateWalletDetails createWalletDetails)
        {
            CreateWalletDetails = createWalletDetails;
            var walletCreated = _walletService.CreateWallet(createWalletDetails);

            if (walletCreated)
            {
                var addresses = _walletService.GenerateAddresses(createWalletDetails.Name, "account 0", 3);
                Wallet = new MiniWallet(createWalletDetails.Name, createWalletDetails.Password, addresses);
            }
            else
            {
                ErrorMessage = "Wallet already exists";
            }
        }
コード例 #11
0
        public async Task <IActionResult> CreateKey([FromBody] CreateApiKeyRequest request)
        {
            if (request == null)
            {
                return(BadRequest());
            }

            var client = await _clientAccountService.GetClientByIdAsync(request.ClientId);

            if (client == null)
            {
                ModelState.AddModelError("ClientId", request.ClientId);
                return(BadRequest(ModelState));
            }

            var apiKey = await _walletService.CreateWallet(request.ClientId, request.Apiv2Only, request.Name, request.Description);

            return(Ok(_mapper.Map <ApiKeyDto>(apiKey)));
        }
コード例 #12
0
        public async Task <IActionResult> CreateWallet([FromQuery] string walletName)
        {
            var wallet = await walletService.CreateWallet(walletName);

            wallet.Validate();
            if (!wallet.IsValid)
            {
                StringBuilder sb = new StringBuilder();
                foreach (var n in wallet.Notifications)
                {
                    sb.Append(n.Message);
                    sb.Append("\n");
                }

                return(BadRequest(sb.ToString()));
            }

            await walletService.Save(wallet);

            return(Ok(Mapper.Map <WalletDto>(wallet)));
        }
コード例 #13
0
        public async Task <IActionResult> CreateWallet()
        {
            string[] mnemonicDefault = await _walletService.CreateMnemonic(NBitcoin.Language.English, NBitcoin.WordCount.TwentyFour);

            string[] passphraseDefault = await _walletService.CreateMnemonic(NBitcoin.Language.English, NBitcoin.WordCount.Twelve);

            string joinMmnemonic  = string.Join(" ", mnemonicDefault);
            string joinPassphrase = string.Join(" ", passphraseDefault);
            string id             = _walletService.CreateWallet(joinMmnemonic.ToSecureString(), joinPassphrase.ToSecureString());
            var    session        = _walletService.SessionAddOrUpdate(new Session(id.ToSecureString(),
                                                                                  joinPassphrase.ToSecureString()));
            var address = _walletService.Addresses(session.SessionId).First();

            return(new OkObjectResult(new
            {
                path = Util.WalletPath(id),
                identifier = id,
                mnemonic = joinMmnemonic,
                passphrase = joinPassphrase,
                address
            }));
        }
コード例 #14
0
        public async Task <IActionResult> CreateWallet()
        {
            var creds = await walletService.CreateWallet();

            return(new OkObjectResult(creds));
        }
コード例 #15
0
        public override async Task Execute()
        {
            var creds = await walletService.CreateWallet();

            console.WriteLine($"Created Wallet {creds.Identifier} with password: {creds.Password}");
        }
コード例 #16
0
        //[Authorize(Roles = "Admin, Vendor")]
        public async Task <IActionResult> CreateWallet([FromBody] CreateWalletRequest request)
        {
            var result = await walletService.CreateWallet(request);

            return(StatusCode((int)result.Code, result.Value));
        }
コード例 #17
0
        public async Task <IActionResult> CreateWallet([FromBody] CredentialsDto credentials)
        {
            var creds = await walletService.CreateWallet();

            return(new OkObjectResult(creds));
        }
コード例 #18
0
        public async override Task Execute()
        {
            var yesNo = Prompt.GetYesNo("Create default mnemonic and passphrase?", true, ConsoleColor.Yellow);

            try
            {
                if (yesNo)
                {
                    var mnemonicDefault = await _walletService.CreateMnemonic(NBitcoin.Language.English, NBitcoin.WordCount.TwentyFour);

                    var passphraseDefault = await _walletService.CreateMnemonic(NBitcoin.Language.English, NBitcoin.WordCount.Twelve);

                    var joinMmnemonic  = string.Join(" ", mnemonicDefault);
                    var joinPassphrase = string.Join(" ", passphraseDefault);
                    var id             = _walletService.CreateWallet(joinMmnemonic.ToSecureString(), joinPassphrase.ToSecureString());
                    var path           = Util.WalletPath(id);

                    _console.WriteLine();

                    _console.WriteLine("Wallet Path:");
                    _console.ForegroundColor = ConsoleColor.Green;
                    _console.WriteLine($"{path}");
                    _console.ForegroundColor = ConsoleColor.White;

                    _console.WriteLine();

                    _console.WriteLine("Wallet ID:");
                    _console.ForegroundColor = ConsoleColor.Green;
                    _console.WriteLine($"{id}");
                    _console.ForegroundColor = ConsoleColor.White;

                    _console.WriteLine();

                    _console.WriteLine("Seed phrase:");
                    _console.ForegroundColor = ConsoleColor.Green;
                    _console.WriteLine($"{joinMmnemonic}");
                    _console.ForegroundColor = ConsoleColor.White;

                    _console.WriteLine();

                    _console.WriteLine("Passphrase:");
                    _console.ForegroundColor = ConsoleColor.Green;
                    _console.WriteLine($"{joinPassphrase}");
                    _console.ForegroundColor = ConsoleColor.White;


                    _console.WriteLine();

                    joinMmnemonic.ZeroString();
                    joinPassphrase.ZeroString();
                }
                else
                {
                    using var mnemonic   = Prompt.GetPasswordAsSecureString("Mnemonic:", ConsoleColor.Yellow);
                    using var passphrase = Prompt.GetPasswordAsSecureString("Passphrase:", ConsoleColor.Yellow);

                    var id   = _walletService.CreateWallet(mnemonic, passphrase);
                    var path = Util.WalletPath(id);

                    _console.WriteLine($"Wallet ID: {id}");
                    _console.WriteLine($"Wallet Path: {path}");
                }
            }
            catch (Exception ex)
            {
                _console.ForegroundColor = ConsoleColor.Red;
                _console.WriteLine($"Please create the mnemonics first. See help for more info.\n {ex.Message}");
                _console.ForegroundColor = ConsoleColor.White;
            }
        }
コード例 #19
0
        public async Task <IActionResult> CreateWallet(WalletParameters walletParameters)
        {
            var response = await _walletService.CreateWallet(walletParameters);

            return(Ok(new Response(response, HttpStatusCode.OK)));
        }