mirror of
https://github.com/lnbits/lnbits-legend.git
synced 2025-02-23 22:47:05 +01:00
Merge branch 'master' into StreamerCopilot
This commit is contained in:
commit
00b8a52421
6 changed files with 29 additions and 18 deletions
|
@ -52,7 +52,10 @@ class Wallet(NamedTuple):
|
|||
wal=self.id,
|
||||
_external=True,
|
||||
)
|
||||
return lnurl_encode(url)
|
||||
try:
|
||||
return lnurl_encode(url)
|
||||
except:
|
||||
return ""
|
||||
|
||||
def lnurlauth_key(self, domain: str) -> SigningKey:
|
||||
hashing_key = hashlib.sha256(self.id.encode("utf-8")).digest()
|
||||
|
|
|
@ -186,6 +186,9 @@ async def redeem_lnurl_withdraw(
|
|||
wait_seconds: int = 0,
|
||||
conn: Optional[Connection] = None,
|
||||
) -> None:
|
||||
if not lnurl_request:
|
||||
return None
|
||||
|
||||
res = {}
|
||||
|
||||
async with httpx.AsyncClient() as client:
|
||||
|
@ -193,13 +196,19 @@ async def redeem_lnurl_withdraw(
|
|||
r = await client.get(str(lnurl))
|
||||
res = r.json()
|
||||
|
||||
_, payment_request = await create_invoice(
|
||||
wallet_id=wallet_id,
|
||||
amount=int(res["maxWithdrawable"] / 1000),
|
||||
memo=memo or res["defaultDescription"] or "",
|
||||
extra=extra,
|
||||
conn=conn,
|
||||
)
|
||||
try:
|
||||
_, payment_request = await create_invoice(
|
||||
wallet_id=wallet_id,
|
||||
amount=int(res["maxWithdrawable"] / 1000),
|
||||
memo=memo or res["defaultDescription"] or "",
|
||||
extra=extra,
|
||||
conn=conn,
|
||||
)
|
||||
except:
|
||||
print(
|
||||
f"failed to create invoice on redeem_lnurl_withdraw from {lnurl}. params: {res}"
|
||||
)
|
||||
return None
|
||||
|
||||
if wait_seconds:
|
||||
await trio.sleep(wait_seconds)
|
||||
|
|
|
@ -231,11 +231,9 @@
|
|||
<q-list>
|
||||
{% include "core/_api_docs.html" %}
|
||||
<q-separator></q-separator>
|
||||
<q-expansion-item
|
||||
group="extras"
|
||||
icon="crop_free"
|
||||
label="Drain Funds"
|
||||
>
|
||||
|
||||
{% if wallet.lnurlwithdraw_full %}
|
||||
<q-expansion-item group="extras" icon="crop_free" label="Drain Funds">
|
||||
<q-card>
|
||||
<q-card-section class="text-center">
|
||||
<p>
|
||||
|
@ -257,6 +255,8 @@
|
|||
</q-card>
|
||||
</q-expansion-item>
|
||||
<q-separator></q-separator>
|
||||
{% endif %}
|
||||
|
||||
<q-expansion-item
|
||||
group="extras"
|
||||
icon="settings_cell"
|
||||
|
@ -334,7 +334,7 @@
|
|||
<q-btn
|
||||
unelevated
|
||||
color="deep-purple"
|
||||
:disable="receive.data.amount == null || receive.data.amount <= 0"
|
||||
:disable="receive.data.memo == null || receive.data.amount == null || receive.data.amount <= 0"
|
||||
type="submit"
|
||||
>
|
||||
<span v-if="receive.lnurl">
|
||||
|
|
|
@ -123,7 +123,6 @@ class LNbitsWallet(Wallet):
|
|||
async with client.stream("GET", url) as r:
|
||||
async for line in r.aiter_lines():
|
||||
if line.startswith("data:"):
|
||||
|
||||
try:
|
||||
data = json.loads(line[5:])
|
||||
except json.decoder.JSONDecodeError:
|
||||
|
@ -134,7 +133,7 @@ class LNbitsWallet(Wallet):
|
|||
|
||||
yield data["payment_hash"] # payment_hash
|
||||
|
||||
except (OSError, httpx.ReadError, httpx.ConnectError):
|
||||
except (OSError, httpx.ReadError, httpx.ConnectError, httpx.ReadTimeout):
|
||||
pass
|
||||
|
||||
print("lost connection to lnbits /payments/sse, retrying in 5 seconds")
|
||||
|
|
|
@ -146,7 +146,7 @@ class LntxbotWallet(Wallet):
|
|||
data = json.loads(line[5:])
|
||||
if "payment_hash" in data and data.get("msatoshi") > 0:
|
||||
yield data["payment_hash"]
|
||||
except (OSError, httpx.ReadError):
|
||||
except (OSError, httpx.ReadError, httpx.ReadTimeout, httpx.ConnectError):
|
||||
pass
|
||||
|
||||
print("lost connection to lntxbot /payments/stream, retrying in 5 seconds")
|
||||
|
|
|
@ -195,7 +195,7 @@ class SparkWallet(Wallet):
|
|||
data = json.loads(line[5:])
|
||||
if "pay_index" in data and data.get("status") == "paid":
|
||||
yield data["label"]
|
||||
except (OSError, httpx.ReadError, httpx.ConnectError):
|
||||
except (OSError, httpx.ReadError, httpx.ConnectError, httpx.ReadTimeout):
|
||||
pass
|
||||
|
||||
print("lost connection to spark /stream, retrying in 5 seconds")
|
||||
|
|
Loading…
Add table
Reference in a new issue