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

feat: allow custom message #17

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
4 changes: 3 additions & 1 deletion crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ async def create_card(data: CreateCardData, wallet_id: str) -> Card:
external_id,
wallet,
card_name,
message,
counter,
tx_limit,
daily_limit,
Expand All @@ -29,14 +30,15 @@ async def create_card(data: CreateCardData, wallet_id: str) -> Card:
k2,
otp
)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
""",
(
card_id,
data.uid.upper(),
extenal_id,
wallet_id,
data.card_name,
data.message,
data.counter,
data.tx_limit,
data.daily_limit,
Expand Down
2 changes: 1 addition & 1 deletion lnurl.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ async def api_scan(p, c, request: Request, external_id: str):
"k1": hit.id,
"minWithdrawable": 1 * 1000,
"maxWithdrawable": card.tx_limit * 1000,
"defaultDescription": f"Boltcard (refund address lnurl://{lnurlpay})",
"defaultDescription": card.message or f"Boltcard (refund address lnurl://{lnurlpay})",
}


Expand Down
9 changes: 9 additions & 0 deletions migrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,12 @@ async def m001_initial(db):
);
"""
)


async def m002_add_custom_message(db):
"""
Adds column for custom message to be shown on scan.
"""
await db.execute(
"ALTER TABLE boltcards.cards ADD COLUMN message TEXT"
)
2 changes: 2 additions & 0 deletions models.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class Card(BaseModel):
id: str
wallet: str
card_name: str
message: str
uid: str
external_id: str
counter: int
Expand Down Expand Up @@ -43,6 +44,7 @@ async def lnurlpay_metadata(self) -> LnurlPayMetadata:

class CreateCardData(BaseModel):
card_name: str = Query(...)
message: str = Query(...)
uid: str = Query(...)
counter: int = Query(0)
tx_limit: int = Query(0)
Expand Down
10 changes: 10 additions & 0 deletions templates/boltcards/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,16 @@ <h6 class="text-subtitle1 q-my-none">
type="text"
label="Card name "
>
<q-input
filled
dense
emit-value
v-model.trim="cardDialog.data.message"
type="text"
label="Message"
>
<q-tooltip>Message to be shown on scan</q-tooltip>
</q-input>
</q-input>
<div class="row">
<div class="col-10">
Expand Down