diff --git a/lnbits/extensions/livestream/lnurl.py b/lnbits/extensions/livestream/lnurl.py index 86569eda..ed987f8a 100644 --- a/lnbits/extensions/livestream/lnurl.py +++ b/lnbits/extensions/livestream/lnurl.py @@ -21,8 +21,8 @@ async def lnurl_response(ls_id): resp = LnurlPayResponse( callback=url_for("livestream.lnurl_callback", track_id=track.id, _external=True), - min_sendable=min(100000, track.price_msat), - max_sendable=track.price_msat * 5, + min_sendable=track.min_sendable, + max_sendable=track.max_sendable, metadata=await track.lnurlpay_metadata(), ) @@ -40,19 +40,19 @@ async def lnurl_callback(track_id): amount_received = int(request.args.get("amount")) - if amount_received < track.price_msat: + if amount_received < track.min_sendable: return ( jsonify( LnurlErrorResponse( - reason=f"Amount {round(amount_received / 1000)} is smaller than minimum {math.floor(track.price_msat / 1000)}." + reason=f"Amount {round(amount_received / 1000)} is smaller than minimum {math.floor(track.min_sendable)}." ).dict() ), ) - elif track.price_msat * 5 < amount_received: + elif track.max_sendable < amount_received: return ( jsonify( LnurlErrorResponse( - reason=f"Amount {round(amount_received / 1000)} is greater than maximum {math.floor(track.price_msat * 5 / 1000)}." + reason=f"Amount {round(amount_received / 1000)} is greater than maximum {math.floor(track.max_sendable)}." ).dict() ), ) diff --git a/lnbits/extensions/livestream/models.py b/lnbits/extensions/livestream/models.py index f913d65d..e8380647 100644 --- a/lnbits/extensions/livestream/models.py +++ b/lnbits/extensions/livestream/models.py @@ -25,6 +25,14 @@ class Track(NamedTuple): name: str producer: int + @property + def min_sendable(self) -> int: + return min(100_000, self.price_msat or 100_000) + + @property + def max_sendable(self) -> int: + return max(50_000_000, self.price_msat * 5) + async def fullname(self) -> str: from .crud import get_producer diff --git a/lnbits/extensions/livestream/static/js/index.js b/lnbits/extensions/livestream/static/js/index.js index 81620d3a..ac00fa80 100644 --- a/lnbits/extensions/livestream/static/js/index.js +++ b/lnbits/extensions/livestream/static/js/index.js @@ -44,7 +44,6 @@ new Vue({ return ( !this.trackDialog.data.name || this.trackDialog.data.name.length === 0 || - !this.trackDialog.data.price_sat || !this.trackDialog.data.producer || this.trackDialog.data.producer.length === 0 ) @@ -107,7 +106,7 @@ new Vue({ ? download_url : undefined, name, - price_msat: price_sat * 1000, + price_msat: price_sat * 1000 || 0, producer_name: typeof producer === 'string' ? producer : undefined, producer_id: typeof producer === 'object' ? producer.id : undefined } diff --git a/lnbits/extensions/livestream/templates/livestream/index.html b/lnbits/extensions/livestream/templates/livestream/index.html index 50df74bc..57c65343 100644 --- a/lnbits/extensions/livestream/templates/livestream/index.html +++ b/lnbits/extensions/livestream/templates/livestream/index.html @@ -252,7 +252,7 @@ type="number" min="1" label="Track price (sat)" - hint="This is a minimum price. Payments up to 5x bigger than this will be accepted." + hint="This is the minimum price for buying the track download link. It does nothing for tracks without a download URL." >