-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
feat: update to lnbits 1.0.0 (#27)
* feat: update to lnbits 1.0.0 * fix select wallet * fix splits * fix: types, postgres errors with cache --------- Co-authored-by: Tiago Vasconcelos <[email protected]>
1 parent
32bf4ae
commit 5042d40
Showing
11 changed files
with
1,300 additions
and
1,218 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,23 @@ | ||
from typing import List | ||
|
||
from lnbits.db import Database | ||
from lnbits.helpers import urlsafe_short_hash | ||
|
||
from .models import Target | ||
|
||
db = Database("ext_splitpayments") | ||
|
||
|
||
async def get_targets(source_wallet: str) -> List[Target]: | ||
rows = await db.fetchall( | ||
"SELECT * FROM splitpayments.targets WHERE source = ?", (source_wallet,) | ||
async def get_targets(source_wallet: str) -> list[Target]: | ||
return await db.fetchall( | ||
"SELECT * FROM splitpayments.targets WHERE source = :source_wallet", | ||
{"source_wallet": source_wallet}, | ||
Target, | ||
) | ||
return [Target(**row) for row in rows] | ||
|
||
|
||
async def set_targets(source_wallet: str, targets: List[Target]): | ||
async def set_targets(source_wallet: str, targets: list[Target]): | ||
async with db.connect() as conn: | ||
await conn.execute( | ||
"DELETE FROM splitpayments.targets WHERE source = ?", (source_wallet,) | ||
"DELETE FROM splitpayments.targets WHERE source = :source_wallet", | ||
{"source_wallet": source_wallet}, | ||
) | ||
for target in targets: | ||
await conn.execute( | ||
""" | ||
INSERT INTO splitpayments.targets | ||
(id, source, wallet, percent, alias) | ||
VALUES (?, ?, ?, ?, ?) | ||
""", | ||
( | ||
urlsafe_short_hash(), | ||
source_wallet, | ||
target.wallet, | ||
target.percent, | ||
target.alias, | ||
), | ||
) | ||
await conn.insert("splitpayments.targets", target) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.