Merge pull request #5425 from UdjinM6/multi_fixes

fix: Various small fixes
This commit is contained in:
UdjinM6 2023-06-12 10:57:49 +03:00 committed by pasta
parent ec8d081556
commit 7477d839cd
No known key found for this signature in database
GPG Key ID: 52527BEDABE87984
13 changed files with 29 additions and 18 deletions

View File

@ -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());
}

View File

@ -32,7 +32,7 @@ public:
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);
};

View File

@ -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;
}

View File

@ -734,14 +734,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);

View File

@ -573,7 +573,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);

View File

@ -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) {

View File

@ -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);

View File

@ -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);
@ -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);
@ -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();

View File

@ -89,6 +89,7 @@ private:
QString previousTheme;
AppearanceWidget* appearance;
bool fCoinJoinEnabledPrev{false};
bool m_enable_wallet{false};
void showEvent(QShowEvent* event) override;
};

View File

@ -86,6 +86,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();

View File

@ -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)

View File

@ -36,7 +36,6 @@ public:
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++));
@ -44,6 +43,7 @@ public:
it->second.first = std::forward<Value2>(v);
it->second.second = accessCounter++;
}
truncate_if_needed();
}
void emplace(const Key& key, Value&& v)

View File

@ -486,7 +486,9 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue,
strErr = "Found unsupported 'wkey' record, try loading with version 0.17";
return false;
} else if (strType != DBKeys::BESTBLOCK && strType != DBKeys::BESTBLOCK_NOMERKLE &&
strType != DBKeys::MINVERSION && strType != DBKeys::ACENTRY && strType != DBKeys::VERSION) {
strType != DBKeys::MINVERSION && strType != DBKeys::ACENTRY &&
strType != DBKeys::VERSION &&
strType != DBKeys::PRIVATESEND_SALT && strType != DBKeys::COINJOIN_SALT) {
wss.m_unknown_records++;
}
} catch (const std::exception& e) {