[Dev] Documenting Feathercoin Specific Software settings - Part 1
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
https://github.com/FeatherCoin/Feathercoin/commit/412dfc58f714dab14edc7108be77b160d82efc01
main.h
Main header contains a number of important settings changes. May be worth maintaining our own and manually patching further changes.
+// Copyright (c) 2013-2014 The Feathercoin developers
Copyright needs updating. Automatic way to update Copyright? Add to release check list?
#include "core.h" #include "net.h" #include "script.h" + #include "scrypt.h" #include "sync.h" #include "txmempool.h" #include "uint256.h"
Here are all the header #includes, scrypt is added to main.h.
/** The maximum allowed size for a serialized block, in bytes (network rule) */ static const unsigned int MAX_BLOCK_SIZE = 1000000; /** Default for -blockmaxsize and -blockminsize, which control the range of sizes the mining code will create **/ - static const unsigned int DEFAULT_BLOCK_MAX_SIZE = 750000; + static const unsigned int DEFAULT_BLOCK_MAX_SIZE = 250000;
The MAX_BLOCK_SIZE is left the same as Bitcoin. DEFAULT_BLOCK_MAX_SIZE is reduced by 1/3 . Probably more in line with LTC. This was probably optimal when block times were 2.5 minute. Left at original (scrypt) value since changing it may cause blockchain issues, if altered after “Genesis” block.
static const unsigned int DEFAULT_BLOCK_MIN_SIZE = 0; /** Default for -blockprioritysize, maximum space for zero/low-fee transactions **/ - static const unsigned int DEFAULT_BLOCK_PRIORITY_SIZE = 50000; + static const unsigned int DEFAULT_BLOCK_PRIORITY_SIZE = 17000;
The DEFAULT_BLOCK_PRIORITY_SIZE is adjusted from 50000 to 17000
/** The maximum size for transactions we're willing to relay/mine */ static const unsigned int MAX_STANDARD_TX_SIZE = 100000; /** The maximum allowed number of signature check operations in a block (network rule) */
The maximum transfer size remains the unchanged from Bitcoin.
static const unsigned int MAX_BLOCK_SIGOPS = MAX_BLOCK_SIZE/50; - /** The maximum number of orphan transactions kept in memory */ + /** Default for -maxorphantx, maximum number of orphan transactions kept in memory */ - static const unsigned int MAX_ORPHAN_TRANSACTIONS = MAX_BLOCK_SIZE/100; + static const unsigned int DEFAULT_MAX_ORPHAN_TRANSACTIONS = 100; - /** The maximum number of orphan blocks kept in memory */ + /** Default for -maxorphanblocks, maximum number of orphan blocks kept in memory */ - static const unsigned int MAX_ORPHAN_BLOCKS = 750; + static const unsigned int DEFAULT_MAX_ORPHAN_BLOCKS = 750;
Here there is an interface change DEFAULT_MAX_ORPHAN_TRANSACTIONS is given a value instead of being calculated. Part of the (scrypt?) orphan interface change.
/** The maximum size of a blk?????.dat file (since 0.8) */ static const unsigned int MAX_BLOCKFILE_SIZE = 0x8000000; // 128 MiB static const unsigned int MAX_BLOCKFILE_SIZE = 0x8000000; // 128 MiB /** The pre-allocation chunk size for blk?????.dat files (since 0.8) */ /** The pre-allocation chunk size for blk?????.dat files (since 0.8) */ static const unsigned int BLOCKFILE_CHUNK_SIZE = 0x1000000; // 16 MiB static const unsigned int BLOCKFILE_CHUNK_SIZE = 0x1000000; // 16 MiB /** The pre-allocation chunk size for rev?????.dat files (since 0.8) */ /** The pre-allocation chunk size for rev?????.dat files (since 0.8) */ static const unsigned int UNDOFILE_CHUNK_SIZE = 0x100000; // 1 MiB static const unsigned int UNDOFILE_CHUNK_SIZE = 0x100000; // 1 MiB
This section defines the (blockchain) database files size and parameters. Unchanged for FTC.
+ /** Dust Soft Limit, allowed with additional fee per output */ + static const int64_t DUST_SOFT_LIMIT = COIN; + /** Dust Hard Limit, ignored as wallet inputs (mininput default) */ +static const int64_t DUST_HARD_LIMIT = 1000000;
DUST_SOFT_LIMIT is included and set to he variable COIN. ?? where is COIN defined?
/** Coinbase transaction outputs can only be spent after this number of new blocks (network rule) */ - static const int COINBASE_MATURITY = 100; + static const int COINBASE_MATURITY = 30; + /** Coinbase maturity after block 145000 **/ + static const int COINBASE_MATURITY_NEW = 60*4; + /** Block at which COINBASE_MATURITY_NEW comes into effect **/ + static const int COINBASE_MATURITY_SWITCH = 145000;
Scrypt coinbase interface change.
/** Threshold for nLockTime: below this value it is interpreted as block number, otherwise as UNIX timestamp. */ static const unsigned int LOCKTIME_THRESHOLD = 500000000; // Tue Nov 5 00:53:20 1985 UTC /** Maximum number of script-checking threads allowed */ @@ -67,6 +79,14 @@ (static const int MAX_BLOCKS_IN_TRANSIT_PER_PEER = 128;) /** Timeout in seconds before considering a block download peer unresponsive. */ static const unsigned int BLOCK_DOWNLOAD_TIMEOUT = 60;
This code remains similar. MAX_BLOCKS_IN_TRANSIT_PER_PEER removed because of scrypt interface?
+ /** AuxPow Block versions for sanity checks. */ + /** bare AuxPoW block version which will be modulated further. */ + static const int BLOCK_VERSION_AUXPOW_BARE = CBlockHeader::CURRENT_VERSION | (AUXPOW_CHAIN_ID * BLOCK_VERSION_CHAIN_START); + /** version when AuxPoW exists on the block */ + static const int BLOCK_VERSION_AUXPOW_WITH_AUX = BLOCK_VERSION_AUXPOW_BARE | BLOCK_VERSION_AUXPOW; + /** version when no AuxPoW exists on the block */ + static const int BLOCK_VERSION_AUXPOW_WITHOUT_AUX = BLOCK_VERSION_AUXPOW_BARE & ~BLOCK_VERSION_AUXPOW; +
Additional code for Scrypt AuxPOW - used for Dogecoin?
- /** Get the number of active peers */ - int GetNumBlocksOfPeers();
GetNumBlocksOfPeers is removed.
// Large (in bytes) low-priority (new, small-coin) transactions // need a fee. - return dPriority > COIN * 144 / 250; + return dPriority > 100 * COIN * 1440 / 250; // Feathercoin: 1440 blocks found a day. Priority cutoff is 100 feathercoin day / 250 bytes.
Alter dPriority to FTC settings.
+ /** Get the maturity depth for coinbase transactions at a given height. + @param[in] nHeight The height at which to check maturity for + @return the depth at which the coinbase transaction matures + */ + // Dogecoin specific implementation, standardizes checks for the hard maturity change at block 145k + int GetRequiredMaturityDepth(int nHeight);
Include Maturity depth for scrypt interface changes.
// Check whether all inputs of this transaction are valid (no double spends, scripts & sigs, amounts) // This does not modify the UTXO set. If pvChecks is not NULL, script checks are pushed onto it // instead of being performed inline. filein >> hashChecksum;
Here is where the transactions are checked, unchanged for FTC.
- return error("%s : Deserialize or I/O error - %s", __PRETTY_FUNCTION__, e.what()); + return error("%s : Deserialize or I/O error - %s", __func__, e.what());
Here is another error output interface fix.
+// Get the block at which AuxPoW is enabled for this network +int GetAuxPowStartBlock();
Code for Auxilliary POW (scrypt)
// Context-independent validity checks - bool CheckBlock(const CBlock& block, CValidationState& state, bool fCheckPOW = true, bool fCheckMerkleRoot = true); + bool CheckBlockHeader(const CBlockHeader& block, CValidationState& state, int nHeight, bool fCheckPOW = true); + bool CheckBlock(const CBlock& block, CValidationState& state, int nHeight, bool fCheckPOW = true, bool fCheckMerkleRoot = true);
Additional scrypt validity checks.
// Store block on disk // if dbp is provided, the file is known to already reside on disk - bool AcceptBlock(CBlock& block, CValidationState& state, CDiskBlockPos* dbp = NULL); + bool AcceptBlock(CBlock& block, CValidationState& state, CBlockIndex **pindex, CDiskBlockPos* dbp = NULL); + bool AcceptBlockHeader(CBlockHeader& block, CValidationState& state, CBlockIndex **ppindex= NULL); +
Block storage to disk is updated for scrypt interface.
+ CBlockHeader GetBlockHeader() const;
A block header function replaces the Bitcoin code.
- CBlockHeader GetBlockHeader() const - { - CBlockHeader block; - block.nVersion = nVersion; - if (pprev) - block.hashPrevBlock = pprev ->GetBlockHash(); - block.hashMerkleRoot = hashMerkleRoot; - block.nTime = nTime; - block.nBits = nBits; - block.nNonce = nNonce; - return block;
A block header function replaces the Bitcoin code .
- return CheckProofOfWork(GetBlockHash(), nBits); + /** Scrypt is used for block proof -of -work, but for purposes of performance the index internally uses sha256. + * This check was considered unneccessary given the other safeguards like the genesis and checkpoints. */ + return true; // return CheckProofOfWork(GetBlockHash(), nBits);
Scrypt POW
+ // Check whether this block index entry is valid up to the passed validity level. + bool IsValid(enum BlockStatus nUpTo = BLOCK_VALID_TRANSACTIONS) const + { + assert(!(nUpTo & ~BLOCK_VALID_MASK)); // Only validity flags allowed. + if (nStatus & BLOCK_FAILED_MASK) + return false; + return ((nStatus & BLOCK_VALID_MASK) >= nUpTo); + } + + // Raise the validity level of this block index entry. + // Returns true if the validity was changed. + bool RaiseValidity(enum BlockStatus nUpTo) + { + assert(!(nUpTo & ~BLOCK_VALID_MASK)); // Only validity flags allowed. + if (nStatus & BLOCK_FAILED_MASK) + return false; + if ((nStatus & BLOCK_VALID_MASK) < nUpTo) { + nStatus = (nStatus & ~BLOCK_VALID_MASK) | nUpTo; + return true; + } + return false;
Scrypt Validation code.
- std::string ToString() const + std::string ToString() const; // moved code to main.cpp - { - std::string str = "CDiskBlockIndex("; - str += CBlockIndex::ToString(); - str += strprintf("\n hashBlock=%s, hashPrev=%s)", - GetBlockHash().ToString().c_str(), - hashPrev.ToString().c_str()); - return str;
ToString() function moved o main.cpp
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
https://github.com/FeatherCoin/Feathercoin/commit/1db406e12b2506d0ecf554f7eccdec30ba1f29af
alert.h
FTC Copyright needs update.
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
https://github.com/FeatherCoin/Feathercoin/commit/55dacecae05dacfc1524c2e1be8847455af3499b
core.h
FTC Copyright needs update.
+ #include "scrypt.h"
Scrypt header included
+ class CAuxPow; + + template <typename Stream> + int ReadWriteAuxPow(Stream& s, const boost::shared_ptr<CAuxPow>& auxpow, int nType, int nVersion, CSerActionSerialize ser_action); + + template <typename Stream> + int ReadWriteAuxPow(Stream& s, boost::shared_ptr<CAuxPow>& auxpow, int nType, int nVersion, CSerActionUnserialize ser_action); + + template <typename Stream> + int ReadWriteAuxPow(Stream& s, const boost::shared_ptr<CAuxPow>& auxpow, int nType, int nVersion, CSerActionGetSerializeSize ser_action); + + // primary version, Feathercoin unuse + static const int BLOCK_VERSION_DEFAULT = (1 << 0); + static const int BLOCK_VERSION_AUXPOW = (1 << 8); + static const int BLOCK_VERSION_CHAIN_START = (1 << 16); + static const int BLOCK_VERSION_CHAIN_END = (1 << 30); + + // DogeCoin aux chain ID = 0x0062 (98), Feathercoin unuse + static const int AUXPOW_CHAIN_ID = 0x0062; + static const int AUXPOW_START_MAINNET = 371337; + static const int AUXPOW_START_TESTNET = 158100;
Scrypt Aux POW code and settings.
/** No amount larger than this (in satoshi) is valid */ - static const int64_t MAX_MONEY = 21000000 * COIN; + static const int64_t MAX_MONEY = 336000000 * COIN;
Largest valid amount changed.
/** An outpoint - a combination of a transaction hash and an index n into its vout */ class CTxOut // need a CTxIn of at least 148 bytes to spend, // need a CTxIn of at least 148 bytes to spend, // so dust is a txout less than 546 satoshis // so dust is a txout less than 546 satoshis // with default nMinRelayTxFee. // with default nMinRelayTxFee. - return ((nValue*1000)/(3*((int)GetSerializeSize(SER_DISK,0) + 148)) < nMinRelayTxFee); + //return ((nValue*1000)/(3*((int)GetSerializeSize(SER_DISK,0) + 148)) < nMinRelayTxFee); + + //Feathercoin IsDust() detection disabled + return false;
Define if it is a dust payment.
- std::string ToString() const; + std::string ToString() const;
Don’t know why this was done.
+ int GetChainID() const + { + return nVersion / BLOCK_VERSION_CHAIN_START; + } + + void SetAuxPow(CAuxPow* pow);
int GetChainID() included for scrypt interface.
+ + uint256 GetPoWHash() const + { + uint256 thash; + scrypt_1024_1_1_256(BEGIN(nVersion), BEGIN(thash)); + return thash; + }
GetPoWHash() include for scrypt interface changes.
+ bool CheckProofOfWork(int nHeight) const;
CheckProofOfWork included for scrypt interface changes.
+ uint256 GetPoWHash() const + { + uint256 thash; + scrypt_1024_1_1_256(BEGIN(nVersion), BEGIN(thash)); + return thash; + }
Scrypt interface changes
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
https://github.com/FeatherCoin/Feathercoin/commit/e9b6b652993ef80ad020be3c8a4420f11199ee3f
rpcnet.cpp
if (!(stats.addrLocal.empty())) obj.push_back(Pair("addrlocal", stats.addrLocal)); obj.push_back(Pair("addrlocal", stats.addrLocal)); obj.push_back(Pair("services", strprintf("%08x", stats.nServices))); obj.push_back(Pair("services", strprintf("%08x", stats.nServices)));
These remain the same
- obj.push_back(Pair("lastsend", (boost::int64_t)stats.nLastSend)); - obj.push_back(Pair("lastrecv", (boost::int64_t)stats.nLastRecv)); - obj.push_back(Pair("bytessent", (boost::int64_t)stats.nSendBytes)); - obj.push_back(Pair("bytesrecv", (boost::int64_t)stats.nRecvBytes)); - obj.push_back(Pair("conntime", (boost::int64_t)stats.nTimeConnected));
Removed lines
+ obj.push_back(Pair("lastsend", stats.nLastSend)); + obj.push_back(Pair("lastrecv", stats.nLastRecv)); + obj.push_back(Pair("bytessent", stats.nSendBytes)); + obj.push_back(Pair("bytesrecv", stats.nRecvBytes)); + obj.push_back(Pair("conntime", stats.nTimeConnected));
Interface change from boost.
- + HelpExampleCli("addnode", "\"192.168.0.6:8333\" \"onetry\"") + + HelpExampleCli("addnode", "\"192.168.0.6:9336\" \"onetry\"") - + HelpExampleRpc("addnode", "\"192.168.0.6:8333\", \"onetry\"") + + HelpExampleRpc("addnode", "\"192.168.0.6:9336\", \"onetry\"")
These are the examples shown when using the Debug console, here for addnode. Adjusted for Feathercoins rpc Port.
+ " \"address\" : \"192.168.0.201:9336\", (string) The bitcoin server host and port\n"
Modify port number for FTC in Debug console. Bitcoin code removed. bitcoin reference (in code comment) has not been removed.
- obj.push_back(Pair("totalbytesrecv", static_cast< boost::uint64_t>(CNode::GetTotalBytesRecv()))); - obj.push_back(Pair("totalbytessent", static_cast<boost::uint64_t>(CNode::GetTotalBytesSent()))); - obj.push_back(Pair("timemillis", static_cast<boost::int64_t>(GetTimeMillis())));
Code removed.
+ obj.push_back(Pair("totalbytesrecv", CNode::GetTotalBytesRecv())); + obj.push_back(Pair("totalbytessent", CNode::GetTotalBytesSent())); + obj.push_back(Pair("timemillis", GetTimeMillis())); + return obj; +}
Adding the scrypt interface replacement.
+ Value getnetworkinfo(const Array& params, bool fHelp) + { + if (fHelp || params.size() != 0) + throw runtime_error( + "getnetworkinfo\n" + "Returns an object containing various state info regarding P2P networking.\n" + "\nResult:\n" + "{\n" + " \"version\": xxxxx, (numeric) the server version\n" + " \"protocolversion\": xxxxx, (numeric) the protocol version\n" + " \"timeoffset\": xxxxx, (numeric) the time offset\n" + " \"connections\": xxxxx, (numeric) the number of connections\n" + " \"proxy\": \"host:port\", (string, optional) the proxy used by the server\n" + " \"relayfee\": x.xxxx, (numeric) minimum relay fee for non-free transactions in btc/kb\n" + " \"localaddresses\": [, (array) list of local addresses\n" + " \"address\": \"xxxx\", (string) network address\n" + " \"port\": xxx, (numeric) network port\n" + " \"score\": xxx (numeric) relative score\n" + " ]\n" + "}\n" + "\nExamples:\n" + + HelpExampleCli("getnetworkinfo", "") + + HelpExampleRpc("getnetworkinfo", "") + ); + + proxyType proxy; + GetProxy(NET_IPV4, proxy); + + Object obj; + obj.push_back(Pair("version", (int)CLIENT_VERSION)); + obj.push_back(Pair("protocolversion",(int)PROTOCOL_VERSION)); + obj.push_back(Pair("timeoffset", GetTimeOffset())); + obj.push_back(Pair("connections", (int)vNodes.size())); + obj.push_back(Pair("proxy", (proxy.first.IsValid() ? proxy.first.ToStringIPPort() : string()))); + obj.push_back(Pair("relayfee", ValueFromAmount(CTransaction::nMinRelayTxFee))); + Array localAddresses; + { + LOCK(cs_mapLocalHost); + BOOST_FOREACH(const PAIRTYPE(CNetAddr, LocalServiceInfo) &item, mapLocalHost) + { + Object rec; + rec.push_back(Pair("address", item.first.ToString())); + rec.push_back(Pair("port", item.second.nPort)); + rec.push_back(Pair("score", item.second.nScore)); + localAddresses.push_back(rec); + } + } + obj.push_back(Pair("localaddresses", localAddresses));
getnetworkinfo replacement for scrypt.
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
https://github.com/FeatherCoin/Feathercoin/commit/f4003712b2147b515c073d1a92985161d667cae9
rpcclient.cpp
rpcclient.cpp contains a number of scrypt interface change related settings such as Methods. FTC should maintain a separate file, or such as this could be over writen by changes at head (and pass auto build test).
+ if (strMethod == "setgenerate" && n > 1) ConvertTo<int64_t>(params[1]); - if (strMethod == "getnetworkhashps" && n > 0) ConvertTo<boost::int64_t>(params[0]); + if (strMethod == "getnetworkhashps" && n > 0) ConvertTo<int64_t>(params[0]); - if (strMethod == "getnetworkhashps" && n > 1) ConvertTo<boost::int64_t>(params[1]); + if (strMethod == "getnetworkhashps" && n > 1) ConvertTo<int64_t>(params[1]);
Note : Further similar Methods / see debug console, are defined .
- strUsage += " -conf=<file> " + _("Specify configuration file (default: bitcoin.conf)") + "\n"; + strUsage += " -conf=<file> " + _("Specify configuration file (default: feathercoin.conf)") + "\n";
Name change to .conf file.
- strUsage += " -rpcport=<port> " + _("Connect to JSON-RPC on <port> (default: 8332 or testnet: 18332)") + "\n"; + strUsage += " -rpcport=<port> " + _("Connect to JSON-RPC on <port> (default: 9337 or testnet: 19337)") + "\n";
Setting Feathercoin mining / rpc ports.
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
https://github.com/FeatherCoin/Feathercoin/commit/d58d75a44a95b6b06147bd7f1419c36157d184fa
rpcserver.cpp
A short file with a number of settings changes. Consider build change to FTC version of file when move to head…
+ static std::vector< boost::shared_ptr<ip::tcp::acceptor> > rpc_acceptors;
added static for scrypt interface.
+ "\nStop Feathercoin server."); + return "Feathercoin server stopping";
Update close down messages to say Feathercoin.
/* P2P networking */ + { "getnetworkinfo", &getnetworkinfo, true, false, false },
Added getnetworkinfo for scrypt interface.
/* Block chain and UTXO */ + { "getblockchaininfo", &getblockchaininfo, true, false, false },
Added getblockchaininfo for scrypt interface.
- AcceptedConnection* conn, + boost::shared_ptr< AcceptedConnection > conn, - AcceptedConnectionImpl<Protocol>* conn = new AcceptedConnectionImpl<Protocol>(acceptor->get_io_service(), context, fUseSSL); + boost::shared_ptr< AcceptedConnectionImpl<Protocol> > conn(new AcceptedConnectionImpl<Protocol>(acceptor->get_io_service(), context, fUseSSL));
Updated AcceptedConnection for scrypt interface.
- boost::asio::placeholders::error)); + _1));
Updated Boost error to function?
- AcceptedConnection* conn, + boost::shared_ptr< AcceptedConnection > conn,
Updates to RPCAcceptHandler for the scrypt interface.
// Immediately start accepting new connections, except when we're cancelled or our socket is closed. if (error != asio::error::operation_aborted && acceptor->is_open()) RPCListen(acceptor, context, fUseSSL); - AcceptedConnectionImpl<ip::tcp>* tcp_conn = dynamic_cast< AcceptedConnectionImpl<ip::tcp>* >(conn); + AcceptedConnectionImpl<ip::tcp>* tcp_conn = dynamic_cast< AcceptedConnectionImpl<ip::tcp>* >(conn.get());
Updates to connection error interface.
if (error) { - delete conn; + // TODO: Actually handle errors + LogPrintf("%s: Error: %s\n", __func__, error.message()); }
Updates to connection error interface.
- delete conn; + conn->close(); - ServiceConnection(conn); + ServiceConnection(conn.get()); conn->close();
Further updates to connections handling.
- string strWhatAmI = "To use bitcoind"; + string strWhatAmI = "To use feathercoind";
strWhatAm updated to read feathercoin
- "rpcuser=bitcoinrpc\n" + "rpcuser=feathercoinrpc\n"
rpcuser name change to FTC
- "for example: alertnotify=echo %%s | mail -s \"Bitcoin Alert\" [email protected]\n"), + "for example: alertnotify=echo %%s | mail -s \"Feathercoin Alert\" [email protected]\n"),
name change to FTC, alert messages from admin.
- boost::shared_ptr<ip::tcp::acceptor> acceptor(new ip::tcp::acceptor(*rpc_io_service));
Remove Bitcoin Boost code. Was this moved?
+ rpc_acceptors.push_back(acceptor);
extra line added scrypt acceptance interface.
- acceptor.reset(new ip::tcp::acceptor(*rpc_io_service)); + boost::shared_ptr<ip::tcp::acceptor> acceptor(new ip::tcp::acceptor(*rpc_io_service));
connection interface change to scrypt
+ rpc_acceptors.push_back(acceptor);
additional rpc inspector for scrypt connection interface.
+ // First, cancel all timers and acceptors + // This is not done automatically by ->stop(), and in some cases the destructor of + // asio::io_service can hang if this is skipped. + boost::system::error_code ec; + BOOST_FOREACH(const boost::shared_ptr<ip::tcp::acceptor> &acceptor, rpc_acceptors) + { + acceptor->cancel(ec); + if (ec) + LogPrintf("%s: Warning: %s when cancelling acceptor", __func__, ec.message()); + } + rpc_acceptors.clear(); + BOOST_FOREACH(const PAIRTYPE(std::string, boost::shared_ptr<deadline_timer>) &timer, deadlineTimers) + { + timer.second->cancel(ec); + if (ec) + LogPrintf("%s: Warning: %s when cancelling timer", __func__, ec.message());
Main code of rpc interface change for scrypt.
- return "> bitcoin-cli " + methodname + " " + args + "\n"; + return "> feathercoin-cli " + methodname + " " + args + "\n";
Name change for the feathercoin-cli (replaces feathercoind
- "\"method\": \"" + methodname + "\", \"params\": [" + args + "] }' -H 'content-type: text/plain;' http://127.0.0.1:8332/\n"; + "\"method\": \"" + methodname + "\", \"params\": [" + args + "] }' -H 'content-type: text/plain;' http://127.0.0.1:9337/\n";
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
https://github.com/FeatherCoin/Feathercoin/commit/d58d75a44a95b6b06147bd7f1419c36157d184fa
checkpoints.cpp
Probably should be maintained as FTC specific file. Contains dev included FTC checkpoints, or “know blocks”.
+ ( 1, uint256("0xfdbe99b90c90bae7505796461471d89ae8388ab953997aa06a355bbda8d915cb"))
Example of FTC checkpoint
static const CCheckpointData data = { &mapCheckpoints, - 1389047471, // * UNIX timestamp of last checkpoint block + 1372166807, // * UNIX timestamp of last checkpoint block - 30549816, // * total number of transactions between genesis and last checkpoint + 257285, // * total number of transactions between genesis and last checkpoint // (the tx=... number in the SetBestChain debug.log lines) - 60000.0 // * estimated number of transactions per day after checkpoint + 3450.0 // * estimated number of transactions per day after checkpoint
checkpoint settings customization.
+ if (TestNet()) return true; // Testnet has no checkpoints + if (TestNet()) return NULL; // Testnet has no checkpoints
Switch off checkpoints for testnet
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
https://github.com/FeatherCoin/Feathercoin/commit/c86c18168555458aae830a4baa487184324adae3
util.cpp
Short file consisting of mostly feathercoin / scrypt specific settings. Consider maintaining seperate FTC file integrated at build going forward to head.
+ #include <boost/date_time/posix_time/posix_time.hpp>
Include Boost
- void ParseString(const string& str, char c, vector<string>& v) - { - if (str.empty()) - return; - string::size_type i1 = 0; - string::size_type i2; - while (true) - { - i2 = str.find(c, i1); - if (i2 == str.npos) - { - v.push_back(str.substr(i1)); - return; - } - v.push_back(str.substr(i1, i2 - i1)); - i1 = i2+1; - }
Remove Bitcoin ParseString() function.
- const char* pszModule = "bitcoin"; + const char* pszModule = "feathercoin"
Name change to Feathercoin.
+ // Windows < Vista: C:\Documents and Settings\Username\Application Data\Feathercoin + // Windows >= Vista: C:\Users\Username\AppData\Roaming\Feathercoin + // Mac: ~/Library/Application Support/Feathercoin
Name change directories.
+ return GetSpecialFolderPath(CSIDL_APPDATA) / "Feathercoin";
Name change application directories.
+ return pathRet / "Feathercoin";
Path change
+ return pathRet / ".feathercoin";
Path update name
+ boost::filesystem::path pathConfigFile(GetArg("-conf", "feathercoin.conf"));
Change Boost reference to feathercoin.
+ return; // No feathercoin.conf file is OK
name change in comments?
+ boost::filesystem::path pathPidFile(GetArg("-pid", "feathercoind.pid"));
name change feathercoind
+ void SetupEnvironment() + { + #ifndef WIN32 + try + { + #if BOOST_FILESYSTEM_VERSION == 3 + boost::filesystem::path::codecvt(); // Raises runtime error if current locale is invalid + #else // boost filesystem v2 + std::locale(); // Raises runtime error if current locale is invalid + #endif + } catch(std::runtime_error &e) + { + setenv("LC_ALL", "C", 1); // Force C locale + } + #endif + } + + std::string DateTimeStrFormat(const char* pszFormat, int64_t nTime) + { + // std::locale takes ownership of the pointer + std::locale loc(std::locale::classic(), new boost::posix_time::time_facet(pszFormat)); + std::stringstream ss; + ss.imbue(loc); + ss << boost::posix_time::from_time_t(nTime); + return ss.str();;
Include SetupEnvironment()
+ // First, cancel all timers and acceptors + // This is not done automatically by ->stop(), and in some cases the destructor of + // asio::io_service can hang if this is skipped. + boost::system::error_code ec; + BOOST_FOREACH(const boost::shared_ptr<ip::tcp::acceptor> &acceptor, rpc_acceptors) + { + acceptor->cancel(ec); + if (ec) + LogPrintf("%s: Warning: %s when cancelling acceptor", __func__, ec.message()); + } + rpc_acceptors.clear(); + BOOST_FOREACH(const PAIRTYPE(std::string, boost::shared_ptr<deadline_timer>) &timer, deadlineTimers) + { + timer.second->cancel(ec); + if (ec) + LogPrintf("%s: Warning: %s when cancelling timer", __func__, ec.message());
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
https://github.com/FeatherCoin/Feathercoin/commit/da79a745dcd1b50245d832cf52dfb5a517981e7c
util.h
Short file consisting of mostly feathercoin / scrypt specific settings. Consider maintaining separate FTC file integrated at build going forward to head.
- /* Format characters for (s)size_t, ptrdiff_t. - * - * Define these as empty as the tinyformat - based formatting system is - * type - safe, no special format characters are needed to specify sizes. - */ - #define PRIszx "x" - #define PRIszu "u" - #define PRIszd "d" - #define PRIpdx "x" - #define PRIpdu "u" - #define PRIpdd "d"
Code defining Priszx is removed.
+ void SetupEnvironment();
SetupEnvironment function is included.
- void ParseString(const std::string& str, char c, std::vector<std::string>& v);
Code removed.
+ std::string DateTimeStrFormat(const char* pszFormat, int64_t nTime);
Time format function included.
- inline std::string DateTimeStrFormat(const char* pszFormat, int64_t nTime) -{ - time_t n = nTime; - struct tm* ptmTime = gmtime(&n); - char pszTime[200]; - strftime(pszTime, sizeof(pszTime), pszFormat, ptmTime); - return pszTime; -}
Bitcoin time definition code is removed.
+ std::string s = strprintf("feathercoin-%s", name);
Name change to Feathercoin. Bitcoin code removed.
+ std::string s = strprintf("feathercoin-%s", name);
Name change to Feathercoin. Bitcoin code removed.
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
https://github.com/FeatherCoin/Feathercoin/commit/43997d510b900f6eeca0d82545bf902f3b104349
init.cpp
Init.cpp is the main program loop?. Short file consisting of mostly feathercoin / scrypt specific settings. Consider maintaining separate FTC file integrated at build going forward to head.
+ // Copyright (c) 2014 The Feathercoin developers
Copyright needs update
+ #include "key.h" + #include <stdio.h>
Extra files included,
RenameThread("feathercoin-shutoff");
Thread name change to Feathercoin. Bitcoin line removed.
+ strUsage += " -conf=<file> " + _("Specify configuration file (default: feathercoin.conf)") + "\n";
Name change to Feathercoin. Bitcoin code removed.
- strUsage += " -keypool=<n> " + _("Set key pool size to <n> (default: 100)") + "\n";
Remove Bitcoin keypool size settings.
+ strUsage += " -maxorphanblocks=<n> " + strprintf(_("Keep at most <n> unconnectable blocks in memory (default: %u)"), DEFAULT_MAX_ORPHAN_BLOCKS) + "\n"; + strUsage += " -maxorphantx=<n> " + strprintf(_("Keep at most <n> unconnectable transactions in memory (default: %u)"), DEFAULT_MAX_ORPHAN_TRANSACTIONS) + "\n";
Include the Scrypt interface for orphans.
+ strUsage += " -pid=<file> " + _("Specify pid file (default: feathercoind.pid)") + "\n";
Name change to Feathercoin. Bitcoin code removed.
- strUsage += " -dnsseed " + _("Find peers using DNS lookup (default: 1 unless -connect)") + "\n";
Bitcoin dnsseed handling removed
+ strUsage += " -dnsseed " + _("Query for peer addresses via DNS lookup, if low on addresses (default: 1 unless -connect)") + "\n"; + strUsage += " -forcednsseed " + _("Always query for peer addresses via DNS lookup (default: 0)") + "\n";
Scrypt interface for dnsseed handling included.
- strUsage += " -port=<port> " + _("Listen for connections on <port> (default: 8333 or testnet: 18333)") + "\n"; + strUsage += " -port=<port> " + _("Listen for connections on <port> (default: 9336 or testnet: 19336)") + "\n";
Port message is updated to Feathercoin Ports.
+ strUsage += " -keypool=<n> " + _("Set key pool size to <n> (default: 100)") + "\n";
keypool code is included? was bitcoin code earlier?
+#ifdef ENABLE_WALLET
if definition included, so action only taken if wallet open.
strUsage += " -gen " + _("Generate coins (default: 0)") + "\n"; strUsage += " -genproclimit=<n> " + _("Set the processor limit for when generation is on (-1 = unlimited, default: -1)") + "\n";
Disabled unless in a FTC wallet.
+ strUsage += " -rpcport=<port> " + _("Listen for JSON-RPC connections on <port> (default: 9337 or testnet: 19337)") + "\n";
Active port message rename
+ RenameThread("feathercoin-loadblk"); if (fReindex) { + /** Sanity checks + * Ensure that Bitcoin is running in a usable environment with all + * necessary library support. + */ + bool InitSanityCheck(void) + { + if(!ECC_InitSanityCheck()) { + InitError("OpenSSL appears to lack support for elliptic curve cryptography. For more " + "information, visit https://en.bitcoin.it/wiki/OpenSSL_and_EC_Libraries"); + return false; + } + + // TODO: remaining sanity checks, see #4081 + + return true; + } + + /** Initialize feathercoin.
Feathercoin specific database re-index code is included.
+ setvbuf(stdout, NULL, _IOLBF, 0);
setvbuf included , scrypt interface? error message?
+ // Make sure only a single feathercoin process is using the data directory.
Comment name change.
+ return InitError(strprintf(_("Cannot obtain a lock on data directory %s. Feathercoin Core is probably already running."), strDataDir));
error message name change to Feathercoin. Bitcoin code removed
+ LogPrintf("Feathercoin version %s (%s)\n", FormatFullVersion(), CLIENT_DATE);
Name change to Feathercoin. Bitcoin code removed.
+ #ifdef ENABLE_WALLET + LogPrintf("Using BerkeleyDB version %s\n", DbEnv::version(0, 0, 0)); + #endif
Include an extra error message re database type.
- #if defined(USE_IPV6) - #if ! USE_IPV6 - else - SetLimited(NET_IPV6); - #endif
Bitcoin code to handle ipv6 is removed.
- #ifdef USE_IPV6 if (!IsLimited(NET_IPV6))
An IPv6 ifdef is removed, but inside is – if ipv6 anyway, is this change needed? review IPv6 for head
-# ifdef USE_IPV6 fBound |= Bind(CService(in6addr_any, GetListenPort()), BF_NONE);
The if def is removed so an IPv6 function? runs on IPv4?
+ strErrors << _("Error loading wallet.dat: Wallet requires newer version of Feathercoin") << "\n";
Name change to Feathercoin error message. Bitcoin code replaced.
+ strErrors << _("Wallet needed to be rewritten: restart Feathercoin to complete") << "\n";
Name change to Feathercoin error message. Bitcoin code replaced.
+ LogPrintf("mapBlockIndex.size() = %u\n", mapBlockIndex.size());
Name change to Feathercoin error message. Bitcoin code replaced.
- LogPrintf("setKeyPool.size() = %"PRIszu"\n", pwalletMain ? pwalletMain->setKeyPool.size() : 0); - LogPrintf("mapWallet.size() = %"PRIszu"\n", pwalletMain ? pwalletMain->mapWallet.size() : 0); - LogPrintf("mapAddressBook.size() = %"PRIszu"\n", pwalletMain ? pwalletMain->mapAddressBook.size() : 0);
Name change Bitcoin code replaced.
+ LogPrintf("setKeyPool.size() = %u\n", pwalletMain ? pwalletMain->setKeyPool.size() : 0); + LogPrintf("mapWallet.size() = %u\n", pwalletMain ? pwalletMain->mapWallet.size() : 0); + LogPrintf("mapAddressBook.size() = %u\n", pwalletMain ? pwalletMain->mapAddressBook.size() : 0);
Feathercoin name change.
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
https://github.com/FeatherCoin/Feathercoin/commit/d46f1eec796bc422c4b7ccc2879aede80e1c2ff9
net.cpp
File consisting of a lot of feathercoin / scrypt specific settings. Consider maintaining separate FTC file integrated at build going forward to head.
- struct LocalServiceInfo { - int nScore; - int nPort; - } ;
Bitcoincode removed
- static CCriticalSection cs_mapLocalHost; - static map<CNetAddr, LocalServiceInfo> mapLocalHost; + CCriticalSection cs_mapLocalHost; + map<CNetAddr, LocalServiceInfo> mapLocalHost;
The static definition is removed ? why? (scrypt interface?)
+ LogPrint("net", "recv failed: %s\n", NetworkErrorString(nErr));
Log message interface change
- for (int nHost = 1; nHost <= 2; nHost++) + for (int nHost = 1; nHost <= 1; nHost++) // We should be phasing out our use of sites like these. If we need // replacements, we should ask for volunteers to put this simple
nHost lower limit before incrementation changed.
- else if (nHost == 2) - { - addrConnect = CService("74.208.43.192", 80); // www.showmyip.com - - if (nLookup == 1) - { - CService addrIP("www.showmyip.com", 80, true); - if (addrIP.IsValid()) - addrConnect = addrIP; - } - - pszGet = "GET /simple/ HTTP/1.1\r\n" - "Host: www.showmyip.com\r\n" - "User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)\r\n" - "Connection: close\r\n" - "\r\n"; - - pszKeyword = NULL; // Returns just IP address - }
Bitcoin CService removed
+ LogPrintf("ConnectSocket() : ioctlsocket non-blocking setting failed, error %s\n", NetworkErrorString(WSAGetLastError()));
Log interface change. Bitcoin code replaced.
+ LogPrintf("ConnectSocket() : fcntl non-blocking setting failed, error %s\n", NetworkErrorString(errno));
Log interface change. Bitcoin code replaced.
+ LogPrintf("socket send error %s\n", NetworkErrorString(nErr));
Log interface change. Bitcoin code replaced.
-#ifdef USE_IPV6 struct sockaddr_storage sockaddr; -#else - struct sockaddr sockaddr; -#endif
If IPV6 removed so runs under iPv4
+ LogPrintf("socket error accept failed: %s\n", NetworkErrorString(nErr));
Log interface change. Bitcoin code replaced.
- { - LOCK(cs_setservAddNodeAddresses); - if (!setservAddNodeAddresses.count(addr)) - closesocket(hSocket); - }
Bitcoin lock interface removed
+ closesocket(hSocket);
hSocket code added.
+ LogPrintf("socket recv error %s\n", NetworkErrorString(nErr));
Log interface change. Bitcoin code replaced.
- - MilliSleep(10);
A sleep loop is removed.
+ string strDesc = "Feathercoin " + FormatFullVersion();
Name change to Feathercoin.
+ // goal: only query DNS seeds if address need is acute + if ((addrman.size() > 0) && + (!GetBoolArg("-forcednsseed", false))) { + MilliSleep(11 * 1000); + + LOCK(cs_vNodes); + if (vNodes.size() >= 2) { + LogPrintf("P2P peers available. Skipped DNS seeding.\n"); + return; + } + } +
DNS code added.
- double static NodeSyncScore(const CNode *pnode) { + static int64_t NodeSyncScore(const CNode *pnode) { - return -pnode->nLastRecv; + return pnode->nLastRecv;
Bug fix, need more info on this change? interface change?
- double dBestScore = 0; + int64_t nBestScore = 0;
Bestscore interface change.
// if ok, compare node's score with the best so far - double dScore = NodeSyncScore(pnode); + int64_t nScore = NodeSyncScore(pnode); - if (pnodeNewSync == NULL || dScore > dBestScore) { + if (pnodeNewSync == NULL || nScore > nBestScore) { pnodeNewSync = pnode; pnodeNewSync = pnode; - dBestScore = dScore; + nBestScore = nScore;
Best score interface implemented. (scrypt interface change?)
- #ifdef USE_IPV6 struct sockaddr_storage sockaddr;
If statements removed for IPv6
+ strError = strprintf("Error: Couldn't open socket for incoming connections (socket returned error %s)", NetworkErrorString(WSAGetLastError()));
error interface change.
+ strError = strprintf("Error: Couldn't set properties on socket for incoming connections (error %s)", NetworkErrorString(WSAGetLastError()));
error interface change.
- #ifdef USE_IPV6 // some systems don't have IPV6_V6ONLY but are always v6only; others do have the option
if IPv6 removed
strError = strprintf(_("Unable to bind to %s on this computer. Feathercoin Core is probably already running."), addrBind.ToString());
Name change Bitcoin code removed
+ strError = strprintf(_("Unable to bind to %s on this computer (bind returned error %s)"), addrBind.ToString(), NetworkErrorString(nErr));
Name change Bitcoin code removed
+ strError = strprintf(_("Error: Listening for incoming connections failed (listen returned error %s)"), NetworkErrorString(WSAGetLastError()));
Name change Bitcoin code removed
- #ifdef USE_IPV6 else if (ifa->ifa_addr->sa_family == AF_INET6)
if IPv6 removed
+ LogPrintf("closesocket(hListenSocket) failed with error %s\n", NetworkErrorString(WSAGetLastError()));
Log print interface change
+ return error("%s : Failed to open file %s", __func__, pathTmp.string());
error print interface change
+ return error("%s : Serialize or I/O error - %s", __func__, e.what()); + return error("%s : Rename-into-place failed", __func__); + return error("%s : Failed to open file %s", __func__, pathAddr.string()); + return error("%s : Checksum mismatch, data corrupted", __func__); + return error("%s : Invalid network magic number", __func__); + return error("%s : Deserialize or I/O error - %s", __func__, e.what());
error print interface change
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
https://github.com/FeatherCoin/Feathercoin/commit/9cde7d1d32e266d8b98cc0b28750e9dcd8cb3cf9
miner.cpp
File consisting of a lot of feathercoin / scrypt specific settings. Consider maintaining separate FTC file integrated at build going forward to head.
+ #include "scrypt.h" + #include "auxpow.h"
Scrypt and Auxilliary proof of work is included.
+ pblock->vtx[0].vin[0].scriptSig = (CScript() << nHeight << CScriptNum(nExtraNonce)) + COINBASE_FLAGS;
Script interface change.
+ LogPrintf("FeathercoinMiner:\n");
Name change to Feathercoin.
+ return error("FeathercoinMiner : generated block is stale");
Error message interface change.
+ void static FeathercoinMiner(CWallet *pwallet)
Feathercoin interface change
+ LogPrintf("FeathercoinMiner started\n"); SetThreadPriority(THREAD_PRIORITY_LOWEST); + RenameThread("feathercoin-miner"); + LogPrintf("Running FeathercoinMiner with %u transactions in block (%u bytes)\n", pblock->vtx.size(),
LogPrint interface change.
- unsigned int nNonceFound; - // Crypto++ SHA256 - nNonceFound = ScanHash_CryptoPP(pmidstate, pdata + 64, phash1, - (char*)&hash, nHashesDone); - // Check if something found - if (nNonceFound != (unsigned int) -1) { - for (unsigned int i = 0; i < sizeof(hash)/4; i++) - ((unsigned int*)&hash)[i] = ByteReverse(((unsigned int*)&hash)[i]); - pblock->nNonce = ByteReverse(nNonceFound); - assert(hash == pblock->GetHash());
Bitcoin interface removed.
+ uint256 thash; + char scratchpad[SCRYPT_SCRATCHPAD_SIZE]; + while (true) + scrypt_1024_1_1_256_sp(BEGIN(pblock->nVersion), BEGIN(thash), scratchpad); + + if (thash <= hashTarget) + pblock->nNonce += 1; + nHashesDone += 1; + if ((pblock->nNonce & 0xFF) == 0) + break;
Include Scrypt interface.
+ LogPrintf("FeathercoinMiner terminated\n"); + minerThreads->create_thread(boost::bind(&FeathercoinMiner, pwallet));
Name change interface changes to Feathercoin
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
https://github.com/FeatherCoin/Feathercoin/commit/a72b6f6608ef3bca7cdc60cd08d96e5730906b90
coins.h
File consisting of a lot of feathercoin / scrypt specific settings. Consider maintaining separate FTC file integrated at build going forward to head.
+ * * 8358: compact amount representation for 60000000000 (600 FTC) + * * 86ef97d579: compact amount representation for 234925952 (2.35 FTC) + * * bbd123: compact amount representation for 110397 (0.001 FTC)
Feathercoin specific changes, Bitcoin code is replaced.
+ /** Amount of feathercoins coming in to a transaction
Comment name update to Feathercoin, are comment changes neccessary?
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
https://github.com/FeatherCoin/Feathercoin/commit/f44fd83ef4d029bde85b37d9aa5f013c19b09e33
core.cpp
+ #include "auxpow.h"
Include auxiliary proof of work header. For scrypt interface
+ str += strprintf("CTransaction(hash=%s, ver=%d, vin.size=%u, vout.size=%u, nLockTime=%u)\n",
print Interface change. Bitcoin code removed
+ LogPrintf("CBlock(hash=%s, ver=%d, hashPrevBlock=%s, hashMerkleRoot=%s, nTime=%u, nBits=%08x, nNonce=%u, vtx=%u)\n",
Print Interface change. Bitcoin code removed
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
https://github.com/FeatherCoin/Feathercoin/commit/8fbccd63ab2ea5736499fd79072e37f0f8f62063
feathercoin-cli.cpp
feathercoin-cli.cpp is a new file, from Litecoin? Maintain separately / cherry pick?
+ // Copyright (c) 2009-2010 Satoshi Nakamoto + // Copyright (c) 2009-2013 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 "util.h" + #include "init.h" + #include "rpcclient.h" + #include "rpcprotocol.h" + #include "ui_interface.h" /* for _(...) */ + #include "chainparams.h" + + #include <boost/filesystem/operations.hpp> + + ////////////////////////////////////////////////////////////////////////////// + // + // Start + // + static bool AppInitRPC(int argc, char* argv[]) + { + // + // Parameters + // + ParseParameters(argc, argv); + if (!boost::filesystem::is_directory(GetDataDir(false))) + { + fprintf(stderr, "Error: Specified data directory \"%s\" does not exist.\n", mapArgs["-datadir"].c_str()); + return false; + } + try { + ReadConfigFile(mapArgs, mapMultiArgs); + } catch(std::exception &e) { + fprintf(stderr,"Error reading configuration file: %s\n", e.what()); + return false; + } + // Check for -testnet or -regtest parameter (TestNet() calls are only valid after this clause) + if (!SelectParamsFromCommandLine()) { + fprintf(stderr, "Error: Invalid combination of -regtest and -testnet.\n"); + return false; + } + + if (argc<2 || mapArgs.count("-?") || mapArgs.count("--help")) + { + // First part of help message is specific to RPC client + std::string strUsage = _("Feathercoin Core RPC client version") + " " + FormatFullVersion() + "\n\n" + + _("Usage:") + "\n" + + " feathercoin-cli [options] <command> [params] " + _("Send command to Feathercoin Core") + "\n" + + " feathercoin-cli [options] help " + _("List commands") + "\n" + + " feathercoin-cli [options] help <command> " + _("Get help for a command") + "\n"; + + strUsage + = "\n" + HelpMessageCli(true); + + fprintf(stdout, "%s", strUsage.c_str()); + return false; + } + return true; + } + + int main(int argc, char* argv[]) + { + SetupEnvironment(); + + try + { + if(!AppInitRPC(argc, argv)) + return abs(RPC_MISC_ERROR); + } + catch (std::exception& e) { + PrintExceptionContinue(&e, "AppInitRPC()"); + return abs(RPC_MISC_ERROR); + } catch (...) { + PrintExceptionContinue(NULL, "AppInitRPC()"); + return abs(RPC_MISC_ERROR); + } + + int ret = abs(RPC_MISC_ERROR); + try + { + ret = CommandLineRPC(argc, argv); + } + catch (std::exception& e) { + PrintExceptionContinue(&e, "CommandLineRPC()"); + } catch (...) { + PrintExceptionContinue(NULL, "CommandLineRPC()"); + } + return ret; + }
Copyright needs updating.
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
https://github.com/FeatherCoin/Feathercoin/commit/fe121c87cc28b2c1b07fd11559494edefcfd666a
feathercoind.cpp
feathercoind.cpp is a new file, from Litecoin? Maintain separately / cherry pick?
+ // Copyright (c) 2009-2010 Satoshi Nakamoto + // Copyright (c) 2009-2013 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 "util.h" + #include "init.h" + #include "rpcclient.h" + #include "rpcprotocol.h" + #include "ui_interface.h" /* for _(...) */ + #include "chainparams.h" + + #include <boost/filesystem/operations.hpp> + + ////////////////////////////////////////////////////////////////////////////// + // + // Start + // + static bool AppInitRPC(int argc, char* argv[]) + { + // + // Parameters + // + ParseParameters(argc, argv); + if (!boost::filesystem::is_directory(GetDataDir(false))) + { + fprintf(stderr, "Error: Specified data directory \"%s\" does not exist.\n", mapArgs["-datadir"].c_str()); + return false; + } + try { + ReadConfigFile(mapArgs, mapMultiArgs); + } catch(std::exception &e) { + fprintf(stderr,"Error reading configuration file: %s\n", e.what()); + return false; + } + // Check for -testnet or -regtest parameter (TestNet() calls are only valid after this clause) + if (!SelectParamsFromCommandLine()) { + fprintf(stderr, "Error: Invalid combination of -regtest and -testnet.\n"); + return false; + } + + if (argc<2 || mapArgs.count("-?") || mapArgs.count("--help")) + { + // First part of help message is specific to RPC client + std::string strUsage = _("Feathercoin Core RPC client version") + " " + FormatFullVersion() + "\n\n" + + _("Usage:") + "\n" + + " feathercoin-cli [options] <command> [params] " + _("Send command to Feathercoin Core") + "\n" + + " feathercoin-cli [options] help " + _("List commands") + "\n" + + " feathercoin-cli [options] help <command> " + _("Get help for a command") + "\n"; + + strUsage + = "\n" + HelpMessageCli(true); + + fprintf(stdout, "%s", strUsage.c_str()); + return false; + } + return true; + } + + int main(int argc, char* argv[]) + { + SetupEnvironment(); + + try + { + if(!AppInitRPC(argc, argv)) + return abs(RPC_MISC_ERROR); + } + catch (std::exception& e) { + PrintExceptionContinue(&e, "AppInitRPC()"); + return abs(RPC_MISC_ERROR); + } catch (...) { + PrintExceptionContinue(NULL, "AppInitRPC()"); + return abs(RPC_MISC_ERROR); + } + + int ret = abs(RPC_MISC_ERROR); + try + { + ret = CommandLineRPC(argc, argv); + } + catch (std::exception& e) { + PrintExceptionContinue(&e, "CommandLineRPC()"); + } catch (...) { + PrintExceptionContinue(NULL, "CommandLineRPC()"); + } + return ret; + }
Copyright needs update.
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
https://github.com/FeatherCoin/Feathercoin/commit/82bcdec1e61e0aca27fc63b357735d3ab59c7434
bitcoin-config.h
bitcoin-config.h is a new file, from Litecoin? Maintain separately / cherry pick?
This could be specified as an alternate file at build time? Is it auto generated?
+ /* src/bitcoin-config.h. Generated from bitcoin-config.h.in by configure. */ + /* src/bitcoin-config.h.in. Generated from configure.ac by autoheader. */ + + #ifndef BITCOIN_CONFIG_H + + #define BITCOIN_CONFIG_H + + /* Define if building universal (internal helper macro) */ + /* #undef AC_APPLE_UNIVERSAL_BUILD */ + + /* Version Build */ + #define CLIENT_VERSION_BUILD 0 + + /* Version is release */ + #define CLIENT_VERSION_IS_RELEASE true + + /* Major version */ + #define CLIENT_VERSION_MAJOR 0 + + /* Minor version */ + #define CLIENT_VERSION_MINOR 9 + + /* Build revision */ + #define CLIENT_VERSION_REVISION 3 + + /* Version is release */ + #define COPYRIGHT_YEAR 2014 + + /* Define to 1 to enable wallet functions */ + #define ENABLE_WALLET 1 + + /* parameter and return value type for __fdelt_chk */ + /* #undef FDELT_TYPE */ + + /* define if the Boost library is available */ + #define HAVE_BOOST /**/ + + /* define if the Boost::Chrono library is available */ + #define HAVE_BOOST_CHRONO /**/ + + /* define if the Boost::Filesystem library is available */ + #define HAVE_BOOST_FILESYSTEM /**/ + + /* define if the Boost::PROGRAM_OPTIONS library is available */ + #define HAVE_BOOST_PROGRAM_OPTIONS /**/ + + /* define if the Boost::System library is available */ + #define HAVE_BOOST_SYSTEM /**/ + + /* define if the Boost::Thread library is available */ + #define HAVE_BOOST_THREAD /**/ + + /* define if the Boost::Unit_Test_Framework library is available */ + /* #undef HAVE_BOOST_UNIT_TEST_FRAMEWORK */ + + /* Define to 1 if you have the declaration of `strerror_r', and to 0 if you + don't. */ + #define HAVE_DECL_STRERROR_R 0 + + /* Define to 1 if you have the <inttypes.h> header file. */ + #define HAVE_INTTYPES_H 1 + + /* Define to 1 if you have the `advapi32' library (-ladvapi32). */ + #define HAVE_LIBADVAPI32 1 + + /* Define to 1 if you have the `comctl32' library (-lcomctl32). */ + #define HAVE_LIBCOMCTL32 1 + + /* Define to 1 if you have the `comdlg32' library (-lcomdlg32). */ + #define HAVE_LIBCOMDLG32 1 + + /* Define to 1 if you have the `crypt32' library (-lcrypt32). */ + #define HAVE_LIBCRYPT32 1 + + /* Define to 1 if you have the `crypto' library (-lcrypto). */ + #define HAVE_LIBCRYPTO 1 + + /* Define to 1 if you have the `gdi32' library (-lgdi32). */ + #define HAVE_LIBGDI32 1 + + /* Define to 1 if you have the `imm32' library (-limm32). */ + #define HAVE_LIBIMM32 1 + + /* Define to 1 if you have the `iphlpapi' library (-liphlpapi). */ + #define HAVE_LIBIPHLPAPI 1 + + /* Define to 1 if you have the `kernel32' library (-lkernel32). */ + #define HAVE_LIBKERNEL32 1 + + /* Define to 1 if you have the `mingwthrd' library (-lmingwthrd). */ + #define HAVE_LIBMINGWTHRD 1 + + /* Define to 1 if you have the `miniupnpc' library (-lminiupnpc). */ + #define HAVE_LIBMINIUPNPC 1 + + /* Define to 1 if you have the `mswsock' library (-lmswsock). */ + #define HAVE_LIBMSWSOCK 1 + + /* Define to 1 if you have the `ole32' library (-lole32). */ + #define HAVE_LIBOLE32 1 + + /* Define to 1 if you have the `oleaut32' library (-loleaut32). */ + #define HAVE_LIBOLEAUT32 1 + + /* Define to 1 if you have the `png ' library (-lpng ). */ + #define HAVE_LIBPNG_ 1 + + /* Define to 1 if you have the `protobuf ' library (-lprotobuf ). */ + #define HAVE_LIBPROTOBUF_ 1 + + /* Define to 1 if you have the `qrencode' library (-lqrencode). */ + #define HAVE_LIBQRENCODE 1 + + /* Define to 1 if you have the `rpcrt4' library (-lrpcrt4). */ + #define HAVE_LIBRPCRT4 1 + + /* Define to 1 if you have the `shell32' library (-lshell32). */ + #define HAVE_LIBSHELL32 1 + + /* Define to 1 if you have the `shlwapi' library (-lshlwapi). */ + #define HAVE_LIBSHLWAPI 1 + + /* Define to 1 if you have the `ssl' library (-lssl). */ + #define HAVE_LIBSSL 1 + + /* Define to 1 if you have the `user32' library (-luser32). */ + #define HAVE_LIBUSER32 1 + + /* Define to 1 if you have the `uuid' library (-luuid). */ + #define HAVE_LIBUUID 1 + + /* Define to 1 if you have the `winmm' library (-lwinmm). */ + #define HAVE_LIBWINMM 1 + + /* Define to 1 if you have the `winspool' library (-lwinspool). */ + #define HAVE_LIBWINSPOOL 1 + + /* Define to 1 if you have the `ws2_32' library (-lws2_32). */ + #define HAVE_LIBWS2_32 1 + + /* Define to 1 if you have the `z ' library (-lz ). */ + #define HAVE_LIBZ_ 1 + + /* Define to 1 if you have the <memory.h> header file. */ + #define HAVE_MEMORY_H 1 + + /* Define to 1 if you have the <miniupnpc/miniupnpc.h> header file. */ + #define HAVE_MINIUPNPC_MINIUPNPC_H 1 + + /* Define to 1 if you have the <miniupnpc/miniwget.h> header file. */ + #define HAVE_MINIUPNPC_MINIWGET_H 1 + + /* Define to 1 if you have the <miniupnpc/upnpcommands.h> header file. */ + #define HAVE_MINIUPNPC_UPNPCOMMANDS_H 1 + + /* Define to 1 if you have the <miniupnpc/upnperrors.h> header file. */ + #define HAVE_MINIUPNPC_UPNPERRORS_H 1 + + /* Define this symbol if you have MSG_NOSIGNAL */ + /* #undef HAVE_MSG_NOSIGNAL */ + + /* Define if you have POSIX threads libraries and header files. */ + #define HAVE_PTHREAD 1 + + /* Have PTHREAD_PRIO_INHERIT. */ + #define HAVE_PTHREAD_PRIO_INHERIT 1 + + /* Define to 1 if you have the <stdint.h> header file. */ + #define HAVE_STDINT_H 1 + + /* Define to 1 if you have the <stdio.h> header file. */ + #define HAVE_STDIO_H 1 + + /* Define to 1 if you have the <stdlib.h> header file. */ + #define HAVE_STDLIB_H 1 + + /* Define to 1 if you have the `strerror_r' function. */ + /* #undef HAVE_STRERROR_R */ + + /* Define to 1 if you have the <strings.h> header file. */ + #define HAVE_STRINGS_H 1 + + /* Define to 1 if you have the <string.h> header file. */ + #define HAVE_STRING_H 1 + + /* Define to 1 if you have the <sys/stat.h> header file. */ + #define HAVE_SYS_STAT_H 1 + + /* Define to 1 if you have the <sys/types.h> header file. */ + #define HAVE_SYS_TYPES_H 1 + + /* Define to 1 if you have the <unistd.h> header file. */ + #define HAVE_UNISTD_H 1 + + /* Define this symbol if boost sleep works */ + /* #undef HAVE_WORKING_BOOST_SLEEP */ + + /* Define this symbol if boost sleep_for works */ + #define HAVE_WORKING_BOOST_SLEEP_FOR 1 + + /* Define to the address where bug reports for this package should be sent. */ + #define PACKAGE_BUGREPORT "[email protected]" + + /* Define to the full name of this package. */ + #define PACKAGE_NAME "Feathercoin Core" + + /* Define to the full name and version of this package. */ + #define PACKAGE_STRING "Feathercoin Core 0.9.3" + + /* Define to the one symbol short name of this package. */ + #define PACKAGE_TARNAME "feathercoin" + + /* Define to the home page for this package. */ + #define PACKAGE_URL "" + + /* Define to the version of this package. */ + #define PACKAGE_VERSION "0.9.3" + + /* Define to necessary symbol if this constant uses a non-standard name on + your system. */ + /* #undef PTHREAD_CREATE_JOINABLE */ + + /* Define this symbol if qt plugins are static */ + #define QT_STATICPLUGIN 1 + + /* Define to 1 if you have the ANSI C header files. */ + #define STDC_HEADERS 1 + + /* Define to 1 if strerror_r returns char *. */ + /* #undef STRERROR_R_CHAR_P */ + + /* Define if dbus support should be compiled in */ + /* #undef USE_DBUS */ + + /* Define if QR support should be compiled in */ + #define USE_QRCODE 1 + + /* UPnP support not compiled if undefined, otherwise value (0 or 1) determines + default state */ + #define USE_UPNP 0 + + /* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most + significant byte first (like Motorola and SPARC, unlike Intel). */ + #if defined AC_APPLE_UNIVERSAL_BUILD + # if defined __BIG_ENDIAN__ + # define WORDS_BIGENDIAN 1 + # endif + #else + # ifndef WORDS_BIGENDIAN + /* # undef WORDS_BIGENDIAN */ + # endif + #endif + + /* Number of bits in a file offset, on hosts where this is settable. */ + #define _FILE_OFFSET_BITS 64 + + /* Define for large files, on AIX-style hosts. */ + /* #undef _LARGE_FILES */ + + #endif //BITCOIN_CONFIG_H
Copyrights need including.
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
https://github.com/FeatherCoin/Feathercoin/commit/82bcdec1e61e0aca27fc63b357735d3ab59c7434
version.cpp
version.cpp contains a number of Feathercoin settings , from Litecoin? Maintain separately / cherry pick?
This could be specified as an alternate file at build time?
// Client version number - #define CLIENT_VERSION_SUFFIX "-beta" + #define CLIENT_VERSION_SUFFIX "-Standard"
Optimistic.
+// git will put "#define GIT_ARCHIVE 1" on the next line inside archives. +#define GIT_ARCHIVE 1 -# define GIT_COMMIT_ID "$Format:%h$" +# define GIT_COMMIT_ID "it" -# define GIT_COMMIT_DATE "$Format:%cD$" +# define GIT_COMMIT_DATE "Fri, 12 September 2014 16:29:30 -0400"
Interface change to git.
+ #define BUILD_DESC_WITH_SUFFIX(maj,min,rev,build,suffix) \ + "v" DO_STRINGIZE(maj) "." DO_STRINGIZE(min) "." DO_STRINGIZE(rev) "." DO_STRINGIZE(build) "-" DO_STRINGIZE(suffix)
Code added / build interface change?
#ifndef BUILD_DESC - # ifdef GIT_COMMIT_ID + # ifdef BUILD_SUFFIX + # define BUILD_DESC UILD_DESC_WITH_SUFFIX(CLIENT_VERSION_MAJOR, CLIENT_VERSION_MINOR, CLIENT_VERSION_REVISION, CLIENT_VERSION_BUILD, BUILD_SUFFIX) +# elif defined(GIT_COMMIT_ID)
More complicated build system, to account for scrypt additions?
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
https://github.com/FeatherCoin/Feathercoin/commit/1ace81fbc58f3cc24f60bb32edb3d39aa6b0207e
feathercoin-cli-res.rc
feathercoin-cli-res.rc contains a number of Feathercoin settings , from Litecoin, for scrypt interface change? Maintain separately / cherry pick?
Additional file to Bitcoin?.
This could be specified as an alternate file at build time?
+ #include <windows.h> // needed for VERSIONINFO + #include "clientversion.h" // holds the needed client version information + + #define VER_PRODUCTVERSION CLIENT_VERSION_MAJOR,CLIENT_VERSION_MINOR,CLIENT_VERSION_REVISION,CLIENT_VERSION_BUILD + #define VER_PRODUCTVERSION_STR STRINGIZE(CLIENT_VERSION_MAJOR) "." STRINGIZE(CLIENT_VERSION_MINOR) "." STRINGIZE(CLIENT_VERSION_REVISION) "." STRINGIZE(CLIENT_VERSION_BUILD) + #define VER_FILEVERSION VER_PRODUCTVERSION + #define VER_FILEVERSION_STR VER_PRODUCTVERSION_STR + #define COPYRIGHT_STR "Feathercoin developers 2013-" STRINGIZE(COPYRIGHT_YEAR) ", The Bitcoin developers 2009-" STRINGIZE(COPYRIGHT_YEAR) + + VS_VERSION_INFO VERSIONINFO + FILEVERSION VER_FILEVERSION + PRODUCTVERSION VER_PRODUCTVERSION + FILEOS VOS_NT_WINDOWS32 + FILETYPE VFT_APP + BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904E4" // U.S. English - multilingual (hex) + BEGIN + VALUE "CompanyName", "Feathercoin" + VALUE "FileDescription", "Feathercoin-cli (OSS RPC client for Feathercoin)" + VALUE "FileVersion", VER_FILEVERSION_STR + VALUE "InternalName", "feathercoin-cli" + VALUE "LegalCopyright", COPYRIGHT_STR + VALUE "LegalTrademarks1", "Distributed under the MIT/X11 software license, see the accompanying file COPYING or http://www.opensource.org/licenses/mit-license.php." + VALUE "OriginalFilename", "feathercoin-cli.exe" + VALUE "ProductName", "Feathercoin-cli" + VALUE "ProductVersion", VER_PRODUCTVERSION_STR + END + END + + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x0, 1252 // language neutral - multilingual (decimal) + END + END
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
https://github.com/FeatherCoin/Feathercoin/commit/7a8051972186f24ba2fed3be5abe8e7cd586bc75
auxpow.cpp
auxpow.cpp contains a number of Feathercoin settings , from Litecoin, for scrypt interface change? Maintain separately / cherry pick?
Additional file to Bitcoin.
This could be specified as an alternate file at build time?
+ // Copyright (c) 2011 Vince Durham + // Distributed under the MIT/X11 software license, see the accompanying + // file license.txt or http://www.opensource.org/licenses/mit-license.php. + #include "script.h" + #include "auxpow.h" + #include "init.h" + + using namespace std; + using namespace boost; + + unsigned char pchMergedMiningHeader[] = { 0xfa, 0xbe, 'm', 'm' } ; + + void RemoveMergedMiningHeader(vector<unsigned char>& vchAux) + { + if (vchAux.begin() != std::search(vchAux.begin(), vchAux.end(), UBEGIN(pchMergedMiningHeader), UEND(pchMergedMiningHeader))) + throw runtime_error("merged mining aux too short"); + vchAux.erase(vchAux.begin(), vchAux.begin() + sizeof(pchMergedMiningHeader)); + } + + bool CAuxPow::Check(uint256 hashAuxBlock, int nChainID) + { + if (nIndex != 0) + return error("AuxPow is not a generate"); + + if (!TestNet() && parentBlockHeader.GetChainID() == nChainID) + return error("Aux POW parent has our chain ID"); + + if (vChainMerkleBranch.size() > 30) + return error("Aux POW chain merkle branch too long"); + + // Check that the chain merkle root is in the coinbase + uint256 nRootHash = CBlock::CheckMerkleBranch(hashAuxBlock, vChainMerkleBranch, nChainIndex); + vector<unsigned char> vchRootHash(nRootHash.begin(), nRootHash.end()); + std::reverse(vchRootHash.begin(), vchRootHash.end()); // correct endian + + // Check that we are in the parent block merkle tree + if (CBlock::CheckMerkleBranch(GetHash(), vMerkleBranch, nIndex) != parentBlockHeader.hashMerkleRoot) + return error("Aux POW merkle root incorrect"); + + const CScript script = vin[0].scriptSig; + + // Check that the same work is not submitted twice to our chain. + // + + CScript::const_iterator pcHead = + std::search(script.begin(), script.end(), UBEGIN(pchMergedMiningHeader), UEND(pchMergedMiningHeader)); + + CScript::const_iterator pc = + std::search(script.begin(), script.end(), vchRootHash.begin(), vchRootHash.end()); + + if (pcHead == script.end()) + return error("MergedMiningHeader missing from parent coinbase"); + + if (pc == script.end()) + return error("Aux POW missing chain merkle root in parent coinbase"); + + if (pcHead != script.end()) + { + // Enforce only one chain merkle root by checking that a single instance of the merged + // mining header exists just before. + if (script.end() != std::search(pcHead + 1, script.end(), UBEGIN(pchMergedMiningHeader), UEND(pchMergedMiningHeader))) + return error("Multiple merged mining headers in coinbase"); + if (pcHead + sizeof(pchMergedMiningHeader) != pc) + return error("Merged mining header is not just before chain merkle root"); + } + else + { + // For backward compatibility. + // Enforce only one chain merkle root by checking that it starts early in the coinbase. + // 8-12 bytes are enough to encode extraNonce and nBits. + if (pc - script.begin() > 20) + return error("Aux POW chain merkle root must start in the first 20 bytes of the parent coinbase"); + } + + + // Ensure we are at a deterministic point in the merkle leaves by hashing + // a nonce and our chain ID and comparing to the index. + pc + = vchRootHash.size(); + if (script.end() - pc < 8) + return error("Aux POW missing chain merkle tree size and nonce in parent coinbase"); + + int nSize; + memcpy(&nSize, &pc[0], 4); + if (nSize != (1 << vChainMerkleBranch.size())) + return error("Aux POW merkle branch size does not match parent coinbase"); + + int nNonce; + memcpy(&nNonce, &pc[4], 4); + + // Choose a pseudo-random slot in the chain merkle tree + // but have it be fixed for a size/nonce/chain combination. + // + // This prevents the same work from being used twice for the + // same chain while reducing the chance that two chains clash + // for the same slot. + unsigned int rand = nNonce; + rand = rand * 1103515245 + 12345; + rand + = nChainID; + rand = rand * 1103515245 + 12345; + + if (nChainIndex != (rand % nSize)) + return error("Aux POW wrong index"); + + return true; + } + + CScript MakeCoinbaseWithAux(unsigned int nHeight, unsigned int nExtraNonce, vector<unsigned char>& vchAux) + { + vector<unsigned char> vchAuxWithHeader(UBEGIN(pchMergedMiningHeader), UEND(pchMergedMiningHeader)); + vchAuxWithHeader.insert(vchAuxWithHeader.end(), vchAux.begin(), vchAux.end()); + + CScript script = (CScript() << nHeight << CScriptNum(nExtraNonce)) + COINBASE_FLAGS; + + // Push OP_2 just in case we want versioning later + script = script << OP_2 << vchAuxWithHeader; + + return script; + } + + + void IncrementExtraNonceWithAux(CBlock* pblock, CBlockIndex* pindexPrev, unsigned int& nExtraNonce, vector<unsigned char>& vchAux) + { + // Update nExtraNonce + static uint256 hashPrevBlock; + if (hashPrevBlock != pblock->hashPrevBlock) + { + nExtraNonce = 0; + hashPrevBlock = pblock->hashPrevBlock; + } + + + nExtraNonce; + + unsigned int nHeight = pindexPrev->nHeight + 1; // Height first in coinbase required for block.version=2 + pblock->vtx[0].vin[0].scriptSig = MakeCoinbaseWithAux(nHeight, nExtraNonce, vchAux); + pblock->hashMerkleRoot = pblock->BuildMerkleTree(); + } + +
Copyright - cherry pick from Litecoin / FTC