Skip to content

Commit 6f569ac

Browse files
committed
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.
1 parent 435fe5c commit 6f569ac

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/rpc/rawtransaction_util.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ void AddInputs(CMutableTransaction& rawTx, const UniValue& inputs_in, std::optio
7070
}
7171
}
7272

73-
void AddOutputs(CMutableTransaction& rawTx, const UniValue& outputs_in)
73+
UniValue NormalizeOutputs(const UniValue& outputs_in)
7474
{
7575
if (outputs_in.isNull()) {
7676
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)
9494
}
9595
outputs = std::move(outputs_dict);
9696
}
97+
return outputs;
98+
}
99+
100+
void AddOutputs(CMutableTransaction& rawTx, const UniValue& outputs_in)
101+
{
102+
UniValue outputs(UniValue::VOBJ);
103+
outputs = NormalizeOutputs(outputs_in);
97104

98105
// Duplicate checking
99106
std::set<CTxDestination> destinations;

src/rpc/rawtransaction_util.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ void ParsePrevouts(const UniValue& prevTxsUnival, FillableSigningProvider* keyst
4242
/** Normalize univalue-represented inputs and add them to the transaction */
4343
void AddInputs(CMutableTransaction& rawTx, const UniValue& inputs_in, bool rbf);
4444

45-
/** Normalize univalue-represented outputs and add them to the transaction */
45+
/** Normalize univalue-represented outputs */
46+
UniValue NormalizeOutputs(const UniValue& outputs_in);
47+
48+
/** Normalize, parse, and add outputs to the transaction */
4649
void AddOutputs(CMutableTransaction& rawTx, const UniValue& outputs_in);
4750

4851
/** Create a transaction from univalue parameters */

0 commit comments

Comments
 (0)