Skip to content

Commit

Permalink
Merge pull request #2 from zcoinofficial/modulus
Browse files Browse the repository at this point in the history
Modulus
  • Loading branch information
sn-ntu authored May 12, 2018
2 parents defe606 + 88bd9de commit a783599
Show file tree
Hide file tree
Showing 44 changed files with 2,080 additions and 182 deletions.
19 changes: 18 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ AC_PREREQ([2.60])
define(_CLIENT_VERSION_MAJOR, 0)
define(_CLIENT_VERSION_MINOR, 13)
define(_CLIENT_VERSION_REVISION, 5)
define(_CLIENT_VERSION_BUILD, 7)
define(_CLIENT_VERSION_BUILD, 8)
define(_CLIENT_VERSION_IS_RELEASE, true)
define(_COPYRIGHT_YEAR, 2018)
define(_COPYRIGHT_HOLDERS,[The %s developers])
Expand Down Expand Up @@ -197,6 +197,9 @@ AC_ARG_ENABLE([debug],
[enable_debug=$enableval],
[enable_debug=no])

AC_ARG_ENABLE(seccomp,
AS_HELP_STRING(--disable-seccomp, [do not attempt to use libseccomp]))

AC_LANG_PUSH([C++])
AX_CHECK_COMPILE_FLAG([-Werror],[CXXFLAG_WERROR="-Werror"],[CXXFLAG_WERROR=""])

Expand Down Expand Up @@ -888,6 +891,20 @@ fi

fi

dnl ============================================================
dnl Check for libseccomp

if test "x$enable_seccomp" != "xno"; then
AC_CHECK_HEADERS([seccomp.h])
AC_SEARCH_LIBS(seccomp_init, [seccomp])
fi

dnl ============================================================
dnl Check for libcap

AC_CHECK_HEADERS([sys/capability.h])
AC_SEARCH_LIBS(cap_get_proc, [cap])

ac_configure_args="${ac_configure_args} --disable-shared"

AM_CONDITIONAL([EMBEDDED_UNIVALUE],[test x$need_bundled_univalue = xyes])
Expand Down
6 changes: 3 additions & 3 deletions contrib/spendfrom/spendfrom.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ def check_json_precision():
def determine_db_dir():
"""Return the default location of the bitcoin data directory"""
if platform.system() == "Darwin":
return os.path.expanduser("~/Library/Application Support/Bitcoin/")
return os.path.expanduser("~/Library/Application Support/Zcoin/")
elif platform.system() == "Windows":
return os.path.join(os.environ['APPDATA'], "Bitcoin")
return os.path.expanduser("~/.bitcoin")
return os.path.join(os.environ['APPDATA'], "Zcoin")
return os.path.expanduser("~/.zcoin")

def read_bitcoin_config(dbdir):
"""Read the bitcoin.conf file from dbdir, returns dictionary of settings"""
Expand Down
8 changes: 4 additions & 4 deletions share/setup.nsi.in
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ Var StartMenuGroup
# Installer attributes
OutFile @abs_top_srcdir@/@PACKAGE_TARNAME@-${VERSION}-win@WINDOWS_BITS@-setup.exe
!if "@WINDOWS_BITS@" == "64"
InstallDir $PROGRAMFILES64\Bitcoin
InstallDir $PROGRAMFILES64\Zcoin
!else
InstallDir $PROGRAMFILES\Bitcoin
InstallDir $PROGRAMFILES\Zcoin
!endif
CRCCheck on
XPStyle on
Expand Down Expand Up @@ -104,7 +104,7 @@ Section -post SEC0001
WriteRegDWORD HKCU "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" NoModify 1
WriteRegDWORD HKCU "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" NoRepair 1
WriteRegStr HKCR "@PACKAGE_TARNAME@" "URL Protocol" ""
WriteRegStr HKCR "@PACKAGE_TARNAME@" "" "URL:Bitcoin"
WriteRegStr HKCR "@PACKAGE_TARNAME@" "" "URL:Zcoin"
WriteRegStr HKCR "@PACKAGE_TARNAME@\DefaultIcon" "" $INSTDIR\@BITCOIN_GUI_NAME@@EXEEXT@
WriteRegStr HKCR "@PACKAGE_TARNAME@\shell\open\command" "" '"$INSTDIR\@BITCOIN_GUI_NAME@@EXEEXT@" "%1"'
SectionEnd
Expand Down Expand Up @@ -137,7 +137,7 @@ Section -un.post UNSEC0001
Delete /REBOOTOK "$SMPROGRAMS\$StartMenuGroup\Uninstall $(^Name).lnk"
Delete /REBOOTOK "$SMPROGRAMS\$StartMenuGroup\$(^Name).lnk"
Delete /REBOOTOK "$SMPROGRAMS\$StartMenuGroup\@PACKAGE_NAME@ (testnet, @WINDOWS_BITS@-bit).lnk"
Delete /REBOOTOK "$SMSTARTUP\Bitcoin.lnk"
Delete /REBOOTOK "$SMSTARTUP\Zcoin.lnk"
Delete /REBOOTOK $INSTDIR\uninstall.exe
Delete /REBOOTOK $INSTDIR\debug.log
Delete /REBOOTOK $INSTDIR\db.log
Expand Down
2 changes: 2 additions & 0 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ endif
# bitcoin core #
BITCOIN_CORE_H = \
activeznode.h \
addressindex.h \
spentindex.h \
addrman.h \
base58.h \
bloom.h \
Expand Down
82 changes: 82 additions & 0 deletions src/addressindex.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2015 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#ifndef BITCOIN_ADDRESSINDEX_H
#define BITCOIN_ADDRESSINDEX_H

#include "uint256.h"
#include "amount.h"

struct CMempoolAddressDelta
{
int64_t time;
CAmount amount;
uint256 prevhash;
unsigned int prevout;

CMempoolAddressDelta(int64_t t, CAmount a, uint256 hash, unsigned int out) {
time = t;
amount = a;
prevhash = hash;
prevout = out;
}

CMempoolAddressDelta(int64_t t, CAmount a) {
time = t;
amount = a;
prevhash.SetNull();
prevout = 0;
}
};

struct CMempoolAddressDeltaKey
{
int type;
uint160 addressBytes;
uint256 txhash;
unsigned int index;
int spending;

CMempoolAddressDeltaKey(int addressType, uint160 addressHash, uint256 hash, unsigned int i, int s) {
type = addressType;
addressBytes = addressHash;
txhash = hash;
index = i;
spending = s;
}

CMempoolAddressDeltaKey(int addressType, uint160 addressHash) {
type = addressType;
addressBytes = addressHash;
txhash.SetNull();
index = 0;
spending = 0;
}
};

struct CMempoolAddressDeltaKeyCompare
{
bool operator()(const CMempoolAddressDeltaKey& a, const CMempoolAddressDeltaKey& b) const {
if (a.type == b.type) {
if (a.addressBytes == b.addressBytes) {
if (a.txhash == b.txhash) {
if (a.index == b.index) {
return a.spending < b.spending;
} else {
return a.index < b.index;
}
} else {
return a.txhash < b.txhash;
}
} else {
return a.addressBytes < b.addressBytes;
}
} else {
return a.type < b.type;
}
}
};

#endif // BITCOIN_ADDRESSINDEX_H
18 changes: 18 additions & 0 deletions src/base58.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,24 @@ CTxDestination CBitcoinAddress::Get() const
return CNoDestination();
}


bool CBitcoinAddress::GetIndexKey(uint160& hashBytes, int& type) const
{
if (!IsValid()) {
return false;
} else if (vchVersion == Params().Base58Prefix(CChainParams::PUBKEY_ADDRESS)) {
memcpy(&hashBytes, &vchData[0], 20);
type = 1;
return true;
} else if (vchVersion == Params().Base58Prefix(CChainParams::SCRIPT_ADDRESS)) {
memcpy(&hashBytes, &vchData[0], 20);
type = 2;
return true;
}

return false;
}

bool CBitcoinAddress::GetKeyID(CKeyID& keyID) const
{
if (!IsValid() || vchVersion != Params().Base58Prefix(CChainParams::PUBKEY_ADDRESS))
Expand Down
1 change: 1 addition & 0 deletions src/base58.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ class CBitcoinAddress : public CBase58Data {
CBitcoinAddress(const char* pszAddress) { SetString(pszAddress); }

CTxDestination Get() const;
bool GetIndexKey(uint160& hashBytes, int& type) const;
bool GetKeyID(CKeyID &keyID) const;
bool IsScript() const;
};
Expand Down
7 changes: 5 additions & 2 deletions src/chain.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,9 @@ class CBlockIndex
//! Maps <denomination, id> to <accumulator value (CBigNum), number of such mints in this block>
map<pair<int,int>, pair<CBigNum,int>> accumulatorChanges;

//! Same as accumulatorChanges but for alternative modulus
map<pair<int,int>, pair<CBigNum,int>> alternativeAccumulatorChanges;

//! Values of coin serials spent in this block
set<CBigNum> spentSerials;

Expand Down Expand Up @@ -293,9 +296,9 @@ class CBlockIndex
return *phashBlock;
}

uint256 GetBlockPoWHash() const
uint256 GetBlockPoWHash(bool forceCalc = false) const
{
return GetBlockHeader().GetPoWHash(nHeight);
return GetBlockHeader().GetPoWHash(nHeight, forceCalc);
}

int64_t GetBlockTime() const
Expand Down
30 changes: 30 additions & 0 deletions src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "chainparams.h"
#include "consensus/merkle.h"
#include "consensus/consensus.h"
#include "zerocoin_params.h"

#include "tinyformat.h"
#include "util.h"
Expand Down Expand Up @@ -199,6 +200,16 @@ class CMainParams : public CChainParams {
// (the tx=... number in the SetBestChain debug.log lines)
1200.0 // * estimated number of transactions per day after checkpoint
};

nSpendV15StartBlock = ZC_V1_5_STARTING_BLOCK;
nSpendV2ID_1 = ZC_V2_SWITCH_ID_1;
nSpendV2ID_10 = ZC_V2_SWITCH_ID_10;
nSpendV2ID_25 = ZC_V2_SWITCH_ID_25;
nSpendV2ID_50 = ZC_V2_SWITCH_ID_50;
nSpendV2ID_100 = ZC_V2_SWITCH_ID_100;
nModulusV2StartBlock = ZC_MODULUS_V2_START_BLOCK;
nModulusV1MempoolStopBlock = ZC_MODULUS_V1_MEMPOOL_STOP_BLOCK;
nModulusV1StopBlock = ZC_MODULUS_V1_STOP_BLOCK;
}
};

Expand Down Expand Up @@ -317,6 +328,15 @@ class CTestNetParams : public CChainParams {
100.0
};

nSpendV15StartBlock = ZC_V1_5_TESTNET_STARTING_BLOCK;
nSpendV2ID_1 = ZC_V2_TESTNET_SWITCH_ID_1;
nSpendV2ID_10 = ZC_V2_TESTNET_SWITCH_ID_10;
nSpendV2ID_25 = ZC_V2_TESTNET_SWITCH_ID_25;
nSpendV2ID_50 = ZC_V2_TESTNET_SWITCH_ID_50;
nSpendV2ID_100 = ZC_V2_TESTNET_SWITCH_ID_100;
nModulusV2StartBlock = ZC_MODULUS_V2_TESTNET_START_BLOCK;
nModulusV1MempoolStopBlock = ZC_MODULUS_V1_TESTNET_MEMPOOL_STOP_BLOCK;
nModulusV1StopBlock = ZC_MODULUS_V1_TESTNET_STOP_BLOCK;
}
};

Expand Down Expand Up @@ -407,6 +427,16 @@ class CRegTestParams : public CChainParams {
base58Prefixes[SECRET_KEY] = std::vector < unsigned char > (1, 239);
base58Prefixes[EXT_PUBLIC_KEY] = boost::assign::list_of(0x04)(0x35)(0x87)(0xCF).convert_to_container < std::vector < unsigned char > > ();
base58Prefixes[EXT_SECRET_KEY] = boost::assign::list_of(0x04)(0x35)(0x83)(0x94).convert_to_container < std::vector < unsigned char > > ();

nSpendV15StartBlock = ZC_V1_5_TESTNET_STARTING_BLOCK;
nSpendV2ID_1 = ZC_V2_TESTNET_SWITCH_ID_1;
nSpendV2ID_10 = ZC_V2_TESTNET_SWITCH_ID_10;
nSpendV2ID_25 = ZC_V2_TESTNET_SWITCH_ID_25;
nSpendV2ID_50 = ZC_V2_TESTNET_SWITCH_ID_50;
nSpendV2ID_100 = ZC_V2_TESTNET_SWITCH_ID_100;
nModulusV2StartBlock = ZC_MODULUS_V2_TESTNET_START_BLOCK;
nModulusV1MempoolStopBlock = ZC_MODULUS_V1_TESTNET_MEMPOOL_STOP_BLOCK;
nModulusV1StopBlock = ZC_MODULUS_V1_TESTNET_STOP_BLOCK;
}

void UpdateBIP9Parameters(Consensus::DeploymentPos d, int64_t nStartTime, int64_t nTimeout) {
Expand Down
10 changes: 10 additions & 0 deletions src/chainparams.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,15 @@ class CChainParams
int FulfilledRequestExpireTime() const { return nFulfilledRequestExpireTime; }
std::string SporkPubKey() const { return strSporkPubKey; }
std::string ZnodePaymentPubKey() const { return strZnodePaymentsPubKey; }

/** Zerocoin-related block numbers when features are changed */
int nSpendV15StartBlock;
int nSpendV2ID_1, nSpendV2ID_10, nSpendV2ID_25, nSpendV2ID_50, nSpendV2ID_100;

int nModulusV2StartBlock;
int nModulusV1MempoolStopBlock;
int nModulusV1StopBlock;

protected:
CChainParams() {}

Expand All @@ -99,6 +108,7 @@ class CChainParams
bool fMineBlocksOnDemand;
bool fTestnetToBeDeprecatedFieldRPC;
CCheckpointData checkpointData;

/** znode params*/
long nMaxTipAge;
int nPoolMaxTransactions;
Expand Down
2 changes: 1 addition & 1 deletion src/clientversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#define CLIENT_VERSION_MAJOR 0
#define CLIENT_VERSION_MINOR 13
#define CLIENT_VERSION_REVISION 5
#define CLIENT_VERSION_BUILD 7
#define CLIENT_VERSION_BUILD 8

//! Set to true for release, false for prerelease or test build
#define CLIENT_VERSION_IS_RELEASE true
Expand Down
32 changes: 18 additions & 14 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,9 @@ std::string HelpMessage(HelpMessageMode mode) {
strUsage += HelpMessageOpt("-txindex", strprintf(
_("Maintain a full transaction index, used by the getrawtransaction rpc call (default: %u)"),
DEFAULT_TXINDEX));
strUsage += HelpMessageOpt("-addressindex", strprintf(_("Maintain a full address index, used to query for the balance, txids and unspent outputs for addresses (default: %u)"), DEFAULT_ADDRESSINDEX));
strUsage += HelpMessageOpt("-timestampindex", strprintf(_("Maintain a timestamp index for block hashes, used to query blocks hashes by a range of timestamps (default: %u)"), DEFAULT_TIMESTAMPINDEX));
strUsage += HelpMessageOpt("-spentindex", strprintf(_("Maintain a full spent index, used to query the spending txid and input index for an outpoint (default: %u)"), DEFAULT_SPENTINDEX));

strUsage += HelpMessageGroup(_("Connection options:"));
strUsage += HelpMessageOpt("-addnode=<ip>", _("Add a node to connect to and attempt to keep the connection open"));
Expand Down Expand Up @@ -1882,32 +1885,33 @@ bool AppInit2(boost::thread_group &threadGroup, CScheduler &scheduler) {
}
}


nLiquidityProvider = GetArg("-liquidityprovider", nLiquidityProvider);
nLiquidityProvider = std::min(std::max(nLiquidityProvider, 0), 100);
darkSendPool.SetMinBlockSpacing(nLiquidityProvider * 15);

fEnablePrivateSend = GetBoolArg("-enableprivatesend", 0);
fPrivateSendMultiSession = GetBoolArg("-privatesendmultisession", DEFAULT_PRIVATESEND_MULTISESSION);
nPrivateSendRounds = GetArg("-privatesendrounds", DEFAULT_PRIVATESEND_ROUNDS);
nPrivateSendRounds = std::min(std::max(nPrivateSendRounds, 2), nLiquidityProvider ? 99999 : 16);
nPrivateSendAmount = GetArg("-privatesendamount", DEFAULT_PRIVATESEND_AMOUNT);
nPrivateSendAmount = std::min(std::max(nPrivateSendAmount, 2), 999999);
fEnablePrivateSend = false;
// fEnablePrivateSend = GetBoolArg("-enableprivatesend", 0);
// fPrivateSendMultiSession = GetBoolArg("-privatesendmultisession", DEFAULT_PRIVATESEND_MULTISESSION);
// nPrivateSendRounds = GetArg("-privatesendrounds", DEFAULT_PRIVATESEND_ROUNDS);
// nPrivateSendRounds = std::min(std::max(nPrivateSendRounds, 2), nLiquidityProvider ? 99999 : 16);
// nPrivateSendAmount = GetArg("-privatesendamount", DEFAULT_PRIVATESEND_AMOUNT);
// nPrivateSendAmount = std::min(std::max(nPrivateSendAmount, 2), 999999);

fEnableInstantSend = GetBoolArg("-enableinstantsend", 1);
nInstantSendDepth = GetArg("-instantsenddepth", DEFAULT_INSTANTSEND_DEPTH);
nInstantSendDepth = std::min(std::max(nInstantSendDepth, 0), 60);
fEnableInstantSend = false;
// fEnableInstantSend = GetBoolArg("-enableinstantsend", 1);
// nInstantSendDepth = GetArg("-instantsenddepth", DEFAULT_INSTANTSEND_DEPTH);
// nInstantSendDepth = std::min(std::max(nInstantSendDepth, 0), 60);

//lite mode disables all Znode and Darksend related functionality
// lite mode disables all Znode and Darksend related functionality
fLiteMode = GetBoolArg("-litemode", false);
if (fZNode && fLiteMode) {
return InitError("You can not start a znode in litemode");
}

LogPrintf("fLiteMode %d\n", fLiteMode);
LogPrintf("nInstantSendDepth %d\n", nInstantSendDepth);
LogPrintf("PrivateSend rounds %d\n", nPrivateSendRounds);
LogPrintf("PrivateSend amount %d\n", nPrivateSendAmount);
// LogPrintf("nInstantSendDepth %d\n", nInstantSendDepth);
// LogPrintf("PrivateSend rounds %d\n", nPrivateSendRounds);
// LogPrintf("PrivateSend amount %d\n", nPrivateSendAmount);

darkSendPool.InitDenominations();

Expand Down
2 changes: 1 addition & 1 deletion src/libzerocoin/Accumulator.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ class AccumulatorWitness {
AccumulatorWitness& operator +=(const PublicCoin& rhs);
private:
const Params* params;
Accumulator witness;
Accumulator witness;
const PublicCoin element;
};

Expand Down
Loading

0 comments on commit a783599

Please sign in to comment.