mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 15:09:59 +01:00
Remove unused and confusing CTransaction constructor
This commit is contained in:
@@ -77,8 +77,6 @@ uint256 CTransaction::ComputeWitnessHash() const
|
|||||||
return SerializeHash(*this, SER_GETHASH, 0);
|
return SerializeHash(*this, SER_GETHASH, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* For backward compatibility, the hash is initialized to 0. TODO: remove the need for this default constructor entirely. */
|
|
||||||
CTransaction::CTransaction() : vin(), vout(), nVersion(CTransaction::CURRENT_VERSION), nLockTime(0), hash{}, m_witness_hash{} {}
|
|
||||||
CTransaction::CTransaction(const CMutableTransaction& tx) : vin(tx.vin), vout(tx.vout), nVersion(tx.nVersion), nLockTime(tx.nLockTime), hash{ComputeHash()}, m_witness_hash{ComputeWitnessHash()} {}
|
CTransaction::CTransaction(const CMutableTransaction& tx) : vin(tx.vin), vout(tx.vout), nVersion(tx.nVersion), nLockTime(tx.nLockTime), hash{ComputeHash()}, m_witness_hash{ComputeWitnessHash()} {}
|
||||||
CTransaction::CTransaction(CMutableTransaction&& tx) : vin(std::move(tx.vin)), vout(std::move(tx.vout)), nVersion(tx.nVersion), nLockTime(tx.nLockTime), hash{ComputeHash()}, m_witness_hash{ComputeWitnessHash()} {}
|
CTransaction::CTransaction(CMutableTransaction&& tx) : vin(std::move(tx.vin)), vout(std::move(tx.vout)), nVersion(tx.nVersion), nLockTime(tx.nLockTime), hash{ComputeHash()}, m_witness_hash{ComputeWitnessHash()} {}
|
||||||
|
|
||||||
|
|||||||
@@ -287,12 +287,9 @@ private:
|
|||||||
uint256 ComputeWitnessHash() const;
|
uint256 ComputeWitnessHash() const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/** Construct a CTransaction that qualifies as IsNull() */
|
|
||||||
CTransaction();
|
|
||||||
|
|
||||||
/** Convert a CMutableTransaction into a CTransaction. */
|
/** Convert a CMutableTransaction into a CTransaction. */
|
||||||
explicit CTransaction(const CMutableTransaction &tx);
|
explicit CTransaction(const CMutableTransaction& tx);
|
||||||
CTransaction(CMutableTransaction &&tx);
|
CTransaction(CMutableTransaction&& tx);
|
||||||
|
|
||||||
template <typename Stream>
|
template <typename Stream>
|
||||||
inline void Serialize(Stream& s) const {
|
inline void Serialize(Stream& s) const {
|
||||||
@@ -393,7 +390,6 @@ struct CMutableTransaction
|
|||||||
};
|
};
|
||||||
|
|
||||||
typedef std::shared_ptr<const CTransaction> CTransactionRef;
|
typedef std::shared_ptr<const CTransaction> CTransactionRef;
|
||||||
static inline CTransactionRef MakeTransactionRef() { return std::make_shared<const CTransaction>(); }
|
|
||||||
template <typename Tx> static inline CTransactionRef MakeTransactionRef(Tx&& txIn) { return std::make_shared<const CTransaction>(std::forward<Tx>(txIn)); }
|
template <typename Tx> static inline CTransactionRef MakeTransactionRef(Tx&& txIn) { return std::make_shared<const CTransaction>(std::forward<Tx>(txIn)); }
|
||||||
|
|
||||||
/** A generic txid reference (txid or wtxid). */
|
/** A generic txid reference (txid or wtxid). */
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ void test_one_input(const std::vector<uint8_t>& buffer)
|
|||||||
FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
|
FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
|
||||||
|
|
||||||
const std::optional<CMutableTransaction> mutable_transaction = ConsumeDeserializable<CMutableTransaction>(fuzzed_data_provider);
|
const std::optional<CMutableTransaction> mutable_transaction = ConsumeDeserializable<CMutableTransaction>(fuzzed_data_provider);
|
||||||
const CTransaction tx = mutable_transaction ? CTransaction{*mutable_transaction} : CTransaction{};
|
const CTransaction tx{mutable_transaction ? *mutable_transaction : CMutableTransaction{}};
|
||||||
const unsigned int n_in = fuzzed_data_provider.ConsumeIntegral<unsigned int>();
|
const unsigned int n_in = fuzzed_data_provider.ConsumeIntegral<unsigned int>();
|
||||||
const CAmount amount = ConsumeMoney(fuzzed_data_provider);
|
const CAmount amount = ConsumeMoney(fuzzed_data_provider);
|
||||||
const bool store = fuzzed_data_provider.ConsumeBool();
|
const bool store = fuzzed_data_provider.ConsumeBool();
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ void test_one_input(const std::vector<uint8_t>& buffer)
|
|||||||
return CTransaction(deserialize, ds);
|
return CTransaction(deserialize, ds);
|
||||||
} catch (const std::ios_base::failure&) {
|
} catch (const std::ios_base::failure&) {
|
||||||
valid_tx = false;
|
valid_tx = false;
|
||||||
return CTransaction();
|
return CTransaction{CMutableTransaction{}};
|
||||||
}
|
}
|
||||||
}();
|
}();
|
||||||
bool valid_mutable_tx = true;
|
bool valid_mutable_tx = true;
|
||||||
|
|||||||
@@ -215,7 +215,7 @@ Result CreateRateBumpTransaction(CWallet& wallet, const uint256& txid, const CCo
|
|||||||
// We cannot source new unconfirmed inputs(bip125 rule 2)
|
// We cannot source new unconfirmed inputs(bip125 rule 2)
|
||||||
new_coin_control.m_min_depth = 1;
|
new_coin_control.m_min_depth = 1;
|
||||||
|
|
||||||
CTransactionRef tx_new = MakeTransactionRef();
|
CTransactionRef tx_new;
|
||||||
CAmount fee_ret;
|
CAmount fee_ret;
|
||||||
int change_pos_in_out = -1; // No requested location for change
|
int change_pos_in_out = -1; // No requested location for change
|
||||||
bilingual_str fail_reason;
|
bilingual_str fail_reason;
|
||||||
|
|||||||
Reference in New Issue
Block a user