Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LSPS1 client #2097

Merged
merged 23 commits into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
f81439e
LSPS1 client
kaloudis May 6, 2024
597cfcc
LSPS1: flesh out settings pages
kaloudis May 6, 2024
d1ebb7e
LSPS1: REST: change get_order to a GET call
kaloudis May 6, 2024
6525ffc
LSPS1: show make payment btn only when the status is CREATED
shubhamkmr04 May 6, 2024
b13ab5e
Make separate component to display order response
shubhamkmr04 May 7, 2024
970e070
LSPS1: localize remaning strings + refactoring
shubhamkmr04 May 7, 2024
50e67ac
reorder lsp and client balance and display total balance as well
shubhamkmr04 May 7, 2024
5de5f4e
LSPS1: grok errors on sendCustomMessage
kaloudis May 8, 2024
3426a90
LSPS1: temp timeout fix for getInfo
kaloudis May 8, 2024
7fd3f1c
LSPS1: fix race conditions for getInfo
kaloudis May 8, 2024
e3f389e
LSPS1: Refactoring
shubhamkmr04 May 9, 2024
052c871
LSPS1: Saving uris and endpoints in storage for implementing getOrder…
shubhamkmr04 May 13, 2024
0c0c37a
LSPS1: Move getOrder call to store + feedback changes
shubhamkmr04 May 13, 2024
a8cef44
LSPS1: Fix update order logic
shubhamkmr04 May 14, 2024
a4454b4
LSPS1: Passing navigation as a prop to the LSPS1OrderResponse component
shubhamkmr04 May 14, 2024
8c4d6d2
LSPS1: Fix logic to display error in case of no orders saved
shubhamkmr04 May 15, 2024
bdac1fc
LSPS1: Only update FAILED or COMPLETED order first time
shubhamkmr04 May 17, 2024
3506476
Merge branch 'master' into shubham/wiring-up-endpoints
shubhamkmr04 May 17, 2024
0f6adf7
LSPS1: Using new navigation
shubhamkmr04 May 20, 2024
f9ea1db
LSPS1: Order view bug fix
shubhamkmr04 May 22, 2024
5b3892d
LSPS1: Filter orders according to backend
shubhamkmr04 May 23, 2024
e1a792c
Merge Master to shubham/wiring-up-endpoints
shubhamkmr04 May 23, 2024
e3d1363
LSPS1: Adding clientPubkey to the order responses to filter orders
shubhamkmr04 May 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,12 @@ import LspExplanationWrappedInvoices from './views/Explanations/LspExplanationWr
import LspExplanationOverview from './views/Explanations/LspExplanationOverview';
import RestoreChannelBackups from './views/Settings/EmbeddedNode/RestoreChannelBackups';

// LSPS1
import LSPS1 from './views/Settings/LSPS1/index';
import LSPS1Settings from './views/Settings/LSPS1/Settings';
import OrdersPane from './views/Settings/LSPS1/OrdersPane';
import Orders from './views/Settings/LSPS1/Order';

import RawTxHex from './views/RawTxHex';

import CustodialWalletWarning from './views/Settings/CustodialWalletWarning';
Expand Down Expand Up @@ -785,6 +791,24 @@ export default class App extends React.PureComponent {
name="TxHex"
component={TxHex}
/>
<Stack.Screen
name="LSPS1"
component={LSPS1}
/>
<Stack.Screen
name="LSPS1Settings"
component={
LSPS1Settings
}
/>
<Stack.Screen
name="OrdersPane"
component={OrdersPane}
/>
<Stack.Screen
name="LSPS1Order"
component={Orders}
/>
</Stack.Navigator>
</NavigationContainer>
</>
Expand Down
26 changes: 26 additions & 0 deletions assets/images/SVG/OlympusAnimated.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions assets/images/SVG/order-list.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions backends/CLightningREST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,4 +275,6 @@ export default class CLightningREST extends LND {
supportsOnchainBatching = () => false;
supportsChannelBatching = () => false;
isLNDBased = () => false;
supportsLSPS1customMessage = () => false;
supportsLSPS1rest = () => true;
}
2 changes: 2 additions & 0 deletions backends/Eclair.ts
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,8 @@ export default class Eclair {
supportsOnchainBatching = () => false;
supportsChannelBatching = () => false;
isLNDBased = () => false;
supportsLSPS1customMessage = () => false;
supportsLSPS1rest = () => true;
}

const mapInvoice =
Expand Down
9 changes: 8 additions & 1 deletion backends/EmbeddedLND.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ const {
getNetworkInfo,
queryRoutes,
lookupInvoice,
fundingStateStep
fundingStateStep,
sendCustomMessage,
subscribeCustomMessages
} = lndMobile.index;
const {
channelBalance,
Expand Down Expand Up @@ -68,6 +70,9 @@ export default class EmbeddedLND extends LND {
data.spend_unconfirmed,
data.send_all
);
sendCustomMessage = async (data: any) =>
await sendCustomMessage(data.peer, data.type, data.data);
subscribeCustomMessages = async () => await subscribeCustomMessages();
getMyNodeInfo = async () => await getInfo();
getNetworkInfo = async () => await getNetworkInfo();
getInvoices = async () => await listInvoices();
Expand Down Expand Up @@ -290,4 +295,6 @@ export default class EmbeddedLND extends LND {
supportsOnchainBatching = () => true;
supportsChannelBatching = () => true;
isLNDBased = () => true;
supportsLSPS1customMessage = () => true;
supportsLSPS1rest = () => false;
}
53 changes: 53 additions & 0 deletions backends/LND.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,57 @@ export default class LND {
spend_unconfirmed: data.spend_unconfirmed,
send_all: data.send_all
});
sendCustomMessage = (data: any) =>
this.postRequest('/v1/custommessage', {
peer: Base64Utils.hexToBase64(data.peer),
type: data.type,
data: Base64Utils.hexToBase64(data.data)
});
subscribeCustomMessages = (onResponse: any, onError: any) => {
const route = '/v1/custommessage/subscribe';
const method = 'GET';

const { host, lndhubUrl, port, macaroonHex, accessToken } =
stores.settingsStore;

const auth = macaroonHex || accessToken;
const headers: any = this.getHeaders(auth, true);
const methodRoute = `${route}?method=${method}`;
const url = this.getURL(host || lndhubUrl, port, methodRoute, true);

const ws: any = new WebSocket(url, null, {
headers
});

ws.addEventListener('open', () => {
// connection opened
console.log('subscribeCustomMessages ws open');
ws.send(JSON.stringify({}));
});

ws.addEventListener('message', (e: any) => {
// a message was received
const data = JSON.parse(e.data);
console.log('subscribeCustomMessagews message', data);
if (data.error) {
onError(data.error);
} else {
onResponse(data);
}
});

ws.addEventListener('error', (e: any) => {
// an error occurred
console.log('subscribeCustomMessages ws err', e);
const certWarning = localeString('backends.LND.wsReq.warning');
onError(e.message ? `${certWarning} (${e.message})` : certWarning);
});

ws.addEventListener('close', () => {
// ws closed
console.log('subscribeCustomMessages ws close');
});
};
getMyNodeInfo = () => this.getRequest('/v1/getinfo');
getInvoices = (data: any) =>
this.getRequest(
Expand Down Expand Up @@ -617,4 +668,6 @@ export default class LND {
supportsOnchainBatching = () => true;
supportsChannelBatching = () => true;
isLNDBased = () => true;
supportsLSPS1customMessage = () => true;
supportsLSPS1rest = () => false;
}
12 changes: 12 additions & 0 deletions backends/LightningNodeConnect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,16 @@ export default class LightningNodeConnect {
send_all: data.send_all
})
.then((data: lnrpc.SendCoinsResponse) => snakeize(data));
sendCustomMessage = async (data: any) =>
await this.lnc.lnd.lightning
.sendCustomMessage({
peer: Base64Utils.hexToBase64(data.peer),
type: data.type,
data: Base64Utils.hexToBase64(data.data)
})
.then((data: lnrpc.SendCustomMessageResponse) => snakeize(data));
subscribeCustomMessages = () =>
this.lnc.lnd.lightning.subscribeCustomMessages({});
getMyNodeInfo = async () =>
await this.lnc.lnd.lightning
.getInfo({})
Expand Down Expand Up @@ -477,4 +487,6 @@ export default class LightningNodeConnect {
supportsOnchainBatching = () => true;
supportsChannelBatching = () => true;
isLNDBased = () => true;
supportsLSPS1customMessage = () => true;
supportsLSPS1rest = () => false;
}
2 changes: 2 additions & 0 deletions backends/LndHub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,4 +155,6 @@ export default class LndHub extends LND {
supportsOnchainBatching = () => false;
supportsChannelBatching = () => true;
isLNDBased = () => false;
supportsLSPS1customMessage = () => false;
supportsLSPS1rest = () => false;
}
2 changes: 2 additions & 0 deletions backends/Spark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -381,4 +381,6 @@ export default class Spark {
supportsOnchainBatching = () => false;
supportsChannelBatching = () => true;
isLNDBased = () => false;
supportsLSPS1customMessage = () => false;
supportsLSPS1rest = () => true;
}
Loading
Loading