Skip to content

Commit

Permalink
fixes master->0.18
Browse files Browse the repository at this point in the history
  • Loading branch information
kallewoof committed Aug 19, 2019
1 parent 8c09335 commit 5cced1d
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 51 deletions.
2 changes: 1 addition & 1 deletion src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ class SigNetParams : public CChainParams {

fDefaultConsistencyChecks = false;
fRequireStandard = true;
m_is_test_chain = true;
m_fallback_fee_enabled = true;
}
};

Expand Down
77 changes: 41 additions & 36 deletions src/rpc/mining.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ static bool grindBlock(CBlock* pblock, uint64_t& nMaxTries, uint256& result, boo

UniValue generateBlocks(std::shared_ptr<CReserveScript> coinbaseScript, int nGenerate, uint64_t nMaxTries, bool keepScript)
{
static const int nInnerLoopCount = 0x10000;
int nHeightEnd = 0;
int nHeight = 0;

Expand Down Expand Up @@ -995,18 +994,21 @@ static UniValue estimaterawfee(const JSONRPCRequest& request)

UniValue getnewblockhex(const JSONRPCRequest& request)
{
RPCHelpMan{"getnewblockhex",
"\nGets hex representation of a proposed, unmined new signet block.\n",
{
{"coinbase_destination", RPCArg::Type::STR, RPCArg::Optional::NO, "Pay-out destination, as an address or a custom coinbase script"},
},
RPCResult{
"blockhex (hex) The block hex\n"
},
RPCExamples{
HelpExampleCli("getnewblockhex", "bc1qkallealmkdwwyuc2tmf5c6hzmlaujq6jl38hpe")
}
}.Check(request);
if (request.fHelp || request.params.size() < 1 || request.params.size() > 1)
throw std::runtime_error(
RPCHelpMan{"getnewblockhex",
"\nGets hex representation of a proposed, unmined new signet block.\n",
{
{"coinbase_destination", RPCArg::Type::STR, RPCArg::Optional::NO, "Pay-out destination, as an address or a custom coinbase script"},
},
RPCResult{
"blockhex (hex) The block hex\n"
},
RPCExamples{
HelpExampleCli("getnewblockhex", "bc1qkallealmkdwwyuc2tmf5c6hzmlaujq6jl38hpe")
}
}.ToString()
);

if (!g_signet_blocks) {
throw std::runtime_error("getnewblockhex can only be used with signet networks");
Expand All @@ -1026,7 +1028,7 @@ UniValue getnewblockhex(const JSONRPCRequest& request)
// we bump stuff to bop stuff, or merkle root will be 0, etc etc etc etc
{
LOCK(cs_main);
IncrementExtraNonce(&block, ::ChainActive().Tip(), extra_nonce);
IncrementExtraNonce(&block, chainActive.Tip(), extra_nonce);
}

CDataStream ssBlock(SER_NETWORK, PROTOCOL_VERSION);
Expand All @@ -1037,28 +1039,31 @@ UniValue getnewblockhex(const JSONRPCRequest& request)

static UniValue grindblock(const JSONRPCRequest& request)
{
RPCHelpMan{"grindblock",
"\nGrind the given signet block to find valid proof of work\n"
"May fail if it reaches maxtries attempts.\n",
{
{"blockhex", RPCArg::Type::STR, RPCArg::Optional::NO, "The block data, or a script challenge, for new Signet networks"},
{"maxtries", RPCArg::Type::NUM, /* default */ "1000000", "How many iterations to try."},
},
{
RPCResult{"for block data",
"blockhash (hex) resulting block hash, or null if none was found\n"
},
RPCResult{"for script challenge",
"nonce (number) resulting nonce value which satisfies the proof of work requirement"
},
},
RPCExamples{
"\nGrind a block with hex $blockhex\n"
+ HelpExampleCli("grindblock", "$blockhex")
+ "\nCreate a new signet network with challenge 512103ad5e0edad18cb1f0fc0d28a3d4f1f3e445640337489abb10404f2d1e086be43051ae\n"
+ HelpExampleCli("grindblock", "512103ad5e0edad18cb1f0fc0d28a3d4f1f3e445640337489abb10404f2d1e086be43051ae")
},
}.Check(request);
if (request.fHelp || request.params.size() < 1 || request.params.size() > 2)
throw std::runtime_error(
RPCHelpMan{"grindblock",
"\nGrind the given signet block to find valid proof of work\n"
"May fail if it reaches maxtries attempts.\n",
{
{"blockhex", RPCArg::Type::STR, RPCArg::Optional::NO, "The block data, or a script challenge, for new Signet networks"},
{"maxtries", RPCArg::Type::NUM, /* default */ "1000000", "How many iterations to try."},
},
{
RPCResult{"for block data",
"blockhash (hex) resulting block hash, or null if none was found\n"
},
RPCResult{"for script challenge",
"nonce (number) resulting nonce value which satisfies the proof of work requirement"
},
},
RPCExamples{
"\nGrind a block with hex $blockhex\n"
+ HelpExampleCli("grindblock", "$blockhex")
+ "\nCreate a new signet network with challenge 512103ad5e0edad18cb1f0fc0d28a3d4f1f3e445640337489abb10404f2d1e086be43051ae\n"
+ HelpExampleCli("grindblock", "512103ad5e0edad18cb1f0fc0d28a3d4f1f3e445640337489abb10404f2d1e086be43051ae")
},
}.ToString()
);

bool grinding_nonce = false;
CBlock block;
Expand Down
2 changes: 1 addition & 1 deletion src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3109,7 +3109,7 @@ bool CheckBlock(const CBlock& block, CValidationState& state, const Consensus::P
if (!CheckBlockHeader(block, state, consensusParams, fCheckPOW))
return false;

if (g_signet_blocks && really_check_pow && !CheckBlockSolution(block, consensusParams)) return false;
if (g_signet_blocks && fCheckPOW && block.GetHash() != consensusParams.hashGenesisBlock && !CheckBlockSolution(block, consensusParams)) return false;

// Check the merkle root.
if (fCheckMerkleRoot) {
Expand Down
29 changes: 16 additions & 13 deletions src/wallet/rpcwallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4174,19 +4174,22 @@ UniValue signblock(const JSONRPCRequest& request)
return NullUniValue;
}

RPCHelpMan{"signblock",
"\nSigns a block proposal, checking that it would be accepted first.\n"
"(Note: only useable with signet networks.)\n",
{
{"blockhex", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The hex-encoded block from getnewblockhex, or a filename"},
},
RPCResult{
" sig (hex) The signature\n"
},
RPCExamples{
HelpExampleCli("signblock", "0000002018c6f2f913f9902aeab...5ca501f77be96de63f609010000000000000000015100000000")
},
}.Check(request);
if (request.fHelp || request.params.size() < 1 || request.params.size() > 1)
throw std::runtime_error(
RPCHelpMan{"signblock",
"\nSigns a block proposal, checking that it would be accepted first.\n"
"(Note: only useable with signet networks.)\n",
{
{"blockhex", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The hex-encoded block from getnewblockhex, or a filename"},
},
RPCResult{
" sig (hex) The signature\n"
},
RPCExamples{
HelpExampleCli("signblock", "0000002018c6f2f913f9902aeab...5ca501f77be96de63f609010000000000000000015100000000")
},
}.ToString()
);

if (!g_signet_blocks) {
throw std::runtime_error("signblock can only be used with signet networks");
Expand Down

0 comments on commit 5cced1d

Please sign in to comment.