public async Task InsertWalletAsync_NoEntries_SingleWalletEntry()
        {
            //// Arrange

            // Setup In-Memory Database at desired state

            DbContextOptions <WalletContext> dbContextOptions = new DbContextOptionsBuilder <WalletContext>()
                                                                .UseInMemoryDatabase(databaseName: "InsertWalletAsync_NoEntries_SingleWalletEntry")
                                                                .Options;

            // Initialize Entry

            WalletEntry expectedEntry = new WalletEntry {
                Id = Guid.NewGuid().ToString(), EventTime = DateTime.UtcNow, Amount = 10, BalanceBefore = 0
            };

            //// Act

            using (WalletContext context = new WalletContext(dbContextOptions))
            {
                IWalletRepository walletRepository = new WalletRepository(context);
                await walletRepository.InsertWalletEntryAsync(expectedEntry);
            }

            //// Assert

            DbSet <WalletEntry> actualWalletEntries;

            using (WalletContext context = new WalletContext(dbContextOptions))
            {
                actualWalletEntries = context.Transactions;
                Assert.Collection(actualWalletEntries, actualWalletEntry => actualWalletEntry.ShouldCompare(expectedEntry));
            }
        }
        public async Task GetLastWalletEntryAsync_SingleEntry_ReturnsTheEntry()
        {
            //// Arrange

            // Setup In-Memory Database at desired state

            DbContextOptions <WalletContext> dbContextOptions = new DbContextOptionsBuilder <WalletContext>()
                                                                .UseInMemoryDatabase(databaseName: "GetLastWalletEntryAsync_SingleEntry_ReturnsTheEntry")
                                                                .Options;

            WalletEntry expectedEntry = new WalletEntry {
                Id = Guid.NewGuid().ToString(), EventTime = DateTime.UtcNow, Amount = 10, BalanceBefore = 0
            };

            using (WalletContext context = new WalletContext(dbContextOptions))
            {
                context.Add(expectedEntry);
                context.SaveChanges();
            }

            //// Act

            WalletEntry actualEntry;

            using (WalletContext context = new WalletContext(dbContextOptions))
            {
                IWalletRepository walletRepository = new WalletRepository(context);
                actualEntry = await walletRepository.GetLastWalletEntryAsync();
            }

            //// Assert

            Assert.NotNull(actualEntry);
            actualEntry.ShouldCompare(expectedEntry);
        }
        private void HandleOnWalletEntryAdded(WalletEntry walletEntry)
        {
            this.dispatcher.BeginInvoke((Action)(() =>
                                                 this.WalletEntries.Insert(0, walletEntry)));

            this.BitBalance = this.walletMonitor.BitBalance;
        }
Exemple #4
0
 public WalletEntry GetEntry(UInt160 scriptHash)
 {
     byte[] redeemScript, encryptedPrivateKey;
     GetEncryptedEntry(scriptHash, out redeemScript, out encryptedPrivateKey);
     if (redeemScript == null || encryptedPrivateKey == null) return null;
     if ((redeemScript.Length - 3) % 34 != 0 || encryptedPrivateKey.Length % 96 != 0) throw new IOException();
     ProtectedMemory.Unprotect(masterKey, MemoryProtectionScope.SameProcess);
     byte[] decryptedPrivateKey;
     using (AesManaged aes = new AesManaged())
     {
         aes.Padding = PaddingMode.None;
         using (ICryptoTransform decryptor = aes.CreateDecryptor(masterKey, iv))
         {
             decryptedPrivateKey = decryptor.TransformFinalBlock(encryptedPrivateKey, 0, encryptedPrivateKey.Length);
         }
     }
     ProtectedMemory.Protect(masterKey, MemoryProtectionScope.SameProcess);
     byte[][] privateKeys = new byte[encryptedPrivateKey.Length / 96][];
     for (int i = 0; i < privateKeys.Length; i++)
     {
         privateKeys[i] = new byte[96];
         Buffer.BlockCopy(decryptedPrivateKey, i * 96, privateKeys[i], 0, 96);
     }
     WalletEntry entry = new WalletEntry(redeemScript, privateKeys);
     Array.Clear(decryptedPrivateKey, 0, decryptedPrivateKey.Length);
     for (int i = 0; i < privateKeys.Length; i++)
     {
         Array.Clear(privateKeys[i], 0, privateKeys[i].Length);
     }
     return entry;
 }
Exemple #5
0
        public WalletEntry CreateEntry()
        {
            WalletEntry entry = WalletEntry.Create(CreatePrivateKey());

            accounts.Add(entry);
            return(entry);
        }
Exemple #6
0
        public async Task <Balance> WithdrawFundsAsync(Withdrawal withdrawal)
        {
            decimal entryAmount    = withdrawal.Amount;
            Balance currentBalance = await GetBalanceAsync();

            decimal currentBalanceAmount = currentBalance.Amount;

            if (entryAmount > currentBalance.Amount)
            {
                throw new InsufficientBalanceException();
            }

            entryAmount *= -1;

            WalletEntry withdrawalEntry = new WalletEntry()
            {
                Amount        = entryAmount,
                BalanceBefore = currentBalanceAmount,
                EventTime     = DateTimeOffset.UtcNow
            };

            await _walletRepository.InsertWalletEntryAsync(withdrawalEntry);

            Balance newBalance = new Balance
            {
                Amount = currentBalanceAmount + entryAmount
            };

            return(newBalance);
        }
Exemple #7
0
        private string FormatWalletEntryToText(WalletEntry entry)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append($@"Name: {entry.Name}{Environment.NewLine}Type: {entry.Type}{Environment.NewLine}Public Address: {entry.PublicAddress}{Environment.NewLine}Private Key: {entry.PublicAddress}{Environment.NewLine}Date Created: {entry.PublicAddress}{Environment.NewLine}Description: {entry.PublicAddress}");
            return(builder.ToString());
        }
        public async Task InsertWalletAsync_MissingId_ThrowsInvalidOperationException()
        {
            //// Arrange

            // Setup In-Memory Database at desired state

            DbContextOptions <WalletContext> dbContextOptions = new DbContextOptionsBuilder <WalletContext>()
                                                                .UseInMemoryDatabase(databaseName: "InsertWalletAsync_MissingId_ThrowsInvalidOperationException")
                                                                .Options;

            // Initialize Entry

            WalletEntry missingIdEntry = new WalletEntry {
                Id = null, EventTime = DateTime.UtcNow, Amount = 10, BalanceBefore = 0
            };

            //// Act / Assert

            using (WalletContext context = new WalletContext(dbContextOptions))
            {
                IWalletRepository walletRepository = new WalletRepository(context);
                await Assert.ThrowsAsync <InvalidOperationException>(() =>
                                                                     walletRepository.InsertWalletEntryAsync(missingIdEntry)
                                                                     );
            }
        }
Exemple #9
0
        public async Task WithdrawFundsAsync_ValidWithdrawalAmount_ReturnsExpectedBalance()
        {
            ////Arrange

            decimal lastTransactionBalanceBefore = 20;
            decimal lastTransactionAmount        = 10;
            decimal withdrawalAmount             = 15;
            decimal withdrawalBalanceBefore      = 30;

            // Setup Mocks

            Mock <IWalletRepository> walletRepositoryMock = new Mock <IWalletRepository>();

            WalletEntry lastTransaction = new WalletEntry {
                Amount = lastTransactionAmount, BalanceBefore = lastTransactionBalanceBefore
            };

            walletRepositoryMock
            .Setup(walletRepository => walletRepository.GetLastWalletEntryAsync())
            .Returns(Task.FromResult(lastTransaction));

            walletRepositoryMock
            .Setup(walletRepositoryMock => walletRepositoryMock.InsertWalletEntryAsync(It.Is <WalletEntry>(
                                                                                           walletEntry => _compareWalletEntry(walletEntry, withdrawalAmount, withdrawalBalanceBefore)))
                   )
            .Returns(Task.CompletedTask);

            IWalletRepository walletRepository = walletRepositoryMock.Object;

            // Initialize SUT

            IWalletService walletService = new WalletService(walletRepository);
            Withdrawal     withdrawal    = new Withdrawal {
                Amount = withdrawalAmount
            };

            // Set expectations

            decimal expectedBalanceAmount = 15;
            Balance expectedBalance       = new Balance {
                Amount = expectedBalanceAmount
            };


            //// Act

            Balance actualBalance = await walletService.WithdrawFundsAsync(withdrawal);

            //// Assert

            actualBalance.ShouldCompare(expectedBalance);

            walletRepositoryMock.Verify(walletRepository => walletRepository.GetLastWalletEntryAsync(), Times.Once);
            walletRepositoryMock.Verify(walletRepository => walletRepository.InsertWalletEntryAsync(It.Is <WalletEntry>(
                                                                                                        walletEntry => _compareWalletEntry(walletEntry, -1 * withdrawalAmount, withdrawalBalanceBefore))
                                                                                                    ), Times.Once);
            walletRepositoryMock.VerifyNoOtherCalls();
        }
 public AccountDetailsDialog(WalletEntry entry)
 {
     InitializeComponent();
     textBox1.Text = Wallet.ToAddress(entry.ScriptHash);
     textBox2.Text = entry.ScriptHash.ToString();
     textBox3.Text = string.Format("{0}/{1}", entry.N, entry.M);
     textBox4.Text = entry.RedeemScript.ToHexString();
     textBox5.Text = string.Join("\r\n", entry.PublicKeys.Select(p => ECPoint.FromBytes(p, ECCurve.Secp256r1).ToString()));
 }
 public ViewPrivateKeyDialog(WalletEntry entry)
 {
     InitializeComponent();
     textBox3.Text = entry.Address;
     using (entry.Decrypt())
     {
         textBox1.Text = entry.PrivateKey.ToHexString();
     }
     textBox2.Text = entry.Export();
 }
 public ViewPrivateKeyDialog(WalletEntry entry)
 {
     InitializeComponent();
     textBox3.Text = entry.Address;
     using (entry.Decrypt())
     {
         textBox1.Text = entry.PrivateKey.ToHexString();
     }
     textBox2.Text = entry.Export();
 }
Exemple #13
0
        private void 查看私钥VToolStripMenuItem_Click(object sender, EventArgs e)
        {
            bool        p2sh;
            WalletEntry entry = wallet.FindEntry(Wallet.ToScriptHash(listView1.SelectedItems[0].Text, out p2sh));

            using (ViewPrivateKeyDialog dialog = new ViewPrivateKeyDialog(entry))
            {
                dialog.ShowDialog();
            }
        }
Exemple #14
0
        public WalletEntry Import(string wif)
        {
            bool compressed;

            byte[]      privateKey = GetPrivateKeyFromWIF(wif, out compressed);
            WalletEntry entry      = WalletEntry.Create(privateKey, compressed);

            accounts.Add(entry);
            return(entry);
        }
Exemple #15
0
 public WalletEntry CreateEntry()
 {
     using (CngKey key = CngKey.Create(CngAlgorithm.ECDsaP256, null, new CngKeyCreationParameters { ExportPolicy = CngExportPolicies.AllowPlaintextArchiving }))
     {
         byte[] privateKey = key.Export(CngKeyBlobFormat.EccPrivateBlob);
         byte[] redeemScript = ScriptBuilder.CreateRedeemScript(1, Secp256r1Point.FromBytes(privateKey));
         WalletEntry entry = new WalletEntry(redeemScript, privateKey);
         SaveEntry(entry);
         Array.Clear(privateKey, 0, privateKey.Length);
         return entry;
     }
 }
        public async Task InsertWalletAsync_PreviousWalletEntries_NewWalletEntry()
        {
            //// Arrange

            // Setup In-Memory Database at desired state

            DbContextOptions <WalletContext> dbContextOptions = new DbContextOptionsBuilder <WalletContext>()
                                                                .UseInMemoryDatabase(databaseName: "InsertWalletAsync_PreviousWalletEntries_NewWalletEntry")
                                                                .Options;

            WalletEntry[] previousEntries = new[] {
                new WalletEntry {
                    Id = Guid.NewGuid().ToString(), EventTime = DateTime.UtcNow, Amount = 10, BalanceBefore = 0
                },
                new WalletEntry {
                    Id = Guid.NewGuid().ToString(), EventTime = DateTime.UtcNow.AddTicks(1), Amount = 10, BalanceBefore = 0
                }
            };
            using (WalletContext context = new WalletContext(dbContextOptions))
            {
                await context.AddRangeAsync(previousEntries);

                context.SaveChanges();
            }

            // Initialize Entry

            WalletEntry expectedNewEntry = new WalletEntry {
                Id = Guid.NewGuid().ToString(), EventTime = DateTime.UtcNow, Amount = 10, BalanceBefore = 0
            };

            //// Act

            using (WalletContext context = new WalletContext(dbContextOptions))
            {
                IWalletRepository walletRepository = new WalletRepository(context);
                await walletRepository.InsertWalletEntryAsync(expectedNewEntry);
            }

            //// Assert

            DbSet <WalletEntry> actualWalletEntries;

            using (WalletContext context = new WalletContext(dbContextOptions))
            {
                actualWalletEntries = context.Transactions;
                Assert.Collection(actualWalletEntries,
                                  walletEntry => walletEntry.ShouldCompare(previousEntries[0]),
                                  walletEntry => walletEntry.ShouldCompare(previousEntries[1]),
                                  walletEntry => walletEntry.ShouldCompare(expectedNewEntry));
            }
        }
Exemple #17
0
        private void 创建新地址NToolStripMenuItem_Click(object sender, EventArgs e)
        {
            WalletEntry entry = wallet.CreateEntry();

            wallet.Save(wallet_path, password);
            listView1.Items.Add(new ListViewItem(new[] { entry.Address, "" })
            {
                Name = entry.Address
            });
            RefreshWallet();
            listView1.SelectedIndices.Clear();
            listView1.Items[entry.Address].Selected = true;
        }
Exemple #18
0
        public async Task <Balance> GetBalanceAsync()
        {
            WalletEntry walletEntry = await _walletRepository.GetLastWalletEntryAsync();

            // Default BalanceBefore to 0 if there are no transactions
            decimal amount = walletEntry == default(WalletEntry) ? 0 : (walletEntry.BalanceBefore + walletEntry.Amount);

            Balance currentBalance = new Balance
            {
                Amount = amount
            };

            return(currentBalance);
        }
Exemple #19
0
 // POST: api/WalletEntry
 public IHttpActionResult Post([FromBody] WalletEntry walletEntry)
 {
     if (ModelState.IsValid)
     {
         walletEntry.RequestedAt = DateTime.UtcNow;
         walletEntry.Status      = "Pending";
         _walletEntryRepository.Insert(walletEntry);
         return(StatusCode(HttpStatusCode.Created));
     }
     else
     {
         return(StatusCode(HttpStatusCode.BadRequest));
     }
 }
Exemple #20
0
 private void 导入私钥IToolStripMenuItem_Click(object sender, EventArgs e)
 {
     using (ImportPrivateKeyDialog dialog = new ImportPrivateKeyDialog())
     {
         if (dialog.ShowDialog() != DialogResult.OK)
         {
             return;
         }
         WalletEntry entry = wallet.Import(dialog.WIF);
         wallet.Save(wallet_path, password);
         listView1.Items.Add(new ListViewItem(new[] { entry.Address, "" })
         {
             Name = entry.Address
         });
         RefreshWallet();
         listView1.SelectedIndices.Clear();
         listView1.Items[entry.Address].Selected = true;
     }
 }
Exemple #21
0
        public async Task WithdrawalFundsAsync_WithdrawalAmountExceedsBalance_ThrowsInsufficientBalanceException()
        {
            ////Arrange

            decimal lastTransactionBalanceBefore = 50;
            decimal lastTransactionAmount        = 10;
            decimal withdrawalAmount             = 100;

            // Setup Mocks

            WalletEntry lastTransaction = new WalletEntry {
                Amount = lastTransactionAmount, BalanceBefore = lastTransactionBalanceBefore
            };
            Mock <IWalletRepository> walletRepositoryMock = new Mock <IWalletRepository>();

            walletRepositoryMock
            .Setup(walletRepository => walletRepository.GetLastWalletEntryAsync())
            .Returns(Task.FromResult(lastTransaction));

            IWalletRepository walletRepository = walletRepositoryMock.Object;

            // Initialize SUT

            IWalletService walletService = new WalletService(walletRepository);
            Withdrawal     withdrawal    = new Withdrawal {
                Amount = withdrawalAmount
            };

            //// Act

            async Task withdrawalTask() => await walletService.WithdrawFundsAsync(withdrawal);

            //// Assert

            await Assert.ThrowsAsync <InsufficientBalanceException>(withdrawalTask);

            walletRepositoryMock.Verify(walletRepository => walletRepository.GetLastWalletEntryAsync(), Times.Once);
            walletRepositoryMock.VerifyNoOtherCalls();
        }
        public void BackupWalletData_BasicUsuage()
        {
            WalletEngine engine = new WalletEngine();


            for (int i = 0; i < 5; i++)
            {
                WalletEntry entry = new WalletEntry
                {
                    Name          = "Test " + i.ToString(),
                    DateCreated   = System.DateTime.Now.ToShortDateString(),
                    Description   = "Description " + i.ToString(),
                    PrivateKey    = "98347659827395274g96b762987346hf87234569827365982347g6f892hf6fh987hf28375" + i,
                    PublicAddress = "9208346hg2384h75298hgnf2y3" + i.ToString(),
                    Type          = "BTC"
                };

                engine.AddWalletDataEntry(entry);
            }

            engine.BackupWalletData("c:\\temp\\");
        }
Exemple #23
0
        public async Task GetBalanceAsync_ExistingLastTransaction_ReturnsExpectedBalance(decimal lastTransactionBalanceBefore, decimal lastTransactionAmount, decimal expectedBalanceAmont)
        {
            //// Arrange

            // Setup Mocks

            WalletEntry lastTransaction = new WalletEntry {
                Amount = lastTransactionAmount, BalanceBefore = lastTransactionBalanceBefore
            };

            Mock <IWalletRepository> walletRepositoryMock = new Mock <IWalletRepository>();

            walletRepositoryMock
            .Setup(walletRepository => walletRepository.GetLastWalletEntryAsync())
            .Returns(Task.FromResult(lastTransaction));

            IWalletRepository walletRepository = walletRepositoryMock.Object;

            // Initialize SUT

            IWalletService walletService = new WalletService(walletRepository);

            // Set Expectations

            Balance expectedBalance = new Balance {
                Amount = expectedBalanceAmont
            };

            //// Act

            Balance actualBalance = await walletService.GetBalanceAsync();

            //// Assert

            actualBalance.ShouldCompare(expectedBalance);

            walletRepositoryMock.Verify(walletRepository => walletRepository.GetLastWalletEntryAsync(), Times.Once);
            walletRepositoryMock.VerifyNoOtherCalls();
        }
        public async Task InsertWalletAsync_DuplicateId_ThrowsArgumentException()
        {
            //// Arrange

            // Setup In-Memory Database at desired state

            DbContextOptions <WalletContext> dbContextOptions = new DbContextOptionsBuilder <WalletContext>()
                                                                .UseInMemoryDatabase(databaseName: "InsertWalletAsync_DuplicateId_ThrowsArgumentException")
                                                                .Options;

            WalletEntry originalWalletEntry =
                new WalletEntry {
                Id = "IAmDuplicate", EventTime = DateTime.UtcNow, Amount = 10, BalanceBefore = 0
            };

            using (WalletContext context = new WalletContext(dbContextOptions))
            {
                await context.AddAsync(originalWalletEntry);

                context.SaveChanges();
            }

            // Initialize Entry

            WalletEntry duplicateEntry = new WalletEntry {
                Id = "IAmDuplicate", EventTime = DateTime.UtcNow, Amount = 10, BalanceBefore = 0
            };

            //// Act / Assert

            using (WalletContext context = new WalletContext(dbContextOptions))
            {
                IWalletRepository walletRepository = new WalletRepository(context);
                await Assert.ThrowsAsync <ArgumentException>(() =>
                                                             walletRepository.InsertWalletEntryAsync(duplicateEntry)
                                                             );
            }
        }
        public async Task <IActionResult> Entry(WalletEntry form)
        {
            int userId = int.Parse(User.FindFirstValue(ClaimTypes.NameIdentifier));

            try
            {
                await _entryService.AddEntry(form.Entry, form.Date, userId);
            }
            catch (InvalidEntryException)
            {
                ModelState.AddModelError("Entry", _localizer["ProvideKeywordAndAmount"]);
                return(View("Index", form));
            }
            catch (InvalidEntryAmountException)
            {
                ModelState.AddModelError("Entry", _localizer["ProvideValidAmount"]);
                return(View("Index", form));
            }

            return(View("Index", new WalletEntry {
                PreviousEntrySaved = true
            }));
        }
        private static List <WalletEntry> GetWalletEntries(string APIKey)
        {
            List <WalletCurrency>     currenciesValue = GetWallet(APIKey);
            List <WalletCurrencyInfo> currencies      = GetCurrencyInfo();

            var wallet = new List <WalletEntry>();

            foreach (WalletCurrencyInfo currency in currencies)
            {
                WalletEntry entry = new WalletEntry();
                entry.ID          = currency.ID;
                entry.Name        = currency.Name;
                entry.Description = currency.Description;
                entry.Icon        = currency.Icon;
                entry.Order       = currency.Order;
                if (currenciesValue.Any(v => v.ID == currency.ID))
                {
                    entry.Value = currenciesValue.Single(v => v.ID == currency.ID).Value;
                }
                wallet.Add(entry);
            }
            return(wallet);
        }
Exemple #27
0
        public async Task <Balance> DepositFundsAsync(Deposit deposit)
        {
            decimal entryAmount = deposit.Amount;

            Balance currentBalance = await GetBalanceAsync();

            decimal currentBalanceAmount = currentBalance.Amount;

            WalletEntry depositEntry = new WalletEntry()
            {
                Amount        = entryAmount,
                BalanceBefore = currentBalanceAmount,
                EventTime     = DateTimeOffset.UtcNow
            };

            await _walletRepository.InsertWalletEntryAsync(depositEntry);

            Balance newBalance = new Balance
            {
                Amount = currentBalanceAmount + entryAmount
            };

            return(newBalance);
        }
Exemple #28
0
 public Task InsertWalletEntryAsync(WalletEntry walletEntry)
 {
     _walletContext.Transactions.Add(walletEntry);
     _walletContext.SaveChanges();
     return(Task.CompletedTask);
 }
Exemple #29
0
 public WalletEntry Import(string wif)
 {
     if (wif == null)
         throw new ArgumentNullException();
     byte[] data = Base58.Decode(wif);
     if (data.Length != 38 || data[0] != 0x80 || data[33] != 0x01)
         throw new FormatException();
     byte[] checksum = data.Sha256(0, data.Length - 4).Sha256();
     if (!data.Skip(data.Length - 4).SequenceEqual(checksum.Take(4)))
         throw new FormatException();
     byte[] privateKey = new byte[32];
     Buffer.BlockCopy(data, 1, privateKey, 0, privateKey.Length);
     byte[] redeemScript = ScriptBuilder.CreateRedeemScript(1, Secp256r1Curve.G * privateKey);
     WalletEntry entry = new WalletEntry(redeemScript, privateKey);
     SaveEntry(entry);
     Array.Clear(privateKey, 0, privateKey.Length);
     Array.Clear(data, 0, data.Length);
     return entry;
 }
Exemple #30
0
 private void SaveEntry(WalletEntry entry)
 {
     byte[] decryptedPrivateKey = new byte[entry.PrivateKeys.Length * 96];
     for (int i = 0; i < entry.PrivateKeys.Length; i++)
     {
         Buffer.BlockCopy(entry.PublicKeys[i], 0, decryptedPrivateKey, i * 96, 64);
         using (entry.Decrypt(i))
         {
             Buffer.BlockCopy(entry.PrivateKeys[i], 0, decryptedPrivateKey, i * 96 + 64, 32);
         }
     }
     ProtectedMemory.Unprotect(masterKey, MemoryProtectionScope.SameProcess);
     byte[] encryptedPrivateKey;
     using (AesManaged aes = new AesManaged())
     {
         aes.Padding = PaddingMode.None;
         using (ICryptoTransform encryptor = aes.CreateEncryptor(masterKey, iv))
         {
             encryptedPrivateKey = encryptor.TransformFinalBlock(decryptedPrivateKey, 0, decryptedPrivateKey.Length);
         }
     }
     ProtectedMemory.Protect(masterKey, MemoryProtectionScope.SameProcess);
     Array.Clear(decryptedPrivateKey, 0, decryptedPrivateKey.Length);
     SaveEncryptedEntry(entry.ScriptHash, entry.RedeemScript, encryptedPrivateKey);
 }
Exemple #31
0
        private void SaveButton_Click(object sender, EventArgs e)
        {
            Log.Debug("test");
            Log.Error("error");

            // Verify Data
            bool verifyFaild = false;

            if (string.IsNullOrEmpty(EntryTypeComboBox.Text))
            {
                EntryTypeComboBox.Focus();
                verifyFaild = true;
            }
            if (string.IsNullOrEmpty(EntryNameTextBox.Text))
            {
                EntryNameTextBox.Focus();
                verifyFaild = true;
            }
            if (string.IsNullOrEmpty(EntryPublicAddressTextBox.Text))
            {
                EntryPublicAddressTextBox.Focus();
                verifyFaild = true;
            }
            if (string.IsNullOrEmpty(EntryPrivateKeyTextBox.Text))
            {
                EntryPrivateKeyTextBox.Focus();
                verifyFaild = true;
            }
            if (verifyFaild)
            {
                MessageBox.Show(this, "You must enter coin details");
                return;
            }



            try
            {
                //Wallet Data Populate
                WalletEntry entry = new WalletEntry
                {
                    Name          = this.EntryNameTextBox.Text,
                    Description   = EntryDescriptionTextBox.Text,
                    PublicAddress = EntryPublicAddressTextBox.Text,
                    PrivateKey    = EntryPrivateKeyTextBox.Text,
                    Type          = EntryTypeComboBox.Text,
                    DateCreated   = DateTime.Now.ToShortDateString()
                };

                // Add the new entry to the datafile
                CoreContext.WalletEngine.AddWalletDataEntry(entry);
            }
            catch (Exception exception)
            {
                MessageBox.Show("Error Saving Data - " + exception.Message);
                return;
            }



            DialogResult = DialogResult.OK;


            Close();
        }
Exemple #32
0
 public void AddWalletDataEntry(WalletEntry entry)
 {
     WalletData.Entries.Add(entry);
     UpdateWalletData(WalletData);
 }