run autoflake
``` autoflake -i --remove-unused-variables $(find . -name "*.py") ```
This commit is contained in:
parent
c8efe41e1a
commit
15d7fbeace
38 changed files with 18 additions and 62 deletions
4
build.py
4
build.py
|
|
@ -1,10 +1,8 @@
|
||||||
import glob
|
import glob
|
||||||
import os
|
import os
|
||||||
import subprocess
|
|
||||||
import warnings
|
import warnings
|
||||||
from os import path
|
from os import path
|
||||||
from pathlib import Path
|
from typing import List
|
||||||
from typing import Any, List, NamedTuple, Optional
|
|
||||||
|
|
||||||
LNBITS_PATH = path.dirname(path.realpath(__file__)) + "/lnbits"
|
LNBITS_PATH = path.dirname(path.realpath(__file__)) + "/lnbits"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -702,7 +702,7 @@ async def websocket_connect(websocket: WebSocket, item_id: str):
|
||||||
await websocketManager.connect(websocket)
|
await websocketManager.connect(websocket)
|
||||||
try:
|
try:
|
||||||
while True:
|
while True:
|
||||||
data = await websocket.receive_text()
|
await websocket.receive_text()
|
||||||
except WebSocketDisconnect:
|
except WebSocketDisconnect:
|
||||||
websocketManager.disconnect(websocket)
|
websocketManager.disconnect(websocket)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
from typing import Callable, Dict, Union
|
from typing import Callable, Union
|
||||||
|
|
||||||
import httpx
|
import httpx
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -143,10 +143,10 @@ async def check_swap(swap: SubmarineSwap, client):
|
||||||
timeout_block_height=swap.timeout_block_height,
|
timeout_block_height=swap.timeout_block_height,
|
||||||
)
|
)
|
||||||
await update_swap_status(swap.id, "refunded")
|
await update_swap_status(swap.id, "refunded")
|
||||||
except BoltzNotFoundException as exc:
|
except BoltzNotFoundException:
|
||||||
logger.debug(f"Boltz - swap: {swap.boltz_id} does not exist.")
|
logger.debug(f"Boltz - swap: {swap.boltz_id} does not exist.")
|
||||||
await update_swap_status(swap.id, "failed")
|
await update_swap_status(swap.id, "failed")
|
||||||
except MempoolBlockHeightException as exc:
|
except MempoolBlockHeightException:
|
||||||
logger.debug(
|
logger.debug(
|
||||||
f"Boltz - tried to refund swap: {swap.id}, but has not reached the timeout."
|
f"Boltz - tried to refund swap: {swap.id}, but has not reached the timeout."
|
||||||
)
|
)
|
||||||
|
|
@ -171,7 +171,7 @@ async def check_reverse_swap(reverse_swap: ReverseSubmarineSwap, client):
|
||||||
logger.debug(f"Boltz - swap_status: {str(exc)}")
|
logger.debug(f"Boltz - swap_status: {str(exc)}")
|
||||||
await update_swap_status(reverse_swap.id, "failed")
|
await update_swap_status(reverse_swap.id, "failed")
|
||||||
# should only happen while development when regtest is reset
|
# should only happen while development when regtest is reset
|
||||||
except BoltzNotFoundException as exc:
|
except BoltzNotFoundException:
|
||||||
logger.debug(f"Boltz - reverse swap: {reverse_swap.boltz_id} does not exist.")
|
logger.debug(f"Boltz - reverse swap: {reverse_swap.boltz_id} does not exist.")
|
||||||
await update_swap_status(reverse_swap.id, "failed")
|
await update_swap_status(reverse_swap.id, "failed")
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,6 @@ from lnbits.tasks import catch_everything_and_restart
|
||||||
|
|
||||||
db = Database("ext_cashu")
|
db = Database("ext_cashu")
|
||||||
|
|
||||||
import sys
|
|
||||||
|
|
||||||
cashu_static_files = [
|
cashu_static_files = [
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,4 @@
|
||||||
import os
|
from typing import List, Optional, Union
|
||||||
import random
|
|
||||||
import time
|
|
||||||
from typing import Any, List, Optional, Union
|
|
||||||
|
|
||||||
from cashu.core.base import MintKeyset
|
from cashu.core.base import MintKeyset
|
||||||
from embit import bip32, bip39, ec, script
|
from embit import bip32, bip39, ec, script
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
from sqlite3 import Row
|
from sqlite3 import Row
|
||||||
from typing import List, Union
|
from typing import List
|
||||||
|
|
||||||
from fastapi import Query
|
from fastapi import Query
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
import asyncio
|
import asyncio
|
||||||
import json
|
|
||||||
|
|
||||||
from cashu.core.migrations import migrate_databases
|
from cashu.core.migrations import migrate_databases
|
||||||
from cashu.mint import migrations
|
from cashu.mint import migrations
|
||||||
|
|
@ -15,7 +14,6 @@ async def startup_cashu_mint():
|
||||||
await migrate_databases(db, migrations)
|
await migrate_databases(db, migrations)
|
||||||
await ledger.load_used_proofs()
|
await ledger.load_used_proofs()
|
||||||
await ledger.init_keysets(autosave=False)
|
await ledger.init_keysets(autosave=False)
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
async def wait_for_paid_invoices():
|
async def wait_for_paid_invoices():
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import math
|
import math
|
||||||
from http import HTTPStatus
|
from http import HTTPStatus
|
||||||
from typing import Dict, List, Union
|
from typing import Dict, Union
|
||||||
|
|
||||||
# -------- cashu imports
|
# -------- cashu imports
|
||||||
from cashu.core.base import (
|
from cashu.core.base import (
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
from http import HTTPStatus
|
|
||||||
from typing import List, Optional
|
from typing import List, Optional
|
||||||
|
|
||||||
from . import db
|
from . import db
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,3 @@
|
||||||
from typing import Optional
|
|
||||||
|
|
||||||
from pydantic.main import BaseModel
|
from pydantic.main import BaseModel
|
||||||
from sqlalchemy.engine import base # type: ignore
|
from sqlalchemy.engine import base # type: ignore
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
from sqlite3 import Row
|
from sqlite3 import Row
|
||||||
from typing import Optional
|
|
||||||
|
|
||||||
from fastapi.param_functions import Query
|
from fastapi.param_functions import Query
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,3 @@
|
||||||
import asyncio
|
|
||||||
|
|
||||||
from fastapi import APIRouter
|
from fastapi import APIRouter
|
||||||
from fastapi.staticfiles import StaticFiles
|
from fastapi.staticfiles import StaticFiles
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
import asyncio
|
import asyncio
|
||||||
import json
|
|
||||||
|
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,3 @@
|
||||||
import json
|
|
||||||
|
|
||||||
import httpx
|
import httpx
|
||||||
|
|
||||||
from .models import Domains
|
from .models import Domains
|
||||||
|
|
|
||||||
|
|
@ -228,4 +228,3 @@ async def lndhub_decodeinvoice(invoice: str = Query(None)):
|
||||||
@lndhub_ext.get("/ext/checkrouteinvoice")
|
@lndhub_ext.get("/ext/checkrouteinvoice")
|
||||||
async def lndhub_checkrouteinvoice():
|
async def lndhub_checkrouteinvoice():
|
||||||
"not implemented on canonical lndhub"
|
"not implemented on canonical lndhub"
|
||||||
pass
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
from typing import List, Optional, Union
|
from typing import List, Optional
|
||||||
|
|
||||||
import shortuuid
|
import shortuuid
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,3 @@
|
||||||
import hashlib
|
|
||||||
import math
|
|
||||||
from http import HTTPStatus
|
from http import HTTPStatus
|
||||||
|
|
||||||
from fastapi import Request
|
from fastapi import Request
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,4 @@
|
||||||
from base64 import urlsafe_b64encode
|
|
||||||
from typing import List, Optional, Union
|
from typing import List, Optional, Union
|
||||||
from uuid import uuid4
|
|
||||||
|
|
||||||
# from lnbits.db import open_ext_db
|
# from lnbits.db import open_ext_db
|
||||||
from lnbits.db import SQLITE
|
from lnbits.db import SQLITE
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
import json
|
import json
|
||||||
from http import HTTPStatus
|
from http import HTTPStatus
|
||||||
from typing import List
|
|
||||||
|
|
||||||
from fastapi import (
|
from fastapi import (
|
||||||
BackgroundTasks,
|
BackgroundTasks,
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,4 @@
|
||||||
from base64 import urlsafe_b64encode
|
|
||||||
from http import HTTPStatus
|
from http import HTTPStatus
|
||||||
from typing import List, Union
|
|
||||||
from uuid import uuid4
|
|
||||||
|
|
||||||
from fastapi import Body, Depends, Query, Request
|
from fastapi import Body, Depends, Query, Request
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,4 @@
|
||||||
from enum import Enum
|
|
||||||
from sqlite3 import Row
|
from sqlite3 import Row
|
||||||
from typing import List, Optional
|
|
||||||
|
|
||||||
from fastapi.param_functions import Query
|
from fastapi.param_functions import Query
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
from datetime import datetime
|
|
||||||
from http import HTTPStatus
|
from http import HTTPStatus
|
||||||
|
|
||||||
from fastapi import Depends, Request
|
from fastapi import Depends, Request
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
import time
|
import time
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from http import HTTPStatus
|
from http import HTTPStatus
|
||||||
from typing import List
|
|
||||||
|
|
||||||
from fastapi import Depends, HTTPException, Query, Request
|
from fastapi import Depends, HTTPException, Query, Request
|
||||||
from starlette.responses import HTMLResponse
|
from starlette.responses import HTMLResponse
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
from http import HTTPStatus
|
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
import httpx
|
import httpx
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,6 @@ async def cloudflare_deletesubdomain(domain: Domains, domain_id: str):
|
||||||
async with httpx.AsyncClient() as client:
|
async with httpx.AsyncClient() as client:
|
||||||
try:
|
try:
|
||||||
r = await client.delete(url + "/" + domain_id, headers=header, timeout=40)
|
r = await client.delete(url + "/" + domain_id, headers=header, timeout=40)
|
||||||
cf_response = r.text
|
r.text
|
||||||
except AssertionError:
|
except AssertionError:
|
||||||
cf_response = "Error occured"
|
pass
|
||||||
|
|
|
||||||
|
|
@ -55,4 +55,4 @@ async def on_invoice_paid(payment: Payment) -> None:
|
||||||
timeout=40,
|
timeout=40,
|
||||||
)
|
)
|
||||||
except AssertionError:
|
except AssertionError:
|
||||||
webhook = None
|
pass
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ import time
|
||||||
import traceback
|
import traceback
|
||||||
import uuid
|
import uuid
|
||||||
from http import HTTPStatus
|
from http import HTTPStatus
|
||||||
from typing import Callable, Dict, List
|
from typing import Dict
|
||||||
|
|
||||||
from fastapi.exceptions import HTTPException
|
from fastapi.exceptions import HTTPException
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import asyncio
|
import asyncio
|
||||||
import hashlib
|
import hashlib
|
||||||
import json
|
import json
|
||||||
from typing import AsyncGenerator, Dict, Optional
|
from typing import AsyncGenerator, Optional
|
||||||
|
|
||||||
import httpx
|
import httpx
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,7 @@ except ImportError: # pragma: nocover
|
||||||
LightningRpc = None
|
LightningRpc = None
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
import hashlib
|
|
||||||
import random
|
import random
|
||||||
import time
|
|
||||||
from functools import partial, wraps
|
from functools import partial, wraps
|
||||||
from typing import AsyncGenerator, Optional
|
from typing import AsyncGenerator, Optional
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -98,7 +98,6 @@ class EclairWallet(Wallet):
|
||||||
error_message = data["error"]
|
error_message = data["error"]
|
||||||
except:
|
except:
|
||||||
error_message = r.text
|
error_message = r.text
|
||||||
pass
|
|
||||||
|
|
||||||
return InvoiceResponse(False, None, None, error_message)
|
return InvoiceResponse(False, None, None, error_message)
|
||||||
|
|
||||||
|
|
@ -120,7 +119,6 @@ class EclairWallet(Wallet):
|
||||||
error_message = data["error"]
|
error_message = data["error"]
|
||||||
except:
|
except:
|
||||||
error_message = r.text
|
error_message = r.text
|
||||||
pass
|
|
||||||
return PaymentResponse(False, None, None, None, error_message)
|
return PaymentResponse(False, None, None, None, error_message)
|
||||||
|
|
||||||
data = r.json()
|
data = r.json()
|
||||||
|
|
@ -147,7 +145,6 @@ class EclairWallet(Wallet):
|
||||||
error_message = data["error"]
|
error_message = data["error"]
|
||||||
except:
|
except:
|
||||||
error_message = r.text
|
error_message = r.text
|
||||||
pass
|
|
||||||
return PaymentResponse(None, checking_id, None, preimage, error_message)
|
return PaymentResponse(None, checking_id, None, preimage, error_message)
|
||||||
|
|
||||||
statuses = {
|
statuses = {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
import asyncio
|
import asyncio
|
||||||
import hashlib
|
|
||||||
import json
|
import json
|
||||||
from typing import AsyncGenerator, Dict, Optional
|
from typing import AsyncGenerator, Dict, Optional
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ except ImportError: # pragma: nocover
|
||||||
import asyncio
|
import asyncio
|
||||||
import base64
|
import base64
|
||||||
import hashlib
|
import hashlib
|
||||||
from os import environ, error
|
from os import environ
|
||||||
from typing import AsyncGenerator, Dict, Optional
|
from typing import AsyncGenerator, Dict, Optional
|
||||||
|
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
|
|
@ -238,7 +238,7 @@ class LndWallet(Wallet):
|
||||||
return PaymentStatus(None)
|
return PaymentStatus(None)
|
||||||
try:
|
try:
|
||||||
resp = await self.rpc.LookupInvoice(ln.PaymentHash(r_hash=r_hash))
|
resp = await self.rpc.LookupInvoice(ln.PaymentHash(r_hash=r_hash))
|
||||||
except RpcError as exc:
|
except RpcError:
|
||||||
return PaymentStatus(None)
|
return PaymentStatus(None)
|
||||||
if resp.settled:
|
if resp.settled:
|
||||||
return PaymentStatus(True)
|
return PaymentStatus(True)
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ import asyncio
|
||||||
import base64
|
import base64
|
||||||
import hashlib
|
import hashlib
|
||||||
import json
|
import json
|
||||||
from pydoc import describe
|
|
||||||
from typing import AsyncGenerator, Dict, Optional
|
from typing import AsyncGenerator, Dict, Optional
|
||||||
|
|
||||||
import httpx
|
import httpx
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,6 @@ class LnTipsWallet(Wallet):
|
||||||
error_message = data["message"]
|
error_message = data["message"]
|
||||||
except:
|
except:
|
||||||
error_message = r.text
|
error_message = r.text
|
||||||
pass
|
|
||||||
|
|
||||||
return InvoiceResponse(False, None, None, error_message)
|
return InvoiceResponse(False, None, None, error_message)
|
||||||
|
|
||||||
|
|
@ -103,7 +102,6 @@ class LnTipsWallet(Wallet):
|
||||||
error_message = data["error"]
|
error_message = data["error"]
|
||||||
except:
|
except:
|
||||||
error_message = r.text
|
error_message = r.text
|
||||||
pass
|
|
||||||
return PaymentResponse(False, None, 0, None, error_message)
|
return PaymentResponse(False, None, 0, None, error_message)
|
||||||
|
|
||||||
data = r.json()["details"]
|
data = r.json()["details"]
|
||||||
|
|
@ -165,7 +163,7 @@ class LnTipsWallet(Wallet):
|
||||||
except:
|
except:
|
||||||
continue
|
continue
|
||||||
yield inv["payment_hash"]
|
yield inv["payment_hash"]
|
||||||
except Exception as e:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# do not sleep if the connection was active for more than 10s
|
# do not sleep if the connection was active for more than 10s
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,6 @@ class LntxbotWallet(Wallet):
|
||||||
error_message = data["message"]
|
error_message = data["message"]
|
||||||
except:
|
except:
|
||||||
error_message = r.text
|
error_message = r.text
|
||||||
pass
|
|
||||||
|
|
||||||
return InvoiceResponse(False, None, None, error_message)
|
return InvoiceResponse(False, None, None, error_message)
|
||||||
|
|
||||||
|
|
@ -97,7 +96,6 @@ class LntxbotWallet(Wallet):
|
||||||
error_message = data["message"]
|
error_message = data["message"]
|
||||||
except:
|
except:
|
||||||
error_message = r.text
|
error_message = r.text
|
||||||
pass
|
|
||||||
return PaymentResponse(False, None, None, None, error_message)
|
return PaymentResponse(False, None, None, None, error_message)
|
||||||
|
|
||||||
data = r.json()
|
data = r.json()
|
||||||
|
|
|
||||||
|
|
@ -161,7 +161,6 @@ class SparkWallet(Wallet):
|
||||||
# this may result in an error if it was paid previously
|
# this may result in an error if it was paid previously
|
||||||
# our database won't allow the same payment_hash to be added twice
|
# our database won't allow the same payment_hash to be added twice
|
||||||
# this is good
|
# this is good
|
||||||
pass
|
|
||||||
|
|
||||||
fee_msat = -int(r["msatoshi_sent"] - r["msatoshi"])
|
fee_msat = -int(r["msatoshi_sent"] - r["msatoshi"])
|
||||||
preimage = r["payment_preimage"]
|
preimage = r["payment_preimage"]
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
import asyncio
|
import asyncio
|
||||||
from typing import Tuple
|
|
||||||
|
|
||||||
import pytest_asyncio
|
import pytest_asyncio
|
||||||
from httpx import AsyncClient
|
from httpx import AsyncClient
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue