From ea91c374894f20cc95039508a0cf66f839c1651e Mon Sep 17 00:00:00 2001 From: Tiago Vasconcelos Date: Thu, 27 Oct 2022 15:55:30 +0100 Subject: [PATCH] fix typo in tasks and add/fix extra props --- lnbits/extensions/livestream/lnurl.py | 6 +++++- lnbits/extensions/livestream/tasks.py | 17 +++++++++++------ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/lnbits/extensions/livestream/lnurl.py b/lnbits/extensions/livestream/lnurl.py index 89e431e5..efe7986d 100644 --- a/lnbits/extensions/livestream/lnurl.py +++ b/lnbits/extensions/livestream/lnurl.py @@ -86,9 +86,13 @@ async def lnurl_callback( ls = await get_livestream_by_track(track_id) + extra_amount = amount_received - int( + amount_received * (100 - ls.fee_pct) / 100 + ) # msats + payment_hash, payment_request = await create_invoice( wallet_id=ls.wallet, - amount=int(amount_received / 1000), + amount=int(amount_received / 1000), # sats memo=await track.fullname(), unhashed_description=(await track.lnurlpay_metadata()).encode(), extra={"tag": "livestream", "track": track.id, "comment": comment}, diff --git a/lnbits/extensions/livestream/tasks.py b/lnbits/extensions/livestream/tasks.py index d081332f..ac96e508 100644 --- a/lnbits/extensions/livestream/tasks.py +++ b/lnbits/extensions/livestream/tasks.py @@ -41,21 +41,26 @@ async def on_invoice_paid(payment: Payment) -> None: ls = await get_livestream_by_track(track.id) assert ls, f"track {track.id} is not associated with a livestream" - # now we make a special kind of internal transfer - amount = int(payment.amount * (100 - ls.fee_pct) / 100) + amount = int(payment.amount * (100 - ls.fee_pct) / 100) # msats payment_hash, payment_request = await create_invoice( - wallet_id=tpos.tip_wallet, - amount=amount, # sats + wallet_id=producer.wallet, + amount=int(amount / 1000), # sats internal=True, memo=f"Revenue from '{track.name}'.", ) - logger.debug(f"livestream: producer invoice created: {payment_hash}") + logger.debug( + f"livestream: producer invoice created: {payment_hash}, {amount} msats" + ) checking_id = await pay_invoice( payment_request=payment_request, wallet_id=payment.wallet_id, - extra={"tag": "livestream"}, + extra={ + **payment.extra, + "shared_with": f"Producer ID: {producer.id}", + "received": payment.amount, + }, ) logger.debug(f"livestream: producer invoice paid: {checking_id}")