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

    [Dev] Documenting Feathercoin Specific Software settings - Part 8

    Technical Development
    1
    53
    10094
    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

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

      Fix sx and CKey/CPubKey : - commit

      https://github.com/FeatherCoin/Feathercoin/commit/55252135009938926532ddeabb3ac52d991b4381

      src/key.cpp

      Large amount of code added and removed. Examples of code replaced.

      +#include <map>
      

      Code replaced

       -#include <openssl/bn.h>
      
       -#include <openssl/rand.h>
      

      Code removed

       +void CKey::SetCompressedPubKey(bool fCompressed)
       +    EC_KEY_set_conv_form(pkey, fCompressed ? POINT_CONVERSION_COMPRESSED : POINT_CONVERSION_UNCOMPRESSED);
       +    fCompressedPubKey = true;
      

      Complete functions replaced

       +void CKey::Reset()
      
       +CKey::CKey(const CKey& b)
      
        +bool CKey::SetPrivKey(const CPrivKey& vchPrivKey)
      
        +    const unsigned char* pbegin = &vchPrivKey[0];
      
       +bool CKey::SetSecret(const CSecret& vchSecret, bool fCompressed
      
       +CSecret CKey::GetSecret(bool &fCompressed) const
      
       +CPrivKey CKey::GetPrivKey() const
      
        +CPubKey CKey::GetPubKey() const
      

      Various functions replaced

       +// create a compact signature (65 bytes), which allows reconstructing the used public key
       +// The format is one header byte, followed by two times 32 bytes for the serialized r and s values.
        +// The header byte: 0x1B = first key with even y, 0x1C = first key with odd y,
        +//                  0x1D = second key with even y, 0x1E = second key with o   
      
        +bool CKey::SignCompact(uint256 hash, std::vector<unsigned char>& vchSig)
      

      Code replaced

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

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

        Fix sx and CKey/CPubKey : - commit

        https://github.com/FeatherCoin/Feathercoin/commit/55252135009938926532ddeabb3ac52d991b4381

        src/key.h

         +#include <stdexcept>
         +#include <vector>
        
         +#include "hash.h"
        
        +#include <openssl/ec.h> // for EC_KEY definition
        

        Code added

         + // secp160k1
         + // const unsigned int PRIVATE_KEY_SIZE = 192;
         + // const unsigned int PUBLIC_KEY_SIZE  = 41;
         + // const unsigned int SIGNATURE_SIZE   = 48;
         + //
         + // secp192k1
         + // const unsigned int PRIVATE_KEY_SIZE = 222;
         + // const unsigned int PUBLIC_KEY_SIZE  = 49;
         + // const unsigned int SIGNATURE_SIZE   = 57;
         + //
         + // secp224k1
         + // const unsigned int PRIVATE_KEY_SIZE = 250;
         + // const unsigned int PUBLIC_KEY_SIZE  = 57;
         + // const unsigned int SIGNATURE_SIZE   = 66;
         + //
        

        Code added

         + class key_error : public std::runtime_error
         + {
         + public:
         +     explicit key_error(const std::string& str) : std::runtime_error(str) {}
         + };
         + 
        

        Code added

        +    unsigned char *begin() {
        +        return vch;
        
        Code replaced
        
         +    friend class CKey;
         +
          public:
         +    CPubKey() { vch[0] = 0xFF; }
        

        Code added

         +     CPubKey(const std::vector<unsigned char> &vchPubKeyIn) {
         +         int len = vchPubKeyIn.empty() ? 0 : GetLen(vchPubKeyIn[0]);
         +         if (len) {
         +             memcpy(vch, &vchPubKeyIn[0], len);
         +         } else {
         +             vch[0] = 0xFF;
         +         }
        

        Code replaced

        +    unsigned int size() const {
        +        return GetLen(vch[0]);
        

        Code replaced

        +    const unsigned char *begin() const {
        +        return vch;
        

        Code replaced

         +    const unsigned char *end() const {
         +        return vch+size();
        

        Code replaced

         + 
         +     friend bool operator==(const CPubKey &a, const CPubKey &b) { return memcmp(a.vch, b.vch, a.size()) == 0; }
         +     friend bool operator!=(const CPubKey &a, const CPubKey &b) { return memcmp(a.vch, b.vch, a.size()) != 0; }
        

        Code added

         +               (a.vch[0] == b.vch[0] && memcmp(a.vch+1, b.vch+1, a.size() - 1) < 0);
        

        Code replaced

         +            // invalid pubkey
         +            vch[0] = 0xFF;
        

        Code added

         +    //bool IsFullyValid() const;
        

        Code commented out

        +        return std::vector<unsigned char>(vch, vch+size());
        

        Code replaced

        +/** An encapsulated OpenSSL Elliptic Curve key (public and/or private) */
        +class CKey
        +{
         +protected:
         +    EC_KEY* pkey;
         +    bool fSet;
         +    bool fCompressedPubKey;
        

        Code replaced

        +    void SetCompressedPubKey(bool fCompressed = true);
        
        +    void Reset();
        

        Code replaced

         +     CKey();
         +     CKey(const CKey& b);
         +     CKey& operator=(const CKey& b);
         +     ~CKey();
         +     bool IsNull() const;
         +     bool IsCompressed() const;
         +     bool SetPrivKey(const CPrivKey& vchPrivKey);
         +     bool SetSecret(const CSecret& vchSecret, bool fCompressed = false);
         +     CSecret GetSecret(bool &fCompressed) const;
         +     bool SetPubKey(const CPubKey& vchPubKey);
         +     bool Sign(uint256 hash, std::vector<unsigned char>& vchSig);
         +     // create a compact signature (65 bytes), which allows reconstructing the used public key
         // The format is one header byte, followed by two times 32 bytes for the serialized r and s values.
         // The header byte: 0x1B = first key with even y, 0x1C = first key with odd y,
         +     //                  0x1D = second key with even y, 0x1E = second key with odd y
         +     bool SignCompact(uint256 hash, std::vector<unsigned char>& vchSig);
        

        Code replaced

         +     // reconstruct public key from a compact signature
         +     // This is only slightly more CPU intensive than just verifying it.
         +     // If this function succeeds, the recovered public key is guaranteed to be valid
         +     // (the signature is a valid signature of the given data for that key)
         +     bool SetCompactSignature(uint256 hash, const std::vector<unsigned char>& vchSig);
        

        Code replaced

         +    bool Verify(uint256 hash, const std::vector<unsigned char>& vchSig);
        

        Code replaced

         +     // Verify a compact signature
         +     bool VerifyCompact(uint256 hash, const std::vector<unsigned char>& vchSig);
        

        Code replaced

         +     bool IsValid();
         +     
         +     // Check whether an element of a signature (r or s) is valid.
         +     static bool CheckSignatureElement(const unsigned char *vch, int len, bool half);
        

        Code replaced

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

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

          Fix sx and CKey/CPubKey : - commit

          https://github.com/FeatherCoin/Feathercoin/commit/55252135009938926532ddeabb3ac52d991b4381

          src/keystore.cpp

          +bool CBasicKeyStore::AddKey(const CKey& key)
          

          Code replaced

           +     bool fCompressed = false;
           +     CSecret secret = key.GetSecret(fCompressed);
           +     {
           +         LOCK(cs_KeyStore);
           +         mapKeys[key.GetPubKey().GetID()] = make_pair(secret, fCompressed);
           +     } 
          

          Code replaced

           +     {
           +         LOCK(cs_KeyStore);
           +         mapScripts[redeemScript.GetID()] = redeemScript;
           +     }
          

          Code replaced

           +     bool result;
           +     {
           +         LOCK(cs_KeyStore);
           +         result = (mapScripts.count(hash) > 0);
           +     }
           +     return result;
          

          Code replaced

           +         LOCK(cs_KeyStore);
           +         ScriptMap::const_iterator mi = mapScripts.find(hash);
           +         if (mi != mapScripts.end())
           +         {
           +             redeemScriptOut = (*mi).second;
           +            return true;
          

          Code replaced

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

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

            Fix sx and CKey/CPubKey : - commit

            https://github.com/FeatherCoin/Feathercoin/commit/55252135009938926532ddeabb3ac52d991b4381

            src/keystore.h

             +     //virtual bool AddKeyPubKey(const CKey &key, const CPubKey &pubkey) =0;
             +     //virtual bool AddKey(const CKey &key);
             +     virtual bool AddKey(const CKey& key) =0;
            

            Code replaced

             +     
             +     virtual bool GetSecret(const CKeyID &address, CSecret& vchSecret, bool &fCompressed) const
             +     {
             +         CKey key;
             +         if (!GetKey(address, key))
             +             return false;
             +         vchSecret = key.GetSecret(fCompressed);
             +         return true;
             +     }
            

            Code replaced

             +//typedef std::map<CKeyID, CKey> KeyMap;
             +typedef std::map<CKeyID, std::pair<CSecret, bool> > KeyMap;
            

            Code replaced

             +    //bool AddKeyPubKey(const CKey& key, const CPubKey &pubkey);
             +    bool AddKey(const CKey& key);
            

            Code replaced

            +                keyOut.Reset();
            +                keyOut.SetSecret((*mi).second.first, (*mi).second.second);
            

            Code replaced

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

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

              Fix sx and CKey/CPubKey : - commit

              https://github.com/FeatherCoin/Feathercoin/commit/55252135009938926532ddeabb3ac52d991b4381

              src/qt/bitcoingui.cpp

               +    debugAction = new QAction(QIcon(":/icons/sx"), tr("&SX Tool"), this);
               +    debugAction->setStatusTip(tr("SX Tool"));
              

              Code replaced

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

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

                Fix sx and CKey/CPubKey : - commit

                https://github.com/FeatherCoin/Feathercoin/commit/55252135009938926532ddeabb3ac52d991b4381

                src/qt/bitcoingui.cpp

                 + #include "stealth.h"
                 + #include "base58.h"
                 + #include "wallet.h"
                 + #include "walletmodel.h"
                 + #include "init.h"
                

                Code added

                 +     
                 +     if (ui->addressEdit->text().length()>=75)
                 +     {
                 + 	    CStealthAddress sxAddr;
                 + 	    if (sxAddr.SetEncoded(ui->addressEdit->text().toStdString()))
                 + 	    {
                 + 	    	ui->lblPubkey->setText("");
                 + 	    	ui->lblPrikey->setText("");
                 + 	    	ui->lblScanPubkey->setText(HexStr(sxAddr.scan_pubkey).c_str());
                 + 	    	ui->lblScanSecret->setText(HexStr(sxAddr.scan_secret).c_str());
                 + 	    	ui->lblSpendPubkey->setText(HexStr(sxAddr.spend_pubkey).c_str());
                 + 	    	ui->lblSpendSecret->setText(HexStr(sxAddr.spend_secret).c_str());
                 + 	    }
                 +   	}
                 +   	else
                 +   	{
                 +   		CBitcoinAddress address(ui->addressEdit->text().toStdString());
                 +       CKeyID keyID;
                 +       if ( !address.GetKeyID(keyID) )
                 +       {
                 +           QMessageBox::warning(this, windowTitle(),
                 +               tr("Address \"%1\" doesn't have public key ").arg(ui->addressEdit->text()),
                 +               QMessageBox::Ok, QMessageBox::Ok);
                 +           return;
                 +       }
                 +       CPubKey vchPubKey;
                 +       if ( !pwalletMain->GetPubKey(keyID, vchPubKey))
                 +       {
                 +           QMessageBox::warning(this, windowTitle(),
                 +               tr("Address \"%1\" doesn't have public key ").arg(ui->addressEdit->text()),
                 +               QMessageBox::Ok, QMessageBox::Ok);
                 +           return;
                 +       }
                 +       CSecret vchSecret;
                 +       bool fCompressed;
                 +       if (!pwalletMain->GetSecret(keyID, vchSecret, fCompressed))
                 +       {
                 +           QMessageBox::warning(this, windowTitle(),
                 +               tr("Address \"%1\" doesn't have private key ").arg(ui->addressEdit->text()),
                 +               QMessageBox::Ok, QMessageBox::Ok);
                 +           return;
                 +       }
                 +       ui->lblPubkey->setText(HexStr(vchPubKey).c_str());
                 +       ui->lblPrikey->setText(CBitcoinSecret(vchSecret, fCompressed).ToString().c_str());
                 +       GUIUtil::setClipboard(QString::fromStdString(HexStr(vchPubKey)));
                 +       
                 +     	ui->lblScanPubkey->setText("");
                 +     	ui->lblScanSecret->setText("");
                 +     	ui->lblSpendPubkey->setText("");
                 +     	ui->lblSpendSecret->setText("");
                 +   	}
                

                Code added

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

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

                  Fix sx and CKey/CPubKey : - commit

                  https://github.com/FeatherCoin/Feathercoin/commit/55252135009938926532ddeabb3ac52d991b4381

                  src/qt/feathercoin.qrc

                   +        <file alias="sx">res/icons/sx.png</file>
                  

                  Code added

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

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

                    Fix sx and CKey/CPubKey : - commit

                    https://github.com/FeatherCoin/Feathercoin/commit/55252135009938926532ddeabb3ac52d991b4381

                    src/qt/forms/debugdialog.ui

                     +   <string>Stealth Transaction Tool (experts only!)</string>
                    
                     +    <string>Find My Stealth Transactions From Height:</string>
                    

                    GUI changes done through Qt

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

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

                      Fix sx and CKey/CPubKey : - commit

                      https://github.com/FeatherCoin/Feathercoin/commit/55252135009938926532ddeabb3ac52d991b4381

                      src/qt/forms/editaddressdialog.ui

                       +      <item row="3" column="0">
                       +       <widget class="QLabel" name="label_3">
                       +        <property name="text">
                       +         <string>Public Key</string>
                       +        </property>
                       +       </widget>
                       +      </item>
                       +      <item row="4" column="0">
                       +       <widget class="QLabel" name="label_4">
                       +        <property name="text">
                       +         <string>Private Key</string>
                      

                      Various UI changes

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

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

                        Fix sx and CKey/CPubKey : - commit

                        https://github.com/FeatherCoin/Feathercoin/commit/55252135009938926532ddeabb3ac52d991b4381

                        src/qt/locale/bitcoin_zh_CN.ts

                        Translation file

                         +         <source>&amp;SX Tool</source>
                         +         <translation>隐身交易助手</translation>
                         +     </message>
                         +     <message>
                        

                        Code added

                         +     <name>DebugDialog</name>
                         +     <message>
                         +         <source>Exit</source>
                         +         <translation>关闭</translation>
                         +     </message>
                         +     <message>
                         +         <source>Stealth Transaction Tool (experts only!)</source>
                         +         <translation>隐身交易助手(仅专家)</translation>
                         +     </message>
                         +     <message>
                         +         <source>Find My Stealth Transactions From Height:</source>
                         +         <translation>在块链中查找我的隐身交易,从开始块号</translation>
                         +     </message>
                         +     <message>
                         +         <source>To</source>
                         +         <translation>到</translation>
                         +     </message>
                         +     <message>
                         +         <source>Ending Height must be greater than beginning Height !</source>
                         +         <translation>结束块号必须大于开始块号</translation>
                         +     </message>
                         +     <message>
                         +         <source>Beginning Height must be greater than 556535.</source>
                         +         <translation>开始块号必须大于556535。</translation>
                         +     </message>
                         +     <message>
                         +         <source>Scan stealth transactions on blockchain,Yes!!!</source>
                         +         <translation>从块链中扫描隐身交易,完毕!</translation>
                         +     </message>
                         +     <message>
                         +         <source>Wallet Message</source>
                         +         <translation>钱包信息</translation>
                         +     </message>
                         +     <message>
                         +         <source>Block Number</source>
                         +         <translation>块编号</translation>
                         +     </message>
                         +     <message>
                         +         <source>Scan Stealth Transactions</source>
                         +         <translation>开始扫描隐身交易</translation>
                         +     </message>
                         + </context>
                         + <context>
                        

                        Code added

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

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

                          Fix sx and CKey/CPubKey : - commit

                          https://github.com/FeatherCoin/Feathercoin/commit/55252135009938926532ddeabb3ac52d991b4381

                          src/qt/res/icons/*

                           src/qt/res/icons/sx.png
                          

                          icon file added

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

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

                            Fix sx and CKey/CPubKey : - commit

                            https://github.com/FeatherCoin/Feathercoin/commit/55252135009938926532ddeabb3ac52d991b4381

                            src/qt/signverifymessagedialog.cpp

                             +     //CPubKey pubkey;
                             +     CKey key;
                             +     //if (!pubkey.RecoverCompact(Hash(ss.begin(), ss.end()), vchSig))
                             +     if (!key.SetCompactSignature(Hash(ss.begin(), ss.end()), vchSig))
                            

                            Code replaced

                             +    //if (!(CBitcoinAddress(pubkey.GetID()) == addr))
                             +    if (!(CBitcoinAddress(key.GetPubKey().GetID()) == addr))
                            

                            Code replaced

                            1 Reply Last reply Reply Quote 0
                            • First post
                              Last post