private void MenuItemNewReceipt_Click(object sender, RoutedEventArgs e) { try { var invoice = (vwInvoicedReceipts)dgInvoices.SelectedItem; int?addressIndex = 0; ReceiptKeyWindow newReceipt = new ReceiptKeyWindow(tcBitcoin.NewChangeKey(AccountKey.KeyName, AccountKey.HDPath, CoinChangeType.Receipt, ref addressIndex), invoice.InvoiceNumber); newReceipt.KeyNamespace = AccountKey.KeyNamespace; if (newReceipt.ShowDialog() == true) { if (tcBitcoin.AddChangeKey(AccountKey.KeyName, CoinChangeType.Receipt, newReceipt.PaymentAddress, (int)addressIndex, newReceipt.Note, newReceipt.InvoiceNumber)) { Refresh(); } } } catch (Exception err) { MessageBox.Show($"{err.Message}", $"{err.Source}.{err.TargetSite.Name}", MessageBoxButton.OK, MessageBoxImage.Error); } }