mirror of
https://git.hush.is/hush/hush3.git
synced 2025-07-17 00:01:50 -04:00
Compare commits
3 Commits
4257b257df
...
fe9f1ef9e4
Author | SHA1 | Date | |
---|---|---|---|
|
fe9f1ef9e4 | ||
|
da5ae526e7 | ||
|
ae64eb2392 |
@ -35,12 +35,6 @@ pre-start script
|
|||||||
echo
|
echo
|
||||||
echo "bash -c 'tr -dc a-zA-Z0-9 < /dev/urandom | head -c32 && echo'"
|
echo "bash -c 'tr -dc a-zA-Z0-9 < /dev/urandom | head -c32 && echo'"
|
||||||
echo
|
echo
|
||||||
echo "It is also recommended that you also set alertnotify so you are "
|
|
||||||
echo "notified of problems:"
|
|
||||||
echo
|
|
||||||
echo "ie: alertnotify=echo %%s | mail -s \"Hush Alert\"" \
|
|
||||||
"admin@foo.com"
|
|
||||||
echo
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -81,11 +81,6 @@ checkconfig()
|
|||||||
eerror ""
|
eerror ""
|
||||||
eerror "bash -c 'tr -dc a-zA-Z0-9 < /dev/urandom | head -c32 && echo'"
|
eerror "bash -c 'tr -dc a-zA-Z0-9 < /dev/urandom | head -c32 && echo'"
|
||||||
eerror ""
|
eerror ""
|
||||||
eerror "It is also recommended that you also set alertnotify so you are "
|
|
||||||
eerror "notified of problems:"
|
|
||||||
eerror ""
|
|
||||||
eerror "ie: alertnotify=echo %%s | mail -s \"Hush Alert\"" \
|
|
||||||
"admin@foo.com"
|
|
||||||
eerror ""
|
eerror ""
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
@ -984,24 +984,6 @@ class msg_addr(object):
|
|||||||
return "msg_addr(addrs=%s)" % (repr(self.addrs))
|
return "msg_addr(addrs=%s)" % (repr(self.addrs))
|
||||||
|
|
||||||
|
|
||||||
class msg_alert(object):
|
|
||||||
command = "alert"
|
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
self.alert = CAlert()
|
|
||||||
|
|
||||||
def deserialize(self, f):
|
|
||||||
self.alert = CAlert()
|
|
||||||
self.alert.deserialize(f)
|
|
||||||
|
|
||||||
def serialize(self):
|
|
||||||
r = ""
|
|
||||||
r += self.alert.serialize()
|
|
||||||
return r
|
|
||||||
|
|
||||||
def __repr__(self):
|
|
||||||
return "msg_alert(alert=%s)" % (repr(self.alert), )
|
|
||||||
|
|
||||||
|
|
||||||
class msg_inv(object):
|
class msg_inv(object):
|
||||||
command = "inv"
|
command = "inv"
|
||||||
@ -1370,7 +1352,6 @@ class NodeConn(asyncore.dispatcher):
|
|||||||
"version": msg_version,
|
"version": msg_version,
|
||||||
"verack": msg_verack,
|
"verack": msg_verack,
|
||||||
"addr": msg_addr,
|
"addr": msg_addr,
|
||||||
"alert": msg_alert,
|
|
||||||
"inv": msg_inv,
|
"inv": msg_inv,
|
||||||
"getdata": msg_getdata,
|
"getdata": msg_getdata,
|
||||||
"getblocks": msg_getblocks,
|
"getblocks": msg_getblocks,
|
||||||
|
@ -122,7 +122,6 @@ BITCOIN_CORE_H = \
|
|||||||
addressindex.h \
|
addressindex.h \
|
||||||
spentindex.h \
|
spentindex.h \
|
||||||
addrman.h \
|
addrman.h \
|
||||||
alert.h \
|
|
||||||
amount.h \
|
amount.h \
|
||||||
amqp/amqpabstractnotifier.h \
|
amqp/amqpabstractnotifier.h \
|
||||||
amqp/amqpconfig.h \
|
amqp/amqpconfig.h \
|
||||||
@ -249,10 +248,7 @@ libbitcoin_util_a-clientversion.$(OBJEXT): obj/build.h
|
|||||||
libbitcoin_server_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(EVENT_CFLAGS) $(EVENT_PTHREADS_CFLAGS)
|
libbitcoin_server_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(EVENT_CFLAGS) $(EVENT_PTHREADS_CFLAGS)
|
||||||
libbitcoin_server_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
|
libbitcoin_server_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
|
||||||
libbitcoin_server_a_SOURCES = \
|
libbitcoin_server_a_SOURCES = \
|
||||||
sendalert.cpp \
|
|
||||||
addrman.cpp \
|
addrman.cpp \
|
||||||
alert.cpp \
|
|
||||||
alertkeys.h \
|
|
||||||
asyncrpcoperation.cpp \
|
asyncrpcoperation.cpp \
|
||||||
asyncrpcqueue.cpp \
|
asyncrpcqueue.cpp \
|
||||||
bloom.cpp \
|
bloom.cpp \
|
||||||
|
163
src/alert.cpp
163
src/alert.cpp
@ -1,163 +0,0 @@
|
|||||||
// Copyright (c) 2010 Satoshi Nakamoto
|
|
||||||
// Copyright (c) 2009-2014 The Bitcoin Core developers
|
|
||||||
// Copyright (c) 2016-2022 The Hush developers
|
|
||||||
// Distributed under the GPLv3 software license, see the accompanying
|
|
||||||
// file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html
|
|
||||||
/******************************************************************************
|
|
||||||
* Copyright © 2014-2019 The SuperNET Developers. *
|
|
||||||
* *
|
|
||||||
* See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at *
|
|
||||||
* the top-level directory of this distribution for the individual copyright *
|
|
||||||
* holder information and the developer policies on copyright and licensing. *
|
|
||||||
* *
|
|
||||||
* Unless otherwise agreed in a custom licensing agreement, no part of the *
|
|
||||||
* SuperNET software, including this file may be copied, modified, propagated *
|
|
||||||
* or distributed except according to the terms contained in the LICENSE file *
|
|
||||||
* *
|
|
||||||
* Removal or modification of this copyright notice is prohibited. *
|
|
||||||
* *
|
|
||||||
******************************************************************************/
|
|
||||||
#include "alert.h"
|
|
||||||
#include "clientversion.h"
|
|
||||||
#include "net.h"
|
|
||||||
#include "pubkey.h"
|
|
||||||
#include "timedata.h"
|
|
||||||
#include "ui_interface.h"
|
|
||||||
#include "util.h"
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <algorithm>
|
|
||||||
#include <map>
|
|
||||||
#include <boost/algorithm/string/classification.hpp>
|
|
||||||
#include <boost/algorithm/string/replace.hpp>
|
|
||||||
#include <boost/foreach.hpp>
|
|
||||||
#include <boost/thread.hpp>
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
map<uint256, CAlert> mapAlerts;
|
|
||||||
CCriticalSection cs_mapAlerts;
|
|
||||||
|
|
||||||
void CUnsignedAlert::SetNull()
|
|
||||||
{
|
|
||||||
nVersion = 1;
|
|
||||||
nRelayUntil = 0;
|
|
||||||
nExpiration = 0;
|
|
||||||
nID = 0;
|
|
||||||
nCancel = 0;
|
|
||||||
setCancel.clear();
|
|
||||||
nMinVer = 0;
|
|
||||||
nMaxVer = 0;
|
|
||||||
setSubVer.clear();
|
|
||||||
nPriority = 0;
|
|
||||||
|
|
||||||
strComment.clear();
|
|
||||||
strStatusBar.clear();
|
|
||||||
strRPCError.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string CUnsignedAlert::ToString() const
|
|
||||||
{
|
|
||||||
std::string strSetCancel;
|
|
||||||
BOOST_FOREACH(int n, setCancel)
|
|
||||||
strSetCancel += strprintf("%d ", n);
|
|
||||||
std::string strSetSubVer;
|
|
||||||
BOOST_FOREACH(const std::string& str, setSubVer)
|
|
||||||
strSetSubVer += "\"" + str + "\" ";
|
|
||||||
return strprintf(
|
|
||||||
"CAlert(\n"
|
|
||||||
" nVersion = %d\n"
|
|
||||||
" nRelayUntil = %d\n"
|
|
||||||
" nExpiration = %d\n"
|
|
||||||
" nID = %d\n"
|
|
||||||
" nCancel = %d\n"
|
|
||||||
" setCancel = %s\n"
|
|
||||||
" nMinVer = %d\n"
|
|
||||||
" nMaxVer = %d\n"
|
|
||||||
" setSubVer = %s\n"
|
|
||||||
" nPriority = %d\n"
|
|
||||||
" strComment = \"%s\"\n"
|
|
||||||
" strStatusBar = \"%s\"\n"
|
|
||||||
" strRPCError = \"%s\"\n"
|
|
||||||
")\n",
|
|
||||||
nVersion,
|
|
||||||
nRelayUntil,
|
|
||||||
nExpiration,
|
|
||||||
nID,
|
|
||||||
nCancel,
|
|
||||||
strSetCancel,
|
|
||||||
nMinVer,
|
|
||||||
nMaxVer,
|
|
||||||
strSetSubVer,
|
|
||||||
nPriority,
|
|
||||||
strComment,
|
|
||||||
strStatusBar,
|
|
||||||
strRPCError);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CAlert::SetNull()
|
|
||||||
{
|
|
||||||
CUnsignedAlert::SetNull();
|
|
||||||
vchMsg.clear();
|
|
||||||
vchSig.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CAlert::IsNull() const
|
|
||||||
{
|
|
||||||
return (nExpiration == 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint256 CAlert::GetHash() const
|
|
||||||
{
|
|
||||||
return Hash(this->vchMsg.begin(), this->vchMsg.end());
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CAlert::IsInEffect() const
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CAlert::Cancels(const CAlert& alert) const
|
|
||||||
{
|
|
||||||
if (!IsInEffect())
|
|
||||||
return false; // this was a no-op before 31403
|
|
||||||
return (alert.nID <= nCancel || setCancel.count(alert.nID));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CAlert::AppliesTo(int nVersion, const std::string& strSubVerIn) const
|
|
||||||
{
|
|
||||||
// TODO: rework for client-version-embedded-in-strSubVer ?
|
|
||||||
return (IsInEffect() &&
|
|
||||||
nMinVer <= nVersion && nVersion <= nMaxVer &&
|
|
||||||
(setSubVer.empty() || setSubVer.count(strSubVerIn)));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CAlert::AppliesToMe() const
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CAlert::RelayTo(CNode* pnode) const
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CAlert::CheckSignature(const std::vector<unsigned char>& alertKey) const
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
CAlert CAlert::getAlertByHash(const uint256 &hash)
|
|
||||||
{
|
|
||||||
CAlert retval;
|
|
||||||
return retval;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CAlert::ProcessAlert(const std::vector<unsigned char>& alertKey, bool fThread)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CAlert::Notify(const std::string& strMessage, bool fThread)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
127
src/alert.h
127
src/alert.h
@ -1,127 +0,0 @@
|
|||||||
// Copyright (c) 2010 Satoshi Nakamoto
|
|
||||||
// Copyright (c) 2009-2013 The Bitcoin Core developers
|
|
||||||
// Copyright (c) 2016-2022 The Hush developers
|
|
||||||
// Distributed under the GPLv3 software license, see the accompanying
|
|
||||||
// file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html
|
|
||||||
|
|
||||||
/******************************************************************************
|
|
||||||
* Copyright © 2014-2019 The SuperNET Developers. *
|
|
||||||
* *
|
|
||||||
* See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at *
|
|
||||||
* the top-level directory of this distribution for the individual copyright *
|
|
||||||
* holder information and the developer policies on copyright and licensing. *
|
|
||||||
* *
|
|
||||||
* Unless otherwise agreed in a custom licensing agreement, no part of the *
|
|
||||||
* SuperNET software, including this file may be copied, modified, propagated *
|
|
||||||
* or distributed except according to the terms contained in the LICENSE file *
|
|
||||||
* *
|
|
||||||
* Removal or modification of this copyright notice is prohibited. *
|
|
||||||
* *
|
|
||||||
******************************************************************************/
|
|
||||||
|
|
||||||
#ifndef HUSH_ALERT_H
|
|
||||||
#define HUSH_ALERT_H
|
|
||||||
|
|
||||||
#include "serialize.h"
|
|
||||||
#include "sync.h"
|
|
||||||
#include <map>
|
|
||||||
#include <set>
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
class CAlert;
|
|
||||||
class CNode;
|
|
||||||
class uint256;
|
|
||||||
|
|
||||||
extern std::map<uint256, CAlert> mapAlerts;
|
|
||||||
extern CCriticalSection cs_mapAlerts;
|
|
||||||
|
|
||||||
/** Alerts are for notifying old versions if they become too obsolete and
|
|
||||||
* need to upgrade. The message is displayed in the status bar.
|
|
||||||
* Alert messages are broadcast as a vector of signed data. Unserializing may
|
|
||||||
* not read the entire buffer if the alert is for a newer version, but older
|
|
||||||
* versions can still relay the original data.
|
|
||||||
*/
|
|
||||||
class CUnsignedAlert
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
int nVersion;
|
|
||||||
int64_t nRelayUntil; // when newer nodes stop relaying to newer nodes
|
|
||||||
int64_t nExpiration;
|
|
||||||
int nID;
|
|
||||||
int nCancel;
|
|
||||||
std::set<int> setCancel;
|
|
||||||
int nMinVer; // lowest version inclusive
|
|
||||||
int nMaxVer; // highest version inclusive
|
|
||||||
std::set<std::string> setSubVer; // empty matches all
|
|
||||||
int nPriority;
|
|
||||||
|
|
||||||
// Actions
|
|
||||||
std::string strComment;
|
|
||||||
std::string strStatusBar;
|
|
||||||
std::string strRPCError;
|
|
||||||
|
|
||||||
ADD_SERIALIZE_METHODS;
|
|
||||||
|
|
||||||
template <typename Stream, typename Operation>
|
|
||||||
inline void SerializationOp(Stream& s, Operation ser_action) {
|
|
||||||
READWRITE(this->nVersion);
|
|
||||||
READWRITE(nRelayUntil);
|
|
||||||
READWRITE(nExpiration);
|
|
||||||
READWRITE(nID);
|
|
||||||
READWRITE(nCancel);
|
|
||||||
READWRITE(setCancel);
|
|
||||||
READWRITE(nMinVer);
|
|
||||||
READWRITE(nMaxVer);
|
|
||||||
READWRITE(setSubVer);
|
|
||||||
READWRITE(nPriority);
|
|
||||||
|
|
||||||
READWRITE(LIMITED_STRING(strComment, 65536));
|
|
||||||
READWRITE(LIMITED_STRING(strStatusBar, 256));
|
|
||||||
READWRITE(LIMITED_STRING(strRPCError, 256));
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetNull();
|
|
||||||
|
|
||||||
std::string ToString() const;
|
|
||||||
};
|
|
||||||
|
|
||||||
/** An alert is a combination of a serialized CUnsignedAlert and a signature. */
|
|
||||||
class CAlert : public CUnsignedAlert
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
std::vector<unsigned char> vchMsg;
|
|
||||||
std::vector<unsigned char> vchSig;
|
|
||||||
|
|
||||||
CAlert()
|
|
||||||
{
|
|
||||||
SetNull();
|
|
||||||
}
|
|
||||||
|
|
||||||
ADD_SERIALIZE_METHODS;
|
|
||||||
|
|
||||||
template <typename Stream, typename Operation>
|
|
||||||
inline void SerializationOp(Stream& s, Operation ser_action) {
|
|
||||||
READWRITE(vchMsg);
|
|
||||||
READWRITE(vchSig);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetNull();
|
|
||||||
bool IsNull() const;
|
|
||||||
uint256 GetHash() const;
|
|
||||||
bool IsInEffect() const;
|
|
||||||
bool Cancels(const CAlert& alert) const;
|
|
||||||
bool AppliesTo(int nVersion, const std::string& strSubVerIn) const;
|
|
||||||
bool AppliesToMe() const;
|
|
||||||
bool RelayTo(CNode* pnode) const;
|
|
||||||
bool CheckSignature(const std::vector<unsigned char>& alertKey) const;
|
|
||||||
bool ProcessAlert(const std::vector<unsigned char>& alertKey, bool fThread = true); // fThread means run -alertnotify in a free-running thread
|
|
||||||
static void Notify(const std::string& strMessage, bool fThread);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Get copy of (active) alert object by hash. Returns a null alert if it is not found.
|
|
||||||
*/
|
|
||||||
static CAlert getAlertByHash(const uint256 &hash);
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // HUSH_ALERT_H
|
|
@ -1,28 +0,0 @@
|
|||||||
// Copyright (c) 2016-2022 The Hush developers
|
|
||||||
// Distributed under the GPLv3 software license, see the accompanying
|
|
||||||
// file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html
|
|
||||||
/******************************************************************************
|
|
||||||
* Copyright © 2014-2019 The SuperNET Developers. *
|
|
||||||
* *
|
|
||||||
* See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at *
|
|
||||||
* the top-level directory of this distribution for the individual copyright *
|
|
||||||
* holder information and the developer policies on copyright and licensing. *
|
|
||||||
* *
|
|
||||||
* Unless otherwise agreed in a custom licensing agreement, no part of the *
|
|
||||||
* SuperNET software, including this file may be copied, modified, propagated *
|
|
||||||
* or distributed except according to the terms contained in the LICENSE file *
|
|
||||||
* *
|
|
||||||
* Removal or modification of this copyright notice is prohibited. *
|
|
||||||
* *
|
|
||||||
******************************************************************************/
|
|
||||||
|
|
||||||
#ifndef HUSH_ALERTKEYS_H
|
|
||||||
#define HUSH_ALERTKEYS_H
|
|
||||||
|
|
||||||
// REMINDER: DO NOT COMMIT YOUR PRIVATE KEYS TO THE GIT REPOSITORY, lulz
|
|
||||||
|
|
||||||
const char* pszPrivKey = "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000";
|
|
||||||
const char* pszTestNetPrivKey = "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000";
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -142,7 +142,6 @@ public:
|
|||||||
pchMessageStart[1] = 0xee;
|
pchMessageStart[1] = 0xee;
|
||||||
pchMessageStart[2] = 0xe4;
|
pchMessageStart[2] = 0xe4;
|
||||||
pchMessageStart[3] = 0x8d;
|
pchMessageStart[3] = 0x8d;
|
||||||
vAlertPubKey = ParseHex("038a1bd41a08f38edda51042988022933c5775dfce81f7bae0b32a9179650352ac");
|
|
||||||
nDefaultPort = 5420;
|
nDefaultPort = 5420;
|
||||||
nMinerThreads = 0;
|
nMinerThreads = 0;
|
||||||
nMaxTipAge = 24 * 60 * 60;
|
nMaxTipAge = 24 * 60 * 60;
|
||||||
@ -280,7 +279,6 @@ public:
|
|||||||
pchMessageStart[1] = 0x1F;
|
pchMessageStart[1] = 0x1F;
|
||||||
pchMessageStart[2] = 0x7E;
|
pchMessageStart[2] = 0x7E;
|
||||||
pchMessageStart[3] = 0x62;
|
pchMessageStart[3] = 0x62;
|
||||||
vAlertPubKey = ParseHex("038a1bd41a08f38edda51042988022933c5775dfce81f7bae0b32a9179650352ac");
|
|
||||||
nMaxTipAge = 24 * 60 * 60;
|
nMaxTipAge = 24 * 60 * 60;
|
||||||
|
|
||||||
nPruneAfterHeight = 1000;
|
nPruneAfterHeight = 1000;
|
||||||
|
@ -85,7 +85,6 @@ public:
|
|||||||
|
|
||||||
const Consensus::Params& GetConsensus() const { return consensus; }
|
const Consensus::Params& GetConsensus() const { return consensus; }
|
||||||
const CMessageHeader::MessageStartChars& MessageStart() const { return pchMessageStart; }
|
const CMessageHeader::MessageStartChars& MessageStart() const { return pchMessageStart; }
|
||||||
const std::vector<unsigned char>& AlertKey() const { return vAlertPubKey; }
|
|
||||||
int GetDefaultPort() const { return nDefaultPort; }
|
int GetDefaultPort() const { return nDefaultPort; }
|
||||||
|
|
||||||
const CBlock& GenesisBlock() const { return genesis; }
|
const CBlock& GenesisBlock() const { return genesis; }
|
||||||
@ -134,8 +133,6 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
CChainParams() {}
|
CChainParams() {}
|
||||||
|
|
||||||
//! Raw pub key bytes for the broadcast alert signing key.
|
|
||||||
std::vector<unsigned char> vAlertPubKey;
|
|
||||||
int nMinerThreads = 0;
|
int nMinerThreads = 0;
|
||||||
long nMaxTipAge = 0;
|
long nMaxTipAge = 0;
|
||||||
int nDefaultPort = 0;
|
int nDefaultPort = 0;
|
||||||
|
@ -19,8 +19,6 @@
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
#include "deprecation.h"
|
#include "deprecation.h"
|
||||||
|
|
||||||
#include "alert.h"
|
|
||||||
#include "clientversion.h"
|
#include "clientversion.h"
|
||||||
#include "init.h"
|
#include "init.h"
|
||||||
#include "ui_interface.h"
|
#include "ui_interface.h"
|
||||||
@ -51,7 +49,6 @@ void EnforceNodeDeprecation(int nHeight, bool forceLogging, bool fThread) {
|
|||||||
DEPRECATION_HEIGHT) + " " +
|
DEPRECATION_HEIGHT) + " " +
|
||||||
_("You should upgrade to the latest version of Hush.");
|
_("You should upgrade to the latest version of Hush.");
|
||||||
LogPrintf("*** %s\n", msg);
|
LogPrintf("*** %s\n", msg);
|
||||||
CAlert::Notify(msg, fThread);
|
|
||||||
uiInterface.ThreadSafeMessageBox(msg, "", CClientUIInterface::MSG_ERROR);
|
uiInterface.ThreadSafeMessageBox(msg, "", CClientUIInterface::MSG_ERROR);
|
||||||
}
|
}
|
||||||
StartShutdown();
|
StartShutdown();
|
||||||
@ -60,7 +57,6 @@ void EnforceNodeDeprecation(int nHeight, bool forceLogging, bool fThread) {
|
|||||||
DEPRECATION_HEIGHT) + " " +
|
DEPRECATION_HEIGHT) + " " +
|
||||||
_("You should upgrade to the latest version of Hush.");
|
_("You should upgrade to the latest version of Hush.");
|
||||||
LogPrintf("*** %s\n", msg);
|
LogPrintf("*** %s\n", msg);
|
||||||
CAlert::Notify(msg, fThread);
|
|
||||||
uiInterface.ThreadSafeMessageBox(msg, "", CClientUIInterface::MSG_WARNING);
|
uiInterface.ThreadSafeMessageBox(msg, "", CClientUIInterface::MSG_WARNING);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -87,7 +87,6 @@ using namespace std;
|
|||||||
|
|
||||||
#include "hush_defs.h"
|
#include "hush_defs.h"
|
||||||
static const bool DEFAULT_STRATUM_ENABLE = false;
|
static const bool DEFAULT_STRATUM_ENABLE = false;
|
||||||
extern void ThreadSendAlert();
|
|
||||||
extern bool hush_dailysnapshot(int32_t height);
|
extern bool hush_dailysnapshot(int32_t height);
|
||||||
extern int32_t HUSH_LOADINGBLOCKS;
|
extern int32_t HUSH_LOADINGBLOCKS;
|
||||||
extern char SMART_CHAIN_SYMBOL[];
|
extern char SMART_CHAIN_SYMBOL[];
|
||||||
@ -361,7 +360,6 @@ std::string HelpMessage(HelpMessageMode mode)
|
|||||||
|
|
||||||
string strUsage = HelpMessageGroup(_("Options:"));
|
string strUsage = HelpMessageGroup(_("Options:"));
|
||||||
strUsage += HelpMessageOpt("-?", _("This help message"));
|
strUsage += HelpMessageOpt("-?", _("This help message"));
|
||||||
strUsage += HelpMessageOpt("-alertnotify=<cmd>", _("Execute command when a relevant alert is received or we see a really long fork (%s in cmd is replaced by message)"));
|
|
||||||
strUsage += HelpMessageOpt("-blocknotify=<cmd>", _("Execute command when the best block changes (%s in cmd is replaced by block hash)"));
|
strUsage += HelpMessageOpt("-blocknotify=<cmd>", _("Execute command when the best block changes (%s in cmd is replaced by block hash)"));
|
||||||
strUsage += HelpMessageOpt("-checkblocks=<n>", strprintf(_("How many blocks to check at startup (default: %u, 0 = all)"), 288));
|
strUsage += HelpMessageOpt("-checkblocks=<n>", strprintf(_("How many blocks to check at startup (default: %u, 0 = all)"), 288));
|
||||||
strUsage += HelpMessageOpt("-checklevel=<n>", strprintf(_("How thorough the block verification of -checkblocks is (0-4, default: %u)"), 3));
|
strUsage += HelpMessageOpt("-checklevel=<n>", strprintf(_("How thorough the block verification of -checkblocks is (0-4, default: %u)"), 3));
|
||||||
@ -501,7 +499,7 @@ std::string HelpMessage(HelpMessageMode mode)
|
|||||||
strUsage += HelpMessageOpt("-stopafterblockimport", strprintf("Stop running after importing blocks from disk (default: %u)", 0));
|
strUsage += HelpMessageOpt("-stopafterblockimport", strprintf("Stop running after importing blocks from disk (default: %u)", 0));
|
||||||
strUsage += HelpMessageOpt("-nuparams=hexBranchId:activationHeight", "Use given activation height for specified network upgrade (regtest-only)");
|
strUsage += HelpMessageOpt("-nuparams=hexBranchId:activationHeight", "Use given activation height for specified network upgrade (regtest-only)");
|
||||||
}
|
}
|
||||||
string debugCategories = "addrman, alert, bench, coindb, db, deletetx, estimatefee, http, libevent, lock, mempool, net, tls, partitioncheck, pow, proxy, prune, rand, randomx, reindex, rpc, selectcoins, stratum, tor, zrpc, zrpcunsafe (implies zrpc)"; // Don't translate these
|
string debugCategories = "addrman, bench, coindb, db, deletetx, estimatefee, http, libevent, lock, mempool, net, tls, partitioncheck, pow, proxy, prune, rand, randomx, reindex, rpc, selectcoins, stratum, tor, zrpc, zrpcunsafe (implies zrpc)"; // Don't translate these
|
||||||
strUsage += HelpMessageOpt("-debug=<category>", strprintf(_("Output debugging information (default: %u, supplying <category> is optional)"), 0) + ". " +
|
strUsage += HelpMessageOpt("-debug=<category>", strprintf(_("Output debugging information (default: %u, supplying <category> is optional)"), 0) + ". " +
|
||||||
_("If <category> is not supplied or if <category> = 1, output all debugging information.") + " " + _("<category> can be:") + " " + debugCategories + ".");
|
_("If <category> is not supplied or if <category> = 1, output all debugging information.") + " " + _("<category> can be:") + " " + debugCategories + ".");
|
||||||
strUsage += HelpMessageOpt("-experimentalfeatures", _("Enable use of experimental features"));
|
strUsage += HelpMessageOpt("-experimentalfeatures", _("Enable use of experimental features"));
|
||||||
@ -1380,8 +1378,6 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
|||||||
fIsBareMultisigStd = GetBoolArg("-permitbaremultisig", true);
|
fIsBareMultisigStd = GetBoolArg("-permitbaremultisig", true);
|
||||||
nMaxDatacarrierBytes = GetArg("-datacarriersize", nMaxDatacarrierBytes);
|
nMaxDatacarrierBytes = GetArg("-datacarriersize", nMaxDatacarrierBytes);
|
||||||
|
|
||||||
fAlerts = GetBoolArg("-alerts", DEFAULT_ALERTS);
|
|
||||||
|
|
||||||
// Option to startup with mocktime set (used for regression testing):
|
// Option to startup with mocktime set (used for regression testing):
|
||||||
SetMockTime(GetArg("-mocktime", 0)); // SetMockTime(0) is a no-op
|
SetMockTime(GetArg("-mocktime", 0)); // SetMockTime(0) is a no-op
|
||||||
|
|
||||||
@ -2398,9 +2394,6 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// SENDALERT
|
|
||||||
threadGroup.create_thread(boost::bind(ThreadSendAlert));
|
|
||||||
|
|
||||||
if(fDebug)
|
if(fDebug)
|
||||||
fprintf(stderr,"%s end fRequestShutdown=%d\n", __FUNCTION__, !!fRequestShutdown);
|
fprintf(stderr,"%s end fRequestShutdown=%d\n", __FUNCTION__, !!fRequestShutdown);
|
||||||
return !fRequestShutdown;
|
return !fRequestShutdown;
|
||||||
|
52
src/main.cpp
52
src/main.cpp
@ -20,7 +20,6 @@
|
|||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "sodium.h"
|
#include "sodium.h"
|
||||||
#include "addrman.h"
|
#include "addrman.h"
|
||||||
#include "alert.h"
|
|
||||||
#include "arith_uint256.h"
|
#include "arith_uint256.h"
|
||||||
#include "importcoin.h"
|
#include "importcoin.h"
|
||||||
#include "chainparams.h"
|
#include "chainparams.h"
|
||||||
@ -106,7 +105,6 @@ bool fCheckpointsEnabled = true;
|
|||||||
bool fCoinbaseEnforcedProtectionEnabled = true;
|
bool fCoinbaseEnforcedProtectionEnabled = true;
|
||||||
size_t nCoinCacheUsage = 5000 * 300;
|
size_t nCoinCacheUsage = 5000 * 300;
|
||||||
uint64_t nPruneTarget = 0;
|
uint64_t nPruneTarget = 0;
|
||||||
bool fAlerts = DEFAULT_ALERTS;
|
|
||||||
// If the tip is older than this (in seconds), the node is considered to be in initial block download.
|
// If the tip is older than this (in seconds), the node is considered to be in initial block download.
|
||||||
int64_t nMaxTipAge = DEFAULT_MAX_TIP_AGE;
|
int64_t nMaxTipAge = DEFAULT_MAX_TIP_AGE;
|
||||||
bool ishush3 = strncmp(SMART_CHAIN_SYMBOL, "HUSH3",5) == 0 ? true : false;
|
bool ishush3 = strncmp(SMART_CHAIN_SYMBOL, "HUSH3",5) == 0 ? true : false;
|
||||||
@ -2470,9 +2468,8 @@ void CheckForkWarningConditions()
|
|||||||
{
|
{
|
||||||
if (!fLargeWorkForkFound && pindexBestForkBase)
|
if (!fLargeWorkForkFound && pindexBestForkBase)
|
||||||
{
|
{
|
||||||
std::string warning = std::string("'Warning: Large-work fork detected, forking after block ") +
|
std::string warning = std::string("'Warning: Large-work fork detected, forking after block ") + pindexBestForkBase->phashBlock->ToString() + std::string("'");
|
||||||
pindexBestForkBase->phashBlock->ToString() + std::string("'");
|
LogPrintf("%s: %s\n", __func__, warning.c_str());
|
||||||
CAlert::Notify(warning, true);
|
|
||||||
}
|
}
|
||||||
if (pindexBestForkTip && pindexBestForkBase)
|
if (pindexBestForkTip && pindexBestForkBase)
|
||||||
{
|
{
|
||||||
@ -2480,12 +2477,9 @@ void CheckForkWarningConditions()
|
|||||||
pindexBestForkBase->GetHeight(), pindexBestForkBase->phashBlock->ToString(),
|
pindexBestForkBase->GetHeight(), pindexBestForkBase->phashBlock->ToString(),
|
||||||
pindexBestForkTip->GetHeight(), pindexBestForkTip->phashBlock->ToString());
|
pindexBestForkTip->GetHeight(), pindexBestForkTip->phashBlock->ToString());
|
||||||
fLargeWorkForkFound = true;
|
fLargeWorkForkFound = true;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
std::string warning = std::string("Warning: Found invalid chain at least ~6 blocks longer than our best chain.\nChain state database corruption likely.");
|
std::string warning = std::string("Warning: Found invalid chain at least ~6 blocks longer than our best chain.\nChain state database corruption likely.");
|
||||||
LogPrintf("%s: %s\n", warning.c_str(), __func__);
|
LogPrintf("%s: %s\n", __func__, warning.c_str());
|
||||||
CAlert::Notify(warning, true);
|
|
||||||
fLargeWorkInvalidChainFound = true;
|
fLargeWorkInvalidChainFound = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -6651,11 +6645,7 @@ void static CheckBlockIndex()
|
|||||||
assert(nNodes == forward.size());
|
assert(nNodes == forward.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// CAlert
|
// CAlert
|
||||||
//
|
|
||||||
|
|
||||||
std::string GetWarnings(const std::string& strFor)
|
std::string GetWarnings(const std::string& strFor)
|
||||||
{
|
{
|
||||||
int nPriority = 0;
|
int nPriority = 0;
|
||||||
@ -6686,23 +6676,6 @@ std::string GetWarnings(const std::string& strFor)
|
|||||||
strStatusBar = strRPC = _("Warning: We do not appear to fully agree with our peers! You may need to upgrade, or other nodes may need to upgrade.");
|
strStatusBar = strRPC = _("Warning: We do not appear to fully agree with our peers! You may need to upgrade, or other nodes may need to upgrade.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Alerts
|
|
||||||
{
|
|
||||||
LOCK(cs_mapAlerts);
|
|
||||||
BOOST_FOREACH(PAIRTYPE(const uint256, CAlert)& item, mapAlerts)
|
|
||||||
{
|
|
||||||
const CAlert& alert = item.second;
|
|
||||||
if (alert.AppliesToMe() && alert.nPriority > nPriority)
|
|
||||||
{
|
|
||||||
nPriority = alert.nPriority;
|
|
||||||
strStatusBar = alert.strStatusBar;
|
|
||||||
if (alert.nPriority >= ALERT_PRIORITY_SAFE_MODE) {
|
|
||||||
strRPC = alert.strRPCError;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (strFor == "statusbar")
|
if (strFor == "statusbar")
|
||||||
return strStatusBar;
|
return strStatusBar;
|
||||||
else if (strFor == "rpc")
|
else if (strFor == "rpc")
|
||||||
@ -6711,18 +6684,7 @@ std::string GetWarnings(const std::string& strFor)
|
|||||||
return "error";
|
return "error";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// Messages
|
// Messages
|
||||||
//
|
|
||||||
|
|
||||||
|
|
||||||
bool static AlreadyHave(const CInv& inv) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
|
bool static AlreadyHave(const CInv& inv) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
|
||||||
{
|
{
|
||||||
@ -7702,9 +7664,9 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
|||||||
}
|
}
|
||||||
if (vInv.size() > 0)
|
if (vInv.size() > 0)
|
||||||
pfrom->PushMessage("inv", vInv);
|
pfrom->PushMessage("inv", vInv);
|
||||||
} else if (fAlerts && strCommand == "alert") {
|
} else if (strCommand == "alert") {
|
||||||
// Do not process alert p2p messages and give DoS penalty
|
// Do not process alert p2p messages
|
||||||
Misbehaving(pfrom->GetId(), 10);
|
// Misbehaving(pfrom->GetId(), 10);
|
||||||
} else if (!(nLocalServices & NODE_BLOOM) &&
|
} else if (!(nLocalServices & NODE_BLOOM) &&
|
||||||
(strCommand == "filterload" ||
|
(strCommand == "filterload" ||
|
||||||
strCommand == "filteradd")) {
|
strCommand == "filteradd")) {
|
||||||
|
@ -71,10 +71,6 @@ static const unsigned int DEFAULT_BLOCK_MAX_SIZE = 2000000;//MAX_BLOCK_SIZE;
|
|||||||
static const unsigned int DEFAULT_BLOCK_MIN_SIZE = 0;
|
static const unsigned int DEFAULT_BLOCK_MIN_SIZE = 0;
|
||||||
/** Default for -blockprioritysize, maximum space for zero/low-fee transactions **/
|
/** Default for -blockprioritysize, maximum space for zero/low-fee transactions **/
|
||||||
static const unsigned int DEFAULT_BLOCK_PRIORITY_SIZE = DEFAULT_BLOCK_MAX_SIZE / 2;
|
static const unsigned int DEFAULT_BLOCK_PRIORITY_SIZE = DEFAULT_BLOCK_MAX_SIZE / 2;
|
||||||
/** Default for accepting alerts from the P2P network. */
|
|
||||||
static const bool DEFAULT_ALERTS = true;
|
|
||||||
/** Minimum alert priority for enabling safe mode. */
|
|
||||||
static const int ALERT_PRIORITY_SAFE_MODE = 4000;
|
|
||||||
/** Maximum reorg length we will accept before we shut down and alert the user. */
|
/** Maximum reorg length we will accept before we shut down and alert the user. */
|
||||||
static unsigned int MAX_REORG_LENGTH = _COINBASE_MATURITY - 1;
|
static unsigned int MAX_REORG_LENGTH = _COINBASE_MATURITY - 1;
|
||||||
/** Maximum number of signature check operations in an IsStandard() P2SH script */
|
/** Maximum number of signature check operations in an IsStandard() P2SH script */
|
||||||
@ -165,7 +161,6 @@ extern bool fCheckpointsEnabled;
|
|||||||
extern bool fCoinbaseEnforcedProtectionEnabled;
|
extern bool fCoinbaseEnforcedProtectionEnabled;
|
||||||
extern size_t nCoinCacheUsage;
|
extern size_t nCoinCacheUsage;
|
||||||
extern CFeeRate minRelayTxFee;
|
extern CFeeRate minRelayTxFee;
|
||||||
extern bool fAlerts;
|
|
||||||
extern int64_t nMaxTipAge;
|
extern int64_t nMaxTipAge;
|
||||||
|
|
||||||
/** Best header we've seen so far (used for getheaders queries' starting points). */
|
/** Best header we've seen so far (used for getheaders queries' starting points). */
|
||||||
|
@ -1,83 +0,0 @@
|
|||||||
// Copyright (c) 2016-2022 The Hush developers
|
|
||||||
// Copyright (c) 2016 The Zcash developers
|
|
||||||
// Original code from: https://gist.github.com/laanwj/0e689cfa37b52bcbbb44
|
|
||||||
// Distributed under the GPLv3 software license, see the accompanying
|
|
||||||
// file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html
|
|
||||||
|
|
||||||
/******************************************************************************
|
|
||||||
* Copyright © 2014-2019 The SuperNET Developers. *
|
|
||||||
* *
|
|
||||||
* See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at *
|
|
||||||
* the top-level directory of this distribution for the individual copyright *
|
|
||||||
* holder information and the developer policies on copyright and licensing. *
|
|
||||||
* *
|
|
||||||
* Unless otherwise agreed in a custom licensing agreement, no part of the *
|
|
||||||
* SuperNET software, including this file may be copied, modified, propagated *
|
|
||||||
* or distributed except according to the terms contained in the LICENSE file *
|
|
||||||
* *
|
|
||||||
* Removal or modification of this copyright notice is prohibited. *
|
|
||||||
* *
|
|
||||||
******************************************************************************/
|
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
To set up a new alert system
|
|
||||||
----------------------------
|
|
||||||
|
|
||||||
Create a new alert key pair:
|
|
||||||
openssl ecparam -name secp256k1 -genkey -param_enc explicit -outform PEM -out data.pem
|
|
||||||
|
|
||||||
Get the private key in hex:
|
|
||||||
openssl ec -in data.pem -outform DER | tail -c 279 | xxd -p -c 279
|
|
||||||
|
|
||||||
Get the public key in hex:
|
|
||||||
openssl ec -in data.pem -pubout -outform DER | tail -c 65 | xxd -p -c 65
|
|
||||||
|
|
||||||
Update the public keys found in chainparams.cpp.
|
|
||||||
|
|
||||||
|
|
||||||
To send an alert message
|
|
||||||
------------------------
|
|
||||||
|
|
||||||
Copy the private keys into alertkeys.h.
|
|
||||||
|
|
||||||
Modify the alert parameters, id and message found in this file.
|
|
||||||
|
|
||||||
Build and run with -sendalert or -printalert.
|
|
||||||
|
|
||||||
./hushd -printtoconsole -sendalert
|
|
||||||
|
|
||||||
One minute after starting up, the alert will be broadcast. It is then
|
|
||||||
flooded through the network until the nRelayUntil time, and will be
|
|
||||||
active until nExpiration OR the alert is cancelled.
|
|
||||||
|
|
||||||
If you make a mistake, send another alert with nCancel set to cancel
|
|
||||||
the bad alert.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Copyright (c) 2016-2022 The Hush developers
|
|
||||||
// Distributed under the GPLv3 software license, see the accompanying
|
|
||||||
// file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html
|
|
||||||
#include "main.h"
|
|
||||||
#include "net.h"
|
|
||||||
#include "alert.h"
|
|
||||||
#include "init.h"
|
|
||||||
#include "util.h"
|
|
||||||
#include "utiltime.h"
|
|
||||||
#include "key.h"
|
|
||||||
#include "clientversion.h"
|
|
||||||
#include "chainparams.h"
|
|
||||||
#include "alertkeys.h"
|
|
||||||
|
|
||||||
static const int64_t DAYS = 24 * 60 * 60;
|
|
||||||
|
|
||||||
void ThreadSendAlert()
|
|
||||||
{
|
|
||||||
if (!mapArgs.count("-sendalert") && !mapArgs.count("-printalert"))
|
|
||||||
return;
|
|
||||||
|
|
||||||
fprintf(stderr,"Sending alerts not supported!\n");
|
|
||||||
return;
|
|
||||||
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user