on master help sign in
Account for the passphrase when doing network seed derivation
6b4ca23Fang
src/lib/keys.js+12−3
@@ -92,6 +92,7 @@ export const deriveNetworkSeedFromUrbitWallet = async (
92) => {
92) => {
93 return await deriveNetworkSeedFromMnemonic(
93 return await deriveNetworkSeedFromMnemonic(
94 urbitWallet.management.seed,
94 urbitWallet.management.seed,
95+ urbitWallet.meta.passphrase,
95 revision
96 revision
96 );
97 );
97};
98};
@@ -113,7 +114,11 @@ export const deriveNetworkSeedFromManagementMnemonic = async (
113
114
114 // the network seed is derivable iff this mnemonic is the management proxy
115 // the network seed is derivable iff this mnemonic is the management proxy
115 if (isManagementProxy) {
116 if (isManagementProxy) {
116− return await deriveNetworkSeedFromMnemonic(authMnemonic, revision);
117+ return await deriveNetworkSeedFromMnemonic(
118+ authMnemonic,
119+ wallet.passphrase,
120+ revision
121+ );
117 }
122 }
118
123
119 return Nothing();
124 return Nothing();
@@ -124,8 +129,12 @@ export const deriveNetworkSeedFromManagementMnemonic = async (
124 * @param {number} revision
129 * @param {number} revision
125 * @return {Promise<Maybe<string>>}
130 * @return {Promise<Maybe<string>>}
126 */
131 */
127−const deriveNetworkSeedFromMnemonic = async (mnemonic, revision) => {
132+const deriveNetworkSeedFromMnemonic = async (
133+ mnemonic,
134+ passphrase,
135+ revision
136+) => {
128− return Just(await kg.deriveNetworkSeed(mnemonic, '', revision));
137+ return Just(await kg.deriveNetworkSeed(mnemonic, passphrase, revision));
129};
138};
130
139
131/**
140/**
src/lib/wallet.js+1
@@ -90,6 +90,7 @@ export const walletFromMnemonic = (mnemonic, hdpath, passphrase) => {
90 const hd = bip32.fromSeed(sd);
90 const hd = bip32.fromSeed(sd);
91 wal = hd.derivePath(path);
91 wal = hd.derivePath(path);
92 wal.address = addressFromSecp256k1Public(wal.publicKey);
92 wal.address = addressFromSecp256k1Public(wal.publicKey);
93+ wal.passphrase = passphrase || '';
93 wal = Just(wal);
94 wal = Just(wal);
94 } catch (_) {
95 } catch (_) {
95 wal = Nothing();
96 wal = Nothing();