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

Improved UI/UX for LNDhub read-only wallets #1781

Merged
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 backends/CLightningREST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ export default class CLightningREST extends LND {
supportsLnurlAuth = () => true;
supportsOnchainSends = () => true;
supportsOnchainReceiving = () => true;
supportsLightningSends = () => true;
supportsKeysend = () => true;
supportsChannelManagement = () => true;
supportsPendingChannels = () => false;
Expand Down
1 change: 1 addition & 0 deletions backends/Eclair.ts
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,7 @@ export default class Eclair {
supportsLnurlAuth = () => true;
supportsOnchainSends = () => true;
supportsOnchainReceiving = () => true;
supportsLightningSends = () => true;
supportsKeysend = () => false;
supportsChannelManagement = () => true;
supportsPendingChannels = () => false;
Expand Down
1 change: 1 addition & 0 deletions backends/EmbeddedLND.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ export default class EmbeddedLND extends LND {
supportsLnurlAuth = () => true;
supportsOnchainSends = () => true;
supportsOnchainReceiving = () => true;
supportsLightningSends = () => true;
supportsKeysend = () => true;
supportsChannelManagement = () => true;
supportsPendingChannels = () => true;
Expand Down
1 change: 1 addition & 0 deletions backends/LND.ts
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,7 @@ export default class LND {
supportsLnurlAuth = () => true;
supportsOnchainSends = () => true;
supportsOnchainReceiving = () => true;
supportsLightningSends = () => true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be able to do this for LND too as it has macaroons as well. tough to test an endpoint without sending though

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no idea how to do it... but since app behaviour is not changed by this, i think we can implement this later as well..?

supportsKeysend = () => true;
supportsChannelManagement = () => true;
supportsPendingChannels = () => true;
Expand Down
1 change: 1 addition & 0 deletions backends/LightningNodeConnect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ export default class LightningNodeConnect {
supportsLnurlAuth = () => true;
supportsOnchainSends = () => this.permSendCoins;
supportsOnchainReceiving = () => this.permNewAddress;
supportsLightningSends = () => this.permSendCoins;
supportsKeysend = () => true;
supportsChannelManagement = () => this.permOpenChannel;
supportsPendingChannels = () => true;
Expand Down
6 changes: 6 additions & 0 deletions backends/LndHub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,12 @@ export default class LndHub extends LND {
// LNBits
stores?.settingsStore?.lndhubUrl?.includes('/lndhub/ext/')
);
supportsLightningSends = () => {
return !(
stores?.settingsStore?.lndhubUrl?.includes('/lndhub/ext/') &&
stores.settingsStore.username === 'invoice'
);
};
supportsKeysend = () => false;
supportsChannelManagement = () => false;
supportsPendingChannels = () => false;
Expand Down
1 change: 1 addition & 0 deletions backends/Spark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ export default class Spark {
supportsLnurlAuth = () => false;
supportsOnchainSends = () => true;
supportsOnchainReceiving = () => true;
supportsLightningSends = () => true;
supportsKeysend = () => false;
supportsChannelManagement = () => true;
supportsPendingChannels = () => false;
Expand Down
59 changes: 35 additions & 24 deletions components/LayerBalances/LightningSwipeableRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,32 +114,43 @@ export default class LightningSwipeableRow extends Component<
);
};

private renderActions = (progress: Animated.AnimatedInterpolation) => (
<View
style={{
marginLeft: 15,
width: BackendUtils.supportsRouting() ? 210 : 140,
flexDirection: I18nManager.isRTL ? 'row-reverse' : 'row'
}}
>
{this.renderAction(
localeString('general.receive'),
BackendUtils.supportsRouting() ? 210 : 140,
progress
)}
{BackendUtils.supportsRouting() &&
this.renderAction(
localeString('general.routing'),
200,
private renderActions = (progress: Animated.AnimatedInterpolation) => {
const width =
BackendUtils.supportsRouting() &&
BackendUtils.supportsLightningSends()
? 210
: BackendUtils.supportsRouting() ||
BackendUtils.supportsLightningSends()
? 140
: 70;
return (
<View
style={{
marginLeft: 15,
width,
flexDirection: I18nManager.isRTL ? 'row-reverse' : 'row'
}}
>
{this.renderAction(
localeString('general.receive'),
width,
progress
)}
{this.renderAction(
localeString('general.send'),
BackendUtils.supportsRouting() ? 210 : 140,
progress
)}
</View>
);
{BackendUtils.supportsRouting() &&
this.renderAction(
localeString('general.routing'),
width,
progress
)}
{BackendUtils.supportsLightningSends() &&
this.renderAction(
localeString('general.send'),
width,
progress
)}
</View>
);
};

private swipeableRow?: Swipeable;

Expand Down
17 changes: 17 additions & 0 deletions components/WalletHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import handleAnything, { isClipboardValue } from '../utils/handleAnything';
import { localeString } from '../utils/LocaleUtils';
import PrivacyUtils from '../utils/PrivacyUtils';
import { themeColor } from '../utils/ThemeUtils';
import BackendUtils from '../utils/BackendUtils';

import Add from '../assets/images/SVG/Add.svg';
import ClipboardSVG from '../assets/images/SVG/Clipboard.svg';
Expand Down Expand Up @@ -285,6 +286,20 @@ export default class WalletHeader extends React.Component<
</>
);

const ReadOnlyBadge = () => {
return !BackendUtils.supportsLightningSends() ? (
<Badge
value={localeString('general.readOnlyWallet')}
badgeStyle={{
backgroundColor: themeColor('error'),
borderWidth: 0,
marginLeft: 8,
marginRight: 8
}}
/>
) : null;
};

const SearchButton = () => (
<TouchableOpacity
onPress={() => ChannelsStore!.toggleSearch()}
Expand Down Expand Up @@ -426,12 +441,14 @@ export default class WalletHeader extends React.Component<
)?.toString()}
</Text>
<NetworkBadge />
<ReadOnlyBadge />
<TorBadge />
</Row>
</View>
) : (
<Row>
<NetworkBadge />
<ReadOnlyBadge />
<TorBadge />
</Row>
)
Expand Down
2 changes: 2 additions & 0 deletions locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
"general.content": "Content",
"general.lightningInvoice": "Lightning invoice",
"general.or": "or",
"general.readOnlyWallet": "Read-only Wallet",
"general.reset": "Reset",
"general.other": "Other",
"views.Settings.Support.title": "Support ZEUS",
Expand Down Expand Up @@ -506,6 +507,7 @@
"views.PaymentRequest.lndGettingReadyReceive": "LND is getting ready to receive payments. Please wait.",
"views.PaymentRequest.isPmtHashSigValid": "Payment hash signature",
"views.PaymentRequest.isRelaysSigValid": "Relays signature",
"views.PaymentRequest.notAllowedToSend": "This wallet is not allowed to send funds!",
"views.Receive.title": "Receive",
"views.Receive.successCreate": "Successfully created invoice",
"views.Receive.warningLndHub": "Please note that LNDHub has a fixed on-chain address",
Expand Down
1 change: 1 addition & 0 deletions utils/BackendUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ class BackendUtils {
supportsLnurlAuth = () => this.call('supportsLnurlAuth');
supportsOnchainSends = () => this.call('supportsOnchainSends');
supportsOnchainReceiving = () => this.call('supportsOnchainReceiving');
supportsLightningSends = () => this.call('supportsLightningSends');
supportsKeysend = () => this.call('supportsKeysend');
supportsChannelManagement = () => this.call('supportsChannelManagement');
supportsPendingChannels = () => this.call('supportsPendingChannels');
Expand Down
128 changes: 72 additions & 56 deletions views/PaymentRequest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ export default class PaymentRequest extends React.Component<
/>
</View>
)}
{noBalance && (
{!BackendUtils.supportsLightningSends() && (
<View
style={{
paddingTop: 10,
Expand All @@ -453,11 +453,26 @@ export default class PaymentRequest extends React.Component<
>
<WarningMessage
message={localeString(
'views.Send.noLightningBalance'
'views.PaymentRequest.notAllowedToSend'
)}
/>
</View>
)}
{noBalance &&
BackendUtils.supportsLightningSends() && (
<View
style={{
paddingTop: 10,
paddingBottom: 10
}}
>
<WarningMessage
message={localeString(
'views.Send.noLightningBalance'
)}
/>
</View>
)}
{isNoAmountInvoice ? (
<AmountInput
amount={customAmount}
Expand Down Expand Up @@ -1136,61 +1151,62 @@ export default class PaymentRequest extends React.Component<
</>
)}

{!!pay_req && (
<View style={styles.button}>
<Button
title={localeString(
'views.PaymentRequest.payInvoice'
)}
icon={
lightningReadyToSend
? {
name: 'send',
size: 25
}
: undefined
}
onPress={() => {
if (isZaplocker)
LnurlPayStore.broadcastAttestation();
this.sendPayment(
feeOption,
String(percentAmount),
{
payment_request:
paymentRequest,
amount: satAmount
? satAmount.toString()
: undefined,
max_parts:
enableMultiPathPayment
? maxParts
: null,
max_shard_amt:
enableMultiPathPayment
? maxShardAmt
: null,
fee_limit_sat: isLnd
? feeLimitSat
: null,
max_fee_percent:
isCLightning
? maxFeePercentFormatted
{!!pay_req &&
BackendUtils.supportsLightningSends() && (
<View style={styles.button}>
<Button
title={localeString(
'views.PaymentRequest.payInvoice'
)}
icon={
lightningReadyToSend
? {
name: 'send',
size: 25
}
: undefined
}
onPress={() => {
if (isZaplocker)
LnurlPayStore.broadcastAttestation();
this.sendPayment(
feeOption,
String(percentAmount),
{
payment_request:
paymentRequest,
amount: satAmount
? satAmount.toString()
: undefined,
max_parts:
enableMultiPathPayment
? maxParts
: null,
max_shard_amt:
enableMultiPathPayment
? maxShardAmt
: null,
fee_limit_sat: isLnd
? feeLimitSat
: null,
outgoing_chan_id:
outgoingChanId,
last_hop_pubkey:
lastHopPubkey,
amp: enableAmp,
timeout_seconds:
timeoutSeconds
}
);
}}
disabled={!lightningReadyToSend}
/>
</View>
)}
max_fee_percent:
isCLightning
? maxFeePercentFormatted
: null,
outgoing_chan_id:
outgoingChanId,
last_hop_pubkey:
lastHopPubkey,
amp: enableAmp,
timeout_seconds:
timeoutSeconds
}
);
}}
disabled={!lightningReadyToSend}
/>
</View>
)}
</View>
)}
</ScrollView>
Expand Down
3 changes: 3 additions & 0 deletions views/Wallet/KeypadPane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,9 @@ export default class KeypadPane extends React.PureComponent<
});
}}
buttonStyle={{ height: 40 }}
disabled={
!BackendUtils.supportsLightningSends()
}
/>
</View>
</View>
Expand Down