mirror of
https://github.com/RoboSats/robosats.git
synced 2025-01-18 20:21:35 +00:00
Add lnproxy json responses, enable lnproxy on android app
This commit is contained in:
parent
0ae63c50d2
commit
f7d4648fa5
@ -203,8 +203,10 @@ const Main = ({ settings, setSettings }: MainProps): JSX.Element => {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// Sets Setting network from coordinator API param if accessing via web
|
// Sets Setting network from coordinator API param if accessing via web
|
||||||
if (settings.network == undefined) {
|
if (settings.network == undefined && info.network) {
|
||||||
setSettings({ ...settings, network: info.network });
|
setSettings((settings: Settings) => {
|
||||||
|
return { ...settings, network: info.network };
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}, [info]);
|
}, [info]);
|
||||||
|
|
||||||
|
@ -172,44 +172,59 @@ export const LightningPayoutForm = ({
|
|||||||
lnproxyUrl();
|
lnproxyUrl();
|
||||||
}, [lightning.lnproxyServer]);
|
}, [lightning.lnproxyServer]);
|
||||||
|
|
||||||
// const fetchLnproxy = function () {
|
|
||||||
// setLoadingLnproxy(true);
|
|
||||||
// apiClient
|
|
||||||
// .get(
|
|
||||||
// lnproxyUrl(),
|
|
||||||
// `/api/${lightning.lnproxyInvoice}${lightning.lnproxyBudgetSats > 0 ? `?routing_msat=${lightning.lnproxyBudgetSats * 1000}` : ''}`,
|
|
||||||
// )
|
|
||||||
// };
|
|
||||||
|
|
||||||
// Lnproxy API does not return JSON, therefore not compatible with current apiClient service
|
|
||||||
// Does not work on Android robosats!
|
|
||||||
const fetchLnproxy = function () {
|
const fetchLnproxy = function () {
|
||||||
setLoadingLnproxy(true);
|
setLoadingLnproxy(true);
|
||||||
fetch(
|
apiClient
|
||||||
lnproxyUrl() +
|
.get(
|
||||||
`/api/${lightning.lnproxyInvoice.toLocaleLowerCase()}${
|
lnproxyUrl(),
|
||||||
|
`/api/${lightning.lnproxyInvoice}${
|
||||||
lightning.lnproxyBudgetSats > 0
|
lightning.lnproxyBudgetSats > 0
|
||||||
? `?routing_msat=${lightning.lnproxyBudgetSats * 1000}`
|
? `?routing_msat=${lightning.lnproxyBudgetSats * 1000}`
|
||||||
: ''
|
: ''
|
||||||
}`,
|
}&format=json`,
|
||||||
)
|
)
|
||||||
.then((response) => response.text())
|
.then((data) => {
|
||||||
.then((text) => {
|
if (data.reason) {
|
||||||
if (text.includes('lnproxy error')) {
|
setLightning({ ...lightning, badLnproxy: data.reason });
|
||||||
setLightning({ ...lightning, badLnproxy: text });
|
} else if (data.wpr) {
|
||||||
|
setLightning({ ...lightning, invoice: data.wpr, badLnproxy: '' });
|
||||||
} else {
|
} else {
|
||||||
const invoice = text.replace('\n', '');
|
setLightning({ ...lightning, badLnproxy: 'Unknown lnproxy response' });
|
||||||
setLightning({ ...lightning, invoice, badLnproxy: '' });
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
setLightning({ ...lightning, badLnproxy: 'Lnproxy server uncaught error' });
|
setLightning({ ...lightning, badLnproxy: 'Lnproxy server uncaught error' });
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => setLoadingLnproxy(false));
|
||||||
setLoadingLnproxy(false);
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// const fetchLnproxy = function () {
|
||||||
|
// setLoadingLnproxy(true);
|
||||||
|
// fetch(
|
||||||
|
// lnproxyUrl() +
|
||||||
|
// `/api/${lightning.lnproxyInvoice.toLocaleLowerCase()}${
|
||||||
|
// lightning.lnproxyBudgetSats > 0
|
||||||
|
// ? `?routing_msat=${lightning.lnproxyBudgetSats * 1000}`
|
||||||
|
// : ''
|
||||||
|
// }`,
|
||||||
|
// )
|
||||||
|
// .then((response) => response.text())
|
||||||
|
// .then((text) => {
|
||||||
|
// if (text.includes('lnproxy error')) {
|
||||||
|
// setLightning({ ...lightning, badLnproxy: text });
|
||||||
|
// } else {
|
||||||
|
// const invoice = text.replace('\n', '');
|
||||||
|
// setLightning({ ...lightning, invoice, badLnproxy: '' });
|
||||||
|
// }
|
||||||
|
// })
|
||||||
|
// .catch(() => {
|
||||||
|
// setLightning({ ...lightning, badLnproxy: 'Lnproxy server uncaught error' });
|
||||||
|
// })
|
||||||
|
// .finally(() => {
|
||||||
|
// setLoadingLnproxy(false);
|
||||||
|
// });
|
||||||
|
// };
|
||||||
|
|
||||||
const handleAdvancedOptions = function (checked: boolean) {
|
const handleAdvancedOptions = function (checked: boolean) {
|
||||||
if (checked) {
|
if (checked) {
|
||||||
setLightning({
|
setLightning({
|
||||||
@ -376,47 +391,43 @@ export const LightningPayoutForm = ({
|
|||||||
/>
|
/>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
{window.NativeRobosats === undefined ? (
|
<Grid item>
|
||||||
<Grid item>
|
<Tooltip
|
||||||
<Tooltip
|
enterTouchDelay={0}
|
||||||
enterTouchDelay={0}
|
leaveTouchDelay={4000}
|
||||||
leaveTouchDelay={4000}
|
placement='top'
|
||||||
placement='top'
|
title={t(
|
||||||
title={t(
|
`Wrap this invoice using a Lnproxy server to protect your privacy (hides the receiving wallet).`,
|
||||||
`Wrap this invoice using a Lnproxy server to protect your privacy (hides the receiving wallet).`,
|
)}
|
||||||
)}
|
>
|
||||||
>
|
<div>
|
||||||
<div>
|
<FormControlLabel
|
||||||
<FormControlLabel
|
onChange={(e) =>
|
||||||
onChange={(e) =>
|
setLightning({
|
||||||
setLightning({
|
...lightning,
|
||||||
...lightning,
|
useLnproxy: e.target.checked,
|
||||||
useLnproxy: e.target.checked,
|
invoice: e.target.checked ? '' : lightning.invoice,
|
||||||
invoice: e.target.checked ? '' : lightning.invoice,
|
})
|
||||||
})
|
}
|
||||||
}
|
checked={lightning.useLnproxy}
|
||||||
checked={lightning.useLnproxy}
|
control={<Checkbox />}
|
||||||
control={<Checkbox />}
|
label={
|
||||||
label={
|
<Typography color={lightning.useLnproxy ? 'primary' : 'text.secondary'}>
|
||||||
<Typography color={lightning.useLnproxy ? 'primary' : 'text.secondary'}>
|
{t('Use Lnproxy')}
|
||||||
{t('Use Lnproxy')}
|
</Typography>
|
||||||
</Typography>
|
}
|
||||||
}
|
/>{' '}
|
||||||
/>{' '}
|
<IconButton
|
||||||
<IconButton
|
component='a'
|
||||||
component='a'
|
target='_blank'
|
||||||
target='_blank'
|
href='https://www.lnproxy.org/about'
|
||||||
href='https://www.lnproxy.org/about'
|
rel='noreferrer'
|
||||||
rel='noreferrer'
|
>
|
||||||
>
|
<Help sx={{ width: '0.9em', height: '0.9em', color: 'text.secondary' }} />
|
||||||
<Help sx={{ width: '0.9em', height: '0.9em', color: 'text.secondary' }} />
|
</IconButton>
|
||||||
</IconButton>
|
</div>
|
||||||
</div>
|
</Tooltip>
|
||||||
</Tooltip>
|
</Grid>
|
||||||
</Grid>
|
|
||||||
) : (
|
|
||||||
<></>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<Grid item>
|
<Grid item>
|
||||||
<Collapse in={lightning.useLnproxy}>
|
<Collapse in={lightning.useLnproxy}>
|
||||||
|
@ -287,7 +287,7 @@ const TradeBox = ({
|
|||||||
}, [order.status]);
|
}, [order.status]);
|
||||||
|
|
||||||
const statusToContract = function (order: Order) {
|
const statusToContract = function (order: Order) {
|
||||||
const status = 6;
|
const status = order.status;
|
||||||
const isBuyer = order.is_buyer;
|
const isBuyer = order.is_buyer;
|
||||||
const isMaker = order.is_maker;
|
const isMaker = order.is_maker;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user