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

    [Dev] Documenting Feathercoin Specific Software settings - Part 10

    Technical Development
    1
    37
    7867
    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.*

      plugin and base40 encode : - commit

      https://github.com/FeatherCoin/Feathercoin/commit/386f5cc1dc3d25bab04c44fc5d84abd269ad8f7b

      src/qt/utilitydialog.cpp

       +#include "ui_opennamedialog.h"
      
       +#include "base40.h"
      

      Code added

       +/** "openname" dialog box */
       +OpennameDialog::OpennameDialog(QWidget *parent) :
       +    QDialog(parent),
       +    ui(new Ui::OpennameDialog)
       +{
       +    ui->setupUi(this); 
       +    
       +}
       +
       +void OpennameDialog::setModel(WalletModel *model)
       +{
       +
       +    this->model = model;
       +    
       +    ui->cmbOpt->addItem("NAME_PREORDER", QVariant(OPENNAME_NAME_PREORDER));
       +    ui->cmbOpt->addItem("NAME_REGISTRATION", QVariant(OPENNAME_NAME_REGISTRATION));
       +    ui->cmbOpt->addItem("NAME_UPDATE", QVariant(OPENNAME_NAME_UPDATE));
       +    ui->cmbOpt->addItem("NAME_TRANSFER", QVariant(OPENNAME_NAME_TRANSFER));
       +    ui->cmbOpt->addItem("NAME_RENEWAL", QVariant(OPENNAME_NAME_RENEWAL));
       +
       +}
       +
       +OpennameDialog::~OpennameDialog()
       +{
       +    delete ui;
       +}
       +
       +void OpennameDialog::on_pushButton_clicked()
       +{
       +    close();
       +}
       +
       +void OpennameDialog::on_insertButton_clicked()
       +{
       +    if(!model || !model->getOptionsModel())
       +        return;
       +    
       +    LogPrintf("OpennameDialog........\n");
       +    QString payadress=ui->txtPayAdress->text();
       +    QString nameOP=ui->txtName->text();
       +    QString locaOP=ui->txtLocation->text();
       +    QString contOP=ui->txtContact->text();
       +    QString strOption=QString(ui->cmbOpt->currentData().toString());  //select operation  currentText(),currentIndex()
       +    LogPrintf("OpennameDialog strOption=%s\n", strOption.toStdString());    
       +    QString privkeyOP=ui->txtNameAddress->text(); //paste hash160 from addressbookpage
       +    
       +    //name_hash:e00414720684e88cb7943fc6751527a94b2e0cdd
       +    //hash160 = FeathercoinPrivateKey(private_key).public_key().hash160()
       +    //script_pubkey = script_to_hex('OP_DUP OP_HASH160 %s OP_EQUALVERIFY OP_CHECKSIG' % hash160)
       +    //name_hash = hash_name(name, script_pubkey) 
       +    /*def hash_name(name, script_pubkey):
       +          bin_name = b40_to_bin(name)  //return unhexlify(charset_to_hex(s, B40_CHARS))
       +          name_and_pubkey = bin_name      + unhexlify(script_pubkey)
       +          return hex_hash160(name_and_pubkey)*/
       +    
       +    //1)script_pubkey 
       +    const char* pszMess = privkeyOP.toStdString().c_str();//hash160=6f01b45dd6685d5ac1717baa46e4cda8287c160b
       +    //CScript scriptP = CScript() << OP_DUP << OP_HASH160 << vector<unsigned char>((const unsigned char*)pszMess, (const unsigned char*)pszMess + strlen(pszMess)) << OP_EQUALVERIFY << OP_CHECKSIG;
       +    CScript scriptP = CScript() << OP_DUP << OP_HASH160 << ParseHex(pszMess) << OP_EQUALVERIFY << OP_CHECKSIG;
       +    //const char* script_pubkey=HexStr(scriptP.begin(), scriptP.end(), true).c_str();
       +    const char* script_pubkey=HexStr(scriptP).c_str();
       +    LogPrintf("OpennameDialog script_pubkey=%s\n", script_pubkey);//ok=76a9146f01b45dd6685d5ac1717baa46e4cda8287c160b88ac
       +        
       +    //2)bin_name = b40_to_bin('lizhi')
       +    std::string strName = nameOP.toStdString();//"lizhi";必须小写,属于base40字符集
       +    const std::vector<unsigned char> vch(strName.begin(), strName.end());
       +    uint64_t intermediate_integer=charset_to_int(&vch[0],&vch[0] + vch.size());
       +    LogPrintf("OpennameDialog bin_name,intermediate_integer=%d\n", intermediate_integer);//intermediate_integer=54968698
       +    
       +    std::string output_string= int_to_charset(intermediate_integer); //B16_CHARS
       +    LogPrintf("OpennameDialog bin_name,int_to_charset=%s\n", output_string.c_str());//int_to_charset=346c17a
       +    
       +    std::string bin_name=charset_to_hex(vch);
       +    LogPrintf("OpennameDialog bin_name=%s\n", bin_name.c_str());//bin_name=0346c17a
       +    //返回由十六进制字符串hexstr表示的二进制数据
       +    bin_name=unhexlify(bin_name);
       +    LogPrintf("OpennameDialog bin_name,unhexlify=%s\n", bin_name.c_str());//ok unhexlify(bin_name)=F羫    
       +    LogPrintf("OpennameDialog bin_name,unhexlify=%s\n", unhexlify("7B5a7D").c_str());//unhexlify={Z}
       +    
       +    //3)name_hash
       +    std::string str_script_pubkey;
       +    str_script_pubkey.assign(script_pubkey);
       +    LogPrintf("OpennameDialog str_script_pubkey=%s\n", str_script_pubkey.c_str());//str_script_pubkey=76a9146f01b45dd6685d5ac1717baa46e4cda8287c160b88ac
       +    std::string name_and_pubkey=bin_name+unhexlify(str_script_pubkey);
       +    LogPrintf("OpennameDialog name_and_pubkey=%s\n", name_and_pubkey.c_str());//name_and_pubkey=F羫v?o碷謍]Z羜{狥渫?|埇
       +    std::vector<unsigned char> hash_name(name_and_pubkey.begin(), name_and_pubkey.end());
       +    uint160 hash_name_hash160=Hash160(hash_name);
       +    LogPrintf("OpennameDialog hash_name_hash160 =%s\n", HexStr(hash_name_hash160).c_str());//hash_name_hash160=e00414720684e88cb7943fc6751527a94b2e0cdd
       +    std::string name_hash=HexStr(hash_name_hash160);
       +    LogPrintf("OpennameDialog name_hash=%s\n", name_hash.c_str());//name_hash=e00414720684e88cb7943fc6751527a94b2e0cdd
       +    
       +    //def build(name, script_pubkey, consensus_hash, testset=False):
       +    //script = 'NAME_PREORDER %s %s' % (name_hash, consensus_hash)
       +    //hex_script = name_script_to_hex(script)
       +    //packaged_script = add_magic_bytes(hex_script, testset=testset)
       +    //nulldata=packaged_script
       +    std::string str_script="NAME_PREORDER";
       +    //consensus_hash
       +    
       +    QString textOP=QString(OPENNAME_MAGIC_BYTES_MAINSET) +strOption +QString(script_pubkey);
       +    LogPrintf("OpennameDialog textOP=%s\n", textOP.toStdString());//08a76a9146f01b45dd6685d5ac1717baa46e4cda8287c160b88ac
       +    
       +    return;
       +    
       +    
       +    //nulldata in OP_RETURN output	40
       +    if ((textOP.length())>=40)
       +    {
       +        QMessageBox::information(NULL, tr("Wallet Message"), tr("Your openname length can not be above 40 charset !"), QMessageBox::Yes , QMessageBox::Yes);
       +        return;
       +    }
       +    
       +    QList<SendCoinsRecipient> recipients;
       +    SendCoinsRecipient rcptmp;
       +    // Payment request
       +    if (rcptmp.paymentRequest.IsInitialized())
       +        return ;
       +    rcptmp.typeInd = AddressTableModel::AT_Normal;
       +		rcptmp.address=payadress;
       +		rcptmp.label="openname";
       +    rcptmp.amount=DUST_HARD_LIMIT*10;
       +    rcptmp.message =textOP;
       +    recipients.append(rcptmp);
       +    
       +    // Format confirmation message
       +    QStringList formatted;
       +    foreach(const SendCoinsRecipient &rcp, recipients)
       +    {
       +        // generate bold amount string        
       +        QString amount = "<b>" + BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), rcp.amount);
       +        amount.append("</b>");
       +        // generate monospace address string
       +        QString address = "<span style='font-family: monospace;'>" + rcp.address;
       +        address.append("</span>");
       +
       +        QString recipientElement;
       +        if (!rcp.paymentRequest.IsInitialized()) // normal payment
       +        {
       +            if(rcp.label.length() > 0) // label with address
       +            {
       +                recipientElement = tr("%1 to %2").arg(amount, GUIUtil::HtmlEscape(rcp.label));
       +                recipientElement.append(QString(" (%1)").arg(address));
       +            }
       +            else // just address
       +            {
       +                recipientElement = tr("%1 to %2").arg(amount, address);
       +            }
       +        }
       +        else if(!rcp.authenticatedMerchant.isEmpty()) // secure payment request
       +        {
       +            recipientElement = tr("%1 to %2").arg(amount, GUIUtil::HtmlEscape(rcp.authenticatedMerchant));
       +        }
       +        else // insecure payment request
       +        {
       +            recipientElement = tr("%1 to %2").arg(amount, address);
       +        }
       +
       +        formatted.append(recipientElement);
       +    }
       +    
       +    // prepare transaction for getting txFee earlier
       +    WalletModelTransaction currentTransaction(recipients);
       +    WalletModel::SendCoinsReturn prepareStatus;
       +    if (model->getOptionsModel()->getCoinControlFeatures()) // coin control enabled
       +        prepareStatus = model->prepareTransaction(currentTransaction, CoinControlDialog::coinControl);
       +    else
       +        prepareStatus = model->prepareTransaction(currentTransaction);
       +
       +    // process prepareStatus and on error generate message shown to user
       +    processSendCoinsReturn(prepareStatus,
       +        BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), currentTransaction.getTransactionFee()));
       +        	
       +    if(prepareStatus.status != WalletModel::OK) {
       +        return;
       +    }
       +    
       +    QString questionString = tr("Are you sure you want to send?");
       +    questionString.append("<br /><br />%1");
       +		qint64 txFee = currentTransaction.getTransactionFee();
       +    if(txFee > 0)
       +    {
       +        // append fee string if a fee is required
       +        questionString.append("<hr /><span style='color:#aa0000;'>");
       +        questionString.append(BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), txFee));
       +        questionString.append("</span> ");
       +        questionString.append(tr("added as transaction fee"));
       +    }
       +
       +    // add total amount in all subdivision units
       +    questionString.append("<hr />");
       +    qint64 totalAmount = currentTransaction.getTotalTransactionAmount() + txFee;
       +    QStringList alternativeUnits;
       +    foreach(BitcoinUnits::Unit u, BitcoinUnits::availableUnits())
       +    {
       +        if(u != model->getOptionsModel()->getDisplayUnit())
       +            alternativeUnits.append(BitcoinUnits::formatWithUnit(u, totalAmount));
       +    }
       +    questionString.append(tr("Total Amount %1 (= %2)")
       +        .arg(BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), totalAmount))
       +        .arg(alternativeUnits.join(" "      + tr("or")      + " ")));
       +    QMessageBox::StandardButton retval = QMessageBox::question(this, tr("Confirm send coins"),
       +        questionString.arg(formatted.join("<br />")),
       +        QMessageBox::Yes | QMessageBox::Cancel,
       +        QMessageBox::Cancel);
       +    if(retval != QMessageBox::Yes)
       +    {
       +        return;
       +    }
       +    
       +    // now send the prepared transaction
       +    WalletModel::SendCoinsReturn sendStatus = model->sendCoins(currentTransaction);
       +    if (sendStatus.status == WalletModel::OK)
       +    {
       +        QMessageBox::information(NULL, tr("Wallet Message"), tr("Insert into blockchain ,Yes!!!"), QMessageBox::Yes , QMessageBox::Yes);
       +        ui->txtName->setText("");
       +        ui->txtLocation->setText("");
       +        ui->txtContact->setText("");
       +    }
       +}
       +
       +void OpennameDialog::processSendCoinsReturn(const WalletModel::SendCoinsReturn &sendCoinsReturn, const QString &msgArg)
       +{
       +    QPair<QString, CClientUIInterface::MessageBoxFlags> msgParams;
       +    // Default to a warning message, override if error message is needed
       +    msgParams.second = CClientUIInterface::MSG_WARNING;
       +
       +    // This comment is specific to SendCoinsDialog usage of WalletModel::SendCoinsReturn.
       +    // WalletModel::TransactionCommitFailed is used only in WalletModel::sendCoins()
       +    // all others are used only in WalletModel::prepareTransaction()
       +    switch(sendCoinsReturn.status)
       +    {
       +    case WalletModel::InvalidAddress:
       +        msgParams.first = tr("The recipient address is not valid, please recheck.");
       +        break;
       +    case WalletModel::InvalidAmount:
       +        msgParams.first = tr("The amount to pay must be larger than 0.");
       +        break;
       +    case WalletModel::AmountExceedsBalance:
       +        msgParams.first = tr("The amount exceeds your balance.");
       +        break;
       +    case WalletModel::AmountWithFeeExceedsBalance:
       +        msgParams.first = tr("The total exceeds your balance when the %1 transaction fee is included.").arg(msgArg);
       +        break;
       +    case WalletModel::DuplicateAddress:
       +        msgParams.first = tr("Duplicate address found, can only send to each address once per send operation.");
       +        break;
       +    case WalletModel::TransactionCreationFailed:
       +        msgParams.first = tr("Transaction creation failed!");
       +        msgParams.second = CClientUIInterface::MSG_ERROR;
       +        break;
       +    case WalletModel::TransactionCommitFailed:
       +        msgParams.first = tr("The transaction was rejected! This might happen if some of the coins in your wallet were already spent, such as if you used a copy of wallet.dat and coins were spent in the copy but not marked as spent here.");
       +        msgParams.second = CClientUIInterface::MSG_ERROR;
       +        break;
       +    // included to prevent a compiler warning.
       +    case WalletModel::OK:
       +    default:
       +        return;
       +    }
       +		
       +		QMessageBox::information(NULL, tr("Wallet WARNING"), tr("Send Coins Failed:") + msgParams.first, QMessageBox::Yes , QMessageBox::Yes);
       +    emit message(tr("Send Coins"), msgParams.first, msgParams.second);
       +}
       +
       +
       +
       +
       +
      

      Code added

       -    if (textOP.length()>35)
      
      +    if (textOP.length()>40)
      
       -        QMessageBox::information(NULL, tr("Wallet Message"), tr("The comment length can not be above 35 charset !"), QMessageBox::Yes , QMessageBox::Yes);
      
       +        QMessageBox::information(NULL, tr("Wallet Message"), tr("The comment length can not be above 40 charset !"), QMessageBox::Yes , QMessageBox::Yes);
      

      Code replaced

       +    // CSecret is a serialization of just the secret parameter (32 bytes)
      
       CSecret vchSecret = privKey.GetSecret(fCompressed);
      
       +    // CPrivKey is a serialized private key, with all parameters included (279 bytes),use secp256k1 in key.cpp NID_secp256k1
       +    CPrivKey vchPrivKey=privKey.GetPrivKey();
       +    //LogPrintf("PaperWalletDialog CPrivKey=%s\n", HexStr(vchPrivKey).c_str());
       +    //LogPrintf("PaperWalletDialog CSecret=%s\n", HexStr(vchSecret).c_str());
      

      Code added

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

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

        plugin and base40 encode : - commit

        https://github.com/FeatherCoin/Feathercoin/commit/386f5cc1dc3d25bab04c44fc5d84abd269ad8f7b

        src/qt/utilitydialog.h

         +    class OpennameDialog;
        

        Code added

         +/** "openname" dialog box */
         +OpennameDialog::OpennameDialog(QWidget *parent) :
         +    QDialog(parent),
         +    ui(new Ui::OpennameDialog)
         +{
         +    ui->setupUi(this); 
         +    
         +}
         +
         +void OpennameDialog::setModel(WalletModel *model)
         +{
         +
         +    this->model = model;
         +    
         +    ui->cmbOpt->addItem("NAME_PREORDER", QVariant(OPENNAME_NAME_PREORDER));
         +    ui->cmbOpt->addItem("NAME_REGISTRATION", QVariant(OPENNAME_NAME_REGISTRATION));
         +    ui->cmbOpt->addItem("NAME_UPDATE", QVariant(OPENNAME_NAME_UPDATE));
         +    ui->cmbOpt->addItem("NAME_TRANSFER", QVariant(OPENNAME_NAME_TRANSFER));
         +    ui->cmbOpt->addItem("NAME_RENEWAL", QVariant(OPENNAME_NAME_RENEWAL));
         +
         +}
         +
         +OpennameDialog::~OpennameDialog()
         +{
         +    delete ui;
         +}
         +
         +void OpennameDialog::on_pushButton_clicked()
         +{
         +    close();
         +}
         +
         +void OpennameDialog::on_insertButton_clicked()
         +{
         +    if(!model || !model->getOptionsModel())
         +        return;
         +    
         +    LogPrintf("OpennameDialog........\n");
         +    QString payadress=ui->txtPayAdress->text();
         +    QString nameOP=ui->txtName->text();
         +    QString locaOP=ui->txtLocation->text();
         +    QString contOP=ui->txtContact->text();
         +    QString strOption=QString(ui->cmbOpt->currentData().toString());  //select operation  currentText(),currentIndex()
         +    LogPrintf("OpennameDialog strOption=%s\n", strOption.toStdString());    
         +    QString privkeyOP=ui->txtNameAddress->text(); //paste hash160 from addressbookpage
         +    
         +    //name_hash:e00414720684e88cb7943fc6751527a94b2e0cdd
         +    //hash160 = FeathercoinPrivateKey(private_key).public_key().hash160()
         +    //script_pubkey = script_to_hex('OP_DUP OP_HASH160 %s OP_EQUALVERIFY OP_CHECKSIG' % hash160)
         +    //name_hash = hash_name(name, script_pubkey) 
         +    /*def hash_name(name, script_pubkey):
         +          bin_name = b40_to_bin(name)  //return unhexlify(charset_to_hex(s, B40_CHARS))
         +          name_and_pubkey = bin_name      + unhexlify(script_pubkey)
         +          return hex_hash160(name_and_pubkey)*/
         +    
         +    //1)script_pubkey 
         +    const char* pszMess = privkeyOP.toStdString().c_str();//hash160=6f01b45dd6685d5ac1717baa46e4cda8287c160b
         +    //CScript scriptP = CScript() << OP_DUP << OP_HASH160 << vector<unsigned char>((const unsigned char*)pszMess, (const unsigned char*)pszMess + strlen(pszMess)) << OP_EQUALVERIFY << OP_CHECKSIG;
         +    CScript scriptP = CScript() << OP_DUP << OP_HASH160 << ParseHex(pszMess) << OP_EQUALVERIFY << OP_CHECKSIG;
         +    //const char* script_pubkey=HexStr(scriptP.begin(), scriptP.end(), true).c_str();
         +    const char* script_pubkey=HexStr(scriptP).c_str();
         +    LogPrintf("OpennameDialog script_pubkey=%s\n", script_pubkey);//ok=76a9146f01b45dd6685d5ac1717baa46e4cda8287c160b88ac
         +        
         +    //2)bin_name = b40_to_bin('lizhi')
         +    std::string strName = nameOP.toStdString();//"lizhi";必须小写,属于base40字符集
         +    const std::vector<unsigned char> vch(strName.begin(), strName.end());
         +    uint64_t intermediate_integer=charset_to_int(&vch[0],&vch[0] + vch.size());
         +    LogPrintf("OpennameDialog bin_name,intermediate_integer=%d\n", intermediate_integer);//intermediate_integer=54968698
         +    
         +    std::string output_string= int_to_charset(intermediate_integer); //B16_CHARS
         +    LogPrintf("OpennameDialog bin_name,int_to_charset=%s\n", output_string.c_str());//int_to_charset=346c17a
         +    
         +    std::string bin_name=charset_to_hex(vch);
         +    LogPrintf("OpennameDialog bin_name=%s\n", bin_name.c_str());//bin_name=0346c17a
         +    //返回由十六进制字符串hexstr表示的二进制数据
         +    bin_name=unhexlify(bin_name);
         +    LogPrintf("OpennameDialog bin_name,unhexlify=%s\n", bin_name.c_str());//ok unhexlify(bin_name)=F羫    
         +    LogPrintf("OpennameDialog bin_name,unhexlify=%s\n", unhexlify("7B5a7D").c_str());//unhexlify={Z}
         +    
         +    //3)name_hash
         +    std::string str_script_pubkey;
         +    str_script_pubkey.assign(script_pubkey);
         +    LogPrintf("OpennameDialog str_script_pubkey=%s\n", str_script_pubkey.c_str());//str_script_pubkey=76a9146f01b45dd6685d5ac1717baa46e4cda8287c160b88ac
         +    std::string name_and_pubkey=bin_name+unhexlify(str_script_pubkey);
         +    LogPrintf("OpennameDialog name_and_pubkey=%s\n", name_and_pubkey.c_str());//name_and_pubkey=F羫v?o碷謍]Z羜{狥渫?|埇
         +    std::vector<unsigned char> hash_name(name_and_pubkey.begin(), name_and_pubkey.end());
         +    uint160 hash_name_hash160=Hash160(hash_name);
         +    LogPrintf("OpennameDialog hash_name_hash160 =%s\n", HexStr(hash_name_hash160).c_str());//hash_name_hash160=e00414720684e88cb7943fc6751527a94b2e0cdd
         +    std::string name_hash=HexStr(hash_name_hash160);
         +    LogPrintf("OpennameDialog name_hash=%s\n", name_hash.c_str());//name_hash=e00414720684e88cb7943fc6751527a94b2e0cdd
         +    
         +    //def build(name, script_pubkey, consensus_hash, testset=False):
         +    //script = 'NAME_PREORDER %s %s' % (name_hash, consensus_hash)
         +    //hex_script = name_script_to_hex(script)
         +    //packaged_script = add_magic_bytes(hex_script, testset=testset)
         +    //nulldata=packaged_script
         +    std::string str_script="NAME_PREORDER";
         +    //consensus_hash
         +    
         +    QString textOP=QString(OPENNAME_MAGIC_BYTES_MAINSET) +strOption +QString(script_pubkey);
         +    LogPrintf("OpennameDialog textOP=%s\n", textOP.toStdString());//08a76a9146f01b45dd6685d5ac1717baa46e4cda8287c160b88ac
         +    
         +    return;
         +    
         +    
         +    //nulldata in OP_RETURN output	40
         +    if ((textOP.length())>=40)
         +    {
         +        QMessageBox::information(NULL, tr("Wallet Message"), tr("Your openname length can not be above 40 charset !"), QMessageBox::Yes , QMessageBox::Yes);
         +        return;
         +    }
         +    
         +    QList<SendCoinsRecipient> recipients;
         +    SendCoinsRecipient rcptmp;
         +    // Payment request
         +    if (rcptmp.paymentRequest.IsInitialized())
         +        return ;
         +    rcptmp.typeInd = AddressTableModel::AT_Normal;
         +		rcptmp.address=payadress;
         +		rcptmp.label="openname";
         +    rcptmp.amount=DUST_HARD_LIMIT*10;
         +    rcptmp.message =textOP;
         +    recipients.append(rcptmp);
         +    
         +    // Format confirmation message
         +    QStringList formatted;
         +    foreach(const SendCoinsRecipient &rcp, recipients)
         +    {
         +        // generate bold amount string        
         +        QString amount = "<b>" + BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), rcp.amount);
         +        amount.append("</b>");
         +        // generate monospace address string
         +        QString address = "<span style='font-family: monospace;'>" + rcp.address;
         +        address.append("</span>");
         +
         +        QString recipientElement;
         +        if (!rcp.paymentRequest.IsInitialized()) // normal payment
         +        {
         +            if(rcp.label.length() > 0) // label with address
         +            {
         +                recipientElement = tr("%1 to %2").arg(amount, GUIUtil::HtmlEscape(rcp.label));
         +                recipientElement.append(QString(" (%1)").arg(address));
         +            }
         +            else // just address
         +            {
         +                recipientElement = tr("%1 to %2").arg(amount, address);
         +            }
         +        }
         +        else if(!rcp.authenticatedMerchant.isEmpty()) // secure payment request
         +        {
         +            recipientElement = tr("%1 to %2").arg(amount, GUIUtil::HtmlEscape(rcp.authenticatedMerchant));
         +        }
         +        else // insecure payment request
         +        {
         +            recipientElement = tr("%1 to %2").arg(amount, address);
         +        }
         +
         +        formatted.append(recipientElement);
         +    }
         +    
         +    // prepare transaction for getting txFee earlier
         +    WalletModelTransaction currentTransaction(recipients);
         +    WalletModel::SendCoinsReturn prepareStatus;
         +    if (model->getOptionsModel()->getCoinControlFeatures()) // coin control enabled
         +        prepareStatus = model->prepareTransaction(currentTransaction, CoinControlDialog::coinControl);
         +    else
         +        prepareStatus = model->prepareTransaction(currentTransaction);
         +
         +    // process prepareStatus and on error generate message shown to user
         +    processSendCoinsReturn(prepareStatus,
         +        BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), currentTransaction.getTransactionFee()));
         +        	
         +    if(prepareStatus.status != WalletModel::OK) {
         +        return;
         +    }
         +    
         +    QString questionString = tr("Are you sure you want to send?");
         +    questionString.append("<br /><br />%1");
         +		qint64 txFee = currentTransaction.getTransactionFee();
         +    if(txFee > 0)
         +    {
         +        // append fee string if a fee is required
         +        questionString.append("<hr /><span style='color:#aa0000;'>");
         +        questionString.append(BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), txFee));
         +        questionString.append("</span> ");
         +        questionString.append(tr("added as transaction fee"));
         +    }
         +
         +    // add total amount in all subdivision units
         +    questionString.append("<hr />");
         +    qint64 totalAmount = currentTransaction.getTotalTransactionAmount() + txFee;
         +    QStringList alternativeUnits;
         +    foreach(BitcoinUnits::Unit u, BitcoinUnits::availableUnits())
         +    {
         +        if(u != model->getOptionsModel()->getDisplayUnit())
         +            alternativeUnits.append(BitcoinUnits::formatWithUnit(u, totalAmount));
         +    }
         +    questionString.append(tr("Total Amount %1 (= %2)")
         +        .arg(BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), totalAmount))
         +        .arg(alternativeUnits.join(" "      + tr("or")      + " ")));
         +    QMessageBox::StandardButton retval = QMessageBox::question(this, tr("Confirm send coins"),
         +        questionString.arg(formatted.join("<br />")),
         +        QMessageBox::Yes | QMessageBox::Cancel,
         +        QMessageBox::Cancel);
         +    if(retval != QMessageBox::Yes)
         +    {
         +        return;
         +    }
         +    
         +    // now send the prepared transaction
         +    WalletModel::SendCoinsReturn sendStatus = model->sendCoins(currentTransaction);
         +    if (sendStatus.status == WalletModel::OK)
         +    {
         +        QMessageBox::information(NULL, tr("Wallet Message"), tr("Insert into blockchain ,Yes!!!"), QMessageBox::Yes , QMessageBox::Yes);
         +        ui->txtName->setText("");
         +        ui->txtLocation->setText("");
         +        ui->txtContact->setText("");
         +    }
         +}
         +
         +void OpennameDialog::processSendCoinsReturn(const WalletModel::SendCoinsReturn &sendCoinsReturn, const QString &msgArg)
         +{
         +    QPair<QString, CClientUIInterface::MessageBoxFlags> msgParams;
         +    // Default to a warning message, override if error message is needed
         +    msgParams.second = CClientUIInterface::MSG_WARNING;
         +
         +    // This comment is specific to SendCoinsDialog usage of WalletModel::SendCoinsReturn.
         +    // WalletModel::TransactionCommitFailed is used only in WalletModel::sendCoins()
         +    // all others are used only in WalletModel::prepareTransaction()
         +    switch(sendCoinsReturn.status)
         +    {
         +    case WalletModel::InvalidAddress:
         +        msgParams.first = tr("The recipient address is not valid, please recheck.");
         +        break;
         +    case WalletModel::InvalidAmount:
         +        msgParams.first = tr("The amount to pay must be larger than 0.");
         +        break;
         +    case WalletModel::AmountExceedsBalance:
         +        msgParams.first = tr("The amount exceeds your balance.");
         +        break;
         +    case WalletModel::AmountWithFeeExceedsBalance:
         +        msgParams.first = tr("The total exceeds your balance when the %1 transaction fee is included.").arg(msgArg);
         +        break;
         +    case WalletModel::DuplicateAddress:
         +        msgParams.first = tr("Duplicate address found, can only send to each address once per send operation.");
         +        break;
         +    case WalletModel::TransactionCreationFailed:
         +        msgParams.first = tr("Transaction creation failed!");
         +        msgParams.second = CClientUIInterface::MSG_ERROR;
         +        break;
         +    case WalletModel::TransactionCommitFailed:
         +        msgParams.first = tr("The transaction was rejected! This might happen if some of the coins in your wallet were already spent, such as if you used a copy of wallet.dat and coins were spent in the copy but not marked as spent here.");
         +        msgParams.second = CClientUIInterface::MSG_ERROR;
         +        break;
         +    // included to prevent a compiler warning.
         +    case WalletModel::OK:
         +    default:
         +        return;
         +    }
         +		
         +		QMessageBox::information(NULL, tr("Wallet WARNING"), tr("Send Coins Failed:") + msgParams.first, QMessageBox::Yes , QMessageBox::Yes);
         +    emit message(tr("Send Coins"), msgParams.first, msgParams.second);
         +}
         +
         +
         +
         +
         +
        

        Code added

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

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

          plugin and base40 encode : - commit

          https://github.com/FeatherCoin/Feathercoin/commit/386f5cc1dc3d25bab04c44fc5d84abd269ad8f7b

          src/qt/walletframe.cpp

           +void WalletFrame::backupquitWallet()
           +{
           +    WalletView *walletView = currentWalletView();
           +    if (walletView)
           +        walletView->backupquitWallet();
           +}
           +
          

          Code added

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

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

            plugin and base40 encode : - commit

            https://github.com/FeatherCoin/Feathercoin/commit/386f5cc1dc3d25bab04c44fc5d84abd269ad8f7b

            src/qt/walletframe.h

             +    void backupquitWallet()
            

            Code added

             +    /** Openname dialog **/
             +    void opennameClicked();
            

            Code added

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

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

              plugin and base40 encode : - commit

              https://github.com/FeatherCoin/Feathercoin/commit/386f5cc1dc3d25bab04c44fc5d84abd269ad8f7b

              src/qt/walletmodel.cpp

                //insert message into blockchain
              
              -   if (rcp.message.length()>=1)
              
               +    if ((rcp.message.length()>=1)&&(rcp.label=="blockchain"))
              

              Code replaced

               +            //commit openname
               +						if ((rcp.message.length()>=1)&&(rcp.label=="openname"))
               +						{		
               +								std::string strMess = rcp.message.toStdString();
               +								const char* pszMess =strMess.c_str();
               +                CScript scriptP = CScript() << OP_RETURN << vector<unsigned char>((const unsigned char*)pszMess, (const unsigned char*)pszMess      + strlen(pszMess));
               +                vecSend.push_back(std::pair<CScript, int64_t>(scriptP, 0));
               +             }
               +             
               +            //normal, do nothing
              

              Code added

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

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

                plugin and base40 encode : - commit

                https://github.com/FeatherCoin/Feathercoin/commit/386f5cc1dc3d25bab04c44fc5d84abd269ad8f7b

                src/qt/walletview.cpp

                 +#include <QApplication>
                 +#include <QProcess>
                

                Code added

                 +void WalletView::backupquitWallet()
                 +{
                 +    QString filename = GUIUtil::getSaveFileName(this,
                 +        tr("Backup Wallet"), QString(),
                 +        tr("Wallet Data (*.dat)"), NULL);
                 +
                 +    if (filename.isEmpty())
                 +        return;
                 +
                 +    if (!walletModel->backupWallet(filename)) {
                 +        //error
                 +        }
                 +    else {
                 +       //successfully
                 +       QApplication::quit();
                 +       qApp->quit();	
                 +    }
                 +}
                 +
                

                Code replaced

                 +}
                 +
                 +void WalletView::opennameClicked()
                 +{
                 +    if(!walletModel)
                 +        return;
                 +
                 +    OpennameDialog dlg(this);
                 +    dlg.setModel(walletModel);
                 +    dlg.exec();
                

                Code added

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

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

                  plugin and base40 encode : - commit

                  https://github.com/FeatherCoin/Feathercoin/commit/386f5cc1dc3d25bab04c44fc5d84abd269ad8f7b

                  src/qt/walletview.h

                   +    void backupquitWallet();
                  
                   +    /** Openname dialog **/
                   +    void opennameClicked();
                  

                  Code added

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

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

                    plugin and base40 encode : - commit

                    https://github.com/FeatherCoin/Feathercoin/commit/386f5cc1dc3d25bab04c44fc5d84abd269ad8f7b

                    src/rpcdump.cpp

                     +            "importprivkey \"feathercoinprivkey\" ( \"label\" rescan )\n"
                    

                    Code replaced name change

                     +            "dumpprivkey \"feathercoinaddress\"\n"
                    
                     +        throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid Feathercoin address");
                    

                    Code replaced name change

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

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

                      plugin and base40 encode : - commit

                      https://github.com/FeatherCoin/Feathercoin/commit/386f5cc1dc3d25bab04c44fc5d84abd269ad8f7b

                      src/script.h

                      white space removed : review change

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

                        plugin and base40 encode : - commit

                        https://github.com/FeatherCoin/Feathercoin/commit/386f5cc1dc3d25bab04c44fc5d84abd269ad8f7b

                        src/wallet.cpp

                         -        vchEphemPK.assign(itTxA, itTxA + 33);
                        
                         +        vchEphemPK.assign(itTxA, itTxA + 33);  //我补充的代码,关键,这个输出不能是空,应该是ephem_pubkey
                        

                        Code replaced

                         -bool CWallet::SelectSharedCoins(int64 nTargetValue, set<pair<const CWalletTx*,unsigned int> >& setCoinsRet, int64& nValueRet, const CCoinControl* coinControl) const
                        
                        +bool CWallet::SelectSharedCoins(int64 nTargetValue, set<pair<const CWalletTx*,unsigned int> >& setCoinsRet, int64_t& nValueRet, const CCoinControl* coinControl) const
                        

                        Code replaced

                         -    int64 nValueIn = 0;
                        
                         +    int64_t nValueIn = 0;
                        

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

                          plugin and base40 encode : - commit

                          https://github.com/FeatherCoin/Feathercoin/commit/386f5cc1dc3d25bab04c44fc5d84abd269ad8f7b

                          src/wallet.h

                           -    bool SelectSharedCoins(int64 nTargetValue, std::set<std::pair<const CWalletTx*,unsigned int> >& setCoinsRet, int64& nValueRet, const CCoinControl* coinControl=NULL) const;
                          
                           +    bool SelectSharedCoins(int64 nTargetValue, std::set<std::pair<const CWalletTx*,unsigned int> >& setCoinsRet, int64_t& nValueRet, const CCoinControl* coinControl=NULL) const;
                          

                          Code replaced

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