Ejemplo n.º 1
0
KeyPair KeyManager::presaleSecret(std::string const& _json, function<string(bool)> const& _password)
{
	js::mValue val;
	json_spirit::read_string(_json, val);
	auto obj = val.get_obj();
	string p = _password(true);
	if (obj["encseed"].type() == js::str_type)
	{
		auto encseed = fromHex(obj["encseed"].get_str());
		KeyPair k;
		for (bool gotit = false; !gotit;)
		{
			gotit = true;
			k = KeyPair::fromEncryptedSeed(&encseed, p);
			if (obj["ethaddr"].type() == js::str_type)
			{
				Address a(obj["ethaddr"].get_str());
				Address b = k.address();
				if (a != b)
				{
					if ((p = _password(false)).empty())
						BOOST_THROW_EXCEPTION(PasswordUnknown());
					else
						gotit = false;
				}
			}
		}
		return k;
	}
	else
		BOOST_THROW_EXCEPTION(Exception() << errinfo_comment("encseed type is not js::str_type"));
}
Ejemplo n.º 2
0
void MixClient::resetState(std::map<Secret, u256> _accounts, Secret _miner)
{
	WriteGuard l(x_state);
	Guard fl(x_filtersWatches);
	m_filters.clear();
	m_watches.clear();

	m_stateDB = OverlayDB();
	SecureTrieDB<Address, MemoryDB> accountState(&m_stateDB);
	accountState.init();

	m_userAccounts.clear();
	std::map<Address, Account> genesisState;
	for (auto account: _accounts)
	{
		KeyPair a = KeyPair(account.first);
		m_userAccounts.push_back(a);
		genesisState.insert(std::make_pair(a.address(), Account(account.second, Account::NormalCreation)));
	}

	dev::eth::commit(genesisState, static_cast<MemoryDB&>(m_stateDB), accountState);
	h256 stateRoot = accountState.root();
	m_bc.reset();
	m_bc.reset(new MixBlockChain(m_dbPath, stateRoot));
	m_state = eth::State(m_stateDB, BaseState::PreExisting, KeyPair(_miner).address());
	m_state.sync(bc());
	m_startState = m_state;
	WriteGuard lx(x_executions);
	m_executions.clear();
}
std::string WebThreeStubServerBase::shh_newIdentity()
{
//	cnote << this << m_ids;
	KeyPair kp = KeyPair::create();
	m_ids[kp.pub()] = kp.secret();
	return toJS(kp.pub());
}
Ejemplo n.º 4
0
bool KeyPair::Encrypt(Ciphertext& out, Digest key) {
	KeyPair temp;
	temp.Keygen();
	memcpy(out, &temp.publicKey[1], sizeof(out));
	if (!ecdh_shared_secret(publicKey, temp.privateKey, key.Byte)) return false;
	blake2b(key, sizeof(key), 0, 0, key, sizeof(key));
	return true;
}
Ejemplo n.º 5
0
void NewAccount::create()
{
	QDialog d;
	Ui::NewAccount u;
	u.setupUi(&d);
	u.keysPath->setText(QString::fromStdString(getDataDir("web3/keys")));

	auto updateStatus = [&]()
	{
		bool useMaster = u.useMaster->isChecked();
		u.password->setEnabled(!useMaster);
		u.confirm->setEnabled(!useMaster);
		u.hint->setEnabled(!useMaster);
		u.status->setText("");
		bool ok = (useMaster || (!u.password->text().isEmpty() && u.password->text() == u.confirm->text()));
		if (!ok)
			u.status->setText("Passphrases must match");
		if (u.keyName->text().isEmpty())
		{
			ok = false;
			u.status->setText("Name must not be empty");
		}
		u.create->setEnabled(ok);
	};

	connect(u.useMaster, &QCheckBox::toggled, [&]() { updateStatus(); });
	connect(u.useOwn, &QCheckBox::toggled, [&]() { updateStatus(); });
	connect(u.password, &QLineEdit::textChanged, [&]() { updateStatus(); });
	connect(u.keyName, &QLineEdit::textChanged, [&]() { updateStatus(); });
	connect(u.confirm, &QLineEdit::textChanged, [&]() { updateStatus(); });

	updateStatus();
	if (d.exec() == QDialog::Accepted)
	{
		KeyManager::NewKeyType v = (KeyManager::NewKeyType)u.keyType->currentIndex();
		KeyPair p = KeyManager::newKeyPair(v);
		QString s = u.keyName->text();
		if (u.useMaster->isChecked())
			aleth()->keyManager().import(p.secret(), s.toStdString());
		else
		{
			std::string hint = u.hint->toPlainText().toStdString();
			std::string password = u.password->text().toStdString();
			aleth()->keyManager().import(p.secret(), s.toStdString(), password, hint);
		}

		aleth()->noteKeysChanged();
	}
}
Ejemplo n.º 6
0
	void endecryptTest()
	{
		const unsigned int bitLength = 128;
		KeyPair pair = RSA::makeKeyPair(bitLength);
		
		PublicKey pubKey = pair.getPublicKey();
		PrivateKey privKey = pair.getPrivateKey();

		RSA cipher(pubKey, privKey);
		MPInteger plaintext("12fbff45836b");
		MPInteger ciphertext = cipher.encrypt(plaintext);
		MPInteger decrypttext = cipher.decrypt(ciphertext);

		CPPUNIT_ASSERT(plaintext == decrypttext);
	}
Ejemplo n.º 7
0
/* time difference */
void TimeManager::time_diff_callback(const synchronization::time_diff::ConstPtr& time_diff_msg) {
    ros::Time sensors_time_diff;
    double lidar = (double)time_diff_msg->lidar.sec + (double)time_diff_msg->lidar.nsec/1000000000.0L;
    double camera = (double)time_diff_msg->camera.sec + (double)time_diff_msg->camera.nsec/1000000000.0L;

    if (time_diff_msg->lidar.sec > time_diff_msg->camera.sec) {
        sensors_time_diff.sec = time_diff_msg->lidar.sec - time_diff_msg->camera.sec;
        if (time_diff_msg->lidar.nsec >= time_diff_msg->camera.nsec) {
            sensors_time_diff.nsec = time_diff_msg->lidar.nsec - time_diff_msg->camera.nsec;
        } else {
            sensors_time_diff.sec -= 1;
            sensors_time_diff.nsec = 1000000000L + time_diff_msg->lidar.nsec - time_diff_msg->camera.nsec;
        }
    } else if  (time_diff_msg->lidar.sec < time_diff_msg->camera.sec) {
        sensors_time_diff.sec = time_diff_msg->camera.sec - time_diff_msg->lidar.sec;
        if (time_diff_msg->camera.nsec >= time_diff_msg->lidar.nsec) {
            sensors_time_diff.nsec = time_diff_msg->camera.nsec - time_diff_msg->lidar.nsec;
        } else {
            sensors_time_diff.sec -= 1;
            sensors_time_diff.nsec = 1000000000L + time_diff_msg->camera.nsec - time_diff_msg->lidar.nsec;
        }
    } else if (time_diff_msg->lidar.sec == time_diff_msg->camera.sec) {
        sensors_time_diff.sec = 0;
        if (time_diff_msg->lidar.nsec >= time_diff_msg->camera.nsec) {
            sensors_time_diff.nsec = time_diff_msg->lidar.nsec - time_diff_msg->camera.nsec;
        } else {
            sensors_time_diff.nsec = time_diff_msg->camera.nsec - time_diff_msg->lidar.nsec;
        }
    } else {
        // not impl
        ROS_ERROR("Exception error");
    }
    time_diff_.push_front(time_diff_msg->header.stamp, sensors_time_diff);
}
Ejemplo n.º 8
0
NodeTable::NodeTable(ba::io_service& _io, KeyPair _alias, uint16_t _udp):
	m_node(Node(_alias.pub(), bi::udp::endpoint())),
	m_secret(_alias.sec()),
	m_io(_io),
	m_socket(new NodeSocket(m_io, *this, _udp)),
	m_socketPointer(m_socket.get()),
	m_bucketRefreshTimer(m_io),
	m_evictionCheckTimer(m_io)
{
	for (unsigned i = 0; i < s_bins; i++)
	{
		m_state[i].distance = i;
		m_state[i].modified = chrono::steady_clock::now() - chrono::seconds(1);
	}
	
	m_socketPointer->connect();
	doRefreshBuckets(boost::system::error_code());
}
Ejemplo n.º 9
0
int stateTest()
{
	KeyPair me = sha3("Gav Wood");
	KeyPair myMiner = sha3("Gav's Miner");
//	KeyPair you = sha3("123");

	Defaults::setDBPath("/tmp");

	Overlay stateDB = State::openDB();
	BlockChain bc;
	State s(myMiner.address(), stateDB);

	cout << bc;

	// Sync up - this won't do much until we use the last state.
	s.sync(bc);

	cout << s;

	// Mine to get some ether!
	s.commitToMine(bc);
	while (s.mine(100).completed) {}
	bc.attemptImport(s.blockData(), stateDB);

	cout << bc;

	s.sync(bc);

	cout << s;

	// Inject a transaction to transfer funds from miner to me.
	bytes tx;
	{
		Transaction t;
		t.nonce = s.transactionsFrom(myMiner.address());
		t.value = 1000;			// 1e3 wei.
		t.receiveAddress = me.address();
		t.sign(myMiner.secret());
		assert(t.sender() == myMiner.address());
		tx = t.rlp();
	}
	s.execute(tx);

	cout << s;

	// Mine to get some ether and set in stone.
	s.commitToMine(bc);
	while (s.mine(100).completed) {}
	bc.attemptImport(s.blockData(), stateDB);

	cout << bc;

	s.sync(bc);

	cout << s;

	return 0;
}
Ejemplo n.º 10
0
int main()
{
	KeyPair u = KeyPair::create();
	KeyPair cb = KeyPair::create();
	OverlayDB db;
	State s(cb.address(), db, BaseState::Empty);
	cnote << s.rootHash();
	s.addBalance(u.address(), 1 * ether);
	Address c = s.newContract(1000 * ether, compileLLL("(suicide (caller))"));
	s.commit();
	State before = s;
	cnote << "State before transaction: " << before;
	Transaction t(0, 10000, 10000, c, bytes(), 0, u.secret());
	cnote << "Transaction: " << t;
	cnote << s.balance(c);
	s.execute(LastHashes(), t.rlp());
	cnote << "State after transaction: " << s;
	cnote << before.diff(s);
}
Ejemplo n.º 11
0
int main()
{
	string tempDir = boost::filesystem::temp_directory_path().string() + "/" + toString(chrono::system_clock::now().time_since_epoch().count());

	KeyPair myMiner = sha3("Gav's Miner");

	p2p::Host net("Test");
	cdebug << "Path:" << tempDir;
	Client c(&net, tempDir);

	c.setAddress(myMiner.address());

	this_thread::sleep_for(chrono::milliseconds(1000));

	c.startMining();

	this_thread::sleep_for(chrono::milliseconds(6000));

	c.stopMining();

	return 0;
}
Ejemplo n.º 12
0
NodeTable::NodeTable(ba::io_service& _io, KeyPair const& _alias, NodeIPEndpoint const& _endpoint, bool _enabled):
	m_node(Node(_alias.pub(), _endpoint)),
	m_secret(_alias.sec()),
	m_socket(new NodeSocket(_io, *this, (bi::udp::endpoint)m_node.endpoint)),
	m_socketPointer(m_socket.get()),
	m_timers(_io)
{
	for (unsigned i = 0; i < s_bins; i++)
		m_state[i].distance = i;
	
	if (!_enabled)
		return;
	
	try
	{
		m_socketPointer->connect();
		doDiscovery();
	}
	catch (std::exception const& _e)
	{
		clog(NetWarn) << "Exception connecting NodeTable socket: " << _e.what();
		clog(NetWarn) << "Discovery disabled.";
	}
}
Ejemplo n.º 13
0
int main()
{
	cnote << "Testing State...";

	KeyPair me = sha3("Gav Wood");
	KeyPair myMiner = sha3("Gav's Miner");
//	KeyPair you = sha3("123");

	Defaults::setDBPath(boost::filesystem::temp_directory_path().string() + "/" + toString(chrono::system_clock::now().time_since_epoch().count()));

	OverlayDB stateDB = State::openDB();
	CanonBlockChain bc;
	cout << bc;

	State s(stateDB, BaseState::CanonGenesis, myMiner.address());
	cout << s;

	// Sync up - this won't do much until we use the last state.
	s.sync(bc);

	cout << s;

	// Mine to get some ether!
	mine(s, bc);

	bc.attemptImport(s.blockData(), stateDB);

	cout << bc;

	s.sync(bc);

	cout << s;

	// Inject a transaction to transfer funds from miner to me.
	Transaction t(1000, 10000, 30000, me.address(), bytes(), s.transactionsFrom(myMiner.address()), myMiner.secret());
	assert(t.sender() == myMiner.address());
	s.execute(bc.lastHashes(), t);

	cout << s;

	// Mine to get some ether and set in stone.
	s.commitToMine(bc);
	s.commitToMine(bc);
	mine(s, bc);
	bc.attemptImport(s.blockData(), stateDB);

	cout << bc;

	s.sync(bc);

	cout << s;

	return 0;
}
Ejemplo n.º 14
0
	void keyCreateTest()
	{
		const unsigned int bitLength = 256;
		KeyPair pair = RSA::makeKeyPair(bitLength);
		
		CPPUNIT_ASSERT(
			pair.getPublicKey().getEncryptExponent().getBitLength() == 17);
		CPPUNIT_ASSERT(
			pair.getPublicKey().getModulus() ==
			pair.getPrivateKey().getModulus());
		
		PublicKey pubKey = pair.getPublicKey();
		PrivateKey privKey = pair.getPrivateKey();
	}
Ejemplo n.º 15
0
void TimeManager::sync_image_obj_tracked_callback(const cv_tracker_msgs::image_obj_ranged::ConstPtr& sync_image_obj_ranged_msg) {
//    ROS_INFO("sync_image_obj_tracked: \t%d.%d", sync_image_obj_ranged_msg->header.stamp.sec, sync_image_obj_ranged_msg->header.stamp.nsec);
    sync_image_obj_tracked_.push_front(sync_image_obj_ranged_msg->header.stamp, get_walltime_now());
}
Ejemplo n.º 16
0
string WebThreeStubServerBase::shh_newIdentity()
{
	KeyPair kp = KeyPair::create();
	m_shhIds[kp.pub()] = kp.secret();
	return toJS(kp.pub());
}
Ejemplo n.º 17
0
bool AccountManager::execute(int argc, char** argv)
{
	if (string(argv[1]) == "wallet")
	{
		if (3 < argc && string(argv[2]) == "import")
		{
			if (!openWallet())
				return false;
			string file = argv[3];
			string name = "presale wallet";
			string pw;
			KeyPair k;
			try
			{
				k = m_keyManager->presaleSecret(
					contentsString(file),
					[&](bool){ return (pw = getPassword("Enter the passphrase for the presale key: "));}
				);
			}
			catch (Exception const& _e)
			{
				if (auto err = boost::get_error_info<errinfo_comment>(_e))
					cout << "  Decryption failed: " << *err << endl;
				else
					cout << "  Decryption failed: Unknown reason." << endl;
				return false;
			}
			m_keyManager->import(k.secret(), name, pw, "Same passphrase as used for presale key");
			cout << "  Address: {" << k.address().hex() << "}" << endl;
		}
		else
			streamWalletHelp(cout);
		return true;
	}
	else if (string(argv[1]) == "account")
	{
		if (argc < 3 || string(argv[2]) == "list")
		{
			openWallet();
			if (m_keyManager->store().keys().empty())
				cout << "No keys found." << endl;
			else
			{
				vector<u128> bare;
				AddressHash got;
				int k = 0;
				for (auto const& u: m_keyManager->store().keys())
				{
					if (Address a = m_keyManager->address(u))
					{
						got.insert(a);
						cout << "Account #" << k << ": {" << a.hex() << "}" << endl;
						k++;
					}
					else
						bare.push_back(u);
				}
				for (auto const& a: m_keyManager->accounts())
					if (!got.count(a))
					{
						cout << "Account #" << k << ": {" << a.hex() << "}" << " (Brain)" << endl;
						k++;
					}
				for (auto const& u: bare)
				{
					cout << "Account #" << k << ": " << toUUID(u) << " (Bare)" << endl;
					k++;
				}
			}
		}
		else if (2 < argc && string(argv[2]) == "new")
		{
			openWallet();
			string name;
			string lock;
			string lockHint;
			lock = createPassword("Enter a passphrase with which to secure this account:");
			auto k = makeKey();
			h128 u = m_keyManager->import(k.secret(), name, lock, lockHint);
			cout << "Created key " << toUUID(u) << endl;
			cout << "  ICAP: " << ICAP(k.address()).encoded() << endl;
			cout << "  Address: {" << k.address().hex() << "}" << endl;
		}
		else if (3 < argc && string(argv[2]) == "import")
		{
			openWallet();
			h128 u = m_keyManager->store().importKey(argv[3]);
			if (!u)
			{
				cerr << "Error: reading key file failed" << endl;
				return false;
			}
			string pw;
			bytesSec s = m_keyManager->store().secret(u, [&](){ return (pw = getPassword("Enter the passphrase for the key: ")); });
			if (s.empty())
			{
				cerr << "Error: couldn't decode key or invalid secret size." << endl;
				return false;
			}
			else
			{
				string lockHint;
				string name;
				m_keyManager->importExisting(u, name, pw, lockHint);
				auto a = m_keyManager->address(u);
				cout << "Imported key " << toUUID(u) << endl;
				cout << "  ICAP: " << ICAP(a).encoded() << endl;
				cout << "  Address: {" << a.hex() << "}" << endl;
			}
		}
		else if (3 < argc && string(argv[2]) == "update")
		{
			openWallet();
			for (int k = 3; k < argc; k++)
			{
				string i = argv[k];
				h128 u = fromUUID(i);
				if (isHex(i) || u != h128())
				{
					string newP = createPassword("Enter the new passphrase for the account " + i);
					auto oldP = [&](){ return getPassword("Enter the current passphrase for the account " + i + ": "); };
					bool recoded = false;
					if (isHex(i))
					{
						recoded = m_keyManager->store().recode(
							Address(i),
							newP,
							oldP,
							dev::KDF::Scrypt
						);
					}
					else if (u != h128())
					{
						recoded = m_keyManager->store().recode(
							u,
							newP,
							oldP,
							dev::KDF::Scrypt
						);
					}
					if (recoded)
						cerr << "Re-encoded " << i << endl;
					else
						cerr << "Couldn't re-encode " << i << "; key does not exist, corrupt or incorrect passphrase supplied." << endl;
				}
				else
					cerr << "Couldn't re-encode " << i << "; does not represent an address or uuid." << endl;
			}
		}
		else
			streamAccountHelp(cout);
		return true;
	}
	else
		return false;
}
Ejemplo n.º 18
0
int main(int argc, char** argv)
{
	unsigned short listenPort = 30303;
	string remoteHost;
	unsigned short remotePort = 30303;
	string dbPath;
	bool mining = false;
	unsigned peers = 5;
#if ETH_JSONRPC
	int jsonrpc = 8080;
#endif
	string publicIP;
	bool upnp = true;
	string clientName;

	// Init defaults
	Defaults::get();

	// Our address.
	KeyPair us = KeyPair::create();
	Address coinbase = us.address();

	string configFile = getDataDir() + "/config.rlp";
	bytes b = contents(configFile);
	if (b.size())
	{
		RLP config(b);
		us = KeyPair(config[0].toHash<Secret>());
		coinbase = config[1].toHash<Address>();
	}
	else
	{
		RLPStream config(2);
		config << us.secret() << coinbase;
		writeFile(configFile, config.out());
	}

	for (int i = 1; i < argc; ++i)
	{
		string arg = argv[i];
		if ((arg == "-l" || arg == "--listen" || arg == "--listen-port") && i + 1 < argc)
			listenPort = (short)atoi(argv[++i]);
		else if ((arg == "-u" || arg == "--public-ip" || arg == "--public") && i + 1 < argc)
			publicIP = argv[++i];
		else if ((arg == "-r" || arg == "--remote") && i + 1 < argc)
			remoteHost = argv[++i];
		else if ((arg == "-p" || arg == "--port") && i + 1 < argc)
			remotePort = (short)atoi(argv[++i]);
		else if ((arg == "-n" || arg == "--upnp") && i + 1 < argc)
		{
			string m = argv[++i];
			if (isTrue(m))
				upnp = true;
			else if (isFalse(m))
				upnp = false;
			else
			{
				cerr << "Invalid UPnP option: " << m << endl;
				return -1;
			}
		}
		else if ((arg == "-c" || arg == "--client-name") && i + 1 < argc)
			clientName = argv[++i];
		else if ((arg == "-a" || arg == "--address" || arg == "--coinbase-address") && i + 1 < argc)
			coinbase = h160(fromHex(argv[++i]));
		else if ((arg == "-s" || arg == "--secret") && i + 1 < argc)
			us = KeyPair(h256(fromHex(argv[++i])));
		else if ((arg == "-d" || arg == "--path" || arg == "--db-path") && i + 1 < argc)
			dbPath = argv[++i];
		else if ((arg == "-m" || arg == "--mining") && i + 1 < argc)
		{
			string m = argv[++i];
			if (isTrue(m))
				mining = true;
			else if (isFalse(m))
				mining = false;
			else
			{
				cerr << "Unknown mining option: " << m << endl;
			}
		}
#if ETH_JSONRPC
		else if ((arg == "-j" || arg == "--json-rpc"))
			jsonrpc = jsonrpc ? jsonrpc : 8080;
		else if (arg == "--json-rpc-port" && i + 1 < argc)
			jsonrpc = atoi(argv[++i]);
#endif
		else if ((arg == "-v" || arg == "--verbosity") && i + 1 < argc)
			g_logVerbosity = atoi(argv[++i]);
		else if ((arg == "-x" || arg == "--peers") && i + 1 < argc)
			peers = atoi(argv[++i]);
		else if (arg == "-h" || arg == "--help")
			help();
		else if (arg == "-V" || arg == "--version")
			version();
		else
			remoteHost = argv[i];
	}

	if (!clientName.empty())
		clientName += "/";

	WebThreeDirect web3("NEthereum(++)/" + clientName + "v" + dev::Version + "/" DEV_QUOTED(ETH_BUILD_TYPE) "/" DEV_QUOTED(ETH_BUILD_PLATFORM), dbPath);
	Client& c = *web3.ethereum();

	c.setForceMining(true);

	cout << credits();

	std::ostringstream ccout;

	// Initialize ncurses
	char* str = new char[255];
	int width;
	int height;
	int y = 0;
	int x = 2;
	string cmd;
	WINDOW * mainwin, * consolewin, * logwin, * blockswin, * pendingwin, *addswin, * contractswin, * peerswin;

	if (!(mainwin = initscr()))
	{
		cerr << "Error initialising ncurses.";
		return -1;
	}

	getmaxyx(mainwin, height, width);
	int qheight = height * 3 / 5;
	int qwidth = width / 4 - 4;

	nonl();
	cbreak();
	timeout(30000);
	echo();
	keypad(mainwin, true);

	// Initialize color pairs
	start_color();
	init_pair(1, COLOR_WHITE, COLOR_BLACK);
	init_pair(2, COLOR_RED, COLOR_BLACK);
	init_pair(3, 7, COLOR_BLACK);
	use_default_colors();

	logwin = newwin(height * 2 / 5 - 2, width * 2 / 3, qheight, 0);
	nc::nc_window_streambuf outbuf(logwin, std::cout);

	consolewin   = newwin(qheight, width / 4, 0, 0);
	nc::nc_window_streambuf coutbuf(consolewin, ccout);
	blockswin    = newwin(qheight, width / 4, 0, width / 4);
	pendingwin   = newwin(height * 1 / 5, width / 4, 0, width * 2 / 4);
	peerswin     = newwin(height * 2 / 5, width / 4, height * 1 / 5, width * 2 / 4);
	addswin      = newwin(height * 2 / 5 - 2, width / 3, qheight, width * 2 / 3);
	contractswin = newwin(qheight, width / 4, 0, width * 3 / 4);

	int vl = qheight - 4;
	wsetscrreg(consolewin, 1, vl);
	wsetscrreg(blockswin, 1, vl);
	wsetscrreg(pendingwin, 1, vl);
	wsetscrreg(peerswin, 1, vl);
	wsetscrreg(addswin, 1, vl);
	wsetscrreg(contractswin, 1, vl);

	mvwprintw(mainwin, 1, 1, " > ");
	wresize(mainwin, 3, width);
	mvwin(mainwin, height - 3, 0);

	wmove(mainwin, 1, 4);

	if (!remoteHost.empty())
	{
		web3.setIdealPeerCount(peers);
		web3.setNetworkPreferences(NetworkPreferences(listenPort, publicIP, upnp));
		web3.startNetwork();
		web3.connect(remoteHost, remotePort);
	}
	if (mining)
		c.startMining();

#if ETH_JSONRPC
	auto_ptr<EthStubServer> jsonrpcServer;
	if (jsonrpc > -1)
	{
		jsonrpcServer = auto_ptr<EthStubServer>(new EthStubServer(new jsonrpc::HttpServer(jsonrpc), web3));
		jsonrpcServer->setKeys({us});
		jsonrpcServer->StartListening();
	}
#endif

	while (true)
	{
		wclrtobot(consolewin);
		wclrtobot(pendingwin);
		wclrtobot(peerswin);
		wclrtobot(addswin);
		wclrtobot(contractswin);

		ccout << credits();

		// Prompt
		wmove(mainwin, 1, 4);
		getstr(str);

		string s(str);
		istringstream iss(s);
		iss >> cmd;

		// Address
		ccout << "Address:" << endl;
		ccout << toHex(us.address().asArray()) << endl << endl;

		mvwprintw(mainwin, 1, 1, " > ");
		clrtoeol();

		if (s.length() > 1)
		{
			ccout << "> ";
			ccout << str << endl;
		}

		if (cmd == "netstart")
		{
			unsigned port;
			iss >> port;
			web3.setNetworkPreferences(NetworkPreferences((short)port, publicIP, upnp));
			web3.startNetwork();
		}
		else if (cmd == "connect")
Ejemplo n.º 19
0
void Main::on_create_clicked()
{
	KeyPair p = KeyPair::create();
	QString s = QString::fromStdString("The new secret key is:\n" + asHex(p.secret().asArray()) + "\n\nAddress:\n" + asHex(p.address().asArray()));
	QMessageBox::information(this, "Create Key", s, QMessageBox::Ok);
}
Ejemplo n.º 20
0
void TimeManager::points_raw_callback(const sensor_msgs::PointCloud2::ConstPtr& points_raw_msg) {
//    ROS_INFO("points_raw: \t\t\t%d.%d", points_raw_msg->header.stamp.sec, points_raw_msg->header.stamp.nsec);
    points_raw_.push_front(points_raw_msg->header.stamp, get_walltime_now());
}
Ejemplo n.º 21
0
void TimeManager::image_raw_callback(const sensor_msgs::Image::ConstPtr& image_raw_msg) {
//    ROS_INFO("image_raw: \t\t\t%d.%d", image_raw_msg->header.stamp.sec, image_raw_msg->header.stamp.nsec);
    image_raw_.push_front(image_raw_msg->header.stamp, get_walltime_now());
}
Ejemplo n.º 22
0
void TimeManager::vscan_image_callback(const points2image::PointsImage::ConstPtr& vscan_image_msg) {
//    ROS_INFO("vscan_image: \t\t\t%d.%d", vscan_image_msg->header.stamp.sec, vscan_image_msg->header.stamp.nsec);
    vscan_image_.push_front(vscan_image_msg->header.stamp, get_walltime_now());
}
Ejemplo n.º 23
0
void TimeManager::vscan_points_callback(const sensor_msgs::PointCloud2::ConstPtr& vscan_points_msg) {
//    ROS_INFO("vscan_points: \t\t\t%d.%d", vscan_points_msg->header.stamp.sec, vscan_points_msg->header.stamp.nsec);
    vscan_points_.push_front(vscan_points_msg->header.stamp, get_walltime_now());
}
Ejemplo n.º 24
0
void TimeManager::image_obj_tracked_callback(const cv_tracker_msgs::image_obj_tracked::ConstPtr& image_obj_tracked_msg) {
//    ROS_INFO("image_obj_tracked: \t\t%d.%d", image_obj_tracked_msg->header.stamp.sec, image_obj_tracked_msg->header.stamp.nsec);
    image_obj_tracked_.push_front(image_obj_tracked_msg->header.stamp, get_walltime_now());
}
Ejemplo n.º 25
0
void TimeManager::obj_pose_callback(const std_msgs::Time::ConstPtr& obj_pose_timestamp_msg) {
//    ROS_INFO("obj_pose: \t\t\t%d.%d", obj_pose_timestamp_msg->data.sec, obj_pose_timestamp_msg->data.nsec);
    obj_pose_.push_front(obj_pose_timestamp_msg->data, get_walltime_now());
    static ros::Time pre_sensor_time;

    synchronization::time_monitor time_monitor_msg;
    time_monitor_msg.header.frame_id = "0";
    time_monitor_msg.header.stamp = ros::Time::now();

    // ROS_INFO("-------------------------------------");
    // ROS_INFO("image_raw");
    if (!ros::Time::isSimTime()) {
        time_monitor_msg.image_raw = time_diff(obj_pose_timestamp_msg->data,
                                               image_raw_.find(obj_pose_timestamp_msg->data));
    } else {
        time_monitor_msg.image_raw = 0;
    }

    // ROS_INFO("points_raw");
    if (!ros::Time::isSimTime()) {
        time_monitor_msg.points_raw = time_diff(obj_pose_timestamp_msg->data,
                                                points_raw_.find(obj_pose_timestamp_msg->data));
    } else {
        time_monitor_msg.points_raw = 0;
    }

    if (is_points_image_) {
        // ROS_INFO("points_image");
        time_monitor_msg.points_image = time_diff(points_raw_.find(obj_pose_timestamp_msg->data),
                                                  points_image_.find(obj_pose_timestamp_msg->data));
    }
    if (is_vscan_image_) {
        // ROS_INFO("vscan_points");
        time_monitor_msg.vscan_points = time_diff(points_raw_.find(obj_pose_timestamp_msg->data),
                                                  vscan_points_.find(obj_pose_timestamp_msg->data));
        // ROS_INFO("vscan_image");
        time_monitor_msg.vscan_image = time_diff(vscan_points_.find(obj_pose_timestamp_msg->data),
        vscan_image_.find(obj_pose_timestamp_msg->data));
    }

    // ROS_INFO("image_obj");
    time_monitor_msg.image_obj = time_diff(image_raw_.find(obj_pose_timestamp_msg->data),
                                           image_obj_.find(obj_pose_timestamp_msg->data));
    // ROS_INFO("image_obj_ranged");
    time_monitor_msg.image_obj_ranged = time_diff(sync_image_obj_ranged_.find(obj_pose_timestamp_msg->data),
                                                  image_obj_ranged_.find(obj_pose_timestamp_msg->data));
    // ROS_INFO("image_obj_tracked");
    time_monitor_msg.image_obj_tracked = time_diff(sync_image_obj_tracked_.find(obj_pose_timestamp_msg->data),
                                                   image_obj_tracked_.find(obj_pose_timestamp_msg->data));
    // ROS_INFO("current_pose");
    time_monitor_msg.current_pose = time_diff(points_raw_.find(obj_pose_timestamp_msg->data),
                                              current_pose_.find(obj_pose_timestamp_msg->data));
    // ROS_INFO("obj_label");
    time_monitor_msg.obj_label = time_diff(sync_obj_label_.find(obj_pose_timestamp_msg->data),
                                           obj_label_.find(obj_pose_timestamp_msg->data));
    // ROS_INFO("cluster_centroids");
    time_monitor_msg.cluster_centroids = time_diff(points_raw_.find(obj_pose_timestamp_msg->data),
                                                   cluster_centroids_.find(obj_pose_timestamp_msg->data));
    // ROS_INFO("obj_pose");
    time_monitor_msg.obj_pose = time_diff(sync_obj_pose_.find(obj_pose_timestamp_msg->data),
                                          obj_pose_.find(obj_pose_timestamp_msg->data));
    // ROS_INFO("-------------------------------------");

    if (!ros::Time::isSimTime()) {
        time_monitor_msg.execution_time = time_diff(obj_pose_timestamp_msg->data, obj_pose_.find(obj_pose_timestamp_msg->data));
    } else {
        time_monitor_msg.execution_time = time_diff(points_raw_.find(obj_pose_timestamp_msg->data), obj_pose_.find(obj_pose_timestamp_msg->data));
    }

    time_monitor_msg.cycle_time = time_diff(pre_sensor_time, obj_pose_timestamp_msg->data); // cycle time
    time_monitor_msg.time_diff = ros_time2msec(time_diff_.find(obj_pose_timestamp_msg->data)); // time difference
    time_monitor_pub.publish(time_monitor_msg);

    pre_sensor_time = obj_pose_timestamp_msg->data;
}
Ejemplo n.º 26
0
void TimeManager::current_pose_callback(const geometry_msgs::PoseStamped::ConstPtr& current_pose_msg) {
//    ROS_INFO("current_pose: \t\t\t%d.%d", current_pose_msg->header.stamp.sec, current_pose_msg->header.stamp.nsec);
    current_pose_.push_front(current_pose_msg->header.stamp, get_walltime_now());
}
Ejemplo n.º 27
0
void TimeManager::obj_label_callback(const cv_tracker_msgs::obj_label::ConstPtr& obj_label_msg) {
//    ROS_INFO("obj_label: \t\t\t%d.%d", obj_label_msg->header.stamp.sec, obj_label_msg->header.stamp.nsec);
    obj_label_.push_front(obj_label_msg->header.stamp, get_walltime_now());
}
Ejemplo n.º 28
0
void TimeManager::cluster_centroids_callback(const lidar_tracker::centroids::ConstPtr& cluster_centroids_msg) {
//    ROS_INFO("cluster_centroids: \t\t%d.%d", cluster_centroids_msg->header.stamp.sec, cluster_centroids_msg->header.stamp.nsec);
    cluster_centroids_.push_front(cluster_centroids_msg->header.stamp, get_walltime_now());
}
Ejemplo n.º 29
0
void importPresale(KeyManager& _km, string const& _file, function<string()> _pass)
{
	KeyPair k = _km.presaleSecret(contentsString(_file), [&](bool){ return _pass(); });
	_km.import(k.secret(), "Presale wallet" + _file + " (insecure)");
}
Ejemplo n.º 30
0
void TimeManager::sync_obj_pose_callback(const cv_tracker_msgs::obj_label::ConstPtr& sync_obj_label_msg) {
//    ROS_INFO("sync_obj_pose: \t\t\t%d.%d", sync_obj_label_msg->header.stamp.sec, sync_obj_label_msg->header.stamp.nsec);
    sync_obj_pose_.push_front(sync_obj_label_msg->header.stamp, get_walltime_now());
}