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

    [Dev] Documenting Feathercoin Specific Software settings - Part 6

    Technical Development
    1
    50
    10274
    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.*

      Add stealth address : - commit

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

      src/crypter.h

       -    CryptedKeyMap mapCryptedKeys;
       -
       -    CKeyingMaterial vMasterKey;
       -
      

      Code removed

       +     CryptedKeyMap mapCryptedKeys;
       + 
       +     CKeyingMaterial vMasterKey;
       + 
      

      Code added

       +    //bool Lock();
       +    bool LockKeyStore();
      

      code replaced

      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.*

        Add stealth address : - commit

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

        src/key.cpp

         + bool CKey::SetSecret(const CSecret& vchSecret, bool fCompressedIn)
         + {
         +     if (vchSecret.size() != 32)
         +         return false;
         +         
         + 		CECKey key;       
         + 		key.SetSecretBytes(&vchSecret[0]);
         +     
         +     fCompressed = fCompressedIn;
         +     fValid = true;
         + 		return true;
         + 		
         +     /*EC_KEY_free(pkey);
         +     pkey = EC_KEY_new_by_curve_name(NID_secp256k1);
         +     if (pkey == NULL)
         +         return false;
         +     if (vchSecret.size() != 32)
         +         return false;
         +     BIGNUM *bn = BN_bin2bn(&vchSecret[0],32,BN_new());
         +     if (bn == NULL)
         +         return false;
         +     if (!EC_KEY_regenerate_key(pkey,bn))
         +     {
         +         BN_clear_free(bn);
         +         return false;
         +     }
         +     BN_clear_free(bn);
         +     fValid = true;
         +     if (fCompressed )
         +         SetCompressedPubKey();
         +     return true;*/
         + }
         + 
        

        Code added

        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.*

          Add stealth address : - commit

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

          src/key.h

           +     std::vector<unsigned char> Raw() const {
           +     		std::vector<unsigned char> vchPubKey(begin(),end());  
           +         return vchPubKey;
           +     }
           +     
          

          Code added

            +// CSecret is a serialization of just the secret parameter (32 bytes)
           +typedef std::vector<unsigned char, secure_allocator<unsigned char> > CSecret;
          

          Code added

          +		bool SetSecret(const CSecret& vchSecret, bool fCompressed = false);
          

          Code added

          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.*

            Add stealth address : - commit

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

            src/main.cpp

             +    unsigned int nTxnOut = 0;
            

            Code added

             +        {
                     nDataOut++;
              +        } 
            

            Bracketing 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.*

              Add stealth address : - commit

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

              src/qt/addressbookpage.cpp

               + 		ui->tableView->horizontalHeader()->resizeSection(0, 140);
               + 		ui->tableView->horizontalHeader()->resizeSection(1, 600);
              

              Code added

              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.*

                Add stealth address : - commit

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

                src/qt/addresstablemodel.cpp

                + #include "stealth.h"
                
                + bool stealth;
                

                Code added

                 +    AddressTableEntry(Type type, const QString &label, const QString &address, const bool &stealth = false):
                 +        type(type), label(label), address(address), stealth(stealth) {}
                

                Code replaced

                 +             std::set<CStealthAddress>::iterator it;
                 +             for (it = wallet->stealthAddresses.begin(); it != wallet->stealthAddresses.end();      +      + it)
                 +             {
                 +                 bool fMine = !(it->scan_secret.size() < 1);
                 +                 cachedAddressTable.append(AddressTableEntry(fMine ? AddressTableEntry::Receiving : AddressTableEntry::Sending,
                 +                                   QString::fromStdString(it->label),
                 +                                   QString::fromStdString(it->Encoded()),
                 +                                   true));
                 +             };
                

                Code added

                  +    std::string strTemp, strValue;
                

                Code added

                 -            wallet->SetAddressBook(curAddress, value.toString().toStdString(), strPurpose);
                

                Code removed

                 +             //wallet->SetAddressBook(curAddress, value.toString().toStdString(), strPurpose);
                 +             strTemp = rec->address.toStdString();
                 +             if (IsStealthAddress(strTemp))
                 +             {
                 +                 strValue = value.toString().toStdString();
                 +                 wallet->UpdateStealthAddress(strTemp, strValue, false);
                 +             } else
                 +             {
                 +                 //wallet->SetAddressBookName(CBitcoinAddress(strTemp).Get(), value.toString().toStdString());
                 +                 wallet->SetAddressBook(CBitcoinAddress(strTemp).Get(), value.toString().toStdString(), strPurpose);
                 +    
                

                Code added

                 +             std::string sTemp = value.toString().toStdString();
                 +             if (IsStealthAddress(sTemp))
                 +             {
                 +                 printf("IsStealthAddress = INVALID_ADDRESS\n");
                 +                 editStatus = INVALID_ADDRESS;
                 +                 return false;
                 +             }
                

                Code added

                 - QString AddressTableModel::addRow(const QString &type, const QString &label, const QString &address)
                 + QString AddressTableModel::addRow(const QString &type, const QString &label, const QString &address, int addressType)
                

                Code replaced

                 +      /*  if(!walletModel->validateAddress(address))
                

                Code added

                 +         }*/
                 +         if (strAddress.length() > 75)
                 +         {
                 +             CStealthAddress sxAddr;
                 +             if (!sxAddr.SetEncoded(strAddress))
                 +             {
                 +                 editStatus = INVALID_ADDRESS;
                 +                 return QString();
                 +             }
                 +             
                 +             // Check for duplicate addresses
                 +             {
                 +                 LOCK(wallet->cs_wallet);
                 +                 
                 +                 if (wallet->stealthAddresses.count(sxAddr))
                 +                 {
                 +                     editStatus = DUPLICATE_ADDRESS;
                 +                     return QString();
                 +                 };
                 +                 
                 +                 sxAddr.label = strLabel;
                 +                 wallet->AddStealthAddress(sxAddr);
                 +             }
                 +         } else {
                 +             if (!walletModel->validateAddress(address))
                 +             {
                 +                 editStatus = INVALID_ADDRESS;
                 +                 return QString();
                 +             }
                 +             // Check for duplicate addresses
                 +             {
                 +                 LOCK(wallet->cs_wallet);
                 +                 if (wallet->mapAddressBook.count(CBitcoinAddress(strAddress).Get()))
                 +                 {
                 +                     editStatus = DUPLICATE_ADDRESS;
                 +                     return QString();
                 +                 };
                 +                 //wallet->SetAddressBookName(CBitcoinAddress(strAddress).Get(), strLabel);
                 +                 wallet->SetAddressBook(CBitcoinAddress(strAddress).Get(), strLabel,(type == Send ? "send" : "receive"));
                 +             }
                

                Code added

                 -        CPubKey newKey;
                 +       /* CPubKey newKey;
                

                Code removed

                 +         */
                 +         WalletModel::UnlockContext ctx(walletModel->requestUnlock());
                 +         if(!ctx.isValid())
                 +         {
                 +             // Unlock wallet failed or was cancelled
                 +             editStatus = WALLET_UNLOCK_FAILURE;
                 +             return QString();
                 +         }
                 +         if (addressType == AT_Stealth)
                 +         {
                 +             CStealthAddress newStealthAddr;
                 +             std::string sError;
                 +             if (!wallet->NewStealthAddress(sError, strLabel, newStealthAddr)
                 +                 || !wallet->AddStealthAddress(newStealthAddr))
                 +             {
                 +                 editStatus = KEY_GENERATION_FAILURE;
                 +                 return QString();
                 +             }
                 +             strAddress = newStealthAddr.Encoded();
                 +         } else {
                 +             CPubKey newKey;
                 +             //if(!wallet->GetKeyFromPool(newKey, true))
                 +             if(!wallet->GetKeyFromPool(newKey))
                 +             {
                 +                 editStatus = KEY_GENERATION_FAILURE;
                 +                 return QString();
                 +             }
                 +             strAddress = CBitcoinAddress(newKey.GetID()).ToString();
                 +             
                 +             {
                 +                 LOCK(wallet->cs_wallet);
                 +                 //wallet->SetAddressBookName(CBitcoinAddress(strAddress).Get(), strLabel);
                 +                 wallet->SetAddressBook(CBitcoinAddress(strAddress).Get(), strLabel,(type == Send ? "send" : "receive"));
                 +             }
                 +         }
                

                Code added

                -    {
                +     /*{
                     LOCK(wallet->cs_wallet);
                      wallet->SetAddressBook(CBitcoinAddress(strAddress).Get(), strLabel,
                                            (type == Send ? "send" : "receive"));
                
                 -    }
                 +     }*/
                

                Bracketing removed

                 +   /*  {
                         LOCK(wallet->cs_wallet);
                         CBitcoinAddress address_parsed(address.toStdString());
                         std::map<CTxDestination, CAddressBookData>::iterator mi = wallet->mapAddressBook.find(address_parsed.Get());
                         if (mi != wallet->mapAddressBook.end())
                         {
                             return QString::fromStdString(mi->second.name);
                         }
                 +     }*/
                

                Bracketing commented out.

                 +     {
                 +         LOCK(wallet->cs_wallet);
                 +         std::string sAddr = address.toStdString();
                 +         
                 +         if (sAddr.length() > 75)
                 +         {
                 +             CStealthAddress sxAddr;
                 +             if (!sxAddr.SetEncoded(sAddr))
                 +                 return QString();
                 +             
                 +             std::set<CStealthAddress>::iterator it;
                 +             it = wallet->stealthAddresses.find(sxAddr);
                 +             if (it == wallet->stealthAddresses.end())
                 +                 return QString();
                 +             
                 +             return QString::fromStdString(it->label);
                 +         } else
                 +         {
                 +             CBitcoinAddress address_parsed(sAddr);
                 +             std::map<CTxDestination, CAddressBookData>::iterator mi = wallet->mapAddressBook.find(address_parsed.Get());
                 +             if (mi != wallet->mapAddressBook.end())
                 +             {
                 +                 return QString::fromStdString(mi->second.name);
                 +             }
                 +         }
                

                Code added

                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.*

                  Add stealth address : - commit

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

                  src/qt/addresstablemodel.h

                   +     enum AddressType {
                   +         AT_Unknown = 0, /**< User specified label */
                   +         AT_Normal = 1,  /**< Bitcoin address */
                   +         AT_Stealth = 2  /**< Stealth address */
                   +     };
                   +     
                  

                  Code added

                   -        Address = 1  /**< Bitcoin address */
                  +        Address = 1,  /**< Bitcoin address */
                  +        Type = 2  /**< Address type  */
                  

                  ? review

                   -    QString addRow(const QString &type, const QString &label, const QString &address);
                   +     //QString addRow(const QString &type, const QString &label, const QString &address);
                   +     QString addRow(const QString &type, const QString &label, const QString &address, int addressType);
                  

                  Bitcoin code commented out, review.

                  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.*

                    Add stealth address : - commit

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

                    src/qt/bitcoingui.cpp

                     + 	
                     + ActiveLabel::ActiveLabel(const QString & text, QWidget * parent):
                     +     QLabel(parent){}
                     + 
                     + void ActiveLabel::mouseReleaseEvent(QMouseEvent * event)
                     + {
                     +     emit clicked();
                     + }
                    

                    Code added

                     +    walletModel(0),
                    

                    Code added

                    -    labelEncryptionIcon = new QLabel();
                    +    labelEncryptionIcon = new ActiveLabel();
                    

                    Code replaced

                     +    connect(labelEncryptionIcon, SIGNAL(clicked()), unlockWalletAction, SLOT(trigger()));
                    

                    Code added

                     +         disconnect(labelEncryptionIcon, SIGNAL(clicked()), unlockWalletAction, SLOT(trigger()));
                     +         disconnect(labelEncryptionIcon, SIGNAL(clicked()),   lockWalletAction, SLOT(trigger()));
                     +         connect   (labelEncryptionIcon, SIGNAL(clicked()),   lockWalletAction, SLOT(trigger()));
                    

                    Code added

                     +         disconnect(labelEncryptionIcon, SIGNAL(clicked()), unlockWalletAction, SLOT(trigger()));
                     +         disconnect(labelEncryptionIcon, SIGNAL(clicked()),   lockWalletAction, SLOT(trigger()));
                     +         connect   (labelEncryptionIcon, SIGNAL(clicked()), unlockWalletAction, SLOT(trigger()));
                    

                    Code added

                    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.*

                      Add stealth address : - commit

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

                      src/qt/bitcoingui.h

                      +#include <QLabel>
                      

                      Code added

                       + class ActiveLabel : public QLabel
                       + {
                       +     Q_OBJECT
                       + public:
                       +     ActiveLabel(const QString & text = "", QWidget * parent = 0);
                       +     ~ActiveLabel(){}
                       + 
                       + signals:
                       +     void clicked();
                       + 
                       + protected:
                       +     void mouseReleaseEvent (QMouseEvent * event) ;
                       + 
                       + };
                       + 
                      

                      Code added

                        -    QLabel *labelEncryptionIcon;
                        +    ActiveLabel *labelEncryptionIcon;
                      

                      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.*

                        Add stealth address : - commit

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

                        src/qt/editaddressdialog.cpp

                         +         ui->addressEdit->setVisible(false);
                         +         ui->stealthCB->setEnabled(true);
                         +         ui->stealthCB->setVisible(true);
                        
                         +         ui->stealthCB->setVisible(false);
                        
                         +         ui->addressEdit->setVisible(true);
                         +         ui->stealthCB->setEnabled(false);
                         +         ui->stealthCB->setVisible(true);
                        
                         +         ui->stealthCB->setVisible(false);
                        
                         +     mapper->addMapping(ui->stealthCB, AddressTableModel::Type);
                        

                        Code added

                         -        address = model     ->addRow(
                         -                mode == NewSendingAddress ? AddressTableModel::Send : AddressTableModel::Receive,
                         -                ui     ->labelEdit     ->text(),
                         -                ui     ->addressEdit     ->text());
                        

                        Code removed

                         +     	  {
                         +     	   int typeInd  = ui->stealthCB->isChecked() ? AddressTableModel::AT_Stealth : AddressTableModel::AT_Normal;
                         +          address = model->addRow(
                         +                    mode == NewSendingAddress ? AddressTableModel::Send : AddressTableModel::Receive,
                         +                    ui->labelEdit->text(),
                         +                    ui->addressEdit->text(),
                         +                    typeInd);
                         +         }
                        

                        Code replaced

                        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.*

                          Add stealth address : - commit

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

                          src/qt/forms/editaddressdialog.ui

                           +      <item row="2" column="0">
                           +       <widget class="QCheckBox" name="stealthCB">
                           +        <property name="text">
                           +         <string>Stealth Address</string>
                           +        </property>
                           +       </widget>
                           +      </item>
                          

                          Code added

                          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.*

                            Add stealth address : - commit

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

                            src/qt/receivecoinsdialog.cpp

                             -        address = model     ->getAddressTableModel()     ->addRow(AddressTableModel::Receive, label, "");
                             +      int typeInd  = AddressTableModel::AT_Normal;
                             +      address = model     ->getAddressTableModel()     ->addRow(AddressTableModel::Receive, label, "",typeInd);
                            

                            Code replaced

                             -    ui->reqAmount->value(), ui->reqMessage->text());
                             +   ui->reqAmount->value(), ui->reqMessage->text());
                            

                            Code replaced

                            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.*

                              Add stealth address : - commit

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

                              src/qt/sendcoinsdialog.cpp

                              +		//QMessageBox::information(NULL, "Info1", "Click_SendButton", QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
                              

                              Code added

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

                                Add stealth address : - commit

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

                                src/qt/sendcoinsentry.cpp

                                 + #include "stealth.h"
                                
                                 + #include <QDebug>
                                

                                Code added

                                 +     
                                 +     if (recipient.address.length() > 75 
                                 +         && IsStealthAddress(recipient.address.toStdString()))
                                 +         recipient.typeInd = AddressTableModel::AT_Stealth;
                                 +     else
                                 +         recipient.typeInd = AddressTableModel::AT_Normal;
                                 +         	
                                 +     qDebug() << "SendCoinsEntry::getValue,recipient.typeInd ="     + QString::number(recipient.typeInd);
                                

                                Code added

                                 +     
                                 +     if (recipient.address.length() > 75 
                                 +         && IsStealthAddress(recipient.address.toStdString()))
                                 +         recipient.typeInd = AddressTableModel::AT_Stealth;
                                 +     else
                                 +         recipient.typeInd = AddressTableModel::AT_Normal;
                                 +         	
                                 +     qDebug() << "SendCoinsEntry::getValue,recipient.typeInd ="+ QString::number(recipient.typeInd);
                                

                                Code added

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

                                  Add stealth address : - commit

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

                                  src/qt/transactiondesc.cpp

                                   +         char cbuf[256];
                                   +         for (int k = 0; k < wtx.vout.size();      +      + k)
                                   +         {
                                   +             snprintf(cbuf, sizeof(cbuf), "n_%d", k);
                                   +             if (wtx.mapValue.count(cbuf) && !wtx.mapValue[cbuf].empty())
                                   +                 strHTML      + = "<br><b>"      +  tr(cbuf)      +  ":</b> "      +  GUIUtil::HtmlEscape(wtx.mapValue[cbuf], true)      +  "<br>";
                                   +         }
                                   +         
                                  

                                  Code added

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

                                    Add stealth address : - commit

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

                                    src/qt/walletmodel.cpp

                                     + #include <QMessageBox>
                                     + 
                                     + #if defined(_MSC_VER) || defined(__MSVCRT__)
                                     +   /* (s)size_t and ptrdiff_t have the same size specifier in MSVC:
                                     +      http://msdn.microsoft.com/en-us/library/tcxf1dw6%28v=vs.100%29.aspx
                                     +    */
                                     +   #define PRIszx    "Ix"
                                     +   #define PRIszu    "Iu"
                                     +   #define PRIszd    "Id"
                                     +   #define PRIpdx    "Ix"
                                     +   #define PRIpdu    "Iu"
                                     +   #define PRIpdd    "Id"
                                     + #else /* C99 standard */
                                     +   #define PRIszx    "zx"
                                     +   #define PRIszu    "zu"
                                     +   #define PRIszd    "zd"
                                     +   #define PRIpdx    "tx"
                                     +   #define PRIpdu    "tu"
                                     +   #define PRIpdd    "td"
                                     + #endif
                                    

                                    Additional code

                                     -    CBitcoinAddress addressParsed(address.toStdString());
                                    

                                    Code removed

                                     +     std::string sAddr = address.toStdString();
                                     +     
                                     +     if (sAddr.length() > 75)
                                     +     {
                                     +         if (IsStealthAddress(sAddr))
                                     +             return true;
                                     +     };
                                     +     
                                     +     CBitcoinAddress addressParsed(sAddr);
                                    

                                    Code replaced

                                    •    {   // User-entered feathercoin address / amount:
                                      

                                    Comment changed? name to Feathercoin

                                     +             std::string sAddr = rcp.address.toStdString();            
                                     +             if (rcp.typeInd == AddressTableModel::AT_Stealth)
                                     +             {
                                     +                 CStealthAddress sxAddr;
                                     +                 if (sxAddr.SetEncoded(sAddr))
                                     +                 {
                                     +                     ec_secret ephem_secret;
                                     +                     ec_secret secretShared;
                                     +                     ec_point pkSendTo;
                                     +                     ec_point ephem_pubkey;
                                     +                     
                                     +                     
                                     +                     if (GenerateRandomSecret(ephem_secret) != 0)
                                     +                     {
                                     +                         printf("GenerateRandomSecret failed.\n");
                                     +                         return Aborted;
                                     +                     };
                                     +                     
                                     +                     if (StealthSecret(ephem_secret, sxAddr.scan_pubkey, sxAddr.spend_pubkey, secretShared, pkSendTo) != 0)
                                     +                     {
                                     +                         printf("Could not generate receiving public key.\n");
                                     +                         return Aborted;
                                     +                     };
                                     +                     
                                     +                     CPubKey cpkTo(pkSendTo);
                                     +                     if (!cpkTo.IsValid())
                                     +                     {
                                     +                         printf("Invalid public key generated.\n");
                                     +                         return Aborted;
                                     +                     };
                                     +                     
                                     +                     CKeyID ckidTo = cpkTo.GetID();
                                     +                     
                                     +                     CBitcoinAddress addrTo(ckidTo);
                                     +                     
                                     +                     if (SecretToPublicKey(ephem_secret, ephem_pubkey) != 0)
                                     +                     {
                                     +                         printf("Could not generate ephem public key.\n");
                                     +                         return Aborted;
                                     +                     };
                                     +                     
                                     +                     //if (fDebug)
                                     +                     if (true)
                                     +                     {
                                     +                         LogPrintf("Stealth send to generated pubkey %"PRIszu": %s\n", pkSendTo.size(), HexStr(pkSendTo).c_str());
                                     +                         LogPrintf("hash %s\n", addrTo.ToString().c_str());
                                     +                         LogPrintf("ephem_pubkey %"PRIszu": %s\n", ephem_pubkey.size(), HexStr(ephem_pubkey).c_str());
                                     +                     };
                                     +                     
                                     +                     CScript scriptPubKey;
                                     +                     scriptPubKey.SetDestination(addrTo.Get());
                                     +                     LogPrintf("scriptPubKey= %s \n", scriptPubKey.ToString());
                                     +                     
                                     +                     vecSend.push_back(make_pair(scriptPubKey, rcp.amount));
                                     +                     
                                     +                     CScript scriptP = CScript() << OP_RETURN << ephem_pubkey;
                                     +                     vecSend.push_back(make_pair(scriptP, 0));
                                     +                     
                                     +                     continue;
                                     +                 }; // else drop through to normal
                                     +             }
                                     +     
                                    

                                    Code added

                                     -            scriptPubKey.SetDestination(CBitcoinAddress(rcp.address.toStdString()).Get());
                                     +            //scriptPubKey.SetDestination(CBitcoinAddress(rcp.address.toStdString()).Get());
                                    
                                     +            scriptPubKey.SetDestination(CBitcoinAddress(sAddr).Get());
                                    

                                    Code commented out?? review

                                     +        int nChangePos = -1;
                                    

                                    Code added

                                     -        bool fCreated = wallet->CreateTransaction(vecSend, *newTx, *keyChange, nFeeRequired, strFailReason, coinControl);
                                     +         bool fCreated = wallet->CreateTransaction(vecSend, *newTx, *keyChange, nFeeRequired, nChangePos, strFailReason, coinControl);
                                    

                                    Code replaced

                                    +            else if (!rcp.message.isEmpty()) // Message from normal feathercoin:URI (feathercoin:123...?message=example)
                                    

                                    Code replaced name

                                     + 	//Run//QMessageBox::information(NULL, "Info2", "Click_sendCoins", QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
                                               CReserveKey *keyChange = transaction.getPossibleKeyChange();
                                     +         LogPrintf("sendCoins: newTx= \n%s", newTx->ToString());
                                     +     
                                    

                                    Code commented out ? code added

                                     +				//string strError =wallet->SendMoneyToDestination(rcp.label, transaction.GetValueOut(), *newTx);
                                    

                                    Code added

                                     +    //No Run//
                                    

                                    Comment added

                                     -                std::map<CTxDestination, CAddressBookData>::iterator mi = wallet     ->mapAddressBook.find(dest);
                                     -
                                     -                // Check if we have a new address or an updated label
                                     -                if (mi == wallet     ->mapAddressBook.end())
                                     -                {
                                     -                    wallet     ->SetAddressBook(dest, strLabel, "send");
                                     -                }
                                     -                else if (mi     ->second.name != strLabel)
                                     -                {
                                     -                    wallet     ->SetAddressBook(dest, strLabel, ""); // "" means don't change purpose
                                     -                }
                                     -            }
                                    

                                    Code removed

                                     + 		            if (rcp.typeInd == AddressTableModel::AT_Stealth)
                                     + 		            {
                                     + 		                wallet->UpdateStealthAddress(strAddress, strLabel, true);
                                     + 		            } else 
                                     + 		            {
                                     + 		                std::map<CTxDestination, CAddressBookData>::iterator mi = wallet->mapAddressBook.find(dest);
                                     + 		                // Check if we have a new address or an updated label
                                     + 		                if (mi == wallet->mapAddressBook.end())
                                     + 		                {
                                     + 		                    wallet->SetAddressBook(dest, strLabel, "send");
                                     + 		                }
                                     + 		                else if (mi->second.name != strLabel)
                                     + 		                {
                                     + 		                    wallet->SetAddressBook(dest, strLabel, ""); // "" means don't change purpose
                                     + 		                }
                                     + 		            }
                                     +           	}
                                    

                                    Code added

                                    +        LogPrintf("sendCoins: updateAddressBook. \n");
                                    

                                    Log interface message added

                                    - static void NotifyAddressBookChanged(WalletModel *walletmodel, CWallet *wallet,
                                    + /*static void NotifyAddressBookChanged(WalletModel *walletmodel, CWallet *wallet,
                                    

                                    Commented out? should be deleted if not used…

                                     + }*/
                                     + static void NotifyAddressBookChanged(WalletModel *walletmodel, CWallet *wallet, 
                                     +         const CTxDestination &address, const std::string &label, bool isMine, 
                                     +         const std::string &purpose, ChangeType status)
                                     + {
                                     +     QString strAddress = QString::fromStdString(CBitcoinAddress(address).ToString());
                                     +     QString strLabel = QString::fromStdString(label);
                                     +     QString strPurpose = QString::fromStdString(purpose);
                                     + 	
                                     +     if (address.type() == typeid(CStealthAddress))
                                     +     {
                                     +         CStealthAddress sxAddr = boost::get<CStealthAddress>(address);
                                     +         std::string enc = sxAddr.Encoded();
                                     +         //OutputDebugStringF("NotifyAddressBookChanged %s %s isMine=%i status=%i\n", enc.c_str(), label.c_str(), isMine, status);
                                     +         qDebug() << "NotifyAddressBookChanged : "      +  QString::fromStdString(enc)      +  " "      +  QString::fromStdString(label)      +  " isMine="      +  QString::number(isMine)      +  " purpose="      +  strPurpose      +  " status="      +  QString::number(status);
                                     +         QMetaObject::invokeMethod(walletmodel, "updateAddressBook", Qt::QueuedConnection,
                                     +                                   Q_ARG(QString, QString::fromStdString(enc)),
                                     +                                   Q_ARG(QString, QString::fromStdString(label)),
                                     +                                   Q_ARG(bool, isMine),
                                     +                                   Q_ARG(QString, strPurpose),
                                     +                                   Q_ARG(int, status));
                                     +     } else {
                                     +         //OutputDebugStringF("NotifyAddressBookChanged %s %s isMine=%i status=%i\n", CBitcoinAddress(address).ToString().c_str(), label.c_str(), isMine, status);
                                     +         qDebug() << "NotifyAddressBookChanged : "      +  strAddress      +  " "      +  strLabel      +  " isMine="      +  QString::number(isMine)      +  " purpose="      +  strPurpose      +  " status="      +  QString::number(status);
                                     +         QMetaObject::invokeMethod(walletmodel, "updateAddressBook", Qt::QueuedConnection,
                                     +                                   Q_ARG(QString, QString::fromStdString(CBitcoinAddress(address).ToString())),
                                     +                                   Q_ARG(QString, QString::fromStdString(label)),
                                     +                                   Q_ARG(bool, isMine),
                                     +                                   Q_ARG(QString, strPurpose),
                                     +                                   Q_ARG(int, status));
                                     +     }
                                    

                                    Code added

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

                                      Add stealth address : - commit

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

                                      src/qt/walletmodel.h

                                      +    int typeInd;
                                      

                                      Code added

                                        -        TransactionCommitFailed
                                       +        TransactionCommitFailed,
                                       +        Aborted
                                      

                                      ?? code added?

                                      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.*

                                        Add stealth address : - commit

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

                                        src/rpcmisc.cpp

                                         +     Object operator()(const CStealthAddress &stxAddr) const {
                                         +         Object obj;
                                         +         obj.push_back(Pair("todo", true));
                                         +         return obj;
                                         +     }
                                        
                                        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.*

                                          Add stealth address : - commit

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

                                          src/rpcserver.cpp

                                           +     
                                           +     { "getnewstealthaddress",   &getnewstealthaddress,   false,  false,      true },
                                           +     { "liststealthaddresses",   &liststealthaddresses,   false,  false,      true },
                                           +     { "importstealthaddress",   &importstealthaddress,   false,  false,      true },
                                           +     { "sendtostealthaddress",   &sendtostealthaddress,   false,  false,      true },
                                           +     { "clearwallettransactions",&clearwallettransactions,false,  false,      true },
                                           +     { "scanforalltxns",         &scanforalltxns,         false,  false,      true },
                                           +     { "scanforstealthtxns",     &scanforstealthtxns,     false,  false,      true },
                                          

                                          Code added

                                          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.*

                                            Add stealth address : - commit

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

                                            src/rpcserver.h

                                             + extern json_spirit::Value getnewstealthaddress(const json_spirit::Array& params, bool fHelp);
                                             + extern json_spirit::Value liststealthaddresses(const json_spirit::Array& params, bool fHelp);
                                             + extern json_spirit::Value importstealthaddress(const json_spirit::Array& params, bool fHelp);
                                             + extern json_spirit::Value sendtostealthaddress(const json_spirit::Array& params, bool fHelp);
                                             + extern json_spirit::Value clearwallettransactions(const json_spirit::Array& params, bool fHelp);
                                             + extern json_spirit::Value scanforalltxns(const json_spirit::Array& params, bool fHelp);
                                             + extern json_spirit::Value scanforstealthtxns(const json_spirit::Array& params, bool fHelp);
                                             + 
                                            

                                            Code added

                                            src/rpcwallet.cpp

                                            Large number of changes, could stealth code have been a seperate module? / file

                                             +#include "stealth.h"
                                            

                                            Code included

                                             -    if (fHelp || params.size() < 2 || params.size() > 4)
                                             +    if (fHelp || params.size() < 2 || params.size() > 5)
                                            

                                            Code replaced

                                             -    if (fHelp || params.size() < 3 || params.size() > 6)
                                             +     if (fHelp || params.size() < 3 || params.size() > 7)
                                            

                                            Code replaced

                                            +    int nChangePos;
                                            

                                            Code added

                                             -    bool fCreated = pwalletMain->CreateTransaction(vecSend, wtx, keyChange, nFeeRequired, strFailReason);
                                            +    bool fCreated = pwalletMain->CreateTransaction(vecSend, wtx, keyChange, nFeeRequired,nChangePos, strFailReason);
                                            

                                            Code replaced

                                            Main stealth function 1992 to line 2379

                                             + 
                                             + Value getnewstealthaddress(const Array& params, bool fHelp)
                                             + {
                                             +     if (fHelp || params.size() > 1)
                                             +         throw runtime_error(
                                             +             "getnewstealthaddress [label]\n"
                                             +             "Returns a new ShadowCoin stealth address for receiving payments anonymously.  ");
                                             +     
                                             +     if (pwalletMain->IsLocked())
                                             +         throw runtime_error("Failed: Wallet must be unlocked.");
                                             +     
                                             +     std::string sLabel;
                                             +     if (params.size() > 0)
                                             +         sLabel = params[0].get_str();
                                             +     
                                             +     CStealthAddress sxAddr;
                                             +     std::string sError;
                                             +     if (!pwalletMain->NewStealthAddress(sError, sLabel, sxAddr))
                                             +         throw runtime_error(std::string("Could get new stealth address: ")      +  sError);
                                             +     
                                             +     if (!pwalletMain->AddStealthAddress(sxAddr))
                                             +         throw runtime_error("Could not save to wallet.");
                                             +     
                                             +     return sxAddr.Encoded();
                                             + }
                                             + 
                                             + Value liststealthaddresses(const Array& params, bool fHelp)
                                             + {
                                             +     if (fHelp || params.size() > 1)
                                             +         throw runtime_error(
                                             +             "liststealthaddresses [show_secrets=0]\n"
                                             +             "List owned stealth addresses.");
                                             +     
                                             +     bool fShowSecrets = false;
                                             +     
                                             +     if (params.size() > 0)
                                             +     {
                                             +         std::string str = params[0].get_str();
                                             +         
                                             +         if (str == "0" || str == "n" || str == "no" || str == "-" || str == "false")
                                             +             fShowSecrets = false;
                                             +         else
                                             +             fShowSecrets = true;
                                             +     };
                                             +     
                                             +     if (fShowSecrets)
                                             +     {
                                             +         if (pwalletMain->IsLocked())
                                             +             throw runtime_error("Failed: Wallet must be unlocked.");
                                             +     };
                                             +     
                                             +     Object result;
                                             +     
                                             +     std::set<CStealthAddress>::iterator it;
                                             +     for (it = pwalletMain->stealthAddresses.begin(); it != pwalletMain->stealthAddresses.end();      +      + it)
                                             +     {
                                             +         if (it->scan_secret.size() < 1)
                                             +             continue; // stealth address is not owned
                                             +         
                                             +         if (fShowSecrets)
                                             +         {
                                             +             Object objA;
                                             +             objA.push_back(Pair("Label        ", it->label));
                                             +             objA.push_back(Pair("Address      ", it->Encoded()));
                                             +             objA.push_back(Pair("Scan Secret  ", HexStr(it->scan_secret.begin(), it->scan_secret.end())));
                                             +             objA.push_back(Pair("Spend Secret ", HexStr(it->spend_secret.begin(), it->spend_secret.end())));
                                             +             result.push_back(Pair("Stealth Address", objA));
                                             +         } else
                                             +         {
                                             +             result.push_back(Pair("Stealth Address", it->Encoded()      +  " - "      +  it->label));
                                             +         };
                                             +     };
                                             +     
                                             +     return result;
                                             + }
                                             + 
                                             + Value importstealthaddress(const Array& params, bool fHelp)
                                             + {
                                             +     if (fHelp || params.size() < 2)
                                             +         throw runtime_error(
                                             +             "importstealthaddress <scan_secret> <spend_secret> [label]\n"
                                             +             "Import an owned stealth addresses.");
                                             +     
                                             +     std::string sScanSecret  = params[0].get_str();
                                             +     std::string sSpendSecret = params[1].get_str();
                                             +     std::string sLabel;
                                             +     
                                             +     
                                             +     if (params.size() > 2)
                                             +     {
                                             +         sLabel = params[2].get_str();
                                             +     };
                                             +     
                                             +     std::vector<uint8_t> vchScanSecret;
                                             +     std::vector<uint8_t> vchSpendSecret;
                                             +     
                                             +     if (IsHex(sScanSecret))
                                             +     {
                                             +         vchScanSecret = ParseHex(sScanSecret);
                                             +     } else
                                             +     {
                                             +         if (!DecodeBase58(sScanSecret, vchScanSecret))
                                             +             throw runtime_error("Could not decode scan secret as hex or base58.");
                                             +     };
                                             +     
                                             +     if (IsHex(sSpendSecret))
                                             +     {
                                             +         vchSpendSecret = ParseHex(sSpendSecret);
                                             +     } else
                                             +     {
                                             +         if (!DecodeBase58(sSpendSecret, vchSpendSecret))
                                             +             throw runtime_error("Could not decode spend secret as hex or base58.");
                                             +     };
                                             +     
                                             +     if (vchScanSecret.size() != 32)
                                             +         throw runtime_error("Scan secret is not 32 bytes.");
                                             +     if (vchSpendSecret.size() != 32)
                                             +         throw runtime_error("Spend secret is not 32 bytes.");
                                             +     
                                             +     
                                             +     ec_secret scan_secret;
                                             +     ec_secret spend_secret;
                                             +     
                                             +     memcpy(&scan_secret.e[0], &vchScanSecret[0], 32);
                                             +     memcpy(&spend_secret.e[0], &vchSpendSecret[0], 32);
                                             +     
                                             +     ec_point scan_pubkey, spend_pubkey;
                                             +     if (SecretToPublicKey(scan_secret, scan_pubkey) != 0)
                                             +         throw runtime_error("Could not get scan public key.");
                                             +     
                                             +     if (SecretToPublicKey(spend_secret, spend_pubkey) != 0)
                                             +         throw runtime_error("Could not get spend public key.");
                                             +     
                                             +     
                                             +     CStealthAddress sxAddr;
                                             +     sxAddr.label = sLabel;
                                             +     sxAddr.scan_pubkey = scan_pubkey;
                                             +     sxAddr.spend_pubkey = spend_pubkey;
                                             +     
                                             +     sxAddr.scan_secret = vchScanSecret;
                                             +     sxAddr.spend_secret = vchSpendSecret;
                                             +     
                                             +     Object result;
                                             +     bool fFound = false;
                                             +     // -- find if address already exists
                                             +     std::set<CStealthAddress>::iterator it;
                                             +     for (it = pwalletMain->stealthAddresses.begin(); it != pwalletMain->stealthAddresses.end();      +      + it)
                                             +     {
                                             +         CStealthAddress &sxAddrIt = const_cast<CStealthAddress&>(*it);
                                             +         if (sxAddrIt.scan_pubkey == sxAddr.scan_pubkey
                                             +             && sxAddrIt.spend_pubkey == sxAddr.spend_pubkey)
                                             +         {
                                             +             if (sxAddrIt.scan_secret.size() < 1)
                                             +             {
                                             +                 sxAddrIt.scan_secret = sxAddr.scan_secret;
                                             +                 sxAddrIt.spend_secret = sxAddr.spend_secret;
                                             +                 fFound = true; // update stealth address with secrets
                                             +                 break;
                                             +             };
                                             +             
                                             +             result.push_back(Pair("result", "Import failed - stealth address exists."));
                                             +             return result;
                                             +         };
                                             +     };
                                             +     
                                             +     if (fFound)
                                             +     {
                                             +         result.push_back(Pair("result", "Success, updated "      +  sxAddr.Encoded()));
                                             +     } else
                                             +     {
                                             +         pwalletMain->stealthAddresses.insert(sxAddr);
                                             +         result.push_back(Pair("result", "Success, imported "      +  sxAddr.Encoded()));
                                             +     };
                                             +     
                                             +     
                                             +     if (!pwalletMain->AddStealthAddress(sxAddr))
                                             +         throw runtime_error("Could not save to wallet.");
                                             +     
                                             +     return result;
                                             + }
                                             + 
                                             + 
                                             + Value sendtostealthaddress(const Array& params, bool fHelp)
                                             + {
                                             +     if (fHelp || params.size() < 2 || params.size() > 5)
                                             +         throw runtime_error(
                                             +             "sendtostealthaddress <stealth_address> <amount> [comment] [comment-to]\n"
                                             +             "<amount> is a real and is rounded to the nearest 0.000001"
                                             +                  +  HelpRequiringPassphrase());
                                             +     
                                             +     if (pwalletMain->IsLocked())
                                             +         throw JSONRPCError(RPC_WALLET_UNLOCK_NEEDED, "Error: Please enter the wallet passphrase with walletpassphrase first.");
                                             +     
                                             +     std::string sEncoded = params[0].get_str();
                                             +     int64_t nAmount = AmountFromValue(params[1]);
                                             +     
                                             +     CStealthAddress sxAddr;
                                             +     Object result;
                                             +     
                                             +     if (!sxAddr.SetEncoded(sEncoded))
                                             +     {
                                             +         result.push_back(Pair("result", "Invalid Deepcoin stealth address."));
                                             +         return result;
                                             +     };
                                             +     
                                             +     
                                             +     CWalletTx wtx;
                                             +     if (params.size() > 2 && params[2].type() != null_type && !params[2].get_str().empty())
                                             +         wtx.mapValue["comment"] = params[2].get_str();
                                             +     if (params.size() > 3 && params[3].type() != null_type && !params[3].get_str().empty())
                                             +         wtx.mapValue["to"]      = params[3].get_str();
                                             +     
                                             +     std::string sError;
                                             +     if (!pwalletMain->SendStealthMoneyToDestination(sxAddr, nAmount, wtx, sError))
                                             +         throw JSONRPCError(RPC_WALLET_ERROR, sError);
                                             + 
                                             +     return wtx.GetHash().GetHex();
                                             +     
                                             +     result.push_back(Pair("result", "Not implemented yet."));
                                             +     
                                             +     return result;
                                             + }
                                             + 
                                             + Value clearwallettransactions(const Array& params, bool fHelp)
                                             + {
                                             +     if (fHelp || params.size() > 0)
                                             +         throw runtime_error(
                                             +             "clearwallettransactions \n"
                                             +             "delete all transactions from wallet - reload with scanforalltxns\n"
                                             +             "Warning: Backup your wallet first!");
                                             +     
                                             +     
                                             +     
                                             +     Object result;
                                             +     
                                             +     uint32_t nTransactions = 0;
                                             +     
                                             +     char cbuf[256];
                                             +     
                                             +     {
                                             +         LOCK2(cs_main, pwalletMain->cs_wallet);
                                             +         
                                             +         CWalletDB walletdb(pwalletMain->strWalletFile);
                                             +         walletdb.TxnBegin();
                                             +         Dbc* pcursor = walletdb.GetTxnCursor();
                                             +         if (!pcursor)
                                             +             throw runtime_error("Cannot get wallet DB cursor");
                                             +         
                                             +         Dbt datKey;
                                             +         Dbt datValue;
                                             +         
                                             +         datKey.set_flags(DB_DBT_USERMEM);
                                             +         datValue.set_flags(DB_DBT_USERMEM);
                                             +         
                                             +         std::vector<unsigned char> vchKey;
                                             +         std::vector<unsigned char> vchType;
                                             +         std::vector<unsigned char> vchKeyData;
                                             +         std::vector<unsigned char> vchValueData;
                                             +         
                                             +         vchKeyData.resize(100);
                                             +         vchValueData.resize(100);
                                             +         
                                             +         datKey.set_ulen(vchKeyData.size());
                                             +         datKey.set_data(&vchKeyData[0]);
                                             +         
                                             +         datValue.set_ulen(vchValueData.size());
                                             +         datValue.set_data(&vchValueData[0]);
                                             +         
                                             +         unsigned int fFlags = DB_NEXT; // same as using DB_FIRST for new cursor
                                             +         while (true)
                                             +         {
                                             +             int ret = pcursor->get(&datKey, &datValue, fFlags);
                                             +             
                                             +             if (ret == ENOMEM
                                             +                 || ret == DB_BUFFER_SMALL)
                                             +             {
                                             +                 if (datKey.get_size() > datKey.get_ulen())
                                             +                 {
                                             +                     vchKeyData.resize(datKey.get_size());
                                             +                     datKey.set_ulen(vchKeyData.size());
                                             +                     datKey.set_data(&vchKeyData[0]);
                                             +                 };
                                             +                 
                                             +                 if (datValue.get_size() > datValue.get_ulen())
                                             +                 {
                                             +                     vchValueData.resize(datValue.get_size());
                                             +                     datValue.set_ulen(vchValueData.size());
                                             +                     datValue.set_data(&vchValueData[0]);
                                             +                 };
                                             +                 // -- try once more, when DB_BUFFER_SMALL cursor is not expected to move
                                             +                 ret = pcursor->get(&datKey, &datValue, fFlags);
                                             +             };
                                             +             
                                             +             if (ret == DB_NOTFOUND)
                                             +                 break;
                                             +             else
                                             +             if (datKey.get_data() == NULL || datValue.get_data() == NULL
                                             +                 || ret != 0)
                                             +             {
                                             +                 snprintf(cbuf, sizeof(cbuf), "wallet DB error %d, %s", ret, db_strerror(ret));
                                             +                 throw runtime_error(cbuf);
                                             +             };
                                             +             
                                             +             CDataStream ssValue(SER_DISK, CLIENT_VERSION);
                                             +             ssValue.SetType(SER_DISK);
                                             +             ssValue.clear();
                                             +             ssValue.write((char*)datKey.get_data(), datKey.get_size());
                                             +             
                                             +             ssValue >> vchType;
                                             +             
                                             +             
                                             +             std::string strType(vchType.begin(), vchType.end());
                                             +             
                                             +             //printf("strType %s\n", strType.c_str());
                                             +             
                                             +             if (strType == "tx")
                                             +             {
                                             +                 uint256 hash;
                                             +                 ssValue >> hash;
                                             +                 
                                             +                 if ((ret = pcursor->del(0)) != 0)
                                             +                 {
                                             +                     printf("Delete transaction failed %d, %s\n", ret, db_strerror(ret));
                                             +                     continue;
                                             +                 };
                                             +                 
                                             +                 pwalletMain->mapWallet.erase(hash);
                                             +                 pwalletMain->NotifyTransactionChanged(pwalletMain, hash, CT_DELETED);
                                             +                 
                                             +                 nTransactions     +      + ;
                                             +             };
                                             +         };
                                             +         pcursor->close();
                                             +         walletdb.TxnCommit();
                                             +         
                                             +         
                                             +         //pwalletMain->mapWallet.clear();
                                             +     }
                                             +     
                                             +     snprintf(cbuf, sizeof(cbuf), "Removed %u transactions.", nTransactions);
                                             +     result.push_back(Pair("complete", std::string(cbuf)));
                                             +     result.push_back(Pair("", "Reload with scanforstealthtxns or re-download blockchain."));
                                             +     
                                             +     
                                             +     return result;
                                             + }
                                             + 
                                             + Value scanforalltxns(const Array& params, bool fHelp)
                                             + {
                                             +     if (fHelp || params.size() > 1)
                                             +         throw runtime_error(
                                             +             "scanforalltxns [fromHeight]\n"
                                             +             "Scan blockchain for owned transactions.");
                                             +     
                                             +     Object result;
                                             +     int32_t nFromHeight = 0;
                                             +     
                                             +     CBlockIndex *pindex = chainActive.Genesis();
                                             +     
                                             +     
                                             +     if (params.size() > 0)
                                             +         nFromHeight = params[0].get_int();
                                             +     
                                             +     
                                             +     if (nFromHeight > 0)
                                             +     {
                                             +         pindex = mapBlockIndex[hashBestChain];
                                             +         while (pindex->nHeight > nFromHeight
                                             +             && pindex->pprev)
                                             +             pindex = pindex->pprev;
                                             +     };
                                             +     
                                             +     if (pindex == NULL)
                                             +         throw runtime_error("Genesis Block is not set.");
                                             +     
                                             +     {
                                             +         LOCK2(cs_main, pwalletMain->cs_wallet);
                                             +         
                                             +         pwalletMain->MarkDirty();
                                             +         
                                             +         pwalletMain->ScanForWalletTransactions(pindex, true);
                                             +         pwalletMain->ReacceptWalletTransactions();
                                             +     }
                                             +     
                                             +     result.push_back(Pair("result", "Scan complete."));
                                             +     
                                             +     return result;
                                             + }
                                             + 
                                             + Value scanforstealthtxns(const Array& params, bool fHelp)
                                             + {
                                             +     if (fHelp || params.size() > 1)
                                             +         throw runtime_error(
                                             +             "scanforstealthtxns [fromHeight]\n"
                                             +             "Scan blockchain for owned stealth transactions.");
                                             +     
                                             +     Object result;
                                             +     uint32_t nBlocks = 0;
                                             +     uint32_t nTransactions = 0;
                                             +     int32_t nFromHeight = 0;
                                             +     
                                             +     CBlockIndex *pindex = chainActive.Genesis();
                                             +     
                                             +     
                                             +     if (params.size() > 0)
                                             +         nFromHeight = params[0].get_int();
                                             +     
                                             +     
                                             +     if (nFromHeight > 0)
                                             +     {
                                             +         pindex = mapBlockIndex[hashBestChain];
                                             +         while (pindex->nHeight > nFromHeight
                                             +             && pindex->pprev)
                                             +             pindex = pindex->pprev;
                                             +     };
                                             +     
                                             +     if (pindex == NULL)
                                             +         throw runtime_error("Genesis Block is not set.");
                                             +     
                                             +     // -- locks in AddToWalletIfInvolvingMe
                                             +     
                                             +     bool fUpdate = true; // todo: option?
                                             +     
                                             +     pwalletMain->nStealth = 0;
                                             +     pwalletMain->nFoundStealth = 0;
                                             +     
                                             +     while (pindex)
                                             +     {
                                             +         nBlocks     +      + ;
                                             +         CBlock block;
                                             +         ReadBlockFromDisk(block, pindex); //block.ReadFromDisk(pindex);
                                             +         
                                             +         BOOST_FOREACH(CTransaction& tx, block.vtx)
                                             +         {
                                             +             //if (!tx.IsStandard())
                                             +             string reason;
                                             +             if (!IsStandardTx(tx, reason))
                                             +                 continue; // leave out coinbase and others
                                             +             nTransactions     +      + ;
                                             +             
                                             +             pwalletMain->AddToWalletIfInvolvingMe(tx.GetHash(), tx, &block, fUpdate);
                                             +         };
                                             +         
                                             +         pindex = pindex->pnext;
                                             +     };
                                             +     
                                             +     printf("Scanned %u blocks, %u transactions\n", nBlocks, nTransactions);
                                             +     printf("Found %u stealth transactions in blockchain.\n", pwalletMain->nStealth);
                                             +     printf("Found %u new owned stealth transactions.\n", pwalletMain->nFoundStealth);
                                             +     
                                             +     char cbuf[256];
                                             +     snprintf(cbuf, sizeof(cbuf), "%u new stealth transactions.", pwalletMain->nFoundStealth);
                                             +     
                                             +     result.push_back(Pair("result", "Scan complete."));
                                             +     result.push_back(Pair("found", std::string(cbuf)));
                                             +     
                                             +     return result;
                                             + }
                                            

                                            Code added stealth function

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