mirror of
https://github.com/RoboSats/robosats.git
synced 2025-09-05 10:24:13 +00:00
Merge pull request #2185 from aftermath2/accept_prefixed_invoices
Support prefixed invoices
This commit is contained in:
@ -34,7 +34,11 @@ import { systemClient } from '../../../services/System';
|
|||||||
|
|
||||||
import lnproxies from '../../../../static/lnproxies.json';
|
import lnproxies from '../../../../static/lnproxies.json';
|
||||||
import { type UseAppStoreType, AppContext } from '../../../contexts/AppContext';
|
import { type UseAppStoreType, AppContext } from '../../../contexts/AppContext';
|
||||||
|
|
||||||
let filteredProxies: Array<Record<string, object>> = [];
|
let filteredProxies: Array<Record<string, object>> = [];
|
||||||
|
|
||||||
|
const lightningPrefix: string = 'lightning:';
|
||||||
|
|
||||||
export interface LightningForm {
|
export interface LightningForm {
|
||||||
invoice: string;
|
invoice: string;
|
||||||
amount: number;
|
amount: number;
|
||||||
@ -132,18 +136,26 @@ export const LightningPayoutForm = ({
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (lightning.invoice !== '') {
|
if (lightning.invoice !== '') {
|
||||||
|
const invoice = lightning.invoice.startsWith(lightningPrefix) ?
|
||||||
|
lightning.invoice.slice(lightningPrefix.length) : lightning.invoice;
|
||||||
|
|
||||||
setLightning({
|
setLightning({
|
||||||
...lightning,
|
...lightning,
|
||||||
badInvoice: validateInvoice(lightning.invoice, lightning.amount),
|
invoice: invoice,
|
||||||
|
badInvoice: validateInvoice(invoice, lightning.amount),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, [lightning.invoice, lightning.amount]);
|
}, [lightning.invoice, lightning.amount]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (lightning.lnproxyInvoice !== '') {
|
if (lightning.lnproxyInvoice !== '') {
|
||||||
|
const invoice = lightning.lnproxyInvoice.startsWith(lightningPrefix) ?
|
||||||
|
lightning.lnproxyInvoice.slice(lightningPrefix.length) : lightning.lnproxyInvoice;
|
||||||
|
|
||||||
setLightning({
|
setLightning({
|
||||||
...lightning,
|
...lightning,
|
||||||
badLnproxy: validateInvoice(lightning.lnproxyInvoice, lightning.lnproxyAmount),
|
lnproxyInvoice: invoice,
|
||||||
|
badLnproxy: validateInvoice(invoice, lightning.lnproxyAmount),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, [lightning.lnproxyInvoice, lightning.lnproxyAmount]);
|
}, [lightning.lnproxyInvoice, lightning.lnproxyAmount]);
|
||||||
|
Reference in New Issue
Block a user