MCPcopy Create free account
hub / github.com/ElementsProject/elements / AddAndGetMultisigDestination

Function AddAndGetMultisigDestination

src/rpc/util.cpp:241–272  ·  view source on GitHub ↗

Creates a multisig address from a given list of public keys, number of signatures required, and the address type

Source from the content-addressed store, hash-verified

239
240// Creates a multisig address from a given list of public keys, number of signatures required, and the address type
241CTxDestination AddAndGetMultisigDestination(const int required, const std::vector<CPubKey>& pubkeys, OutputType type, FillableSigningProvider& keystore, CScript& script_out)
242{
243 // Gather public keys
244 if (required < 1) {
245 throw JSONRPCError(RPC_INVALID_PARAMETER, "a multisignature address must require at least one key to redeem");
246 }
247 if ((int)pubkeys.size() < required) {
248 throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("not enough keys supplied (got %u keys, but need at least %d to redeem)", pubkeys.size(), required));
249 }
250 if (pubkeys.size() > MAX_PUBKEYS_PER_MULTISIG) {
251 throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Number of keys involved in the multisignature address creation > %d\nReduce the number", MAX_PUBKEYS_PER_MULTISIG));
252 }
253
254 script_out = GetScriptForMultisig(required, pubkeys);
255
256 // Check if any keys are uncompressed. If so, the type is legacy
257 for (const CPubKey& pk : pubkeys) {
258 if (!pk.IsCompressed()) {
259 type = OutputType::LEGACY;
260 break;
261 }
262 }
263
264 if (type == OutputType::LEGACY && script_out.size() > MAX_SCRIPT_ELEMENT_SIZE) {
265 throw JSONRPCError(RPC_INVALID_PARAMETER, (strprintf("redeemScript exceeds size limit: %d > %d", script_out.size(), MAX_SCRIPT_ELEMENT_SIZE)));
266 }
267
268 // Make the address
269 CTxDestination dest = AddAndGetDestinationForScript(keystore, script_out, type);
270
271 return dest;
272}
273
274class DescribeAddressVisitor
275{

Callers 2

addmultisigaddressFunction · 0.85
createmultisigFunction · 0.85

Calls 5

JSONRPCErrorFunction · 0.85
GetScriptForMultisigFunction · 0.85
sizeMethod · 0.45
IsCompressedMethod · 0.45

Tested by

no test coverage detected