Skip to content

Commit

Permalink
Netbox.Wallet v3.4.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
NetboxGlobal-Team committed Jun 16, 2020
1 parent d6db983 commit 734e0a2
Show file tree
Hide file tree
Showing 17 changed files with 68 additions and 55 deletions.
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ dnl require autoconf 2.60 (AS_ECHO/AS_ECHO_N)
AC_PREREQ([2.60])
define(_CLIENT_VERSION_MAJOR, 3)
define(_CLIENT_VERSION_MINOR, 4)
define(_CLIENT_VERSION_BUILD, 2)
define(_CLIENT_VERSION_BUILD, 3)
define(_CLIENT_VERSION_REVISION, 0)
define(_CLIENT_VERSION_IS_RELEASE, true)
define(_COPYRIGHT_YEAR, 2020)
Expand Down
2 changes: 0 additions & 2 deletions contrib/debian/netboxwallet.desktop
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
Encoding=UTF-8
Name=Netbox.Wallet
Comment=Netbox.Wallet P2P Cryptocurrency
Comment[fr]=Netbox.Wallet, monnaie virtuelle cryptographique pair à pair
Comment[tr]=Netbox.Wallet, eşten eşe kriptografik sanal para birimi
Exec=netboxwallet %u
Terminal=false
Type=Application
Expand Down
6 changes: 5 additions & 1 deletion doc/man/nbxd.1
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,11 @@ Automatically create Tor hidden service (default: 1)
.HP
\fB\-maxconnections=\fR<n>
.IP
Maintain at most <n> connections to peers (default: 125)
Maintain at most <n> connections to peers (default: 250)
.HP
\fB\-maxoutboundconnections=\fR<n>
.IP
Maintain at most <n> outbound connections to peers (default: 12)
.HP
\fB\-maxreceivebuffer=\fR<n>
.IP
Expand Down
6 changes: 5 additions & 1 deletion doc/man/netboxwallet.1
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,11 @@ Automatically create Tor hidden service (default: 1)
.HP
\fB\-maxconnections=\fR<n>
.IP
Maintain at most <n> connections to peers (default: 125)
Maintain at most <n> connections to peers (default: 250)
.HP
\fB\-maxoutboundconnections=\fR<n>
.IP
Maintain at most <n> outbound connections to peers (default: 12)
.HP
\fB\-maxreceivebuffer=\fR<n>
.IP
Expand Down
10 changes: 7 additions & 3 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,8 @@ std::string HelpMessage(HelpMessageMode mode)
strUsage += HelpMessageOpt("-forcednsseed", strprintf(_("Always query for peer addresses via DNS lookup (default: %u)"), 0));
strUsage += HelpMessageOpt("-listen", _("Accept connections from outside (default: 1 if no -proxy or -connect)"));
strUsage += HelpMessageOpt("-listenonion", strprintf(_("Automatically create Tor hidden service (default: %d)"), DEFAULT_LISTEN_ONION));
strUsage += HelpMessageOpt("-maxconnections=<n>", strprintf(_("Maintain at most <n> connections to peers (default: %u)"), 125));
strUsage += HelpMessageOpt("-maxconnections=<n>", strprintf(_("Maintain at most <n> connections to peers (default: %u)"), 250));
strUsage += HelpMessageOpt("-maxoutboundconnections=<n>", strprintf(_("Maintain at most <n> outbound connections to peers (default: %u)"), 12));
strUsage += HelpMessageOpt("-maxreceivebuffer=<n>", strprintf(_("Maximum per-connection receive buffer, <n>*1000 bytes (default: %u)"), 5000));
strUsage += HelpMessageOpt("-maxsendbuffer=<n>", strprintf(_("Maximum per-connection send buffer, <n>*1000 bytes (default: %u)"), 1000));
strUsage += HelpMessageOpt("-onion=<ip:port>", strprintf(_("Use separate SOCKS5 proxy to reach peers via Tor hidden services (default: %s)"), "-proxy"));
Expand Down Expand Up @@ -898,14 +899,17 @@ bool AppInit2()

// Make sure enough file descriptors are available
int nBind = std::max((int)mapArgs.count("-bind") + (int)mapArgs.count("-whitebind"), 1);
nMaxConnections = GetArg("-maxconnections", 125);
nMaxConnections = GetArg("-maxconnections", 250);
nMaxConnections = std::max(std::min(nMaxConnections, (int)(FD_SETSIZE - nBind - MIN_CORE_FILEDESCRIPTORS)), 0);
int nFD = RaiseFileDescriptorLimit(nMaxConnections + MIN_CORE_FILEDESCRIPTORS);
if (nFD < MIN_CORE_FILEDESCRIPTORS)
return InitError(_("Not enough file descriptors available."));
if (nFD - MIN_CORE_FILEDESCRIPTORS < nMaxConnections)
nMaxConnections = nFD - MIN_CORE_FILEDESCRIPTORS;

nMaxOutboundConnections = GetArg("-maxoutboundconnections", 12);
nMaxOutboundConnections = std::min(std::max(MIN_OUTBOUND_CONNECTIONS, nMaxOutboundConnections), nMaxConnections);

// ********************************************************* Step 3: parameter-to-internal-flags

fDebug = !mapMultiArgs["-debug"].empty();
Expand Down Expand Up @@ -1070,7 +1074,7 @@ bool AppInit2()
LogPrintf("Default data directory %s\n", GetDefaultDataDir().string());
LogPrintf("Using data directory %s\n", strDataDir);
LogPrintf("Using config file %s\n", GetConfigFile().string());
LogPrintf("Using at most %i connections (%i file descriptors available)\n", nMaxConnections, nFD);
LogPrintf("Using at most %i connections (%i file descriptors available, max %i outbound connections)\n", nMaxConnections, nFD, nMaxOutboundConnections);
std::ostringstream strErrors;

LogPrintf("Using %u threads for script verification\n", nScriptCheckThreads);
Expand Down
18 changes: 9 additions & 9 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,7 @@ bool IsStandardTx(const CTransaction& tx, std::string& reason)
{
AssertLockHeld(cs_main);
if (tx.nVersion > CTransaction::CURRENT_VERSION || tx.nVersion < 1) {
reason = "version";
reason = "Wrong transaction version";
return false;
}

Expand All @@ -715,7 +715,7 @@ bool IsStandardTx(const CTransaction& tx, std::string& reason)
// can't know what timestamp the next block will have, and there aren't
// timestamp applications where it matters.
if (!IsFinalTx(tx, chainActive.Height() + 1)) {
reason = "non-final";
reason = "Transaction is not final";
return false;
}

Expand All @@ -726,7 +726,7 @@ bool IsStandardTx(const CTransaction& tx, std::string& reason)
unsigned int sz = tx.GetSerializeSize(SER_NETWORK, CTransaction::CURRENT_VERSION);
unsigned int nMaxSize = MAX_STANDARD_TX_SIZE;
if (sz >= nMaxSize) {
reason = "tx-size";
reason = "Transaction size is too large";
return false;
}

Expand All @@ -739,11 +739,11 @@ bool IsStandardTx(const CTransaction& tx, std::string& reason)
// CHECKMULTISIG scriptPubKey, though such a scriptPubKey is not
// considered standard)
if (txin.scriptSig.size() > 1650) {
reason = "scriptsig-size";
reason = "Wrong ScriptSig size";
return false;
}
if (!txin.scriptSig.IsPushOnly()) {
reason = "scriptsig-not-pushonly";
reason = "ScriptSig is not pushonly";
return false;
}
}
Expand All @@ -752,24 +752,24 @@ bool IsStandardTx(const CTransaction& tx, std::string& reason)
txnouttype whichType;
for (const CTxOut& txout : tx.vout) {
if (!::IsStandard(txout.scriptPubKey, whichType)) {
reason = "scriptpubkey";
reason = "Wrong ScriptPubKey";
return false;
}

if (whichType == TX_NULL_DATA)
nDataOut++;
else if ((whichType == TX_MULTISIG) && (!fIsBareMultisigStd)) {
reason = "bare-multisig";
reason = "Bare Multisig";
return false;
} else if (txout.IsDust(::minRelayTxFee)) {
reason = "dust";
reason = "Transaction output amount is too low (considered as dust)";
return false;
}
}

// only one OP_RETURN txout is permitted
if (nDataOut > 1) {
reason = "multi-op-return";
reason = "Too many nulldata outputs";
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/nbxd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Copyright (c) 2009-2014 The Bitcoin developers
// Copyright (c) 2014-2015 The Dash developers
// Copyright (c) 2015-2019 The PIVX developers
// Copyright (c) 2018-2019 Netbox.Global
// Copyright (c) 2018-2020 Netbox.Global
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

Expand Down
25 changes: 8 additions & 17 deletions src/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@

namespace
{
const int MAX_OUTBOUND_CONNECTIONS = 16;

struct ListenSocket {
SOCKET socket;
Expand All @@ -81,7 +80,8 @@ static CNode* pnodeLocalHost = NULL;
uint64_t nLocalHostNonce = 0;
static std::vector<ListenSocket> vhListenSocket;
CAddrMan addrman;
int nMaxConnections = 125;
int nMaxConnections = 250;
int nMaxOutboundConnections = 12;
bool fAddressesInitialized = false;
std::string strSubVersion;

Expand All @@ -95,9 +95,6 @@ limitedmap<CInv, int64_t> mapAlreadyAskedFor(MAX_INV_SZ);
static std::deque<std::string> vOneShots;
CCriticalSection cs_vOneShots;

std::set<CNetAddr> setservAddNodeAddresses;
CCriticalSection cs_setservAddNodeAddresses;

std::vector<std::string> vAddedNodes;
CCriticalSection cs_vAddedNodes;

Expand Down Expand Up @@ -1006,7 +1003,7 @@ void ThreadSocketHandler()
} else if (!IsSelectableSocket(hSocket)) {
LogPrintf("connection from %s dropped: non-selectable socket\n", addr.ToString());
CloseSocket(hSocket);
} else if (nInbound >= nMaxConnections - MAX_OUTBOUND_CONNECTIONS) {
} else if (nInbound >= nMaxConnections - nMaxOutboundConnections) {
LogPrint("net", "connection from %s dropped (full)\n", addr.ToString());
CloseSocket(hSocket);
} else if (CNode::IsBanned(addr) && !whitelisted) {
Expand Down Expand Up @@ -1432,14 +1429,8 @@ void ThreadOpenAddedConnections()
std::list<std::vector<CService> > lservAddressesToAdd(0);
for (std::string& strAddNode : lAddresses) {
std::vector<CService> vservNode(0);
if (Lookup(strAddNode.c_str(), vservNode, Params().GetDefaultPort(), fNameLookup, 0)) {
if (Lookup(strAddNode.c_str(), vservNode, Params().GetDefaultPort(), fNameLookup, 0))
lservAddressesToAdd.push_back(vservNode);
{
LOCK(cs_setservAddNodeAddresses);
for (CService& serv : vservNode)
setservAddNodeAddresses.insert(serv);
}
}
}
// Attempt to connect to each IP for each addnode entry until at least one is successful per addnode entry
// (keeping in mind that addnode entries can have many IPs if fNameLookup)
Expand All @@ -1455,8 +1446,9 @@ void ThreadOpenAddedConnections()
}
}
for (std::vector<CService>& vserv : lservAddressesToAdd) {
CAddress addr;
CSemaphoreGrant grant(*semOutbound);
OpenNetworkConnection(CAddress(vserv[i % vserv.size()]), &grant);
OpenNetworkConnection(addr, &grant, vserv[i % vserv.size()].ToStringIPPort().c_str());
MilliSleep(500);
}
MilliSleep(120000); // Retry every 2 minutes
Expand Down Expand Up @@ -1719,8 +1711,7 @@ void StartNode(boost::thread_group& threadGroup, CScheduler& scheduler)

if (semOutbound == NULL) {
// initialize semaphore
int nMaxOutbound = std::min(MAX_OUTBOUND_CONNECTIONS, nMaxConnections);
semOutbound = new CSemaphore(nMaxOutbound);
semOutbound = new CSemaphore(nMaxOutboundConnections);
}

if (pnodeLocalHost == NULL)
Expand Down Expand Up @@ -1761,7 +1752,7 @@ bool StopNode()
LogPrintf("StopNode()\n");
MapPort(false);
if (semOutbound)
for (int i = 0; i < MAX_OUTBOUND_CONNECTIONS; i++)
for (int i = 0; i < nMaxOutboundConnections; i++)
semOutbound->post();

if (fAddressesInitialized) {
Expand Down
5 changes: 4 additions & 1 deletion src/net.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2014 The Bitcoin developers
// Copyright (c) 2015-2019 The PIVX developers
// Copyright (c) 2018-2019 Netbox.Global
// Copyright (c) 2018-2020 Netbox.Global
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

Expand Down Expand Up @@ -64,6 +64,8 @@ static const bool DEFAULT_UPNP = true;
/** The maximum number of entries in mapAskFor */
static const size_t MAPASKFOR_MAX_SZ = MAX_INV_SZ;

static const int MIN_OUTBOUND_CONNECTIONS = 12;

unsigned int ReceiveFloodSize();
unsigned int SendBufferSize();

Expand Down Expand Up @@ -130,6 +132,7 @@ extern uint64_t nLocalServices;
extern uint64_t nLocalHostNonce;
extern CAddrMan addrman;
extern int nMaxConnections;
extern int nMaxOutboundConnections;

extern std::vector<CNode*> vNodes;
extern CCriticalSection cs_vNodes;
Expand Down
2 changes: 1 addition & 1 deletion src/qt/bitcoingui.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) 2011-2014 The Bitcoin developers
// Copyright (c) 2014-2015 The Dash developers
// Copyright (c) 2015-2019 The PIVX developers
// Copyright (c) 2018-2019 Netbox.Global
// Copyright (c) 2018-2020 Netbox.Global
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

Expand Down
9 changes: 4 additions & 5 deletions src/qt/netboxwallet.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) 2009-2014 The Bitcoin developers
// Copyright (c) 2014-2015 The Dash developers
// Copyright (c) 2015-2019 The PIVX developers
// Copyright (c) 2018-2019 Netbox.Global
// Copyright (c) 2018-2020 Netbox.Global
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

Expand Down Expand Up @@ -689,10 +689,6 @@ int main(int argc, char* argv[])
return 1;
}

#ifdef WIN32
AllowSetForegroundWindow(ASFW_ANY);
#endif

#ifdef ENABLE_WALLET
// Parse URIs on command line -- this can affect Params()
PaymentServer::ipcParseCommandLine(argc, argv);
Expand Down Expand Up @@ -724,6 +720,9 @@ int main(int argc, char* argv[])
exit(0);

// try to show another already running instance
#ifdef WIN32
AllowSetForegroundWindow(ReadPidFile(GetPidFile()) ?: ASFW_ANY);
#endif
if (PaymentServer::ipcSendCommand("nbx:show"))
exit(0);

Expand Down
2 changes: 1 addition & 1 deletion src/qt/paymentserver.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) 2011-2014 The Bitcoin developers
// Copyright (c) 2014-2015 The Dash developers
// Copyright (c) 2015-2019 The PIVX developers
// Copyright (c) 2018-2019 Netbox.Global
// Copyright (c) 2018-2020 Netbox.Global
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

Expand Down
2 changes: 1 addition & 1 deletion src/qt/paymentserver.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright (c) 2011-2014 The Bitcoin developers
// Copyright (c) 2018-2019 Netbox.Global
// Copyright (c) 2018-2020 Netbox.Global
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

Expand Down
1 change: 1 addition & 0 deletions src/qt/peertablemodel.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Copyright (c) 2011-2013 The Bitcoin developers
// Copyright (c) 2017-2019 The PIVX developers
// Copyright (c) 2020 Netbox.Global
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

Expand Down
2 changes: 1 addition & 1 deletion src/rpc/rawtransaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ UniValue listunspent(const UniValue& params, bool fHelp)
std::vector<COutput> vecOutputs;
assert(pwalletMain != NULL);
LOCK2(cs_main, pwalletMain->cs_wallet);
pwalletMain->AvailableCoins(vecOutputs, false, NULL, false, ALL_COINS, false);
pwalletMain->AvailableCoins(vecOutputs, false, NULL, true, ALL_COINS, false);
for (const COutput& out : vecOutputs) {
if (out.nDepth < nMinDepth || out.nDepth > nMaxDepth)
continue;
Expand Down
11 changes: 7 additions & 4 deletions src/wallet/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -961,16 +961,19 @@ bool CWallet::IsUsed(const CBitcoinAddress address) const
return false;
}

CAmount CWallet::GetDebit(const CTxIn& txin) const
CAmount CWallet::GetDebit(const CTxIn& txin, bool *fIsMine) const
{
{
LOCK(cs_wallet);
std::map<uint256, CWalletTx>::const_iterator mi = mapWallet.find(txin.prevout.hash);
if (mi != mapWallet.end()) {
const CWalletTx& prev = (*mi).second;
if (txin.prevout.n < prev.vout.size())
if (IsMine(prev.vout[txin.prevout.n]))
if (IsMine(prev.vout[txin.prevout.n])) {
if (fIsMine)
*fIsMine = true;
return prev.vout[txin.prevout.n].nValue;
}
}
}
return 0;
Expand Down Expand Up @@ -1102,7 +1105,7 @@ int CWalletTx::GetRequestCount() const
return nRequests;
}

CAmount CWalletTx::GetDebit() const
CAmount CWalletTx::GetDebit(bool *fIsMine) const
{
if (vin.empty())
return 0;
Expand All @@ -1111,7 +1114,7 @@ CAmount CWalletTx::GetDebit() const
if (fDebitCached)
debit += nDebitCached;
else {
nDebitCached = pwallet->GetDebit(*this);
nDebitCached = pwallet->GetDebit(*this, fIsMine);
fDebitCached = true;
debit += nDebitCached;
}
Expand Down
Loading

0 comments on commit 734e0a2

Please sign in to comment.