Skip to content

Commit f0dec3e

Browse files
Support p2sh-segwit stake outputs
1 parent 2b8b5f2 commit f0dec3e

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

src/miner.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -746,11 +746,12 @@ static inline void PoSMiner(std::shared_ptr<CWallet> pwallet, ChainstateManager*
746746
LogPrintf("Set proof-of-stake timeout: %ums for %u UTXOs\n", pos_timio, vCoins.size());
747747
}
748748

749-
const std::string strMintMessage = _("Info: Minting suspended due to locked wallet.").translated;
749+
const std::string strMintWalletMessage = _("Info: Minting suspended due to locked wallet.").translated;
750750
const std::string strMintSyncMessage = _("Info: Minting suspended while synchronizing wallet.").translated;
751751
const std::string strMintDisabledMessage = _("Info: Minting disabled by 'nostaking' option.").translated;
752752
const std::string strMintBlockMessage = _("Info: Minting suspended due to block creation failure.").translated;
753753
const std::string strMintEmpty = "";
754+
754755
if (!gArgs.GetBoolArg("-staking", true)) {
755756
SetMintWarning(strMintDisabledMessage);
756757
LogPrintf("proof-of-stake minter disabled\n");
@@ -761,8 +762,8 @@ static inline void PoSMiner(std::shared_ptr<CWallet> pwallet, ChainstateManager*
761762
bool fNeedToClear = false;
762763
while (true) {
763764
while (pwallet->IsLocked()) {
764-
if (GetMintWarning() != strMintMessage) {
765-
SetMintWarning(strMintMessage);
765+
if (GetMintWarning() != strMintWalletMessage) {
766+
SetMintWarning(strMintWalletMessage);
766767
uiInterface.NotifyAlertChanged();
767768
}
768769
fNeedToClear = true;

src/validation.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5760,6 +5760,10 @@ bool CheckBlockSignature(const CBlock& block)
57605760
if (Hash160(pubkey) != uint160(vSolutions[0])) {
57615761
return error("%s : pubkey used for block signature (%s) does not correspond to first output", __func__, HexStr(pubkey));
57625762
}
5763+
} else if (whichType == TxoutType::SCRIPTHASH) {
5764+
if (Hash160(CScript() << OP_0 << ToByteVector(Hash160(pubkey))) != uint160(vSolutions[0])) { // p2sh-p2wpkh
5765+
return error("%s : pubkey used for block signature (%s) is not used in first %s output", __func__, HexStr(pubkey), GetTxnOutputType(whichType));
5766+
}
57635767
} else
57645768
return error("%s : unable to verify pubkey belongs to first output of type=%s", __func__, GetTxnOutputType(whichType));
57655769
} else if ((fProofOfStake && block.vtx[1]->vout.size() > 2) || (!fProofOfStake && block.vtx[0]->vout.size() > 1)) { // check for pubkey in OP_RETURN output - this can be any arbitrary pubkey as it will be covered by the coinstake TX signature hash

src/wallet/wallet.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4693,6 +4693,15 @@ bool CWallet::GetBlockSigningPubKey(const CBlock& block, CPubKey& pubkey, bool&
46934693
std::unique_ptr<SigningProvider> provider = GetSolvingProvider(txout.scriptPubKey);
46944694
if (!provider || !provider->GetPubKey(CKeyID(uint160(vSolutions[0])), pubkey)) // extract pubkey from output to put in coinbase
46954695
return false;
4696+
} else if (outputType == TxoutType::SCRIPTHASH) {
4697+
CScript subscript;
4698+
std::unique_ptr<SigningProvider> provider = GetSolvingProvider(txout.scriptPubKey);
4699+
if (provider && provider->GetCScript(CScriptID(uint160(vSolutions[0])), subscript)) { // extract pubkey from script to put in coinbase
4700+
outputType = Solver(subscript, vSolutions);
4701+
if (outputType != TxoutType::WITNESS_V0_KEYHASH || !provider->GetPubKey(CKeyID(uint160(vSolutions[0])), pubkey))
4702+
return false;
4703+
} else
4704+
return false;
46964705
} else
46974706
return false;
46984707
} else

0 commit comments

Comments
 (0)