MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / ParseOutputs

Function ParseOutputs

src/rpc/rawtransaction_util.cpp:102–132  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

100}
101
102std::vector<std::pair<CTxDestination, CAmount>> ParseOutputs(const UniValue& outputs)
103{
104 // Duplicate checking
105 std::set<CTxDestination> destinations;
106 std::vector<std::pair<CTxDestination, CAmount>> parsed_outputs;
107 bool has_data{false};
108 for (const std::string& name_ : outputs.getKeys()) {
109 if (name_ == "data") {
110 if (has_data) {
111 throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, duplicate key: data");
112 }
113 has_data = true;
114 std::vector<unsigned char> data = ParseHexV(outputs[name_].getValStr(), "Data");
115 CTxDestination destination{CNoDestination{CScript() << OP_RETURN << data}};
116 CAmount amount{0};
117 parsed_outputs.emplace_back(destination, amount);
118 } else {
119 CTxDestination destination{DecodeDestination(name_)};
120 CAmount amount{AmountFromValue(outputs[name_])};
121 if (!IsValidDestination(destination)) {
122 throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, std::string("Invalid Bitcoin address: ") + name_);
123 }
124
125 if (!destinations.insert(destination).second) {
126 throw JSONRPCError(RPC_INVALID_PARAMETER, std::string("Invalid parameter, duplicated address: ") + name_);
127 }
128 parsed_outputs.emplace_back(destination, amount);
129 }
130 }
131 return parsed_outputs;
132}
133
134void AddOutputs(CMutableTransaction& rawTx, const UniValue& outputs_in)
135{

Callers 5

sendtoaddressFunction · 0.85
sendmanyFunction · 0.85
sendFunction · 0.85
walletcreatefundedpsbtFunction · 0.85
AddOutputsFunction · 0.85

Calls 8

JSONRPCErrorFunction · 0.85
ParseHexVFunction · 0.85
DecodeDestinationFunction · 0.85
IsValidDestinationFunction · 0.85
CScriptClass · 0.70
AmountFromValueFunction · 0.70
emplace_backMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected