mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-18 22:35:39 +01:00
refactor: move normalization to new function
Move the univalue formatting logic out of AddOutputs and into its own function, `NormalizeOutputs`. This allows us to re-use this logic in later commits.
This commit is contained in:
@@ -70,7 +70,7 @@ void AddInputs(CMutableTransaction& rawTx, const UniValue& inputs_in, std::optio
|
||||
}
|
||||
}
|
||||
|
||||
void AddOutputs(CMutableTransaction& rawTx, const UniValue& outputs_in)
|
||||
UniValue NormalizeOutputs(const UniValue& outputs_in)
|
||||
{
|
||||
if (outputs_in.isNull()) {
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, output argument must be non-null");
|
||||
@@ -94,6 +94,13 @@ void AddOutputs(CMutableTransaction& rawTx, const UniValue& outputs_in)
|
||||
}
|
||||
outputs = std::move(outputs_dict);
|
||||
}
|
||||
return outputs;
|
||||
}
|
||||
|
||||
void AddOutputs(CMutableTransaction& rawTx, const UniValue& outputs_in)
|
||||
{
|
||||
UniValue outputs(UniValue::VOBJ);
|
||||
outputs = NormalizeOutputs(outputs_in);
|
||||
|
||||
// Duplicate checking
|
||||
std::set<CTxDestination> destinations;
|
||||
|
||||
@@ -42,7 +42,10 @@ void ParsePrevouts(const UniValue& prevTxsUnival, FillableSigningProvider* keyst
|
||||
/** Normalize univalue-represented inputs and add them to the transaction */
|
||||
void AddInputs(CMutableTransaction& rawTx, const UniValue& inputs_in, bool rbf);
|
||||
|
||||
/** Normalize univalue-represented outputs and add them to the transaction */
|
||||
/** Normalize univalue-represented outputs */
|
||||
UniValue NormalizeOutputs(const UniValue& outputs_in);
|
||||
|
||||
/** Normalize, parse, and add outputs to the transaction */
|
||||
void AddOutputs(CMutableTransaction& rawTx, const UniValue& outputs_in);
|
||||
|
||||
/** Create a transaction from univalue parameters */
|
||||
|
||||
Reference in New Issue
Block a user