[Dev] Documenting Feathercoin Specific Software settings - Part 3
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
Fix compile error commit
https://github.com/FeatherCoin/Feathercoin/commit/ce54ff5609afb5b7cace591a6a0c7ba500f15ac1
src/base58.h
New file
// Why base-58 instead of standard base-64 encoding? // - Don't want 0OIl characters that look the same in some fonts and // could be used to create visually identical looking account numbers. // - A string with non-alphanumeric characters is not as easily accepted as an account number. // - E-mail usually won't line-break if there's no punctuation to break at. // - Double-clicking selects the whole number as one word if it's all alphanumeric. // #ifndef BITCOIN_BASE58_H #define BITCOIN_BASE58_H #include "chainparams.h" #include "key.h" #include "script.h" #include <string> #include <vector> /** * Encode a byte sequence as a base58-encoded string. * pbegin and pend cannot be NULL, unless both are. */ std::string EncodeBase58(const unsigned char* pbegin, const unsigned char* pend);
New file .150 starts.here, where from?
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
Fix compile error commit
https://github.com/FeatherCoin/Feathercoin/commit/ce54ff5609afb5b7cace591a6a0c7ba500f15ac1
src/mruset.h
+ void clear() { set.clear(); queue.clear(); }
Add code
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
Fix compile error commit
https://github.com/FeatherCoin/Feathercoin/commit/ce54ff5609afb5b7cace591a6a0c7ba500f15ac1
src/netbase.h
-#ifdef USE_IPV6
2 if defs for iPv6 Code removed
+/** Return readable error string for a network error code */ +std::string NetworkErrorString(int err);
Code added
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
Fix compile error commit
https://github.com/FeatherCoin/Feathercoin/commit/ce54ff5609afb5b7cace591a6a0c7ba500f15ac1
src/rpcmisc.cpp
- obj.push_back(Pair("timeoffset", (boost::int64_t)GetTimeOffset())); + obj.push_back(Pair("timeoffset", GetTimeOffset())); - obj.push_back(Pair("timeoffset", (boost::int64_t)GetTimeOffset())); + obj.push_back(Pair("timeoffset", GetTimeOffset())); - obj.push_back(Pair("unlocked_until", (boost::int64_t)nWalletUnlockTime)); + obj.push_back(Pair("unlocked_until", nWalletUnlockTime)); - CScript _createmultisig(const Array& params) + CScript _createmultisig_redeemScript(const Array& params)
Code replaced
+ + if (result.size() > MAX_SCRIPT_ELEMENT_SIZE) + throw runtime_error( + strprintf("redeemScript exceeds size limit: %d > %d", result.size(), MAX_SCRIPT_ELEMENT_SIZE)); +
Additional code
- CScript inner = _createmultisig(params); + CScript inner = _createmultisig_redeemScript(params);
Code replaced
+ "verifymessage \"feathercoinaddress\" \"signature\" \"message\"\n" + "1. \"feathercoinaddress\" (string, required) The feathercoin address to use for the signature.\n"
Code replaced name change
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
Fix compile error commit
https://github.com/FeatherCoin/Feathercoin/commit/ce54ff5609afb5b7cace591a6a0c7ba500f15ac1
src/rpcprotocol.cpp
- char buffer[64]; - time(&now); - time_t now; - struct tm* now_gmt = gmtime(&now); - string locale(setlocale(LC_TIME, NULL)); - setlocale(LC_TIME, "C"); // we want POSIX (aka "C") weekday/month strings - strftime(buffer, sizeof(buffer), "%a, %d %b %Y %H:%M:%S +0000", now_gmt); - setlocale(LC_TIME, locale.c_str()); - return string(buffer);
Code replaced
+ return DateTimeStrFormat("%a, %d %b %Y %H:%M:%S +0000", GetTime());
Code added to replace code
- "Content-Length: %"PRIszu"\r\n" + "Content-Length: %u\r\n"
Code replaced
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
Fix compile error commit
https://github.com/FeatherCoin/Feathercoin/commit/ce54ff5609afb5b7cace591a6a0c7ba500f15ac1
src/serialize.h
-#define FLATDATA(obj) REF(CFlatData((char*)&(obj), (char*)&(obj+ sizeof(obj))) + #define FLATDATA(obj) REF(CFlatData((char*)&(obj), (char*)&(obj)+ sizeof(obj))) -#define VARINT(obj) REF(WrapVarInt(REF(obj))) + #define VARINT(obj) REF(WrapVarInt(REF(obj))) + #define LIMITED_STRING(obj,n) REF(LimitedString< n >(REF(obj)))
Replace code
+ template<size_t Limit> + class LimitedString + { + protected: + std::string& string; + public: + LimitedString(std::string& string) : string(string) {} + + template<typename Stream> + void Unserialize(Stream& s, int, int=0) + { + size_t size = ReadCompactSize(s); + if (size > Limit) { + throw std::ios_base::failure("String length limit exceeded"); + } + string.resize(size); + if (size != 0) + s.read((char*)&string[0], size); + } + + template<typename Stream> + void Serialize(Stream& s, int, int=0) const + { + WriteCompactSize(s, string.size()); + if (!string.empty()) + s.write((char*)&string[0], string.size()); + } + + unsigned int GetSerializeSize(int, int=0) const + { + return GetSizeOfCompactSize(string.size()) + string.size(); + } + }; +
Added code
- { setstate(std::ios::failbit, "CDataStream::ignore() : end of data"); - nSize = vch.size() - nReadPos; - }
Code removed
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
Fix compile error 2 - commit
https://github.com/FeatherCoin/Feathercoin/commit/eca6f424ab7d927436a38af434ad357946c8219c
src/rpcblockchain.cpp
+#include "checkpoints.h"
Additional code
- result.push_back(Pair("time", (boost::int64_t)block.GetBlockTime())); + result.push_back(Pair("time", block.GetBlockTime())); - result.push_back(Pair("nonce", (boost::uint64_t)block.nNonce)); + result.push_back(Pair("nonce", (uint64_t)block.nNonce)); - info.push_back(Pair("time", (boost::int64_t)e.GetTime())); + info.push_back(Pair("time", e.GetTime())); - ReadBlockFromDisk(block, pblockindex); + + if(!ReadBlockFromDisk(block, pblockindex)) + throw JSONRPCError(RPC_INTERNAL_ERROR, "Can't read block from disk"); - ret.push_back(Pair("height", (boost::int64_t)stats.nHeight)); + ret.push_back(Pair("height", (int64_t)stats.nHeight)); - ret.push_back(Pair("transactions", (boost::int64_t)stats.nTransactions)); + ret.push_back(Pair("transactions", (int64_t)stats.nTransactions)); - ret.push_back(Pair("txouts", (boost::int64_t)stats.nTransactionOutputs)); + ret.push_back(Pair("txouts", (int64_t)stats.nTransactionOutputs)); - ret.push_back(Pair("bytes_serialized", (boost::int64_t)stats.nSerializedSize)); + ret.push_back(Pair("bytes_serialized", (int64_t)stats.nSerializedSize));
Replace code
+ Value getblockchaininfo(const Array& params, bool fHelp) + { + if (fHelp || params.size() != 0) + throw runtime_error( + "getblockchaininfo\n" + "Returns an object containing various state info regarding block chain processing.\n" + "\nResult:\n" + "{\n" + " \"chain\": \"xxxx\", (string) current chain (main, testnet3, regtest)\n" + " \"blocks\": xxxxxx, (numeric) the current number of blocks processed in the server\n" + " \"bestblockhash\": \"...\", (string) the hash of the currently best block\n" + " \"difficulty\": xxxxxx, (numeric) the current difficulty\n" + " \"verificationprogress\": xxxx, (numeric) estimate of verification progress [0..1]\n" + " \"chainwork\": \"xxxx\" (string) total amount of work in active chain, in hexadecimal\n" + "}\n" + "\nExamples:\n" + + HelpExampleCli("getblockchaininfo", "") + + HelpExampleRpc("getblockchaininfo", "") + ); + + proxyType proxy; + GetProxy(NET_IPV4, proxy); + + Object obj; + std::string chain = Params().DataDir(); + if(chain.empty()) + chain = "main"; + obj.push_back(Pair("chain", chain)); + obj.push_back(Pair("blocks", (int)chainActive.Height())); + obj.push_back(Pair("bestblockhash", chainActive.Tip()->GetBlockHash().GetHex())); + obj.push_back(Pair("difficulty", (double)GetDifficulty())); + obj.push_back(Pair("verificationprogress", Checkpoints::GuessVerificationProgress(chainActive.Tip()))); + obj.push_back(Pair("chainwork", chainActive.Tip()->nChainWork.GetHex())); + return obj; + }
Additional code for getblockchaininfo
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
Fix compile error 2 - commit
https://github.com/FeatherCoin/Feathercoin/commit/eca6f424ab7d927436a38af434ad357946c8219c
src/rpcwallet.cpp
- entry.push_back(Pair("blocktime", (boost::int64_t)(mapBlockIndex[wtx.hashBlock]->nTime))); + entry.push_back(Pair("blocktime", (int64_t)(mapBlockIndex[wtx.hashBlock]->nTime)));
Code replaced
- entry.push_back(Pair("time", (boost::int64_t)wtx.GetTxTime())); + entry.push_back(Pair("time", wtx.GetTxTime())); - entry.push_back(Pair("timereceived", (boost::int64_t)wtx.nTimeReceived)); + entry.push_back(Pair("timereceived", (int64_t)wtx.nTimeReceived)); - "\"transactionid\" (string) The transaction id. (view at https://blockchain.info/tx/[transactionid])\n" + "\"transactionid\" (string) The transaction id.\n" - "\"transactionid\" (string) The transaction id. (view at https://blockchain.info/tx/[transactionid])\n" + "\"transactionid\" (string) The transaction id.\n" - " the number of addresses. See https://blockchain.info/tx/[transactionid]\n" + " the number of addresses.\n" -extern CScript _createmultisig(const Array& params); + extern CScript _createmultisig_redeemScript(const Array& params); - CScript inner = _createmultisig(params); + CScript inner = _createmultisig_redeemScript(params); - entry.push_back(Pair("time", (boost::int64_t)acentry.nTime)); + entry.push_back(Pair("time", acentry.nTime)); - " \"txid\": \"transactionid\", (string) The transaction id (see https://blockchain.info/tx/[transactionid]. Available \n" + " \"txid\": \"transactionid\", (string) The transaction id. Available for 'send' and 'receive' category of transactions.\n" - " for 'send' and 'receive' category of transactions.\n" - " \"txid\": \"transactionid\", (string) The transaction id (see https://blockchain.info/tx/[transactionid]. Available for 'send' and 'receive' category of transactions.\n" + " \"txid\" : \"transactionid\", (string) The transaction id.\n" - "Temporarily lock (lock=true) or unlock (lock=false) specified transaction outputs.\n" + "Temporarily lock (unlock=false) or unlock (unlock=true) specified transaction outputs.\n" - obj.push_back(Pair("keypoololdest", (boost::int64_t)pwalletMain ->GetOldestKeyPoolTime())); + obj.push_back(Pair("keypoololdest", pwalletMain ->GetOldestKeyPoolTime())); - obj.push_back(Pair("unlocked_until", (boost::int64_t)nWalletUnlockTime)); + obj.push_back(Pair("unlocked_until", nWalletUnlockTime));
Code replaced
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
Fix lost file - commit
https://github.com/FeatherCoin/Feathercoin/commit/1d396a14752fbe8120f4bebe0ebfaaa69fba3531
src/qt/locale/bitcoin_mn.ts
Translation file complete
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
Fix lost files 2- commit
https://github.com/FeatherCoin/Feathercoin/commit/388d6bdb1cfd96b8634b5c7f5f8b392990abe7d2
src/qt/guiutil.h
+ + // Replace invalid default fonts with known good ones + void SubstituteFonts(); +
Additional code
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
Fix lost files 2- commit
https://github.com/FeatherCoin/Feathercoin/commit/388d6bdb1cfd96b8634b5c7f5f8b392990abe7d2
src/qt/optionsmodel.h
+ ThirdPartyTxUrls, // QString + QString getThirdPartyTxUrls() { return strThirdPartyTxUrls; } + QString strThirdPartyTxUrls;
Additional code
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
Fix lost files 2- commit
https://github.com/FeatherCoin/Feathercoin/commit/388d6bdb1cfd96b8634b5c7f5f8b392990abe7d2
src/qt/rpcconsole.h
- void setNumBlocks(int count, int countOfPeers); + void setNumBlocks(int count);
Code replaced
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
Fix lost files 2- commit
https://github.com/FeatherCoin/Feathercoin/commit/388d6bdb1cfd96b8634b5c7f5f8b392990abe7d2
src/qt/transactiontablemodel.cpp
-#include <QTimer>
Code removed
- LOCK(wallet->cs_wallet); + LOCK2(cs_main, wallet->cs_wallet);
Lock code replaced twice
+ // Get required locks upfront. This avoids the GUI from getting + // stuck if the core is holding the locks for a longer time - for + // example, during a wallet rescan. + //
Additional comments
- if(rec->statusUpdateNeeded()) + TRY_LOCK(cs_main, lockMain); + if(lockMain) { + TRY_LOCK(wallet->cs_wallet, lockWallet); + if(lockWallet && rec->statusUpdateNeeded()) { - LOCK(wallet->cs_wallet);
Code replaced
- LOCK(wallet->cs_wallet); + LOCK2(cs_main, wallet->cs_wallet);
Lock code replaced
- priv(new TransactionTablePriv(wallet, this)), + priv(new TransactionTablePriv(wallet, this)) - cachedNumBlocks(0)
Code replaced
- QTimer *timer = new QTimer(this); - connect(timer, SIGNAL(timeout()), this, SLOT(updateConfirmations())); - timer->start(MODEL_UPDATE_DELAY); -
Code removed
- { - cachedNumBlocks = chainActive.Height(); - // Blocks came in since last poll. - // Invalidate status (number of confirmations) and (possibly) description - // for all rows. Qt is smart enough to only actually request the data for the - // visible rows. - emit dataChanged(index(0, Status), index(priv ->size() -1, Status)); - emit dataChanged(index(0, ToAddress), index(priv ->size() -1, ToAddress)); - }
Code removed
+ // Blocks came in since last poll. + // Invalidate status (number of confirmations) and (possibly) description + // for all rows. Qt is smart enough to only actually request the data for the + // visible rows. + emit dataChanged(index(0, Status), index(priv ->size() -1, Status)); + emit dataChanged(index(0, ToAddress), index(priv ->size() -1, ToAddress));
Code replaces removed code
+ case TxHashRole: + return QString::fromStdString(rec->hash.ToString());
Additional code
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
Fix lost files 2- commit
https://github.com/FeatherCoin/Feathercoin/commit/388d6bdb1cfd96b8634b5c7f5f8b392990abe7d2
src/qt/transactiontablemodel.h
Wallet transaction screen.
+ /** Transaction hash */ + TxHashRole,
Code added
- int cachedNumBlocks;
Code removed
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
Fix lost files 2- commit
https://github.com/FeatherCoin/Feathercoin/commit/388d6bdb1cfd96b8634b5c7f5f8b392990abe7d2
src/qt/winshutdownmonitor.cpp
A new file? where from?
+ // Copyright (c) 2014 The Bitcoin developers + // Distributed under the MIT/X11 software license, see the accompanying + // file COPYING or http://www.opensource.org/licenses/mit-license.php. + + #include "winshutdownmonitor.h" + + #if defined(Q_OS_WIN) && QT_VERSION >= 0x050000 + #include "init.h" + + #include <windows.h> + + #include <QDebug> + + // If we don't want a message to be processed by Qt, return true and set result to + // the value that the window procedure should return. Otherwise return false. + bool WinShutdownMonitor::nativeEventFilter(const QByteArray &eventType, void *pMessage, long *pnResult) + {
Start of code, 57 lines of code
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
Fix lost files 2- commit
https://github.com/FeatherCoin/Feathercoin/commit/388d6bdb1cfd96b8634b5c7f5f8b392990abe7d2
src/qt/winshutdownmonitor.h
A new file? where from?
+ // Copyright (c) 2014 The Bitcoin developers + // Distributed under the MIT/X11 software license, see the accompanying + // file COPYING or http://www.opensource.org/licenses/mit-license.php. + + #ifndef WINSHUTDOWNMONITOR_H + #define WINSHUTDOWNMONITOR_H + + #ifdef WIN32 + #include <QByteArray> + #include <QString> + + #if QT_VERSION >= 0x050000 + #include <windef.h> // for HWND + + #include <QAbstractNativeEventFilter> + + class WinShutdownMonitor : public QAbstractNativeEventFilter + { + public: + /** Implements QAbstractNativeEventFilter interface for processing Windows messages */ + bool nativeEventFilter(const QByteArray &eventType, void *pMessage, long *pnResult); + + /** Register the reason for blocking shutdown on Windows to allow clean client exit */ + static void registerShutdownBlockReason(const QString& strReason, const HWND& mainWinId); + }; + #endif + #endif + + #endif // WINSHUTDOWNMONITOR_H
Code to replacement / new file
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
Fix lost files / compile error 3- commit
https://github.com/FeatherCoin/Feathercoin/commit/e81b798f50f1536dbf9cd0f0c3649fbea074e22b
src/netbase.cpp
- if(chainActive.Height() != cachedNumBlocks) -#ifdef USE_IPV6 aiHint.ai_family = AF_UNSPEC; -#else - aiHint.ai_family = AF_INET; -#endif
Remove ifdef from just IPv6
#ifdef USE_IPV6
if (aiTrav->ai_family == AF_INET6)Remove ifdef from just IPv6
- if (ret) + if (ret) { + closesocket(hSocket);
Replaced if ret true code
- #ifdef USE_IPV6 struct sockaddr_storage sockaddr;
Remove ifdef from just IPv6
+ LogPrintf("select() for %s failed: %s\n", addrConnect.ToString(), NetworkErrorString(WSAGetLastError())); + LogPrintf("connect() to %s failed after select(): %s\n", addrConnect.ToString(), NetworkErrorString(nRet)); + LogPrintf("connect() to %s failed: %s\n", addrConnect.ToString(), NetworkErrorString(WSAGetLastError()));
Log print interface replace
+ closesocket(hSocket);
Additional code
+ case 4: + closesocket(hSocket); + return false;
Case 4 socket code updated
-#ifdef USE_IPV6 CNetAddr::CNetAddr(const struct in6_addr& ipv6Addr) -#ifdef USE_IPV6 struct sockaddr_storage sockaddr; -#ifdef USE_IPV6 bool CNetAddr::GetIn6Addr(struct in6_addr* pipv6Addr) const -#ifdef USE_IPV6 CService::CService(const struct in6_addr& ipv6Addr, unsigned short portIn) : CNetAddr(ipv6Addr), port(portIn) -#ifdef USE_IPV6 CService::CService(const struct sockaddr_in6 &addr) : -#ifdef USE_IPV6 case AF_INET6: *this = CService(*(const struct sockaddr_in6*)paddr); -#ifdef USE_IPV6 if (IsIPv6()) { if (*addrlen < (socklen_t)sizeof(struct sockaddr_in6))
Remove ifdef from just IPv6
+ + #ifdef WIN32 + std::string NetworkErrorString(int err) + { + char buf[256]; + buf[0] = 0; + if(FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_MAX_WIDTH_MASK, + NULL, err, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + buf, sizeof(buf), NULL)) + { + return strprintf("%s (%d)", buf, err); + } + else + { + return strprintf("Unknown error (%d)", err); + } + } + #else + std::string NetworkErrorString(int err) + { + char buf[256]; + const char *s = buf; + buf[0] = 0; + /* Too bad there are two incompatible implementations of the + * thread-safe strerror. */ + #ifdef STRERROR_R_CHAR_P /* GNU variant can return a pointer outside the passed buffer */ + s = strerror_r(err, buf, sizeof(buf)); + #else /* POSIX variant always returns message in buffer */ + (void) strerror_r(err, buf, sizeof(buf)); + #endif + return strprintf("%s (%d)", s, err); + } + #endif +
Additional code error handling
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
update GUICONSTANTS
https://github.com/FeatherCoin/Feathercoin/commit/c2bb55f2fef05129089bf48d12b190f44f2e4ca3
src/qt/guiconstants.h
+ #define QAPP_ORG_NAME "Feathercoin" + #define QAPP_ORG_DOMAIN "feathercoin.com" + #define QAPP_APP_NAME_DEFAULT "Feathercoin-Qt" + #define QAPP_APP_NAME_TESTNET "Feathercoin-Qt-testnet"
Code replaced Feathercoin name change
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
update SECRET_KEY commit
https://github.com/FeatherCoin/Feathercoin/commit/6b63d986fc8389b1dd73d450406e731f2a0fc679
src/chainparams.cpp
+ base58Prefixes[SECRET_KEY] = list_of(142);// 14 + 128 + base58Prefixes[EXT_PUBLIC_KEY] = list_of(0x04)(0x88)(0xBC)(0x26); + base58Prefixes[EXT_SECRET_KEY] = list_of(0x04)(0x88)(0xDA)(0xEE);
Replace Bitcoin code
+ base58Prefixes[SECRET_KEY] = list_of(193);//65+128
Replace Bitcoin code
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
update SECRET_KEY commit
https://github.com/FeatherCoin/Feathercoin/commit/6b63d986fc8389b1dd73d450406e731f2a0fc679
src/rpcmisc.cpp
+ "1. \"bitcoinaddress\" (string, required) The bitcoin address to use for the signature.\n"
Name change to Feathercoin