Skip to content

Commit

Permalink
Merge pull request #5425 from UdjinM6/multi_fixes
Browse files Browse the repository at this point in the history
fix: Various small fixes
  • Loading branch information
UdjinM6 authored Jun 12, 2023
2 parents a760e33 + 9e862c1 commit a99fd92
Show file tree
Hide file tree
Showing 13 changed files with 28 additions and 18 deletions.
4 changes: 2 additions & 2 deletions src/bip39.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,11 @@ bool CMnemonic::Check(SecureString mnemonic)
return fResult;
}

// passphrase must be at most 256 characters or code may crash
// passphrase must be at most 256 characters otherwise it would be truncated
void CMnemonic::ToSeed(SecureString mnemonic, SecureString passphrase, SecureVector& seedRet)
{
SecureString ssSalt = SecureString("mnemonic") + passphrase;
SecureVector vchSalt(ssSalt.begin(), ssSalt.end());
SecureVector vchSalt(ssSalt.begin(), ssSalt.begin() + strnlen(ssSalt.data(), 256));
seedRet.resize(64);
PKCS5_PBKDF2_HMAC_SHA512(mnemonic.c_str(), mnemonic.size(), vchSalt.data(), vchSalt.size(), 2048, 64, seedRet.data());
}
2 changes: 1 addition & 1 deletion src/bip39.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class CMnemonic
static SecureString Generate(int strength); // strength in bits
static SecureString FromData(const SecureVector& data, int len);
static bool Check(SecureString mnemonic);
// passphrase must be at most 256 characters or code may crash
// passphrase must be at most 256 characters otherwise it would be truncated
static void ToSeed(SecureString mnemonic, SecureString passphrase, SecureVector& seedRet);
};

Expand Down
2 changes: 1 addition & 1 deletion src/evo/specialtx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

uint256 CalcTxInputsHash(const CTransaction& tx)
{
CHashWriter hw(CLIENT_VERSION, SER_GETHASH);
CHashWriter hw(SER_GETHASH, CLIENT_VERSION);
for (const auto& in : tx.vin) {
hw << in.prevout;
}
Expand Down
4 changes: 2 additions & 2 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -737,14 +737,14 @@ void SetupServerArgs(NodeContext& node)
argsman.AddArg("-pushversion", "Protocol version to report to other nodes", ArgsManager::ALLOW_ANY, OptionsCategory::DEBUG_TEST);
argsman.AddArg("-shrinkdebugfile", "Shrink debug.log file on client startup (default: 1 when no -debug)", ArgsManager::ALLOW_ANY, OptionsCategory::DEBUG_TEST);
argsman.AddArg("-sporkaddr=<dashaddress>", "Override spork address. Only useful for regtest and devnet. Using this on mainnet or testnet will ban you.", ArgsManager::ALLOW_ANY, OptionsCategory::DEBUG_TEST);
argsman.AddArg("-sporkkey=<privatekey>", "Set the private key to be used for signing spork messages.", ArgsManager::ALLOW_ANY, OptionsCategory::DEBUG_TEST);
argsman.AddArg("-sporkkey=<privatekey>", "Set the private key to be used for signing spork messages.", ArgsManager::ALLOW_ANY | ArgsManager::SENSITIVE, OptionsCategory::DEBUG_TEST);
argsman.AddArg("-uacomment=<cmt>", "Append comment to the user agent string", ArgsManager::ALLOW_ANY, OptionsCategory::DEBUG_TEST);

SetupChainParamsBaseOptions(argsman);

argsman.AddArg("-llmq-data-recovery=<n>", strprintf("Enable automated quorum data recovery (default: %u)", llmq::DEFAULT_ENABLE_QUORUM_DATA_RECOVERY), ArgsManager::ALLOW_ANY, OptionsCategory::MASTERNODE);
argsman.AddArg("-llmq-qvvec-sync=<quorum_name>:<mode>", strprintf("Defines from which LLMQ type the masternode should sync quorum verification vectors. Can be used multiple times with different LLMQ types. <mode>: %d (sync always from all quorums of the type defined by <quorum_name>), %d (sync from all quorums of the type defined by <quorum_name> if a member of any of the quorums)", (int32_t)llmq::QvvecSyncMode::Always, (int32_t)llmq::QvvecSyncMode::OnlyIfTypeMember), ArgsManager::ALLOW_ANY, OptionsCategory::MASTERNODE);
argsman.AddArg("-masternodeblsprivkey=<hex>", "Set the masternode BLS private key and enable the client to act as a masternode", ArgsManager::ALLOW_ANY, OptionsCategory::MASTERNODE);
argsman.AddArg("-masternodeblsprivkey=<hex>", "Set the masternode BLS private key and enable the client to act as a masternode", ArgsManager::ALLOW_ANY | ArgsManager::SENSITIVE, OptionsCategory::MASTERNODE);
argsman.AddArg("-platform-user=<user>", "Set the username for the \"platform user\", a restricted user intended to be used by Dash Platform, to the specified username.", ArgsManager::ALLOW_ANY, OptionsCategory::MASTERNODE);

argsman.AddArg("-acceptnonstdtxn", strprintf("Relay and mine \"non-standard\" transactions (%sdefault: %u)", "testnet/regtest only; ", !testnetChainParams->RequireStandard()), ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::NODE_RELAY);
Expand Down
2 changes: 1 addition & 1 deletion src/llmq/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ uint256 BuildCommitmentHash(Consensus::LLMQType llmqType, const uint256& blockHa
const std::vector<bool>& validMembers, const CBLSPublicKey& pubKey,
const uint256& vvecHash)
{
CHashWriter hw(SER_NETWORK, 0);
CHashWriter hw(SER_GETHASH, 0);
hw << llmqType;
hw << blockHash;
hw << DYNBITSET(validMembers);
Expand Down
4 changes: 4 additions & 0 deletions src/pow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,10 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead

// Note: GetNextWorkRequiredBTC has it's own special difficulty rule,
// so we only apply this to post-BTC algos.
if (params.fPowNoRetargeting) {
return bnPowLimit.GetCompact();
}

if (params.fPowAllowMinDifficultyBlocks) {
// recent block is more than 2 hours old
if (pblock->GetBlockTime() > pindexLast->GetBlockTime() + 2 * 60 * 60) {
Expand Down
2 changes: 1 addition & 1 deletion src/qt/bitcoingui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ void BitcoinGUI::createActions()

// Jump directly to tabs in RPC-console
connect(openInfoAction, &QAction::triggered, this, &BitcoinGUI::showInfo);
connect(openRPCConsoleAction, &QAction::triggered, this, &BitcoinGUI::showDebugWindow);
connect(openRPCConsoleAction, &QAction::triggered, this, &BitcoinGUI::showConsole);
connect(openGraphAction, &QAction::triggered, this, &BitcoinGUI::showGraph);
connect(openPeersAction, &QAction::triggered, this, &BitcoinGUI::showPeers);
connect(openRepairAction, &QAction::triggered, this, &BitcoinGUI::showRepair);
Expand Down
13 changes: 8 additions & 5 deletions src/qt/optionsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ OptionsDialog::OptionsDialog(QWidget *parent, bool enableWallet) :
ui(new Ui::OptionsDialog),
model(nullptr),
mapper(nullptr),
pageButtons(nullptr)
pageButtons(nullptr),
m_enable_wallet(enableWallet)
{
ui->setupUi(this);

Expand Down Expand Up @@ -108,7 +109,7 @@ OptionsDialog::OptionsDialog(QWidget *parent, bool enableWallet) :
pageButtons = new QButtonGroup(this);
pageButtons->addButton(ui->btnMain, pageButtons->buttons().size());
/* Remove Wallet/CoinJoin tabs and 3rd party-URL textbox in case of -disablewallet */
if (!enableWallet) {
if (!m_enable_wallet) {
ui->stackedWidgetOptions->removeWidget(ui->pageWallet);
ui->btnWallet->hide();
ui->stackedWidgetOptions->removeWidget(ui->pageCoinJoin);
Expand Down Expand Up @@ -396,9 +397,11 @@ void OptionsDialog::on_okButton_clicked()
mapper->submit();
appearance->accept();
#ifdef ENABLE_WALLET
for (auto& wallet : model->node().walletClient().getWallets()) {
wallet->coinJoin().resetCachedBlocks();
wallet->markDirty();
if (m_enable_wallet) {
for (auto& wallet : model->node().walletClient().getWallets()) {
wallet->coinJoin().resetCachedBlocks();
wallet->markDirty();
}
}
#endif // ENABLE_WALLET
accept();
Expand Down
1 change: 1 addition & 0 deletions src/qt/optionsdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ private Q_SLOTS:
QString previousTheme;
AppearanceWidget* appearance;
bool fCoinJoinEnabledPrev{false};
bool m_enable_wallet{false};

void showEvent(QShowEvent* event) override;
};
Expand Down
1 change: 1 addition & 0 deletions src/qt/sendcoinsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ SendCoinsDialog::SendCoinsDialog(bool _fCoinJoin, QWidget* parent) :
GUIUtil::setFont({ui->labelCoinControlFeatures
}, GUIUtil::FontWeight::Bold, 16);

ui->checkBoxCoinControlChange->setEnabled(!_fCoinJoin);
GUIUtil::setupAddressWidget(ui->lineEditCoinControlChange, this);

addEntry();
Expand Down
6 changes: 3 additions & 3 deletions src/test/evo_utils_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ void Test(llmq::CQuorumManager& qman)
BOOST_CHECK_EQUAL(IsQuorumTypeEnabledInternal(consensus_params.llmqTypeDIP0024InstantSend, qman, nullptr, true, false), true);
BOOST_CHECK_EQUAL(IsQuorumTypeEnabledInternal(consensus_params.llmqTypeDIP0024InstantSend, qman, nullptr, true, true), true);
BOOST_CHECK_EQUAL(IsQuorumTypeEnabledInternal(consensus_params.llmqTypeChainLocks, qman, nullptr, false, false), true);
BOOST_CHECK_EQUAL(IsQuorumTypeEnabledInternal(consensus_params.llmqTypeChainLocks, qman, nullptr, false, false), true);
BOOST_CHECK_EQUAL(IsQuorumTypeEnabledInternal(consensus_params.llmqTypeChainLocks, qman, nullptr, true, false), true);
BOOST_CHECK_EQUAL(IsQuorumTypeEnabledInternal(consensus_params.llmqTypeChainLocks, qman, nullptr, true, true), true);
BOOST_CHECK_EQUAL(IsQuorumTypeEnabledInternal(consensus_params.llmqTypePlatform, qman, nullptr, false, false), Params().IsTestChain());
BOOST_CHECK_EQUAL(IsQuorumTypeEnabledInternal(consensus_params.llmqTypePlatform, qman, nullptr, true, false), Params().IsTestChain());
BOOST_CHECK_EQUAL(IsQuorumTypeEnabledInternal(consensus_params.llmqTypePlatform, qman, nullptr, true, true), Params().IsTestChain());
BOOST_CHECK_EQUAL(IsQuorumTypeEnabledInternal(consensus_params.llmqTypePlatform, qman, nullptr, true, true), Params().IsTestChain());
BOOST_CHECK_EQUAL(IsQuorumTypeEnabledInternal(consensus_params.llmqTypeMnhf, qman, nullptr, false, false), true);
BOOST_CHECK_EQUAL(IsQuorumTypeEnabledInternal(consensus_params.llmqTypeMnhf, qman, nullptr, true, false), true);
BOOST_CHECK_EQUAL(IsQuorumTypeEnabledInternal(consensus_params.llmqTypeMnhf, qman, nullptr, true, true), true);
BOOST_CHECK_EQUAL(IsQuorumTypeEnabledInternal(consensus_params.llmqTypeMnhf, qman, nullptr, true, true), true);
}

BOOST_FIXTURE_TEST_CASE(utils_IsQuorumTypeEnabled_tests_regtest, RegTestingSetup)
Expand Down
2 changes: 1 addition & 1 deletion src/unordered_lru_cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ class unordered_lru_cache
template<typename Value2>
void _emplace(const Key& key, Value2&& v)
{
truncate_if_needed();
auto it = cacheMap.find(key);
if (it == cacheMap.end()) {
cacheMap.emplace(key, std::make_pair(std::forward<Value2>(v), accessCounter++));
} else {
it->second.first = std::forward<Value2>(v);
it->second.second = accessCounter++;
}
truncate_if_needed();
}

void emplace(const Key& key, Value&& v)
Expand Down
3 changes: 2 additions & 1 deletion src/wallet/walletdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,8 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue,
return false;
} else if (strType != DBKeys::BESTBLOCK && strType != DBKeys::BESTBLOCK_NOMERKLE &&
strType != DBKeys::MINVERSION && strType != DBKeys::ACENTRY &&
strType != DBKeys::VERSION && strType != DBKeys::SETTINGS) {
strType != DBKeys::VERSION && strType != DBKeys::SETTINGS &&
strType != DBKeys::PRIVATESEND_SALT && strType != DBKeys::COINJOIN_SALT) {
wss.m_unknown_records++;
}
} catch (const std::exception& e) {
Expand Down

0 comments on commit a99fd92

Please sign in to comment.