allow wallet gui to differentiate between different awards (#322)

This commit is contained in:
Maxim Shishmarev 2018-11-16 15:51:05 +11:00 committed by Doyle
parent 4c452e8545
commit 2ba498242e
4 changed files with 30 additions and 0 deletions

View file

@ -92,6 +92,14 @@ std::vector<TransactionInfo *> TransactionHistoryImpl::getAll() const
return m_history;
}
static reward_type from_pay_type(tools::pay_type ptype) {
switch (ptype) {
case tools::pay_type::service_node: return reward_type::service_node;
case tools::pay_type::miner: return reward_type::miner;
default: reward_type::unspecified;
}
}
void TransactionHistoryImpl::refresh()
{
// multithreaded access:
@ -136,6 +144,7 @@ void TransactionHistoryImpl::refresh()
ti->m_timestamp = pd.m_timestamp;
ti->m_confirmations = (wallet_height > pd.m_block_height) ? wallet_height - pd.m_block_height : 0;
ti->m_unlock_time = pd.m_unlock_time;
ti->m_reward_type = from_pay_type(pd.m_type);
m_history.push_back(ti);
}
@ -236,6 +245,7 @@ void TransactionHistoryImpl::refresh()
ti->m_label = m_wallet->m_wallet->get_subaddress_label(pd.m_subaddr_index);
ti->m_timestamp = pd.m_timestamp;
ti->m_confirmations = 0;
ti->m_reward_type = from_pay_type(pd.m_type);
m_history.push_back(ti);
LOG_PRINT_L1(__FUNCTION__ << ": Unconfirmed payment found " << pd.m_amount);

View file

@ -66,6 +66,15 @@ int TransactionInfoImpl::direction() const
return m_direction;
}
bool TransactionInfoImpl::isServiceNodeReward() const
{
return m_reward_type == reward_type::service_node;
}
bool TransactionInfoImpl::isMinerReward() const
{
return m_reward_type == reward_type::miner;
}
bool TransactionInfoImpl::isPending() const
{

View file

@ -36,6 +36,12 @@ namespace Monero {
class TransactionHistoryImpl;
enum class reward_type {
unspecified,
service_node,
miner
};
class TransactionInfoImpl : public TransactionInfo
{
public:
@ -60,11 +66,14 @@ public:
virtual const std::vector<Transfer> &transfers() const override;
virtual uint64_t confirmations() const override;
virtual uint64_t unlockTime() const override;
bool isServiceNodeReward() const override;
bool isMinerReward() const override;
private:
int m_direction;
bool m_pending;
bool m_failed;
reward_type m_reward_type; // may have a value rather than `unspecified` after hf 10
uint64_t m_amount;
uint64_t m_fee;
uint64_t m_blockheight;

View file

@ -178,6 +178,8 @@ struct TransactionInfo
};
virtual ~TransactionInfo() = 0;
virtual bool isServiceNodeReward() const = 0;
virtual bool isMinerReward() const = 0;
virtual int direction() const = 0;
virtual bool isPending() const = 0;
virtual bool isFailed() const = 0;