Skip to content

Commit

Permalink
Merge pull request #41 from globaltoken/coding
Browse files Browse the repository at this point in the history
GlobalToken v3.3.0 Release
  • Loading branch information
globaltoken committed May 8, 2022
2 parents 9ab9424 + faff8c6 commit b7f7bab
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 286 deletions.
6 changes: 3 additions & 3 deletions configure.ac
@@ -1,13 +1,13 @@
dnl require autoconf 2.60 (AS_ECHO/AS_ECHO_N)
AC_PREREQ([2.60])
define(_CLIENT_VERSION_MAJOR, 3)
define(_CLIENT_VERSION_MINOR, 2)
define(_CLIENT_VERSION_REVISION, 1)
define(_CLIENT_VERSION_MINOR, 3)
define(_CLIENT_VERSION_REVISION, 0)
define(_CLIENT_VERSION_BUILD, 0)
define(_CLIENT_VERSION_IS_RELEASE, true)
define(_COPYRIGHT_GLT_START, 2017)
define(_COPYRIGHT_YEAR, 2018)
define(_COPYRIGHT_YEAR_GLT, 2019)
define(_COPYRIGHT_YEAR_GLT, 2022)
define(_COPYRIGHT_HOLDERS,[The %s developers])
define(_COPYRIGHT_HOLDERS_SUBSTITUTION,[[Bitcoin Core]])
define(_COPYRIGHT_HOLDERS_SUBSTITUTION_GLT,[[Globaltoken Core]])
Expand Down
256 changes: 3 additions & 253 deletions src/chainparams.cpp

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/consensus/params.h
Expand Up @@ -79,6 +79,7 @@ struct Params {
CHardforkProperties Hardfork1;
CHardforkProperties Hardfork2;
CHardforkProperties Hardfork3;
CHardforkProperties Hardfork4;
/** The max allowed auxpow blocks after genesis diff*/
uint32_t nMaxAuxpowBlocks;
uint32_t nOldRuleChangeActivationThreshold;
Expand Down
14 changes: 7 additions & 7 deletions src/miner.cpp
Expand Up @@ -190,19 +190,19 @@ std::unique_ptr<CBlockTemplate> BlockAssembler::CreateNewBlock(const CScript& sc
coinbaseTx.vout[0].scriptPubKey = scriptPubKeyIn;
coinbaseTx.vout[0].nValue = blockReward;

if(chainparams.GetConsensus().Hardfork1.IsActivated(pblock->nTime))
if(nHeight < chainparams.GetConsensus().Hardfork4.GetActivationHeight())
{
CAmount nTreasuryAmount = chainparams.GetTreasuryAmount(blockReward);
coinbaseTx.vout[0].nValue -= nTreasuryAmount;
coinbaseTx.vout.push_back(CTxOut(nTreasuryAmount, chainparams.GetFoundersRewardScriptAtHeight(nHeight, chainparams.GetConsensus().Hardfork3.IsActivated(pblock->nTime))));

// Update coinbase transaction with additional info about masternode payments,
// get some info back to pass to getblocktemplate
FillBlockPayments(coinbaseTx, nHeight, blockReward, pblock->txoutMasternode);
// LogPrintf("CreateNewBlock -- nBlockHeight %d blockReward %lld txoutMasternode %s coinbaseTx %s",
// nHeight, GetBlockSubsidy(nHeight, chainparams.GetConsensus()), pblock->txoutMasternode.ToString(), coinbaseTx.ToString());
}

// Update coinbase transaction with additional info about masternode payments,
// get some info back to pass to getblocktemplate
FillBlockPayments(coinbaseTx, nHeight, blockReward, pblock->txoutMasternode);
// LogPrintf("CreateNewBlock -- nBlockHeight %d blockReward %lld txoutMasternode %s coinbaseTx %s",
// nHeight, GetBlockSubsidy(nHeight, chainparams.GetConsensus()), pblock->txoutMasternode.ToString(), coinbaseTx.ToString());

coinbaseTx.vin[0].scriptSig = CScript() << nHeight << OP_0;
pblock->vtx[0] = MakeTransactionRef(std::move(coinbaseTx));
pblocktemplate->vchCoinbaseCommitment = GenerateCoinbaseCommitment(*pblock, pindexPrev, chainparams.GetConsensus());
Expand Down
7 changes: 7 additions & 0 deletions src/rpc/blockchain.cpp
Expand Up @@ -1407,6 +1407,13 @@ UniValue getblockchaininfo(const JSONRPCRequest& request)
globaltoken_hardforks.pushKV("activation_blockhash", consensusParams.Hardfork3.GetActivationBlockHash().GetHex());
globaltoken_hardforks.pushKV("blocks_since_hardfork", tip->nHeight - consensusParams.Hardfork3.GetActivationHeight());
globaltoken_hardfork.pushKV(consensusParams.Hardfork3.GetHardforkIDAsString(), globaltoken_hardforks);
globaltoken_hardforks.setObject(); // clear and reset as object
globaltoken_hardforks.pushKV("activated", tip->nHeight > consensusParams.Hardfork4.GetActivationHeight());
globaltoken_hardforks.pushKV("activation_time", (int64_t)consensusParams.Hardfork4.GetActivationTime());
globaltoken_hardforks.pushKV("activation_height", (int64_t)consensusParams.Hardfork4.GetActivationHeight());
globaltoken_hardforks.pushKV("activation_blockhash", consensusParams.Hardfork4.GetActivationBlockHash().GetHex());
globaltoken_hardforks.pushKV("blocks_since_hardfork", tip->nHeight - consensusParams.Hardfork4.GetActivationHeight());
globaltoken_hardfork.pushKV(consensusParams.Hardfork4.GetHardforkIDAsString(), globaltoken_hardforks);
softforks.push_back(SoftForkDesc("bip34", 2, tip, consensusParams));
softforks.push_back(SoftForkDesc("bip66", 3, tip, consensusParams));
softforks.push_back(SoftForkDesc("bip65", 4, tip, consensusParams));
Expand Down
2 changes: 2 additions & 0 deletions src/rpc/client.cpp
Expand Up @@ -123,7 +123,9 @@ static const CRPCConvertParam vRPCConvertParams[] =
{ "sendrawtransaction", 1, "allowhighfees" },
{ "sendrawtransaction", 2, "instantsend" },
{ "broadcastsignedproposal", 1, "allowhighfees" },
{ "broadcastsignedproposal", 2, "bypass_limits" },
{ "broadcastallsignedproposals", 0, "allowhighfees" },
{ "broadcastallsignedproposals", 1, "bypass_limits" },
{ "submitauxblock", 2, "auxpowversion"},
{ "combinerawtransaction", 0, "txs" },
{ "fundrawtransaction", 1, "options" },
Expand Down
2 changes: 1 addition & 1 deletion src/rpc/mining.cpp
Expand Up @@ -79,7 +79,7 @@ UniValue GetNetworkHashPS(uint8_t nAlgo, int lookup, int height) {

UniValue GetUniValueForTreasury(const CAmount blockReward, const uint32_t nTime, int nHeight, const bool skipActivationCheck)
{
if(Params().GetConsensus().Hardfork1.IsActivated(nTime) || skipActivationCheck)
if(nHeight < Params().GetConsensus().Hardfork4.GetActivationHeight() && skipActivationCheck)
{
const CChainParams& params = Params();
CAmount treasuryamount = params.GetTreasuryAmount(blockReward);
Expand Down
31 changes: 19 additions & 12 deletions src/rpc/treasury.cpp
Expand Up @@ -262,7 +262,7 @@ UniValue GetProposalTxInfo(const CTreasuryProposal* pProposal)
return ret;
}

bool BroadcastSignedTreasuryProposalTransaction(CTreasuryProposal* pProposal, UniValue& result, const CAmount& nMaxRawTxFee)
static bool BroadcastSignedTreasuryProposalTransaction(CTreasuryProposal* pProposal, UniValue& result, const CAmount& nMaxRawTxFee, const bool &bypass_limits)
{
AssertLockHeld(cs_treasury);

Expand All @@ -289,7 +289,7 @@ bool BroadcastSignedTreasuryProposalTransaction(CTreasuryProposal* pProposal, Un
CValidationState state;
bool fMissingInputs;
if (!AcceptToMemoryPool(mempool, state, std::move(tx), &fMissingInputs,
nullptr /* plTxnReplaced */, false /* bypass_limits */, nMaxRawTxFee)) {
nullptr /* plTxnReplaced */, bypass_limits /* bypass_limits */, nMaxRawTxFee)) {
if (state.IsInvalid()) {
ret.pushKV("txid", hashTx.GetHex());
ret.pushKV("sent", fSent);
Expand Down Expand Up @@ -349,13 +349,14 @@ bool BroadcastSignedTreasuryProposalTransaction(CTreasuryProposal* pProposal, Un

UniValue broadcastallsignedproposals(const JSONRPCRequest& request)
{
if (request.fHelp || (request.params.size() != 0 && request.params.size() != 1))
if (request.fHelp || request.params.size() > 2)
throw std::runtime_error(
"broadcastsignedproposal ( allowhighfees )\n"
"\nSubmits signed treasury proposal transaction (serialized, hex-encoded) to local node and network.\n"
"\nAlso see createrawtransaction, updateproposaltxfromhex and signtreasuryproposalswithwallet calls.\n"
"\nArguments:\n"
"1. allowhighfees (boolean, optional, default=false) Allow high fees\n"
"2. bypass_limits (boolean, optional, default=false) Don't check for min transaction fee and tx size, just skip it and accept to local mempool.\n"
"\nResult:\n"
"[\n"
" {\n"
Expand All @@ -375,7 +376,6 @@ UniValue broadcastallsignedproposals(const JSONRPCRequest& request)
+ HelpExampleRpc("broadcastsignedproposal", "\"proposalid\"")
);

RPCTypeCheck(request.params, {UniValue::VBOOL});
UniValue ret(UniValue::VARR);

LOCK(cs_treasury);
Expand All @@ -395,10 +395,14 @@ UniValue broadcastallsignedproposals(const JSONRPCRequest& request)
if(activeTreasury.vTreasuryProposals.empty())
throw JSONRPCError(RPC_INVALID_PARAMETER, "No treasury proposals in mempool.");

bool bypass_limits = false;
CAmount nMaxRawTxFee = maxTxFee;
if (!request.params[0].isNull() && request.params[0].get_bool())
nMaxRawTxFee = 0;

if (!request.params[1].isNull())
bypass_limits = request.params[1].get_bool();

std::vector<CTreasuryProposal*> vPps;

{ // cs_main scope
Expand Down Expand Up @@ -439,22 +443,23 @@ UniValue broadcastallsignedproposals(const JSONRPCRequest& request)
{
UniValue obj(UniValue::VOBJ);
obj.pushKV("proposal", vPps[i]->hashID.GetHex());
BroadcastSignedTreasuryProposalTransaction(vPps[i], obj, nMaxRawTxFee);
BroadcastSignedTreasuryProposalTransaction(vPps[i], obj, nMaxRawTxFee, bypass_limits);
ret.push_back(obj);
}
return ret;
}

UniValue broadcastsignedproposal(const JSONRPCRequest& request)
{
if (request.fHelp || request.params.size() < 1 || request.params.size() > 2)
if (request.fHelp || request.params.size() < 1 || request.params.size() > 3)
throw std::runtime_error(
"broadcastsignedproposal \"id\" ( allowhighfees )\n"
"\nSubmits signed treasury proposal transaction (serialized, hex-encoded) to local node and network.\n"
"\nAlso see createrawtransaction, updateproposaltxfromhex and signtreasuryproposalswithwallet calls.\n"
"\nArguments:\n"
"1. \"id\" (string, required) The proposal ID, that has a signed transaction and now should be broadcasted via network.\n"
"2. allowhighfees (boolean, optional, default=false) Allow high fees\n"
"3. bypass_limits (boolean, optional, default=false) Don't check for min transaction fee and tx size, just skip it and accept to local mempool.\n"
"\nResult:\n"
"\nThe transaction ID, if successful, otherwise it returns an error.\n"
"\nCreate a transaction\n"
Expand All @@ -467,7 +472,6 @@ UniValue broadcastsignedproposal(const JSONRPCRequest& request)
+ HelpExampleRpc("broadcastsignedproposal", "\"proposalid\"")
);

RPCTypeCheck(request.params, {UniValue::VSTR, UniValue::VBOOL});

LOCK(cs_treasury);
UniValue obj(UniValue::VOBJ);
Expand All @@ -486,12 +490,15 @@ UniValue broadcastsignedproposal(const JSONRPCRequest& request)

uint256 proposalHash = uint256S(request.params[0].get_str());
size_t nIndex = 0;
bool fSigned = false;
bool fSigned = false, bypass_limits = false;

CAmount nMaxRawTxFee = maxTxFee;
if (!request.params[1].isNull() && request.params[1].get_bool())
nMaxRawTxFee = 0;

if (!request.params[2].isNull())
bypass_limits = request.params[2].get_bool();

if(!activeTreasury.GetProposalvID(proposalHash, nIndex))
throw JSONRPCError(RPC_INVALID_PARAMETER, "Treasury proposal not found.");

Expand Down Expand Up @@ -521,7 +528,7 @@ UniValue broadcastsignedproposal(const JSONRPCRequest& request)
} // cs_main

if(fSigned)
BroadcastSignedTreasuryProposalTransaction(pProposal, obj, nMaxRawTxFee);
BroadcastSignedTreasuryProposalTransaction(pProposal, obj, nMaxRawTxFee, bypass_limits);
else
throw JSONRPCError(RPC_TRANSACTION_ERROR, "Treasury proposal transaction not signed yet!");

Expand Down Expand Up @@ -1542,7 +1549,7 @@ UniValue moveunusableproposaltxinputs(const JSONRPCRequest& request)
{
if (request.fHelp || request.params.size() != 2)
throw std::runtime_error(
"handleproposaltxinputs\n"
"moveunusableproposaltxinputs\n"
"\nRemoves invalid transaction inputs, removes overflowed (1 MB tx size) inputs and funds the other proposal tx transaction with the overflowed inputs until it reachs 1 MB\nand adds them as change money and clears the scriptSig to sign the transaction.\n"

"\nArguments:\n"
Expand Down Expand Up @@ -2699,8 +2706,8 @@ static const CRPCCommand commands[] =
/** All treasury proposal transaction functions */
{ "treasury", "updateproposaltxfromhex", &updateproposaltxfromhex, {"id","hextx"} },
{ "treasury", "getproposaltxashex", &getproposaltxashex, {"id"} },
{ "treasury", "broadcastallsignedproposals", &broadcastallsignedproposals, {"allowhighfees"} },
{ "treasury", "broadcastsignedproposal", &broadcastsignedproposal, {"id","allowhighfees"} },
{ "treasury", "broadcastallsignedproposals", &broadcastallsignedproposals, {"allowhighfees","bypass_limits"} },
{ "treasury", "broadcastsignedproposal", &broadcastsignedproposal, {"id","allowhighfees","bypass_limits"} },
{ "treasury", "createproposaltx", &createproposaltx, {"id","inputs","outputs","locktime","replaceable"} },
{ "treasury", "clearproposaltx", &clearproposaltx, {"id"} },
{ "treasury", "clearproposaltxrecipients", &clearproposaltxrecipients, {"id"} },
Expand Down
23 changes: 13 additions & 10 deletions src/validation.cpp
Expand Up @@ -2113,20 +2113,23 @@ bool CChainState::ConnectBlock(const CBlock& block, CValidationState& state, CBl

if(chainparams.GetConsensus().Hardfork1.IsActivated(block.nTime))
{
// Coinbase transaction must include the Treasury amount to the given Reward address, if Hardfork is activated.
bool found = false;
if(pindex->nHeight < chainparams.GetConsensus().Hardfork4.GetActivationHeight())
{
// Coinbase transaction must include the Treasury amount to the given Reward address, if Hardfork is activated.
bool found = false;

for(const CTxOut& output : block.vtx[0]->vout) {
if (output.scriptPubKey == Params().GetFoundersRewardScriptAtHeight(pindex->nHeight, chainparams.GetConsensus().Hardfork3.IsActivated(block.nTime))) {
if (output.nValue == Params().GetTreasuryAmount(blockReward)) {
found = true;
break;
for(const CTxOut& output : block.vtx[0]->vout) {
if (output.scriptPubKey == Params().GetFoundersRewardScriptAtHeight(pindex->nHeight, chainparams.GetConsensus().Hardfork3.IsActivated(block.nTime))) {
if (output.nValue == Params().GetTreasuryAmount(blockReward)) {
found = true;
break;
}
}
}
}

if (!found) {
return state.DoS(100, error("ConnectBlock(): couldn't find treasury payment"), REJECT_INVALID, "bad-cb-treasury");
if (!found) {
return state.DoS(100, error("ConnectBlock(): couldn't find treasury payment"), REJECT_INVALID, "bad-cb-treasury");
}
}

if (!IsBlockPayeeValid(*block.vtx[0], pindex->nHeight, blockReward)) {
Expand Down

0 comments on commit b7f7bab

Please sign in to comment.