fc::string register_key_on_server(const QString& keyhotee_id, const QString& key)
{
  fc::string trimmed_keyhotee_id = keyhotee_id.trimmed().toStdString();
  fc::string trimmed_key = key.trimmed().toStdString();
  auto pro = bts::application::instance()->get_profile();
  auto keys = pro->get_keychain();
  auto ident_key       = keys.get_identity_key( trimmed_keyhotee_id );
  std::string key_addr = public_key_address( ident_key.get_public_key() );

  fc::tcp_socket_ptr sock = std::make_shared<fc::tcp_socket>();
  sock->connect_to( fc::ip::endpoint( fc::ip::address("162.243.67.4"), 3879 ) );
  fc::buffered_istream_ptr isock = std::make_shared<fc::buffered_istream>(sock);
  fc::buffered_ostream_ptr osock = std::make_shared<fc::buffered_ostream>(sock);
  fc::rpc::json_connection_ptr con = std::make_shared<fc::rpc::json_connection>( isock, osock );
  con->exec();

  auto result = con->async_call( "register_key", trimmed_keyhotee_id, trimmed_key, key_addr ).wait();
  auto points = result.get_object()["points"].as_string();
  auto pub    = result.get_object()["pub_key"].as_string();
  return points;
}
Exemplo n.º 2
0
void NewIdentityDialog::onSave()
{
    //store new identity in profile
    auto app = bts::application::instance();
    auto profile = app->get_profile();
    auto trim_dac_id = fc::trim(ui->username->text().toUtf8().constData());
    bts::addressbook::wallet_identity ident;
    ident.first_name = fc::trim( ui->firstname->text().toUtf8().constData() );
    ident.last_name = fc::trim( ui->lastname->text().toUtf8().constData() );
    ident.mining_effort = ui->register_checkbox->isChecked();
    ident.wallet_ident = trim_dac_id;
    ident.set_dac_id( trim_dac_id );
    auto priv_key = profile->get_keychain().get_identity_key(trim_dac_id);
    ident.public_key = priv_key.get_public_key();
    profile->store_identity( ident );
    try 
    {
      app->mine_name(trim_dac_id,
                profile->get_keychain().get_identity_key(trim_dac_id).get_public_key(),
                ident.mining_effort);
    }
    catch ( const fc::exception& e )
    {
      wlog( "${e}", ("e",e.to_detail_string()) );
    }

    //store contact for new identity
    bts::addressbook::wallet_contact myself;
    //copy common fields from new identity into contact
    static_cast<bts::addressbook::contact&>(myself) = ident;
    //fill in remaining fields for contact
    myself.first_name = ident.first_name;
    myself.last_name = ident.last_name;
//    profile->get_addressbook()->store_contact(Contact(myself));
    TKeyhoteeApplication::getInstance()->getMainWindow()->getAddressBookModel()->storeContact( Contact(myself) );

    app->add_receive_key(priv_key);
}
Exemplo n.º 3
0
void NewIdentityDialog::onKey( const QString& key )
{
   try {
      auto pro = bts::application::instance()->get_profile();
      auto keys = pro->get_keychain();
      auto trim_name       = fc::trim(ui->username->text().toStdString());
      auto ident_key       = keys.get_identity_key( trim_name );
      std::string key_addr = public_key_address( ident_key.get_public_key() );

      fc::tcp_socket_ptr sock = std::make_shared<fc::tcp_socket>();
      sock->connect_to( fc::ip::endpoint( fc::ip::address("162.243.67.4"), 3879 ) );
      fc::buffered_istream_ptr isock = std::make_shared<fc::buffered_istream>(sock);
      fc::buffered_ostream_ptr osock = std::make_shared<fc::buffered_ostream>(sock);
      fc::rpc::json_connection_ptr con = std::make_shared<fc::rpc::json_connection>( isock, osock );
      con->exec();

      auto trim_key = key.trimmed();

      auto result = con->async_call( "register_key", trim_name, trim_key.toStdString(), key_addr ).wait();
      auto points = result.get_object()["points"].as_string();
      auto pub    = result.get_object()["pub_key"].as_string();
      fc::usleep(fc::seconds(1));

      ui->status_label->setText( ("Status: Registered with " + points + " points").c_str() );
   } 
   catch ( fc::eof_exception&  )
   {
   }
   catch ( fc::exception& e )
   {
      ui->status_label->setText( ("Status: Error Registering Founder ID: " + e.to_detail_string()).c_str() );
   }
   catch ( ... )
   {
      ui->status_label->setText( "Status: Error Registering Founder ID" );
   }
}
Exemplo n.º 4
0
 unsigned int fingerprint() const { return get_public_key().fingerprint(); }
Exemplo n.º 5
0
char* hlms_get_public_key(hlms_priv_key_t* hlms_private_key)
{
    /*Be careful not free this key individually, its part of hlms_private_key */
    return get_public_key(hlms_private_key->lms_priv_key_1);
}
void NewIdentityDialog::onSave()
{
  //store new identity in profile
  auto app = bts::application::instance();
  auto profile = app->get_profile();
  auto trimmed_dac_id = ui->username->text().trimmed();
  fc::string dac_id = trimmed_dac_id.toStdString();

  // make sure the key is unique..
  try {
      bts::addressbook::wallet_identity cur_ident = profile->get_identity( dac_id );
      ui->buttonBox->button( QDialogButtonBox::Save )->setEnabled(false);
      ui->status_label->setStyleSheet("QLabel { color : red; }");
      ui->publickey->setText( "" );
      if (cur_ident.dac_id_string == dac_id)
          ui->status_label->setText( tr( "Status: You have already created this identity." ) );
      else
          ui->status_label->setText( tr( "Status: You have already created a similar id." ) );
      return;
  }
  catch ( fc::key_not_found_exception& )
  {
      fc::optional<bts::bitname::name_record> current_record = bts::application::instance()->lookup_name(dac_id);
      if(current_record)
      {
          ui->status_label->setStyleSheet("QLabel { color : red; }");
          ui->status_label->setText(tr("Status: This Keyhotee ID was already registered by someone else."));
          ui->publickey->setText( "" );
          ui->buttonBox->button( QDialogButtonBox::Save )->setEnabled(false);
          return;
      }
  }


  bts::addressbook::wallet_identity ident;
  ident.first_name = fc::trim( ui->firstname->text().toUtf8().constData() );
  ident.last_name = fc::trim( ui->lastname->text().toUtf8().constData() );
  ident.mining_effort = ui->register_checkbox->isChecked() ? 25.0 : 0.0;
  ident.wallet_ident = dac_id;
  ident.set_dac_id( dac_id );
  auto priv_key = profile->get_keychain().get_identity_key(dac_id);
  ident.public_key = priv_key.get_public_key();
  profile->store_identity( ident );
  /// notify identity observers
  IdentityObservable::getInstance().notify();
  try 
  {
    app->mine_name(dac_id,
              profile->get_keychain().get_identity_key(dac_id).get_public_key(),
              ident.mining_effort);
  }
  catch ( const fc::exception& e )
  {
    wlog( "${e}", ("e",e.to_detail_string()) );
  }

  //store contact for new identity
  bts::addressbook::wallet_contact myself;
  //copy common fields from new identity into contact
  static_cast<bts::addressbook::contact&>(myself) = ident;
  //fill in remaining fields for contact
  myself.first_name = ident.first_name;
  myself.last_name = ident.last_name;
#ifdef ALPHA_RELEASE
  //just store the founder code here so we can access it over in ContactView temporarily for alpha release
  myself.notes = ui->founder_code->text().toStdString();
#endif
  TKeyhoteeApplication::getInstance()->getMainWindow()->getAddressBookModel()->storeContact( Contact(myself) );

  app->add_receive_key(priv_key);

	//re-connect to mail server to send an updated sync_time (get past mail for identities) if history should be downloaded
	int days_in_past_to_fetch = ui->downloadHistory->currentData().toInt();
  if (days_in_past_to_fetch != 0)
  {
    fc::time_point sync_time;
    if (days_in_past_to_fetch != -1)
      sync_time = fc::time_point::now() - fc::days(days_in_past_to_fetch);
    //if requested sync time further in the past than last sync time, change last_sync_time
    if (sync_time < profile->get_last_sync_time())
      profile->set_last_sync_time(sync_time);
    app->connect_to_network();
  }
  emit identityadded();

}
void RegisterNameForm::createCommand( gpm::command& cmd )const
{
    std::string name = m_ui->name->currentText().toStdString();
    cmd = gpm::cmd::register_name( name, get_public_key( m_ui->key_name->currentText().toStdString() ) );
}