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
Add set account passphrase #2664
Conversation
88f8508
to
8cbf22e
Compare
b108de9
to
189e0e2
Compare
Can rebase this now that 2665 is in |
eeb45ce
to
39bf5db
Compare
Hrm looks like there's another rebase that's needed, sorry |
ed69274
to
2250d5d
Compare
2752464
to
36aaa6d
Compare
36aaa6d
to
15b6df5
Compare
Now that 1.6.1 is pretty much done, a rebase is due on this one. |
app/actions/ControlActions.js
Outdated
try { | ||
const acctNumber = acct.encrypted ? acct.value : null; | ||
const error = await dispatch(unlockWalletOrAcct(passphrase, acctNumber)); | ||
if (error) { | ||
return dispatch({ error, type: SIGNTX_FAILED }); | ||
} | ||
const signTransactionResponse = await wallet.signTransaction( | ||
sel.walletService(getState()), | ||
rawTx | ||
); | ||
dispatch({ | ||
signTransactionResponse: signTransactionResponse, | ||
type: SIGNTX_SUCCESS | ||
}); | ||
dispatch( | ||
publishTransactionAttempt(signTransactionResponse.getTransaction()) | ||
); | ||
await dispatch(lockWalletOrAcct(acctNumber)); | ||
} catch(error) { | ||
dispatch({ error, type: SIGNTX_FAILED }); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This whole thing can leave the account unlocked if signTransaction
fails (since that could trigger an exception).
In general, the unlockWalletOrAcct(); doSomething(); lockWalletOrAcct()
pattern is going to be tricky to get (and maintain) correct at every instance an account unlocking can happen.
I suggest writing generic unlock/lock action, that takes as argument an async function and then unconditionally performs the unlock. Something like:
export const performWithUnlockedAccount = async (passphrase, acct, fn) => (dispatch) => {
// TODO: error handling, etc
await dispatch(unlockWalletOrAcct(passphrase, acctNumber));
let fnError;
let res;
try {
res = await fn();
} catch (error) {
fnError = error
}
await dispatch(lockWalletOrAcct(acctNumber));
if (fnError) throw fnError;
return res;
}
app/actions/ControlActions.js
Outdated
const { ticketBuyerService } = getState().grpc; | ||
dispatch({ ticketBuyerConfig, type: STARTTICKETBUYERV2_ATTEMPT }); | ||
const accountNum = account.encrypted ? account.value : null; | ||
const error = await dispatch(unlockWalletOrAcct(passphrase, accountNum)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I send a generic tx from the same account the ticket buyer is purchasing tickets from, will the lockWalletOrAcct()
call at the end of transaction interfere with the ticketbuyer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now it is not possible to do other actions while mixer or auto buyer is running, anymore.
0dbe02b
to
cf669c0
Compare
82bed7c
to
590c20d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks good overall, left some minors.
import { PassphraseModalButton, InvisibleButton } from "buttons"; | ||
import styles from "./SettingAccountsPassphrase.module.css"; | ||
|
||
export default ({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pls use const SettingAccountsPasspharse
.
Also, I feel that SetAccountsPasspharse
might be a better name for this component.
app/wallet/control.js
Outdated
@@ -461,9 +443,11 @@ export const setVspdAgendaChoices = ( | |||
export const unlockWallet = (walletService, passphrase) => | |||
new Promise((resolve, reject) => { | |||
const unlockReq = new api.UnlockWalletRequest(); | |||
console.log(console.log(passphrase)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
console
app/wallet/control.js
Outdated
unlockReq.setPassphrase(new Uint8Array(Buffer.from(passphrase))); | ||
// Unlock wallet so we can call the request. | ||
walletService.unlockWallet(unlockReq, (error) => { | ||
console.log(error); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
console
app/wallet/control.js
Outdated
resolve(response); | ||
}); | ||
}); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unnecessary empty line
On the Account passphrase page during start up with Skip and X button are shown. These should all be hidden since we are going to force the upgrade. |
I'll work on some copy to use on startup page. |
app/actions/ControlActions.js
Outdated
dispatch( | ||
publishTransactionAttempt(signTransactionResponse.getTransaction()) | ||
); | ||
await dispatch(lockWalletOrAcct(acctNumber)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this still needed now that signing happens inside unlockAcctAndExecFn
?
app/actions/ControlActions.js
Outdated
type: CREATE_UNSIGNEDTICKETS_SUCCESS | ||
}); | ||
} | ||
await dispatch(lockWalletOrAcct(accountNum)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still needed?
app/actions/ControlActions.js
Outdated
export const UNLOCKACCTORWALLET_FAILED = "UNLOCKACCTORWALLET_FAILED"; | ||
export const UNLOCKACCTORWALLET_SUCCESS = "UNLOCKACCTORWALLET_SUCCESS"; | ||
|
||
// unlockAcctAndExecFn unlocks the account and perform some acction. Locks the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perform => performs
acction => action
app/actions/ControlActions.js
Outdated
if (fnError !== null) { | ||
throw fnError; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will leave the account unlocked if fnError
is filled in the block above. This needs to happen after the wallet is locked (if leaveUnlock
is false).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
true, good catch.
491e7c7
to
95886d6
Compare
a452bc6
to
5d7e593
Compare
contains db upgrade -- backup db before testingThis PR depends on #2665 and on decred/dcrwallet#1823This PR depends on decred/dcrwallet#1979depends on #3337MAKE A DB BACKUP BEFORE TESTING, AS IT WILL SET ALL ACCOUNTS YOUR WALLET PASSPHRASE
This PR adds a new step into the setup wallet machine, which sets all account's passphrase as the wallet passhrase.
Right now what I changed to use lock/unlock account instead of wallet:
The rest of the wallet operations still are with old functionalities