Skip to content

Commit

Permalink
Merge pull request #120 from BlockMechanic/segwit
Browse files Browse the repository at this point in the history
Anger Management
  • Loading branch information
BlockMechanic authored Oct 6, 2022
2 parents d33dc59 + 517e2d2 commit d18dcf8
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 52 deletions.
4 changes: 2 additions & 2 deletions src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,12 +310,12 @@ class CTestNetParams : public CChainParams {
vFixedSeeds.clear();
vSeeds.clear();
// nodes with support for servicebits filtering should be at the top
/*vSeeds.emplace_back("92.60.46.26");
vSeeds.emplace_back("92.60.46.26");
vSeeds.emplace_back("92.60.46.27");
vSeeds.emplace_back("92.60.46.28");
vSeeds.emplace_back("92.60.46.29");
vSeeds.emplace_back("92.60.46.30");
vSeeds.emplace_back("92.60.46.31");*/
vSeeds.emplace_back("92.60.46.31");

base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,111);
base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1,196);
Expand Down
8 changes: 4 additions & 4 deletions src/masternode/masternode-payments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ bool CMasternodePayments::CanVote(COutPoint outMasternode, int nBlockHeight)
return true;
}

void FillBlockPayee(CMutableTransaction& txNew, int64_t nFees)
void FillBlockPayee(CMutableTransaction& txNew, int64_t nFees, bool hasMNPayment)
{
CBlockIndex* pindexPrev = ::ChainActive().Tip();
if(!pindexPrev) return;
Expand All @@ -145,7 +145,7 @@ void FillBlockPayee(CMutableTransaction& txNew, int64_t nFees)
} else if(IsSporkActive(SPORK_13_ENABLE_SUPERBLOCKS) && budget.IsBudgetPaymentBlock(pindexPrev->nHeight+1)){
budget.FillBlockPayee(txNew, nFees);
} else {
masternodePayments.FillBlockPayee(txNew, nFees);
masternodePayments.FillBlockPayee(txNew, nFees, hasMNPayment);
}
}

Expand All @@ -160,12 +160,12 @@ std::string GetRequiredPaymentsString(int nBlockHeight)
}
}

void CMasternodePayments::FillBlockPayee(CMutableTransaction& txNew, int64_t nFees)
void CMasternodePayments::FillBlockPayee(CMutableTransaction& txNew, int64_t nFees, bool hasPayment)
{
CBlockIndex* pindexPrev = ::ChainActive().Tip();
if(!pindexPrev) return;

bool hasPayment = true;
//bool hasPayment = true;
CScript payee;

//spork
Expand Down
4 changes: 2 additions & 2 deletions src/masternode/masternode-payments.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ bool IsReferenceNode(CTxIn& vin);
bool IsBlockPayeeValid(const CAmount& nValueCreated, const CTransaction& txNew, int nBlockHeight, const uint32_t& nTime, const uint32_t& nTimePrevBlock);
std::string GetRequiredPaymentsString(int nBlockHeight);
bool IsBlockValueValid(const CBlock& block, int64_t nExpectedValue);
void FillBlockPayee(CMutableTransaction& txNew, int64_t nFees);
void FillBlockPayee(CMutableTransaction& txNew, int64_t nFees, bool hasMNPayment);

class CMasternodePayee
{
Expand Down Expand Up @@ -224,7 +224,7 @@ class CMasternodePayments
int GetMinMasternodePaymentsProto();
void ProcessMessageMasternodePayments(CNode* pfrom, const std::string& strCommand, CDataStream& vRecv);
std::string GetRequiredPaymentsString(int nBlockHeight);
void FillBlockPayee(CMutableTransaction& txNew, int64_t nFees);
void FillBlockPayee(CMutableTransaction& txNew, int64_t nFees, bool hasMNPayment);
std::string ToString() const;
int GetOldestBlock();
int GetNewestBlock();
Expand Down
5 changes: 3 additions & 2 deletions src/miner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,9 @@ std::unique_ptr<CBlockTemplate> BlockAssembler::CreateNewBlock(const CScript& sc

// Masternode and general budget payments
if (IsSporkActive(SPORK_4_ENABLE_MASTERNODE_PAYMENTS) || Params().NetworkIDString() == CBaseChainParams::TESTNET) {
FillBlockPayee(coinbaseTx, nFees);
SNFillBlockPayee(coinbaseTx, nFees);
bool hasMNPayment =true;
FillBlockPayee(coinbaseTx, nFees, hasMNPayment);
SNFillBlockPayee(coinbaseTx, nFees, hasMNPayment);
}
else
{
Expand Down
42 changes: 5 additions & 37 deletions src/rpc/contracts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,7 @@ static RPCHelpMan getcontracts()
for(auto s : allcontracts){

UniValue entry(UniValue::VOBJ);

entry.pushKV("url", s.contract_url);
entry.pushKV("name", s.asset_name);
entry.pushKV("symbol", s.asset_symbol);
entry.pushKV("issuing address", s.sIssuingaddress);
entry.pushKV("description", s.description);
entry.pushKV("website", s.website_url);
entry.pushKV("script", HexStr(s.scriptcode));
entry.pushKV("signature", HexStr(s.vchContractSig));

ContractToUniv(s,entry);
result.push_back(entry);
}

Expand Down Expand Up @@ -127,16 +118,7 @@ static RPCHelpMan getcontract()
{
const CContract &s = GetContract(request.params[0].get_str());
UniValue result(UniValue::VOBJ);

result.pushKV("url", s.contract_url);
result.pushKV("name", s.asset_name);
result.pushKV("symbol", s.asset_symbol);
result.pushKV("issuing address", s.sIssuingaddress);
result.pushKV("description", s.description);
result.pushKV("website", s.website_url);
result.pushKV("script", HexStr(s.scriptcode));
result.pushKV("signature", HexStr(s.vchContractSig));
//ContractToUniv(contract,result);
ContractToUniv(s,result);

return result;
},
Expand Down Expand Up @@ -323,24 +305,8 @@ static RPCHelpMan getassets()

UniValue result(UniValue::VARR);
for(auto asset : allassets){

UniValue entry(UniValue::VOBJ);

entry.pushKV("version", (int)asset.nVersion);
uint32_t type = asset.GetType();
entry.pushKV("type", AssetTypeToString(type));
entry.pushKV("name", asset.getAssetName());
entry.pushKV("symbol", asset.getShortName());
entry.pushKV("id", asset.GetHex());
entry.pushKV("contract_hash", asset.contract_hash.GetHex());
entry.pushKV("expiry", (int64_t)asset.GetExpiry());
entry.pushKV("transferable", asset.isTransferable() ? "yes" : "no");
entry.pushKV("convertable", asset.isConvertable() ? "yes" : "no");
entry.pushKV("limited", asset.isLimited() ? "yes" : "no");
entry.pushKV("restricted", asset.isRestricted() ? "yes" : "no");
entry.pushKV("stakeable", asset.isStakeable() ? "yes" : "no");
entry.pushKV("inflation", asset.isInflatable() ? "yes" : "no");

AssetToUniv(asset,entry);
result.push_back(entry);
}

Expand All @@ -367,8 +333,10 @@ static RPCHelpMan getnumassets()
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
{
std::vector<CAsset> allassets = ::GetAllAssets();
std::vector<CContract> allcontracts = ::GetAllContracts();
UniValue deets(UniValue::VOBJ);
deets.pushKV("Asset count", allassets.size());
deets.pushKV("Contract count", allcontracts.size());

return deets;
},
Expand Down
18 changes: 15 additions & 3 deletions src/systemnode/systemnode-payments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ bool CSystemnodePayments::CanVote(COutPoint outSystemnode, int nBlockHeight)
return true;
}

void SNFillBlockPayee(CMutableTransaction& txNew, int64_t nFees)
void SNFillBlockPayee(CMutableTransaction& txNew, int64_t nFees, bool hasMNPayment)
{
CBlockIndex* pindexPrev = ::ChainActive().Tip();
if (!pindexPrev)
Expand All @@ -188,7 +188,7 @@ void SNFillBlockPayee(CMutableTransaction& txNew, int64_t nFees)
} else if (IsSporkActive(SPORK_13_ENABLE_SUPERBLOCKS) && budget.IsBudgetPaymentBlock(pindexPrev->nHeight + 1)) {
// Doesn't pay systemnode, miners get the full amount on these blocks
} else {
systemnodePayments.FillBlockPayee(txNew, nFees);
systemnodePayments.FillBlockPayee(txNew, nFees, hasMNPayment);
}
}

Expand All @@ -204,7 +204,7 @@ std::string SNGetRequiredPaymentsString(int nBlockHeight)
}
}

void CSystemnodePayments::FillBlockPayee(CMutableTransaction& txNew, int64_t nFees)
void CSystemnodePayments::FillBlockPayee(CMutableTransaction& txNew, int64_t nFees, bool hasMNPayment)
{
CBlockIndex* pindexPrev = ::ChainActive().Tip();
if(!pindexPrev) return;
Expand Down Expand Up @@ -252,6 +252,18 @@ void CSystemnodePayments::FillBlockPayee(CMutableTransaction& txNew, int64_t nFe

LogPrint(BCLog::NET, "Systemnode payment to %s\n", EncodeDestination(address1));
}

if(!hasMNPayment && hasPayment){
if(txNew.nVersion >= TX_ELE_VERSION){
txNew.vpout[1].scriptPubKey = payee;
txNew.vpout[1].nValue = 0;
txNew.vpout[1].nAsset = Params().GetConsensus().subsidy_asset;
}
else{
txNew.vout[1].scriptPubKey = payee;
txNew.vout[1].nValue = 0;
}
}
}

std::string CSystemnodeBlockPayees::GetRequiredPaymentsString()
Expand Down
4 changes: 2 additions & 2 deletions src/systemnode/systemnode-payments.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ extern CSystemnodePayments systemnodePayments;
#define SNPAYMENTS_SIGNATURES_TOTAL 10
#define SN_PMT_SLOT 2

void SNFillBlockPayee(CMutableTransaction& txNew, int64_t nFees);
void SNFillBlockPayee(CMutableTransaction& txNew, int64_t nFees, bool hasMNPayment);
bool SNIsBlockPayeeValid(const CAmount& nValueCreated, const CTransaction& txNew, int nBlockHeight, const uint32_t& nTime, const uint32_t& nTimePrevBlock);
std::string SNGetRequiredPaymentsString(int nBlockHeight);

Expand Down Expand Up @@ -216,7 +216,7 @@ class CSystemnodePayments
bool IsScheduled(CSystemnode& sn, int nNotBlockHeight);
bool CanVote(COutPoint outSystemnode, int nBlockHeight);
std::string GetRequiredPaymentsString(int nBlockHeight);
void FillBlockPayee(CMutableTransaction& txNew, int64_t nFees);
void FillBlockPayee(CMutableTransaction& txNew, int64_t nFees, bool hasMNPayment);
std::string ToString() const;

SERIALIZE_METHODS(CSystemnodePayments, obj)
Expand Down

0 comments on commit d18dcf8

Please sign in to comment.