Fix upstream KMD crash bug in getblocktemplate when disablewallet=1

Originally dc8e1695c2
This commit is contained in:
Duke Leto
2021-06-28 22:34:35 -04:00
parent 6ca35f2b0a
commit 8e7cf04ad2

View File

@@ -857,19 +857,26 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey, int32_t nHeight,
scriptPubKey = CScript() << ParseHex(HexStr(pubkey)) << OP_CHECKSIG; scriptPubKey = CScript() << ParseHex(HexStr(pubkey)) << OP_CHECKSIG;
} else { } else {
{ {
if (!reservekey.GetReservedKey(pubkey)) // Support mining with -disablewallet and minetolocalwallet=0
{ if (!GetBoolArg("-disablewallet", false)) {
return NULL; // wallet enabled
} if (!reservekey.GetReservedKey(pubkey))
scriptPubKey.resize(35); return NULL;
ptr = (uint8_t *)pubkey.begin(); scriptPubKey.clear();
scriptPubKey[0] = 33; scriptPubKey = CScript() << ToByteVector(pubkey) << OP_CHECKSIG;
for (i=0; i<33; i++) { } else {
scriptPubKey[i+1] = ptr[i]; // wallet disabled
} CTxDestination dest = DecodeDestination(GetArg("-mineraddress", ""));
scriptPubKey[34] = OP_CHECKSIG; if (IsValidDestination(dest)) {
} // CKeyID keyID = boost::get<CKeyID>(dest);
} // scriptPubKey = CScript() << OP_DUP << OP_HASH160 << ToByteVector(keyID) << OP_EQUALVERIFY << OP_CHECKSIG;
scriptPubKey = GetScriptForDestination(dest);
} else {
return NULL;
}
}
}
}
return CreateNewBlock(pubkey, scriptPubKey, gpucount, isStake); return CreateNewBlock(pubkey, scriptPubKey, gpucount, isStake);
} }