bug: lndhub path
This commit is contained in:
parent
9c52be315e
commit
9f763c09f8
@ -146,7 +146,7 @@ export default function WalletPage() {
|
|||||||
<div>{(a.memo ?? "").length === 0 ? <> </> : a.memo}</div>
|
<div>{(a.memo ?? "").length === 0 ? <> </> : a.memo}</div>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
className={(() => {
|
className={`nowrap ${(() => {
|
||||||
switch (a.state) {
|
switch (a.state) {
|
||||||
case WalletInvoiceState.Paid:
|
case WalletInvoiceState.Paid:
|
||||||
return "success";
|
return "success";
|
||||||
@ -157,7 +157,7 @@ export default function WalletPage() {
|
|||||||
default:
|
default:
|
||||||
return "pending";
|
return "pending";
|
||||||
}
|
}
|
||||||
})()}>
|
})()}`}>
|
||||||
{stateIcon(a.state)}
|
{stateIcon(a.state)}
|
||||||
<FormattedMessage
|
<FormattedMessage
|
||||||
defaultMessage="{amount} sats"
|
defaultMessage="{amount} sats"
|
||||||
@ -175,14 +175,14 @@ export default function WalletPage() {
|
|||||||
function walletBalance() {
|
function walletBalance() {
|
||||||
if (wallet instanceof WebLNWallet) return null;
|
if (wallet instanceof WebLNWallet) return null;
|
||||||
return (
|
return (
|
||||||
<b>
|
<small>
|
||||||
<FormattedMessage
|
<FormattedMessage
|
||||||
defaultMessage="Balance: {amount} sats"
|
defaultMessage="Balance: {amount} sats"
|
||||||
values={{
|
values={{
|
||||||
amount: <FormattedNumber value={balance ?? 0} />,
|
amount: <FormattedNumber value={balance ?? 0} />,
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</b>
|
</small>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -190,17 +190,16 @@ export default function WalletPage() {
|
|||||||
if (!wallet?.isReady()) return null;
|
if (!wallet?.isReady()) return null;
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<h3>{info?.alias}</h3>
|
<div className="card">
|
||||||
{walletBalance()}
|
<h3>{info?.alias}</h3>
|
||||||
|
{walletBalance()}
|
||||||
|
</div>
|
||||||
{/*<div className="flex wallet-buttons">
|
{/*<div className="flex wallet-buttons">
|
||||||
<AsyncButton onClick={createInvoice}>
|
<AsyncButton onClick={createInvoice}>
|
||||||
<FormattedMessage defaultMessage="Receive" description="Receive sats by generating LN invoice" />
|
<FormattedMessage defaultMessage="Receive" description="Receive sats by generating LN invoice" />
|
||||||
</AsyncButton>
|
</AsyncButton>
|
||||||
</div>*/}
|
</div>*/}
|
||||||
{walletHistory()}
|
{walletHistory()}
|
||||||
<button onClick={() => Wallets.remove(unwrap(walletState.config).id)}>
|
|
||||||
<FormattedMessage defaultMessage="Delete Account" />
|
|
||||||
</button>
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -211,6 +210,10 @@ export default function WalletPage() {
|
|||||||
{walletList()}
|
{walletList()}
|
||||||
{unlockWallet()}
|
{unlockWallet()}
|
||||||
{walletInfo()}
|
{walletInfo()}
|
||||||
|
|
||||||
|
<button onClick={() => Wallets.remove(unwrap(walletState.config).id)}>
|
||||||
|
<FormattedMessage defaultMessage="Delete Account" />
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -131,14 +131,18 @@ export class LNCWallet implements LNWallet {
|
|||||||
reversed: true,
|
reversed: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
console.debug(invoices);
|
||||||
return invoices.payments.map(a => {
|
return invoices.payments.map(a => {
|
||||||
const parsedInvoice = prToWalletInvoice(a.paymentRequest);
|
const parsedInvoice = prToWalletInvoice(a.paymentRequest);
|
||||||
|
if (!parsedInvoice) {
|
||||||
|
throw new WalletError(WalletErrorCode.InvalidInvoice, `Could not parse ${a.paymentRequest}`);
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
...parsedInvoice,
|
...parsedInvoice,
|
||||||
state: (() => {
|
state: (() => {
|
||||||
switch (a.status) {
|
switch (a.status) {
|
||||||
case Payment_PaymentStatus.SUCCEEDED:
|
case Payment_PaymentStatus.SUCCEEDED:
|
||||||
return;
|
return WalletInvoiceState.Paid;
|
||||||
case Payment_PaymentStatus.FAILED:
|
case Payment_PaymentStatus.FAILED:
|
||||||
return WalletInvoiceState.Failed;
|
return WalletInvoiceState.Failed;
|
||||||
default:
|
default:
|
||||||
|
@ -18,7 +18,7 @@ const defaultHeaders = {
|
|||||||
|
|
||||||
export default class LNDHubWallet implements LNWallet {
|
export default class LNDHubWallet implements LNWallet {
|
||||||
type: "lndhub" | "snort";
|
type: "lndhub" | "snort";
|
||||||
url: string;
|
url: URL;
|
||||||
user: string;
|
user: string;
|
||||||
password: string;
|
password: string;
|
||||||
auth?: AuthResponse;
|
auth?: AuthResponse;
|
||||||
@ -32,13 +32,13 @@ export default class LNDHubWallet implements LNWallet {
|
|||||||
if (!parsedUrl || parsedUrl.length !== 4) {
|
if (!parsedUrl || parsedUrl.length !== 4) {
|
||||||
throw new Error("Invalid LNDHUB config");
|
throw new Error("Invalid LNDHUB config");
|
||||||
}
|
}
|
||||||
this.url = new URL(parsedUrl[3]).toString();
|
this.url = new URL(parsedUrl[3]);
|
||||||
this.user = parsedUrl[1];
|
this.user = parsedUrl[1];
|
||||||
this.password = parsedUrl[2];
|
this.password = parsedUrl[2];
|
||||||
this.type = "lndhub";
|
this.type = "lndhub";
|
||||||
} else if (url.startsWith("snort://")) {
|
} else if (url.startsWith("snort://")) {
|
||||||
const u = new URL(url);
|
const u = new URL(url);
|
||||||
this.url = `https://${u.host}${u.pathname}`;
|
this.url = new URL(`https://${u.host}${u.pathname}`);
|
||||||
this.user = "";
|
this.user = "";
|
||||||
this.password = "";
|
this.password = "";
|
||||||
this.type = "snort";
|
this.type = "snort";
|
||||||
@ -125,10 +125,11 @@ export default class LNDHubWallet implements LNWallet {
|
|||||||
private async getJson<T>(method: "GET" | "POST", path: string, body?: unknown): Promise<T> {
|
private async getJson<T>(method: "GET" | "POST", path: string, body?: unknown): Promise<T> {
|
||||||
let auth = `Bearer ${this.auth?.access_token}`;
|
let auth = `Bearer ${this.auth?.access_token}`;
|
||||||
if (this.type === "snort") {
|
if (this.type === "snort") {
|
||||||
const ev = await this.publisher?.generic(`${new URL(this.url).pathname}${path}`, 30_000);
|
const ev = await this.publisher?.generic(`${this.url.pathname}${path}`, 30_000);
|
||||||
auth = JSON.stringify(ev?.ToObject());
|
auth = JSON.stringify(ev?.ToObject());
|
||||||
}
|
}
|
||||||
const rsp = await fetch(`${this.url}${path}`, {
|
const url = `${this.url.pathname === "/" ? this.url.toString().slice(0, -1) : this.url.toString()}${path}`;
|
||||||
|
const rsp = await fetch(url, {
|
||||||
method: method,
|
method: method,
|
||||||
body: body ? JSON.stringify(body) : undefined,
|
body: body ? JSON.stringify(body) : undefined,
|
||||||
headers: {
|
headers: {
|
||||||
|
@ -535,6 +535,10 @@ body.scroll-lock {
|
|||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.nowrap {
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
.main-content h2 {
|
.main-content h2 {
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
font-size: 32px;
|
font-size: 32px;
|
||||||
|
Loading…
Reference in New Issue
Block a user