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

LSP: add ability to request Simple Taproot Channels #1721

Merged
merged 1 commit into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,7 @@
"views.Settings.LSP.enableLSP": "Enable Lightning Service Provider (LSP)",
"views.Settings.LSP.enableLSP.subtitle": "The LSP will get you connected to the Lightning network by opening up payment channels for you.",
"views.Settings.LSP.lspAccessKey": "LSP Access Key (if needed)",
"views.Settings.LSP.requestSimpleTaproot": "Request Simple Taproot Channels",
"views.Settings.AddContact.name": "Name",
"views.Settings.AddContact.description": "Description (max 120)",
"views.Settings.AddContact.lnAddress": "LN address",
Expand Down
12 changes: 6 additions & 6 deletions stores/LSPStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,24 +185,24 @@ export default class LSPStore {
this.error = false;
this.error_msg = '';
this.showLspSettings = false;

const { settings } = this.settingsStore;

return new Promise((resolve, reject) => {
ReactNativeBlobUtil.fetch(
'post',
`${this.getLSPHost()}/api/v1/proposal`,
this.settingsStore.settings.lspAccessKey
settings.lspAccessKey
? {
'Content-Type': 'application/json',
'x-auth-token':
this.settingsStore.settings.lspAccessKey
'x-auth-token': settings.lspAccessKey
}
: {
'Content-Type': 'application/json'
},
JSON.stringify({
bolt11,
// TODO investigate why Taproot chans from LSP
// result in unsettled funds
simpleTaproot: false
simpleTaproot: settings.requestSimpleTaproot
})
)
.then(async (response: any) => {
Expand Down
4 changes: 3 additions & 1 deletion stores/SettingsStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ export interface Settings {
lspMainnet: string;
lspTestnet: string;
lspAccessKey: string;
requestSimpleTaproot: boolean;
}

export const FIAT_RATES_SOURCE_KEYS = [
Expand Down Expand Up @@ -718,7 +719,8 @@ export default class SettingsStore {
enableLSP: true,
lspMainnet: DEFAULT_LSP_MAINNET,
lspTestnet: DEFAULT_LSP_TESTNET,
lspAccessKey: ''
lspAccessKey: '',
requestSimpleTaproot: false
};
@observable public posStatus: string = 'unselected';
@observable public loading = false;
Expand Down
47 changes: 44 additions & 3 deletions views/Settings/LSP.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ interface EmbeddedNodeState {
enableLSP: boolean | undefined;
lsp: string;
accessKey: string;
requestSimpleTaproot: boolean;
}

@inject('SettingsStore')
Expand All @@ -33,7 +34,8 @@ export default class EmbeddedNode extends React.Component<
state = {
enableLSP: true,
lsp: '',
accessKey: ''
accessKey: '',
requestSimpleTaproot: false
};

async UNSAFE_componentWillMount() {
Expand All @@ -46,13 +48,14 @@ export default class EmbeddedNode extends React.Component<
embeddedLndNetwork === 'Mainnet'
? settings.lspMainnet
: settings.lspTestnet,
accessKey: settings.lspAccessKey
accessKey: settings.lspAccessKey,
requestSimpleTaproot: settings.requestSimpleTaproot
});
}

render() {
const { navigation, SettingsStore } = this.props;
const { enableLSP, lsp, accessKey } = this.state;
const { enableLSP, lsp, accessKey, requestSimpleTaproot } = this.state;
const { updateSettings, embeddedLndNetwork }: any = SettingsStore;

return (
Expand Down Expand Up @@ -184,6 +187,44 @@ export default class EmbeddedNode extends React.Component<
autoCorrect={false}
/>
</View>
<ListItem
containerStyle={{
borderBottomWidth: 0,
backgroundColor: 'transparent'
}}
>
<ListItem.Title
style={{
color: themeColor('secondaryText'),
fontFamily: 'Lato-Regular'
}}
>
{localeString(
'views.Settings.LSP.requestSimpleTaproot'
)}
</ListItem.Title>
<View
style={{
flex: 1,
flexDirection: 'row',
justifyContent: 'flex-end'
}}
>
<Switch
value={requestSimpleTaproot}
onValueChange={async () => {
this.setState({
requestSimpleTaproot:
!requestSimpleTaproot
});
await updateSettings({
requestSimpleTaproot:
!requestSimpleTaproot
});
}}
/>
</View>
</ListItem>
</View>
</Screen>
);
Expand Down