Skip to content

Commit

Permalink
Released v3.83.14: Improved the GUI.
Browse files Browse the repository at this point in the history
  • Loading branch information
FromHDDtoSSD committed Jul 24, 2024
1 parent 5892638 commit 7e3e164
Show file tree
Hide file tree
Showing 8 changed files with 82 additions and 33 deletions.
2 changes: 1 addition & 1 deletion SorachanCoinQ-qt.pro
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
TEMPLATE = app
VERSION = 3.82.14
VERSION = 3.83.14

INCLUDEPATH += src src/json src/qt
QT += core gui network
Expand Down
24 changes: 23 additions & 1 deletion src/qt/rpcconsole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,7 @@ void RPCConsole::ciphermypubkey() {
bool mintonly;
if(!addressModel->addQai_v3(mintonly))
return;
this->raise();

std::string cipher_address;
std::string err;
Expand All @@ -403,34 +404,49 @@ void RPCConsole::ciphermypubkey() {
addressModel->addQai_v3_wallet_tolock(mintonly);
}

RPCConsole *g_console = nullptr;
extern "C" void call_raise() {
if(g_console)
g_console->raise();
}

void RPCConsole::sendciphermessage() {
g_console = this;
if(!QMB(QMB::M_QUESTION).setText(tr("Is it okay to record the ciphered message on the blockchain?").toStdString(), _("")).ask())
return;
this->raise();
QString q_recipient_pubkey = ui->cipheraddresslineEdit->text();
if(q_recipient_pubkey.size() == 0) {
QMB(QMB::M_ERROR).setText(tr("The recipient's public cipher address is empty.").toStdString(), _("")).exec();
this->raise();
return;
}
QString q_cipher = ui->sendciphermessageWidget->toPlainText();
if(q_cipher.size() == 0) {
QMB(QMB::M_ERROR).setText(tr("The encrypted message to be sent is empty.").toStdString(), _("")).exec();
this->raise();
return;
}

// manual wallet unlock
bool mintflag = walletModel->getMintflag();
AddressTableModel *addressModel = walletModel->getAddressTableModel();
bool junk;
if(!addressModel->addQai_v3(junk))
return;
this->raise();

bool stealth = ui->stealthCheckBox->isChecked();
std::string recipient_pubkey = q_recipient_pubkey.toStdString();
std::string cipher = q_cipher.toStdString();
QMB(QMB::M_INFO).setText(tr("The process of recording to the blockchain has started. "
"Please keep your wallet open and wait for a while until the process is completed. "
"SORA will notify you once the recording to the blockchain is finished.").toStdString(), _("")).exec();
if(!ai_cipher::sendciphermessage(recipient_pubkey, std::move(cipher), stealth))
this->raise();
if(!ai_cipher::sendciphermessage(recipient_pubkey, std::move(cipher), stealth, mintflag)) {
QMB(QMB::M_ERROR).setText(tr("An error occurred during the initiation of the recording process.").toStdString(), _("")).exec();
this->raise();
}
}

static void GetCipherMessages(std::string &dest, uint32_t hours) {
Expand Down Expand Up @@ -475,6 +491,7 @@ void RPCConsole::updateCipherMessage() {
bool mintonly;
if(!addressModel->addQai_v3(mintonly))
return;
this->raise();

uint32_t hours = ui->gethoursSpinBox->value();
std::string result;
Expand Down Expand Up @@ -545,12 +562,16 @@ void RPCConsole::updateSentMyMessages() {
"the Schnorr aggregated signature process will take a considerable amount of time. "
"Please wait patiently until the process is completed. "
"SORA will notify you once it is finished.").toStdString(), _("")).ask())
this->raise();
return;

this->raise();

uint32_t hours = ui->getsentmessagesSpinBox->value();
std::string recipient_address = ui->sentaddressLineEdit->text().toStdString();
if(recipient_address.size() == 0) {
QMB(QMB::M_ERROR).setText(tr("The recipient's public cipher address is empty.").toStdString(), _("")).exec();
this->raise();
return;
}

Expand All @@ -559,6 +580,7 @@ void RPCConsole::updateSentMyMessages() {
bool mintflag;
if(!addressModel->addQai_v3(mintflag))
return;
this->raise();

std::string result;
GetSentMessages(result, recipient_address, hours);
Expand Down
4 changes: 4 additions & 0 deletions src/qt/walletmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,10 @@ WalletModel::SendCoinsReturn WalletModel::sendCoins(const QList<SendCoinsRecipie
return SendCoinsReturn(OK, 0, hex);
}

bool WalletModel::getMintflag() const {
return CWallet::fWalletUnlockMintOnly;
}

OptionsModel *WalletModel::getOptionsModel()
{
return optionsModel;
Expand Down
2 changes: 2 additions & 0 deletions src/qt/walletmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ class WalletModel : public QObject
MintingTableModel *getMintingTableModel();
TransactionTableModel *getTransactionTableModel();

bool getMintflag() const;

bool haveWatchOnly() const;
qint64 getBalance() const;
qint64 getBalanceWatchOnly() const;
Expand Down
4 changes: 2 additions & 2 deletions src/rpc/rpcwallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ json_spirit::Value CRPCTable::getciphermessages(const json_spirit::Array &params
{
if (fHelp || params.size() > 1) {
throw std::runtime_error(
"getciphermessages [time(hours)] "
"getciphermessages [time(hours)]\n"
"Specify the time you want to retrieve retrospectively in hours. "
"If omitted, it defaults to 168 hours (7 days).");
}
Expand Down Expand Up @@ -613,7 +613,7 @@ json_spirit::Value CRPCTable::getnewcipheraddress(const json_spirit::Array &para
if (fHelp || params.size() > 5) {
throw std::runtime_error(
"getnewcipheraddress or "
"getnewcipheraddress [recipient address] [cipher message] (Stealth) "
"getnewcipheraddress [recipient address] [cipher message] (Stealth)\n"
"If no arguments are provided, it can obtain a dedicated address for receiving encrypted messages. "
"This is a special address that starts with cipher1. "
"If arguments are provided, please pass the address of the recipient "
Expand Down
75 changes: 48 additions & 27 deletions src/sorara/aitx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,24 @@ int64_t CAITransaction03::GetTime() const {
return aitx.GetTime();
}

#ifdef QT_GUI
extern "C" void call_raise(); // rpcconsole.cpp
#else
static void call_raise() {}
#endif

namespace aitx_thread {

static void walletLock(int32_t fMintonly) {
if(entry::pwalletMain->IsCrypted() && (!entry::pwalletMain->IsLocked())) {
if(fMintonly) {
CWallet::fWalletUnlockMintOnly = true;
} else {
entry::pwalletMain->Lock();
}
}
}

void wait_for_confirm_transaction(std::shared_ptr<CDataStream> stream) {
//!
//! get the SORA-QAI cipher address qai_address
Expand All @@ -224,20 +240,12 @@ void wait_for_confirm_transaction(std::shared_ptr<CDataStream> stream) {
int32_t fMessage;
int32_t fWalletlock;
int32_t fMintonly;
auto walletLock = [fMintonly]() {
if(entry::pwalletMain->IsCrypted() && (!entry::pwalletMain->IsLocked())) {
if(fMintonly) {
CWallet::fWalletUnlockMintOnly = true;
} else {
entry::pwalletMain->Lock();
}
}
};
try {
(*stream) >> qai_address >> nAmount >> fMessage >> fWalletlock >> fMintonly;
} catch (const std::exception &) {
fMessage ? QMB(QMB::M_ERROR).setText(_("Failed to read from CDataStream.")).exec(): 0;
if(fWalletlock) walletLock();
call_raise();
if(fWalletlock) walletLock(fMintonly);
return;
}

Expand All @@ -246,12 +254,14 @@ void wait_for_confirm_transaction(std::shared_ptr<CDataStream> stream) {

if(!hd_wallet::get().enable) {
fMessage ? QMB(QMB::M_ERROR).setText(_("The HD Wallet disable.")).exec(): 0;
if(fWalletlock) walletLock();
call_raise();
if(fWalletlock) walletLock(fMintonly);
return;
}
if(entry::pwalletMain->IsLocked()) {
fMessage ? QMB(QMB::M_ERROR).setText(_("The Wallet is locked.")).exec(): 0;
if(fWalletlock) walletLock();
call_raise();
if(fWalletlock) walletLock(fMintonly);
return;
}

Expand Down Expand Up @@ -282,7 +292,8 @@ void wait_for_confirm_transaction(std::shared_ptr<CDataStream> stream) {
//print_num("nValue", nValue);
if(nValue < nAmount * 2) {
fMessage ? QMB(QMB::M_ERROR).setText("SORA L1 network fee is insufficient. Please charge the fee to the ECDSA total side.").exec(): 0;
if(fWalletlock) walletLock();
call_raise();
if(fWalletlock) walletLock(fMintonly);
return;
}

Expand All @@ -291,12 +302,14 @@ void wait_for_confirm_transaction(std::shared_ptr<CDataStream> stream) {
int64_t nFeeRequired = 0;
if(!entry::pwalletMain->CreateTransaction(scriptPubKey, nAmount, wtx, reservekey, nFeeRequired, &coinControl)) {
fMessage ? QMB(QMB::M_ERROR).setText("Failed to create transaction.").exec(): 0;
if(fWalletlock) walletLock();
call_raise();
if(fWalletlock) walletLock(fMintonly);
return;
}
if(!entry::pwalletMain->CommitTransaction(wtx, reservekey)) {
fMessage ? QMB(QMB::M_ERROR).setText("Failed to commit transaction.").exec(): 0;
if(fWalletlock) walletLock();
call_raise();
if(fWalletlock) walletLock(fMintonly);
return;
}

Expand All @@ -309,12 +322,13 @@ void wait_for_confirm_transaction(std::shared_ptr<CDataStream> stream) {
break;
} else {
fMessage ? QMB(QMB::M_ERROR).setText("Failed to wait for transaction.").exec(): 0;
if(fWalletlock) walletLock();
call_raise();
if(fWalletlock) walletLock(fMintonly);
return;
}
util::Sleep(300);
if(args_bool::fShutdown) {
if(fWalletlock) walletLock();
if(fWalletlock) walletLock(fMintonly);
return;
}
} while(true);
Expand All @@ -332,7 +346,8 @@ void wait_for_confirm_transaction(std::shared_ptr<CDataStream> stream) {
}
if(vout_index == -1) {
fMessage ? QMB(QMB::M_ERROR).setText("Failed to get the transaction.").exec(): 0;
if(fWalletlock) walletLock();
call_raise();
if(fWalletlock) walletLock(fMintonly);
return;
}
}
Expand All @@ -342,7 +357,8 @@ void wait_for_confirm_transaction(std::shared_ptr<CDataStream> stream) {
CPubKey reserved_pubkey = hd_wallet::get().reserved_pubkey[0];
if(!reserved_pubkey.IsFullyValid_BIP66()) {
fMessage ? QMB(QMB::M_ERROR).setText(_("Detected an anomaly in the public key.")).exec(): 0;
if(fWalletlock) walletLock();
call_raise();
if(fWalletlock) walletLock(fMintonly);
return;
}

Expand All @@ -362,21 +378,24 @@ void wait_for_confirm_transaction(std::shared_ptr<CDataStream> stream) {
int64_t nFeeRequired = 0;
if(!entry::pwalletMain->CreateTransaction(scriptPubKey, nAmountQai, wtx, reservekey, nFeeRequired, &coinControl)) {
fMessage ? QMB(QMB::M_ERROR).setText("Failed to create transaction.").exec(): 0;
if(fWalletlock) walletLock();
call_raise();
if(fWalletlock) walletLock(fMintonly);
return;
}

int64_t nFeeSub = nAmount - nAmountQai - nFeeRequired;
nAmountQai += nFeeSub;
if(!entry::pwalletMain->CreateTransaction(scriptPubKey, nAmountQai, wtx, reservekey, nFeeRequired, &coinControl)) {
fMessage ? QMB(QMB::M_ERROR).setText("Failed to create transaction.").exec(): 0;
if(fWalletlock) walletLock();
call_raise();
if(fWalletlock) walletLock(fMintonly);
return;
}

if(!entry::pwalletMain->CommitTransaction(wtx, reservekey)) {
fMessage ? QMB(QMB::M_ERROR).setText("Failed to commit transaction.").exec(): 0;
if(fWalletlock) walletLock();
call_raise();
if(fWalletlock) walletLock(fMintonly);
return;
}

Expand All @@ -389,19 +408,21 @@ void wait_for_confirm_transaction(std::shared_ptr<CDataStream> stream) {
break;
} else {
fMessage ? QMB(QMB::M_ERROR).setText("Failed to wait for transaction.").exec(): 0;
if(fWalletlock) walletLock();
call_raise();
if(fWalletlock) walletLock(fMintonly);
return;
}
util::Sleep(500);
if(args_bool::fShutdown) {
if(fWalletlock) walletLock();
if(fWalletlock) walletLock(fMintonly);
return;
}
} while(true);
}

fMessage ? QMB(QMB::M_INFO).setText(_("Successfully verified the encrypted message transaction.")).exec(): 0;
if(fWalletlock) walletLock();
call_raise();
if(fWalletlock) walletLock(fMintonly);
}

} // aitx_thread
Expand Down Expand Up @@ -621,7 +642,7 @@ bool getmessages(uint32_t hours, std::vector<std::tuple<time_t, std::string, Sec
return true;
}

bool sendciphermessage(const std::string &recipient_pubkey, std::string &&cipher, bool stealth) {
bool sendciphermessage(const std::string &recipient_pubkey, std::string &&cipher, bool stealth, bool mintflag) {
try {
json_spirit::Array obj;
obj.emplace_back(recipient_pubkey);
Expand All @@ -631,7 +652,7 @@ bool sendciphermessage(const std::string &recipient_pubkey, std::string &&cipher
else
obj.emplace_back((int32_t)0);
obj.emplace_back((int32_t)1);
obj.emplace_back(CWallet::fWalletUnlockMintOnly ? (int32_t)1: (int32_t)0);
obj.emplace_back(mintflag ? (int32_t)1: (int32_t)0);
CRPCTable::getnewcipheraddress(obj, false);
} catch (const json_spirit::Object &) {
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/sorara/aitx.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ constexpr size_t cipher_agg_size = XOnlyAggWalletInfo::DEF_AGG_XONLY_KEYS;

bool getmycipheraddress(std::string &cipher_address, std::string &err);
bool getmessages(uint32_t hours, std::vector<std::tuple<time_t, std::string, SecureString>> &result, std::string &err);
bool sendciphermessage(const std::string &recipient_pubkey, std::string &&cipher, bool stealth);
bool sendciphermessage(const std::string &recipient_pubkey, std::string &&cipher, bool stealth, bool mintflag);

bool getsentmymessages(uint32_t hours, const std::string &recipient_address, std::vector<std::pair<time_t, SecureString>> &result, std::string &err);

Expand Down
2 changes: 1 addition & 1 deletion src/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class format_version : private no_instance

// display version
#define DISPLAY_VERSION_MAJOR 3
#define DISPLAY_VERSION_MINOR 82
#define DISPLAY_VERSION_MINOR 83
#define DISPLAY_VERSION_REVISION 14

#endif

0 comments on commit 7e3e164

Please sign in to comment.