Esempio n. 1
0
void find_transaction_history (){
	uint256 hash;
	char hash_ch[32];
	for (int i = 0; i < 32; ++i)	hash_ch[i] = i;
	hash_ch[0] = 1; hash_ch[1] = 2;
	hash.init (hash_ch);

//	vector <Transaction::pointer> vet;
	Account::pointer acc = Bubi::last_ledger->get_account_entry (hash);

	uint256 tx_hash;
	std::uint32_t	tx_seq;

	tx_seq = acc->get_previous_ledger_seq ();
	tx_hash = acc->get_previous_tx_hash ();


	while ( tx_seq != 0 ){
		Transaction::pointer tx = Bubi::last_ledger->get_transaction_entry (tx_hash);
		std::cout << "------------------------------------" << std::endl;
		std::cout << tx->get_source_address ().to_string () << std::endl;
		std::cout << tx->get_destination_address ().to_string () << std::endl;
		std::cout << tx->get_payment_amount () << std::endl;

		if (hash == tx->get_source_address ()){
			tx_seq = tx->get_source_previous_ledger_seq ();
			tx_hash = tx->get_source_previous_tx_hash ();
		}
		else {
			tx_seq = tx->get_destination_previous_ledger_seq ();
			tx_hash = tx->get_destination_previous_tx_hash ();
		}
	}

}
Esempio n. 2
0
std::vector <Transaction::pointer>	get_transaction_history (std::string acc_pub){
	uint256 hash = string_address_to_uint256 (acc_pub);
	Account::pointer acc = Bubi::last_ledger->get_account_entry (hash);
	std::vector <Transaction::pointer> res;

	uint256 tx_hash;
	std::uint32_t	tx_seq;

	tx_seq = acc->get_previous_ledger_seq ();
	tx_hash = acc->get_previous_tx_hash ();


	while ( tx_seq != 0 ){
		Transaction::pointer tx = Bubi::last_ledger->get_transaction_entry (tx_hash);
		res.push_back (tx);
/*
		std::cout << "------------------------------------" << std::endl;
		std::cout << tx->get_source_address ().to_string () << std::endl;
		std::cout << tx->get_destination_address ().to_string () << std::endl;
		std::cout << tx->get_payment_amount () << std::endl;
*/
		if (hash == tx->get_source_address ()){
			tx_seq = tx->get_source_previous_ledger_seq ();
			tx_hash = tx->get_source_previous_tx_hash ();
		}
		else {
			tx_seq = tx->get_destination_previous_ledger_seq ();
			tx_hash = tx->get_destination_previous_tx_hash ();
		}
	}
	return res;
}