Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow name without extra splits #6

Merged
merged 1 commit into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,8 @@ The TipJar extension allows you to integrate Bitcoin Lightning (and on-chain) ti
<h2>How to set it up</h2>

1. Simply create a new Tip Jar with the desired details (onchain and webhook optional):
![image](https://user-images.githubusercontent.com/28876473/134996842-ec2f2783-2eef-4671-8eaf-023713865512.png)
![image](https://user-images.githubusercontent.com/28876473/134996842-ec2f2783-2eef-4671-8eaf-023713865512.png)
1. Share the URL you get from this little button:
![image](https://user-images.githubusercontent.com/28876473/134996973-f8ed4632-ea2f-4b62-83f1-1e4c6b6c91fa.png)

<h2>A note on webhooks</h3>

The `description` field of the message POSTed to your webhook will be in the following format:
* `{length of the name}|{name}{message}`

You can split along the first `|`. This will give you the index at which to split between the name of the tipper and the message of the tipper.
![image](https://user-images.githubusercontent.com/28876473/134996973-f8ed4632-ea2f-4b62-83f1-1e4c6b6c91fa.png)

<h3>And that's it already! Let the sats flow!</h3>
14 changes: 4 additions & 10 deletions views_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,12 @@ async def api_create_tip(data: createTips):
if not name:
name = "Anonymous"

# Ensure that description string can be split reliably
description = f"{len(name)}|{name}{message}"
charge_id = await create_charge(
data={
"amount": sats,
"webhook": tipjar.webhook or "",
"description": description,
"name": name,
"description": message,
"onchainwallet": tipjar.onchain or "",
"lnbitswallet": tipjar.wallet,
"completelink": "/tipjar/" + str(tipjar_id),
Expand Down Expand Up @@ -136,7 +135,6 @@ async def api_update_tip(
)

if tip.wallet != wallet.wallet.id:

raise HTTPException(
status_code=HTTPStatus.FORBIDDEN, detail="Not your tip."
)
Expand Down Expand Up @@ -178,9 +176,7 @@ async def api_update_tipjar(


@tipjar_ext.delete("/api/v1/tips/{tip_id}")
async def api_delete_tip(
tip_id: str, wallet: WalletTypeInfo = Depends(get_key_type)
):
async def api_delete_tip(tip_id: str, wallet: WalletTypeInfo = Depends(get_key_type)):
"""Delete the tip with the given tip_id"""
tip = await get_tip(tip_id)
if not tip:
Expand All @@ -200,8 +196,7 @@ async def api_delete_tip(

@tipjar_ext.delete("/api/v1/tipjars/{tipjar_id}")
async def api_delete_tipjar(
tipjar_id: int,
wallet: WalletTypeInfo = Depends(get_key_type)
tipjar_id: int, wallet: WalletTypeInfo = Depends(get_key_type)
):
"""Delete the tipjar with the given tipjar_id"""
tipjar = await get_tipjar(tipjar_id)
Expand All @@ -210,7 +205,6 @@ async def api_delete_tipjar(
status_code=HTTPStatus.NOT_FOUND, detail="No tipjar with this ID!"
)
if tipjar.wallet != wallet.wallet.id:

raise HTTPException(
status_code=HTTPStatus.FORBIDDEN,
detail="Not authorized to delete this tipjar!",
Expand Down