mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 03:52:49 +01:00
Merge pull request #5626 from knst/v20-todo-backports
backport: bitcoin#23416,#18997,#18996, partial #27483 (TODO cleanup)
This commit is contained in:
commit
dab44cd0b0
150
src/protocol.h
150
src/protocol.h
@ -66,17 +66,17 @@ namespace NetMsgType {
|
||||
* The version message provides information about the transmitting node to the
|
||||
* receiving node at the beginning of a connection.
|
||||
*/
|
||||
extern const char *VERSION;
|
||||
extern const char* VERSION;
|
||||
/**
|
||||
* The verack message acknowledges a previously-received version message,
|
||||
* informing the connecting node that it can begin to send other messages.
|
||||
*/
|
||||
extern const char *VERACK;
|
||||
extern const char* VERACK;
|
||||
/**
|
||||
* The addr (IP address) message relays connection information for peers on the
|
||||
* network.
|
||||
*/
|
||||
extern const char *ADDR;
|
||||
extern const char* ADDR;
|
||||
/**
|
||||
* The addrv2 message relays connection information for peers on the network just
|
||||
* like the addr message, but is extended to allow gossiping of longer node
|
||||
@ -93,70 +93,70 @@ extern const char *SENDADDRV2;
|
||||
* The inv message (inventory message) transmits one or more inventories of
|
||||
* objects known to the transmitting peer.
|
||||
*/
|
||||
extern const char *INV;
|
||||
extern const char* INV;
|
||||
/**
|
||||
* The getdata message requests one or more data objects from another node.
|
||||
*/
|
||||
extern const char *GETDATA;
|
||||
extern const char* GETDATA;
|
||||
/**
|
||||
* The merkleblock message is a reply to a getdata message which requested a
|
||||
* block using the inventory type MSG_MERKLEBLOCK.
|
||||
* @since protocol version 70001 as described by BIP37.
|
||||
*/
|
||||
extern const char *MERKLEBLOCK;
|
||||
extern const char* MERKLEBLOCK;
|
||||
/**
|
||||
* The getblocks message requests an inv message that provides block header
|
||||
* hashes starting from a particular point in the block chain.
|
||||
*/
|
||||
extern const char *GETBLOCKS;
|
||||
extern const char* GETBLOCKS;
|
||||
/**
|
||||
* The getheaders message requests a headers message that provides block
|
||||
* headers starting from a particular point in the block chain.
|
||||
* @since protocol version 31800.
|
||||
*/
|
||||
extern const char *GETHEADERS;
|
||||
extern const char* GETHEADERS;
|
||||
/**
|
||||
* The tx message transmits a single transaction.
|
||||
*/
|
||||
extern const char *TX;
|
||||
extern const char* TX;
|
||||
/**
|
||||
* The headers message sends one or more block headers to a node which
|
||||
* previously requested certain headers with a getheaders message.
|
||||
* @since protocol version 31800.
|
||||
*/
|
||||
extern const char *HEADERS;
|
||||
extern const char* HEADERS;
|
||||
/**
|
||||
* The block message transmits a single serialized block.
|
||||
*/
|
||||
extern const char *BLOCK;
|
||||
extern const char* BLOCK;
|
||||
/**
|
||||
* The getaddr message requests an addr message from the receiving node,
|
||||
* preferably one with lots of IP addresses of other receiving nodes.
|
||||
*/
|
||||
extern const char *GETADDR;
|
||||
extern const char* GETADDR;
|
||||
/**
|
||||
* The mempool message requests the TXIDs of transactions that the receiving
|
||||
* node has verified as valid but which have not yet appeared in a block.
|
||||
* @since protocol version 60002.
|
||||
*/
|
||||
extern const char *MEMPOOL;
|
||||
extern const char* MEMPOOL;
|
||||
/**
|
||||
* The ping message is sent periodically to help confirm that the receiving
|
||||
* peer is still connected.
|
||||
*/
|
||||
extern const char *PING;
|
||||
extern const char* PING;
|
||||
/**
|
||||
* The pong message replies to a ping message, proving to the pinging node that
|
||||
* the ponging node is still alive.
|
||||
* @since protocol version 60001 as described by BIP31.
|
||||
*/
|
||||
extern const char *PONG;
|
||||
extern const char* PONG;
|
||||
/**
|
||||
* The notfound message is a reply to a getdata message which requested an
|
||||
* object the receiving node does not have available for relay.
|
||||
* @since protocol version 70001.
|
||||
*/
|
||||
extern const char *NOTFOUND;
|
||||
extern const char* NOTFOUND;
|
||||
/**
|
||||
* The filterload message tells the receiving peer to filter all relayed
|
||||
* transactions and requested merkle blocks through the provided filter.
|
||||
@ -164,7 +164,7 @@ extern const char *NOTFOUND;
|
||||
* Only available with service bit NODE_BLOOM since protocol version
|
||||
* 70011 as described by BIP111.
|
||||
*/
|
||||
extern const char *FILTERLOAD;
|
||||
extern const char* FILTERLOAD;
|
||||
/**
|
||||
* The filteradd message tells the receiving peer to add a single element to a
|
||||
* previously-set bloom filter, such as a new public key.
|
||||
@ -172,7 +172,7 @@ extern const char *FILTERLOAD;
|
||||
* Only available with service bit NODE_BLOOM since protocol version
|
||||
* 70011 as described by BIP111.
|
||||
*/
|
||||
extern const char *FILTERADD;
|
||||
extern const char* FILTERADD;
|
||||
/**
|
||||
* The filterclear message tells the receiving peer to remove a previously-set
|
||||
* bloom filter.
|
||||
@ -180,13 +180,13 @@ extern const char *FILTERADD;
|
||||
* Only available with service bit NODE_BLOOM since protocol version
|
||||
* 70011 as described by BIP111.
|
||||
*/
|
||||
extern const char *FILTERCLEAR;
|
||||
extern const char* FILTERCLEAR;
|
||||
/**
|
||||
* Indicates that a node prefers to receive new block announcements via a
|
||||
* "headers" message rather than an "inv".
|
||||
* @since protocol version 70012 as described by BIP130.
|
||||
*/
|
||||
extern const char *SENDHEADERS;
|
||||
extern const char* SENDHEADERS;
|
||||
|
||||
/**
|
||||
* Contains a 1-byte bool and 8-byte LE version number.
|
||||
@ -195,25 +195,25 @@ extern const char *SENDHEADERS;
|
||||
* "cmpctblock" message rather than an "inv", depending on message contents.
|
||||
* @since protocol version 70209 as described by BIP 152
|
||||
*/
|
||||
extern const char *SENDCMPCT;
|
||||
extern const char* SENDCMPCT;
|
||||
/**
|
||||
* Contains a CBlockHeaderAndShortTxIDs object - providing a header and
|
||||
* list of "short txids".
|
||||
* @since protocol version 70209 as described by BIP 152
|
||||
*/
|
||||
extern const char *CMPCTBLOCK;
|
||||
extern const char* CMPCTBLOCK;
|
||||
/**
|
||||
* Contains a BlockTransactionsRequest
|
||||
* Peer should respond with "blocktxn" message.
|
||||
* @since protocol version 70209 as described by BIP 152
|
||||
*/
|
||||
extern const char *GETBLOCKTXN;
|
||||
extern const char* GETBLOCKTXN;
|
||||
/**
|
||||
* Contains a BlockTransactions.
|
||||
* Sent in response to a "getblocktxn" message.
|
||||
* @since protocol version 70209 as described by BIP 152
|
||||
*/
|
||||
extern const char *BLOCKTXN;
|
||||
extern const char* BLOCKTXN;
|
||||
/**
|
||||
* getcfilters requests compact filters for a range of blocks.
|
||||
* Only available with service bit NODE_COMPACT_FILTERS as described by
|
||||
@ -244,61 +244,61 @@ extern const char* CFHEADERS;
|
||||
* Only available with service bit NODE_COMPACT_FILTERS as described by
|
||||
* BIP 157 & 158.
|
||||
*/
|
||||
extern const char *GETCFCHECKPT;
|
||||
extern const char* GETCFCHECKPT;
|
||||
/**
|
||||
* cfcheckpt is a response to a getcfcheckpt request containing a vector of
|
||||
* evenly spaced filter headers for blocks on the requested chain.
|
||||
*/
|
||||
extern const char *CFCHECKPT;
|
||||
extern const char* CFCHECKPT;
|
||||
|
||||
// Dash message types
|
||||
// NOTE: do NOT declare non-implmented here, we don't want them to be exposed to the outside
|
||||
// TODO: add description
|
||||
extern const char *SPORK;
|
||||
extern const char *GETSPORKS;
|
||||
extern const char *DSACCEPT;
|
||||
extern const char *DSVIN;
|
||||
extern const char *DSFINALTX;
|
||||
extern const char *DSSIGNFINALTX;
|
||||
extern const char *DSCOMPLETE;
|
||||
extern const char *DSSTATUSUPDATE;
|
||||
extern const char *DSTX;
|
||||
extern const char *DSQUEUE;
|
||||
extern const char *SENDDSQUEUE;
|
||||
extern const char *SYNCSTATUSCOUNT;
|
||||
extern const char *MNGOVERNANCESYNC;
|
||||
extern const char *MNGOVERNANCEOBJECT;
|
||||
extern const char *MNGOVERNANCEOBJECTVOTE;
|
||||
extern const char *GETMNLISTDIFF;
|
||||
extern const char *MNLISTDIFF;
|
||||
extern const char *QSENDRECSIGS;
|
||||
extern const char *QFCOMMITMENT;
|
||||
extern const char *QCONTRIB;
|
||||
extern const char *QCOMPLAINT;
|
||||
extern const char *QJUSTIFICATION;
|
||||
extern const char *QPCOMMITMENT;
|
||||
extern const char *QWATCH;
|
||||
extern const char *QSIGSESANN;
|
||||
extern const char *QSIGSHARESINV;
|
||||
extern const char *QGETSIGSHARES;
|
||||
extern const char *QBSIGSHARES;
|
||||
extern const char *QSIGREC;
|
||||
extern const char *QSIGSHARE;
|
||||
extern const char* SPORK;
|
||||
extern const char* GETSPORKS;
|
||||
extern const char* DSACCEPT;
|
||||
extern const char* DSVIN;
|
||||
extern const char* DSFINALTX;
|
||||
extern const char* DSSIGNFINALTX;
|
||||
extern const char* DSCOMPLETE;
|
||||
extern const char* DSSTATUSUPDATE;
|
||||
extern const char* DSTX;
|
||||
extern const char* DSQUEUE;
|
||||
extern const char* SENDDSQUEUE;
|
||||
extern const char* SYNCSTATUSCOUNT;
|
||||
extern const char* MNGOVERNANCESYNC;
|
||||
extern const char* MNGOVERNANCEOBJECT;
|
||||
extern const char* MNGOVERNANCEOBJECTVOTE;
|
||||
extern const char* GETMNLISTDIFF;
|
||||
extern const char* MNLISTDIFF;
|
||||
extern const char* QSENDRECSIGS;
|
||||
extern const char* QFCOMMITMENT;
|
||||
extern const char* QCONTRIB;
|
||||
extern const char* QCOMPLAINT;
|
||||
extern const char* QJUSTIFICATION;
|
||||
extern const char* QPCOMMITMENT;
|
||||
extern const char* QWATCH;
|
||||
extern const char* QSIGSESANN;
|
||||
extern const char* QSIGSHARESINV;
|
||||
extern const char* QGETSIGSHARES;
|
||||
extern const char* QBSIGSHARES;
|
||||
extern const char* QSIGREC;
|
||||
extern const char* QSIGSHARE;
|
||||
extern const char* QGETDATA;
|
||||
extern const char* QDATA;
|
||||
extern const char *CLSIG;
|
||||
extern const char *ISLOCK;
|
||||
extern const char *ISDLOCK;
|
||||
extern const char *MNAUTH;
|
||||
extern const char *GETHEADERS2;
|
||||
extern const char *SENDHEADERS2;
|
||||
extern const char *HEADERS2;
|
||||
extern const char *GETQUORUMROTATIONINFO;
|
||||
extern const char *QUORUMROTATIONINFO;
|
||||
extern const char* CLSIG;
|
||||
extern const char* ISLOCK;
|
||||
extern const char* ISDLOCK;
|
||||
extern const char* MNAUTH;
|
||||
extern const char* GETHEADERS2;
|
||||
extern const char* SENDHEADERS2;
|
||||
extern const char* HEADERS2;
|
||||
extern const char* GETQUORUMROTATIONINFO;
|
||||
extern const char* QUORUMROTATIONINFO;
|
||||
};
|
||||
|
||||
/* Get a vector of all valid message types (see above) */
|
||||
const std::vector<std::string> &getAllNetMessageTypes();
|
||||
const std::vector<std::string>& getAllNetMessageTypes();
|
||||
|
||||
/* Whether the message type violates blocks-relay-only policy */
|
||||
bool NetMessageViolatesBlocksOnly(const std::string& msg_type);
|
||||
@ -375,7 +375,8 @@ void SetServiceFlagsIBDCache(bool status);
|
||||
* == GetDesirableServiceFlags(services), ie determines whether the given
|
||||
* 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));
|
||||
}
|
||||
|
||||
@ -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
|
||||
* robust address-storage DB.
|
||||
*/
|
||||
static inline bool MayHaveUsefulAddressDB(ServiceFlags services) {
|
||||
static inline bool MayHaveUsefulAddressDB(ServiceFlags services)
|
||||
{
|
||||
return (services & NODE_NETWORK) || (services & NODE_NETWORK_LIMITED);
|
||||
}
|
||||
|
||||
@ -500,11 +502,11 @@ enum GetDataMsg {
|
||||
MSG_TX = 1,
|
||||
MSG_BLOCK = 2,
|
||||
// The following can only occur in getdata. Invs always use TX or BLOCK.
|
||||
MSG_FILTERED_BLOCK = 3, //!< Defined in BIP37
|
||||
MSG_FILTERED_BLOCK = 3, //!< Defined in BIP37
|
||||
// Dash message types
|
||||
// NOTE: we must keep this enum consistent and backwards compatible
|
||||
/* MSG_LEGACY_TXLOCK_REQUEST = 4, */ // Legacy InstantSend and not used anymore
|
||||
/* MSG_TXLOCK_VOTE = 5, */ // Legacy InstantSend and not used anymore
|
||||
/* MSG_LEGACY_TXLOCK_REQUEST = 4, */ // Legacy InstantSend and not used anymore
|
||||
/* MSG_TXLOCK_VOTE = 5, */ // Legacy InstantSend and not used anymore
|
||||
MSG_SPORK = 6,
|
||||
/* 7 - 15 were used in old Dash versions and were mainly budget and MN broadcast/ping related*/
|
||||
MSG_DSTX = 16,
|
||||
@ -513,14 +515,14 @@ enum GetDataMsg {
|
||||
/* 19 was used for MSG_MASTERNODE_VERIFY and is not supported anymore */
|
||||
// Nodes may always request a MSG_CMPCT_BLOCK in a getdata, however,
|
||||
// MSG_CMPCT_BLOCK should not appear in any invs except as a part of getdata.
|
||||
MSG_CMPCT_BLOCK = 20, //!< Defined in BIP152
|
||||
MSG_CMPCT_BLOCK = 20, //!< Defined in BIP152
|
||||
MSG_QUORUM_FINAL_COMMITMENT = 21,
|
||||
/* MSG_QUORUM_DUMMY_COMMITMENT = 22, */ // was shortly used on testnet/devnet/regtest
|
||||
/* MSG_QUORUM_DUMMY_COMMITMENT = 22, */ // was shortly used on testnet/devnet/regtest
|
||||
MSG_QUORUM_CONTRIB = 23,
|
||||
MSG_QUORUM_COMPLAINT = 24,
|
||||
MSG_QUORUM_JUSTIFICATION = 25,
|
||||
MSG_QUORUM_PREMATURE_COMMITMENT = 26,
|
||||
/* MSG_QUORUM_DEBUG_STATUS = 27, */ // was shortly used on testnet/devnet/regtest
|
||||
/* MSG_QUORUM_DEBUG_STATUS = 27, */ // was shortly used on testnet/devnet/regtest
|
||||
MSG_QUORUM_RECOVERED_SIG = 28,
|
||||
MSG_CLSIG = 29,
|
||||
MSG_ISLOCK = 30,
|
||||
|
@ -1814,7 +1814,7 @@ void BitcoinGUI::setEncryptionStatus(int status)
|
||||
changePassphraseAction->setEnabled(true);
|
||||
unlockWalletAction->setVisible(false);
|
||||
lockWalletAction->setVisible(true);
|
||||
encryptWalletAction->setEnabled(false); // TODO: decrypt currently not supported
|
||||
encryptWalletAction->setEnabled(false);
|
||||
break;
|
||||
case WalletModel::UnlockedForMixingOnly:
|
||||
labelWalletEncryptionIcon->show();
|
||||
@ -1823,7 +1823,7 @@ void BitcoinGUI::setEncryptionStatus(int status)
|
||||
changePassphraseAction->setEnabled(true);
|
||||
unlockWalletAction->setVisible(true);
|
||||
lockWalletAction->setVisible(true);
|
||||
encryptWalletAction->setEnabled(false); // TODO: decrypt currently not supported
|
||||
encryptWalletAction->setEnabled(false);
|
||||
break;
|
||||
case WalletModel::Locked:
|
||||
labelWalletEncryptionIcon->show();
|
||||
@ -1832,7 +1832,7 @@ void BitcoinGUI::setEncryptionStatus(int status)
|
||||
changePassphraseAction->setEnabled(true);
|
||||
unlockWalletAction->setVisible(true);
|
||||
lockWalletAction->setVisible(false);
|
||||
encryptWalletAction->setEnabled(false); // TODO: decrypt currently not supported
|
||||
encryptWalletAction->setEnabled(false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -40,17 +40,14 @@
|
||||
#include <QKeyEvent>
|
||||
#include <QMenu>
|
||||
#include <QMessageBox>
|
||||
#include <QScrollBar>
|
||||
#include <QScreen>
|
||||
#include <QScrollBar>
|
||||
#include <QSettings>
|
||||
#include <QTime>
|
||||
#include <QTimer>
|
||||
#include <QStringList>
|
||||
#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 QSize FONT_RANGE(4, 40);
|
||||
|
@ -363,16 +363,10 @@ WalletModel::EncryptionStatus WalletModel::getEncryptionStatus() const
|
||||
|
||||
bool WalletModel::setWalletEncrypted(bool encrypted, const SecureString &passphrase)
|
||||
{
|
||||
if(encrypted)
|
||||
{
|
||||
// Encrypt
|
||||
if (encrypted) {
|
||||
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)
|
||||
|
@ -366,8 +366,6 @@ void CTxMemPool::addUnchecked(const CTxMemPoolEntry &entry, setEntries &setAnces
|
||||
mapLinks.insert(make_pair(newit, TxLinks()));
|
||||
|
||||
// Update transaction for any feeDelta created by PrioritiseTransaction
|
||||
// TODO: refactor so that the fee delta is calculated before inserting
|
||||
// into mapTx.
|
||||
CAmount delta{0};
|
||||
ApplyDelta(entry.GetTx().GetHash(), delta);
|
||||
if (delta) {
|
||||
|
@ -613,18 +613,7 @@ def modinv(a, n):
|
||||
"""Compute the modular inverse of a modulo n using the extended Euclidean
|
||||
Algorithm. See https://en.wikipedia.org/wiki/Extended_Euclidean_algorithm#Modular_integers.
|
||||
"""
|
||||
# TODO: Change to pow(a, -1, n) available in Python 3.8
|
||||
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
|
||||
return pow(a, -1, n)
|
||||
|
||||
class TestFrameworkUtil(unittest.TestCase):
|
||||
def test_modinv(self):
|
||||
|
Loading…
Reference in New Issue
Block a user