Some checks failed
ci.yml / feat(v2): nostr-transport roster-resolver hook (#20 path-B) (pull_request) Failing after 0s
Exposes `resolve(sender_pubkey_hex) -> RouteHit | None` and a
`register_with_lnbits()` helper that lazily-imports + soft-fails on
lnbits versions without `register_roster_resolver`. Wired into
`satmachineadmin_start()`.
The hook delivers the path-B outcome ("cash-out sats go to the
operator's wallet, not an auto-created machine wallet") once the
lnbits side ships its half. Shape contract `(operator_user_id,
wallet_id, source_extension)` frozen per coord-log 2026-05-31T15:25Z.
Branch held local until lnbits lands the registry — no behaviour
change on the current lnbits version, just the future-ready handoff
+ a benign INFO log on boot.
Boot-smoked in dev container: extension loads, registration logs the
documented soft-fail message, invoice listener + cassette consumer
unchanged. 6 new unit tests cover happy path, miss, bech32 +
uppercase canonicalisation, fail-closed on malformed input, and the
soft-fail register branch.
68 lines
2.2 KiB
Python
68 lines
2.2 KiB
Python
import asyncio
|
|
|
|
from fastapi import APIRouter
|
|
from lnbits.tasks import create_permanent_unique_task
|
|
from loguru import logger
|
|
|
|
from .crud import db
|
|
from .nostr_transport_roster import register_with_lnbits as register_roster_with_lnbits
|
|
from .tasks import wait_for_cassette_state_events, wait_for_paid_invoices
|
|
from .views import satmachineadmin_generic_router
|
|
from .views_api import satmachineadmin_api_router
|
|
|
|
logger.info("satmachineadmin v2 loaded")
|
|
|
|
|
|
satmachineadmin_ext: APIRouter = APIRouter(
|
|
prefix="/satmachineadmin", tags=["DCA Admin"]
|
|
)
|
|
satmachineadmin_ext.include_router(satmachineadmin_generic_router)
|
|
satmachineadmin_ext.include_router(satmachineadmin_api_router)
|
|
|
|
satmachineadmin_static_files = [
|
|
{
|
|
"path": "/satmachineadmin/static",
|
|
"name": "satmachineadmin_static",
|
|
}
|
|
]
|
|
|
|
scheduled_tasks: list[asyncio.Task] = []
|
|
|
|
|
|
def satmachineadmin_stop():
|
|
for task in scheduled_tasks:
|
|
try:
|
|
task.cancel()
|
|
except Exception as ex:
|
|
logger.warning(ex)
|
|
|
|
|
|
def satmachineadmin_start():
|
|
# bitSpire invoice listener — replaces the v1 SSH/PostgreSQL poller.
|
|
invoice_task = create_permanent_unique_task(
|
|
"ext_satmachineadmin", wait_for_paid_invoices
|
|
)
|
|
scheduled_tasks.append(invoice_task)
|
|
# Cassette bootstrap consumer (#29 v1) — subscribes to
|
|
# bitspire-cassettes-state events from each active ATM and upserts
|
|
# cassette_configs on receipt. Soft-fails if nostrclient isn't
|
|
# installed (logs + backs off, never crashes).
|
|
cassette_task = create_permanent_unique_task(
|
|
"ext_satmachineadmin_cassette_bootstrap", wait_for_cassette_state_events
|
|
)
|
|
scheduled_tasks.append(cassette_task)
|
|
# Path-B wallet-routing hook (#20 / coord-log 2026-05-31T15:25Z):
|
|
# register our ATM-roster resolver with lnbits' nostr-transport so
|
|
# inbound kind-21000 from a known ATM npub routes to the operator's
|
|
# wallet, not an auto-created machine wallet. Soft-fails on lnbits
|
|
# versions that don't yet expose `register_roster_resolver`.
|
|
register_roster_with_lnbits()
|
|
|
|
|
|
__all__ = [
|
|
"db",
|
|
"satmachineadmin_ext",
|
|
"satmachineadmin_start",
|
|
"satmachineadmin_static_files",
|
|
"satmachineadmin_stop",
|
|
]
|