Skip to content

Commit

Permalink
Set minimum UTXO value to be used for staking to 0.1 BLK
Browse files Browse the repository at this point in the history
  • Loading branch information
lateminer committed Feb 17, 2024
1 parent c39431c commit a077e17
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/wallet/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ void WalletInit::AddWalletOptions(ArgsManager& argsman) const
argsman.AddArg("-staking=<true/false>", strprintf("Enables or disables staking (default: %u)", node::DEFAULT_STAKE), ArgsManager::ALLOW_ANY, OptionsCategory::WALLET);
argsman.AddArg("-stakecache=<true/false>", strprintf("Enables or disables the staking cache; significantly improves staking performance, but can use a lot of memory (default: %u)", node::DEFAULT_STAKE_CACHE), ArgsManager::ALLOW_ANY, OptionsCategory::WALLET);
argsman.AddArg("-staketimio=<n>", strprintf("Proof of stake timeout. (default: %u)", node::DEFAULT_STAKETIMIO), ArgsManager::ALLOW_ANY, OptionsCategory::WALLET);

argsman.AddArg("-minstakingamount=<amt>", strprintf("Minimum input value to be used for staking (default: %u)", wallet::DEFAULT_MIN_STAKING_AMOUNT), ArgsManager::ALLOW_ANY, OptionsCategory::WALLET);
argsman.AddArg("-reservebalance=<amt>", strprintf("Reserved balance not used for staking (default: %u)", wallet::DEFAULT_RESERVE_BALANCE), ArgsManager::ALLOW_ANY, OptionsCategory::WALLET);
argsman.AddArg("-donatetodevfund=<n>", strprintf("Donate the specified percentage of staking rewards to the dev fund (%u to %u, default: %u)",
wallet::MIN_DONATION_PERCENTAGE, wallet::MAX_DONATION_PERCENTAGE, wallet::DEFAULT_DONATION_PERCENTAGE), ArgsManager::ALLOW_ANY, OptionsCategory::WALLET);
Expand Down
3 changes: 3 additions & 0 deletions src/wallet/staking.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ void AvailableCoinsForStaking(const CWallet& wallet,
const CTxOut& output = wtx.tx->vout[i];
const COutPoint outpoint(wtxid, i);

if (output.nValue < wallet.m_min_staking_amount)
continue;

if (output.nValue < params.min_amount || output.nValue > params.max_amount)
continue;

Expand Down
3 changes: 3 additions & 0 deletions src/wallet/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3090,6 +3090,9 @@ std::shared_ptr<CWallet> CWallet::Create(WalletContext& context, const std::stri

walletInstance->m_spend_zero_conf_change = args.GetBoolArg("-spendzeroconfchange", DEFAULT_SPEND_ZEROCONF_CHANGE);

std::optional<CAmount> min_staking_amount = ParseMoney(gArgs.GetArg("-minstakingamount", FormatMoney(DEFAULT_MIN_STAKING_AMOUNT)));
walletInstance->m_min_staking_amount = min_staking_amount.value_or(DEFAULT_MIN_STAKING_AMOUNT);

std::optional<CAmount> reserve_balance = ParseMoney(gArgs.GetArg("-reservebalance", FormatMoney(DEFAULT_RESERVE_BALANCE)));
walletInstance->m_reserve_balance = reserve_balance.value_or(DEFAULT_RESERVE_BALANCE);

Expand Down
3 changes: 3 additions & 0 deletions src/wallet/wallet.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ constexpr CAmount HIGH_MAX_TX_FEE{100 * HIGH_TX_FEE_PER_KB};
//! Pre-calculated constants for input size estimation in *virtual size*
static constexpr size_t DUMMY_NESTED_P2WPKH_INPUT_SIZE = 91;

//! -minstakingamount default
static const CAmount DEFAULT_MIN_STAKING_AMOUNT = 0.1 * COIN;
//! -reservebalance default
static const CAmount DEFAULT_RESERVE_BALANCE = 0;
//! -donatetodevfund default
Expand Down Expand Up @@ -717,6 +719,7 @@ class CWallet final : public WalletStorage, public interfaces::Chain::Notificati
// provides no real security
std::atomic<bool> m_wallet_unlock_staking_only{false};
int64_t m_last_coin_stake_search_interval{0};
CAmount m_min_staking_amount{DEFAULT_MIN_STAKING_AMOUNT};
CAmount m_reserve_balance{DEFAULT_RESERVE_BALANCE};
unsigned int m_donation_percentage{DEFAULT_DONATION_PERCENTAGE};
std::atomic<bool> m_enabled_staking{false};
Expand Down

0 comments on commit a077e17

Please sign in to comment.