ACINQ / phoenixd

https://phoenix.acinq.co/server
Apache License 2.0
117 stars 15 forks source link

Add the ability to agree to prompts via flags #2

Closed sethforprivacy closed 8 months ago

sethforprivacy commented 8 months ago

While I understand the intent of the agreement prompts that are required on first-run, it adds a lot of complexity for use-cases where the binary is run in Docker or similar setups.

Would it be possible to add a flag that bypasses this consent? At present there is no real way to run phoenixd in a detached state until you first agree to the prompts.

prusnak commented 8 months ago

+1

Let's add the flag --agree-to-terms-of-service via change similar to this:

diff --git a/src/commonMain/kotlin/fr/acinq/lightning/bin/Main.kt b/src/commonMain/kotlin/fr/acinq/lightning/bin/Main.kt
index 4126ada..03df5ea 100644
--- a/src/commonMain/kotlin/fr/acinq/lightning/bin/Main.kt
+++ b/src/commonMain/kotlin/fr/acinq/lightning/bin/Main.kt
@@ -139,6 +139,8 @@ class Phoenixd : CliktCommand() {
         "--verbose" to Verbosity.Verbose
     ).default(Verbosity.Default, defaultForHelp = "prints high-level info to the console")

+    private val agreeToTermsOfService by option("--agree-to-terms-of-service", help = "Agree to terms of service").flag()
+
     init {
         context {
             valueSource = MapValueSource(readConfFile(confFile))
@@ -158,7 +160,7 @@ class Phoenixd : CliktCommand() {
     override fun run() {
         FileSystem.SYSTEM.createDirectories(datadir)
         val (seed, new) = getOrGenerateSeed(datadir)
-        if (new) {
+        if (new && !agreeToTermsOfService) {
             runBlocking {
                 terminal.print(yellow("Generating new seed..."))
                 delay(500.milliseconds)
prusnak commented 8 months ago

Another alternative approach is described in https://github.com/ACINQ/phoenixd/issues/3 - make it possible to provide the seed via env variable PHOENIXD_SEED (and in this case the daemon does not show the interactive UI.