mirror of
https://github.com/lnbits/lnbits.git
synced 2025-09-27 20:36:16 +02:00
make extension use new settings
This commit is contained in:
@@ -12,7 +12,7 @@ from loguru import logger
|
|||||||
|
|
||||||
from lnbits.core.services import create_invoice, pay_invoice
|
from lnbits.core.services import create_invoice, pay_invoice
|
||||||
from lnbits.helpers import urlsafe_short_hash
|
from lnbits.helpers import urlsafe_short_hash
|
||||||
from lnbits.settings import BOLTZ_NETWORK, BOLTZ_URL
|
from lnbits.settings import settings
|
||||||
|
|
||||||
from .crud import update_swap_status
|
from .crud import update_swap_status
|
||||||
from .mempool import (
|
from .mempool import (
|
||||||
@@ -33,9 +33,7 @@ from .models import (
|
|||||||
)
|
)
|
||||||
from .utils import check_balance, get_timestamp, req_wrap
|
from .utils import check_balance, get_timestamp, req_wrap
|
||||||
|
|
||||||
net = NETWORKS[BOLTZ_NETWORK]
|
net = NETWORKS[settings.boltz_network]
|
||||||
logger.trace(f"BOLTZ_URL: {BOLTZ_URL}")
|
|
||||||
logger.trace(f"Bitcoin Network: {net['name']}")
|
|
||||||
|
|
||||||
|
|
||||||
async def create_swap(data: CreateSubmarineSwap) -> SubmarineSwap:
|
async def create_swap(data: CreateSubmarineSwap) -> SubmarineSwap:
|
||||||
@@ -62,7 +60,7 @@ async def create_swap(data: CreateSubmarineSwap) -> SubmarineSwap:
|
|||||||
|
|
||||||
res = req_wrap(
|
res = req_wrap(
|
||||||
"post",
|
"post",
|
||||||
f"{BOLTZ_URL}/createswap",
|
f"{settings.boltz_url}/createswap",
|
||||||
json={
|
json={
|
||||||
"type": "submarine",
|
"type": "submarine",
|
||||||
"pairId": "BTC/BTC",
|
"pairId": "BTC/BTC",
|
||||||
@@ -129,7 +127,7 @@ async def create_reverse_swap(
|
|||||||
|
|
||||||
res = req_wrap(
|
res = req_wrap(
|
||||||
"post",
|
"post",
|
||||||
f"{BOLTZ_URL}/createswap",
|
f"{settings.boltz_url}/createswap",
|
||||||
json={
|
json={
|
||||||
"type": "reversesubmarine",
|
"type": "reversesubmarine",
|
||||||
"pairId": "BTC/BTC",
|
"pairId": "BTC/BTC",
|
||||||
@@ -409,7 +407,7 @@ def check_boltz_limits(amount):
|
|||||||
def get_boltz_pairs():
|
def get_boltz_pairs():
|
||||||
res = req_wrap(
|
res = req_wrap(
|
||||||
"get",
|
"get",
|
||||||
f"{BOLTZ_URL}/getpairs",
|
f"{settings.boltz_url}/getpairs",
|
||||||
headers={"Content-Type": "application/json"},
|
headers={"Content-Type": "application/json"},
|
||||||
)
|
)
|
||||||
return res.json()
|
return res.json()
|
||||||
@@ -418,7 +416,7 @@ def get_boltz_pairs():
|
|||||||
def get_boltz_status(boltzid):
|
def get_boltz_status(boltzid):
|
||||||
res = req_wrap(
|
res = req_wrap(
|
||||||
"post",
|
"post",
|
||||||
f"{BOLTZ_URL}/swapstatus",
|
f"{settings.boltz_url}/swapstatus",
|
||||||
json={"id": boltzid},
|
json={"id": boltzid},
|
||||||
)
|
)
|
||||||
return res.json()
|
return res.json()
|
||||||
|
@@ -7,14 +7,11 @@ import websockets
|
|||||||
from embit.transaction import Transaction
|
from embit.transaction import Transaction
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
|
|
||||||
from lnbits.settings import BOLTZ_MEMPOOL_SPACE_URL, BOLTZ_MEMPOOL_SPACE_URL_WS
|
from lnbits.settings import settings
|
||||||
|
|
||||||
from .utils import req_wrap
|
from .utils import req_wrap
|
||||||
|
|
||||||
logger.trace(f"BOLTZ_MEMPOOL_SPACE_URL: {BOLTZ_MEMPOOL_SPACE_URL}")
|
websocket_url = f"{settings.boltz_mempool_space_url_ws}/api/v1/ws"
|
||||||
logger.trace(f"BOLTZ_MEMPOOL_SPACE_URL_WS: {BOLTZ_MEMPOOL_SPACE_URL_WS}")
|
|
||||||
|
|
||||||
websocket_url = f"{BOLTZ_MEMPOOL_SPACE_URL_WS}/api/v1/ws"
|
|
||||||
|
|
||||||
|
|
||||||
async def wait_for_websocket_message(send, message_string):
|
async def wait_for_websocket_message(send, message_string):
|
||||||
@@ -33,7 +30,7 @@ async def wait_for_websocket_message(send, message_string):
|
|||||||
def get_mempool_tx(address):
|
def get_mempool_tx(address):
|
||||||
res = req_wrap(
|
res = req_wrap(
|
||||||
"get",
|
"get",
|
||||||
f"{BOLTZ_MEMPOOL_SPACE_URL}/api/address/{address}/txs",
|
f"{settings.boltz_mempool_space_url}/api/address/{address}/txs",
|
||||||
headers={"Content-Type": "text/plain"},
|
headers={"Content-Type": "text/plain"},
|
||||||
)
|
)
|
||||||
txs = res.json()
|
txs = res.json()
|
||||||
@@ -70,7 +67,7 @@ def get_fee_estimation() -> int:
|
|||||||
def get_mempool_fees() -> int:
|
def get_mempool_fees() -> int:
|
||||||
res = req_wrap(
|
res = req_wrap(
|
||||||
"get",
|
"get",
|
||||||
f"{BOLTZ_MEMPOOL_SPACE_URL}/api/v1/fees/recommended",
|
f"{settings.boltz_mempool_space_url}/api/v1/fees/recommended",
|
||||||
headers={"Content-Type": "text/plain"},
|
headers={"Content-Type": "text/plain"},
|
||||||
)
|
)
|
||||||
fees = res.json()
|
fees = res.json()
|
||||||
@@ -80,7 +77,7 @@ def get_mempool_fees() -> int:
|
|||||||
def get_mempool_blockheight() -> int:
|
def get_mempool_blockheight() -> int:
|
||||||
res = req_wrap(
|
res = req_wrap(
|
||||||
"get",
|
"get",
|
||||||
f"{BOLTZ_MEMPOOL_SPACE_URL}/api/blocks/tip/height",
|
f"{settings.boltz_mempool_space_url}/api/blocks/tip/height",
|
||||||
headers={"Content-Type": "text/plain"},
|
headers={"Content-Type": "text/plain"},
|
||||||
)
|
)
|
||||||
return int(res.text)
|
return int(res.text)
|
||||||
@@ -91,7 +88,7 @@ async def send_onchain_tx(tx: Transaction):
|
|||||||
logger.debug(f"Boltz - mempool sending onchain tx...")
|
logger.debug(f"Boltz - mempool sending onchain tx...")
|
||||||
req_wrap(
|
req_wrap(
|
||||||
"post",
|
"post",
|
||||||
f"{BOLTZ_MEMPOOL_SPACE_URL}/api/tx",
|
f"{settings.boltz_mempool_space_url}/api/tx",
|
||||||
headers={"Content-Type": "text/plain"},
|
headers={"Content-Type": "text/plain"},
|
||||||
content=raw,
|
content=raw,
|
||||||
)
|
)
|
||||||
|
@@ -14,7 +14,7 @@ from starlette.requests import Request
|
|||||||
|
|
||||||
from lnbits.core.crud import get_user
|
from lnbits.core.crud import get_user
|
||||||
from lnbits.decorators import WalletTypeInfo, get_key_type, require_admin_key
|
from lnbits.decorators import WalletTypeInfo, get_key_type, require_admin_key
|
||||||
from lnbits.settings import BOLTZ_MEMPOOL_SPACE_URL
|
from lnbits.settings import settings
|
||||||
|
|
||||||
from . import boltz_ext
|
from . import boltz_ext
|
||||||
from .boltz import (
|
from .boltz import (
|
||||||
@@ -55,7 +55,7 @@ from .utils import check_balance
|
|||||||
response_model=str,
|
response_model=str,
|
||||||
)
|
)
|
||||||
async def api_mempool_url():
|
async def api_mempool_url():
|
||||||
return BOLTZ_MEMPOOL_SPACE_URL
|
return settings.boltz_mempool_space_url
|
||||||
|
|
||||||
|
|
||||||
# NORMAL SWAP
|
# NORMAL SWAP
|
||||||
|
@@ -12,7 +12,7 @@ from lnbits import bolt11
|
|||||||
from lnbits.core.crud import delete_expired_invoices, get_payments
|
from lnbits.core.crud import delete_expired_invoices, get_payments
|
||||||
from lnbits.core.services import create_invoice, pay_invoice
|
from lnbits.core.services import create_invoice, pay_invoice
|
||||||
from lnbits.decorators import WalletTypeInfo
|
from lnbits.decorators import WalletTypeInfo
|
||||||
from lnbits.settings import LNBITS_SITE_TITLE, WALLET
|
from lnbits.settings import WALLET, settings
|
||||||
|
|
||||||
from . import lndhub_ext
|
from . import lndhub_ext
|
||||||
from .decorators import check_wallet, require_admin_key
|
from .decorators import check_wallet, require_admin_key
|
||||||
@@ -56,7 +56,7 @@ async def lndhub_addinvoice(
|
|||||||
_, pr = await create_invoice(
|
_, pr = await create_invoice(
|
||||||
wallet_id=wallet.wallet.id,
|
wallet_id=wallet.wallet.id,
|
||||||
amount=int(data.amt),
|
amount=int(data.amt),
|
||||||
memo=data.memo or LNBITS_SITE_TITLE,
|
memo=data.memo or settings.lnbits_site_title,
|
||||||
extra={"tag": "lndhub"},
|
extra={"tag": "lndhub"},
|
||||||
)
|
)
|
||||||
except:
|
except:
|
||||||
|
@@ -8,7 +8,7 @@ from starlette.responses import HTMLResponse
|
|||||||
|
|
||||||
from lnbits.core.models import User
|
from lnbits.core.models import User
|
||||||
from lnbits.decorators import check_user_exists
|
from lnbits.decorators import check_user_exists
|
||||||
from lnbits.settings import LNBITS_CUSTOM_LOGO, LNBITS_SITE_TITLE
|
from lnbits.settings import settings
|
||||||
|
|
||||||
from . import tpos_ext, tpos_renderer
|
from . import tpos_ext, tpos_renderer
|
||||||
from .crud import get_tpos
|
from .crud import get_tpos
|
||||||
@@ -50,12 +50,12 @@ async def manifest(tpos_id: str):
|
|||||||
)
|
)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"short_name": LNBITS_SITE_TITLE,
|
"short_name": settings.lnbits_site_title,
|
||||||
"name": tpos.name + " - " + LNBITS_SITE_TITLE,
|
"name": tpos.name + " - " + settings.lnbits_site_title,
|
||||||
"icons": [
|
"icons": [
|
||||||
{
|
{
|
||||||
"src": LNBITS_CUSTOM_LOGO
|
"src": settings.lnbits_custom_logo
|
||||||
if LNBITS_CUSTOM_LOGO
|
if settings.lnbits_custom_logo
|
||||||
else "https://cdn.jsdelivr.net/gh/lnbits/lnbits@0.3.0/docs/logos/lnbits.png",
|
else "https://cdn.jsdelivr.net/gh/lnbits/lnbits@0.3.0/docs/logos/lnbits.png",
|
||||||
"type": "image/png",
|
"type": "image/png",
|
||||||
"sizes": "900x900",
|
"sizes": "900x900",
|
||||||
@@ -69,9 +69,9 @@ async def manifest(tpos_id: str):
|
|||||||
"theme_color": "#1F2234",
|
"theme_color": "#1F2234",
|
||||||
"shortcuts": [
|
"shortcuts": [
|
||||||
{
|
{
|
||||||
"name": tpos.name + " - " + LNBITS_SITE_TITLE,
|
"name": tpos.name + " - " + settings.lnbits_site_title,
|
||||||
"short_name": tpos.name,
|
"short_name": tpos.name,
|
||||||
"description": tpos.name + " - " + LNBITS_SITE_TITLE,
|
"description": tpos.name + " - " + settings.lnbits_site_title,
|
||||||
"url": "/tpos/" + tpos_id,
|
"url": "/tpos/" + tpos_id,
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
Reference in New Issue
Block a user