mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-18 13:17:55 +02:00
Merge ade38b6ee8 into merged_master (Bitcoin PR #20588)
o.O apparently the `tx_aux` argument to `createrawpegin` was literally unused
This commit is contained in:
commit
939d8ee135
7 changed files with 12 additions and 19 deletions
|
|
@ -116,8 +116,6 @@ uint256 CTransaction::GetWitnessOnlyHash() const
|
|||
return ComputeFastMerkleRoot(leaves);
|
||||
}
|
||||
|
||||
/* 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), witness(tx.witness), hash{ComputeHash()}, m_witness_hash{ComputeWitnessHash()} {}
|
||||
CTransaction::CTransaction(CMutableTransaction&& tx) :
|
||||
|
|
|
|||
|
|
@ -506,12 +506,9 @@ private:
|
|||
uint256 ComputeWitnessHash() const;
|
||||
|
||||
public:
|
||||
/** Construct a CTransaction that qualifies as IsNull() */
|
||||
CTransaction();
|
||||
|
||||
/** Convert a CMutableTransaction into a CTransaction. */
|
||||
explicit CTransaction(const CMutableTransaction &tx);
|
||||
CTransaction(CMutableTransaction &&tx);
|
||||
explicit CTransaction(const CMutableTransaction& tx);
|
||||
CTransaction(CMutableTransaction&& tx);
|
||||
|
||||
template <typename Stream>
|
||||
inline void Serialize(Stream& s) const {
|
||||
|
|
@ -606,7 +603,6 @@ struct CMutableTransaction
|
|||
};
|
||||
|
||||
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)); }
|
||||
|
||||
/** 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());
|
||||
|
||||
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 CAmount amount = ConsumeMoney(fuzzed_data_provider);
|
||||
const bool store = fuzzed_data_provider.ConsumeBool();
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ void test_one_input(const std::vector<uint8_t>& buffer)
|
|||
return CTransaction(mtx);
|
||||
} catch (const std::ios_base::failure&) {
|
||||
valid_tx = false;
|
||||
return CTransaction();
|
||||
return CTransaction{CMutableTransaction{}};
|
||||
}
|
||||
}();
|
||||
bool valid_mutable_tx = true;
|
||||
|
|
|
|||
|
|
@ -232,7 +232,7 @@ Result CreateRateBumpTransaction(CWallet& wallet, const uint256& txid, const CCo
|
|||
// We cannot source new unconfirmed inputs(bip125 rule 2)
|
||||
new_coin_control.m_min_depth = 1;
|
||||
|
||||
CTransactionRef tx_new = MakeTransactionRef();
|
||||
CTransactionRef tx_new;
|
||||
CAmount fee_ret;
|
||||
int change_pos_in_out = -1; // No requested location for change
|
||||
bilingual_str fail_reason;
|
||||
|
|
|
|||
|
|
@ -5868,8 +5868,8 @@ static RPCHelpMan sendtomainchain()
|
|||
extern UniValue signrawtransaction(const JSONRPCRequest& request);
|
||||
extern UniValue sendrawtransaction(const JSONRPCRequest& request);
|
||||
|
||||
template<typename T_tx_ref, typename T_tx, typename T_merkle_block>
|
||||
static UniValue createrawpegin(const JSONRPCRequest& request, T_tx_ref& txBTCRef, T_tx& tx_aux, T_merkle_block& merkleBlock)
|
||||
template<typename T_tx_ref, typename T_merkle_block>
|
||||
static UniValue createrawpegin(const JSONRPCRequest& request, T_tx_ref& txBTCRef, T_merkle_block& merkleBlock)
|
||||
{
|
||||
std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(request);
|
||||
if (!wallet) return NullUniValue;
|
||||
|
|
@ -5990,17 +5990,15 @@ static RPCHelpMan createrawpegin()
|
|||
UniValue ret(UniValue::VOBJ);
|
||||
if (Params().GetConsensus().ParentChainHasPow()) {
|
||||
Sidechain::Bitcoin::CTransactionRef txBTCRef;
|
||||
Sidechain::Bitcoin::CTransaction tx_aux;
|
||||
Sidechain::Bitcoin::CMerkleBlock merkleBlock;
|
||||
ret = createrawpegin(request, txBTCRef, tx_aux, merkleBlock);
|
||||
ret = createrawpegin(request, txBTCRef, merkleBlock);
|
||||
if (!CheckParentProofOfWork(merkleBlock.header.GetHash(), merkleBlock.header.nBits, Params().GetConsensus())) {
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid tx out proof");
|
||||
}
|
||||
} else {
|
||||
CTransactionRef txBTCRef;
|
||||
CTransaction tx_aux;
|
||||
CMerkleBlock merkleBlock;
|
||||
ret = createrawpegin(request, txBTCRef, tx_aux, merkleBlock);
|
||||
ret = createrawpegin(request, txBTCRef, merkleBlock);
|
||||
if (!CheckProofSignedParent(merkleBlock.header, Params().GetConsensus())) {
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid tx out proof");
|
||||
}
|
||||
|
|
@ -6455,7 +6453,7 @@ static CTransactionRef SendGenerationTransaction(const CScript& asset_script, co
|
|||
FeeCalculation fee_calc_out;
|
||||
CCoinControl dummy_control;
|
||||
BlindDetails blind_details;
|
||||
CTransactionRef tx_ref(MakeTransactionRef());
|
||||
CTransactionRef tx_ref;
|
||||
if (!pwallet->CreateTransaction(vecSend, tx_ref, nFeeRequired, nChangePosRet, error, dummy_control, fee_calc_out, true, &blind_details, issuance_details)) {
|
||||
throw JSONRPCError(RPC_WALLET_ERROR, error.original);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4003,13 +4003,14 @@ bool CWallet::CreateTransaction(
|
|||
const IssuanceDetails* issuance_details)
|
||||
{
|
||||
int nChangePosIn = nChangePosInOut;
|
||||
CTransactionRef tx2 = tx;
|
||||
Assert(!tx); // tx is an out-param. TODO change the return type from bool to tx (or nullptr)
|
||||
bool res = CreateTransactionInternal(vecSend, tx, nFeeRet, nChangePosInOut, error, coin_control, fee_calc_out, sign, blind_details, issuance_details);
|
||||
// try with avoidpartialspends unless it's enabled already
|
||||
if (res && nFeeRet > 0 /* 0 means non-functional fee rate estimation */ && m_max_aps_fee > -1 && !coin_control.m_avoid_partial_spends) {
|
||||
CCoinControl tmp_cc = coin_control;
|
||||
tmp_cc.m_avoid_partial_spends = true;
|
||||
CAmount nFeeRet2;
|
||||
CTransactionRef tx2;
|
||||
int nChangePosInOut2 = nChangePosIn;
|
||||
bilingual_str error2; // fired and forgotten; if an error occurs, we discard the results
|
||||
BlindDetails blind_details2;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue