mirror of
https://github.com/oxen-io/oxen-core.git
synced 2023-12-14 02:22:56 +01:00
adjusted implementation of StakeUnlockResult
This commit is contained in:
parent
a7b60ff282
commit
6d0081a955
5 changed files with 51 additions and 31 deletions
|
@ -4,16 +4,8 @@ namespace Wallet {
|
|||
|
||||
StakeUnlockResult::~StakeUnlockResult() {}
|
||||
|
||||
//StakeUnlockResultImpl::StakeUnlockResultImpl(tools::wallet2::request_stake_unlock_result& result)
|
||||
//{
|
||||
|
||||
//success = result.success;
|
||||
//msg = result.msg;
|
||||
//ptx = &result.ptx;
|
||||
|
||||
//}
|
||||
|
||||
StakeUnlockResultImpl::StakeUnlockResultImpl()
|
||||
StakeUnlockResultImpl::StakeUnlockResultImpl(tools::wallet2::request_stake_unlock_result& res)
|
||||
: result(res)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -22,4 +14,23 @@ StakeUnlockResultImpl::~StakeUnlockResultImpl()
|
|||
LOG_PRINT_L3("Stake Unlock Result Deleted");
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
bool StakeUnlockResultImpl::success()
|
||||
{
|
||||
return result.success;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
std::string StakeUnlockResultImpl::msg()
|
||||
{
|
||||
return result.msg;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
std::string StakeUnlockResultImpl::msg()
|
||||
PendingTransaction* StakeUnlockResultImpl:: ptx();
|
||||
{
|
||||
return &result.ptx;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -10,13 +10,16 @@ class WalletImpl;
|
|||
class StakeUnlockResultImpl : public StakeUnlockResult
|
||||
{
|
||||
public:
|
||||
StakeUnlockResultImpl(tools::wallet2::request_stake_unlock_result result);
|
||||
StakeUnlockResultImpl(tools::wallet2::request_stake_unlock_result res);
|
||||
StakeUnlockResultImpl();
|
||||
~StakeUnlockResultImpl();
|
||||
|
||||
bool success;
|
||||
std::string msg;
|
||||
PendingTransaction * ptx;
|
||||
bool success();
|
||||
std::string msg();
|
||||
PendingTransaction * ptx();
|
||||
|
||||
private:
|
||||
tools::wallet2::request_stake_unlock_result &result;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -2464,31 +2464,34 @@ PendingTransaction* WalletImpl::stakePending(const std::string& sn_key_str, cons
|
|||
return transaction;
|
||||
}
|
||||
|
||||
StakeUnlockResult WalletImpl::canRequestStakeUnlock(const std::string &sn_key)
|
||||
StakeUnlockResult* WalletImpl::canRequestStakeUnlock(const std::string &sn_key)
|
||||
{
|
||||
StakeUnlockResult res = {};
|
||||
tools::wallet2::request_stake_unlock_result res = {};
|
||||
|
||||
crypto::public_key snode_key;
|
||||
if (!tools::hex_to_type(sn_key, snode_key))
|
||||
{
|
||||
res.success = false;
|
||||
res.msg = "Failed to Parse Service Node Key";
|
||||
return res;
|
||||
StakeUnlockResultImpl stake_unlock_result(res);
|
||||
return &stake_unlock_result;
|
||||
}
|
||||
|
||||
return StakeUnlockResultImpl(m_wallet->can_request_stake_unlock(snode_key));
|
||||
StakeUnlockResultImpl stake_unlock_result(m_wallet->can_request_stake_unlock(snode_key));
|
||||
return &stake_unlock_result;
|
||||
}
|
||||
|
||||
StakeUnlockResult WalletImpl::requestStakeUnlock(const std::string &sn_key)
|
||||
StakeUnlockResult* WalletImpl::requestStakeUnlock(const std::string &sn_key)
|
||||
{
|
||||
StakeUnlockResult res = {};
|
||||
tools::wallet2::request_stake_unlock_result res = {};
|
||||
|
||||
crypto::public_key snode_key;
|
||||
if (!tools::hex_to_type(sn_key, snode_key))
|
||||
{
|
||||
res.success = false;
|
||||
res.msg = "Failed to Parse Service Node Key";
|
||||
return res;
|
||||
StakeUnlockResultImpl stake_unlock_result(res);
|
||||
return &stake_unlock_result;
|
||||
}
|
||||
tools::wallet2::request_stake_unlock_result unlock_result = m_wallet->can_request_stake_unlock(snode_key);
|
||||
if (unlock_result.success)
|
||||
|
@ -2501,17 +2504,20 @@ StakeUnlockResult WalletImpl::requestStakeUnlock(const std::string &sn_key)
|
|||
{
|
||||
res.success = false;
|
||||
res.msg = "Failed to commit tx.";
|
||||
return res;
|
||||
StakeUnlockResultImpl stake_unlock_result(res);
|
||||
return &stake_unlock_result;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
res.success = false;
|
||||
res.msg = tr("Cannot request stake unlock: " + unlock_result.msg);
|
||||
return res;
|
||||
StakeUnlockResultImpl stake_unlock_result(res);
|
||||
return &stake_unlock_result;
|
||||
}
|
||||
|
||||
return StakeUnlockResultImpl(unlock_result);
|
||||
StakeUnlockResultImpl stake_unlock_result(unlock_result);
|
||||
return &stake_unlock_result;
|
||||
}
|
||||
|
||||
uint64_t WalletImpl::coldKeyImageSync(uint64_t &spent, uint64_t &unspent)
|
||||
|
|
|
@ -130,9 +130,9 @@ public:
|
|||
|
||||
PendingTransaction* stakePending(const std::string& service_node_key, const std::string& address, const std::string& amount, std::string& error_msg) override;
|
||||
|
||||
StakeUnlockResult canRequestStakeUnlock(const std::string &sn_key) override;
|
||||
StakeUnlockResult* canRequestStakeUnlock(const std::string &sn_key) override;
|
||||
|
||||
StakeUnlockResult requestStakeUnlock(const std::string &sn_key) override;
|
||||
StakeUnlockResult* requestStakeUnlock(const std::string &sn_key) override;
|
||||
|
||||
MultisigState multisig() const override;
|
||||
std::string getMultisigInfo() const override;
|
||||
|
|
|
@ -112,9 +112,9 @@ struct PendingTransaction
|
|||
|
||||
struct StakeUnlockResult
|
||||
{
|
||||
bool success;
|
||||
std::string msg;
|
||||
PendingTransaction * ptx;
|
||||
virtual bool success() = 0;
|
||||
virtual std::string msg() = 0;
|
||||
virtual PendingTransaction * ptx() = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -1011,9 +1011,9 @@ struct Wallet
|
|||
/// Prepare a staking transaction; return nullptr on failure
|
||||
virtual PendingTransaction* stakePending(const std::string& service_node_key, const std::string& address, const std::string& amount, std::string& error_msg) = 0;
|
||||
|
||||
virtual StakeUnlockResult canRequestStakeUnlock(const std::string &sn_key) = 0;
|
||||
virtual StakeUnlockResult* canRequestStakeUnlock(const std::string &sn_key) = 0;
|
||||
|
||||
virtual StakeUnlockResult requestStakeUnlock(const std::string &sn_key) = 0;
|
||||
virtual StakeUnlockResult* requestStakeUnlock(const std::string &sn_key) = 0;
|
||||
|
||||
//! cold-device protocol key image sync
|
||||
virtual uint64_t coldKeyImageSync(uint64_t &spent, uint64_t &unspent) = 0;
|
||||
|
|
Loading…
Reference in a new issue