Skip to content
This repository has been archived by the owner on Feb 21, 2019. It is now read-only.

Commit

Permalink
Validate wallet name in create_from_json (#373)
Browse files Browse the repository at this point in the history
  • Loading branch information
vikramrajkumar committed Jun 23, 2014
1 parent 0f340cb commit fecd6ee
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions libraries/wallet/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -583,8 +583,9 @@ namespace bts { namespace wallet {
const string& password,
const string& brainkey )
{ try {
if( !is_valid_account_name(wallet_name))
if( !is_valid_account_name( wallet_name ) )
FC_THROW_EXCEPTION( invalid_name, "Invalid name for a wallet!", ("wallet_name",wallet_name) );

auto wallet_file_path = fc::absolute( get_data_directory() ) / wallet_name;
if( fc::exists( wallet_file_path ) )
FC_THROW_EXCEPTION( wallet_already_exists, "Wallet name already exists!", ("wallet_name",wallet_name) );
Expand Down Expand Up @@ -660,8 +661,11 @@ namespace bts { namespace wallet {

void wallet::open( const string& wallet_name )
{ try {
if( !is_valid_account_name( wallet_name ) )
FC_THROW_EXCEPTION( invalid_name, "Invalid name for a wallet!", ("wallet_name",wallet_name) );

auto wallet_file_path = fc::absolute( get_data_directory() ) / wallet_name;
if ( !is_valid_account_name(wallet_name) || !fc::exists( wallet_file_path ) )
if ( !fc::exists( wallet_file_path ) )
FC_THROW_EXCEPTION( no_such_wallet, "No such wallet exists!", ("wallet_name", wallet_name) );

try
Expand Down Expand Up @@ -741,6 +745,10 @@ namespace bts { namespace wallet {
void wallet::create_from_json( const path& filename, const string& wallet_name, const string& passphrase )
{ try {
FC_ASSERT( fc::exists( filename ) );

if( !is_valid_account_name( wallet_name ) )
FC_THROW_EXCEPTION( invalid_name, "Invalid name for a wallet!", ("wallet_name",wallet_name) );

try
{
create( wallet_name, passphrase );
Expand Down

0 comments on commit fecd6ee

Please sign in to comment.