forked from wownero/wownero
parent
1080a90d23
commit
a21f06b933
@ -0,0 +1,47 @@
|
||||
#include "pending_transaction_info.h"
|
||||
#include "transaction_construction_info.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace Monero {
|
||||
|
||||
PendingTransactionInfo::~PendingTransactionInfo() = default;
|
||||
|
||||
PendingTransactionInfoImpl::PendingTransactionInfoImpl(WalletImpl &wallet, const tools::wallet2::pending_tx & ptx)
|
||||
: m_wallet(wallet)
|
||||
, m_ptx(ptx)
|
||||
, m_constructionData(new TransactionConstructionInfoImpl(wallet, ptx.construction_data))
|
||||
{
|
||||
}
|
||||
|
||||
PendingTransactionInfoImpl::~PendingTransactionInfoImpl() = default;
|
||||
|
||||
uint64_t PendingTransactionInfoImpl::fee() const
|
||||
{
|
||||
return m_ptx.fee;
|
||||
}
|
||||
|
||||
uint64_t PendingTransactionInfoImpl::dust() const
|
||||
{
|
||||
return m_ptx.dust;
|
||||
}
|
||||
|
||||
bool PendingTransactionInfoImpl::dustAddedToFee() const
|
||||
{
|
||||
return m_ptx.dust_added_to_fee;
|
||||
}
|
||||
|
||||
std::string PendingTransactionInfoImpl::txKey() const
|
||||
{
|
||||
return epee::string_tools::pod_to_hex(m_ptx.tx_key);
|
||||
}
|
||||
|
||||
TransactionConstructionInfo * PendingTransactionInfoImpl::constructionData() const {
|
||||
return m_constructionData;
|
||||
}
|
||||
|
||||
// TransactionConstructionInfo::Output TransactionConstructionInfoImpl::change() const {
|
||||
// return Output(
|
||||
// {m_ptx.change_dts.amount, m_ptx.change_dts.address(m_wallet.m_wallet->nettype(), crypto::hash())});
|
||||
// }
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
#ifndef WOWLET_PENDING_TX_H
|
||||
#define WOWLET_PENDING_TX_H
|
||||
|
||||
#include "wallet/api/wallet2_api.h"
|
||||
#include "wallet/wallet2.h"
|
||||
#include "wallet.h"
|
||||
#include <string>
|
||||
|
||||
namespace Monero {
|
||||
|
||||
class PendingTransactionImpl;
|
||||
|
||||
class PendingTransactionInfoImpl : public PendingTransactionInfo
|
||||
{
|
||||
public:
|
||||
PendingTransactionInfoImpl(WalletImpl &wallet, const tools::wallet2::pending_tx & ptx);
|
||||
~PendingTransactionInfoImpl() override;
|
||||
|
||||
uint64_t fee() const override;
|
||||
uint64_t dust() const override;
|
||||
bool dustAddedToFee() const override;
|
||||
std::string txKey() const override;
|
||||
TransactionConstructionInfo *constructionData() const override;
|
||||
// Output change() const override;
|
||||
|
||||
private:
|
||||
friend class WalletImpl;
|
||||
WalletImpl &m_wallet;
|
||||
tools::wallet2::pending_tx m_ptx;
|
||||
TransactionConstructionInfo *m_constructionData;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif //FEATHER_PENDING_TX_H
|
@ -0,0 +1,63 @@
|
||||
#include "transaction_construction_info.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace Monero {
|
||||
TransactionConstructionInfo::~TransactionConstructionInfo() = default;
|
||||
|
||||
TransactionConstructionInfo::Input::Input(uint64_t _amount, const std::string &_pubkey)
|
||||
: amount(_amount), pubkey(_pubkey) {}
|
||||
|
||||
TransactionConstructionInfo::Output::Output(uint64_t _amount, const std::string &_address)
|
||||
: amount(_amount), address(_address) {}
|
||||
|
||||
TransactionConstructionInfoImpl::TransactionConstructionInfoImpl(WalletImpl &wallet, const tools::wallet2::tx_construction_data & txcd)
|
||||
: m_wallet(wallet)
|
||||
, m_txcd(txcd) {}
|
||||
|
||||
TransactionConstructionInfoImpl::~TransactionConstructionInfoImpl() = default;
|
||||
|
||||
uint64_t TransactionConstructionInfoImpl::unlockTime() const {
|
||||
return m_txcd.unlock_time;
|
||||
}
|
||||
|
||||
std::set<std::uint32_t> TransactionConstructionInfoImpl::subaddressIndices() const {
|
||||
return m_txcd.subaddr_indices;
|
||||
}
|
||||
|
||||
std::vector<std::string> TransactionConstructionInfoImpl::subaddresses() const {
|
||||
std::vector<std::string> s;
|
||||
auto major = m_txcd.subaddr_account;
|
||||
for (const auto &minor : m_txcd.subaddr_indices) {
|
||||
s.push_back(m_wallet.m_wallet->get_subaddress_as_str({major, minor}));
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
uint64_t TransactionConstructionInfoImpl::minMixinCount() const {
|
||||
uint64_t min_mixin = -1;
|
||||
for (const auto &source : m_txcd.sources) {
|
||||
size_t mixin = source.outputs.size() - 1;
|
||||
if (mixin < min_mixin)
|
||||
min_mixin = mixin;
|
||||
}
|
||||
|
||||
return min_mixin;
|
||||
}
|
||||
|
||||
std::vector<TransactionConstructionInfo::Input> TransactionConstructionInfoImpl::inputs() const {
|
||||
std::vector<Input> inputs;
|
||||
for (const auto &i : m_txcd.sources) {
|
||||
inputs.emplace_back(i.amount, epee::string_tools::pod_to_hex(i.real_out_tx_key));
|
||||
}
|
||||
return inputs;
|
||||
}
|
||||
|
||||
std::vector<TransactionConstructionInfo::Output> TransactionConstructionInfoImpl::outputs() const {
|
||||
std::vector<Output> outputs;
|
||||
for (const auto &o : m_txcd.splitted_dsts) {
|
||||
outputs.emplace_back(o.amount, o.address(m_wallet.m_wallet->nettype(), crypto::hash()));
|
||||
}
|
||||
return outputs;
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
#ifndef WOWLET_TRANSACTION_CONSTRUCTION_INFO_H
|
||||
#define WOWLET_TRANSACTION_CONSTRUCTION_INFO_H
|
||||
|
||||
#include "wallet/api/wallet2_api.h"
|
||||
#include "wallet/wallet2.h"
|
||||
#include "wallet.h"
|
||||
#include <string>
|
||||
|
||||
namespace Monero {
|
||||
|
||||
class TransactionConstructionInfoImpl : public TransactionConstructionInfo
|
||||
{
|
||||
public:
|
||||
TransactionConstructionInfoImpl(WalletImpl &wallet, const tools::wallet2::tx_construction_data & ptx);
|
||||
~TransactionConstructionInfoImpl() override;
|
||||
|
||||
uint64_t unlockTime() const override;
|
||||
std::set<std::uint32_t> subaddressIndices() const override;
|
||||
std::vector<std::string> subaddresses() const override;
|
||||
uint64_t minMixinCount() const override;
|
||||
std::vector<Input> inputs() const override;
|
||||
std::vector<Output> outputs() const override;
|
||||
|
||||
private:
|
||||
friend class WalletImpl;
|
||||
WalletImpl &m_wallet;
|
||||
tools::wallet2::tx_construction_data m_txcd;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif //WOWLET_TRANSACTION_CONSTRUCTION_INFO_H
|
Loading…
Reference in new issue