logging and error handling
This commit is contained in:
@@ -93,21 +93,17 @@ void Chat::renderChatBox(Ui::MainWindow *ui, QListView *view, QLabel *label)
|
|||||||
DataStore::getChatDataStore()->dump(); // test to see if the chat items in datastore are correctly dumped to json
|
DataStore::getChatDataStore()->dump(); // test to see if the chat items in datastore are correctly dumped to json
|
||||||
|
|
||||||
qDebug() << __func__ << ": looking at memos...";
|
qDebug() << __func__ << ": looking at memos...";
|
||||||
for (auto &p : AddressBook::getInstance()->getAllAddressLabels())
|
for (auto &contact : AddressBook::getInstance()->getAllAddressLabels())
|
||||||
{
|
{
|
||||||
for (auto &c : DataStore::getChatDataStore()->getAllMemos())
|
for (auto &memo : DataStore::getChatDataStore()->getAllMemos()) {
|
||||||
{
|
if ( (contact.getName() == ui->contactNameMemo->text().trimmed()) &&
|
||||||
|
(contact.getPartnerAddress() == memo.second.getAddress()) &&
|
||||||
|
(memo.second.isOutgoing() == true)) {
|
||||||
|
|
||||||
if (
|
QStandardItem *Items = new QStandardItem(memo.second.toChatLine());
|
||||||
(p.getName() == ui->contactNameMemo->text().trimmed()) &&
|
|
||||||
(p.getPartnerAddress() == c.second.getAddress()) &&
|
|
||||||
(c.second.isOutgoing() == true))
|
|
||||||
{
|
|
||||||
|
|
||||||
QStandardItem *Items = new QStandardItem(c.second.toChatLine());
|
|
||||||
|
|
||||||
Items->setData(OUTGOING, Qt::UserRole + 1);
|
Items->setData(OUTGOING, Qt::UserRole + 1);
|
||||||
qDebug() << __func__ << ": appending row to OUTGOING chatitems to contact " << p.getName() << " with item " << Items;
|
qDebug() << __func__ << ": appending row to OUTGOING chatitems to contact " << contact.getName() << " with item " << Items;
|
||||||
chat->appendRow(Items);
|
chat->appendRow(Items);
|
||||||
ui->listChat->setModel(chat);
|
ui->listChat->setModel(chat);
|
||||||
|
|
||||||
@@ -115,16 +111,15 @@ void Chat::renderChatBox(Ui::MainWindow *ui, QListView *view, QLabel *label)
|
|||||||
ui->listChat->setModel(chat);
|
ui->listChat->setModel(chat);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
qDebug() << __func__ << ": memo.first=" << memo.first;
|
||||||
(p.getName() == ui->contactNameMemo->text().trimmed()) &&
|
if ( (contact.getName() == ui->contactNameMemo->text().trimmed()) &&
|
||||||
(p.getMyAddress() == c.second.getAddress()) &&
|
(contact.getMyAddress() == memo.second.getAddress()) &&
|
||||||
(c.second.isOutgoing() == false) &&
|
(memo.second.isOutgoing() == false) &&
|
||||||
(c.second.getCid() == p.getCid())
|
(memo.second.getCid() == contact.getCid())
|
||||||
)
|
) {
|
||||||
{
|
QStandardItem *Items1 = new QStandardItem(memo.second.toChatLine());
|
||||||
QStandardItem *Items1 = new QStandardItem(c.second.toChatLine());
|
|
||||||
Items1->setData(INCOMING, Qt::UserRole + 1);
|
Items1->setData(INCOMING, Qt::UserRole + 1);
|
||||||
qDebug() << __func__ << ": appending row to INCOMING chatitems to contact " << p.getName() << "with cid=" << p.getCid() << " and item " << Items1;
|
qDebug() << __func__ << ": appending row to INCOMING chatitems to contact " << contact.getName() << "with txid=" << memo.second.getTxid() << " cid=" << contact.getCid() << " item " << Items1 << " memo=" << memo.second.getMemo();
|
||||||
chat->appendRow(Items1);
|
chat->appendRow(Items1);
|
||||||
ui->listChat->setModel(chat);
|
ui->listChat->setModel(chat);
|
||||||
ui->memoTxtChat->setEnabled(true);
|
ui->memoTxtChat->setEnabled(true);
|
||||||
|
|||||||
@@ -160,14 +160,7 @@ std::map<QString, ChatItem> ChatDataStore::getAllMemos()
|
|||||||
std::map<QString, ChatItem> filteredItems;
|
std::map<QString, ChatItem> filteredItems;
|
||||||
for(auto &c: this->data)
|
for(auto &c: this->data)
|
||||||
{
|
{
|
||||||
if (
|
if ((c.second.getMemo().startsWith("{") == false) && (c.second.getMemo().isEmpty() == false) ) {
|
||||||
|
|
||||||
(c.second.getMemo().startsWith("{") == false) &&
|
|
||||||
(c.second.getMemo().isEmpty() == false)
|
|
||||||
|
|
||||||
|
|
||||||
)
|
|
||||||
{
|
|
||||||
filteredItems[c.first] = c.second;
|
filteredItems[c.first] = c.second;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -267,6 +267,7 @@ void ConnectionLoader::doRPCSetConnection(Connection* conn)
|
|||||||
try {
|
try {
|
||||||
QFile plaintextWallet(dirwalletconnection);
|
QFile plaintextWallet(dirwalletconnection);
|
||||||
main->logger->write("Path to Wallet.dat : " );
|
main->logger->write("Path to Wallet.dat : " );
|
||||||
|
qDebug() << __func__ << ": wallet path =" << plaintextWallet;
|
||||||
plaintextWallet.remove();
|
plaintextWallet.remove();
|
||||||
|
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
@@ -286,6 +287,7 @@ void ConnectionLoader::doRPCSetConnectionShield(Connection* conn)
|
|||||||
try {
|
try {
|
||||||
QFile plaintextWallet(dirwalletconnection);
|
QFile plaintextWallet(dirwalletconnection);
|
||||||
main->logger->write("Path to Wallet.dat : " );
|
main->logger->write("Path to Wallet.dat : " );
|
||||||
|
qDebug() << __func__ << ": wallet path =" << plaintextWallet;
|
||||||
plaintextWallet.remove();
|
plaintextWallet.remove();
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
main->logger->write("no Plaintext wallet.dat");
|
main->logger->write("no Plaintext wallet.dat");
|
||||||
|
|||||||
@@ -1236,13 +1236,13 @@ void Controller::refreshTransactions() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int position = it["position"].get<json::number_integer_t>();
|
int position = it["position"].get<json::number_integer_t>();
|
||||||
|
|
||||||
int ciphercheck = memo.length() - crypto_secretstream_xchacha20poly1305_ABYTES;
|
int ciphercheck = memo.length() - crypto_secretstream_xchacha20poly1305_ABYTES;
|
||||||
|
qDebug() << __func__ << ": position=" << position << " headerbytes=" << headerbytes
|
||||||
|
<< " ciphercheck=" << ciphercheck << " for memo=" << memo;
|
||||||
|
|
||||||
if ((memo.startsWith("{") == false) && (headerbytes > 0) && (ciphercheck > 0))
|
if ((memo.startsWith("{") == false) && (headerbytes > 0) && (ciphercheck > 0))
|
||||||
{
|
{
|
||||||
if (chatModel->getMemoByTx(txid) == QString("0xdeadbeef"))
|
if (chatModel->getMemoByTx(txid) == QString("0xdeadbeef")) {
|
||||||
{
|
|
||||||
if (position == 1)
|
if (position == 1)
|
||||||
{
|
{
|
||||||
chatModel->addMemo(txid, headerbytes);
|
chatModel->addMemo(txid, headerbytes);
|
||||||
@@ -1352,10 +1352,13 @@ void Controller::refreshTransactions() {
|
|||||||
DataStore::getChatDataStore()->setData(ChatIDGenerator::getInstance()->generateID(item), item);
|
DataStore::getChatDataStore()->setData(ChatIDGenerator::getInstance()->generateID(item), item);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
//
|
qDebug() << __func__ << ": ignoring txid="<< txid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//} else if (memo.startsWith("{")) {
|
||||||
|
//qDebug() << __func__ << ": ignoring a header memo";
|
||||||
} else {
|
} else {
|
||||||
|
// Add a chatitem for the initial CR
|
||||||
ChatItem item = ChatItem(
|
ChatItem item = ChatItem(
|
||||||
datetime,
|
datetime,
|
||||||
address,
|
address,
|
||||||
@@ -1371,7 +1374,7 @@ void Controller::refreshTransactions() {
|
|||||||
isContact
|
isContact
|
||||||
);
|
);
|
||||||
|
|
||||||
qDebug() << "refreshTransactions: adding chatItem with memo=" << memo;
|
qDebug() << "refreshTransactions: adding chatItem for initial CR with memo=" << memo;
|
||||||
DataStore::getChatDataStore()->setData(ChatIDGenerator::getInstance()->generateID(item), item);
|
DataStore::getChatDataStore()->setData(ChatIDGenerator::getInstance()->generateID(item), item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -86,15 +86,17 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
}else{}
|
}else{}
|
||||||
|
|
||||||
logger = new Logger(this, QDir(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation)).filePath("silentdragonlite-wallet.log"));
|
logger = new Logger(this, QDir(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation)).filePath("silentdragonlite-wallet.log"));
|
||||||
// Check for encryption
|
|
||||||
|
|
||||||
|
// Check for encryption
|
||||||
if(fileExists(dirwalletenc))
|
if(fileExists(dirwalletenc))
|
||||||
{
|
{
|
||||||
|
qDebug() << __func__ << ": decrypting wallet=" << dirwalletenc;
|
||||||
this->removeWalletEncryptionStartUp();
|
this->removeWalletEncryptionStartUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
ui->memoTxtChat->setAutoFillBackground(false);
|
ui->memoTxtChat->setAutoFillBackground(false);
|
||||||
ui->memoTxtChat->setPlaceholderText("Send Message (you can only write messages after the initial message from your contact)");
|
// TODO: make this HTML with some emoji
|
||||||
|
ui->memoTxtChat->setPlaceholderText("Send Memo (you can only write memo after the initial message from your contact)");
|
||||||
ui->memoTxtChat->setTextColor(Qt::white);
|
ui->memoTxtChat->setTextColor(Qt::white);
|
||||||
|
|
||||||
// Status Bar
|
// Status Bar
|
||||||
@@ -543,10 +545,8 @@ void MainWindow::removeWalletEncryption() {
|
|||||||
QObject::connect(ed.txtConfirmPassword, &QLineEdit::textChanged, fnPasswordEdited);
|
QObject::connect(ed.txtConfirmPassword, &QLineEdit::textChanged, fnPasswordEdited);
|
||||||
QObject::connect(ed.txtPassword, &QLineEdit::textChanged, fnPasswordEdited);
|
QObject::connect(ed.txtPassword, &QLineEdit::textChanged, fnPasswordEdited);
|
||||||
|
|
||||||
if (d.exec() == QDialog::Accepted)
|
if (d.exec() == QDialog::Accepted) {
|
||||||
{
|
|
||||||
QString passphraseBlank = ed.txtPassword->text(); // data comes from user inputs
|
QString passphraseBlank = ed.txtPassword->text(); // data comes from user inputs
|
||||||
|
|
||||||
QString passphrase = QString("HUSH3") + passphraseBlank + QString("SDL");
|
QString passphrase = QString("HUSH3") + passphraseBlank + QString("SDL");
|
||||||
|
|
||||||
int length = passphrase.length();
|
int length = passphrase.length();
|
||||||
@@ -563,18 +563,17 @@ void MainWindow::removeWalletEncryption() {
|
|||||||
|
|
||||||
|
|
||||||
#define hash ((const unsigned char *) sequence1)
|
#define hash ((const unsigned char *) sequence1)
|
||||||
|
|
||||||
#define PASSWORD sequence
|
#define PASSWORD sequence
|
||||||
#define KEY_LEN crypto_box_SEEDBYTES
|
#define KEY_LEN crypto_box_SEEDBYTES
|
||||||
|
|
||||||
unsigned char key[KEY_LEN];
|
unsigned char key[KEY_LEN];
|
||||||
|
|
||||||
if (crypto_pwhash
|
if (crypto_pwhash(key, sizeof key, PASSWORD, strlen(PASSWORD), hash,
|
||||||
(key, sizeof key, PASSWORD, strlen(PASSWORD), hash,
|
crypto_pwhash_OPSLIMIT_SENSITIVE, crypto_pwhash_MEMLIMIT_SENSITIVE, crypto_pwhash_ALG_DEFAULT) != 0) {
|
||||||
crypto_pwhash_OPSLIMIT_SENSITIVE, crypto_pwhash_MEMLIMIT_SENSITIVE,
|
|
||||||
crypto_pwhash_ALG_DEFAULT) != 0) {
|
|
||||||
/* out of memory */
|
/* out of memory */
|
||||||
}
|
qDebug() << "crypto_pwhash failed!";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
auto dir = QDir(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation));
|
auto dir = QDir(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation));
|
||||||
auto dirHome = QDir(QStandardPaths::writableLocation(QStandardPaths::HomeLocation));
|
auto dirHome = QDir(QStandardPaths::writableLocation(QStandardPaths::HomeLocation));
|
||||||
@@ -587,9 +586,7 @@ void MainWindow::removeWalletEncryption() {
|
|||||||
QFile filencrypted(dirwalletenc);
|
QFile filencrypted(dirwalletenc);
|
||||||
QFile wallet(dirwallet);
|
QFile wallet(dirwallet);
|
||||||
|
|
||||||
if (wallet.size() > 0)
|
if (wallet.size() > 0) {
|
||||||
{
|
|
||||||
|
|
||||||
QMessageBox::information(this, tr("Wallet decryption Success"),
|
QMessageBox::information(this, tr("Wallet decryption Success"),
|
||||||
QString("Successfully delete the encryption"),
|
QString("Successfully delete the encryption"),
|
||||||
QMessageBox::Ok
|
QMessageBox::Ok
|
||||||
@@ -597,7 +594,7 @@ void MainWindow::removeWalletEncryption() {
|
|||||||
|
|
||||||
filencrypted.remove();
|
filencrypted.remove();
|
||||||
|
|
||||||
}else{
|
} else {
|
||||||
|
|
||||||
QMessageBox::critical(this, tr("Wallet Encryption Failed"),
|
QMessageBox::critical(this, tr("Wallet Encryption Failed"),
|
||||||
QString("False password, please try again"),
|
QString("False password, please try again"),
|
||||||
|
|||||||
Reference in New Issue
Block a user