refactor: change the WITH_ONION env var and use FORCE_HTTPS instead

This commit is contained in:
Eneko Illarramendi
2020-04-23 18:37:22 +02:00
parent e461e34fc0
commit 4bf93d36c6
7 changed files with 25 additions and 11 deletions
+4 -7
View File
@@ -1,8 +1,9 @@
from flask import url_for
from lnurl import Lnurl, LnurlWithdrawResponse, encode as lnurl_encode
from os import getenv
from typing import NamedTuple
from lnbits.settings import FORCE_HTTPS
class WithdrawLink(NamedTuple):
id: str
@@ -22,19 +23,15 @@ class WithdrawLink(NamedTuple):
def is_spent(self) -> bool:
return self.used >= self.uses
@property
def is_onion(self) -> bool:
return getenv("LNBITS_WITH_ONION", 1) == 1
@property
def lnurl(self) -> Lnurl:
scheme = None if self.is_onion else "https"
scheme = "https" if FORCE_HTTPS else None
url = url_for("withdraw.api_lnurl_response", unique_hash=self.unique_hash, _external=True, _scheme=scheme)
return lnurl_encode(url)
@property
def lnurl_response(self) -> LnurlWithdrawResponse:
scheme = None if self.is_onion else "https"
scheme = "https" if FORCE_HTTPS else None
url = url_for("withdraw.api_lnurl_callback", unique_hash=self.unique_hash, _external=True, _scheme=scheme)
return LnurlWithdrawResponse(