tx_details class removed as it is not used

master
moneroexamples 8 years ago
parent 8a731907f5
commit 08e22f4870

@ -6,13 +6,12 @@ set(SOURCE_HEADERS
MicroCore.h
tools.h
monero_headers.h
tx_details.h)
)
set(SOURCE_FILES
MicroCore.cpp
tools.cpp
CmdLineOptions.cpp
tx_details.cpp
page.h
rpccalls.cpp rpccalls.h version.h.in)

@ -8,8 +8,7 @@
#include <iostream>
#include "monero_headers.h"
#include "tx_details.h"
#include "tools.h"
namespace xmreg
{

@ -2210,6 +2210,23 @@ public:
if (it != tx_key_imgs.end())
{
uint64_t xmr_amount = (*it).amount;
// RingCT, i.e., tx version is 2
// thus need to decode the amounts
// otherwise they all appear to be zero.
// so to find the amount, first we need to find
// our output in the key images's mixins, and then
if (tx.version == 2)
{
// bool r = decode_ringct(tx.rct_signatures,
// txd.pk,
// prv_view_key,
// i,
// tx.rct_signatures.ecdhInfo[i].mask,
// rct_amount);
}
key_img_info["amount"] = xmreg::xmr_amount_to_str(xmr_amount);
total_xmr += xmr_amount;
}

@ -897,6 +897,56 @@ namespace xmreg
return tp;
}
/**
* Check if given output (specified by output_index)
* belongs is ours based
* on our private view key and public spend key
*/
bool
is_output_ours(const size_t& output_index,
const transaction& tx,
const public_key& pub_tx_key,
const secret_key& private_view_key,
const public_key& public_spend_key)
{
// public transaction key is combined with our viewkey
// to create, so called, derived key.
key_derivation derivation;
if (!generate_key_derivation(pub_tx_key, private_view_key, derivation))
{
cerr << "Cant get dervied key for: " << "\n"
<< "pub_tx_key: " << pub_tx_key << " and "
<< "prv_view_key" << private_view_key << endl;
return false;
}
// get the tx output public key
// that normally would be generated for us,
// if someone had sent us some xmr.
public_key pubkey;
derive_public_key(derivation,
output_index,
public_spend_key,
pubkey);
//cout << "\n" << tx.vout.size() << " " << output_index << endl;
// get tx output public key
const txout_to_key tx_out_to_key
= boost::get<txout_to_key>(tx.vout[output_index].target);
if (tx_out_to_key.key == pubkey)
{
return true;
}
return false;
}
}

@ -14,7 +14,6 @@
a_hash.substr(1, a_hash.size()-2)
#include "monero_headers.h"
#include "tx_details.h"
#include "../ext/infix_iterator.h"
#include "../ext/date/tz.h"
@ -249,6 +248,13 @@ xmr_amount_to_str(const uint64_t& xmr_amount, string format="{:0.12f}")
return fmt::format("{:0.12f}", XMR_AMOUNT(xmr_amount));
}
bool
is_output_ours(const size_t& output_index,
const transaction& tx,
const public_key& pub_tx_key,
const secret_key& private_view_key,
const public_key& public_spend_key);
}
#endif //XMREG01_TOOLS_H

@ -1,223 +0,0 @@
//
// Created by mwo on 14/11/15.
//
#include "tx_details.h"
namespace xmreg
{
crypto::hash
transfer_details::tx_hash() const
{
return get_transaction_hash(m_tx);
};
uint64_t
transfer_details::amount() const
{
return m_tx.vout[m_internal_output_index].amount;
}
ostream&
operator<<(ostream& os, const transfer_details& td)
{
os << "Block: " << td.m_block_height
<< " time: " << timestamp_to_str(td.m_block_timestamp)
<< " tx hash: " << td.tx_hash()
<< " out idx: " << td.m_internal_output_index
<< " amount: " << print_money(td.amount());
return os;
}
/**
* Get tx outputs associated with the given private view and public spend keys
*
*
*/
vector<xmreg::transfer_details>
get_belonging_outputs(const block& blk,
const transaction& tx,
const secret_key& private_view_key,
const public_key& public_spend_key,
uint64_t block_height)
{
// vector to be returned
vector<xmreg::transfer_details> our_outputs;
// get transaction's public key
public_key pub_tx_key = get_tx_pub_key_from_extra(tx);
// check if transaction has valid public key
// if no, then skip
if (pub_tx_key == null_pkey)
{
return our_outputs;
}
// get the total number of outputs in a transaction.
size_t output_no = tx.vout.size();
// check if the given transaction has any outputs
// if no, then finish
if (output_no == 0)
{
return our_outputs;
}
// public transaction key is combined with our viewkey
// to create, so called, derived key.
key_derivation derivation;
if (!generate_key_derivation(pub_tx_key, private_view_key, derivation))
{
cerr << "Cant get dervied key for: " << "\n"
<< "pub_tx_key: " << private_view_key << " and "
<< "prv_view_key" << private_view_key << endl;
return our_outputs;
}
// each tx that we (or the address we are checking) received
// contains a number of outputs.
// some of them are ours, some not. so we need to go through
// all of them in a given tx block, to check which outputs are ours.
// sum amount of xmr sent to us
// in the given transaction
uint64_t money_transfered {0};
// loop through outputs in the given tx
// to check which outputs our ours. we compare outputs'
// public keys with the public key that would had been
// generated for us if we had gotten the outputs.
// not sure this is the case though, but that's my understanding.
for (size_t i = 0; i < output_no; ++i)
{
// get the tx output public key
// that normally would be generated for us,
// if someone had sent us some xmr.
public_key pubkey;
derive_public_key(derivation,
i,
public_spend_key,
pubkey);
// get tx output public key
const txout_to_key tx_out_to_key
= boost::get<txout_to_key>(tx.vout[i].target);
//cout << "Output no: " << i << ", " << tx_out_to_key.key;
// check if the output's public key is ours
if (tx_out_to_key.key == pubkey)
{
// if so, then add this output to the
// returned vector
//our_outputs.push_back(tx.vout[i]);
our_outputs.push_back(
xmreg::transfer_details {block_height,
blk.timestamp,
tx, i, false}
);
}
}
return our_outputs;
}
/**
* Check if given output (specified by output_index)
* belongs is ours based
* on our private view key and public spend key
*/
bool
is_output_ours(const size_t& output_index,
const transaction& tx,
const secret_key& private_view_key,
const public_key& public_spend_key)
{
// get transaction's public key
public_key pub_tx_key = get_tx_pub_key_from_extra(tx);
// check if transaction has valid public key
// if no, then skip
if (pub_tx_key == null_pkey)
{
return false;
}
// public transaction key is combined with our viewkey
// to create, so called, derived key.
key_derivation derivation;
if (!generate_key_derivation(pub_tx_key, private_view_key, derivation))
{
cerr << "Cant get dervied key for: " << "\n"
<< "pub_tx_key: " << pub_tx_key << " and "
<< "prv_view_key" << private_view_key << endl;
return false;
}
// get the tx output public key
// that normally would be generated for us,
// if someone had sent us some xmr.
public_key pubkey;
derive_public_key(derivation,
output_index,
public_spend_key,
pubkey);
//cout << "\n" << tx.vout.size() << " " << output_index << endl;
// get tx output public key
const txout_to_key tx_out_to_key
= boost::get<txout_to_key>(tx.vout[output_index].target);
if (tx_out_to_key.key == pubkey)
{
return true;
}
return false;
}
}
template<>
csv::ofstream&
operator<<(csv::ofstream& ostm, const xmreg::transfer_details& td)
{
ostm << xmreg::timestamp_to_str(td.m_block_timestamp, "%F");
ostm << xmreg::timestamp_to_str(td.m_block_timestamp, "%T");
ostm << td.m_block_height;
ostm << td.tx_hash();
ostm << td.m_internal_output_index;
ostm << cryptonote::print_money(td.amount());
return ostm;
}

@ -1,64 +0,0 @@
//
// Created by mwo on 14/11/15.
//
#ifndef XMR2CSV_TXDATA_H
#define XMR2CSV_TXDATA_H
#include "../ext/minicsv.h"
#include "monero_headers.h"
#include "tools.h"
namespace xmreg
{
using namespace cryptonote;
using namespace crypto;
using namespace std;
struct transfer_details
{
uint64_t m_block_height;
uint64_t m_block_timestamp;
transaction m_tx;
size_t m_internal_output_index;
bool m_spent;
crypto::hash tx_hash() const;
uint64_t amount() const;
};
ostream&
operator<<(ostream& os, const transfer_details& dt);
vector<xmreg::transfer_details>
get_belonging_outputs(const block& blk,
const transaction& tx,
const secret_key& private_view_key,
const public_key& public_spend_key,
uint64_t block_height = 0);
bool
is_output_ours(const size_t& output_index,
const transaction& tx,
const secret_key& private_view_key,
const public_key& public_spend_key);
}
template<>
csv::ostringstream&
operator<<(csv::ostringstream& ostm, const xmreg::transfer_details& td);
#endif //XMR2CSV_TXDATA_H
Loading…
Cancel
Save