Skip to content

Commit

Permalink
Merge pull request #83 from BlockMechanic/segwit
Browse files Browse the repository at this point in the history
Segwit
  • Loading branch information
BlockMechanic authored Jul 14, 2022
2 parents cf87cdf + 2c644bc commit 16991c6
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 15 deletions.
13 changes: 11 additions & 2 deletions src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,11 @@ class CMainParams : public CChainParams {
nStakePointerValidityPeriod = 4320; //Stake pointers are valid to stake with for the next 3 day worth of blocks
nMaxReorgDepth = 100;
nKernelModifierOffset = 100;

std::vector<unsigned char> addrdata(ParseHex("0014848a4a37883c295bc1dc021941e0f185fafc1aae"));
CScript genscript(addrdata.begin(), addrdata.end());
consensus.mandatory_coinbase_destination = genscript;

genesis = CreateGenesisBlock(1412760826, 1612467894, 0x1d00ffff, 1, 10 * COIN, consensus);

consensus.hashGenesisBlock = genesis.GetHash();
Expand Down Expand Up @@ -292,10 +297,14 @@ class CTestNetParams : public CChainParams {
m_assumed_blockchain_size = 1;
m_assumed_chain_state_size = 1;

genesis = CreateGenesisBlock(1657000537, 2343754, 0x1e0ffff0, 1, 10 * COIN, consensus);
std::vector<unsigned char> addrdata(ParseHex("0014848a4a37883c295bc1dc021941e0f185fafc1aae"));
CScript genscript(addrdata.begin(), addrdata.end());
consensus.mandatory_coinbase_destination = genscript;

genesis = CreateGenesisBlock(1657811432, 98, 0x1e0ffff0, 1, 10 * COIN, consensus);
consensus.hashGenesisBlock = genesis.GetHash();
//MineNewGenesisBlock(consensus,genesis);
assert(consensus.hashGenesisBlock == uint256S("0x00000a145849947660e2a489b750c2cb779f5bc438597feb8f5c138a71313a62"));
assert(consensus.hashGenesisBlock == uint256S("0x00000850f701bcce35569afca8e518568761b56920050a1d4167741448ec7a99"));
assert(genesis.hashMerkleRoot == uint256S("0x80ad356118a9ab8db192db66ef77146cc36d958f959251feace550e4ca3d1446"));

vFixedSeeds.clear();
Expand Down
2 changes: 1 addition & 1 deletion src/primitives/asset.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ struct CAsset : public AssetMetadata

friend bool operator==(const CAsset& a, const CAsset& b)
{
return a.assetID == b.assetID && a.getName() == b.getName();
return a.assetID == b.assetID;
}

friend bool operator!=(const CAsset& a, const CAsset& b)
Expand Down
40 changes: 29 additions & 11 deletions src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -625,22 +625,40 @@ bool MemPoolAccept::PreChecks(ATMPArgs& args, Workspace& ws)

{ //data checking is done here
bool fHasFee = false;
for (unsigned int k = 0; k < (tx.nVersion >= TX_ELE_VERSION ? tx.vpout.size() : tx.vout.size()) ; k++){
for (unsigned int k = 0; k < (tx.nVersion >= TX_ELE_VERSION ? tx.vpout.size() : tx.vout.size()) ; k++){
CTxOutAsset txout = (tx.nVersion >= TX_ELE_VERSION ? tx.vpout[k] : tx.vout[k]);
if(txout.scriptPubKey == Params().GetConsensus().mandatory_coinbase_destination && txout.nAsset == Params().GetConsensus().subsidy_asset && txout.nValue == 10.0001 * COIN)

bool sub_address = false;
sub_address = txout.scriptPubKey == Params().GetConsensus().mandatory_coinbase_destination;
if(sub_address)
LogPrintf("%s: Subsidy address found \n", __func__);

bool sub_asset = false;
sub_asset = txout.nAsset == Params().GetConsensus().subsidy_asset;
if(sub_asset)
LogPrintf("%s: Subsidy asset found \n", __func__);
else
LogPrintf("%s: Subsidy asset not found %s vs %s \n", __func__, txout.nAsset.assetID.ToString(), Params().GetConsensus().subsidy_asset.assetID.ToString());

bool sub_fee = false;
sub_fee = txout.nValue == 10.0001 * COIN;
if(sub_fee)
LogPrintf("%s: Subsidy fee found \n", __func__);

if(sub_address /*&& sub_asset*/ && sub_fee)
fHasFee = true;
}

for (unsigned int i = 0; i < tx.vdata.size(); i++){
uint8_t vers = tx.vdata[i].get()->GetVersion();
switch(vers){
case OUTPUT_CONTRACT:{
CContract *contract = (CContract*)tx.vdata[i].get();
if(pcontractCache->Exists(contract->asset_name) || ExistsContract(contract->asset_name)){
return state.Invalid(TxValidationResult::TX_CONSENSUS, strprintf("%s: Contract DB already contains an entry with this name.\n", __func__));
}
if(!fHasFee)
return state.Invalid(TxValidationResult::TX_CONSENSUS, strprintf("%s: Contract registry has no fees.\n", __func__));
uint8_t vers = tx.vdata[i].get()->GetVersion();
switch(vers){
case OUTPUT_CONTRACT:{
CContract *contract = (CContract*)tx.vdata[i].get();
if(pcontractCache->Exists(contract->asset_name) || ExistsContract(contract->asset_name)){
return state.Invalid(TxValidationResult::TX_CONSENSUS, strprintf("%s: Contract DB already contains an entry with this name.\n", __func__));
}
if(!fHasFee)
return state.Invalid(TxValidationResult::TX_CONSENSUS, strprintf("%s: Contract registry has no fees.\n", __func__));
break;
}
case OUTPUT_DATA:{
Expand Down
2 changes: 1 addition & 1 deletion src/wallet/coincontrol.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class CCoinControl
vOutpoints.assign(setSelected.begin(), setSelected.end());
}

private:
//private:
std::set<COutPoint> setSelected;
};

Expand Down
5 changes: 5 additions & 0 deletions src/wallet/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3277,6 +3277,11 @@ bool CWallet::CreateContract(CContract& contract, CTransactionRef& tx, std::stri
coin_control.Select(COutPoint(out.tx->GetHash(), out.i));
}

if(coin_control.setSelected.size() < 1){
strFailReason ="No suitable output found";
return false;
}

mapValue_t mapValue;

//coin_control.m_add_inputs = false;
Expand Down

0 comments on commit 16991c6

Please sign in to comment.