Skip to content

Commit

Permalink
Released v3.77.14 with web3.0 blockchain ciphered communication.
Browse files Browse the repository at this point in the history
  • Loading branch information
FromHDDtoSSD committed Jul 17, 2024
1 parent 13ee091 commit 4733ad1
Show file tree
Hide file tree
Showing 25 changed files with 286 additions and 194 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.76.14
VERSION = 3.77.14

INCLUDEPATH += src src/json src/qt
QT += core gui network
Expand Down
6 changes: 3 additions & 3 deletions src/alert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,11 +223,11 @@ bool CAlert::ProcessAlert()
const CAlert &alert = (*mi).second;
if (Cancels(alert)) {
printf("cancelling alert %d\n", alert.nID);
CClientUIInterface::uiInterface.NotifyAlertChanged((*mi).first, CT_DELETED);
CClientUIInterface::get().NotifyAlertChanged((*mi).first, CT_DELETED);
CAlert::mapAlerts.erase(mi++);
} else if (! alert.IsInEffect()) {
printf("expiring alert %d\n", alert.nID);
CClientUIInterface::uiInterface.NotifyAlertChanged((*mi).first, CT_DELETED);
CClientUIInterface::get().NotifyAlertChanged((*mi).first, CT_DELETED);
CAlert::mapAlerts.erase(mi++);
} else {
mi++;
Expand All @@ -248,7 +248,7 @@ bool CAlert::ProcessAlert()

// Notify UI if it applies to me
if(AppliesToMe()) {
CClientUIInterface::uiInterface.NotifyAlertChanged(GetHash(), CT_NEW);
CClientUIInterface::get().NotifyAlertChanged(GetHash(), CT_NEW);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/block/block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,7 @@ bool CBlock::AddToBlockIndex(unsigned int nFile, unsigned int nBlockPos)

static int8_t counter = 0;
if( (++counter & 0x0F) == 0 || !block_notify::IsInitialBlockDownload()) // repaint every 16 blocks if not in initial block download
CClientUIInterface::uiInterface.NotifyBlocksChanged();
CClientUIInterface::get().NotifyBlocksChanged();

return true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/block/block_check.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ void block_check::manage::InvalidChainFound(CBlockIndex *pindexNew)
if (pindexNew->get_nChainTrust() > block_info::nBestInvalidTrust) {
block_info::nBestInvalidTrust = pindexNew->get_nChainTrust();
CTxDB().WriteBestInvalidTrust(CBigNum(block_info::nBestInvalidTrust));
CClientUIInterface::uiInterface.NotifyBlocksChanged();
CClientUIInterface::get().NotifyBlocksChanged();
}

uint256 nBestInvalidBlockTrust = pindexNew->get_nChainTrust() - pindexNew->get_pprev()->get_nChainTrust();
Expand Down
4 changes: 2 additions & 2 deletions src/boot/shutdown.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class boot : private no_instance
strMiscWarning = strMessage;
logging::LogPrintf("*** %s\n", strMessage);
#ifdef QT_GUI
CClientUIInterface::uiInterface.ThreadSafeMessageBox(
CClientUIInterface::get().ThreadSafeMessageBox(
userMessage.empty() ? _("Error: A fatal internal error occured, see debug.log for details") : userMessage,
"", CClientUIInterface::MSG_ERROR);
#endif
Expand All @@ -31,7 +31,7 @@ class boot : private no_instance
static void StartShutdown() {
#ifdef QT_GUI
// ensure we leave the Qt main loop for a clean GUI exit (Shutdown() is called in bitcoin.cpp afterwards)
CClientUIInterface::uiInterface.QueueShutdown();
CClientUIInterface::get().QueueShutdown();
#else
// Without UI, Shutdown() can simply be started in a new thread
if(! bitthread::NewThread(Shutdown, nullptr))
Expand Down
2 changes: 1 addition & 1 deletion src/file_operate/file_open.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class file_open : private no_instance
std::string strMessage = _("Warning: Disk space is low!");
excep::set_strMiscWarning( strMessage );
logging::LogPrintf("*** %s\n", strMessage.c_str());
CClientUIInterface::uiInterface.ThreadSafeMessageBox(strMessage, strCoinName, CClientUIInterface::OK | CClientUIInterface::ICON_EXCLAMATION | CClientUIInterface::MODAL);
CClientUIInterface::get().ThreadSafeMessageBox(strMessage, strCoinName, CClientUIInterface::OK | CClientUIInterface::ICON_EXCLAMATION | CClientUIInterface::MODAL);
boot::StartShutdown();
return false;
}
Expand Down
43 changes: 22 additions & 21 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
# include <signal.h>
#endif

CClientUIInterface CClientUIInterface::uiInterface;
std::string entry::strWalletFileName;
std::string entry::strWalletqFileName;
CWallet *entry::pwalletMain = nullptr;
Expand Down Expand Up @@ -232,8 +231,10 @@ void entry::noui_connect()
//
// Connect bitcoind signal handlers
//
CClientUIInterface::uiInterface.ThreadSafeMessageBox.connect(CClientUIInterface::noui_ThreadSafeMessageBox);
CClientUIInterface::uiInterface.ThreadSafeAskFee.connect(CClientUIInterface::noui_ThreadSafeAskFee);
CClientUIInterface::get().ThreadSafeMessageBox.connect(CClientUIInterface::noui_ThreadSafeMessageBox);
CClientUIInterface::get().ThreadSafeAskFee.connect(CClientUIInterface::noui_ThreadSafeAskFee);
CClientUIInterface::get().ThreadSafeMessageOk(CClientUIInterface::noui_ThreadSafeMessageOk);
CClientUIInterface::get().ThreadSafeMessageAsk(CClientUIInterface::noui_ThreadSafeMessageAsk);
}

int main(int argc, char *argv[])
Expand Down Expand Up @@ -275,13 +276,13 @@ int main(int argc, char *argv[])

bool entry::InitError(const std::string &str)
{
CClientUIInterface::uiInterface.ThreadSafeMessageBox(str, _(strCoinName), CClientUIInterface::OK | CClientUIInterface::MODAL);
CClientUIInterface::get().ThreadSafeMessageBox(str, _(strCoinName), CClientUIInterface::OK | CClientUIInterface::MODAL);
return false;
}

bool entry::InitWarning(const std::string &str)
{
CClientUIInterface::uiInterface.ThreadSafeMessageBox(str, _(strCoinName), CClientUIInterface::OK | CClientUIInterface::ICON_EXCLAMATION | CClientUIInterface::MODAL);
CClientUIInterface::get().ThreadSafeMessageBox(str, _(strCoinName), CClientUIInterface::OK | CClientUIInterface::ICON_EXCLAMATION | CClientUIInterface::MODAL);
return true;
}

Expand Down Expand Up @@ -815,7 +816,7 @@ bool entry::AppInit2(bool restart/*=false*/)
#endif

#ifndef USE_LEVELDB
//CClientUIInterface::uiInterface.InitMessage(_("[Blockchain] migrate from LevelDB to SQLite, Blockchain database ..."));
//CClientUIInterface::get().InitMessage(_("[Blockchain] migrate from LevelDB to SQLite, Blockchain database ..."));
//leveldb_to_sqlite_blockchain();
leveldb_oldblockchain_remove_once();
#else
Expand Down Expand Up @@ -981,7 +982,7 @@ bool entry::AppInit2(bool restart/*=false*/)
// ********************************************************* Step 5: verify database integrity
I_DEBUG_CS("Step 5: verify database integrity (CDBEnv and CLevelDBEnv)")

CClientUIInterface::uiInterface.InitMessage(_("Verifying database integrity..."));
CClientUIInterface::get().InitMessage(_("Verifying database integrity..."));
#ifdef USE_BERKELEYDB
const fs::path bdbwallet_path = iofs::GetDataDir() / strWalletFileName.c_str();
#endif
Expand Down Expand Up @@ -1014,7 +1015,7 @@ bool entry::AppInit2(bool restart/*=false*/)
const fs::path leveldb_path = iofs::GetDataDir() / CLevelDBEnv::getname_mainchain();
if(fsbridge::dir_exists(leveldb_path)) { // Blockchain
LOCK(CLevelDBEnv::cs_leveldb);
CClientUIInterface::uiInterface.InitMessage(_("[Blockchain] Data migrate from LevelDB to SQLite."));
CClientUIInterface::get().InitMessage(_("[Blockchain] Data migrate from LevelDB to SQLite."));
if(! CSqliteDB(CSqliteDBEnv::getname_mainchain(), "r+").PortToSqlite(std::move(CLevelDB(CLevelDBEnv::getname_mainchain(), "r").GetIteCursor()), CSqliteDB::MIGRATE_BLOCKCHAIN)) {
CSqliteDBEnv::get_instance().CloseDb(CSqliteDBEnv::getname_mainchain());
const fs::path blksql_path = iofs::GetDataDir() / CSqliteDBEnv::getname_mainchain();
Expand All @@ -1031,7 +1032,7 @@ bool entry::AppInit2(bool restart/*=false*/)
// port from CDB to CSqliteDB
if(fsbridge::file_exists(bdbwallet_path)) { // wallet
LOCK(CDBEnv::cs_db);
CClientUIInterface::uiInterface.InitMessage(_("[Wallet] Data migrate from BerkeleyDB to SQLite ..."));
CClientUIInterface::get().InitMessage(_("[Wallet] Data migrate from BerkeleyDB to SQLite ..."));
if(! CSqliteDB(CSqliteDBEnv::getname_wallet(), "r+").PortToSqlite(std::move(CDB(strWalletFileName.c_str(), "r").GetIteCursor()), CSqliteDB::MIGRATE_WALLET)) {
CSqliteDBEnv::get_instance().CloseDb(CSqliteDBEnv::getname_wallet());
const fs::path sqlwallet_path = iofs::GetDataDir() / CSqliteDBEnv::getname_wallet();
Expand Down Expand Up @@ -1059,7 +1060,7 @@ bool entry::AppInit2(bool restart/*=false*/)
" Original wallet.dat saved as wallet.{timestamp}.bak in %s; if"
" your balance or transactions are incorrect you should"
" restore from a backup."), strDataDir.c_str());
CClientUIInterface::uiInterface.ThreadSafeMessageBox(msg, _(strCoinName), CClientUIInterface::OK | CClientUIInterface::ICON_EXCLAMATION | CClientUIInterface::MODAL);
CClientUIInterface::get().ThreadSafeMessageBox(msg, _(strCoinName), CClientUIInterface::OK | CClientUIInterface::ICON_EXCLAMATION | CClientUIInterface::MODAL);
} else if (r == CDBEnv::RECOVER_FAIL) {
return InitError(_("wallet.dat corrupt, salvage failed"));
} else if (r == CDBEnv::VERIFY_OK) {
Expand Down Expand Up @@ -1264,7 +1265,7 @@ bool entry::AppInit2(bool restart/*=false*/)
while (! fLoaded)
{
std::string strLoadError;
CClientUIInterface::uiInterface.InitMessage(_("Loading block index..."));
CClientUIInterface::get().InitMessage(_("Loading block index..."));

nStart = util::GetTimeMillis();
do
Expand Down Expand Up @@ -1332,18 +1333,18 @@ bool entry::AppInit2(bool restart/*=false*/)
I_DEBUG_CS("Step 8: load wallet")

if (map_arg::GetBoolArg("-zapwallettxes", false)) {
CClientUIInterface::uiInterface.InitMessage(_("Zapping all transactions from wallet..."));
CClientUIInterface::get().InitMessage(_("Zapping all transactions from wallet..."));

CWallet walletMain(strWalletFileName, std::string("unused"), CSqliteDBEnv::getname_wallet());
DBErrors nZapWalletRet = walletMain.ZapWalletTx();
if (nZapWalletRet != DB_LOAD_OK) {
CClientUIInterface::uiInterface.InitMessage(_("Error loading wallet.dat: Wallet corrupted"));
CClientUIInterface::get().InitMessage(_("Error loading wallet.dat: Wallet corrupted"));
return false;
}
entry::pwalletMain = nullptr;
}

CClientUIInterface::uiInterface.InitMessage(_("Loading wallet..."));
CClientUIInterface::get().InitMessage(_("Loading wallet..."));
logging::LogPrintf("Loading wallet...\n");
nStart = util::GetTimeMillis();

Expand All @@ -1362,7 +1363,7 @@ bool entry::AppInit2(bool restart/*=false*/)
strErrors << _("Error loading wallet.dat: Wallet corrupted") << "\n";
} else if (nLoadWalletRet == DB_NONCRITICAL_ERROR) {
std::string msg(_("Warning: error reading wallet.dat! All keys read correctly, but transaction data or address book entries might be missing or incorrect."));
CClientUIInterface::uiInterface.ThreadSafeMessageBox(msg, _(strCoinName), CClientUIInterface::OK | CClientUIInterface::ICON_EXCLAMATION | CClientUIInterface::MODAL);
CClientUIInterface::get().ThreadSafeMessageBox(msg, _(strCoinName), CClientUIInterface::OK | CClientUIInterface::ICON_EXCLAMATION | CClientUIInterface::MODAL);
} else if (nLoadWalletRet == DB_TOO_NEW) {
strErrors << _("Error loading wallet.dat: Wallet requires newer version of coin") << "\n";
} else if (nLoadWalletRet == DB_NEED_REWRITE) {
Expand Down Expand Up @@ -1431,7 +1432,7 @@ bool entry::AppInit2(bool restart/*=false*/)
}
}
if (block_info::pindexBest != pindexRescan && block_info::pindexBest && pindexRescan && block_info::pindexBest->get_nHeight() > pindexRescan->get_nHeight()) {
CClientUIInterface::uiInterface.InitMessage(_("Rescanning..."));
CClientUIInterface::get().InitMessage(_("Rescanning..."));
logging::LogPrintf("Rescanning last %i blocks (from block %i)...\n", block_info::pindexBest->get_nHeight() - pindexRescan->get_nHeight(), pindexRescan->get_nHeight());
nStart = util::GetTimeMillis();
entry::pwalletMain->ScanForWalletTransactions(pindexRescan, true);
Expand All @@ -1441,7 +1442,7 @@ bool entry::AppInit2(bool restart/*=false*/)
#ifdef WALLET_SQL_MODE
if(entry::pwalletMain && (!map_arg::GetBoolArg("-restorehdwallet"))) {
if(hd_wallet::get().enable == false && entry::pwalletMain->GetBalance() == 0) {
CClientUIInterface::uiInterface.InitMessage(_("Creating HD Wallet..."));
CClientUIInterface::get().InitMessage(_("Creating HD Wallet..."));
try {
(void)hd_create::CreateHDWallet(true, CSeedSecret());
}
Expand All @@ -1455,7 +1456,7 @@ bool entry::AppInit2(bool restart/*=false*/)
I_DEBUG_CS("Step 9: import blocks")

if (map_arg::GetMapArgsCount("-loadblock")) {
CClientUIInterface::uiInterface.InitMessage(_("Importing blockchain data file."));
CClientUIInterface::get().InitMessage(_("Importing blockchain data file."));
for(std::string strFile: map_arg::GetMapMultiArgsString("-loadblock")) {
FILE *file = ::fopen(strFile.c_str(), "rb");
if (file)
Expand All @@ -1466,7 +1467,7 @@ bool entry::AppInit2(bool restart/*=false*/)

fs::path pathBootstrap = iofs::GetDataDir() / "bootstrap.dat";
if (fs::exists(pathBootstrap)) {
CClientUIInterface::uiInterface.InitMessage(_("Importing bootstrap blockchain data file."));
CClientUIInterface::get().InitMessage(_("Importing bootstrap blockchain data file."));
FILE *file = ::fopen(pathBootstrap.string().c_str(), "rb");
if (file) {
fs::path pathBootstrapOld = iofs::GetDataDir() / "bootstrap.dat.old";
Expand All @@ -1486,7 +1487,7 @@ bool entry::AppInit2(bool restart/*=false*/)
// ********************************************************* Step 11: load peers
I_DEBUG_CS("Step 11: load peers")

CClientUIInterface::uiInterface.InitMessage(_("Loading addresses..."));
CClientUIInterface::get().InitMessage(_("Loading addresses..."));
logging::LogPrintf("Loading addresses...\n");
nStart = util::GetTimeMillis();

Expand Down Expand Up @@ -1533,7 +1534,7 @@ bool entry::AppInit2(bool restart/*=false*/)
// ********************************************************* Step 14: finished
I_DEBUG_CS("Step 14: finished")

CClientUIInterface::uiInterface.InitMessage(_("Done loading"));
CClientUIInterface::get().InitMessage(_("Done loading"));
logging::LogPrintf("Done loading\n");

if (! strErrors.str().empty())
Expand Down
2 changes: 1 addition & 1 deletion src/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -864,7 +864,7 @@ void net_node::ThreadSocketHandler2(void *parg)
}
if(net_node::vNodes.size() != nPrevNodeCount) {
nPrevNodeCount = net_node::vNodes.size();
CClientUIInterface::uiInterface.NotifyNumConnectionsChanged(net_node::vNodes.size());
CClientUIInterface::get().NotifyNumConnectionsChanged(net_node::vNodes.size());
}

//
Expand Down
29 changes: 22 additions & 7 deletions src/noui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,37 @@
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#include "ui_interface.h"
#include "init.h"
#include <ui_interface.h>
#include <init.h>
#include <rpc/bitcoinrpc.h>

#include <string>

int CClientUIInterface::noui_ThreadSafeMessageBox(const std::string &message, const std::string &caption, int style)
{
logging::LogPrintf("%s: %s\n", caption.c_str(), message.c_str());
fprintf(stderr, "%s: %s\n", caption.c_str(), message.c_str());
return 4;
}

bool CClientUIInterface::noui_ThreadSafeAskFee(int64_t /*nFeeRequired*/, const std::string &/*strCaption*/)
bool CClientUIInterface::noui_ThreadSafeAskFee(int64_t nFeeRequired, const std::string &strCaption)
{
(void)nFeeRequired;
(void)strCaption;
return true;
}

void CClientUIInterface::noui_ThreadSafeMessageOk(const std::string &message, const std::string &caption, const std::string &detail, unsigned int style)
{
(void)message;
(void)caption;
(void)detail;
(unsigned int)style;
}

bool CClientUIInterface::noui_ThreadSafeMessageAsk(const std::string &message, const std::string &caption, const std::string &detail, unsigned int style)
{
//static_cast<int64_t>(nFeeRequired);
//static_cast<const std::string &>(strCaption);
(void)message;
(void)caption;
(void)detail;
(unsigned int)style;
return true;
}
2 changes: 1 addition & 1 deletion src/ntp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ void ntp::ThreadNtpSamples(void *parg)
std::string strMessage = _("Warning: Please check that your computer's date and time are correct! If your clock is wrong " strCoinName " will not work properly.");
excep::set_strMiscWarning(strMessage);
logging::LogPrintf("*** %s\n", strMessage.c_str());
CClientUIInterface::uiInterface.ThreadSafeMessageBox(strMessage + " ", strCoinName, CClientUIInterface::OK | CClientUIInterface::ICON_EXCLAMATION);
CClientUIInterface::get().ThreadSafeMessageBox(strMessage + " ", strCoinName, CClientUIInterface::OK | CClientUIInterface::ICON_EXCLAMATION);
}

logging::LogPrintf("nNtpOffset = %+" PRId64 " (%+" PRId64 " minutes)\n", nNtpOffset, nNtpOffset / 60);
Expand Down
45 changes: 39 additions & 6 deletions src/qt/bitcoin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,37 @@ static void ThreadSafeMessageBox(const std::string &message, const std::string &
}
}

static void ThreadSafeMessageOk(const std::string &message, const std::string &caption, const std::string &detail, unsigned int style)
{
if(guiref) {
QMetaObject::invokeMethod(guiref, "ok",
GUIUtil::blockingGUIThreadConnection(),
Q_ARG(QString, QString::fromStdString(caption)),
Q_ARG(QString, QString::fromStdString(message)),
Q_ARG(unsigned int, style),
Q_ARG(QString, QString::fromStdString(detail)));
}
}

static bool ThreadSafeMessageAsk(const std::string &message, const std::string &caption, const std::string &detail, unsigned int style)
{
if(guiref) {
bool result = false;
QMetaObject::invokeMethod(guiref, "ask",
GUIUtil::blockingGUIThreadConnection(),
Q_ARG(QString, QString::fromStdString(caption)),
Q_ARG(QString, QString::fromStdString(message)),
Q_ARG(unsigned int, style),
Q_ARG(bool*, &result),
Q_ARG(QString, QString::fromStdString(detail)));
return result;
} else {
logging::LogPrintf("%s: %s\n", caption.c_str(), message.c_str());
fprintf(stderr, "%s: %s\n", caption.c_str(), message.c_str());
return true;
}
}

static bool ThreadSafeAskFee(int64_t nFeeRequired, const std::string &strCaption)
{
(void)strCaption;
Expand Down Expand Up @@ -269,12 +300,14 @@ int main(int argc, char *argv[])
OptionsModel optionsModel;

// Subscribe to global signals from core
CClientUIInterface::uiInterface.ThreadSafeMessageBox.connect(ThreadSafeMessageBox);
CClientUIInterface::uiInterface.ThreadSafeAskFee.connect(ThreadSafeAskFee);
CClientUIInterface::uiInterface.ThreadSafeHandleURI.connect(ThreadSafeHandleURI);
CClientUIInterface::uiInterface.InitMessage.connect(InitMessage);
CClientUIInterface::uiInterface.QueueShutdown.connect(QueueShutdown);
CClientUIInterface::uiInterface.Translate.connect(Translate);
CClientUIInterface::get().ThreadSafeMessageBox.connect(ThreadSafeMessageBox);
CClientUIInterface::get().ThreadSafeMessageOk.connect(ThreadSafeMessageOk);
CClientUIInterface::get().ThreadSafeMessageAsk.connect(ThreadSafeMessageAsk);
CClientUIInterface::get().ThreadSafeAskFee.connect(ThreadSafeAskFee);
CClientUIInterface::get().ThreadSafeHandleURI.connect(ThreadSafeHandleURI);
CClientUIInterface::get().InitMessage.connect(InitMessage);
CClientUIInterface::get().QueueShutdown.connect(QueueShutdown);
CClientUIInterface::get().Translate.connect(Translate);

// Show help message immediately after parsing command-line options (for "-lang") and setting locale,
// but before showing splash screen.
Expand Down
Loading

0 comments on commit 4733ad1

Please sign in to comment.