You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if (whichType == TxoutType::SCRIPTHASH || whichType == TxoutType::WITNESS_V0_SCRIPTHASH) { // a p2sh/p2wsh input could be many things, but we only support p2sh-p2wpkh and multisig for now
if (scriptType != TxoutType::WITNESS_V0_KEYHASH || Params().NetworkIDString() == CBaseChainParams::MAIN) { // this is a script we don't recognize
612
+
if (!fNewStakingCodeActive || (scriptType != TxoutType::WITNESS_V0_KEYHASH && scriptType != TxoutType::MULTISIG && scriptType != TxoutType::MULTISIG_DATA)) { // this is a script we don't recognize
601
613
if (gArgs.GetBoolArg("-debug", false) && gArgs.GetBoolArg("-printcoinstake", false))
602
614
LogPrintf("%s : no support for %s kernel type=%s\n", __func__, GetTxnOutputType(whichType), GetTxnOutputType(scriptType));
if (gArgs.GetBoolArg("-quantumsafestaking", false)) { // a new bech32 address is generated for every stake to protect the public key from quantum computers
625
+
if ((fNewStakingCodeActive || whichType != TxoutType::PUBKEY) && gArgs.GetBoolArg("-quantumsafestaking", false)) { // a new bech32 address is generated for every stake to protect the public key from quantum computers
LogPrintf("%s : failed to get new destination for coinstake (%s)\n", __func__, error);
622
634
scriptPubKeyOut = scriptPubKeyKernel;
623
635
}
624
-
} elseif (!pwallet->IsWalletFlagSet(WALLET_FLAG_DESCRIPTORS)) { // on legacy wallets we can convert every input to p2pk for smaller coinstake TXs
636
+
} elseif (whichType == TxoutType::MULTISIG || whichType == TxoutType::MULTISIG_DATA) { // try to create a new destination for p2sh/p2wsh-multisig inputs
637
+
OutputType output_type = OutputType::BECH32;
638
+
CTxDestination dest;
639
+
std::string error;
640
+
if (pwallet->GetNewChangeDestination(output_type, dest, error)) {
641
+
LogPrintf("%s : using new destination for coinstake (%s)\n", __func__, EncodeDestination(dest));
642
+
scriptPubKeyOut = GetScriptForDestination(dest);
643
+
} else
644
+
continue;
645
+
} elseif (pwallet->IsWalletFlagSet(WALLET_FLAG_DESCRIPTORS) || whichType == TxoutType::PUBKEY) { // descriptor wallets only credit earnings back to the original address and p2pk inputs can be left alone
646
+
scriptPubKeyOut = scriptPubKeyKernel;
647
+
} else { // on legacy wallets we can convert every input to p2pk for smaller coinstake TXs
if ((pubkeyStart + CPubKey::COMPRESSED_SIZE) > txin.scriptSig.size() || txin.scriptSig[pubkeyStart-1] < CPubKey::COMPRESSED_SIZE) // last pushdata must be large enough to at least hold a compressed pubkey
5752
-
returnfalse;
5752
+
returnerror("%s : p2pkh txin.scriptSig.size() = %u is too small", __func__, txin.scriptSig.size());
if (whichType == TxoutType::PUBKEYHASH || whichType == TxoutType::WITNESS_V0_KEYHASH) { // this code could be removed in the future to allow block signing with any arbitrary pubkey
5760
+
if (Hash160(pubkey) != uint160(vSolutions[0])) {
5761
+
returnerror("%s : pubkey used for block signature (%s) does not correspond to first output", __func__, HexStr(pubkey));
5762
+
}
5763
+
} else
5764
+
returnerror("%s : unable to verify pubkey belongs to first output of type=%s", __func__, GetTxnOutputType(whichType));
5754
5765
} else { // we don't know where the pubkey is or how to parse it
5755
-
returnfalse;
5766
+
returnerror("%s : unable to find pubkey to validate block signature", __func__);
5756
5767
}
5757
5768
}
5758
5769
//LogPrintf("%s : validating signature for %s output using pubkey %s\n", __func__, GetTxnOutputType(whichType), HexStr(pubkey));
0 commit comments