Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
parity
Mirrored projects
parity-signer
Commits
a93ef8a8
Unverified
Commit
a93ef8a8
authored
Jul 25, 2019
by
Thibaut Sardan
Committed by
GitHub
Jul 25, 2019
Browse files
Merge pull request #282 from paritytech/tbaut-no-empty-seed
Don't allow empty seed phrase recovery
parents
882349dd
97053acf
Pipeline
#44677
failed with stage
in 14 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/screens/AccountRecover.js
View file @
a93ef8a8
...
...
@@ -108,29 +108,41 @@ class AccountRecoverView extends React.Component {
onPress
=
{()
=>
{
const
validation
=
validateSeed
(
selected
.
seed
,
selected
.
validBip39Seed
);
if
(
!
validation
.
valid
)
{
Alert
.
alert
(
'
Warning:
'
,
`
${
validation
.
reason
}
`
,
[
{
text
:
'
I understand the risks
'
,
style
:
'
default
'
,
onPress
:
()
=>
{
this
.
props
.
navigation
.
navigate
(
'
AccountPin
'
,
{
isWelcome
:
this
.
props
.
navigation
.
getParam
(
'
isWelcome
'
),
isNew
:
true
});
if
(
validation
.
accountRecoveryAllowed
){
return
Alert
.
alert
(
'
Warning:
'
,
`
${
validation
.
reason
}
`
,
[
{
text
:
'
I understand the risks
'
,
style
:
'
default
'
,
onPress
:
()
=>
{
this
.
props
.
navigation
.
navigate
(
'
AccountPin
'
,
{
isWelcome
:
this
.
props
.
navigation
.
getParam
(
'
isWelcome
'
),
isNew
:
true
});
}
},
{
text
:
'
Back
'
,
style
:
'
cancel
'
}
},
{
text
:
'
Back
'
,
style
:
'
cancel
'
}
]
);
return
;
]
);
}
else
{
return
Alert
.
alert
(
'
Error:
'
,
`
${
validation
.
reason
}
`
,
[
{
text
:
'
Back
'
,
style
:
'
cancel
'
}
]
);
}
}
this
.
props
.
navigation
.
navigate
(
'
AccountPin
'
,
{
isWelcome
:
this
.
props
.
navigation
.
getParam
(
'
isWelcome
'
),
...
...
src/stores/AccountsStore.js
View file @
a93ef8a8
...
...
@@ -85,11 +85,15 @@ export default class AccountsStore extends Container<AccountsState> {
async
submitNew
(
pin
)
{
const
account
=
this
.
state
.
newAccount
;
await
this
.
save
(
account
,
pin
);
this
.
setState
({
accounts
:
this
.
state
.
accounts
.
set
(
accountId
(
account
),
account
),
newAccount
:
empty
()
});
// only save the account if the seed isn't empty
if
(
account
.
seed
)
{
await
this
.
save
(
account
,
pin
);
this
.
setState
({
accounts
:
this
.
state
.
accounts
.
set
(
accountId
(
account
),
account
),
newAccount
:
empty
()
});
}
}
update
(
accountUpdate
)
{
...
...
src/util/account.js
View file @
a93ef8a8
...
...
@@ -31,8 +31,9 @@ export function empty(account = {}) {
export
function
validateSeed
(
seed
,
validBip39Seed
)
{
if
(
seed
.
length
===
0
)
{
return
{
valid
:
false
,
reason
:
`You're trying to recover from an empty seed phrase`
accountRecoveryAllowed
:
false
,
reason
:
`A seed phrase is required.`
,
valid
:
false
};
}
const
words
=
seed
.
split
(
'
'
);
...
...
@@ -40,21 +41,24 @@ export function validateSeed(seed, validBip39Seed) {
for
(
let
word
of
words
)
{
if
(
word
===
''
)
{
return
{
valid
:
false
,
reason
:
`Extra whitespace found`
accountRecoveryAllowed
:
true
,
reason
:
`Extra whitespace found.`
,
valid
:
false
};
}
}
if
(
!
validBip39Seed
)
{
return
{
valid
:
false
,
reason
:
`This recovery phrase will be treated as a legacy Parity brain wallet`
accountRecoveryAllowed
:
true
,
reason
:
`This recovery phrase will be treated as a legacy Parity brain wallet.`
,
valid
:
false
};
}
return
{
valid
:
true
,
reason
:
null
reason
:
null
,
valid
:
true
};
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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