NACK-- reservekey.KeepKey must happen AFTER .GetReservedKey or it is a no-op.
This works:
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
index 440459f..933b0ec 100644
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -2586,12 +2586,12 @@ void CWallet::UpdatedTransaction(const uint256 &hashTx)
void CWallet::GetScriptForMining(CScript &script)
{
CReserveKey reservekey(this);
- reservekey.KeepKey();
CPubKey pubkey;
if (!reservekey.GetReservedKey(pubkey))
return;
script = CScript() << ToByteVector(pubkey) << OP_CHECKSIG;
+ reservekey.KeepKey();
}
void CWallet::LockCoin(COutPoint& output)
To test: generate a block in -regtest mode, get the address of the coinbase transaction (getblock and then gettransaction). Then call getnewaddress; with the code as-is, you'll get the same pubkey as used by the coinbase transaction.