p2sh-wrap peg-in addresses if fedpeg_program is p2sh-wrapped

This commit is contained in:
Gregory Sanders 2019-08-19 12:07:10 -04:00
parent e2be2356dd
commit 953dd82eae

View file

@ -4859,8 +4859,10 @@ UniValue getpeginaddress(const JSONRPCRequest& request)
// Get P2CH deposit address on mainchain from most recent fedpegscript.
const auto& fedpegscripts = GetValidFedpegScripts(chainActive.Tip(), Params().GetConsensus(), true /* nextblock_validation */);
CTxDestination mainchain_dest(WitnessV0ScriptHash(calculate_contract(fedpegscripts.front().second, dest_script)));
// P2SH-wrapped is the only valid choice for non-dynafed chains
if (!IsDynaFedEnabled(chainActive.Tip(), Params().GetConsensus())) {
// P2SH-wrapped is the only valid choice for non-dynafed chains but still an
// option for dynafed-enabled ones as well
if (!IsDynaFedEnabled(chainActive.Tip(), Params().GetConsensus()) ||
fedpegscripts.front().first.IsPayToScriptHash()) {
mainchain_dest = ScriptHash(GetScriptForDestination(mainchain_dest));
}