cli_wallet: Copy ws_server, ws_user, ws_password to new wallet

This commit is contained in:
theoreticalbts 2015-08-24 15:08:09 -04:00
parent c0b9af9a99
commit aeebb1be09
3 changed files with 10 additions and 7 deletions

View file

@ -214,7 +214,7 @@ class wallet_api_impl;
class wallet_api class wallet_api
{ {
public: public:
wallet_api( const chain_id_type& chain_id, fc::api<login_api> rapi ); wallet_api( const wallet_data& initial_data, fc::api<login_api> rapi );
virtual ~wallet_api(); virtual ~wallet_api();
bool copy_wallet_file( string destination_filename ); bool copy_wallet_file( string destination_filename );

View file

@ -359,9 +359,9 @@ private:
public: public:
wallet_api& self; wallet_api& self;
wallet_api_impl( wallet_api& s, const chain_id_type& chain_id, fc::api<login_api> rapi ) wallet_api_impl( wallet_api& s, const wallet_data& initial_data, fc::api<login_api> rapi )
: self(s), : self(s),
_chain_id(chain_id), _chain_id(initial_data.chain_id),
_remote_api(rapi), _remote_api(rapi),
_remote_db(rapi->database()), _remote_db(rapi->database()),
_remote_net_broadcast(rapi->network_broadcast()), _remote_net_broadcast(rapi->network_broadcast()),
@ -372,7 +372,7 @@ public:
{ {
FC_THROW( "Remote server gave us an unexpected chain_id", FC_THROW( "Remote server gave us an unexpected chain_id",
("remote_chain_id", remote_chain_id) ("remote_chain_id", remote_chain_id)
("chain_id", chain_id) ); ("chain_id", _chain_id) );
} }
init_prototype_ops(); init_prototype_ops();
_remote_db->subscribe_to_objects( [=]( const fc::variant& obj ) _remote_db->subscribe_to_objects( [=]( const fc::variant& obj )
@ -380,6 +380,9 @@ public:
fc::async([this]{resync();}, "Resync after block"); fc::async([this]{resync();}, "Resync after block");
}, {dynamic_global_property_id_type()} ); }, {dynamic_global_property_id_type()} );
_wallet.chain_id = _chain_id; _wallet.chain_id = _chain_id;
_wallet.ws_server = initial_data.ws_server;
_wallet.ws_user = initial_data.ws_user;
_wallet.ws_password = initial_data.ws_password;
} }
virtual ~wallet_api_impl() virtual ~wallet_api_impl()
{ {
@ -2026,8 +2029,8 @@ void operation_printer::operator()(const asset_create_operation& op) const
namespace graphene { namespace wallet { namespace graphene { namespace wallet {
wallet_api::wallet_api(const chain_id_type& chain_id, fc::api<login_api> rapi) wallet_api::wallet_api(const wallet_data& initial_data, fc::api<login_api> rapi)
: my(new detail::wallet_api_impl(*this, chain_id, rapi)) : my(new detail::wallet_api_impl(*this, initial_data, rapi))
{ {
} }

View file

@ -169,7 +169,7 @@ int main( int argc, char** argv )
// TODO: Error message here // TODO: Error message here
FC_ASSERT( remote_api->login( wdata.ws_user, wdata.ws_password ) ); FC_ASSERT( remote_api->login( wdata.ws_user, wdata.ws_password ) );
auto wapiptr = std::make_shared<wallet_api>( wdata.chain_id, remote_api ); auto wapiptr = std::make_shared<wallet_api>( wdata, remote_api );
wapiptr->set_wallet_filename( wallet_file.generic_string() ); wapiptr->set_wallet_filename( wallet_file.generic_string() );
wapiptr->load_wallet_file(); wapiptr->load_wallet_file();