Skip to content

Commit faac315

Browse files
author
MarcoFalke
committed
Remove unused and confusing CTransaction constructor
1 parent eab63b9 commit faac315

File tree

5 files changed

+5
-11
lines changed

5 files changed

+5
-11
lines changed

src/primitives/transaction.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,6 @@ uint256 CTransaction::ComputeWitnessHash() const
7777
return SerializeHash(*this, SER_GETHASH, 0);
7878
}
7979

80-
/* For backward compatibility, the hash is initialized to 0. TODO: remove the need for this default constructor entirely. */
81-
CTransaction::CTransaction() : vin(), vout(), nVersion(CTransaction::CURRENT_VERSION), nLockTime(0), hash{}, m_witness_hash{} {}
8280
CTransaction::CTransaction(const CMutableTransaction& tx) : vin(tx.vin), vout(tx.vout), nVersion(tx.nVersion), nLockTime(tx.nLockTime), hash{ComputeHash()}, m_witness_hash{ComputeWitnessHash()} {}
8381
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()} {}
8482

src/primitives/transaction.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -287,12 +287,9 @@ class CTransaction
287287
uint256 ComputeWitnessHash() const;
288288

289289
public:
290-
/** Construct a CTransaction that qualifies as IsNull() */
291-
CTransaction();
292-
293290
/** Convert a CMutableTransaction into a CTransaction. */
294-
explicit CTransaction(const CMutableTransaction &tx);
295-
CTransaction(CMutableTransaction &&tx);
291+
explicit CTransaction(const CMutableTransaction& tx);
292+
CTransaction(CMutableTransaction&& tx);
296293

297294
template <typename Stream>
298295
inline void Serialize(Stream& s) const {
@@ -393,7 +390,6 @@ struct CMutableTransaction
393390
};
394391

395392
typedef std::shared_ptr<const CTransaction> CTransactionRef;
396-
static inline CTransactionRef MakeTransactionRef() { return std::make_shared<const CTransaction>(); }
397393
template <typename Tx> static inline CTransactionRef MakeTransactionRef(Tx&& txIn) { return std::make_shared<const CTransaction>(std::forward<Tx>(txIn)); }
398394

399395
/** A generic txid reference (txid or wtxid). */

src/test/fuzz/script_sigcache.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ void test_one_input(const std::vector<uint8_t>& buffer)
2929
FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
3030

3131
const std::optional<CMutableTransaction> mutable_transaction = ConsumeDeserializable<CMutableTransaction>(fuzzed_data_provider);
32-
const CTransaction tx = mutable_transaction ? CTransaction{*mutable_transaction} : CTransaction{};
32+
const CTransaction tx{mutable_transaction ? *mutable_transaction : CMutableTransaction{}};
3333
const unsigned int n_in = fuzzed_data_provider.ConsumeIntegral<unsigned int>();
3434
const CAmount amount = ConsumeMoney(fuzzed_data_provider);
3535
const bool store = fuzzed_data_provider.ConsumeBool();

src/test/fuzz/transaction.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ void test_one_input(const std::vector<uint8_t>& buffer)
4242
return CTransaction(deserialize, ds);
4343
} catch (const std::ios_base::failure&) {
4444
valid_tx = false;
45-
return CTransaction();
45+
return CTransaction{CMutableTransaction{}};
4646
}
4747
}();
4848
bool valid_mutable_tx = true;

src/wallet/feebumper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ Result CreateRateBumpTransaction(CWallet& wallet, const uint256& txid, const CCo
215215
// We cannot source new unconfirmed inputs(bip125 rule 2)
216216
new_coin_control.m_min_depth = 1;
217217

218-
CTransactionRef tx_new = MakeTransactionRef();
218+
CTransactionRef tx_new;
219219
CAmount fee_ret;
220220
int change_pos_in_out = -1; // No requested location for change
221221
bilingual_str fail_reason;

0 commit comments

Comments
 (0)