-
Notifications
You must be signed in to change notification settings - Fork 381
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
Add commandline flag to set genesis block script destination #55
Conversation
Why not call ScriptDestinationFromCommandLine etc directly in CRegTestParams instead of in SelectParamsFromCommandLine() ? |
@jtimon For "why did I structure the functions this way" I was trying to copy as best I could what is done for the As for the bugs, you're right, thanks. |
re CRegTestParams::CRegTestParams() parameter: I was assuming some of bitcoin/bitcoin#6382 had already been merged, but some of those changes were rejected for alpha so never mind. Anyway, the solution is still simple: just put all the new code inside CRegTestParams::CRegTestParams(), before the hash of the genesis block is calculated. See bitcoin/bitcoin#6382 which also builds the genesis block dynamically from a command line parameter for the sizetest |
@@ -249,7 +249,7 @@ class CRegTestParams : public CTestNetParams { | |||
txNew.vout[1].scriptPubKey = CScript() << OP_TRUE; | |||
genesis.vtx[0] = CTransaction(txNew); | |||
|
|||
CScript scriptDestination(CScript() << OP_TRUE); | |||
CScript scriptDestination(CScript() << OP_2 << ParseHex("023303dedc51b9d227b17c9fb4710f96b844e1ccdc2c776e1b7274bd4e246b6202") << ParseHex("03024c3b4f830854d6d26d6e34d92aff4c703bf57e85cd42abe328d928e01d4286") << ParseHex("03fe4e8c8d99b9dcbb529a87d54f606bae0149a34018325547fa0c2239e038a1c9") << OP_3 << OP_CHECKMULTISIG); |
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.
Oops, this should not have made it into the PR.
Thanks for bitcoin/bitcoin#6382 @jtimon, there are a lot of good ideas in there. I think I'll copy your factory pattern. |
Awesome! Maybe you want to utACK one of the following open little steps in bitcoin/bitcoin? Chainparams: Translations: DRY: options and error strings #6235 |
Rebased using a factory pattern as in @jtimon's code. Need to add some unit tests before this is usable. Like bitcoin/6382, there is an argument that this is only useful for QA and may not make sense to be merged. But in this case, I think it's reasonable to expect users to play with their own network with their own functionaries, and this makes this much easier. |
Added unit tests that confirms the genesis hash is computed correctly (for testnet and regtest, that the output of RPC |
@jtimon Do you have further thoughts on this PR? I know you have overlapping PRs in Core. @gmaxwell You commented on bitcoin/bitcoin#6907 that you feel making this a factory is a bad idea. Keeping them static would mean moving the constructor into some sort of In any case I'd like to move forward with this PR. |
@@ -80,6 +80,14 @@ class CChainParams | |||
const std::vector<unsigned char>& Base58Prefix(Base58Type type) const { return base58Prefixes[type]; } | |||
const std::vector<CAddress>& FixedSeeds() const { return vFixedSeeds; } | |||
virtual const Checkpoints::CCheckpointData& Checkpoints() const = 0; | |||
/** Change the script in the genesis hash */ | |||
void ChangeGenesisScriptDestination(CScript s) { genesis.proof = CProof(s, CScript()); } |
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.
Unused method.
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.
Removed
If I understood it correctly, @gmaxwell 's nit was that I was making globalChainParams and globalSwitchingChainParams extern instead of static and it's already solved (but it would be nice if he can clarify whether his nit has been solved or not in bitcoin/bitcoin#6907 ). As said, I don't like the script being passed to SeelectParams(), the factory, nor the constructors and I would prefer ScriptDestinationFromCommandLine to be called directly within the constructors, but just a preference. The overlapping PR/commits in Core are contained in https://github.com/jtimon/bitcoin/tree/alpha-base-0.12 which I will maintain rebased until 0.12 is forked and is what I would l would like @TheBlueMatt to use as a base when rebasing. |
86876f1
to
195a14e
Compare
Addressed @jtimon's nits |
I'm going to merge. |
Add commandline flag to set genesis block script destination
@@ -139,13 +145,15 @@ const CChainParams &Params(); | |||
/** Return parameters for the given network. */ | |||
CChainParams &Params(CBaseChainParams::Network network); |
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.
Wait a minute...where is this function defined now?
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.
chainparams.cpp:315
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.
No, I mean the parametrized version.
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.
Oh, hmm, this is not defined anywhere anymore (nor is it called anywhere, of course, else we would have compilation errors).
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.
mhmm I would like to eventually remove it from core too.I guess when rebasing the remaining uses can be replaced with the factory i elements. It's just something I expected to happen in bitcoin core first.
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.
Of course another option is to maintain it in elements until it removed in core.
getrawtransaction: scriptpubkey type is 'fee'
Fixes #54