fixed fee calc issue, removed segwit enable fallback
This commit is contained in:
parent
12ab16f50e
commit
9149e371ed
4 changed files with 29 additions and 4 deletions
|
@ -11,7 +11,7 @@
|
||||||
// This is the minimum claim fee per character in the name of an OP_CLAIM_NAME command that must
|
// This is the minimum claim fee per character in the name of an OP_CLAIM_NAME command that must
|
||||||
// be attached to transactions for it to be accepted into the memory pool.
|
// be attached to transactions for it to be accepted into the memory pool.
|
||||||
// Rationale: current implementation of the claim trie uses more memory for longer name claims
|
// Rationale: current implementation of the claim trie uses more memory for longer name claims
|
||||||
// due to the fact that each chracater is assigned a trie node regardless of whether it contains
|
// due to the fact that each character is assigned a trie node regardless of whether it contains
|
||||||
// any claims or not. In the future, we can switch to a radix tree implementation where
|
// any claims or not. In the future, we can switch to a radix tree implementation where
|
||||||
// empty nodes do not take up any memory and the minimum fee can be priced on a per claim
|
// empty nodes do not take up any memory and the minimum fee can be priced on a per claim
|
||||||
// basis.
|
// basis.
|
||||||
|
|
|
@ -204,9 +204,10 @@ public:
|
||||||
ThresholdState VersionBitsState(const CBlockIndex* pindexPrev, const Consensus::Params& params, Consensus::DeploymentPos pos, VersionBitsCache& cache)
|
ThresholdState VersionBitsState(const CBlockIndex* pindexPrev, const Consensus::Params& params, Consensus::DeploymentPos pos, VersionBitsCache& cache)
|
||||||
{
|
{
|
||||||
// Check if we've past a hardfork state for segwit.
|
// Check if we've past a hardfork state for segwit.
|
||||||
if ((pos == Consensus::DEPLOYMENT_SEGWIT) && (pindexPrev != nullptr) &&
|
if (pos == Consensus::DEPLOYMENT_SEGWIT) {
|
||||||
(pindexPrev->nHeight + 1 >= params.nWitnessForkHeight))
|
return pindexPrev != nullptr && pindexPrev->nHeight + 1 >= params.nWitnessForkHeight ?
|
||||||
return ThresholdState::ACTIVE;
|
ThresholdState::ACTIVE : ThresholdState::FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
return VersionBitsConditionChecker(pos).GetStateFor(pindexPrev, params, cache.caches[pos]);
|
return VersionBitsConditionChecker(pos).GetStateFor(pindexPrev, params, cache.caches[pos]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,6 +63,10 @@ uint256 ClaimAName(const std::string& name, const std::string& data, const std::
|
||||||
UniValue results = rpc_method(req);
|
UniValue results = rpc_method(req);
|
||||||
auto txid = results.get_str();
|
auto txid = results.get_str();
|
||||||
uint256 ret;
|
uint256 ret;
|
||||||
|
if (txid.find(' ') != std::string::npos) {
|
||||||
|
fprintf(stderr, "Error creating claim: %s\n", txid.c_str());
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
ret.SetHex(txid);
|
ret.SetHex(txid);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -468,5 +472,24 @@ BOOST_AUTO_TEST_CASE(can_sign_all_pbst)
|
||||||
BOOST_CHECK_EQUAL(looked.size(), 0U);
|
BOOST_CHECK_EQUAL(looked.size(), 0U);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(can_claim_after_each_fork)
|
||||||
|
{
|
||||||
|
generateBlock(140);
|
||||||
|
auto txid = ClaimAName("tester", "deadbeef", "1.0");
|
||||||
|
BOOST_CHECK(!txid.IsNull());
|
||||||
|
generateBlock(100);
|
||||||
|
txid = ClaimAName("tester2", "deadbeef", "1.0");
|
||||||
|
BOOST_CHECK(!txid.IsNull());
|
||||||
|
generateBlock(100);
|
||||||
|
txid = ClaimAName("tester3", "deadbeef", "10.0");
|
||||||
|
BOOST_CHECK(!txid.IsNull());
|
||||||
|
generateBlock(15);
|
||||||
|
txid = ClaimAName("tester4", "deadbeef", "10.0");
|
||||||
|
BOOST_CHECK(!txid.IsNull());
|
||||||
|
generateBlock(1);
|
||||||
|
auto looked = LookupAllNames().get_array();
|
||||||
|
BOOST_CHECK_EQUAL(looked.size(), 4U);
|
||||||
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE_END()
|
BOOST_AUTO_TEST_SUITE_END()
|
||||||
|
|
||||||
|
|
|
@ -2985,6 +2985,7 @@ bool CWallet::CreateTransaction(const std::vector<CRecipient>& vecSend, CTransac
|
||||||
if (nChangePosInOut == -1 && nSubtractFeeFromAmount == 0 && pick_new_inputs) {
|
if (nChangePosInOut == -1 && nSubtractFeeFromAmount == 0 && pick_new_inputs) {
|
||||||
unsigned int tx_size_with_change = nBytes + coin_selection_params.change_output_size + 2; // Add 2 as a buffer in case increasing # of outputs changes compact size
|
unsigned int tx_size_with_change = nBytes + coin_selection_params.change_output_size + 2; // Add 2 as a buffer in case increasing # of outputs changes compact size
|
||||||
CAmount fee_needed_with_change = GetMinimumFee(*this, tx_size_with_change, coin_control, ::mempool, ::feeEstimator, nullptr);
|
CAmount fee_needed_with_change = GetMinimumFee(*this, tx_size_with_change, coin_control, ::mempool, ::feeEstimator, nullptr);
|
||||||
|
fee_needed_with_change = std::max(minClaimTrieFee, fee_needed_with_change);
|
||||||
CAmount minimum_value_for_change = GetDustThreshold(change_prototype_txout, discard_rate);
|
CAmount minimum_value_for_change = GetDustThreshold(change_prototype_txout, discard_rate);
|
||||||
if (nFeeRet >= fee_needed_with_change + minimum_value_for_change) {
|
if (nFeeRet >= fee_needed_with_change + minimum_value_for_change) {
|
||||||
pick_new_inputs = false;
|
pick_new_inputs = false;
|
||||||
|
|
Loading…
Reference in a new issue