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

Embedded LND: Seed: ypriv/zpriv: cache locally #2770

Merged
merged 1 commit into from
Jan 27, 2025
Merged
Changes from all commits
Commits
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
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
Loading