Skip to content

Commit

Permalink
Embedded LND: Seed: ypriv/zpriv: cache locally
Browse files Browse the repository at this point in the history
  • Loading branch information
kaloudis committed Jan 25, 2025
1 parent 28671f1 commit ba70ce5
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions views/Settings/SeedQRExport.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,18 @@ import {
} from '../../components/SuccessErrorMessage';

import stores from '../../stores/Stores';
import NodeInfoStore from '../../stores/NodeInfoStore';
import SettingsStore from '../../stores/SettingsStore';

import { BIP39_WORD_LIST } from '../../utils/Bip39Utils';
import { themeColor } from '../../utils/ThemeUtils';
import { localeString } from '../../utils/LocaleUtils';

import Storage from '../../storage';

interface SeedQRExportProps {
navigation: StackNavigationProp<any, any>;
NodeInfoStore: NodeInfoStore;
SettingsStore: SettingsStore;
}

Expand All @@ -58,7 +62,7 @@ const AEZEED_DEFAULT_PASSPHRASE = 'aezeed',
CHECKSUM_OFFSET = ENCIPHERED_LENGTH - CHECKSUM_LENGTH,
SALT_OFFSET = CHECKSUM_OFFSET - SALT_LENGTH;

@inject('SettingsStore')
@inject('NodeInfoStore', 'SettingsStore')
@observer
export default class SeedQRExport extends React.PureComponent<
SeedQRExportProps,
Expand Down Expand Up @@ -92,9 +96,25 @@ export default class SeedQRExport extends React.PureComponent<
async initializeSeed() {
try {
await this.props.SettingsStore.getSettings();
const { SettingsStore } = this.props;
const { NodeInfoStore, SettingsStore } = this.props;
const { seedPhrase }: any = SettingsStore;

const pubkey = NodeInfoStore!.nodeInfo?.nodeId;
const storageKey = `${pubkey}-extended-private-keys`;
const extendedKeys = await Storage.getItem(storageKey);
if (extendedKeys) {
const extendedKeysJson = JSON.parse(extendedKeys);
const { nodeBase58Segwit, nodeBase58NativeSegwit } =
extendedKeysJson;

this.setState({
loading: false,
nodeBase58Segwit,
nodeBase58NativeSegwit
});
return;
}

const bits = seedPhrase
.map((word: string) => {
const index = BIP39_WORD_LIST.indexOf(word);
Expand Down Expand Up @@ -238,6 +258,11 @@ export default class SeedQRExport extends React.PureComponent<
)
.toBase58();

await Storage.setItem(storageKey, {
nodeBase58Segwit,
nodeBase58NativeSegwit
});

this.setState({
loading: false,
nodeBase58Segwit,
Expand Down

0 comments on commit ba70ce5

Please sign in to comment.