Skip to content

frontend/qt: add -dataDir cli flag #3135

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion backend/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -1003,7 +1003,7 @@ func (backend *Backend) ExportLogs() error {
backend.log.WithError(err).Error("error creating new log file")
return err
}
logFilePath := filepath.Join(utilConfig.AppDir(), "log.txt")
logFilePath := filepath.Join(backend.arguments.MainDirectoryPath(), "log.txt")

existingLogFile, err := os.Open(logFilePath)
if err != nil {
Expand Down
9 changes: 5 additions & 4 deletions frontends/qt/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,18 +303,15 @@ int main(int argc, char *argv[])
// issues were observed on Windows and the app crashes on some Linux systems.
qputenv("QMLSCENE_DEVICE", "softwarecontext");
qputenv("QT_QUICK_BACKEND", "software");
goLog("BITBOXAPP_RENDER=software");
} else if (renderMode == "auto") {
// Do nothing: leave it to Qt to decide the rendering backend, which is usually hardware
// accelerated if available.
//
// In rare cases, this can lead to rendering artefacts and crashes, which is why it is not
// enabled by default.
std::cerr << "Rendering mode: automatic (usually hardware accelerated)" << std::endl;
goLog("BITBOXAPP_RENDER=auto");
} else {
std::cerr << "Invalid value for BITBOXAPP_RENDER" << std::endl;
goLog("Invalid value for BITBOXAPP_RENDER");
return 1;
}

Expand All @@ -328,7 +325,7 @@ int main(int argc, char *argv[])
a.setWindowIcon(QIcon(QCoreApplication::applicationDirPath() + "/bitbox.png"));

if(a.isSecondary()) {
// The application is already running. If there is exactly one positional argument, we send
// The application is already running. If there is exactly one positional argument, we
// assume it is an URI click and send it to the primary instance to parse, validate and
// handle.

Expand Down Expand Up @@ -431,6 +428,10 @@ int main(int argc, char *argv[])
return result;
});

char renderLog[1000] = {0};
snprintf(renderLog, sizeof(renderLog), "BITBOXAPP_RENDER=%s", renderMode.toStdString().c_str());
goLog(renderLog);

RequestInterceptor interceptor;
view->page()->profile()->setUrlRequestInterceptor(&interceptor);

Expand Down
12 changes: 10 additions & 2 deletions frontends/qt/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ import (
"github.com/BitBoxSwiss/bitbox-wallet-app/backend/bridgecommon"
btctypes "github.com/BitBoxSwiss/bitbox-wallet-app/backend/coins/btc/types"
"github.com/BitBoxSwiss/bitbox-wallet-app/backend/devices/usb"
"github.com/BitBoxSwiss/bitbox-wallet-app/util/config"
"github.com/BitBoxSwiss/bitbox-wallet-app/util/logging"
"github.com/BitBoxSwiss/bitbox-wallet-app/util/system"
)
Expand Down Expand Up @@ -112,8 +113,6 @@ func serve(
preferredLocale *C.cchar_t,
getSaveFilenameFn C.getSaveFilenameCallback,
) {
log := logging.Get().WithGroup("server")
log.WithField("args", os.Args).Info("Started Qt application")
testnet := flag.Bool("testnet", false, "activate testnets")

if runtime.GOOS == "darwin" {
Expand All @@ -129,9 +128,18 @@ func serve(

gapLimitsReceive := flag.Uint("gapLimitReceive", 0, "gap limit for receive addresses. Do not use this unless you know what this means.")
gapLimitsChange := flag.Uint("gapLimitChange", 0, "gap limit for change addresses. Do not use this unless you know what this means.")
var dataDir *string
dataDir = flag.String("dataDir", "", "location where BitBoxApp's data files are stored.")

flag.Parse()

if *dataDir != "" {
config.SetAppDir(*dataDir)
}

log := logging.Get().WithGroup("server")
log.WithField("args", os.Args).Info("Started Qt application")

var gapLimits *btctypes.GapLimits
if *gapLimitsReceive != 0 || *gapLimitsChange != 0 {
gapLimits = &btctypes.GapLimits{
Expand Down
Loading