Forum Home
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Popular

    [Dev] Documenting Feathercoin Specific Software settings - Part 1

    Technical Development
    2
    84
    24279
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • wrapper
      wrapper Moderators last edited by wrapper

      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.

      1 Reply Last reply Reply Quote 1
      • wrapper
        wrapper Moderators last edited by wrapper

        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";
        
        1 Reply Last reply Reply Quote 1
        • wrapper
          wrapper Moderators last edited by wrapper

          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

          1 Reply Last reply Reply Quote 1
          • wrapper
            wrapper Moderators last edited by wrapper

            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());
            
            1 Reply Last reply Reply Quote 0
            • wrapper
              wrapper Moderators last edited by wrapper

              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.

              1 Reply Last reply Reply Quote 0
              • wrapper
                wrapper Moderators last edited by wrapper

                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.

                1 Reply Last reply Reply Quote 0
                • wrapper
                  wrapper Moderators last edited by wrapper

                  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

                  1 Reply Last reply Reply Quote 0
                  • wrapper
                    wrapper Moderators last edited by wrapper

                    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

                    1 Reply Last reply Reply Quote 1
                    • wrapper
                      wrapper Moderators last edited by wrapper

                      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?

                      1 Reply Last reply Reply Quote 1
                      • wrapper
                        wrapper Moderators last edited by wrapper

                        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

                        1 Reply Last reply Reply Quote 0
                        • wrapper
                          wrapper Moderators last edited by wrapper

                          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.

                          1 Reply Last reply Reply Quote 1
                          • wrapper
                            wrapper Moderators last edited by wrapper

                            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.

                            1 Reply Last reply Reply Quote 1
                            • wrapper
                              wrapper Moderators last edited by wrapper

                              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.

                              1 Reply Last reply Reply Quote 1
                              • wrapper
                                wrapper Moderators last edited by wrapper

                                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?

                                1 Reply Last reply Reply Quote 1
                                • wrapper
                                  wrapper Moderators last edited by wrapper

                                  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
                                  
                                  1 Reply Last reply Reply Quote 1
                                  • wrapper
                                    wrapper Moderators last edited by wrapper

                                    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

                                    1 Reply Last reply Reply Quote 0
                                    • wrapper
                                      wrapper Moderators last edited by wrapper

                                      Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*

                                      https://github.com/FeatherCoin/Feathercoin/commit/dd48f45ec1b22a82fb8c94eee647e1e8a1c1013c

                                      auxpow.h

                                      auxpow.h 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) 2009-2010 Satoshi Nakamoto
                                       +  // Distributed under the MIT/X11 software license, see the accompanying
                                       +  // file license.txt or http://www.opensource.org/licenses/mit-license.php.
                                       +  #ifndef BITCOIN_AUXPOW_H
                                       +  #define BITCOIN_AUXPOW_H
                                       +  
                                       +  #include "main.h"
                                       +  
                                       +  class CAuxPow : public CMerkleTx
                                       +  {
                                       +  public:
                                       +      CAuxPow(const CTransaction& txIn) : CMerkleTx(txIn)
                                       +      {
                                       +      }
                                       +  
                                       +      CAuxPow() :CMerkleTx()
                                       +      {
                                       +      }
                                       +  
                                       +      // Merkle branch with root vchAux
                                       +      // root must be present inside the coinbase
                                       +      std::vector<uint256> vChainMerkleBranch;
                                       +      // Index of chain in chains merkle tree
                                       +      unsigned int nChainIndex;
                                       +      CBlockHeader parentBlockHeader;
                                       +  
                                       +      IMPLEMENT_SERIALIZE
                                       +      (
                                       +          nSerSize      +  = SerReadWrite(s, *(CMerkleTx*)this, nType, nVersion, ser_action);
                                       +          nVersion = this->nVersion;
                                       +          READWRITE(vChainMerkleBranch);
                                       +          READWRITE(nChainIndex);
                                       +  
                                       +          // Always serialize the saved parent block as header so that the size of CAuxPow
                                       +          // is consistent.
                                       +          nSerSize      +  = SerReadWrite(s, parentBlockHeader, nType, nVersion, ser_action);
                                       +      )
                                       +  
                                       +      bool Check(uint256 hashAuxBlock, int nChainID);
                                       +  
                                       +      uint256 GetParentBlockHash()
                                       +      {
                                       +          return parentBlockHeader.GetPoWHash();
                                       +      }
                                       +  };
                                       +  
                                       +  template <typename Stream>
                                       +  int ReadWriteAuxPow(Stream& s, const boost::shared_ptr<CAuxPow>& auxpow, int nType, int nVersion, CSerActionGetSerializeSize ser_action)
                                       +  {
                                       +      if (nVersion & BLOCK_VERSION_AUXPOW)
                                       +      {
                                       +          return ::GetSerializeSize(*auxpow, nType, nVersion);
                                       +      }
                                       +      return 0;
                                       +  }
                                       +  
                                       +  template <typename Stream>
                                       +  int ReadWriteAuxPow(Stream& s, const boost::shared_ptr<CAuxPow>& auxpow, int nType, int nVersion, CSerActionSerialize ser_action)
                                       +  {
                                       +      if (nVersion & BLOCK_VERSION_AUXPOW)
                                       +      {
                                       +          return SerReadWrite(s, *auxpow, nType, nVersion, ser_action);
                                       +      }
                                       +      return 0;
                                       +  }
                                       +  
                                       +  template <typename Stream>
                                       +  int ReadWriteAuxPow(Stream& s, boost::shared_ptr<CAuxPow>& auxpow, int nType, int nVersion, CSerActionUnserialize ser_action)
                                       +  {
                                       +      if (nVersion & BLOCK_VERSION_AUXPOW)
                                       +      {
                                       +          auxpow.reset(new CAuxPow());
                                       +          return SerReadWrite(s, *auxpow, nType, nVersion, ser_action);
                                       +      }
                                       +      else
                                       +      {
                                       +          auxpow.reset();
                                       +          return 0;
                                       +      }
                                       +  }
                                       +  
                                       +  extern void RemoveMergedMiningHeader(std::vector<unsigned char>& vchAux);
                                       +  extern CScript MakeCoinbaseWithAux(unsigned int nBits, unsigned int nExtraNonce, std::vector<unsigned char>& vchAux);
                                       +  #endif
                                      
                                      1 Reply Last reply Reply Quote 1
                                      • wrapper
                                        wrapper Moderators last edited by wrapper

                                        Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*

                                        https://github.com/FeatherCoin/Feathercoin/commit/dd48f45ec1b22a82fb8c94eee647e1e8a1c1013c

                                        scrypt.cpp

                                        scrypt.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 2009 Colin Percival, 2011 ArtForz, 2012-2013 pooler
                                         +   * All rights reserved.
                                         +   *
                                         +   * Redistribution and use in source and binary forms, with or without
                                         +   * modification, are permitted provided that the following conditions
                                         +   * are met:
                                         +   * 1. Redistributions of source code must retain the above copyright
                                         +   *    notice, this list of conditions and the following disclaimer.
                                         +   * 2. Redistributions in binary form must reproduce the above copyright
                                         +   *    notice, this list of conditions and the following disclaimer in the
                                         +   *    documentation and/or other materials provided with the distribution.
                                         +   *
                                         +   * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
                                         +   * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
                                         +   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                                         +   * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
                                         +   * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                                         +   * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
                                         +   * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                                         +   * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                                         +   * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                                         +   * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                                         +   * SUCH DAMAGE.
                                         +   *
                                         +   * This file was originally written by Colin Percival as part of the Tarsnap
                                         +   * online backup system.
                                         +   */
                                         +  
                                         +   // Copyright (c) 2013-2014 Dogecoin Developers
                                         +  
                                         +  #include "scrypt.h"
                                         +  #include "util.h"
                                         +  #include <stdlib.h>
                                         +  #include <stdint.h>
                                         +  #include <string.h>
                                         +  #include <openssl/sha.h>
                                         +  
                                         +  #if defined(USE_SSE2) && !defined(USE_SSE2_ALWAYS)
                                         +  #ifdef _MSC_VER
                                         +  // MSVC 64bit is unable to use inline asm
                                         +  #include <intrin.h>
                                         +  #else
                                         +  // GCC Linux or i686-w64-mingw32
                                         +  #include <cpuid.h>
                                         +  #endif
                                         +  #endif
                                         +  
                                         +  static inline uint32_t be32dec(const void *pp)
                                         +  {
                                         +  	const uint8_t *p = (uint8_t const *)pp;
                                         +  	return ((uint32_t)(p[3])      +   ((uint32_t)(p[2]) << 8)      +  
                                         +  	    ((uint32_t)(p[1]) << 16)      +   ((uint32_t)(p[0]) << 24));
                                         +  }
                                         +  
                                         +  static inline void be32enc(void *pp, uint32_t x)
                                         +  {
                                         +  	uint8_t *p = (uint8_t *)pp;
                                         +  	p[3] = x & 0xff;
                                         +  	p[2] = (x >> 8) & 0xff;
                                         +  	p[1] = (x >> 16) & 0xff;
                                         +  	p[0] = (x >> 24) & 0xff;
                                         +  }
                                         +  
                                         +  typedef struct HMAC_SHA256Context {
                                         +  	SHA256_CTX ictx;
                                         +  	SHA256_CTX octx;
                                         +  } HMAC_SHA256_CTX;
                                         +  
                                         +  /* Initialize an HMAC-SHA256 operation with the given key. */
                                         +  static void
                                         +  HMAC_SHA256_Init(HMAC_SHA256_CTX *ctx, const void *_K, size_t Klen)
                                         +  {
                                         +  	unsigned char pad[64];
                                         +  	unsigned char khash[32];
                                         +  	const unsigned char *K = (const unsigned char *)_K;
                                         +  	size_t i;
                                         +  
                                         +  	/* If Klen > 64, the key is really SHA256(K). */
                                         +  	if (Klen > 64) {
                                         +  		SHA256_Init(&ctx->ictx);
                                         +  		SHA256_Update(&ctx->ictx, K, Klen);
                                         +  		SHA256_Final(khash, &ctx->ictx);
                                         +  		K = khash;
                                         +  		Klen = 32;
                                         +  	}
                                         +  
                                         +  	/* Inner SHA256 operation is SHA256(K xor [block of 0x36] || data). */
                                         +  	SHA256_Init(&ctx->ictx);
                                         +  	memset(pad, 0x36, 64);
                                         +  	for (i = 0; i < Klen; i     +       +  )
                                         +  		pad[i] ^= K[i];
                                         +  	SHA256_Update(&ctx->ictx, pad, 64);
                                         +  
                                         +  	/* Outer SHA256 operation is SHA256(K xor [block of 0x5c] || hash). */
                                         +  	SHA256_Init(&ctx->octx);
                                         +  	memset(pad, 0x5c, 64);
                                         +  	for (i = 0; i < Klen; i     +       +  )
                                         +  		pad[i] ^= K[i];
                                         +  	SHA256_Update(&ctx->octx, pad, 64);
                                         +  
                                         +  	/* Clean the stack. */
                                         +  	memset(khash, 0, 32);
                                         +  }
                                         +  
                                         +  /* Add bytes to the HMAC-SHA256 operation. */
                                         +  static void
                                         +  HMAC_SHA256_Update(HMAC_SHA256_CTX *ctx, const void *in, size_t len)
                                         +  {
                                         +  	/* Feed data to the inner SHA256 operation. */
                                         +  	SHA256_Update(&ctx->ictx, in, len);
                                         +  }
                                         +  
                                         +  /* Finish an HMAC-SHA256 operation. */
                                         +  static void
                                         +  HMAC_SHA256_Final(unsigned char digest[32], HMAC_SHA256_CTX *ctx)
                                         +  {
                                         +  	unsigned char ihash[32];
                                         +  
                                         +  	/* Finish the inner SHA256 operation. */
                                         +  	SHA256_Final(ihash, &ctx->ictx);
                                         +  
                                         +  	/* Feed the inner hash to the outer SHA256 operation. */
                                         +  	SHA256_Update(&ctx->octx, ihash, 32);
                                         +  
                                         +  	/* Finish the outer SHA256 operation. */
                                         +  	SHA256_Final(digest, &ctx->octx);
                                         +  
                                         +  	/* Clean the stack. */
                                         +  	memset(ihash, 0, 32);
                                         +  }
                                         +  
                                         +  /**
                                         +   * PBKDF2_SHA256(passwd, passwdlen, salt, saltlen, c, buf, dkLen):
                                         +   * Compute PBKDF2(passwd, salt, c, dkLen) using HMAC-SHA256 as the PRF, and
                                         +   * write the output to buf.  The value dkLen must be at most 32 * (2^32 - 1).
                                         +   */
                                         +  void
                                         +  PBKDF2_SHA256(const uint8_t *passwd, size_t passwdlen, const uint8_t *salt,
                                         +      size_t saltlen, uint64_t c, uint8_t *buf, size_t dkLen)
                                         +  {
                                         +  	HMAC_SHA256_CTX PShctx, hctx;
                                         +  	size_t i;
                                         +  	uint8_t ivec[4];
                                         +  	uint8_t U[32];
                                         +  	uint8_t T[32];
                                         +  	uint64_t j;
                                         +  	int k;
                                         +  	size_t clen;
                                         +  
                                         +  	/* Compute HMAC state after processing P and S. */
                                         +  	HMAC_SHA256_Init(&PShctx, passwd, passwdlen);
                                         +  	HMAC_SHA256_Update(&PShctx, salt, saltlen);
                                         +  
                                         +  	/* Iterate through the blocks. */
                                         +  	for (i = 0; i * 32 < dkLen; i     +       +  ) {
                                         +  		/* Generate INT(i      +   1). */
                                         +  		be32enc(ivec, (uint32_t)(i      +   1));
                                         +  
                                         +  		/* Compute U_1 = PRF(P, S || INT(i)). */
                                         +  		memcpy(&hctx, &PShctx, sizeof(HMAC_SHA256_CTX));
                                         +  		HMAC_SHA256_Update(&hctx, ivec, 4);
                                         +  		HMAC_SHA256_Final(U, &hctx);
                                         +  
                                         +  		/* T_i = U_1 ... */
                                         +  		memcpy(T, U, 32);
                                         +  
                                         +  		for (j = 2; j <= c; j     +       +  ) {
                                         +  			/* Compute U_j. */
                                         +  			HMAC_SHA256_Init(&hctx, passwd, passwdlen);
                                         +  			HMAC_SHA256_Update(&hctx, U, 32);
                                         +  			HMAC_SHA256_Final(U, &hctx);
                                         +  
                                         +  			/* ... xor U_j ... */
                                         +  			for (k = 0; k < 32; k     +       +  )
                                         +  				T[k] ^= U[k];
                                         +  		}
                                         +  
                                         +  		/* Copy as many bytes as necessary into buf. */
                                         +  		clen = dkLen - i * 32;
                                         +  		if (clen > 32)
                                         +  			clen = 32;
                                         +  		memcpy(&buf[i * 32], T, clen);
                                         +  	}
                                         +  
                                         +  	/* Clean PShctx, since we never called _Final on it. */
                                         +  	memset(&PShctx, 0, sizeof(HMAC_SHA256_CTX));
                                         +  }
                                         +  
                                         +  #define ROTL(a, b) (((a) << (b)) | ((a) >> (32 - (b))))
                                         +  
                                         +  static inline void xor_salsa8(uint32_t B[16], const uint32_t Bx[16])
                                         +  {
                                         +  	uint32_t x00,x01,x02,x03,x04,x05,x06,x07,x08,x09,x10,x11,x12,x13,x14,x15;
                                         +  	int i;
                                         +  
                                         +  	x00 = (B[ 0] ^= Bx[ 0]);
                                         +  	x01 = (B[ 1] ^= Bx[ 1]);
                                         +  	x02 = (B[ 2] ^= Bx[ 2]);
                                         +  	x03 = (B[ 3] ^= Bx[ 3]);
                                         +  	x04 = (B[ 4] ^= Bx[ 4]);
                                         +  	x05 = (B[ 5] ^= Bx[ 5]);
                                         +  	x06 = (B[ 6] ^= Bx[ 6]);
                                         +  	x07 = (B[ 7] ^= Bx[ 7]);
                                         +  	x08 = (B[ 8] ^= Bx[ 8]);
                                         +  	x09 = (B[ 9] ^= Bx[ 9]);
                                         +  	x10 = (B[10] ^= Bx[10]);
                                         +  	x11 = (B[11] ^= Bx[11]);
                                         +  	x12 = (B[12] ^= Bx[12]);
                                         +  	x13 = (B[13] ^= Bx[13]);
                                         +  	x14 = (B[14] ^= Bx[14]);
                                         +  	x15 = (B[15] ^= Bx[15]);
                                         +  	for (i = 0; i < 8; i      +  = 2) {
                                         +  		/* Operate on columns. */
                                         +  		x04 ^= ROTL(x00      +   x12,  7);  x09 ^= ROTL(x05      +   x01,  7);
                                         +  		x14 ^= ROTL(x10      +   x06,  7);  x03 ^= ROTL(x15      +   x11,  7);
                                         +  
                                         +  		x08 ^= ROTL(x04      +   x00,  9);  x13 ^= ROTL(x09      +   x05,  9);
                                         +  		x02 ^= ROTL(x14      +   x10,  9);  x07 ^= ROTL(x03      +   x15,  9);
                                         +  
                                         +  		x12 ^= ROTL(x08      +   x04, 13);  x01 ^= ROTL(x13      +   x09, 13);
                                         +  		x06 ^= ROTL(x02      +   x14, 13);  x11 ^= ROTL(x07      +   x03, 13);
                                         +  
                                         +  		x00 ^= ROTL(x12      +   x08, 18);  x05 ^= ROTL(x01      +   x13, 18);
                                         +  		x10 ^= ROTL(x06      +   x02, 18);  x15 ^= ROTL(x11      +   x07, 18);
                                         +  
                                         +  		/* Operate on rows. */
                                         +  		x01 ^= ROTL(x00      +   x03,  7);  x06 ^= ROTL(x05      +   x04,  7);
                                         +  		x11 ^= ROTL(x10      +   x09,  7);  x12 ^= ROTL(x15      +   x14,  7);
                                         +  
                                         +  		x02 ^= ROTL(x01      +   x00,  9);  x07 ^= ROTL(x06      +   x05,  9);
                                         +  		x08 ^= ROTL(x11      +   x10,  9);  x13 ^= ROTL(x12      +   x15,  9);
                                         +  
                                         +  		x03 ^= ROTL(x02      +   x01, 13);  x04 ^= ROTL(x07      +   x06, 13);
                                         +  		x09 ^= ROTL(x08      +   x11, 13);  x14 ^= ROTL(x13      +   x12, 13);
                                         +  
                                         +  		x00 ^= ROTL(x03      +   x02, 18);  x05 ^= ROTL(x04      +   x07, 18);
                                         +  		x10 ^= ROTL(x09      +   x08, 18);  x15 ^= ROTL(x14      +   x13, 18);
                                         +  	}
                                         +  	B[ 0]      +  = x00;
                                         +  	B[ 1]      +  = x01;
                                         +  	B[ 2]      +  = x02;
                                         +  	B[ 3]      +  = x03;
                                         +  	B[ 4]      +  = x04;
                                         +  	B[ 5]      +  = x05;
                                         +  	B[ 6]      +  = x06;
                                         +  	B[ 7]      +  = x07;
                                         +  	B[ 8]      +  = x08;
                                         +  	B[ 9]      +  = x09;
                                         +  	B[10]      +  = x10;
                                         +  	B[11]      +  = x11;
                                         +  	B[12]      +  = x12;
                                         +  	B[13]      +  = x13;
                                         +  	B[14]      +  = x14;
                                         +  	B[15]      +  = x15;
                                         +  }
                                         +  
                                         +  void scrypt_1024_1_1_256_sp_generic(const char *input, char *output, char *scratchpad)
                                         +  {
                                         +  	uint8_t B[128];
                                         +  	uint32_t X[32];
                                         +  	uint32_t *V;
                                         +  	uint32_t i, j, k;
                                         +  
                                         +  	V = (uint32_t *)(((uintptr_t)(scratchpad)      +   63) & ~ (uintptr_t)(63));
                                         +  
                                         +  	PBKDF2_SHA256((const uint8_t *)input, 80, (const uint8_t *)input, 80, 1, B, 128);
                                         +  
                                         +  	for (k = 0; k < 32; k     +       +  )
                                         +  		X[k] = le32dec(&B[4 * k]);
                                         +  
                                         +  	for (i = 0; i < 1024; i     +       +  ) {
                                         +  		memcpy(&V[i * 32], X, 128);
                                         +  		xor_salsa8(&X[0], &X[16]);
                                         +  		xor_salsa8(&X[16], &X[0]);
                                         +  	}
                                         +  	for (i = 0; i < 1024; i     +       +  ) {
                                         +  		j = 32 * (X[16] & 1023);
                                         +  		for (k = 0; k < 32; k     +       +  )
                                         +  			X[k] ^= V[j      +   k];
                                         +  		xor_salsa8(&X[0], &X[16]);
                                         +  		xor_salsa8(&X[16], &X[0]);
                                         +  	}
                                         +  
                                         +  	for (k = 0; k < 32; k     +       +  )
                                         +  		le32enc(&B[4 * k], X[k]);
                                         +  
                                         +  	PBKDF2_SHA256((const uint8_t *)input, 80, B, 128, 1, (uint8_t *)output, 32);
                                         +  }
                                         +  
                                         +  #if defined(USE_SSE2)
                                         +  // By default, set to generic scrypt function. This will prevent crash in case when scrypt_detect_sse2() wasn't called
                                         +  void (*scrypt_1024_1_1_256_sp_detected)(const char *input, char *output, char *scratchpad) = &scrypt_1024_1_1_256_sp_generic;
                                         +  
                                         +  void scrypt_detect_sse2()
                                         +  {
                                         +  #if defined(USE_SSE2_ALWAYS)
                                         +      printf("scrypt: using scrypt-sse2 as built.\n");
                                         +  #else // USE_SSE2_ALWAYS
                                         +      // 32bit x86 Linux or Windows, detect cpuid features
                                         +      unsigned int cpuid_edx=0;
                                         +  #if defined(_MSC_VER)
                                         +      // MSVC
                                         +      int x86cpuid[4];
                                         +      __cpuid(x86cpuid, 1);
                                         +      cpuid_edx = (unsigned int)buffer[3];
                                         +  #else // _MSC_VER
                                         +      // Linux or i686-w64-mingw32 (gcc-4.6.3)
                                         +      unsigned int eax, ebx, ecx;
                                         +      __get_cpuid(1, &eax, &ebx, &ecx, &cpuid_edx);
                                         +  #endif // _MSC_VER
                                         +  
                                         +      if (cpuid_edx & 1<<26)
                                         +      {
                                         +          scrypt_1024_1_1_256_sp_detected = &scrypt_1024_1_1_256_sp_sse2;
                                         +          printf("scrypt: using scrypt-sse2 as detected.\n");
                                         +      }
                                         +      else
                                         +      {
                                         +          scrypt_1024_1_1_256_sp_detected = &scrypt_1024_1_1_256_sp_generic;
                                         +          printf("scrypt: using scrypt-generic, SSE2 unavailable.\n");
                                         +      }
                                         +  #endif // USE_SSE2_ALWAYS
                                         +  }
                                         +  #endif
                                         +  
                                         +  void scrypt_1024_1_1_256(const char *input, char *output)
                                         +  {
                                         +  	char scratchpad[SCRYPT_SCRATCHPAD_SIZE];
                                         +      scrypt_1024_1_1_256_sp(input, output, scratchpad);
                                         +  }
                                        

                                        Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*

                                        https://github.com/FeatherCoin/Feathercoin/commit/30516a6ce8d723cc3d8eb624e2d30431843f01a0

                                        script.cpp

                                        Commit 2

                                         - #include "bignum.h"
                                        

                                        Biitcoin code removed

                                         +static const CScriptNum bnZero(0);
                                         +static const CScriptNum bnOne(1);
                                         +static const CScriptNum bnFalse(0);
                                         +static const CScriptNum bnTrue(1);
                                        

                                        Scrypt interface.

                                            -CBigNum CastToBigNum(const valtype& vch)
                                            -{
                                            -    if (vch.size() > nMaxNumSize)
                                            -        throw runtime_error("CastToBigNum() : overflow");
                                            -    // Get rid of extra leading zeros
                                            -    return CBigNum(CBigNum(vch).getvch());
                                            -}
                                        
                                            -    if (flags & SCRIPT_VERIFY_EVEN_S) {
                                            -     if (S[nLenS-1] & 1)
                                            -      return error("Non-canonical signature: S value odd");
                                        
                                          -    CAutoBN_CTX pctx;
                                        

                                        Remove Bitcoin code.

                                         +    if (flags & SCRIPT_VERIFY_LOW_S) {
                                         +        // If the S value is above the order of the curve divided by two, its
                                         +        // complement modulo the order could have been used instead, which is
                                         +        // one byte shorter when encoded correctly.
                                         +        if (!CKey::CheckSignatureElement(S, nLenS, true))
                                         +            return error("Non-canonical signature: S value is unnecessarily high");
                                        

                                        Scrypt code removed

                                           +        CScriptNum bn((int)opcode - (int)(OP_1 - 1));
                                        

                                        Bitcoin code replaced. Scrypt interface

                                          +                    CScriptNum bn(stack.size());
                                        
                                         +           int n = CScriptNum(stacktop(-1)).getint();
                                        
                                         +          CScriptNum bn(stacktop(-1).size());
                                        
                                         +           CScriptNum bn(stacktop(-1));
                                        
                                         +            CScriptNum bn1(stacktop(-2));
                                         +            CScriptNum bn2(stacktop(-1));
                                         +            CScriptNum bn(0);
                                        
                                         +           CScriptNum bn1(stacktop(-3));
                                         +           CScriptNum bn2(stacktop(-2));
                                         +           CScriptNum bn3(stacktop(-1));
                                        
                                         +           int nKeysCount = CScriptNum(stacktop(-i)).getint();
                                        
                                         +           int nSigsCount = CScriptNum(stacktop(-i)).getint();
                                        

                                        Bitcoin code replaced. Scrypt interface

                                         +        // Feathercoin address tx, sender provides hash of pubkey, receiver provides signature and pubkey
                                        

                                        Name change for comment?

                                        1 Reply Last reply Reply Quote 1
                                        • wrapper
                                          wrapper Moderators last edited by wrapper

                                          Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*

                                          https://github.com/FeatherCoin/Feathercoin/commit/9346686d71f874429a5b0508bdc3be50850e7b66

                                          scrypt.h

                                          scrypt.h contains a number of Feathercoin settings , from Litecoin / Dogecoin? , 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) 2013-2014 Dogecoin Developers
                                           +  
                                           +  #ifndef SCRYPT_H
                                           +  #define SCRYPT_H
                                           +  #include <stdlib.h>
                                           +  #include <stdint.h>
                                           +  
                                           +  static const int SCRYPT_SCRATCHPAD_SIZE = 131072      +   63;
                                           +  
                                           +  void scrypt_1024_1_1_256(const char *input, char *output);
                                           +  void scrypt_1024_1_1_256_sp_generic(const char *input, char *output, char *scratchpad);
                                           +  
                                           +  #if defined(USE_SSE2)
                                           +  #if defined(_M_X64) || defined(__x86_64__) || defined(_M_AMD64) || (defined(MAC_OSX) && defined(__i386__))
                                           +  #define USE_SSE2_ALWAYS 1
                                           +  #define scrypt_1024_1_1_256_sp(input, output, scratchpad) scrypt_1024_1_1_256_sp_sse2((input), (output), (scratchpad))
                                           +  #else
                                           +  #define scrypt_1024_1_1_256_sp(input, output, scratchpad) scrypt_1024_1_1_256_sp_detected((input), (output), (scratchpad))
                                           +  #endif
                                           +  
                                           +  void scrypt_detect_sse2();
                                           +  void scrypt_1024_1_1_256_sp_sse2(const char *input, char *output, char *scratchpad);
                                           +  extern void (*scrypt_1024_1_1_256_sp_detected)(const char *input, char *output, char *scratchpad);
                                           +  #else
                                           +  #define scrypt_1024_1_1_256_sp(input, output, scratchpad) scrypt_1024_1_1_256_sp_generic((input), (output), (scratchpad))
                                           +  #endif
                                           +  
                                           +  void
                                           +  PBKDF2_SHA256(const uint8_t *passwd, size_t passwdlen, const uint8_t *salt,
                                           +      size_t saltlen, uint64_t c, uint8_t *buf, size_t dkLen);
                                           +  
                                           +  static inline uint32_t le32dec(const void *pp)
                                           +  {
                                           +          const uint8_t *p = (uint8_t const *)pp;
                                           +          return ((uint32_t)(p[0])      +   ((uint32_t)(p[1]) << 8)      +  
                                           +              ((uint32_t)(p[2]) << 16)      +   ((uint32_t)(p[3]) << 24));
                                           +  }
                                           +  
                                           +  static inline void le32enc(void *pp, uint32_t x)
                                           +  {
                                           +          uint8_t *p = (uint8_t *)pp;
                                           +          p[0] = x & 0xff;
                                           +          p[1] = (x >> 8) & 0xff;
                                           +          p[2] = (x >> 16) & 0xff;
                                           +          p[3] = (x >> 24) & 0xff;
                                           +  }
                                           +  #endif
                                          

                                          Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*

                                          https://github.com/FeatherCoin/Feathercoin/commit/30516a6ce8d723cc3d8eb624e2d30431843f01a0

                                          script.h

                                          Commit 2

                                            - #include "bignum.h"
                                          

                                          Include removed

                                                 +class scriptnum_error : public std::runtime_error
                                             +{
                                             +public:
                                             +    explicit scriptnum_error(const std::string& str) : std::runtime_error(str) {}
                                             +};
                                             +
                                             +class CScriptNum
                                             +{
                                             +// Numeric opcodes (OP_1ADD, etc) are restricted to operating on 4-byte integers.
                                             +// The semantics are subtle, though: operands must be in the range [-2^31        +1...2^31 -1],
                                             +// but results may overflow (and are valid as long as they are not used in a subsequent
                                             +// numeric operation). CScriptNum enforces those semantics by storing results as
                                             +// an int64 and allowing out-of-range values to be returned as a vector of bytes but
                                             +// throwing an exception if arithmetic is done or the result is interpreted as an integer.
                                             +public:
                                             +
                                             +    explicit CScriptNum(const int64_t& n)
                                             +    {
                                             +        m_value = n;
                                             +    }
                                             +
                                             +    explicit CScriptNum(const std::vector<unsigned char>& vch)
                                             +    {
                                             +        if (vch.size() > nMaxNumSize)
                                             +            throw scriptnum_error("CScriptNum(const std::vector<unsigned char>&) : overflow");
                                             +        m_value = set_vch(vch);
                                             +    }
                                             +
                                             +    inline bool operator==(const int64_t& rhs) const    { return m_value == rhs; }
                                             +    inline bool operator!=(const int64_t& rhs) const    { return m_value != rhs; }
                                             +    inline bool operator<=(const int64_t& rhs) const    { return m_value <= rhs; }
                                             +    inline bool operator< (const int64_t& rhs) const    { return m_value <  rhs; }
                                             +    inline bool operator>=(const int64_t& rhs) const    { return m_value >= rhs; }
                                             +    inline bool operator> (const int64_t& rhs) const    { return m_value >  rhs; }
                                             +
                                             +    inline bool operator==(const CScriptNum& rhs) const { return operator==(rhs.m_value); }
                                             +    inline bool operator!=(const CScriptNum& rhs) const { return operator!=(rhs.m_value); }
                                             +    inline bool operator<=(const CScriptNum& rhs) const { return operator<=(rhs.m_value); }
                                             +    inline bool operator< (const CScriptNum& rhs) const { return operator< (rhs.m_value); }
                                             +    inline bool operator>=(const CScriptNum& rhs) const { return operator>=(rhs.m_value); }
                                             +    inline bool operator> (const CScriptNum& rhs) const { return operator> (rhs.m_value); }
                                             +
                                             +    inline CScriptNum operator       +(   const int64_t& rhs)    const { return CScriptNum(m_value        + rhs);}
                                             +    inline CScriptNum operator-(   const int64_t& rhs)    const { return CScriptNum(m_value - rhs);}
                                             +    inline CScriptNum operator       +(   const CScriptNum& rhs) const { return operator       +(rhs.m_value);   }
                                             +    inline CScriptNum operator-(   const CScriptNum& rhs) const { return operator-(rhs.m_value);   }
                                             +
                                             +    inline CScriptNum& operator       +=( const CScriptNum& rhs)       { return operator       +=(rhs.m_value);  }
                                             +    inline CScriptNum& operator-=( const CScriptNum& rhs)       { return operator-=(rhs.m_value);  }
                                             +
                                             +    inline CScriptNum operator-()                         const
                                             +    {
                                             +        assert(m_value != std::numeric_limits<int64_t>::min());
                                             +        return CScriptNum(-m_value);
                                             +    }
                                             +
                                             +    inline CScriptNum& operator=( const int64_t& rhs)
                                             +    {
                                             +        m_value = rhs;
                                             +        return *this;
                                             +    }
                                             +
                                             +    inline CScriptNum& operator       +=( const int64_t& rhs)
                                             +    {
                                             +        assert(rhs == 0 || (rhs > 0 && m_value <= std::numeric_limits<int64_t>::max() - rhs) ||
                                             +                           (rhs < 0 && m_value >= std::numeric_limits<int64_t>::min() - rhs));
                                             +        m_value        += rhs;
                                             +        return *this;
                                             +    }
                                             +
                                             +    inline CScriptNum& operator-=( const int64_t& rhs)
                                             +    {
                                             +        assert(rhs == 0 || (rhs > 0 && m_value >= std::numeric_limits<int64_t>::min()        + rhs) ||
                                             +                           (rhs < 0 && m_value <= std::numeric_limits<int64_t>::max()        + rhs));
                                             +        m_value -= rhs;
                                             +        return *this;
                                             +    }
                                             +
                                             +    int getint() const
                                             +    {
                                             +        if (m_value > std::numeric_limits<int>::max())
                                             +            return std::numeric_limits<int>::max();
                                             +        else if (m_value < std::numeric_limits<int>::min())
                                             +            return std::numeric_limits<int>::min();
                                             +        return m_value;
                                             +    }
                                             +
                                             +    std::vector<unsigned char> getvch() const
                                             +    {
                                             +        return serialize(m_value);
                                             +    }
                                             +
                                             +    static std::vector<unsigned char> serialize(const int64_t& value)
                                             +    {
                                             +        if(value == 0)
                                             +            return std::vector<unsigned char>();
                                             +
                                             +        std::vector<unsigned char> result;
                                             +        const bool neg = value < 0;
                                             +        uint64_t absvalue = neg ? -value : value;
                                             +
                                             +        while(absvalue)
                                             +        {
                                             +            result.push_back(absvalue & 0xff);
                                             +            absvalue >>= 8;
                                             +        }
                                             +
                                             +
                                             +//    - If the most significant byte is >= 0x80 and the value is positive, push a
                                             +//    new zero-byte to make the significant byte < 0x80 again.
                                             +
                                             +//    - If the most significant byte is >= 0x80 and the value is negative, push a
                                             +//    new 0x80 byte that will be popped off when converting to an integral.
                                             +
                                             +//    - If the most significant byte is < 0x80 and the value is negative, add
                                             +//    0x80 to it, since it will be subtracted and interpreted as a negative when
                                             +//    converting to an integral.
                                             +
                                             +        if (result.back() & 0x80)
                                             +            result.push_back(neg ? 0x80 : 0);
                                             +        else if (neg)
                                             +            result.back() |= 0x80;
                                             +
                                             +        return result;
                                             +    }
                                             +
                                             +    static const size_t nMaxNumSize = 4;
                                             +
                                             +private:
                                             +    static int64_t set_vch(const std::vector<unsigned char>& vch)
                                             +    {
                                             +      if (vch.empty())
                                             +          return 0;
                                             +
                                             +      int64_t result = 0;
                                             +      for (size_t i = 0; i != vch.size();        +       +i)
                                             +          result |= static_cast<int64_t>(vch[i]) << 8*i;
                                             +
                                             +      // If the input vector's most significant byte is 0x80, remove it from
                                             +      // the result's msb and return a negative.
                                             +      if (vch.back() & 0x80)
                                             +          return -(result & ~(0x80 << (8 * (vch.size() - 1))));
                                             +
                                             +      return result;
                                             +    }
                                             +
                                             +    int64_t m_value;
                                             +};
                                             +
                                          

                                          Scrypt interface change

                                           +    SCRIPT_VERIFY_LOW_S     = (1U << 2), // enforce low S values (<n/2) in signatures (depends on STRICTENC)
                                          
                                           +    SCRIPT_VERIFY_NULLDUMMY = (1U << 4), // verify dummy stack item consumed by CHECKMULTISIG is of zero-length
                                          

                                          Scrypt interface change Bitcoin code replaced.

                                          +        return strprintf("%d", CScriptNum(vch).getint());
                                          

                                          Print name interface change

                                          -            CBigNum bn(n);
                                          -            *this << bn.getvch();
                                          
                                             -
                                             -    CScript& push_uint64(uint64_t n)
                                             -    {
                                             -        if (n >= 1 && n <= 16)
                                             -        {
                                             -            push_back(n + (OP_1        - 1));
                                             -        }
                                             -        else
                                             -        {
                                             -            CBigNum bn(n);
                                             -            *this << bn.getvch();
                                             -        }
                                             -        return *this;
                                             -    }
                                          

                                          Bitcoin code removed

                                          +      *this << CScriptNum::serialize(n);
                                          
                                           +    CScript(int64_t b)        { operator<<(b); }
                                          

                                          Scrypt interface included

                                             -    //explicit CScript(char b) is not portable.  Use 'signed char' or 'unsigned char'.
                                             -    explicit CScript(signed char b)        { operator<<(b); }
                                             -    explicit CScript(short b)              { operator<<(b); }
                                             -    explicit CScript(int b)                { operator<<(b); }
                                             -    explicit CScript(long b)               { operator<<(b); }
                                             -    explicit CScript(long long b)          { operator<<(b); }
                                             -    explicit CScript(unsigned char b)      { operator<<(b); }
                                             -    explicit CScript(unsigned int b)       { operator<<(b); }
                                             -    explicit CScript(unsigned short b)     { operator<<(b); }
                                             -    explicit CScript(unsigned long b)      { operator<<(b); }
                                             -    explicit CScript(unsigned long long b) { operator<<(b); }              -
                                          

                                          Bitcoin code removed

                                            +    CScript(int64_t b)        { operator<<(b); }
                                          

                                          Scrypt interface included

                                           -    explicit CScript(const CBigNum& b) { operator<<(b); }
                                          

                                          Bitcoin code removed

                                           +    explicit CScript(const CScriptNum& b) { operator<<(b); }
                                          
                                          +    CScript& operator<<(int64_t b) { return push_int64(b); }
                                          

                                          Scrypt interface added

                                             -    //CScript& operator<<(char b) is not portable.  Use 'signed char' or 'unsigned char'.
                                             -    CScript& operator<<(signed char b)        { return push_int64(b); }
                                             -    CScript& operator<<(short b)              { return push_int64(b); }
                                             -    CScript& operator<<(int b)                { return push_int64(b); }
                                             -    CScript& operator<<(long b)               { return push_int64(b); }
                                             -    CScript& operator<<(long long b)          { return push_int64(b); }
                                             -    CScript& operator<<(unsigned char b)      { return push_uint64(b); }
                                             -    CScript& operator<<(unsigned int b)       { return push_uint64(b); }
                                             -    CScript& operator<<(unsigned short b)     { return push_uint64(b); }
                                             -    CScript& operator<<(unsigned long b)      { return push_uint64(b); }
                                             -    CScript& operator<<(unsigned long long b) { return push_uint64(b); } 
                                          

                                          Bitcoin code removed

                                           +    CScript& operator<<(int64_t b) { return push_int64(b); }
                                          
                                           +    CScript& operator<<(const CScriptNum& b)
                                          

                                          Scrypt interface added

                                          1 Reply Last reply Reply Quote 1
                                          • wrapper
                                            wrapper Moderators last edited by

                                            Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*

                                            https://github.com/FeatherCoin/Feathercoin/commit/900050b10fb9b56bea9d8dd664350a59adac73ab

                                            scrypt-sse2.cpp

                                            scrypt-sse2.cpp contains a number of Feathercoin settings , from Litecoin / Dogecoin? , for scrypt interface change Maintain separately / cherry pick?

                                            Additional file to Bitcoin.

                                            This could be specified as an alternate file at build time?

                                             +  /*
                                             +   * Copyright 2009 Colin Percival, 2011 ArtForz, 2012-2013 pooler
                                             +   * All rights reserved.
                                             +   *
                                             +   * Redistribution and use in source and binary forms, with or without
                                             +   * modification, are permitted provided that the following conditions
                                             +   * are met:
                                             +   * 1. Redistributions of source code must retain the above copyright
                                             +   *    notice, this list of conditions and the following disclaimer.
                                             +   * 2. Redistributions in binary form must reproduce the above copyright
                                             +   *    notice, this list of conditions and the following disclaimer in the
                                             +   *    documentation and/or other materials provided with the distribution.
                                             +   *
                                             +   * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
                                             +   * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
                                             +   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                                             +   * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
                                             +   * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                                             +   * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
                                             +   * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                                             +   * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                                             +   * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                                             +   * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                                             +   * SUCH DAMAGE.
                                             +   *
                                             +   * This file was originally written by Colin Percival as part of the Tarsnap
                                             +   * online backup system.
                                             +   */
                                             +  
                                             +  // Copyright (c) 2013-2014 Dogecoin Developers
                                             +  
                                             +  #include "scrypt.h"
                                             +  #include <stdlib.h>
                                             +  #include <stdint.h>
                                             +  #include <string.h>
                                             +  #include <openssl/sha.h>
                                             +  
                                             +  #include <emmintrin.h>
                                             +  
                                             +  static inline void xor_salsa8_sse2(__m128i B[4], const __m128i Bx[4])
                                             +  {
                                             +  	__m128i X0, X1, X2, X3;
                                             +  	__m128i T;
                                             +  	int i;
                                             +  
                                             +  	X0 = B[0] = _mm_xor_si128(B[0], Bx[0]);
                                             +  	X1 = B[1] = _mm_xor_si128(B[1], Bx[1]);
                                             +  	X2 = B[2] = _mm_xor_si128(B[2], Bx[2]);
                                             +  	X3 = B[3] = _mm_xor_si128(B[3], Bx[3]);
                                             +  
                                             +  	for (i = 0; i < 8; i      +  = 2) {
                                             +  		/* Operate on "columns". */
                                             +  		T = _mm_add_epi32(X0, X3);
                                             +  		X1 = _mm_xor_si128(X1, _mm_slli_epi32(T, 7));
                                             +  		X1 = _mm_xor_si128(X1, _mm_srli_epi32(T, 25));
                                             +  		T = _mm_add_epi32(X1, X0);
                                             +  		X2 = _mm_xor_si128(X2, _mm_slli_epi32(T, 9));
                                             +  		X2 = _mm_xor_si128(X2, _mm_srli_epi32(T, 23));
                                             +  		T = _mm_add_epi32(X2, X1);
                                             +  		X3 = _mm_xor_si128(X3, _mm_slli_epi32(T, 13));
                                             +  		X3 = _mm_xor_si128(X3, _mm_srli_epi32(T, 19));
                                             +  		T = _mm_add_epi32(X3, X2);
                                             +  		X0 = _mm_xor_si128(X0, _mm_slli_epi32(T, 18));
                                             +  		X0 = _mm_xor_si128(X0, _mm_srli_epi32(T, 14));
                                             +  
                                             +  		/* Rearrange data. */
                                             +  		X1 = _mm_shuffle_epi32(X1, 0x93);
                                             +  		X2 = _mm_shuffle_epi32(X2, 0x4E);
                                             +  		X3 = _mm_shuffle_epi32(X3, 0x39);
                                             +  
                                             +  		/* Operate on "rows". */
                                             +  		T = _mm_add_epi32(X0, X1);
                                             +  		X3 = _mm_xor_si128(X3, _mm_slli_epi32(T, 7));
                                             +  		X3 = _mm_xor_si128(X3, _mm_srli_epi32(T, 25));
                                             +  		T = _mm_add_epi32(X3, X0);
                                             +  		X2 = _mm_xor_si128(X2, _mm_slli_epi32(T, 9));
                                             +  		X2 = _mm_xor_si128(X2, _mm_srli_epi32(T, 23));
                                             +  		T = _mm_add_epi32(X2, X3);
                                             +  		X1 = _mm_xor_si128(X1, _mm_slli_epi32(T, 13));
                                             +  		X1 = _mm_xor_si128(X1, _mm_srli_epi32(T, 19));
                                             +  		T = _mm_add_epi32(X1, X2);
                                             +  		X0 = _mm_xor_si128(X0, _mm_slli_epi32(T, 18));
                                             +  		X0 = _mm_xor_si128(X0, _mm_srli_epi32(T, 14));
                                             +  
                                             +  		/* Rearrange data. */
                                             +  		X1 = _mm_shuffle_epi32(X1, 0x39);
                                             +  		X2 = _mm_shuffle_epi32(X2, 0x4E);
                                             +  		X3 = _mm_shuffle_epi32(X3, 0x93);
                                             +  	}
                                             +  
                                             +  	B[0] = _mm_add_epi32(B[0], X0);
                                             +  	B[1] = _mm_add_epi32(B[1], X1);
                                             +  	B[2] = _mm_add_epi32(B[2], X2);
                                             +  	B[3] = _mm_add_epi32(B[3], X3);
                                             +  }
                                             +  
                                             +  void scrypt_1024_1_1_256_sp_sse2(const char *input, char *output, char *scratchpad)
                                             +  {
                                             +  	uint8_t B[128];
                                             +  	union {
                                             +  		__m128i i128[8];
                                             +  		uint32_t u32[32];
                                             +  	} X;
                                             +  	__m128i *V;
                                             +  	uint32_t i, j, k;
                                             +  
                                             +  	V = (__m128i *)(((uintptr_t)(scratchpad)      +   63) & ~ (uintptr_t)(63));
                                             +  
                                             +  	PBKDF2_SHA256((const uint8_t *)input, 80, (const uint8_t *)input, 80, 1, B, 128);
                                             +  
                                             +  	for (k = 0; k < 2; k     +       +  ) {
                                             +  		for (i = 0; i < 16; i     +       +  ) {
                                             +  			X.u32[k * 16      +   i] = le32dec(&B[(k * 16      +   (i * 5 % 16)) * 4]);
                                             +  		}
                                             +  	}
                                             +  
                                             +  	for (i = 0; i < 1024; i     +       +  ) {
                                             +  		for (k = 0; k < 8; k     +       +  )
                                             +  			V[i * 8      +   k] = X.i128[k];
                                             +  		xor_salsa8_sse2(&X.i128[0], &X.i128[4]);
                                             +  		xor_salsa8_sse2(&X.i128[4], &X.i128[0]);
                                             +  	}
                                             +  	for (i = 0; i < 1024; i     +       +  ) {
                                             +  		j = 8 * (X.u32[16] & 1023);
                                             +  		for (k = 0; k < 8; k     +       +  )
                                             +  			X.i128[k] = _mm_xor_si128(X.i128[k], V[j      +   k]);
                                             +  		xor_salsa8_sse2(&X.i128[0], &X.i128[4]);
                                             +  		xor_salsa8_sse2(&X.i128[4], &X.i128[0]);
                                             +  	}
                                             +  
                                             +  	for (k = 0; k < 2; k     +       +  ) {
                                             +  		for (i = 0; i < 16; i     +       +  ) {
                                             +  			le32enc(&B[(k * 16      +   (i * 5 % 16)) * 4], X.u32[k * 16      +   i]);
                                             +  		}
                                             +  	}
                                             +  
                                             +  	PBKDF2_SHA256((const uint8_t *)input, 80, B, 128, 1, (uint8_t *)output, 32);
                                             +  }
                                            
                                            1 Reply Last reply Reply Quote 1
                                            • First post
                                              Last post