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

    [Dev] Documenting Feathercoin Specific Software settings - Part 21

    Technical Development
    1
    5
    2392
    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 - FTC 0.11.2.

      Smart Contract Status Review

      Smart contract step one : : commit

      https://github.com/wrapperband/Feathercoin/commit/0e457b6e89c2eef64deb9028d9f2ae9baf53e7d8

      src/qt/locale/bitcoin_zh_CN.ts

       +    <message>
       +        <source>Input your receiving addresses!</source>
       +        <translation>输入你的地址!</translation>
       +    </message>
      

      Translation file updated

      src/qt/sendcoinsdialog.cpp

       +	 int nHashType = SIGHASH_ALL;
       +	 if (!fSend)
       +	 {
       +	 LogPrintf("sendCoins,SIGHASH_ALL=%i, SIGHASH_ANYONECANPAY=%i, SIGHASH_ALL|SIGHASH_ANYONECANPAY=%i\n",int(SIGHASH_ALL), int(SIGHASH_ANYONECANPAY), int(SIGHASH_ALL|SIGHASH_ANYONECANPAY));
       +	 nHashType = SIGHASH_ALL|SIGHASH_ANYONECANPAY;  //按位或运算符(|)
       +	 }
       +	 LogPrintf("sendCoins,nHashType=%i\n",nHashType);
       +		
      

      Note : chinese comments later removed

       +   	//是否能正常准备交易??
      

      comment

       - prepareStatus = model->prepareTransaction(currentTransaction, CoinControlDialog::coinControl);
      
       + prepareStatus = model->prepareTransaction(currentTransaction, CoinControlDialog::coinControl, nHashType);
      

      Code replaced

       +  LogPrintf("sendCoins,200\n");	
      

      Code added

       -        BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), currentTransaction.getTransactionFee()));
      
      
       +    if(nHashType != int(SIGHASH_ALL|SIGHASH_ANYONECANPAY))
       +    {
       +    	processSendCoinsReturn(prepareStatus, BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), currentTransaction.getTransactionFee()));
       +    }
       +		LogPrintf("sendCoins,210\n");
      

      Code replaced

       -        fNewRecipientAllowed = true;
       -        return;
       -    }    
      
       +    		if(nHashType != int(SIGHASH_ALL|SIGHASH_ANYONECANPAY))
       +    		{	
       +        	fNewRecipientAllowed = true;
       +        	return;
       +      	}
       +    }
           //此时交易已经完整、已经签名
           //此时交易已经完整、已经签名
       +    LogPrintf("sendCoins,300\n");
      

      Code Replaced

      src/qt/utilitydialog.cpp

      Large section of additional code from Line 773 to 839

       -		空白交易中vin的scriptSig是空,要将输入的txID中的输出vout中的地址(scriptPubKey的hex)作为参数,
       -		进行签名。此后才形成完整交易。 */
       + 空白交易中vin的scriptSig是空,要将输入的txID中的输出vout中的地址(scriptPubKey的hex)作为参数,进行签名。此后才形成完整交易。 */
      
       + /*  SIGHASH_ANYONECANPAY是附加的指示器,意味着签名仅覆盖自己的输入部分-不签名其他人的输入,这样其他人的输入可以留空。
       + 使用这些符号,我们能创建这样一个签名,即使在其他输入添加进入后,该签名依旧是有效的。
       + 但如果输出内容或其他的交易部分被改变了,该签名就无效了。 */
      	
      	
       + //向同一个地址输出相同的金额
       + //输入32.08,输出100
       + QString txCode1="0100000001045a7ee58f31e0be85ef14d53c3da28c0da54e43ddbc1a5d8a96629604912cca060000006a47304402202bc13618ec8a45144b16fd4f7e94c610c578cfac3459e1f4df6486f9990515e00220325d7410fa162aeea36a616fc3f6ed6a036591de51c2a4ef92f1e0d2313939f3812102e28e23791192c079c8e2d24ed554b739e8b19a2b72e68d42b50e66a7b71d57d7feffffff0100e40b54020000001976a91488b640990330b13cbe900cdf210f0b1bb9f151b288acb4ae1500";
       + //输入78,输出100
       + QString txCode2="01000000012f82dbddb55f01fde2d91603abc2625ee585a2258106d2f650da50abe8ed06c5010000006b483045022100c6c392ad65950b4b5e64eb4dd4894587e63d8c43fd864d9525f05b23ae76ecb9022011929fcb4b01213b8ab59963c772a9cb8a9e808b5f80b64c8d7c255ec274e4f78121030e34be97bc6afcab5255f3e13061a78b6b6e14b03fcc93e89defd718cfe34621feffffff0100e40b54020000001976a91488b640990330b13cbe900cdf210f0b1bb9f151b288acb4ae1500";
       + 
       + CTransaction tx1;
       + CTransaction tx2;
       + if (!DecodeHexTx(tx1, txCode1.toStdString()))
       + {
       +     QMessageBox::information(NULL, tr("TX Message"), tr("TX1 decode failed!"), QMessageBox::Yes , QMessageBox::Yes);
       +     return;
       + }
       + if (!DecodeHexTx(tx2, txCode2.toStdString()))
       + {
       +     QMessageBox::information(NULL, tr("TX Message"), tr("TX2 decode failed!"), QMessageBox::Yes , QMessageBox::Yes);
       +     return;
       + }
       + LogPrintf("on_BroadcastBtn_clicked,tx1.vin.size=%i\n", tx1.vin.size());
       + LogPrintf("on_BroadcastBtn_clicked,tx2.vin.size=%i\n", tx2.vin.size());
       + 
       + //增加其他人的输入
       + CMutableTransaction rawTx;
       + for (unsigned int i = 0; i < tx1.vin.size(); i++)
       + {
       + 		const CTxIn& txin = tx1.vin[i];				
       + 		//利用 CMutableTransaction
       + 		rawTx.vin.push_back(txin);
       + }
       + for (unsigned int i = 0; i < tx2.vin.size(); i++)
       + {
       + 		const CTxIn& txin = tx2.vin[i];				
       + 		//利用 CMutableTransaction
       + 		rawTx.vin.push_back(txin);
       + }
       + //唯一一个输出
       + for (unsigned int i = 0; i < tx1.vout.size(); i++)
       + {
       + 		const CTxOut& txvout = tx1.vout[i];				
       + 		//利用 CMutableTransaction
       + 		rawTx.vout.push_back(txvout);
       + }
       + LogPrintf("on_BroadcastBtn_clicked,rawTx.vin.size=%i\n", rawTx.vin.size());
       + LogPrintf("on_BroadcastBtn_clicked,rawTx.vout.size=%i\n", rawTx.vout.size());
       + 
       + rawTx.nVersion = tx1.nVersion;
       + rawTx.nLockTime = tx1.nLockTime;
       + 
       + //获取二进制码
       + std::string strHex = EncodeHexTx(rawTx);
       + LogPrintf("on_BroadcastBtn_clicked,rawTx.strHex=%s\n", strHex);
       + //0100000002045a7ee58f31e0be85ef14d53c3da28c0da54e43ddbc1a5d8a96629604912cca060000006a47304402202bc13618ec8a45144b16fd4f7e94c610c578cfac3459e1f4df6486f9990515e00220325d7410fa162aeea36a616fc3f6ed6a036591de51c2a4ef92f1e0d2313939f3812102e28e23791192c079c8e2d24ed554b739e8b19a2b72e68d42b50e66a7b71d57d7feffffff2f82dbddb55f01fde2d91603abc2625ee585a2258106d2f650da50abe8ed06c5010000006b483045022100c6c392ad65950b4b5e64eb4dd4894587e63d8c43fd864d9525f05b23ae76ecb9022011929fcb4b01213b8ab59963c772a9cb8a9e808b5f80b64c8d7c255ec274e4f78121030e34be97bc6afcab5255f3e13061a78b6b6e14b03fcc93e89defd718cfe34621feffffff0100e40b54020000001976a91488b640990330b13cbe900cdf210f0b1bb9f151b288acb4ae1500
       + //Generic error (code -25),feathercoin-cli sendrawtransaction
       + 
       + //广播这个交易
       + CTransaction tx(rawTx);
       + RelayTransaction(tx);
       + uint256 hashTx = tx.GetHash();
       + LogPrintf("on_BroadcastBtn_clicked,rawTx.TxID=%s\n", hashTx.ToString());
       + //472ba519367e3337f0f718396ffc8fa7c0118fa33f78ee7f5a2db85881ddbcc6,超出的部分将是手续费
       + 
       + QMessageBox::information(NULL, tr("Broadcast Message"), tr("Broadcast success!<br>TxID=%1").arg(QString::fromStdString(hashTx.ToString())), QMessageBox::Yes , QMessageBox::Yes);
      

      Additional code

       +		QString strDoAddress=ui->targetLine->text();
       +		if (strDoAddress.toStdString() == "")
       +		{
      +		    QMessageBox::information(NULL, tr("TX Message"), tr("Input your receiving addresses!"), QMessageBox::Yes , QMessageBox::Yes);
      +		    return;
      +		}
      +		
      +		//1.显示输出		
      

      Additional code

       -   LogPrintf("on_AddTransBtn_clicked,obj.size=%d\n", obj.size());
      
       +  LogPrintf("on_AddTransBtn_clicked,scriptTxOut,obj.size=%d\n", obj.size());
      

      Code replaced

       - LogPrintf("on_AddTransBtn_clicked,obj[4].name=%s\n", name); //addresses
      
      + LogPrintf("on_AddTransBtn_clicked,scriptTxOut,obj[4].name=%s\n", name); //addresses
      

      Code replaced

       + LogPrintf("on_AddTransBtn_clicked,scriptTxOut,addresses=%s\n", addresses);
      
       +	LogPrintf("on_AddTransBtn_clicked,scriptTxOut,pay to addresses=%s,value=%d\n", addresses, dCoin);
      
       + LogPrintf("on_AddTransBtn_clicked,scriptTxOut,nowCoins=%d,dCoin=%d,vout.size=%d\n",nowCoins, dCoin, tx.vout.size());
      

      Various log errors replaced

       + 		//2.还需要显示输入
       + 		double dTxInCoin = 0;
       + 		CScript scriptTxIn;
       + 		BOOST_FOREACH(const CTxIn& txin, tx.vin)
       + 		{
       + 				scriptTxIn = txin.scriptSig;
       +         if (tx.IsCoinBase()==false)  //不接受挖矿支付
       +         {
       +         		std::string txID = txin.prevout.hash.GetHex();
       +         		int64_t vout = (int64_t)txin.prevout.n;
       +         		LogPrintf("on_AddTransBtn_clicked,scriptTxIn,txID=%s\n", txID);
       +         		LogPrintf("on_AddTransBtn_clicked,scriptTxIn,vout=%d\n", vout);
       +         		
       +         		//获取输入的那个交易,并找出他的输出值
       +         		CTransaction tx2;
       +         		uint256 hashBlock;
       +         		uint256 hash = txin.prevout.hash;
       +         		if (!GetTransaction(hash, tx2, hashBlock, true))
       +         		{
       +         				LogPrintf("on_AddTransBtn_clicked,scriptTxIn,Error=No information available about transaction\n", vout);
       +         				QMessageBox::information(NULL, tr("TX Message"), tr("No information available about transaction"), QMessageBox::Yes , QMessageBox::Yes);
       + 		    				return;		    				
       + 						}//txID=c42956cfed4a0e70baab7321c888c4bafb2f442e2b4f1aac8ae4ab952b3e2f09
       + 						
       + 						for (unsigned int i = 0; i < tx2.vout.size(); i++ )
       + 						{
       + 								const CTxOut& txout = tx2.vout[i];
       + 								double value = (double)txout.nValue / (double)COIN;
       + 								int64_t n = (int64_t)i;
       + 							  LogPrintf("on_AddTransBtn_clicked,scriptTxIn,scriptTxOut,value=%d,n=%i\n", value, n);
       + 							  
       + 							  //未花费的txid哪个输出是我可以花费的,见tx的txin.prevout.n = vin.vout
       + 							  if (i == vout)
       + 							  {
       + 							  	dTxInCoin = value;
       + 							  	getCoins + = dTxInCoin;
       + 							  }
       + 						}
       +       	}
       + 		}
       + 				  	
       + 	
      

      Section of additional code

       -		ui->progressBar->setValue(nowCoins);
      
       +		//ui->progressBar->setValue(nowCoins);
       +		ui->progressBar->setValue(getCoins);
       +		//Total Coins
      

      Replacement code

       -		QString amount = tr("%1 FTC").arg(dCoin);
      
       +		//This Coins,这个应该可以显示多个列?
       +		QString amount = tr("In %1 FTC,Out %2 FTC,%3").arg(dTxInCoin).arg(dCoin).arg(txCode);
      

      Replaced code

      src/qt/utilitydialog.h

       +    double getCoins;
      
      1 Reply Last reply Reply Quote 0
      • wrapper
        wrapper Moderators last edited by wrapper

        Feathercoin specific changes made to - FTC 0.11.2.

        Smart Contract Status Review

        Smart contract step one : : commit

        https://github.com/wrapperband/Feathercoin/commit/0e457b6e89c2eef64deb9028d9f2ae9baf53e7d8

        src/qt/walletmodel.cpp

         -WalletModel::SendCoinsReturn WalletModel::prepareTransaction(WalletModelTransaction &transaction, const CCoinControl *coinControl)
        
        
         +WalletModel::SendCoinsReturn WalletModel::prepareTransaction(WalletModelTransaction &transaction, const CCoinControl *coinControl, int nHashType)
        

        Code replaced

         -    if(total > nBalance)
        
         +		//合约交易不验证输出,nHashType = SIGHASH_ALL|SIGHASH_ANYONECANPAY
        +    if((total > nBalance) && (nHashType != int(SIGHASH_ALL|SIGHASH_ANYONECANPAY)))
         +    		LogPrintf("prepareTransaction,total=%d,nBalance=%d,nHashType=%i\n",total, nBalance, nHashType);
        

        Code replaced

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

        Code replaced

         +        LogPrintf("prepareTransaction,fCreated=%i\n",fCreated);
        
         +		LogPrintf("createRawTransaction,500\n");
        

        Log prints

        src/qt/walletmodel.h

         -    SendCoinsReturn prepareTransaction(WalletModelTransaction &transaction, const CCoinControl *coinControl = NULL);
        
         +    SendCoinsReturn prepareTransaction(WalletModelTransaction &transaction, const CCoinControl *coinControl = NULL, int nHashType = SIGHASH_ALL);
        

        Code replaced

        Smart contract UI :: commit

        https://github.com/wrapperband/Feathercoin/commit/53359e5d7ee85608cfcc8d76362a41c3d405bba9

        src/qt/forms/debugdialog.ui

        Various size changes

         -    <string>Donation Target:</string>
        
        • <string>Co-Payment : Donation Target</string>

        Code replaced

         -    <string>Within a week,Have 500 FTC.If it fails, it will be returned to the donor.</string>
        
         +    <string>Within a week,Have enough FTC.If it fails, it will be returned to the donor.</string>
        

        Code replaced

         +  <widget class="QTableView" name="tableView">
        +   <property name="geometry">
        +    <rect>
        +     <x>10</x>
        +     <y>180</y>
        +     <width>281</width>
        +     <height>161</height> 
        +    </rect>
        

        Example of ui size changes

        Smart contract test1 :: commit

        configure.ac

         - define(_CLIENT_VERSION_BUILD, 4)
        
         + define(_CLIENT_VERSION_BUILD, 5) 
        

        Change the build version

         -    BITCOIN_FIND_BDB61
        
         +    BITCOIN_FIND_BDB51
        

        blockchain database version

        src/main.cpp

         +  LogPrintf("AcceptToMemoryPool,STANDARD_SCRIPT_VERIFY_FLAGS=%i\n", STANDARD_SCRIPT_VERIFY_FLAGS);
        

        Add message

         -    const CScript &scriptSig = ptxTo->vin[nIn].scriptSig;
        
         +    const CScript &scriptSig = ptxTo->vin[nIn].scriptSig;    
         +    //打印此脚本
         +  LogPrintf("CScriptCheck,nIn=%i,scriptSig=%s\n", nIn, scriptSig.ToString());
         +   LogPrintf("CScriptCheck,nIn=%i,scriptPubKey=%s\n", nIn, scriptPubKey.ToString());
        

        Replace code

         +     /*bool r1=VerifyScript(scriptSig, scriptPubKey, nFlags, CachingTransactionSignatureChecker(ptxTo, nIn, cacheStore), &error);
         +     LogPrintf("CScriptCheck,nIn=%i,VerifyScript.r1=%i\n", nIn, r1);
         +     return r1;*/
         +     
         +     /*vector<vector<unsigned char> > stack;
         +     bool r2=EvalScript(stack, scriptSig, nFlags, CachingTransactionSignatureChecker(ptxTo, nIn, cacheStore), &error);
         +     LogPrintf("CScriptCheck,nIn=%i, EvalScript.r2=%i,stack.size=%i\n", nIn, r2, stack.size());
         +     for(int i=0;i<stack.size();i++ ) {
         +     	LogPrintf("CScriptCheck,nIn=%i, stack.size=%i, stack.i=%i,stack=%s\n", nIn, stack.size(), i, HexStr(stack.at(i)).c_str());
         +   	}
         +     bool r3=EvalScript(stack, scriptPubKey, nFlags, CachingTransactionSignatureChecker(ptxTo, nIn, cacheStore), &error);
         +     LogPrintf("CScriptCheck,nIn=%i, EvalScript.r3=%i,stack.size=%i\n", nIn, r3, stack.size());    
         +     for(int i=0;i<stack.size();i++ ) {
         +     	LogPrintf("CScriptCheck,nIn=%i, stack.size=%i, stack.back=%s\n", nIn, stack.size(), HexStr(stack.back()).c_str());
         +     	LogPrintf("CScriptCheck,nIn=%i, stack.size=%i, stack.i=%i,stack=%s\n", nIn, stack.size(), i, HexStr(stack.at(i)).c_str());
         +   	}
         +     return r2;*/
         +   
        

        Additional code

          +   //if (!CheckInputs(tx,                     state,                        view,              true,         STANDARD_SCRIPT_VERIFY_FLAGS, true))
        

        Code removed

          + LogPrintf("CheckInputs,fScriptChecks=%i\n", fScriptChecks);
        

        message added

         + LogPrintf("CheckInputs,1,i=%i, pvChecks=%i,vin.size=%i\n", i, pvChecks, tx.vin.size());
         +  LogPrintf("CheckInputs,1,i=%i, tx.vin[i].prevout=%s\n", i, tx.vin[i].prevout.ToString());
         + LogPrintf("CheckInputs,1,i=%i, txHash=%s\n", i, tx.GetHash().ToString());
         +  LogPrintf("CheckInputs,1,i=%i,flags=%i\n", i, flags);
         +                 
        

        Code added

         -                } else if (!check()) {
        
         +                } else if (!check()) {                		
         +  LogPrintf("CheckInputs,3,i=%i,STANDARD_NOT_MANDATORY_VERIFY_FLAGS=%i\n", i, STANDARD_NOT_MANDATORY_VERIFY_FLAGS);
        

        Code replaced

         +    LogPrintf("CheckInputs,4,i=%i\n", i);
        

        Code added

         +  LogPrintf("CheckInputs,5,i=%i\n", i);
        

        Code added

        src/qt/forms/sendcoinsentry.ui

         +     <layout class="QHBoxLayout" name="horizontalLayoutAmount" stretch="0,1,0,0,0">
        

        Example layout change

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

          Feathercoin specific changes made to - FTC 0.11.2.

          Smart Contract Status Review

          Smart contract test1 : : commit

          https://github.com/wrapperband/Feathercoin/commit/a59897340c37dbe5ee3de455a1b7f550022a3503

          src/qt/sendcoinsdialog.cpp

           +    connect(ui->checkSmart, SIGNAL(clicked()), this, SLOT(on_checkSmart_clicked()));
          
          
           +  if (ui->checkSmart->checkState() == Qt::Checked) {
           +      recipient.isSmart = true;
           +      recipient.heightSmart = ui->heightEdit->text().toInt();
           +  	} else { 
           +      recipient.isSmart = false;
           +  	}
           +      	
          

          Additional code

                 + }
            + 
            + void SendCoinsEntry::on_checkSmart_clicked()
            + {
            + 		if (ui->checkSmart->checkState() == Qt::Checked) {
            +     	ui->heightEdit->setEnabled(true);
            +   	} else {
            +   		ui->heightEdit->setEnabled(false);
            +   	}
          

          Code added

          src/qt/sendcoinsentry.h

           +    void on_checkSmart_clicked();
          

          Code added

          src/qt/utilitydialog.cpp

          +#include "consensus/validation.h"
          

          Code added

          +    inputRow=0;
          

          Code added

           + //遍历model中的所有数据,构建交易
          

          Code replaced

           -  for (unsigned int i = 0; i < tx.vin.size(); i++)
          
          +  for (unsigned int t = 0; t < tx.vin.size(); t++)
          

          Code replaced

           -  const CTxIn& txin = tx.vin[i];
          
           +  const CTxIn& txin = tx.vin[t];
          
           +  LogPrintf("on_BroadcastBtn_clicked,i=%i, tx.vin[t].prevout=%s\n",i ,tx.vin[t].prevout.ToString());
          
           +  LogPrintf("on_BroadcastBtn_clicked,i=%i,tx.vout.size=%i\n", i, tx.vout.size());
          

          Code added

           -  for (unsigned int i = 0; i < tx.vout.size(); i++ )
           -  const CTxOut& txvout = tx.vout[i];				
          
            +   for (unsigned int t = 0; t < tx.vout.size(); t++ )
            +   const CTxOut& txvout = tx.vout[t];
          

          Code replaced

           -  rawTx.nLockTime = tx.nLockTime;
          
           +  rawTx.nLockTime = tx.nLockTime;  //是否会引起签名验证错误?答案是
           +  LogPrintf("on_BroadcastBtn_clicked,add txvout\n");
          

          Code replaced

            +     
            +     //必须要留出足够的手续费,超出的部分将是手续费
            +     bool fOverrideFees = true; //允许荒谬的高得出奇的手续费
            +     CValidationState state;
            +     bool fMissingInputs;
            +     if (!AcceptToMemoryPool(mempool, state, tx, false, &fMissingInputs, !fOverrideFees)) {
            +         if (state.IsInvalid()) {
            +         		LogPrintf("on_BroadcastBtn_AcceptToMemoryPool,1,RejectCode=%i,Reason=%s\n", state.GetRejectCode(), state.GetRejectReason());
            +         		QMessageBox::information(NULL, tr("Broadcast Message"), tr("AcceptToMemoryPool Fail!GetRejectCode=%1").arg(state.GetRejectCode()), QMessageBox::Yes , QMessageBox::Yes);
            +         		return;
            +         } else {
            +             if (fMissingInputs) {
            +             		LogPrintf("on_BroadcastBtn_AcceptToMemoryPool,2,Missing inputs\n");
            +             		QMessageBox::information(NULL, tr("Broadcast Message"), tr("AcceptToMemoryPool Missing inputs"), QMessageBox::Yes , QMessageBox::Yes);
            +             		return;
            +             }
            +             LogPrintf("on_BroadcastBtn_AcceptToMemoryPool,3,RejectCode=%i,Reason=%s\n", state.GetRejectCode(), state.GetRejectReason());
            +             QMessageBox::information(NULL, tr("Broadcast Message"), tr("AcceptToMemoryPool Fail!GetRejectCode=%1").arg(state.GetRejectCode()), QMessageBox::Yes , QMessageBox::Yes);
            +             return;
            +         }
            +     }
            +     
            +     //广播这个交易
          

          Code added

            + 	    ui->progressBar->setMinimum(0);
            + 	    ui->progressBar->setMaximum(maxCharge);
            + 	    ui->progressBar->setAlignment(Qt::AlignRight | Qt::AlignVCenter); 
            + 	  //ui->progressBar->setRange(0,maxCharge);				
            +  }
          
          
            +  if (getCoins>=maxCharge) {
            +       ui->progressBar->setValue(maxCharge);
            +  }
            +  double dProgress = (ui->progressBar->value() - ui->progressBar->minimum()) * 100.0 / (ui->progressBar->maximum() - ui->progressBar->minimum());
            +  ui->progressBar->setFormat(QString::fromLocal8Bit("processing...%1%").arg(QString::number(dProgress, 'f', 1)));
            +  LogPrintf("on_AddTransBtn_clicked,maxCharge=%d,getCoins=%d,inputRow=%i\n",maxCharge, getCoins, inputRow);
            + 		inputRow++ ;
          

          Code added

          +  LogPrintf("on_AddTransBtn_clicked,totalLabel=%s,nowCoins=%d\n",nowAmount.toStdString(), nowCoins);
          

          Code added

          src/qt/utilitydialog.h

           +    int inputRow;
          

          Code added

          src/qt/walletmodel.cpp

            + LogPrintf("rcp.isSmart=%i\n", rcp.isSmart);
            + LogPrintf("rcp.heightSmart=%i\n", rcp.heightSmart);
          

          Code added

           -  CRecipient recipient = {scriptPubKey, rcp.amount, rcp.fSubtractFeeFromAmount};
          
           + CRecipient recipient ;
           + if (rcp.heightSmart ==0) {
           + 		recipient = {scriptPubKey, rcp.amount, rcp.fSubtractFeeFromAmount};
           + } else {
           + 		recipient = {scriptPubKey, rcp.amount, rcp.fSubtractFeeFromAmount, rcp.heightSmart};
           +					
          

          Code replaced

           -        CMutableTransaction rawTx;
           -        rawTx.nVersion = newTx->nVersion;
          
           +        CMutableTransaction rawTx;        
          

          Code replaced

          src/qt/walletmodel.h

           +    
           +    bool isSmart; // Smart Contract
           +    int heightSmart;
          

          Code moved added

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

            Feathercoin specific changes made to - FTC 0.11.2.

            Smart Contract Status Review

            Smart contract test1 : : commit

            https://github.com/wrapperband/Feathercoin/commit/a59897340c37dbe5ee3de455a1b7f550022a3503

            src/script/interpreter.cpp

             -typedef vector<unsigned char> valtype;
            

            Code removed

              -     bool fSuccess = checker.CheckSig(vchSig, vchPubKey, scriptCode);
              -     popstack(stack);
            
            
             +   bool fSuccess = checker.CheckSig(vchSig, vchPubKey, scriptCode);//Debug
             +   //return fSuccess;//Debug
            
            
             -  stack.push_back(fSuccess ? vchTrue : vchFalse);
            
             +  popstack(stack);                    
             +  stack.push_back(fSuccess ? vchTrue : vchFalse);//Debug
            

            Code replaced

             -    if (!EvalScript(stack, scriptPubKey, flags, checker, serror))
            
             +    if (!EvalScript(stack, scriptPubKey, flags, checker, serror)) //Debug_TRUE
                 // serror is set
            

            Replace code

             -    if (stack.empty())
              
             +    if (stack.empty()) {
             +    		//return true;//Debug
            

            Replace comment / code

             -    if (CastToBool(stack.back()) == false)
            
             +       }
             +    if (CastToBool(stack.back()) == false) {
             +    		//return true;//Debug_TRUE
            

            Code replaced

            +         	}
            +        if (!CastToBool(stack.back())) {
            +        		//return true;//Debug
            

            Code added

            src/wallet/wallet.cpp

             +bool CWallet::SelectCoins(const CAmount& nTargetValue, set<pair<const CWalletTx*,unsigned int> >& setCoinsRet, CAmount& nValueRet, const CCoinControl* coinControl, int nHashType) const
            

            Code added nHashType

             +         if (nHashType != int(SIGHASH_ALL|SIGHASH_ANYONECANPAY))
             +         {
             +         		return (nValueRet >= nTargetValue);
             +         }
             +         else 
             +         {
             +         		return	nTargetValue;
             +         }
            

            Code added

            +   CWalletTx& wtxNew, CReserveKey& reservekey, CAmount& nFeeRet, int& nChangePosRet, std::string& strFailReason, const CCoinControl* coinControl, int nHashType)
            

            Code added

             +   LogPrintf("CreateTransaction,false=100\n");
            

            Code added

             +  LogPrintf("CreateTransaction,false=200\n");
            

            Code added

             + 		int nLockTime=0;
             + 		BOOST_FOREACH (const CRecipient& recipient, vecSend)
             + 		{
             + 				if (recipient.heightSmart>0) {
             + 					nLockTime = recipient.heightSmart;
             + 				}
             + 		}
            

            Code added

             + 		if (nHashType == int(SIGHASH_ALL|SIGHASH_ANYONECANPAY))   {
             + 				txNew.nLockTime = nLockTime;
             + 		}
             + 		//Time(UTC):	1480245414/2016/11/27 19:16:54  /http://tool.chinaz.com/Tools/unixtime.aspx
             + 		LogPrintf("CreateTransaction,nLockTime=%d\n",txNew.nLockTime);//1484594 "lock_time": 1484594, heightEdit
             + 		
            

            Code added

             + LogPrintf("CreateTransaction,false=300\n");
            

            Code added

              -                if (!SelectCoins(nTotalValue, setCoins, nValueIn, coinControl))
            
             +                if (!SelectCoins(nTotalValue, setCoins, nValueIn, coinControl, nHashType))
            

            Code replaced

             +                    LogPrintf("CreateTransaction,false=400\n");
            
             +                    LogPrintf("CreateTransaction,false=500\n");
            
             +                    if (!SignSignature(*this, *coin.first, txNew, nIn++, nHashType))
            
             +                    LogPrintf("CreateTransaction,false=600\n");
            
             +                    LogPrintf("CreateTransaction,false=700\n");
            
             +                    LogPrintf("CreateTransaction,false=800\n");
            
             +    bool rv = CreateTransaction(vecSend, wtxNew, reservekey, nFeeRet, nChangePos, strError, coinControl, SIGHASH_ALL);
            

            Code added

            src/wallet/wallet.h

             +    int	heightSmart;
            
             +    bool SelectCoins(const CAmount& nTargetValue, std::set<std::pair<const CWalletTx*,unsigned int> >& setCoinsRet, CAmount& nValueRet, const CCoinControl *coinControl = NULL, int nHashType=SIGHASH_ALL) const;
            
             +                           CWalletTx& wtxNew, CReserveKey& reservekey, CAmount& nFeeRet, int& nChangePosRet, std::string& strFailReason, const CCoinControl *coinControl = NULL, int nHashType=SIGHASH_ALL);//ʵÏÖ
            
             +                           CWalletTx& wtxNew, CReserveKey& reservekey, int64_t& nFeeRet, std::string& strFailReason, const CCoinControl *coinControl = NULL);//Èë¿Ú
            

            Code replaced

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

              Feathercoin specific changes made to - FTC 0.11.2.

              Smart Contract Status Review

              Active blockheader version 4.0 : : commit

              https://github.com/wrapperband/Feathercoin/commit/bcc6a7f88763f5fd04107cb1eb9ea56ab8fbff70

              src/chain.h

               -    int cVersion;
              

              Code removed

               -  cVersion       = 0;
              

              Code removed

               -  cVersion       = block.cVersion;
              

              Code removed

               -  block.cVersion       = cVersion;
              
              -  READWRITE(this->cVersion);
              
               - block.cVersion        = cVersion;
              

              Code removed

              src/main.cpp

               - static bool IsSuperMajority(int minVersion, int min_cVersion, const CBlockIndex* pstart, unsigned nRequired, const Consensus::Params& consensusParams);
              
               + static bool IsSuperMajority(int minVersion,  const CBlockIndex* pstart, unsigned nRequired, const Consensus::Params& consensusParams);
              

              Code replaced

               -    int cUpgraded = 0;
              

              Code removed

               -    if (pindex->cVersion > CBlock::ACTIVE_VERSION)
               -         	++cUpgraded;
              

              Code removed

               -        if (cUpgraded > 0)
               -            LogPrintf("%s: %d of last 500 blocks above nVersion %d\n", __func__, nUpgraded, (int)CBlock::CURRENT_VERSION);
              

              Code removed

               -        if ((nUpgraded > 500/2)||(cUpgraded > 500/2))
              
               +        if (nUpgraded > 500/2)
              

              Code replaced

               -    if (block.nVersion < 2 && IsSuperMajority(2,5, pindexPrev, consensusParams.nMajorityRejectBlockOutdated, consensusParams))
              
               +    if (block.nVersion < 2 && IsSuperMajority(2, pindexPrev, consensusParams.nMajorityRejectBlockOutdated, consensusParams))
              

              Code replaced

                -    if (block.nVersion < 3 && IsSuperMajority(3,5, pindexPrev, consensusParams.nMajorityRejectBlockOutdated, consensusParams))
              
                +    if (block.nVersion < 3 && IsSuperMajority(3, pindexPrev, consensusParams.nMajorityRejectBlockOutdated, consensusParams))
              

              Code replaced

                -    if (block.nVersion < 4 && IsSuperMajority(4,5, pindexPrev, consensusParams.nMajorityRejectBlockOutdated, consensusParams))
              
                +    if (block.nVersion < 4 && IsSuperMajority(4, pindexPrev, consensusParams.nMajorityRejectBlockOutdated, consensusParams))
              

              Code replaced

               -    if (block.cVersion < 5 && IsSuperMajority(4,5, pindexPrev, consensusParams.nMajorityRejectBlockOutdated, consensusParams))
              
               +    if (block.cVersion < 5 && IsSuperMajority(4, pindexPrev, consensusParams.nMajorityRejectBlockOutdated, consensusParams)) 
              

              Code replaced

                -    	                     && IsSuperMajority(2, 5,pindexPrev, consensusParams.nMajorityEnforceBlockUpgrade, consensusParams))
              
               +    	                     && IsSuperMajority(2, pindexPrev, consensusParams.nMajorityEnforceBlockUpgrade, consensusParams))
              

              Code replaced

               -    	                     && IsSuperMajority(4, 5, pindexPrev, consensusParams.nMajorityEnforceBlockUpgrade, consensusParams))
              
               +    	                     && IsSuperMajority(4, pindexPrev, consensusParams.nMajorityEnforceBlockUpgrade, consensusParams))
              

              Code replaced

               -static bool IsSuperMajority(int minVersion,int min_cVersion, const CBlockIndex* pstart, unsigned nRequired, const Consensus::Params& consensusParams)
              
              +static bool IsSuperMajority(int minVersion, const CBlockIndex* pstart, unsigned nRequired, const Consensus::Params& consensusParams)
              

              Code replaced

               -    unsigned int cFound = 0;
              

              Code removed

               -    LogPrintf("IsSuperMajority: minVersion=%d,min_cVersion=%d, nRequired=%d, nFound=%d, cFound=%d\n",minVersion, min_cVersion, nRequired, nFound, cFound);
               -    return ((nFound >= nRequired)||(cFound >= nRequired));
              
              
              
               +    LogPrintf("IsSuperMajority: minVersion=%d, nRequired=%d, nFound=%d\n",minVersion, nRequired, nFound);
               +    return (nFound >= nRequired);
              

              Code replaced

              src/primitives/block.h

               -    static const int32_t ACTIVE_VERSION=4;
               -    static const int32_t CURRENT_VERSION=2;  //be locked 
              
               +    static const int32_t CURRENT_VERSION=4;  //active new version
              

              Code replaced

               -        cVersion = CBlockHeader::ACTIVE_VERSION;
              

              Code removed

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