Skip to content

Commit

Permalink
created OnChainAddresses screen
Browse files Browse the repository at this point in the history
  • Loading branch information
myxmaster committed Aug 14, 2024
1 parent f2603c4 commit bd7e3ca
Show file tree
Hide file tree
Showing 13 changed files with 537 additions and 44 deletions.
7 changes: 7 additions & 0 deletions App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import Payment from './views/Payment';
import PaymentPaths from './views/PaymentPaths';
import Invoice from './views/Invoice';
import Sweep from './views/Sweep';
import OnChainAddresses from './views/OnChainAddresses';

import SparkQRScanner from './views/SparkQRScanner';
import NodeInfo from './views/NodeInfo';
Expand Down Expand Up @@ -868,6 +869,12 @@ export default class App extends React.PureComponent {
name="PendingHTLCs"
component={PendingHTLCs}
/>
<Stack.Screen
name="OnChainAddresses"
component={
OnChainAddresses
}
/>
</Stack.Navigator>
</NavigationContainer>
</>
Expand Down
20 changes: 20 additions & 0 deletions assets/images/SVG/on-chain_addresses.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/LND.ts
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,7 @@ export default class LND {
getUTXOs = (data: any) => this.postRequest('/v2/wallet/utxos', data);
bumpFee = (data: any) => this.postRequest('/v2/wallet/bumpfee', data);
listAccounts = () => this.getRequest('/v2/wallet/accounts');
listAddresses = () => this.getRequest('/v2/wallet/addresses');
importAccount = (data: any) =>
this.postRequest('/v2/wallet/accounts/import', data);
signMessage = (message: string) =>
Expand Down Expand Up @@ -672,5 +673,6 @@ export default class LND {
supportsLSPS1customMessage = () => true;
supportsLSPS1rest = () => false;
supportsOffers = (): Promise<boolean> | boolean => false;
supportsAddressesWithDerivationPaths = () => this.supports('v0.18.0');
isLNDBased = () => true;
}
4 changes: 2 additions & 2 deletions components/DropdownSetting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ export default class DropdownSetting extends React.Component<
}
);

const displayItem = values.filter(
const displayItem = values.find(
(value: any) => value.value === selectedValue
)[0];
);

const display = displayItem ? displayItem.key : null;

Expand Down
17 changes: 14 additions & 3 deletions locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@
"general.used": "Used",
"general.unused": "Unused",
"general.discountCode": "Discount code",
"general.accountName": "Account name",
"general.addressType": "Address type",
"general.sorting": "Sorting",
"restart.title": "Restart required",
"restart.msg": "ZEUS has to be restarted before the new configuration is applied.",
"restart.msg1": "Would you like to restart now?",
Expand Down Expand Up @@ -277,10 +280,8 @@
"views.SparkQRScanner.text": "Scan a Spark QR code",
"views.SparkQRScanner.error": "Error fetching Spark config",
"views.ImportAccount.title": "Import account",
"views.ImportAccount.name": "Account name",
"views.ImportAccount.extendedPubKey": "Extended Public Key (xpub, zpub, tpub, etc.)",
"views.ImportAccount.masterKeyFingerprint": "Master Key Fingerprint",
"views.ImportAccount.addressType": "Address type",
"views.ImportAccount.importAccount": "Import Account",
"views.ImportAccount.note": "NOTE: Events (deposits/spends) for keys derived from an account will only be detected by LND if they happen after the import. Rescans to detect past events will be supported later on.",
"views.ImportAccount.derivationPath": "Derivation Path",
Expand Down Expand Up @@ -1232,5 +1233,15 @@
"views.PendingHTLCs.outgoing": "Outgoing",
"views.PendingHTLCs.expirationHeight": "Expiration height",
"views.PendingHTLCs.recommendationIOS": "It's recommended to leave ZEUS running while there are pending HTLCs to prevent force closes.",
"views.PendingHTLCs.recommendationAndroid": "It's recommended to enable Persistent LND or leave ZEUS running while there are pending HTLCs to prevent force closes."
"views.PendingHTLCs.recommendationAndroid": "It's recommended to enable Persistent LND or leave ZEUS running while there are pending HTLCs to prevent force closes.",
"views.OnChainAddresses.title": "On-chain addresses",
"views.OnChainAddresses.noAddressesAvailable": "No addresses available",
"views.OnChainAddresses.hideZeroBalanance": "Hide 0-balance",
"views.OnChainAddresses.hideChangeAddresses": "Hide change addresses",
"views.OnChainAddresses.sortBy.creationTimeAscending": "Creation time (ascending)",
"views.OnChainAddresses.sortBy.creationTimeDescending": "Creation time (descending)",
"views.OnChainAddresses.sortBy.balanceAscending": "Balance (ascending)",
"views.OnChainAddresses.sortBy.balanceDescending": "Balance (descending)",
"views.OnChainAddresses.createAddress": "Create address",
"views.OnChainAddresses.changeAddresses": "Change addresses"
}
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@
"@types/lodash": "4.14.198",
"@types/object-hash": "1.3.4",
"@types/pako": "2.0.3",
"@types/react": "18.0.38",
"@types/react-native": "0.70.6",
"@types/react": "18.2.21",
"@types/react-native": "0.73.0",
"@types/react-native-vector-icons": "6.4.14",
"@types/react-test-renderer": "18.0.2",
"@types/sha.js": "2.4.1",
Expand All @@ -198,6 +198,9 @@
"rn-nodeify": "10.3.0",
"typescript": "4.8.4"
},
"resolutions": {
"@types/react": "18.2.21"
},
"react-native": {
"zlib": "browserify-zlib",
"console": "console-browserify",
Expand Down
3 changes: 3 additions & 0 deletions utils/BackendUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ class BackendUtils {
getUTXOs = (...args: any[]) => this.call('getUTXOs', args);
listAccounts = (...args: any[]) => this.call('listAccounts', args);
importAccount = (...args: any[]) => this.call('importAccount', args);
listAddresses = (...args: any[]) => this.call('listAddresses', args);
signMessage = (...args: any[]) => this.call('signMessage', args);
verifyMessage = (...args: any[]) => this.call('verifyMessage', args);
lnurlAuth = (...args: any[]) => this.call('lnurlAuth', args);
Expand Down Expand Up @@ -169,6 +170,8 @@ class BackendUtils {
supportsOnchainBatching = () => this.call('supportsOnchainBatching');
supportsChannelBatching = () => this.call('supportsChannelBatching');
supportsOffers = () => this.call('supportsOffers');
supportsAddressesWithDerivationPaths = () =>
this.call('supportsAddressesWithDerivationPaths');
isLNDBased = () => this.call('isLNDBased');

// LNC
Expand Down
6 changes: 2 additions & 4 deletions views/Accounts/ImportAccount.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ export default class ImportAccount extends React.Component<
color: themeColor('secondaryText')
}}
>
{localeString('views.ImportAccount.name')}
{localeString('general.accountName')}
</Text>
<TextInput
placeholder={'My airgapped hardware wallet'}
Expand Down Expand Up @@ -281,9 +281,7 @@ export default class ImportAccount extends React.Component<
/>
</>
<DropdownSetting
title={localeString(
'views.ImportAccount.addressType'
)}
title={localeString('general.addressType')}
selectedValue={walletrpc.AddressType[address_type]}
onValueChange={async (value: string) => {
this.setState({
Expand Down
6 changes: 2 additions & 4 deletions views/Accounts/ImportingAccount.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export default class ImportingAccount extends React.Component<
/>
)}
<KeyValue
keyValue={localeString('views.ImportAccount.name')}
keyValue={localeString('general.accountName')}
value={name}
/>

Expand All @@ -89,9 +89,7 @@ export default class ImportingAccount extends React.Component<
)}

<KeyValue
keyValue={localeString(
'views.ImportAccount.addressType'
)}
keyValue={localeString('general.addressType')}
value={
walletrpc.AddressType[address_type] || address_type
}
Expand Down
46 changes: 46 additions & 0 deletions views/Menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import NostrichIcon from '../assets/images/SVG/Nostrich.svg';
import ReceiveIcon from '../assets/images/SVG/Receive.svg';
import RoutingIcon from '../assets/images/SVG/Routing.svg';
import WrenchIcon from '../assets/images/SVG/Wrench.svg';
import OnChainAddressesIcon from '../assets/images/SVG/on-chain_addresses.svg';

import Header from '../components/Header';
import NodeIdenticon, { NodeTitle } from '../components/NodeIdenticon';
Expand Down Expand Up @@ -469,6 +470,51 @@ export default class Menu extends React.Component<MenuProps, MenuState> {
</View>
)}

{BackendUtils.supportsAddressesWithDerivationPaths() && (
<View
style={{
backgroundColor: themeColor('secondary'),
width: '90%',
borderRadius: 10,
alignSelf: 'center',
marginVertical: 5
}}
>
<TouchableOpacity
onPress={() =>
navigation.navigate('OnChainAddresses')
}
>
<View style={styles.columnField}>
<View style={styles.icon}>
<OnChainAddressesIcon
fill={themeColor('text')}
stroke={themeColor('text')}
color={themeColor('text')}
height={22}
width={22}
/>
</View>
<Text
style={{
...styles.columnText,
color: themeColor('text')
}}
>
{localeString(
'views.OnChainAddresses.title'
)}
</Text>
<View style={styles.ForwardArrow}>
<ForwardIcon
stroke={forwardArrowColor}
/>
</View>
</View>
</TouchableOpacity>
</View>
)}

{selectedNode && BackendUtils.supportsOffers() && (
<View
style={{
Expand Down
Loading

0 comments on commit bd7e3ca

Please sign in to comment.