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