diff --git a/src/nameclaim.h b/src/nameclaim.h index f865f0540..47ebbaf12 100644 --- a/src/nameclaim.h +++ b/src/nameclaim.h @@ -11,7 +11,7 @@ // 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. // 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 // empty nodes do not take up any memory and the minimum fee can be priced on a per claim // basis. diff --git a/src/versionbits.cpp b/src/versionbits.cpp index 49ef3cbcc..cf1cedc72 100644 --- a/src/versionbits.cpp +++ b/src/versionbits.cpp @@ -188,9 +188,10 @@ public: ThresholdState VersionBitsState(const CBlockIndex* pindexPrev, const Consensus::Params& params, Consensus::DeploymentPos pos, VersionBitsCache& cache) { // Check if we've past a hardfork state for segwit. - if ((pos == Consensus::DEPLOYMENT_SEGWIT) && (pindexPrev != nullptr) && - (pindexPrev->nHeight + 1 >= params.nWitnessForkHeight)) - return ThresholdState::ACTIVE; + if (pos == Consensus::DEPLOYMENT_SEGWIT) { + return pindexPrev != nullptr && pindexPrev->nHeight + 1 >= params.nWitnessForkHeight ? + ThresholdState::ACTIVE : ThresholdState::FAILED; + } return VersionBitsConditionChecker(pos).GetStateFor(pindexPrev, params, cache.caches[pos]); } diff --git a/src/wallet/test/claim_rpc_tests.cpp b/src/wallet/test/claim_rpc_tests.cpp index 8c309d7ed..1c99c165b 100644 --- a/src/wallet/test/claim_rpc_tests.cpp +++ b/src/wallet/test/claim_rpc_tests.cpp @@ -63,6 +63,10 @@ uint256 ClaimAName(const std::string& name, const std::string& data, const std:: UniValue results = rpc_method(req); auto txid = results.get_str(); uint256 ret; + if (txid.find(' ') != std::string::npos) { + fprintf(stderr, "Error creating claim: %s\n", txid.c_str()); + return ret; + } ret.SetHex(txid); return ret; } @@ -468,5 +472,24 @@ BOOST_AUTO_TEST_CASE(can_sign_all_pbst) 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() diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 901fdecb3..663195421 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -3218,6 +3218,7 @@ bool CWallet::CreateTransaction(interfaces::Chain::Lock& locked_chain, const std 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 CAmount fee_needed_with_change = GetMinimumFee(*this, tx_size_with_change, coin_control, nullptr); + fee_needed_with_change = std::max(minClaimTrieFee, fee_needed_with_change); CAmount minimum_value_for_change = GetDustThreshold(change_prototype_txout, discard_rate); if (nFeeRet >= fee_needed_with_change + minimum_value_for_change) { pick_new_inputs = false;