Skip to content
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
24 changes: 12 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,42 +5,42 @@ format: prettier black ruff
check: mypy pyright checkblack checkruff checkprettier

prettier:
poetry run ./node_modules/.bin/prettier --write .
uv run ./node_modules/.bin/prettier --write .
pyright:
poetry run ./node_modules/.bin/pyright
uv run ./node_modules/.bin/pyright

mypy:
poetry run mypy .
uv run mypy .

black:
poetry run black .
uv run black .

ruff:
poetry run ruff check . --fix
uv run ruff check . --fix

checkruff:
poetry run ruff check .
uv run ruff check .

checkprettier:
poetry run ./node_modules/.bin/prettier --check .
uv run ./node_modules/.bin/prettier --check .

checkblack:
poetry run black --check .
uv run black --check .

checkeditorconfig:
editorconfig-checker

test:
PYTHONUNBUFFERED=1 \
DEBUG=true \
poetry run pytest
uv run pytest
install-pre-commit-hook:
@echo "Installing pre-commit hook to git"
@echo "Uninstall the hook with poetry run pre-commit uninstall"
poetry run pre-commit install
@echo "Uninstall the hook with uv run pre-commit uninstall"
uv run pre-commit install

pre-commit:
poetry run pre-commit run --all-files
uv run pre-commit run --all-files


checkbundle:
Expand Down
2 changes: 1 addition & 1 deletion __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def splitpayments_start():
__all__ = [
"db",
"splitpayments_ext",
"splitpayments_static_files",
"splitpayments_start",
"splitpayments_static_files",
"splitpayments_stop",
]
4 changes: 1 addition & 3 deletions models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import Optional

from fastapi import Query
from pydantic import BaseModel

Expand All @@ -9,7 +7,7 @@ class Target(BaseModel):
wallet: str
source: str
percent: float
alias: Optional[str] = None
alias: str | None = None


class TargetPut(BaseModel):
Expand Down
3,642 changes: 0 additions & 3,642 deletions poetry.lock

This file was deleted.

55 changes: 22 additions & 33 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,49 +1,37 @@
[tool.poetry]
name = "lnbits-splitpayments"
version = "0.0.0"
description = "LNbits, free and open-source Lightning wallet and accounts system."
authors = ["Alan Bits <alan@lnbits.com>"]
package-mode = false
[project]
name = "splitpayments"
version = "1.1.1"
requires-python = ">=3.10,<3.13"
description = "Send incoming payments to different targets"
authors = [{name = "benarc"}, {name = "dni"}, {name = "alan"}]
urls = { Homepage = "https://lnbits.com", Repository = "https://github.com/lnbits/splitpayments" }

[tool.poetry.dependencies]
python = "~3.12 | ~3.11 | ~3.10"
lnbits = {version = "*", allow-prereleases = true}
dependencies = [ "lnbits>1" ]

[tool.poetry.group.dev.dependencies]
black = "^24.3.0"
pytest-asyncio = "^0.21.0"
pytest = "^7.3.2"
mypy = "^1.17.1"
pre-commit = "^3.2.2"
ruff = "^0.3.2"
[tool.poetry]
package-mode = false

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
[tool.uv]
dev-dependencies = [
"black",
"pytest-asyncio",
"pytest",
"mypy==1.17.1",
"pre-commit",
"ruff",
"pytest-md",
]

[tool.mypy]
exclude = "(nostr/*)"
plugins = "pydantic.mypy"
plugins = ["pydantic.mypy"]

[tool.pydantic-mypy]
init_forbid_extra = true
init_typed = true
warn_required_dynamic_aliases = true
warn_untyped_fields = true

[[tool.mypy.overrides]]
module = [
"lnbits.*",
"lnurl.*",
"loguru.*",
"fastapi.*",
"pydantic.*",
"pyqrcode.*",
"shortuuid.*",
"httpx.*",
]
ignore_missing_imports = "True"

[tool.pytest.ini_options]
log_cli = false
testpaths = [
Expand Down Expand Up @@ -85,6 +73,7 @@ dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
# needed for pydantic
[tool.ruff.lint.pep8-naming]
classmethod-decorators = [
"validator",
"root_validator",
]

Expand Down
21 changes: 17 additions & 4 deletions static/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,11 @@ window.app = Vue.createApp({
'/splitpayments/api/v1/targets',
this.selectedWallet.adminkey
)
.then(response => {
this.targets = response.data
.then(res => {
this.targets = res.data.map(t => ({
...t,
targetChoice: t.targetChoice || 'wallet'
}))
})
.catch(err => {
LNbits.utils.notifyApiError(err)
Expand All @@ -63,16 +66,26 @@ window.app = Vue.createApp({
this.getTargets()
},
addTarget() {
this.targets.push({source: this.selectedWallet})
this.targets.push({
source: this.selectedWallet,
targetChoice: 'wallet'
})
},
saveTargets() {
const payload = this.targets
.filter(t => t.wallet && String(t.wallet).trim() !== '')
.map(({alias, percent, wallet}) => ({
alias,
percent: Number(percent) || 0,
wallet
}))
LNbits.api
.request(
'PUT',
'/splitpayments/api/v1/targets',
this.selectedWallet.adminkey,
{
targets: this.targets
targets: payload
}
)
.then(response => {
Expand Down
3 changes: 1 addition & 2 deletions tasks.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import asyncio
from math import floor
from typing import Optional

import bolt11
from lnbits.core.crud import get_standalone_payment
Expand Down Expand Up @@ -100,7 +99,7 @@ async def pay_invoice_in_background(payment_request, wallet_id, description, ext

async def get_lnurl_invoice(
payoraddress: str, wallet_id: str, amount_msat: int, memo: str
) -> Optional[str]:
) -> str | None:

rounded_amount = floor(amount_msat / 1000) * 1000

Expand Down
35 changes: 33 additions & 2 deletions templates/splitpayments/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,50 @@ <h5 class="text-subtitle1 q-my-none">Target Wallets</h5>
:hint="t === targets.length - 1 ? 'A name to identify this target wallet locally.' : undefined"
style="width: 150px"
></q-input>

<div class="column q-mt-none">
<div class="col">
<q-radio
class="float-left"
v-model="target.targetChoice"
val="wallet"
label="wallet"
></q-radio>
</div>
<div class="col">
<q-radio
class="float-left"
v-model="target.targetChoice"
val="lnurl"
label="lnurl"
></q-radio>
</div>
</div>
<q-input
v-if="target.targetChoice === 'lnurl'"
dense
v-model.trim="target.wallet"
label="Target"
hint="A wallet ID, invoice key, LNURLp or Lightning Address."
hint="LNURLp or Lightning Address."
option-label="name"
style="width: 500px"
new-value-mode="add-unique"
use-input
input-debounce="0"
emit-value
></q-input>
<q-select
v-if="target.targetChoice === 'wallet'"
class="q-pr-md q-pt-sm"
filled
dense
style="width: 500px"
v-model="target.wallet"
:options="g.user.walletOptions"
emit-value
map-options
label="Receive wallet *"
>
</q-select>

<q-input
style="width: 150px"
Expand Down
Loading