mirror of
https://github.com/wealdtech/ethdo.git
synced 2026-01-08 21:48:05 -05:00
Defer relocking appropriately.
This commit is contained in:
@@ -55,7 +55,7 @@ In quiet mode this will return 0 if the key can be obtained, otherwise 1.`,
|
||||
}
|
||||
}
|
||||
assert(unlocked, "Failed to unlock account to obtain private key")
|
||||
defer errCheck(locker.Lock(context.Background()), "failed to re-lock account")
|
||||
defer relockAccount(locker)
|
||||
}
|
||||
privateKey, err := privateKeyProvider.PrivateKey(ctx)
|
||||
errCheck(err, "Failed to obtain private key")
|
||||
|
||||
@@ -272,7 +272,7 @@ func accountFromPath(ctx context.Context, path string) (e2wtypes.Account, error)
|
||||
if err != nil {
|
||||
return nil, errors.New("invalid wallet passphrase")
|
||||
}
|
||||
defer errCheck(locker.Lock(context.Background()), "failed to re-lock account")
|
||||
defer relockAccount(locker)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -403,3 +403,8 @@ func openNamedWallet(walletName string) (e2wtypes.Wallet, error) {
|
||||
}
|
||||
return walletFromPath(walletName)
|
||||
}
|
||||
|
||||
// relockAccount locks an account; generally called as a defer after an account is unlocked.
|
||||
func relockAccount(locker e2wtypes.AccountLocker) {
|
||||
errCheck(locker.Lock(context.Background()), "failed to re-lock account")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user