From 591b181bcb28e78eeb9d96521a106dfea5eaa0ae Mon Sep 17 00:00:00 2001 From: fiatjaf Date: Mon, 3 Oct 2022 08:54:18 -0300 Subject: [PATCH] option to disable preimage checking (at least until we don't get a leaner way to grab these preimages like a dedicated preimage parser service). --- README.md | 5 ++++- src/main/scala/ChannelMaster.scala | 4 +++- src/main/scala/Config.scala | 3 ++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 3616ef2..0c133c7 100644 --- a/README.md +++ b/README.md @@ -81,12 +81,15 @@ No configuration is needed for a quick test, but you can write a file at `$LIGHT "isDev": true, // controls log level and where are logs displayed "requireSecret": false, // setting this to true will make it so only clients with this secret can get hosted channels - "permanentSecrets": [] // you can specify static secrets here that can be used by clients when "requireSecret" is true + "permanentSecrets": [], // you can specify static secrets here that can be used by clients when "requireSecret" is true + "disablePreimageChecking": false // setting this to true will make it so poncho won't fetch and parse all bitcoin blocks looking for rogue preimages } ``` The branding information won't be used unless contact URL and logo file are set. The logo should be a PNG file also placed under `$LIGHTNING_DIR/bitcoin/poncho/` and specified as a relative path. +Setting `disablePreimageChecking` to `true` will drastically decrease resource consumption since it won't fetch and parse all Bitcoin blocks. It is recommended if you are offering hosted channels only to trusted people or yourself. If you are a public entity offering channels to random people it is not recommended since it opens up the possibility of _reputational_ damage against you, see [this part of the spec about the preimage checking](https://github.com/fiatjaf/blips/blob/blip-hosted-channels/blip-0012.md#dealing-with-problems). + (Remember to remove the JSON comments in the file above otherwise it won't work.) ### Storage diff --git a/src/main/scala/ChannelMaster.scala b/src/main/scala/ChannelMaster.scala index 5654c6b..39f4421 100644 --- a/src/main/scala/ChannelMaster.scala +++ b/src/main/scala/ChannelMaster.scala @@ -119,7 +119,9 @@ object ChannelMaster { logger.info.item(block).msg("updated current block") this.channels.values.foreach(_.onBlockUpdated(block)) - this.preimageCatcher.onBlockUpdated(block) + + if (!config.disablePreimageChecking) + this.preimageCatcher.onBlockUpdated(block) } } case Failure(err) => diff --git a/src/main/scala/Config.scala b/src/main/scala/Config.scala index 306d1a9..ec0ef24 100644 --- a/src/main/scala/Config.scala +++ b/src/main/scala/Config.scala @@ -41,7 +41,8 @@ case class Config( // extra requireSecret: Boolean = false, - permanentSecrets: List[String] = List.empty + permanentSecrets: List[String] = List.empty, + disablePreimageChecking: Boolean = false ) { def init: InitHostedChannel = InitHostedChannel( maxHtlcValueInFlightMsat = UInt64(maxHtlcValueInFlightMsat),