on master help sign in
Merge pull request #197 from urbit/feat/indigo-admin-passphrase-keys
2582248Fang
src/lib/keys.js+15−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,15 @@ 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+) => {
137+ //NOTE revision is the point's on-chain revision number. since common uhdw
138+ // usage derives the first key at revision/index 0, we need to decrement
139+ // the on-chain revision number by one to get the number to derive with.
128− return Just(await kg.deriveNetworkSeed(mnemonic, '', revision));
140+ return Just(await kg.deriveNetworkSeed(mnemonic, passphrase, revision - 1));
129};
141};
130
142
131/**
143/**
src/lib/reticket.js+2−4
@@ -33,6 +33,7 @@ export async function reticketPointBetweenWallets({
33 contracts,
33 contracts,
34 onUpdate,
34 onUpdate,
35 transferEth = false,
35 transferEth = false,
36+ nextRevision = INITIAL_NETWORK_KEY_REVISION,
36}) {
37}) {
37 const askForFunding = (address, minBalance, balance) =>
38 const askForFunding = (address, minBalance, balance) =>
38 onUpdate({
39 onUpdate({
@@ -65,10 +66,7 @@ export async function reticketPointBetweenWallets({
65 transferTmpTx.gas = GAS_LIMITS.TRANSFER;
66 transferTmpTx.gas = GAS_LIMITS.TRANSFER;
66
67
67 // configure networking public keys
68 // configure networking public keys
68− const seed = await deriveNetworkSeedFromUrbitWallet(
69+ const seed = await deriveNetworkSeedFromUrbitWallet(toWallet, nextRevision);
69− toWallet,
70− INITIAL_NETWORK_KEY_REVISION
71− );
72
70
73 const networkSeed = seed.matchWith({
71 const networkSeed = seed.matchWith({
74 Nothing: () => {
72 Nothing: () => {
src/lib/wallet.js+1
@@ -91,6 +91,7 @@ export const walletFromMnemonic = (mnemonic, hdpath, passphrase) => {
91 const hd = bip32.fromSeed(sd);
91 const hd = bip32.fromSeed(sd);
92 wal = hd.derivePath(path);
92 wal = hd.derivePath(path);
93 wal.address = addressFromSecp256k1Public(wal.publicKey);
93 wal.address = addressFromSecp256k1Public(wal.publicKey);
94+ wal.passphrase = passphrase || '';
94 wal = Just(wal);
95 wal = Just(wal);
95 } catch (_) {
96 } catch (_) {
96 wal = Nothing();
97 wal = Nothing();
src/views/Admin/AdminNetworkingKeys.js+1−1
@@ -95,7 +95,7 @@ function useSetKeys() {
95 wallet,
95 wallet,
96 authMnemonic,
96 authMnemonic,
97 details,
97 details,
98− revision: networkRevision + 1,
98+ revision: networkRevision,
99 });
99 });
100
100
101 return networkSeed.matchWith({
101 return networkSeed.matchWith({
src/views/Admin/Reticket/ReticketExecute.js+7−1
@@ -13,6 +13,7 @@ import useLifecycle from 'lib/useLifecycle';
13import { useNetwork } from 'store/network';
13import { useNetwork } from 'store/network';
14import { useWallet } from 'store/wallet';
14import { useWallet } from 'store/wallet';
15import { usePointCursor } from 'store/pointCursor';
15import { usePointCursor } from 'store/pointCursor';
16+import { usePointCache } from 'store/pointCache';
16import { useHistory } from 'store/history';
17import { useHistory } from 'store/history';
17
18
18import { RestartButton, ForwardButton } from 'components/Buttons';
19import { RestartButton, ForwardButton } from 'components/Buttons';
@@ -44,6 +45,7 @@ export default function ReticketExecute({ newWallet, setNewWallet }) {
44 const { web3, contracts } = useNetwork();
45 const { web3, contracts } = useNetwork();
45 const { wallet, setWalletType, resetWallet, setUrbitWallet } = useWallet();
46 const { wallet, setWalletType, resetWallet, setUrbitWallet } = useWallet();
46 const { pointCursor } = usePointCursor();
47 const { pointCursor } = usePointCursor();
48+ const { getDetails } = usePointCache();
47
49
48 const [generalError, setGeneralError] = useState();
50 const [generalError, setGeneralError] = useState();
49 const [progress, setProgress] = useState(0);
51 const [progress, setProgress] = useState(0);
@@ -53,14 +55,18 @@ export default function ReticketExecute({ newWallet, setNewWallet }) {
53 // start reticketing transactions on mount
55 // start reticketing transactions on mount
54 useLifecycle(() => {
56 useLifecycle(() => {
55 (async () => {
57 (async () => {
58+ const point = need.point(pointCursor);
59+ const details = need.details(getDetails(point));
60+ const networkRevision = parseInt(details.keyRevisionNumber, 10);
56 try {
61 try {
57 await reticketPointBetweenWallets({
62 await reticketPointBetweenWallets({
58 fromWallet: need.wallet(wallet),
63 fromWallet: need.wallet(wallet),
59 toWallet: newWallet.value.wallet,
64 toWallet: newWallet.value.wallet,
60− point: need.point(pointCursor),
65+ point: point,
61 web3: need.web3(web3),
66 web3: need.web3(web3),
62 contracts: need.contracts(contracts),
67 contracts: need.contracts(contracts),
63 onUpdate: handleUpdate,
68 onUpdate: handleUpdate,
69+ nextRevision: networkRevision + 1,
64 });
70 });
65 } catch (err) {
71 } catch (err) {
66 setGeneralError(err);
72 setGeneralError(err);