Merge pull request #5626 from knst/v20-todo-backports

backport:  bitcoin#23416,#18997,#18996, partial #27483 (TODO cleanup)
This commit is contained in:
PastaPastaPasta 2023-10-23 10:48:51 -05:00 committed by GitHub
commit dab44cd0b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 83 additions and 103 deletions

View File

@ -375,7 +375,8 @@ void SetServiceFlagsIBDCache(bool status);
* == GetDesirableServiceFlags(services), ie determines whether the given * == GetDesirableServiceFlags(services), ie determines whether the given
* set of service flags are sufficient for a peer to be "relevant". * set of service flags are sufficient for a peer to be "relevant".
*/ */
static inline bool HasAllDesirableServiceFlags(ServiceFlags services) { static inline bool HasAllDesirableServiceFlags(ServiceFlags services)
{
return !(GetDesirableServiceFlags(services) & (~services)); return !(GetDesirableServiceFlags(services) & (~services));
} }
@ -383,7 +384,8 @@ static inline bool HasAllDesirableServiceFlags(ServiceFlags services) {
* Checks if a peer with the given service flags may be capable of having a * Checks if a peer with the given service flags may be capable of having a
* robust address-storage DB. * robust address-storage DB.
*/ */
static inline bool MayHaveUsefulAddressDB(ServiceFlags services) { static inline bool MayHaveUsefulAddressDB(ServiceFlags services)
{
return (services & NODE_NETWORK) || (services & NODE_NETWORK_LIMITED); return (services & NODE_NETWORK) || (services & NODE_NETWORK_LIMITED);
} }

View File

@ -1814,7 +1814,7 @@ void BitcoinGUI::setEncryptionStatus(int status)
changePassphraseAction->setEnabled(true); changePassphraseAction->setEnabled(true);
unlockWalletAction->setVisible(false); unlockWalletAction->setVisible(false);
lockWalletAction->setVisible(true); lockWalletAction->setVisible(true);
encryptWalletAction->setEnabled(false); // TODO: decrypt currently not supported encryptWalletAction->setEnabled(false);
break; break;
case WalletModel::UnlockedForMixingOnly: case WalletModel::UnlockedForMixingOnly:
labelWalletEncryptionIcon->show(); labelWalletEncryptionIcon->show();
@ -1823,7 +1823,7 @@ void BitcoinGUI::setEncryptionStatus(int status)
changePassphraseAction->setEnabled(true); changePassphraseAction->setEnabled(true);
unlockWalletAction->setVisible(true); unlockWalletAction->setVisible(true);
lockWalletAction->setVisible(true); lockWalletAction->setVisible(true);
encryptWalletAction->setEnabled(false); // TODO: decrypt currently not supported encryptWalletAction->setEnabled(false);
break; break;
case WalletModel::Locked: case WalletModel::Locked:
labelWalletEncryptionIcon->show(); labelWalletEncryptionIcon->show();
@ -1832,7 +1832,7 @@ void BitcoinGUI::setEncryptionStatus(int status)
changePassphraseAction->setEnabled(true); changePassphraseAction->setEnabled(true);
unlockWalletAction->setVisible(true); unlockWalletAction->setVisible(true);
lockWalletAction->setVisible(false); lockWalletAction->setVisible(false);
encryptWalletAction->setEnabled(false); // TODO: decrypt currently not supported encryptWalletAction->setEnabled(false);
break; break;
} }
} }

View File

@ -40,17 +40,14 @@
#include <QKeyEvent> #include <QKeyEvent>
#include <QMenu> #include <QMenu>
#include <QMessageBox> #include <QMessageBox>
#include <QScrollBar>
#include <QScreen> #include <QScreen>
#include <QScrollBar>
#include <QSettings> #include <QSettings>
#include <QTime> #include <QTime>
#include <QTimer> #include <QTimer>
#include <QStringList> #include <QStringList>
#include <QStyledItemDelegate> #include <QStyledItemDelegate>
// TODO: add a scrollback limit, as there is currently none
// TODO: make it possible to filter out categories (esp debug messages when implemented)
// TODO: receive errors and debug messages through ClientModel
const int CONSOLE_HISTORY = 50; const int CONSOLE_HISTORY = 50;
const QSize FONT_RANGE(4, 40); const QSize FONT_RANGE(4, 40);

View File

@ -363,17 +363,11 @@ WalletModel::EncryptionStatus WalletModel::getEncryptionStatus() const
bool WalletModel::setWalletEncrypted(bool encrypted, const SecureString &passphrase) bool WalletModel::setWalletEncrypted(bool encrypted, const SecureString &passphrase)
{ {
if(encrypted) if (encrypted) {
{
// Encrypt
return m_wallet->encryptWallet(passphrase); return m_wallet->encryptWallet(passphrase);
} }
else
{
// Decrypt -- TODO; not supported yet
return false; return false;
} }
}
bool WalletModel::setWalletLocked(bool locked, const SecureString &passPhrase, bool fMixing) bool WalletModel::setWalletLocked(bool locked, const SecureString &passPhrase, bool fMixing)
{ {

View File

@ -366,8 +366,6 @@ void CTxMemPool::addUnchecked(const CTxMemPoolEntry &entry, setEntries &setAnces
mapLinks.insert(make_pair(newit, TxLinks())); mapLinks.insert(make_pair(newit, TxLinks()));
// Update transaction for any feeDelta created by PrioritiseTransaction // Update transaction for any feeDelta created by PrioritiseTransaction
// TODO: refactor so that the fee delta is calculated before inserting
// into mapTx.
CAmount delta{0}; CAmount delta{0};
ApplyDelta(entry.GetTx().GetHash(), delta); ApplyDelta(entry.GetTx().GetHash(), delta);
if (delta) { if (delta) {

View File

@ -613,18 +613,7 @@ def modinv(a, n):
"""Compute the modular inverse of a modulo n using the extended Euclidean """Compute the modular inverse of a modulo n using the extended Euclidean
Algorithm. See https://en.wikipedia.org/wiki/Extended_Euclidean_algorithm#Modular_integers. Algorithm. See https://en.wikipedia.org/wiki/Extended_Euclidean_algorithm#Modular_integers.
""" """
# TODO: Change to pow(a, -1, n) available in Python 3.8 return pow(a, -1, n)
t1, t2 = 0, 1
r1, r2 = n, a
while r2 != 0:
q = r1 // r2
t1, t2 = t2, t1 - q * t2
r1, r2 = r2, r1 - q * r2
if r1 > 1:
return None
if t1 < 0:
t1 += n
return t1
class TestFrameworkUtil(unittest.TestCase): class TestFrameworkUtil(unittest.TestCase):
def test_modinv(self): def test_modinv(self):