Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
75a86088
Unverified
Commit
75a86088
authored
May 03, 2019
by
Guillaume Ballet
Committed by
Péter Szilágyi
May 27, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
accounts/scwallet: display PUK retry count, validate PIN/PUK length
parent
fc85777a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
1 deletion
+12
-1
wallet.go
accounts/scwallet/wallet.go
+12
-1
No files found.
accounts/scwallet/wallet.go
View file @
75a86088
...
@@ -27,6 +27,7 @@ import (
...
@@ -27,6 +27,7 @@ import (
"errors"
"errors"
"fmt"
"fmt"
"math/big"
"math/big"
"regexp"
"sort"
"sort"
"strings"
"strings"
"sync"
"sync"
...
@@ -310,8 +311,10 @@ func (w *Wallet) Status() (string, error) {
...
@@ -310,8 +311,10 @@ func (w *Wallet) Status() (string, error) {
return
fmt
.
Sprintf
(
"Failed: %v"
,
err
),
err
return
fmt
.
Sprintf
(
"Failed: %v"
,
err
),
err
}
}
switch
{
switch
{
case
!
w
.
session
.
verified
&&
status
.
PinRetryCount
==
0
&&
status
.
PukRetryCount
==
0
:
return
fmt
.
Sprintf
(
"Bricked, waiting for full wipe"
),
nil
case
!
w
.
session
.
verified
&&
status
.
PinRetryCount
==
0
:
case
!
w
.
session
.
verified
&&
status
.
PinRetryCount
==
0
:
return
fmt
.
Sprintf
(
"Blocked, waiting for PUK
and new PIN"
),
nil
return
fmt
.
Sprintf
(
"Blocked, waiting for PUK
(%d attempts left) and new PIN"
,
status
.
PukRetryCount
),
nil
case
!
w
.
session
.
verified
:
case
!
w
.
session
.
verified
:
return
fmt
.
Sprintf
(
"Locked, waiting for PIN (%d attempts left)"
,
status
.
PinRetryCount
),
nil
return
fmt
.
Sprintf
(
"Locked, waiting for PIN (%d attempts left)"
,
status
.
PinRetryCount
),
nil
case
!
status
.
Initialized
:
case
!
status
.
Initialized
:
...
@@ -377,10 +380,18 @@ func (w *Wallet) Open(passphrase string) error {
...
@@ -377,10 +380,18 @@ func (w *Wallet) Open(passphrase string) error {
case
passphrase
==
""
:
case
passphrase
==
""
:
return
ErrPINUnblockNeeded
return
ErrPINUnblockNeeded
case
status
.
PinRetryCount
>
0
:
case
status
.
PinRetryCount
>
0
:
if
!
regexp
.
MustCompile
(
`^[0-9]{6,}$`
)
.
MatchString
(
passphrase
)
{
w
.
log
.
Error
(
"PIN needs to be at least 6 digits"
)
return
ErrPINNeeded
}
if
err
:=
w
.
session
.
verifyPin
([]
byte
(
passphrase
));
err
!=
nil
{
if
err
:=
w
.
session
.
verifyPin
([]
byte
(
passphrase
));
err
!=
nil
{
return
err
return
err
}
}
default
:
default
:
if
!
regexp
.
MustCompile
(
`^[0-9]{12,}$`
)
.
MatchString
(
passphrase
)
{
w
.
log
.
Error
(
"PUK needs to be at least 12 digits"
)
return
ErrPINUnblockNeeded
}
if
err
:=
w
.
session
.
unblockPin
([]
byte
(
passphrase
));
err
!=
nil
{
if
err
:=
w
.
session
.
unblockPin
([]
byte
(
passphrase
));
err
!=
nil
{
return
err
return
err
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment