Make and get the multisig redeemscript and destination in one function instead of two

Instead of creating a redeemScript with CreateMultisigRedeemscript and
then getting the destination with AddAndGetDestinationForScript, do
both in the same function.

CreateMultisigRedeemscript is changed to AddAndGetMultisigDestination.
It creates the redeemScript and returns it via an output parameter. Then
it calls AddAndGetDestinationForScript to add the destination to the
keystore and get the proper destination.

This allows us to inspect the public keys in the redeemScript before creating
the destination so that the correct destination is used when uncompressed
pubkeys are in the multisig.
This commit is contained in:
Andrew Chow
2019-05-15 00:21:11 -04:00
parent 65526fc866
commit a49503402b
5 changed files with 53 additions and 12 deletions

View File

@@ -130,9 +130,9 @@ static UniValue createmultisig(const JSONRPCRequest& request)
}
// Construct using pay-to-script-hash:
const CScript inner = CreateMultisigRedeemscript(required, pubkeys);
CBasicKeyStore keystore;
const CTxDestination dest = AddAndGetDestinationForScript(keystore, inner, output_type);
CScript inner;
const CTxDestination dest = AddAndGetMultisigDestination(required, pubkeys, output_type, keystore, inner);
UniValue result(UniValue::VOBJ);
result.pushKV("address", EncodeDestination(dest));