Merge pull request #1386 from darcys22/api-list-stakes

Api for staked amount on pending transactions
This commit is contained in:
Sean 2021-04-15 11:21:00 +10:00 committed by GitHub
commit 7b882ac5ae
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 0 deletions

View file

@ -163,6 +163,15 @@ uint64_t PendingTransactionImpl::amount() const
for (const auto &dest : ptx.dests) {
result += dest.amount;
}
service_nodes::staking_components sc;
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

@ -120,6 +120,7 @@ public:
bool rescanSpent() override;
NetworkType nettype() const override {return static_cast<NetworkType>(m_wallet->nettype());}
void hardForkInfo(uint8_t &version, uint64_t &earliest_height) const override;
std::optional<uint8_t> hardForkVersion() const override;
bool useForkRules(uint8_t version, int64_t early_blocks) const override;
void addSubaddressAccount(const std::string& label) override;

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;
/*!