Skip to content

Commit

Permalink
Merge pull request bitcoin#5 from Peerunity/pending_pr_merge
Browse files Browse the repository at this point in the history
Merge of relevant pending peercoin pull requests
  • Loading branch information
sigmike committed Apr 12, 2014
2 parents aa527d3 + 0f46de3 commit 0dc2b71
Show file tree
Hide file tree
Showing 18 changed files with 2,275 additions and 40 deletions.
6 changes: 3 additions & 3 deletions contrib/gitian-descriptors/deps-win32.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ packages:
reference_datetime: "2011-01-30 00:00:00"
remotes: []
files:
- "openssl-1.0.1b.tar.gz"
- "openssl-1.0.1g.tar.gz"
- "db-4.8.30.NC.tar.gz"
- "miniupnpc-1.6.tar.gz"
- "zlib-1.2.7.tar.gz"
Expand All @@ -25,8 +25,8 @@ script: |
export FAKETIME=$REFERENCE_DATETIME
export TZ=UTC
#
tar xzf openssl-1.0.1b.tar.gz
cd openssl-1.0.1b
tar xzf openssl-1.0.1g.tar.gz
cd openssl-1.0.1g
./Configure --cross-compile-prefix=i586-mingw32msvc- mingw
make
cd ..
Expand Down
2 changes: 1 addition & 1 deletion contrib/gitian-descriptors/gitian-win32.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ script: |
export LD_PRELOAD=/usr/lib/faketime/libfaketime.so.1
export FAKETIME=$REFERENCE_DATETIME
export TZ=UTC
$HOME/qt/src/bin/qmake -spec unsupported/win32-g++-cross MINIUPNPC_LIB_PATH=$HOME/build/miniupnpc MINIUPNPC_INCLUDE_PATH=$HOME/build/ BDB_LIB_PATH=$HOME/build/db-4.8.30.NC/build_unix BDB_INCLUDE_PATH=$HOME/build/db-4.8.30.NC/build_unix BOOST_LIB_PATH=$HOME/build/boost_1_47_0/stage/lib BOOST_INCLUDE_PATH=$HOME/build/boost_1_47_0 BOOST_LIB_SUFFIX=-mt-s BOOST_THREAD_LIB_SUFFIX=_win32-mt-s OPENSSL_LIB_PATH=$HOME/build/openssl-1.0.1b OPENSSL_INCLUDE_PATH=$HOME/build/openssl-1.0.1b/include QRENCODE_LIB_PATH=$HOME/build/qrencode-3.2.0/.libs QRENCODE_INCLUDE_PATH=$HOME/build/qrencode-3.2.0 USE_QRCODE=1 INCLUDEPATH=$HOME/build DEFINES=BOOST_THREAD_USE_LIB BITCOIN_NEED_QT_PLUGINS=1 QMAKE_LRELEASE=lrelease QMAKE_CXXFLAGS=-frandom-seed=ppcoin QMAKE_LFLAGS=-frandom-seed=ppcoin USE_BUILD_INFO=1
$HOME/qt/src/bin/qmake -spec unsupported/win32-g++-cross MINIUPNPC_LIB_PATH=$HOME/build/miniupnpc MINIUPNPC_INCLUDE_PATH=$HOME/build/ BDB_LIB_PATH=$HOME/build/db-4.8.30.NC/build_unix BDB_INCLUDE_PATH=$HOME/build/db-4.8.30.NC/build_unix BOOST_LIB_PATH=$HOME/build/boost_1_47_0/stage/lib BOOST_INCLUDE_PATH=$HOME/build/boost_1_47_0 BOOST_LIB_SUFFIX=-mt-s BOOST_THREAD_LIB_SUFFIX=_win32-mt-s OPENSSL_LIB_PATH=$HOME/build/openssl-1.0.1g OPENSSL_INCLUDE_PATH=$HOME/build/openssl-1.0.1g/include QRENCODE_LIB_PATH=$HOME/build/qrencode-3.2.0/.libs QRENCODE_INCLUDE_PATH=$HOME/build/qrencode-3.2.0 USE_QRCODE=1 INCLUDEPATH=$HOME/build DEFINES=BOOST_THREAD_USE_LIB BITCOIN_NEED_QT_PLUGINS=1 QMAKE_LRELEASE=lrelease QMAKE_CXXFLAGS=-frandom-seed=ppcoin QMAKE_LFLAGS=-frandom-seed=ppcoin USE_BUILD_INFO=1
make $MAKEOPTS
cp release/ppcoin-qt.exe $OUTDIR/
#
Expand Down
6 changes: 3 additions & 3 deletions doc/build-msw.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Dependencies
Libraries you need to download separately and build:

default path download
OpenSSL \openssl-1.0.1b-mgw http://www.openssl.org/source/
OpenSSL \openssl-1.0.1g-mgw http://www.openssl.org/source/
Berkeley DB \db-4.8.30.NC-mgw http://www.oracle.com/technology/software/products/berkeley-db/index.html
Boost \boost-1.47.0-mgw http://www.boost.org/users/download/
miniupnpc \miniupnpc-1.6-mgw http://miniupnp.tuxfamily.org/files/
Expand All @@ -36,7 +36,7 @@ Boost MIT-like license
miniupnpc New (3-clause) BSD license

Versions used in this release:
OpenSSL 1.0.1b
OpenSSL 1.0.1g
Berkeley DB 4.8.30.NC
Boost 1.47.0
miniupnpc 1.6
Expand All @@ -48,7 +48,7 @@ MSYS shell:
un-tar sources with MSYS 'tar xfz' to avoid issue with symlinks (OpenSSL ticket 2377)
change 'MAKE' env. variable from 'C:\MinGW32\bin\mingw32-make.exe' to '/c/MinGW32/bin/mingw32-make.exe'

cd /c/openssl-1.0.1b-mgw
cd /c/openssl-1.0.1g-mgw
./config
make

Expand Down
2 changes: 1 addition & 1 deletion doc/build-unix.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Licenses of statically linked libraries:

Versions used in this release:
GCC 4.3.3
OpenSSL 0.9.8g
OpenSSL 1.0.1g
Berkeley DB 4.8.30.NC
Boost 1.37
miniupnpc 1.6
Expand Down
2 changes: 1 addition & 1 deletion doc/release-process.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* Fetch and build inputs:
mkdir -p inputs; cd inputs/
wget 'http://miniupnp.free.fr/files/download.php?file=miniupnpc-1.6.tar.gz' -O miniupnpc-1.6.tar.gz
wget 'http://www.openssl.org/source/openssl-1.0.1b.tar.gz'
wget 'http://www.openssl.org/source/openssl-1.0.1g.tar.gz'
wget 'http://download.oracle.com/berkeley-db/db-4.8.30.NC.tar.gz'
wget 'http://zlib.net/zlib-1.2.6.tar.gz'
wget 'ftp://ftp.simplesystems.org/pub/libpng/png/src/libpng-1.5.9.tar.gz'
Expand Down
4 changes: 2 additions & 2 deletions src/base58.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ class CBase58Data
{
// zero the memory, as it may contain sensitive data
if (!vchData.empty())
memset(&vchData[0], 0, vchData.size());
OPENSSL_cleanse(&vchData[0], vchData.size());
}

void SetData(int nVersionIn, const void* pdata, size_t nSize)
Expand Down Expand Up @@ -221,7 +221,7 @@ class CBase58Data
vchData.resize(vchTemp.size() - 1);
if (!vchData.empty())
memcpy(&vchData[0], &vchTemp[1], vchData.size());
memset(&vchTemp[0], 0, vchTemp.size());
OPENSSL_cleanse(&vchTemp[0], vchData.size());
return true;
}

Expand Down
97 changes: 90 additions & 7 deletions src/bitcoinrpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,81 @@ string AccountFromValue(const Value& value)
return strAccount;
}

Object blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool fPrintTransactionDetail)

void TxToJSON(const CTransaction& tx, Object& txdata)
{
// tx data
txdata.push_back(Pair("txid", tx.GetHash().ToString().c_str()));
txdata.push_back(Pair("version", (int)tx.nVersion));
txdata.push_back(Pair("locktime", (int)tx.nLockTime));
txdata.push_back(Pair("is_coinbase", tx.IsCoinBase()));
txdata.push_back(Pair("is_coinstake", tx.IsCoinStake()));

// add inputs
Array vins;
BOOST_FOREACH(const CTxIn& txin, tx.vin)
{
Object vin;

if (txin.prevout.IsNull())
{
vin.push_back(Pair("coinbase", HexStr(txin.scriptSig).c_str()));
}
else
{
vin.push_back(Pair("txid", txin.prevout.hash.ToString().c_str()));
vin.push_back(Pair("vout", (int)txin.prevout.n));
}

vin.push_back(Pair("sequence", (boost::uint64_t)txin.nSequence));

vins.push_back(vin);
}
txdata.push_back(Pair("vin", vins));

// add outputs
Array vouts;
int n = 0;
BOOST_FOREACH(const CTxOut& txout, tx.vout)
{
Object vout;

std::vector<CBitcoinAddress> addresses;
txnouttype txtype;
int nRequired;

vout.push_back(Pair("value", ValueFromAmount(txout.nValue)));
vout.push_back(Pair("n", n));

Object scriptpubkey;

scriptpubkey.push_back(Pair("asm", txout.scriptPubKey.ToString()));
scriptpubkey.push_back(Pair("hex", HexStr(txout.scriptPubKey.begin(), txout.scriptPubKey.end())));

if (ExtractAddresses(txout.scriptPubKey, txtype, addresses, nRequired))
{
scriptpubkey.push_back(Pair("type", GetTxnOutputType(txtype)));
scriptpubkey.push_back(Pair("reqSig", nRequired));

Array addrs;
BOOST_FOREACH(const CBitcoinAddress& addr, addresses)
addrs.push_back(addr.ToString());
scriptpubkey.push_back(Pair("addresses", addrs));
}
else
{
scriptpubkey.push_back(Pair("type", GetTxnOutputType(TX_NONSTANDARD)));
}

vout.push_back(Pair("scriptPubKey",scriptpubkey));

vouts.push_back(vout);
n++;
}
txdata.push_back(Pair("vout", vouts));
}

Object blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool fTxInfo, bool fTxDetails)
{
Object result;
result.push_back(Pair("hash", block.GetHash().GetHex()));
Expand All @@ -165,7 +239,7 @@ Object blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool fPri
Array txinfo;
BOOST_FOREACH (const CTransaction& tx, block.vtx)
{
if (fPrintTransactionDetail)
if (fTxInfo && !fTxDetails)
{
txinfo.push_back(tx.ToStringShort());
txinfo.push_back(DateTimeStrFormat(tx.nTime));
Expand All @@ -174,15 +248,19 @@ Object blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool fPri
BOOST_FOREACH(const CTxOut& txout, tx.vout)
txinfo.push_back(txout.ToStringShort());
}
else if (fTxDetails)
{
Object txdata;
TxToJSON(tx, txdata);
txinfo.push_back(txdata);
}
else
txinfo.push_back(tx.GetHash().GetHex());
}
result.push_back(Pair("tx", txinfo));
return result;
}



///
/// Note: This interface may still be subject to change.
///
Expand Down Expand Up @@ -2204,10 +2282,11 @@ Value getblockhash(const Array& params, bool fHelp)

Value getblock(const Array& params, bool fHelp)
{
if (fHelp || params.size() < 1 || params.size() > 2)
if (fHelp || params.size() < 1 || params.size() > 3)
throw runtime_error(
"getblock <hash> [txinfo]\n"
"getblock <hash> [txinfo] [txdetails]\n"
"txinfo optional to print more detailed tx info\n"
"txdetails optional to print even more detailed tx info\n"
"Returns details of a block with given block-hash.");

std::string strHash = params[0].get_str();
Expand All @@ -2220,7 +2299,10 @@ Value getblock(const Array& params, bool fHelp)
CBlockIndex* pblockindex = mapBlockIndex[hash];
block.ReadFromDisk(pblockindex, true);

return blockToJSON(block, pblockindex, params.size() > 1 ? params[1].get_bool() : false);
bool fTxInfo = params.size() > 1 ? params[1].get_bool() : false;
bool fTxDetails = params.size() > 2 ? params[2].get_bool() : false;

return blockToJSON(block, pblockindex, fTxInfo, fTxDetails);
}


Expand Down Expand Up @@ -3095,6 +3177,7 @@ Array RPCConvertValues(const std::string &strMethod, const std::vector<std::stri
if (strMethod == "getbalance" && n > 1) ConvertTo<boost::int64_t>(params[1]);
if (strMethod == "getblockhash" && n > 0) ConvertTo<boost::int64_t>(params[0]);
if (strMethod == "getblock" && n > 1) ConvertTo<bool>(params[1]);
if (strMethod == "getblock" && n > 2) ConvertTo<bool>(params[2]);
if (strMethod == "move" && n > 2) ConvertTo<double>(params[2]);
if (strMethod == "move" && n > 3) ConvertTo<boost::int64_t>(params[3]);
if (strMethod == "sendfrom" && n > 2) ConvertTo<double>(params[2]);
Expand Down
4 changes: 2 additions & 2 deletions src/crypter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ bool CCrypter::SetKeyFromPassphrase(const SecureString& strKeyData, const std::v

if (i != (int)WALLET_CRYPTO_KEY_SIZE)
{
memset(&chKey, 0, sizeof chKey);
memset(&chIV, 0, sizeof chIV);
OPENSSL_cleanse(chKey, sizeof(chKey));
OPENSSL_cleanse(chIV, sizeof(chIV));
return false;
}

Expand Down
8 changes: 4 additions & 4 deletions src/crypter.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ class CCrypter

void CleanKey()
{
memset(&chKey, 0, sizeof chKey);
memset(&chIV, 0, sizeof chIV);
munlock(&chKey, sizeof chKey);
munlock(&chIV, sizeof chIV);
OPENSSL_cleanse(chKey, sizeof(chKey));
OPENSSL_cleanse(chIV, sizeof(chIV));
munlock(chKey, sizeof(chKey));
munlock(chIV, sizeof(chIV));
fKeySet = false;
}

Expand Down
1 change: 1 addition & 0 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ bool AppInit2(int argc, char* argv[])
" -rpcallowip=<ip> \t\t " + _("Allow JSON-RPC connections from specified IP address") + "\n" +
" -rpcconnect=<ip> \t " + _("Send commands to node running on <ip> (default: 127.0.0.1)") + "\n" +
" -blocknotify=<cmd> " + _("Execute command when the best block changes (%s in cmd is replaced by block hash)") + "\n" +
" -walletnotify=<cmd> " + _("Execute command when a wallet transaction changes (%s in cmd is replaced by TxID)") + "\n" +
" -upgradewallet \t " + _("Upgrade wallet to latest format") + "\n" +
" -keypool=<n> \t " + _("Set key pool size to <n> (default: 100)") + "\n" +
" -rescan \t " + _("Rescan the block chain for missing wallet transactions") + "\n" +
Expand Down
4 changes: 4 additions & 0 deletions src/key.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,10 @@ bool CKey::SignCompact(uint256 hash, std::vector<unsigned char>& vchSig)
}

if (nRecId == -1)
{
ECDSA_SIG_free(sig);
throw key_error("CKey::SignCompact() : unable to construct recoverable key");
}

vchSig[0] = nRecId+27+(fCompressedPubKey ? 4 : 0);
BN_bn2bin(sig->r,&vchSig[33-(nBitsR+7)/8]);
Expand Down Expand Up @@ -347,6 +350,7 @@ bool CKey::SetCompactSignature(uint256 hash, const std::vector<unsigned char>& v
ECDSA_SIG_free(sig);
return true;
}
ECDSA_SIG_free(sig);
return false;
}

Expand Down
15 changes: 6 additions & 9 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1549,14 +1549,6 @@ bool Reorganize(CTxDB& txdb, CBlockIndex* pindexNew)
}


static void
runCommand(std::string strCommand)
{
int nErr = ::system(strCommand.c_str());
if (nErr)
printf("runCommand error: system(%s) returned %d\n", strCommand.c_str(), nErr);
}

// Called from inside SetBestChain: attaches a block to the new best chain being built
bool CBlock::SetBestChainInner(CTxDB& txdb, CBlockIndex *pindexNew)
{
Expand Down Expand Up @@ -2038,7 +2030,12 @@ bool ProcessBlock(CNode* pfrom, CBlock* pblock)
// Limited duplicity on stake: prevents block flood attack
// Duplicate stake allowed only when there is orphan child block
if (setStakeSeenOrphan.count(pblock2->GetProofOfStake()) && !mapOrphanBlocksByPrev.count(hash) && !Checkpoints::WantedByPendingSyncCheckpoint(hash))
return error("ProcessBlock() : duplicate proof-of-stake (%s, %d) for orphan block %s", pblock2->GetProofOfStake().first.ToString().c_str(), pblock2->GetProofOfStake().second, hash.ToString().c_str());
{
error("ProcessBlock() : duplicate proof-of-stake (%s, %d) for orphan block %s", pblock2->GetProofOfStake().first.ToString().c_str(), pblock2->GetProofOfStake().second, hash.ToString().c_str());
//pblock2 will not be needed, free it
delete pblock2;
return false;
}
else
setStakeSeenOrphan.insert(pblock2->GetProofOfStake());
}
Expand Down
4 changes: 2 additions & 2 deletions src/makefile.linux-mingw
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ USE_UPNP:=0
INCLUDEPATHS= \
-I"$(DEPSDIR)/boost_1_47_0" \
-I"$(DEPSDIR)/db-4.8.30.NC/build_unix" \
-I"$(DEPSDIR)/openssl-1.0.1b/include" \
-I"$(DEPSDIR)/openssl-1.0.1g/include" \
-I"$(DEPSDIR)" \
-I"$(CURDIR)"/obj \

LIBPATHS= \
-L"$(DEPSDIR)/boost_1_47_0/stage/lib" \
-L"$(DEPSDIR)/db-4.8.30.NC/build_unix" \
-L"$(DEPSDIR)/openssl-1.0.1b"
-L"$(DEPSDIR)/openssl-1.0.1g"

LIBS= \
-l boost_system-mt-s \
Expand Down
8 changes: 4 additions & 4 deletions src/makefile.mingw
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
#
# - Add/edit 'MAKE' environment variable with value '/c/MinGW32/bin/mingw32-make.exe'
#
# - Build openssl library version: 1.0.1b
# - Build openssl library version: 1.0.1g
# download from http://www.openssl.org/source/
# Extract to c:\openssl-1.0.1b-mgw
# Extract to c:\openssl-1.0.1g-mgw
# In MinGW MSYS:
# ./config
# make
Expand Down Expand Up @@ -64,12 +64,12 @@ USE_UPNP:=0
INCLUDEPATHS= \
-I"C:\boost-1.47.0-mgw" \
-I"C:\db-4.8.30.NC-mgw\build_unix" \
-I"C:\openssl-1.0.1b-mgw\include"
-I"C:\openssl-1.0.1g-mgw\include"

LIBPATHS= \
-L"C:\boost-1.47.0-mgw\stage\lib" \
-L"C:\db-4.8.30.NC-mgw\build_unix" \
-L"C:\openssl-1.0.1b-mgw"
-L"C:\openssl-1.0.1g-mgw"

LIBS= \
-l boost_system-mgw46-mt-s-1_47 \
Expand Down

0 comments on commit 0dc2b71

Please sign in to comment.