merge bitcoin#14906: Make explicit CMutableTransaction -> CTransaction conversion

This commit is contained in:
Kittywhiskers Van Gogh 2021-10-11 20:36:49 +05:30
parent b50aab204d
commit ee705af2cd
9 changed files with 15 additions and 15 deletions

View File

@ -491,7 +491,7 @@ bool CCoinJoinClientSession::SendDenominate(const std::vector<std::pair<CTxDSIn,
// store our entry for later use // store our entry for later use
LOCK(cs_coinjoin); LOCK(cs_coinjoin);
vecEntries.emplace_back(vecTxDSInTmp, vecTxOutTmp, txMyCollateral); vecEntries.emplace_back(vecTxDSInTmp, vecTxOutTmp, CTransaction(txMyCollateral));
RelayIn(vecEntries.back(), connman); RelayIn(vecEntries.back(), connman);
nTimeLastSuccessfulStep = GetTime(); nTimeLastSuccessfulStep = GetTime();
@ -923,7 +923,7 @@ bool CCoinJoinClientSession::DoAutomaticDenominating(CConnman& connman, bool fDr
return false; return false;
} }
} else { } else {
if (!CCoinJoin::IsCollateralValid(txMyCollateral)) { if (!CCoinJoin::IsCollateralValid(CTransaction(txMyCollateral))) {
LogPrint(BCLog::COINJOIN, "CCoinJoinClientSession::DoAutomaticDenominating -- invalid collateral, recreating...\n"); LogPrint(BCLog::COINJOIN, "CCoinJoinClientSession::DoAutomaticDenominating -- invalid collateral, recreating...\n");
if (!CreateCollateralTransaction(txMyCollateral, strReason)) { if (!CreateCollateralTransaction(txMyCollateral, strReason)) {
LogPrint(BCLog::COINJOIN, "CCoinJoinClientSession::DoAutomaticDenominating -- create collateral error: %s\n", strReason); LogPrint(BCLog::COINJOIN, "CCoinJoinClientSession::DoAutomaticDenominating -- create collateral error: %s\n", strReason);

View File

@ -324,7 +324,7 @@ void CCoinJoinServer::CreateFinalTransaction(CConnman& connman)
// request signatures from clients // request signatures from clients
SetState(POOL_STATE_SIGNING); SetState(POOL_STATE_SIGNING);
RelayFinalTransaction(finalMutableTransaction, connman); RelayFinalTransaction(CTransaction(finalMutableTransaction), connman);
} }
void CCoinJoinServer::CommitFinalTransaction(CConnman& connman) void CCoinJoinServer::CommitFinalTransaction(CConnman& connman)
@ -701,7 +701,7 @@ bool CCoinJoinServer::IsAcceptableDSA(const CCoinJoinAccept& dsa, PoolMessage& n
} }
// check collateral // check collateral
if (!fUnitTest && !CCoinJoin::IsCollateralValid(dsa.txCollateral)) { if (!fUnitTest && !CCoinJoin::IsCollateralValid(CTransaction(dsa.txCollateral))) {
LogPrint(BCLog::COINJOIN, "CCoinJoinServer::%s -- collateral not valid!\n", __func__); LogPrint(BCLog::COINJOIN, "CCoinJoinServer::%s -- collateral not valid!\n", __func__);
nMessageIDRet = ERR_INVALID_COLLATERAL; nMessageIDRet = ERR_INVALID_COLLATERAL;
return false; return false;

View File

@ -137,7 +137,7 @@ CTransactionBuilder::CTransactionBuilder(std::shared_ptr<CWallet> pwalletIn, con
dummyBatch.TxnAbort(); dummyBatch.TxnAbort();
dummyScript = ::GetScriptForDestination(dummyPubkey.GetID()); dummyScript = ::GetScriptForDestination(dummyPubkey.GetID());
// Calculate required bytes for the dummy signed tx with tallyItem's inputs only // Calculate required bytes for the dummy signed tx with tallyItem's inputs only
nBytesBase = CalculateMaximumSignedTxSize(dummyTx, pwallet.get(), false); nBytesBase = CalculateMaximumSignedTxSize(CTransaction(dummyTx), pwallet.get(), false);
} }
// Calculate the output size // Calculate the output size
nBytesOutput = ::GetSerializeSize(CTxOut(0, dummyScript), SER_NETWORK, PROTOCOL_VERSION); nBytesOutput = ::GetSerializeSize(CTxOut(0, dummyScript), SER_NETWORK, PROTOCOL_VERSION);

View File

@ -772,7 +772,7 @@ static int CommandLineRawTx(int argc, char* argv[])
MutateTx(tx, key, value); MutateTx(tx, key, value);
} }
OutputTx(tx); OutputTx(CTransaction(tx));
} }
catch (const std::exception& e) { catch (const std::exception& e) {
strPrint = std::string("error: ") + e.what(); strPrint = std::string("error: ") + e.what();

View File

@ -211,7 +211,7 @@ public:
CTransaction(); CTransaction();
/** Convert a CMutableTransaction into a CTransaction. */ /** Convert a CMutableTransaction into a CTransaction. */
CTransaction(const CMutableTransaction &tx); explicit CTransaction(const CMutableTransaction &tx);
CTransaction(CMutableTransaction &&tx); CTransaction(CMutableTransaction &&tx);
template <typename Stream> template <typename Stream>

View File

@ -543,7 +543,7 @@ static UniValue createrawtransaction(const JSONRPCRequest& request)
CMutableTransaction rawTx = ConstructTransaction(request.params[0], request.params[1], request.params[2]); CMutableTransaction rawTx = ConstructTransaction(request.params[0], request.params[1], request.params[2]);
return EncodeHexTx(rawTx); return EncodeHexTx(CTransaction(rawTx));
} }
static UniValue decoderawtransaction(const JSONRPCRequest& request) static UniValue decoderawtransaction(const JSONRPCRequest& request)
@ -765,7 +765,7 @@ static UniValue combinerawtransaction(const JSONRPCRequest& request)
UpdateInput(txin, sigdata); UpdateInput(txin, sigdata);
} }
return EncodeHexTx(mergedTx); return EncodeHexTx(CTransaction(mergedTx));
} }
UniValue SignTransaction(CMutableTransaction& mtx, const UniValue& prevTxsUnival, CBasicKeyStore *keystore, bool is_temp_keystore, const UniValue& hashType) UniValue SignTransaction(CMutableTransaction& mtx, const UniValue& prevTxsUnival, CBasicKeyStore *keystore, bool is_temp_keystore, const UniValue& hashType)
@ -891,7 +891,7 @@ UniValue SignTransaction(CMutableTransaction& mtx, const UniValue& prevTxsUnival
bool fComplete = vErrors.empty(); bool fComplete = vErrors.empty();
UniValue result(UniValue::VOBJ); UniValue result(UniValue::VOBJ);
result.pushKV("hex", EncodeHexTx(mtx)); result.pushKV("hex", EncodeHexTx(CTransaction(mtx)));
result.pushKV("complete", fComplete); result.pushKV("complete", fComplete);
if (!vErrors.empty()) { if (!vErrors.empty()) {
result.pushKV("errors", vErrors); result.pushKV("errors", vErrors);

View File

@ -234,7 +234,7 @@ static void FundSpecialTx(CWallet* pwallet, CMutableTransaction& tx, const Speci
template<typename SpecialTxPayload> template<typename SpecialTxPayload>
static void UpdateSpecialTxInputsHash(const CMutableTransaction& tx, SpecialTxPayload& payload) static void UpdateSpecialTxInputsHash(const CMutableTransaction& tx, SpecialTxPayload& payload)
{ {
payload.inputsHash = CalcTxInputsHash(tx); payload.inputsHash = CalcTxInputsHash(CTransaction(tx));
} }
template<typename SpecialTxPayload> template<typename SpecialTxPayload>
@ -276,7 +276,7 @@ static std::string SignAndSendSpecialTx(const CMutableTransaction& tx, bool fSub
LOCK(cs_main); LOCK(cs_main);
CValidationState state; CValidationState state;
if (!CheckSpecialTx(tx, chainActive.Tip(), state, *pcoinsTip.get())) { if (!CheckSpecialTx(CTransaction(tx), chainActive.Tip(), state, *pcoinsTip.get())) {
throw std::runtime_error(FormatStateMessage(state)); throw std::runtime_error(FormatStateMessage(state));
} }
} // cs_main } // cs_main
@ -549,7 +549,7 @@ static UniValue protx_register(const JSONRPCRequest& request)
SetTxPayload(tx, ptx); SetTxPayload(tx, ptx);
UniValue ret(UniValue::VOBJ); UniValue ret(UniValue::VOBJ);
ret.pushKV("tx", EncodeHexTx(tx)); ret.pushKV("tx", EncodeHexTx(CTransaction(tx)));
ret.pushKV("collateralAddress", EncodeDestination(txDest)); ret.pushKV("collateralAddress", EncodeDestination(txDest));
ret.pushKV("signMessage", ptx.MakeSignString()); ret.pushKV("signMessage", ptx.MakeSignString());
return ret; return ret;

View File

@ -3326,7 +3326,7 @@ static UniValue fundrawtransaction(const JSONRPCRequest& request)
FundTransaction(pwallet, tx, fee, change_position, request.params[1]); FundTransaction(pwallet, tx, fee, change_position, request.params[1]);
UniValue result(UniValue::VOBJ); UniValue result(UniValue::VOBJ);
result.pushKV("hex", EncodeHexTx(tx)); result.pushKV("hex", EncodeHexTx(CTransaction(tx)));
result.pushKV("fee", ValueFromAmount(fee)); result.pushKV("fee", ValueFromAmount(fee));
result.pushKV("changepos", change_position); result.pushKV("changepos", change_position);

View File

@ -3681,7 +3681,7 @@ bool CWallet::CreateTransaction(const std::vector<CRecipient>& vecSend, CTransac
auto calculateFee = [&](CAmount& nFee) -> bool { auto calculateFee = [&](CAmount& nFee) -> bool {
AssertLockHeld(cs_wallet); AssertLockHeld(cs_wallet);
nBytes = CalculateMaximumSignedTxSize(txNew, this, coin_control.fAllowWatchOnly); nBytes = CalculateMaximumSignedTxSize(CTransaction(txNew), this, coin_control.fAllowWatchOnly);
if (nBytes < 0) { if (nBytes < 0) {
strFailReason = _("Signing transaction failed"); strFailReason = _("Signing transaction failed");
return false; return false;