call the staking transferred function if available rather than returning amount

This commit is contained in:
Sean Darcy 2021-01-07 17:13:08 +11:00 committed by Jason Rhinelander
parent e0eeab5eb7
commit 10057a077f
3 changed files with 15 additions and 4 deletions

View file

@ -163,11 +163,15 @@ uint64_t PendingTransactionImpl::amount() const
for (const auto &dest : ptx.dests) {
result += dest.amount;
}
//TODO(sean)
service_nodes::staking_components sc;
if (service_nodes::tx_get_staking_components_and_amounts(nettype, hf_version, ptx.tx, ptx.block_height, &sc)
&& sc.transferred > 0)
result = sc.transferred;
uint64_t height = m_wallet.blockChainHeight();
std::optional<uint8_t> hf_version = m_wallet.hardForkVersion();
if (hf_version)
{
if (service_nodes::tx_get_staking_components_and_amounts(static_cast<cryptonote::network_type>(m_wallet.nettype()), *hf_version, ptx.tx, height, &sc)
&& sc.transferred > 0)
result = sc.transferred;
}
}
return result;
}

View file

@ -2417,6 +2417,12 @@ void WalletImpl::hardForkInfo(uint8_t &version, uint64_t &earliest_height) const
m_wallet->get_hard_fork_info(version, earliest_height);
}
EXPORT
std::optional<uint8_t> WalletImpl::hardForkVersion() const
{
m_wallet->get_hard_fork_version();
}
EXPORT
bool WalletImpl::useForkRules(uint8_t version, int64_t early_blocks) const
{

View file

@ -454,6 +454,7 @@ struct Wallet
bool devnet() const { return nettype() == DEVNET; }
//! returns current hard fork info
virtual void hardForkInfo(uint8_t &version, uint64_t &earliest_height) const = 0;
virtual std::optional<uint8_t> hardForkVersion() const = 0;
//! check if hard fork rules should be used
virtual bool useForkRules(uint8_t version, int64_t early_blocks) const = 0;
/*!