|
|
|
@ -5,9 +5,6 @@
|
|
|
|
|
#ifndef XMREG01_MICROCORE_H
|
|
|
|
|
#define XMREG01_MICROCORE_H
|
|
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
|
#include <random>
|
|
|
|
|
|
|
|
|
|
#include "monero_headers.h"
|
|
|
|
|
|
|
|
|
|
namespace xmreg
|
|
|
|
@ -16,6 +13,38 @@ using namespace cryptonote;
|
|
|
|
|
using namespace crypto;
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class AbstractCore
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
// the three methods below are used in input identification
|
|
|
|
|
// in the UniveralIdentifier. Thus we are going to make
|
|
|
|
|
// the identifier relay on the AbstractCore, instead of the
|
|
|
|
|
// concrete implementation defined below.
|
|
|
|
|
|
|
|
|
|
virtual void
|
|
|
|
|
get_output_key(uint64_t amount,
|
|
|
|
|
vector<uint64_t> const& absolute_offsets,
|
|
|
|
|
vector<cryptonote::output_data_t>& outputs) const = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
virtual void
|
|
|
|
|
get_output_tx_and_index(
|
|
|
|
|
uint64_t amount,
|
|
|
|
|
std::vector<uint64_t> const& offsets,
|
|
|
|
|
std::vector<tx_out_index>& indices) const = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
virtual bool
|
|
|
|
|
get_tx(crypto::hash const& tx_hash, transaction& tx) const = 0;
|
|
|
|
|
|
|
|
|
|
// below, with time we can other pure virtual methods
|
|
|
|
|
// to the AbstractCore, if needed. For now, the above three are
|
|
|
|
|
// essential
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Micro version of cryptonode::core class
|
|
|
|
|
* Micro version of constructor,
|
|
|
|
@ -24,7 +53,8 @@ using namespace std;
|
|
|
|
|
* Just enough to read the blockchain
|
|
|
|
|
* database for use in the example.
|
|
|
|
|
*/
|
|
|
|
|
class MicroCore {
|
|
|
|
|
class MicroCore : public AbstractCore
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
string blockchain_path;
|
|
|
|
|
|
|
|
|
@ -73,100 +103,53 @@ public:
|
|
|
|
|
virtual void
|
|
|
|
|
get_output_key(uint64_t amount,
|
|
|
|
|
vector<uint64_t> const& absolute_offsets,
|
|
|
|
|
vector<cryptonote::output_data_t>& outputs) const
|
|
|
|
|
{
|
|
|
|
|
core_storage.get_db()
|
|
|
|
|
.get_output_key(epee::span<const uint64_t>(&amount, 1),
|
|
|
|
|
absolute_offsets, outputs);
|
|
|
|
|
}
|
|
|
|
|
vector<cryptonote::output_data_t>& outputs)
|
|
|
|
|
const override;
|
|
|
|
|
|
|
|
|
|
virtual output_data_t
|
|
|
|
|
get_output_key(uint64_t amount,
|
|
|
|
|
uint64_t global_amount_index) const
|
|
|
|
|
{
|
|
|
|
|
return core_storage.get_db()
|
|
|
|
|
.get_output_key(amount, global_amount_index);
|
|
|
|
|
}
|
|
|
|
|
uint64_t global_amount_index) const;
|
|
|
|
|
|
|
|
|
|
virtual bool
|
|
|
|
|
get_transactions(
|
|
|
|
|
const std::vector<crypto::hash>& txs_ids,
|
|
|
|
|
std::vector<crypto::hash> const& txs_ids,
|
|
|
|
|
std::vector<transaction>& txs,
|
|
|
|
|
std::vector<crypto::hash>& missed_txs) const
|
|
|
|
|
{
|
|
|
|
|
return core_storage.get_transactions(txs_ids, txs, missed_txs);
|
|
|
|
|
}
|
|
|
|
|
std::vector<crypto::hash>& missed_txs) const;
|
|
|
|
|
|
|
|
|
|
virtual std::vector<block>
|
|
|
|
|
get_blocks_range(const uint64_t& h1, const uint64_t& h2) const
|
|
|
|
|
{
|
|
|
|
|
return core_storage.get_db().get_blocks_range(h1, h2);
|
|
|
|
|
}
|
|
|
|
|
get_blocks_range(uint64_t h1, uint64_t h2) const;
|
|
|
|
|
|
|
|
|
|
virtual uint64_t
|
|
|
|
|
get_tx_unlock_time(crypto::hash const& tx_hash) const
|
|
|
|
|
{
|
|
|
|
|
return core_storage.get_db().get_tx_unlock_time(tx_hash);
|
|
|
|
|
}
|
|
|
|
|
get_tx_unlock_time(crypto::hash const& tx_hash) const;
|
|
|
|
|
|
|
|
|
|
virtual bool
|
|
|
|
|
have_tx(crypto::hash const& tx_hash) const
|
|
|
|
|
{
|
|
|
|
|
return core_storage.have_tx(tx_hash);
|
|
|
|
|
}
|
|
|
|
|
have_tx(crypto::hash const& tx_hash) const;
|
|
|
|
|
|
|
|
|
|
virtual bool
|
|
|
|
|
tx_exists(crypto::hash const& tx_hash, uint64_t& tx_id) const
|
|
|
|
|
{
|
|
|
|
|
return core_storage.get_db().tx_exists(tx_hash, tx_id);
|
|
|
|
|
}
|
|
|
|
|
tx_exists(crypto::hash const& tx_hash, uint64_t& tx_id) const;
|
|
|
|
|
|
|
|
|
|
virtual tx_out_index
|
|
|
|
|
get_output_tx_and_index(uint64_t const& amount, uint64_t const& index) const
|
|
|
|
|
{
|
|
|
|
|
return core_storage.get_db().get_output_tx_and_index(amount, index);
|
|
|
|
|
}
|
|
|
|
|
get_output_tx_and_index(uint64_t amount, uint64_t index) const;
|
|
|
|
|
|
|
|
|
|
virtual uint64_t
|
|
|
|
|
get_tx_block_height(crypto::hash const& tx_hash) const
|
|
|
|
|
{
|
|
|
|
|
return core_storage.get_db().get_tx_block_height(tx_hash);
|
|
|
|
|
}
|
|
|
|
|
get_tx_block_height(crypto::hash const& tx_hash) const;
|
|
|
|
|
|
|
|
|
|
virtual std::vector<uint64_t>
|
|
|
|
|
get_tx_amount_output_indices(uint64_t const& tx_id) const
|
|
|
|
|
{
|
|
|
|
|
return core_storage.get_db()
|
|
|
|
|
.get_tx_amount_output_indices(tx_id).front();
|
|
|
|
|
}
|
|
|
|
|
get_tx_amount_output_indices(uint64_t tx_id) const;
|
|
|
|
|
|
|
|
|
|
virtual bool
|
|
|
|
|
get_mempool_txs(
|
|
|
|
|
std::vector<tx_info>& tx_infos,
|
|
|
|
|
std::vector<spent_key_image_info>& key_image_infos) const
|
|
|
|
|
{
|
|
|
|
|
return m_mempool.get_transactions_and_spent_keys_info(
|
|
|
|
|
tx_infos, key_image_infos);
|
|
|
|
|
}
|
|
|
|
|
std::vector<spent_key_image_info>& key_image_infos) const;
|
|
|
|
|
|
|
|
|
|
virtual uint64_t
|
|
|
|
|
get_current_blockchain_height() const
|
|
|
|
|
{
|
|
|
|
|
return core_storage.get_current_blockchain_height();
|
|
|
|
|
}
|
|
|
|
|
get_current_blockchain_height() const;
|
|
|
|
|
|
|
|
|
|
virtual void
|
|
|
|
|
get_output_tx_and_index(
|
|
|
|
|
const uint64_t& amount,
|
|
|
|
|
const std::vector<uint64_t>& offsets,
|
|
|
|
|
std::vector<tx_out_index>& indices) const
|
|
|
|
|
{
|
|
|
|
|
// tx_hash , index in tx
|
|
|
|
|
// tx_out_index is std::pair<crypto::hash, uint64_t>;
|
|
|
|
|
|
|
|
|
|
core_storage.get_db().get_output_tx_and_index(
|
|
|
|
|
amount, offsets, indices);
|
|
|
|
|
}
|
|
|
|
|
uint64_t amount,
|
|
|
|
|
std::vector<uint64_t> const& offsets,
|
|
|
|
|
std::vector<tx_out_index>& indices) const override;
|
|
|
|
|
|
|
|
|
|
virtual bool
|
|
|
|
|
get_output_histogram(
|
|
|
|
@ -186,16 +169,10 @@ public:
|
|
|
|
|
|
|
|
|
|
virtual bool
|
|
|
|
|
get_outs(COMMAND_RPC_GET_OUTPUTS_BIN::request const& req,
|
|
|
|
|
COMMAND_RPC_GET_OUTPUTS_BIN::response& res) const
|
|
|
|
|
{
|
|
|
|
|
return core_storage.get_outs(req, res);
|
|
|
|
|
}
|
|
|
|
|
COMMAND_RPC_GET_OUTPUTS_BIN::response& res) const;
|
|
|
|
|
|
|
|
|
|
virtual uint64_t
|
|
|
|
|
get_dynamic_base_fee_estimate(uint64_t const& grace_blocks) const
|
|
|
|
|
{
|
|
|
|
|
return core_storage.get_dynamic_base_fee_estimate(grace_blocks);
|
|
|
|
|
}
|
|
|
|
|
get_dynamic_base_fee_estimate(uint64_t grace_blocks) const;
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
get_block_complete_entry(block const& b, block_complete_entry& bce);
|
|
|
|
@ -204,18 +181,12 @@ public:
|
|
|
|
|
get_block_from_height(uint64_t height, block& blk) const;
|
|
|
|
|
|
|
|
|
|
virtual bool
|
|
|
|
|
get_tx(crypto::hash const& tx_hash, transaction& tx) const;
|
|
|
|
|
get_tx(crypto::hash const& tx_hash, transaction& tx) const override;
|
|
|
|
|
|
|
|
|
|
virtual bool
|
|
|
|
|
decrypt_payment_id(crypto::hash8& payment_id,
|
|
|
|
|
public_key const& public_key,
|
|
|
|
|
secret_key const& secret_key)
|
|
|
|
|
{
|
|
|
|
|
return m_device->decrypt_payment_id(payment_id,
|
|
|
|
|
public_key,
|
|
|
|
|
secret_key);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
secret_key const& secret_key) const;
|
|
|
|
|
|
|
|
|
|
virtual bool
|
|
|
|
|
init_success() const;
|
|
|
|
|