diff --git a/.gitignore b/.gitignore index 4ad2d7ba..1d35ca31 100644 --- a/.gitignore +++ b/.gitignore @@ -129,4 +129,6 @@ src/config/komodo-config.h.in src/komodod src/qt/komodo-qt +# chain files for iguana +src/qt/*_7776 diff --git a/README.md b/README.md index aa88764c..791bd552 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,10 @@ # KomodoOcean (komodo-qt) # -![](./doc/images/komodo-qt-promo-10.png) +![Downloads](https://img.shields.io/github/downloads/DeckerSU/KomodoOcean/total) -Komodo-Qt (KomodoOcean) is a world-first Qt native wallet for KMD ([Komodo](https://komodoplatform.com/)) and all of assetchains. It's available for three OS platforms - Windows, Linux, MacOS. +![](./doc/images/komodo-qt-promo-2020-01.jpg) + +Komodo-Qt (KomodoOcean) is a world-first Qt native wallet for KMD ([Komodo](https://komodoplatform.com/)) and smartchains (assetchains). It's available for three OS platforms - Windows, Linux, MacOS. **NB!** Earlier (till 23.05.2019) we had three branches: @@ -19,7 +21,7 @@ Use the following scripts to build: - Windows: `build-win.sh` (cross-compilation for Win) - MacOS: `build-mac.sh` (native build) -`master` branch still can be used to build Windows version of Komodo-Qt with MSVC compiler. +`master` branch **can't** be used anymore to build actual wallet version, but it still can be used as an example of build with MSVC compiler. To build actual version plz use `static` branch. Visit [#wallet-ocean-qt](https://discord.gg/U5WWaJR) channel in Komodo Discord for more information. @@ -95,5 +97,5 @@ cd komodo ## Developers of Qt wallet ## -- Main developer: [@Ocean](https://komodo-platform.slack.com/team/U8BRG09EV) -- IT Expert / Sysengineer: [@Decker](https://komodo-platform.slack.com/messages/D5UHJMCJ3) \ No newline at end of file +- Main developer: **Ocean** +- IT Expert / Sysengineer: **Decker** diff --git a/configure.ac b/configure.ac index c011ad4d..672bf382 100644 --- a/configure.ac +++ b/configure.ac @@ -7,7 +7,7 @@ define(_CLIENT_VERSION_BUILD, 1) define(_ZC_BUILD_VAL, m4_if(m4_eval(_CLIENT_VERSION_BUILD < 25), 1, m4_incr(_CLIENT_VERSION_BUILD), m4_eval(_CLIENT_VERSION_BUILD < 50), 1, m4_eval(_CLIENT_VERSION_BUILD - 24), m4_eval(_CLIENT_VERSION_BUILD == 50), 1, , m4_eval(_CLIENT_VERSION_BUILD - 50))) define(_CLIENT_VERSION_SUFFIX, m4_if(m4_eval(_CLIENT_VERSION_BUILD < 25), 1, _CLIENT_VERSION_REVISION-beta$1, m4_eval(_CLIENT_VERSION_BUILD < 50), 1, _CLIENT_VERSION_REVISION-rc$1, m4_eval(_CLIENT_VERSION_BUILD == 50), 1, _CLIENT_VERSION_REVISION, _CLIENT_VERSION_REVISION-$1))) define(_CLIENT_VERSION_IS_RELEASE, true) -define(_COPYRIGHT_YEAR, 2019) +define(_COPYRIGHT_YEAR, 2020) define(_COPYRIGHT_HOLDERS, "The %s developers") define(_COPYRIGHT_HOLDERS_SUBSTITUTION, "Ocean and Decker") diff --git a/depends/packages/boost.mk b/depends/packages/boost.mk index 06df125c..3981e98d 100644 --- a/depends/packages/boost.mk +++ b/depends/packages/boost.mk @@ -1,7 +1,7 @@ package=boost $(package)_version=1_72_0 -$(package)_download_path=https://dl.bintray.com/boostorg/release/1.72.0/source +$(package)_download_path=https://github.com/KomodoPlatform/boost/releases/download/boost-1.72.0-kmd $(package)_sha256_hash=59c9b274bc451cf91a9ba1dd2c7fdcaf5d60b1b3aa83f2c9fa143417cc660722 $(package)_file_name=$(package)_$($(package)_version).tar.bz2 diff --git a/doc/images/komodo-qt-promo-10.png b/doc/images/komodo-qt-promo-10.png deleted file mode 100644 index e17345ef..00000000 Binary files a/doc/images/komodo-qt-promo-10.png and /dev/null differ diff --git a/doc/images/komodo-qt-promo-2020-01.jpg b/doc/images/komodo-qt-promo-2020-01.jpg new file mode 100644 index 00000000..704fb791 Binary files /dev/null and b/doc/images/komodo-qt-promo-2020-01.jpg differ diff --git a/src/checkpoints.cpp b/src/checkpoints.cpp index a2a6160e..d76169b5 100644 --- a/src/checkpoints.cpp +++ b/src/checkpoints.cpp @@ -74,7 +74,7 @@ namespace Checkpoints { fWorkAfter = nExpensiveAfter*fSigcheckVerificationFactor; } - return fWorkBefore / (fWorkBefore + fWorkAfter); + return std::min(fWorkBefore / (fWorkBefore + fWorkAfter), 1.0); } int GetTotalBlocksEstimate(const CChainParams::CCheckpointData& data) diff --git a/src/clientversion.h b/src/clientversion.h index 79e2404b..7a4c376d 100644 --- a/src/clientversion.h +++ b/src/clientversion.h @@ -42,7 +42,7 @@ * Copyright year (2009-this) * Todo: update this when changing our copyright comments in the source */ -#define COPYRIGHT_YEAR 2019 +#define COPYRIGHT_YEAR 2020 #endif //HAVE_CONFIG_H diff --git a/src/httpserver.cpp b/src/httpserver.cpp index 2ee8d178..f0b98dae 100644 --- a/src/httpserver.cpp +++ b/src/httpserver.cpp @@ -11,6 +11,7 @@ #include "rpc/protocol.h" // For HTTP status codes #include "sync.h" #include "ui_interface.h" +#include "utilstrencodings.h" #include #include @@ -24,6 +25,7 @@ #include #include #include +#include #include #include @@ -249,23 +251,37 @@ static std::string RequestMethodString(HTTPRequest::RequestMethod m) /** HTTP request callback */ static void http_request_cb(struct evhttp_request* req, void* arg) { + // Disable reading to work around a libevent bug, fixed in 2.2.0. + if (event_get_version_number() >= 0x02010600 && event_get_version_number() < 0x02020001) { + evhttp_connection* conn = evhttp_request_get_connection(req); + if (conn) { + bufferevent* bev = evhttp_connection_get_bufferevent(conn); + if (bev) { + bufferevent_disable(bev, EV_READ); + } + } + } std::unique_ptr hreq(new HTTPRequest(req)); - LogPrint("http", "Received a %s request for %s from %s\n", - RequestMethodString(hreq->GetRequestMethod()), hreq->GetURI(), hreq->GetPeer().ToString()); - // Early address-based allow check if (!ClientAllowed(hreq->GetPeer())) { + LogPrint("http", "HTTP request from %s rejected: Client network is not allowed RPC access\n", + hreq->GetPeer().ToString()); hreq->WriteReply(HTTP_FORBIDDEN); return; } // Early reject unknown HTTP methods if (hreq->GetRequestMethod() == HTTPRequest::UNKNOWN) { + LogPrint("http", "HTTP request from %s rejected: Unknown HTTP request method\n", + hreq->GetPeer().ToString()); hreq->WriteReply(HTTP_BADMETHOD); return; } + LogPrint("http", "Received a %s request for %s from %s\n", + RequestMethodString(hreq->GetRequestMethod()), SanitizeString(hreq->GetURI(), SAFE_CHARS_URI).substr(0, 100), hreq->GetPeer().ToString()); + // Find registered handler for prefix std::string strURI = hreq->GetURI(); std::string path; @@ -599,8 +615,21 @@ void HTTPRequest::WriteReply(int nStatus, const std::string& strReply) struct evbuffer* evb = evhttp_request_get_output_buffer(req); assert(evb); evbuffer_add(evb, strReply.data(), strReply.size()); - HTTPEvent* ev = new HTTPEvent(eventBase, true, - boost::bind(evhttp_send_reply, req, nStatus, (const char*)NULL, (struct evbuffer *)NULL)); + auto req_copy = req; + HTTPEvent* ev = new HTTPEvent(eventBase, true, [req_copy, nStatus]{ + evhttp_send_reply(req_copy, nStatus, (const char*)NULL, (struct evbuffer *)NULL); + // Re-enable reading from the socket. This is the second part of the libevent + // workaround above. + if (event_get_version_number() >= 0x02010600 && event_get_version_number() < 0x02020001) { + evhttp_connection* conn = evhttp_request_get_connection(req_copy); + if (conn) { + bufferevent* bev = evhttp_connection_get_bufferevent(conn); + if (bev) { + bufferevent_enable(bev, EV_READ | EV_WRITE); + } + } + } + }); ev->trigger(0); replySent = true; req = 0; // transferred back to main thread @@ -665,4 +694,3 @@ void UnregisterHTTPHandler(const std::string &prefix, bool exactMatch) pathHandlers.erase(i); } } - diff --git a/src/init.cpp b/src/init.cpp index d9378f84..69d6a0df 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1539,32 +1539,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) fReindex = GetBoolArg("-reindex", false); - // Upgrading to 0.8; hard-link the old blknnnn.dat files into /blocks/ - boost::filesystem::path blocksDir = GetDataDir() / "blocks"; - if (!boost::filesystem::exists(blocksDir)) - { - boost::filesystem::create_directories(blocksDir); - bool linked = false; - for (unsigned int i = 1; i < 10000; i++) { - boost::filesystem::path source = GetDataDir() / strprintf("blk%04u.dat", i); - if (!boost::filesystem::exists(source)) break; - boost::filesystem::path dest = blocksDir / strprintf("blk%05u.dat", i-1); - try { - boost::filesystem::create_hard_link(source, dest); - LogPrintf("Hardlinked %s -> %s\n", source.string(), dest.string()); - linked = true; - } catch (const boost::filesystem::filesystem_error& e) { - // Note: hardlink creation failing is not a disaster, it just means - // blocks will get re-downloaded from peers. - LogPrintf("Error hardlinking blk%04u.dat: %s\n", i, e.what()); - break; - } - } - if (linked) - { - fReindex = true; - } - } + boost::filesystem::create_directories(GetDataDir() / "blocks"); // block tree db settings int dbMaxOpenFiles = GetArg("-dbmaxopenfiles", DEFAULT_DB_MAX_OPEN_FILES); diff --git a/src/main.cpp b/src/main.cpp index 868768e6..44e0fd41 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2020,6 +2020,8 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa return state.DoS(0, false, REJECT_INSUFFICIENTFEE, "insufficient priority"); } + // std::cerr << __func__ << ": " << tx.GetHash().ToString() << " nFees = " << nFees << " ::minRelayTxFee.GetFee(" << nSize << ") = " << ::minRelayTxFee.GetFee(nSize) << " nTotal = " << tx.GetValueOut() << std::endl; + // Continuously rate-limit free (really, very-low-fee) transactions // This mitigates 'penny-flooding' -- sending thousands of free transactions just to // be annoying or make others' transactions take longer to confirm. @@ -2040,7 +2042,8 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa if (dFreeCount >= GetArg("-limitfreerelay", 15)*10*1000) { LogPrintf("accept failure.7\n"); - return state.DoS(0, error("AcceptToMemoryPool: free transaction rejected by rate limiter"), REJECT_INSUFFICIENTFEE, "rate limited free transaction"); + //return state.DoS(0, error("AcceptToMemoryPool: free transaction rejected by rate limiter"), REJECT_INSUFFICIENTFEE, "rate limited free transaction"); + return state.DoS(0, false, REJECT_INSUFFICIENTFEE, "rate limited free transaction"); } LogPrint("mempool", "Rate limit dFreeCount: %g => %g\n", dFreeCount, dFreeCount+nSize); dFreeCount += nSize; diff --git a/src/miner.cpp b/src/miner.cpp index ce3e415d..103651c5 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -370,7 +370,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 if (!mempool.mapTx.count(txin.prevout.hash)) { LogPrintf("ERROR: mempool transaction missing input\n"); - if (fDebug) assert("mempool transaction missing input" == 0); + // if (fDebug) assert("mempool transaction missing input" == 0); fMissingInputs = true; if (porphan) vOrphan.pop_back(); @@ -502,6 +502,40 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 // Size limits unsigned int nTxSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION); + + // Opret spam limits + if (mapArgs.count("-opretmintxfee")) + { + CAmount n = 0; + CFeeRate opretMinFeeRate; + if (ParseMoney(mapArgs["-opretmintxfee"], n) && n > 0) + opretMinFeeRate = CFeeRate(n); + else + opretMinFeeRate = CFeeRate(400000); // default opretMinFeeRate (1 KMD per 250 Kb = 0.004 per 1 Kb = 400000 sat per 1 Kb) + + bool fSpamTx = false; + unsigned int nTxSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION); + unsigned int nTxOpretSize = 0; + + // calc total oprets size + BOOST_FOREACH(const CTxOut& txout, tx.vout) { + if (txout.scriptPubKey.IsOpReturn()) { + CScript::const_iterator it = txout.scriptPubKey.begin() + 1; + opcodetype op; + std::vector opretData; + if (txout.scriptPubKey.GetOp(it, op, opretData)) { + //std::cerr << HexStr(opretData.begin(), opretData.end()) << std::endl; + nTxOpretSize += opretData.size(); + } + } + } + + if ((nTxOpretSize > 256) && (feeRate < opretMinFeeRate)) fSpamTx = true; + // std::cerr << tx.GetHash().ToString() << " nTxSize." << nTxSize << " nTxOpretSize." << nTxOpretSize << " feeRate." << feeRate.ToString() << " opretMinFeeRate." << opretMinFeeRate.ToString() << " fSpamTx." << fSpamTx << std::endl; + if (fSpamTx) continue; + // std::cerr << tx.GetHash().ToString() << " vecPriority.size() = " << vecPriority.size() << std::endl; + } + if (nBlockSize + nTxSize >= nBlockMaxSize-512) // room for extra autotx { //LogPrintf("nBlockSize %d + %d nTxSize >= %d nBlockMaxSize\n",(int32_t)nBlockSize,(int32_t)nTxSize,(int32_t)nBlockMaxSize); @@ -1939,7 +1973,7 @@ void static BitcoinMiner() //LogPrintf("gotinvalid.%d\n",gotinvalid); if ( gotinvalid != 0 ) break; - komodo_longestchain(); + // komodo_longestchain(); // Hash state KOMODO_CHOSEN_ONE = 0; diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 0adc9e69..3492624a 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -4,7 +4,7 @@ // file COPYING or http://www.opensource.org/licenses/mit-license.php. /****************************************************************************** - * Copyright © 2014-2019 The SuperNET Developers. * + * 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 * @@ -107,6 +107,11 @@ double GetNetworkDifficulty(const CBlockIndex* blockindex) return GetDifficultyINTERNAL(blockindex, true); } +UniValue letsdebug(const UniValue& params, bool fHelp, const CPubKey& mypk) { + // here should be a code for letsdebug test RPC + return NullUniValue; +} + static UniValue ValuePoolDesc( const std::string &name, const boost::optional chainValue, @@ -2112,6 +2117,7 @@ static const CRPCCommand commands[] = /* Not shown in help */ { "hidden", "invalidateblock", &invalidateblock, true }, { "hidden", "reconsiderblock", &reconsiderblock, true }, + { "hidden", "letsdebug", &letsdebug, true }, }; void RegisterBlockchainRPCCommands(CRPCTable &tableRPC) diff --git a/src/rpc/client.cpp b/src/rpc/client.cpp index e6715308..81accc7d 100644 --- a/src/rpc/client.cpp +++ b/src/rpc/client.cpp @@ -179,6 +179,7 @@ static const CRPCConvertParam vRPCConvertParams[] = { "height_MoM", 1}, { "calc_MoM", 2}, { "migrate_completeimporttransaction", 1}, + { "letsdebug", 1 } }; class CRPCConvertTable diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index 61147f70..87b0ee63 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -78,7 +78,7 @@ int8_t StakedNotaryID(std::string ¬aryname, char *Raddress); uint64_t komodo_notarypayamount(int32_t nHeight, int64_t notarycount); int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp); -#define KOMODO_VERSION "0.5.1" +#define KOMODO_VERSION "0.5.2" #define VERUS_VERSION "0.4.0g" extern uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT; extern uint32_t ASSETCHAINS_CC; diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp index ab1099c4..19b7a7d5 100644 --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -342,6 +342,7 @@ static const CRPCCommand vRPCCommands[] = { "blockchain", "minerids", &minerids, true }, { "blockchain", "kvsearch", &kvsearch, true }, { "blockchain", "kvupdate", &kvupdate, true }, + { "blockchain", "letsdebug", &letsdebug, true }, /* Cross chain utilities */ { "crosschain", "MoMoMdata", &MoMoMdata, true }, diff --git a/src/rpc/server.h b/src/rpc/server.h index 0be2c208..19d0a5dc 100644 --- a/src/rpc/server.h +++ b/src/rpc/server.h @@ -547,6 +547,6 @@ extern UniValue pricesaddfunding(const UniValue& params, bool fHelp, const CPubK extern UniValue pricesgetorderbook(const UniValue& params, bool fHelp, const CPubKey& mypk); extern UniValue pricesrefillfund(const UniValue& params, bool fHelp, const CPubKey& mypk); - +extern UniValue letsdebug(const UniValue& params, bool fHelp, const CPubKey& mypk); #endif // BITCOIN_RPCSERVER_H diff --git a/src/utilstrencodings.cpp b/src/utilstrencodings.cpp index d4bba72e..132ae82a 100644 --- a/src/utilstrencodings.cpp +++ b/src/utilstrencodings.cpp @@ -20,7 +20,8 @@ static const string CHARS_ALPHA_NUM = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNO static const string SAFE_CHARS[] = { CHARS_ALPHA_NUM + " .,;_/:?@()", // SAFE_CHARS_DEFAULT - CHARS_ALPHA_NUM + " .,;_?@" // SAFE_CHARS_UA_COMMENT + CHARS_ALPHA_NUM + " .,;_?@", // SAFE_CHARS_UA_COMMENT + CHARS_ALPHA_NUM + "!*'();:@&=+$,/?#[]-_.~%" // SAFE_CHARS_URI }; string SanitizeString(const string& str, int rule) diff --git a/src/utilstrencodings.h b/src/utilstrencodings.h index 37a07ea0..2d851093 100644 --- a/src/utilstrencodings.h +++ b/src/utilstrencodings.h @@ -26,7 +26,8 @@ enum SafeChars { SAFE_CHARS_DEFAULT, //!< The full set of allowed chars - SAFE_CHARS_UA_COMMENT //!< BIP-0014 subset + SAFE_CHARS_UA_COMMENT, //!< BIP-0014 subset + SAFE_CHARS_URI //!< Chars allowed in URIs (RFC 3986) }; std::string SanitizeFilename(const std::string& str); diff --git a/src/version.h b/src/version.h index 121e2fe9..81624e42 100644 --- a/src/version.h +++ b/src/version.h @@ -3,7 +3,7 @@ // file COPYING or http://www.opensource.org/licenses/mit-license.php. /****************************************************************************** - * Copyright © 2014-2019 The SuperNET Developers. * + * 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 * @@ -24,7 +24,7 @@ * network protocol versioning */ -static const int PROTOCOL_VERSION = 170008; +static const int PROTOCOL_VERSION = 170009; //! initial proto version, to be increased after version/verack negotiation static const int INIT_PROTO_VERSION = 209; diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 14a6d1d0..6ca417a1 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -4,7 +4,7 @@ // file COPYING or http://www.opensource.org/licenses/mit-license.php. /****************************************************************************** - * Copyright © 2014-2019 The SuperNET Developers. * + * 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 * @@ -1781,49 +1781,48 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl return false; } } - static std::string NotaryAddress; static bool didinit; - if ( !didinit && NotaryAddress.empty() && NOTARY_PUBKEY33[0] != 0 ) - { - didinit = true; - char Raddress[64]; - pubkey2addr((char *)Raddress,(uint8_t *)NOTARY_PUBKEY33); - NotaryAddress.assign(Raddress); - vWhiteListAddress = mapMultiArgs["-whitelistaddress"]; - if ( !vWhiteListAddress.empty() ) - { - LogPrintf( "Activated Wallet Filter \n Notary Address: %s \n Adding whitelist address's:\n", NotaryAddress.c_str()); - for ( auto wladdr : vWhiteListAddress ) - LogPrintf( " %s\n", wladdr.c_str()); - } - } if (fExisted || IsMine(tx) || IsFromMe(tx) || sproutNoteData.size() > 0 || saplingNoteData.size() > 0) { - // wallet filter for notary nodes. Enables by setting -whitelistaddress= as startup param or in conf file (works same as -addnode byut with R-address's) - if ( !tx.IsCoinBase() && !vWhiteListAddress.empty() && !NotaryAddress.empty() ) + /** + * New implementation of wallet filter code. + * + * If any vout of tx is belongs to wallet (IsMine(tx) == true) and tx + * is not from us, mean, if every vin not belongs to our wallet + * (IsFromMe(tx) == false), then tx need to be checked through wallet + * filter. If tx haven't any vin from trusted / whitelisted address it + * shouldn't be added into wallet. + */ + + if (!mapMultiArgs["-whitelistaddress"].empty()) { - int numvinIsOurs = 0, numvinIsWhiteList = 0; - for (size_t i = 0; i < tx.vin.size(); i++) + if (IsMine(tx) && !tx.IsCoinBase() && !IsFromMe(tx)) { - uint256 hash; CTransaction txin; CTxDestination address; - if ( myGetTransaction(tx.vin[i].prevout.hash,txin,hash) && ExtractDestination(txin.vout[tx.vin[i].prevout.n].scriptPubKey, address) ) + bool fIsFromWhiteList = false; + BOOST_FOREACH(const CTxIn& txin, tx.vin) { - if ( CBitcoinAddress(address).ToString() == NotaryAddress ) - numvinIsOurs++; - for ( auto wladdr : vWhiteListAddress ) + if (fIsFromWhiteList) break; + uint256 hashBlock; CTransaction prevTx; CTxDestination dest; + if (GetTransaction(txin.prevout.hash, prevTx, hashBlock, true) && ExtractDestination(prevTx.vout[txin.prevout.n].scriptPubKey,dest)) { - if ( CBitcoinAddress(address).ToString() == wladdr ) + BOOST_FOREACH(const std::string& strWhiteListAddress, mapMultiArgs["-whitelistaddress"]) { - //LogPrintf( "We received from whitelisted address.%s\n", wladdr.c_str()); - numvinIsWhiteList++; + if (EncodeDestination(dest) == strWhiteListAddress) + { + fIsFromWhiteList = true; + // std::cerr << __FUNCTION__ << " tx." << tx.GetHash().ToString() << " passed wallet filter! whitelistaddress." << EncodeDestination(dest) << std::endl; + LogPrintf("tx.%s passed wallet filter! whitelistaddress.%s\n", tx.GetHash().ToString(),EncodeDestination(dest)); + break; + } } } } + if (!fIsFromWhiteList) + { + // std::cerr << __FUNCTION__ << " tx." << tx.GetHash().ToString() << " is NOT passed wallet filter!" << std::endl; + LogPrintf("tx.%s is NOT passed wallet filter!\n", tx.GetHash().ToString()); + return false; + } } - // Now we know if it was a tx sent to us, by either a whitelisted address, or ourself. - if ( numvinIsOurs != 0 ) - LogPrintf( "We sent from address: %s vins: %d\n",NotaryAddress.c_str(),numvinIsOurs); - if ( numvinIsOurs == 0 && numvinIsWhiteList == 0 ) - return false; } CWalletTx wtx(this,tx); diff --git a/src/zmq/zmqpublishnotifier.cpp b/src/zmq/zmqpublishnotifier.cpp index e3fd635f..c08a7fac 100644 --- a/src/zmq/zmqpublishnotifier.cpp +++ b/src/zmq/zmqpublishnotifier.cpp @@ -28,6 +28,7 @@ static int zmq_send_multipart(void *sock, const void* data, size_t size, ...) if (rc != 0) { zmqError("Unable to initialize ZMQ msg"); + va_end(args); return -1; } @@ -41,6 +42,7 @@ static int zmq_send_multipart(void *sock, const void* data, size_t size, ...) { zmqError("Unable to send ZMQ msg"); zmq_msg_close(&msg); + va_end(args); return -1; } @@ -51,6 +53,7 @@ static int zmq_send_multipart(void *sock, const void* data, size_t size, ...) size = va_arg(args, size_t); } + va_end(args); return 0; }