fix typo in tasks and add/fix extra props

This commit is contained in:
Tiago Vasconcelos 2022-10-27 15:55:30 +01:00
parent c22329e86b
commit ea91c37489
2 changed files with 16 additions and 7 deletions

View File

@ -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},

View File

@ -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}")