src/connection.cpp
/**
 * This will create a new HUSH3.conf, download Zcash parameters.
 */
This will create a new HUSH3.conf, download Zcash parameters.
This will create a new HUSH3 . conf download Zcash parameters .
void ConnectionLoader::createZcashConf() {
    main->logger->write("createZcashConf");
    auto confLocation = zcashConfWritableLocation();
    QFileInfo fi(confLocation);
    QDialog d(main);
    Ui_createZcashConf ui;
    ui.setupUi(&d);
    QPixmap logo(":/img/res/zcashdlogo.gif");
    ui.lblTopIcon->setBasePixmap(logo.scaled(512,512, Qt::KeepAspectRatio, Qt::SmoothTransformation));
    ui.btnPickDir->setEnabled(false);
    ui.grpAdvanced->setVisible(false);
    QObject::connect(ui.btnAdvancedConfig, &QPushButton::toggled, [=](bool isVisible) {
        ui.grpAdvanced->setVisible(isVisible);
        ui.btnAdvancedConfig->setText(isVisible ? QObject::tr("Hide Advanced Config") : QObject::tr("Show Advanced Config"));
    });
    QObject::connect(ui.chkCustomDatadir, &QCheckBox::stateChanged, [=](int chked) {
        if (chked == Qt::Checked) {
            ui.btnPickDir->setEnabled(true);
        }
        else {
            ui.btnPickDir->setEnabled(false);
        }
    });
    QObject::connect(ui.btnPickDir, &QPushButton::clicked, [=]() {
        auto datadir = QFileDialog::getExistingDirectory(main, QObject::tr("Choose data directory"), ui.lblDirName->text(), QFileDialog::ShowDirsOnly);
        if (!datadir.isEmpty()) {
            ui.lblDirName->setText(QDir::toNativeSeparators(datadir));
        }
    });
    QString datadir = "";
    bool useTor = false;
    if (d.exec() == QDialog::Accepted) {
        datadir = ui.lblDirName->text();
        useTor = ui.chkUseTor->isChecked();
    }
    main->logger->write("Creating file " + confLocation);
    QDir().mkpath(fi.dir().absolutePath());
    QFile file(confLocation);
    if (!file.open(QIODevice::ReadWrite | QIODevice::Truncate)) {
        main->logger->write("Could not create HUSH3.conf, returning");
        QString explanation = QString() % QObject::tr("Could not create HUSH3.conf.");
        this->showError(explanation);
        return;
    }
    QTextStream out(&file);
    out << "# Autogenerated by Hush ZushDragon https://myhush.org\n";
    out << "server=1\n";
    out << "rpcuser=hush\n";
    out << "rpcpassword=" % randomPassword() << "\n";
    out << "rpcport=23136\n";
    out << "txindex=1\n";
    out << "addressindex=1\n";
    out << "spentindex=1\n";
    out << "timestampindex=1\n";
    out << "rpcworkqueue=256\n";
    out << "rpcallowip=127.0.0.1\n";
    if (!datadir.isEmpty()) {
        out << "datadir=" % datadir % "\n";
    }
    if (useTor) {
        out << "proxy=127.0.0.1:9050\n";
    }
    file.close();
    this->doAutoConnect();
}
void ConnectionLoader :: createZcashConf ( ) { main -> logger -> write ( " " ) ; auto confLocation = zcashConfWritableLocation ( ) ; QFileInfo fi ( confLocation ) ; QDialog d ( main ) ; Ui_createZcashConf ui ; ui . setupUi ( & d ) ; QPixmap logo ( " " ) ; ui . lblTopIcon -> setBasePixmap ( logo . scaled ( 512 , 512 , Qt :: KeepAspectRatio , Qt :: SmoothTransformation ) ) ; ui . btnPickDir -> setEnabled ( false ) ; ui . grpAdvanced -> setVisible ( false ) ; QObject :: connect ( ui . btnAdvancedConfig , & QPushButton :: toggled , [ = ] ( bool isVisible ) { ui . grpAdvanced -> setVisible ( isVisible ) ; ui . btnAdvancedConfig -> setText ( isVisible ? QObject :: tr ( " " ) : QObject :: tr ( " " ) ) ; } ) ; QObject :: connect ( ui . chkCustomDatadir , & QCheckBox :: stateChanged , [ = ] ( int chked ) { if ( chked == Qt :: Checked ) { ui . btnPickDir -> setEnabled ( true ) ; } else { ui . btnPickDir -> setEnabled ( false ) ; } } ) ; QObject :: connect ( ui . btnPickDir , & QPushButton :: clicked , [ = ] ( ) { auto datadir = QFileDialog :: getExistingDirectory ( main , QObject :: tr ( " " ) , ui . lblDirName -> text ( ) , QFileDialog :: ShowDirsOnly ) ; if ( ! datadir . isEmpty ( ) ) { ui . lblDirName -> setText ( QDir :: toNativeSeparators ( datadir ) ) ; } } ) ; QString datadir = " " ; bool useTor = false ; if ( d . exec ( ) == QDialog :: Accepted ) { datadir = ui . lblDirName -> text ( ) ; useTor = ui . chkUseTor -> isChecked ( ) ; } main -> logger -> write ( " " + confLocation ) ; QDir ( ) . mkpath ( fi . dir ( ) . absolutePath ( ) ) ; QFile file ( confLocation ) ; if ( ! file . open ( QIODevice :: ReadWrite | QIODevice :: Truncate ) ) { main -> logger -> write ( " " ) ; QString explanation = QString ( ) % QObject :: tr ( " " ) ; this -> showError ( explanation ) ; return ; } QTextStream out ( & file ) ; out << " \n " ; out << " \n " ; out << " \n " ; out << " " % randomPassword ( ) << " \n " ; out << " \n " ; out << " \n " ; out << " \n " ; out << " \n " ; out << " \n " ; out << " \n " ; out << " \n " ; if ( ! datadir . isEmpty ( ) ) { out << " " % datadir % " \n " ; } if ( useTor ) { out << " \n " ; } file . close ( ) ; this -> doAutoConnect ( ) ; }
This will create a new HUSH3.conf, download Zcash parameters.
This will create a new HUSH3 . conf download Zcash parameters .
// Show the dialog // Now that HUSH3.conf exists, try to autoconnect again