chore: adhere to ruff's "N" rules (#2377)
* chore: adhere to ruff's "N" rules WARN: reinstall failing extensions! bunch of more consistent variable naming. inspired by this issue. https://github.com/lnbits/lnbits/issues/2308 * fixup! chore: adhere to ruff's "N" rules * rename to funding_source * skip jmeter --------- Co-authored-by: Pavol Rusnak <pavol@rusnak.io>
This commit is contained in:
+10
-10
@@ -28,21 +28,21 @@ from .void import VoidWallet
|
||||
from .zbd import ZBDWallet
|
||||
|
||||
|
||||
def set_wallet_class(class_name: Optional[str] = None):
|
||||
def set_funding_source(class_name: Optional[str] = None):
|
||||
backend_wallet_class = class_name or settings.lnbits_backend_wallet_class
|
||||
wallet_class = getattr(wallets_module, backend_wallet_class)
|
||||
global WALLET
|
||||
WALLET = wallet_class()
|
||||
if WALLET.__node_cls__:
|
||||
set_node_class(WALLET.__node_cls__(WALLET))
|
||||
funding_source_constructor = getattr(wallets_module, backend_wallet_class)
|
||||
global funding_source
|
||||
funding_source = funding_source_constructor()
|
||||
if funding_source.__node_cls__:
|
||||
set_node_class(funding_source.__node_cls__(funding_source))
|
||||
|
||||
|
||||
def get_wallet_class() -> Wallet:
|
||||
return WALLET
|
||||
def get_funding_source() -> Wallet:
|
||||
return funding_source
|
||||
|
||||
|
||||
wallets_module = importlib.import_module("lnbits.wallets")
|
||||
FAKE_WALLET = FakeWallet()
|
||||
fake_wallet = FakeWallet()
|
||||
|
||||
# initialize as fake wallet
|
||||
WALLET: Wallet = FAKE_WALLET
|
||||
funding_source: Wallet = fake_wallet
|
||||
|
||||
@@ -144,5 +144,5 @@ class Wallet(ABC):
|
||||
return endpoint
|
||||
|
||||
|
||||
class Unsupported(Exception):
|
||||
class UnsupportedError(Exception):
|
||||
pass
|
||||
|
||||
@@ -18,7 +18,7 @@ from .base import (
|
||||
PaymentStatus,
|
||||
PaymentSuccessStatus,
|
||||
StatusResponse,
|
||||
Unsupported,
|
||||
UnsupportedError,
|
||||
Wallet,
|
||||
)
|
||||
|
||||
@@ -73,12 +73,12 @@ class CoreLightningWallet(Wallet):
|
||||
msat: int = int(amount * 1000)
|
||||
try:
|
||||
if description_hash and not unhashed_description:
|
||||
raise Unsupported(
|
||||
raise UnsupportedError(
|
||||
"'description_hash' unsupported by CoreLightning, provide"
|
||||
" 'unhashed_description'"
|
||||
)
|
||||
if unhashed_description and not self.supports_description_hash:
|
||||
raise Unsupported("unhashed_description")
|
||||
raise UnsupportedError("unhashed_description")
|
||||
r: dict = self.ln.invoice( # type: ignore
|
||||
msatoshi=msat,
|
||||
label=label,
|
||||
|
||||
@@ -16,7 +16,7 @@ from .base import (
|
||||
PaymentResponse,
|
||||
PaymentStatus,
|
||||
StatusResponse,
|
||||
Unsupported,
|
||||
UnsupportedError,
|
||||
Wallet,
|
||||
)
|
||||
from .macaroon import load_macaroon
|
||||
@@ -104,7 +104,7 @@ class CoreLightningRestWallet(Wallet):
|
||||
"label": label,
|
||||
}
|
||||
if description_hash and not unhashed_description:
|
||||
raise Unsupported(
|
||||
raise UnsupportedError(
|
||||
"'description_hash' unsupported by CoreLightningRest, "
|
||||
"provide 'unhashed_description'"
|
||||
)
|
||||
|
||||
@@ -40,8 +40,8 @@ class EclairWallet(Wallet):
|
||||
self.ws_url = f"ws://{urllib.parse.urlsplit(self.url).netloc}/ws"
|
||||
|
||||
password = settings.eclair_pass
|
||||
encodedAuth = base64.b64encode(f":{password}".encode())
|
||||
auth = str(encodedAuth, "utf-8")
|
||||
encoded_auth = base64.b64encode(f":{password}".encode())
|
||||
auth = str(encoded_auth, "utf-8")
|
||||
self.headers = {
|
||||
"Authorization": f"Basic {auth}",
|
||||
"User-Agent": settings.user_agent,
|
||||
|
||||
@@ -164,13 +164,13 @@ class LndRestWallet(Wallet):
|
||||
|
||||
async def pay_invoice(self, bolt11: str, fee_limit_msat: int) -> PaymentResponse:
|
||||
# set the fee limit for the payment
|
||||
lnrpcFeeLimit = {}
|
||||
lnrpcFeeLimit["fixed_msat"] = f"{fee_limit_msat}"
|
||||
lnrpc_fee_limit = {}
|
||||
lnrpc_fee_limit["fixed_msat"] = f"{fee_limit_msat}"
|
||||
|
||||
try:
|
||||
r = await self.client.post(
|
||||
url="/v1/channels/transactions",
|
||||
json={"payment_request": bolt11, "fee_limit": lnrpcFeeLimit},
|
||||
json={"payment_request": bolt11, "fee_limit": lnrpc_fee_limit},
|
||||
timeout=None,
|
||||
)
|
||||
r.raise_for_status()
|
||||
|
||||
@@ -12,7 +12,7 @@ from .base import (
|
||||
PaymentResponse,
|
||||
PaymentStatus,
|
||||
StatusResponse,
|
||||
Unsupported,
|
||||
UnsupportedError,
|
||||
Wallet,
|
||||
)
|
||||
|
||||
@@ -74,7 +74,7 @@ class OpenNodeWallet(Wallet):
|
||||
**kwargs,
|
||||
) -> InvoiceResponse:
|
||||
if description_hash or unhashed_description:
|
||||
raise Unsupported("description_hash")
|
||||
raise UnsupportedError("description_hash")
|
||||
|
||||
r = await self.client.post(
|
||||
"/v1/charges",
|
||||
|
||||
@@ -13,7 +13,7 @@ from .base import (
|
||||
PaymentResponse,
|
||||
PaymentStatus,
|
||||
StatusResponse,
|
||||
Unsupported,
|
||||
UnsupportedError,
|
||||
Wallet,
|
||||
)
|
||||
|
||||
@@ -65,7 +65,7 @@ class ZBDWallet(Wallet):
|
||||
) -> InvoiceResponse:
|
||||
# https://api.zebedee.io/v0/charges
|
||||
if description_hash or unhashed_description:
|
||||
raise Unsupported("description_hash")
|
||||
raise UnsupportedError("description_hash")
|
||||
|
||||
msats_amount = amount * 1000
|
||||
data: Dict = {
|
||||
|
||||
Reference in New Issue
Block a user