New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Switch miner to P2PKH, add -mineraddress option #1965
Conversation
This PR is branched from #1863; merge that first. |
src/miner.cpp
Outdated
|
||
CScript scriptPubKey = CScript() << ToByteVector(pubkey) << OP_CHECKSIG; | ||
CScript scriptPubKey = CScript() << OP_DUP << OP_HASH160 << ToByteVector(keyID) << OP_EQUALVERIFY << OP_CHECKSIG; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewers, please double-check that I have this P2PKH script correct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's correct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no error if the mineraddress is invalid, whether empty whitespace, garbage or an address with a typo.
Instead, mining proceeds successfully with the coinbase reward going to address tm9iMLAuYMzJ6jtFLcA7rzUmfreGuKvr7Ma.
This is the address when keyID is null.
./zcash-cli validateaddress tm9iMLAuYMzJ6jtFLcA7rzUmfreGuKvr7Ma
{
"isvalid" : true,
"address" : "tm9iMLAuYMzJ6jtFLcA7rzUmfreGuKvr7Ma",
"scriptPubKey" : "76a914000000000000000000000000000000000000000088ac",
"ismine" : false
}
The above should be fixed and automated tests written to check input validity and spending the coinbase.
Also consider adding an option -mineraddressismine (default true) where the user must explicitly set this to false to allow mining to an address not in the wallet.
Reporting problems with the miner address, whether invalid or not mine, should be at launch so that the user is notified immediately.
b6eb162
to
aa0081f
Compare
@str4d Getting compile errors:
|
aa0081f
to
a4c34ea
Compare
@bitcartel Strange, I don't get those errors... Re: the current merge conflict, I'll rebase this on master once #1863 is merged. |
Ah, the error @bitcartel has shows up with --disable-mining. Fixing. |
a4c34ea
to
c3d2145
Compare
@bitcartel I like your idea of a |
ecdad51
to
ae8dae9
Compare
Sounds good. If zcashd doesn't have a wallet, then the flag should be disregarded. |
@str4d compile error
|
@bitcartel whoops, I changed the help text but not the error messages. Fixing... |
a7d6500
to
f49bcdf
Compare
ACK |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utACK, but I'm going to smoke-test it with all four combinations of {ENABLE_WALLET, ENABLE_MINER} as well, because there's a lot of conditional code here.
If I disable the wallet (by editing |
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
ACK everything except my last patch. |
ACK |
@zkbot r+ |
📌 Commit 9bba9b3 has been approved by |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@daira @bitcartel I'm not going to stop this merging, but see my comment.
return InitError(_("Zcash was not built with wallet support. Set -minetolocalwallet=0 to use -mineraddress, or rebuild Zcash with wallet support.")); | ||
} | ||
if (!mapArgs.count("-mineraddress")) { | ||
return InitError(_("Zcash was not built with wallet support. Set -mineraddress, or rebuild Zcash with wallet support.")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As-is, this will require a build with !ENABLE_WALLET && ENABLE_MINING
to always have -mineraddress
set, even if -gen
is not set. Is this what we want? It does make some sense, because zcash-cli setgenerate
wouldn't work properly if -mineraddress
wasn't set, and the user likely does want to mine in this setup, but I'm not sure we should assume that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally this would be allowed when -gen is not set, but setgenerate would fail.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in #2081
☀️ Test successful - zcash |
Address @str4d's comment on #1965 about the case where -gen is not set #1965 (comment) Note that the case of calling the ``setgenerate true`` RPC with the wallet disabled was already handled correctly. Signed-off-by: Daira Hopwood <daira@jacaranda.org>
Closes #945 and #1955.