Pass in _pk to CreateBlock
This commit is contained in:
@@ -158,19 +158,22 @@ int32_t decode_hex(uint8_t *bytes,int32_t n,char *hex);
|
|||||||
CScript Marmara_scriptPubKey(int32_t height,CPubKey pk);
|
CScript Marmara_scriptPubKey(int32_t height,CPubKey pk);
|
||||||
CScript MarmaraCoinbaseOpret(int32_t height,CPubKey pk);
|
CScript MarmaraCoinbaseOpret(int32_t height,CPubKey pk);
|
||||||
|
|
||||||
CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount, bool isStake)
|
CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32_t gpucount, bool isStake)
|
||||||
{
|
{
|
||||||
CScript scriptPubKeyIn(_scriptPubKeyIn);
|
CScript scriptPubKeyIn(_scriptPubKeyIn);
|
||||||
|
|
||||||
CPubKey pk = CPubKey();
|
CPubKey pk;
|
||||||
std::vector<std::vector<unsigned char>> vAddrs;
|
if ( _pk.size() != 33 )
|
||||||
txnouttype txT;
|
|
||||||
if ( scriptPubKeyIn.size() > 0 && Solver(scriptPubKeyIn, txT, vAddrs))
|
|
||||||
{
|
{
|
||||||
fprintf(stderr,"txT.%d vs TX_PUBKEY.%d\n",txT,TX_PUBKEY);
|
pk = CPubKey();
|
||||||
if (txT == TX_PUBKEY)
|
std::vector<std::vector<unsigned char>> vAddrs;
|
||||||
pk = CPubKey(vAddrs[0]);
|
txnouttype txT;
|
||||||
}
|
if ( scriptPubKeyIn.size() > 0 && Solver(scriptPubKeyIn, txT, vAddrs))
|
||||||
|
{
|
||||||
|
if (txT == TX_PUBKEY)
|
||||||
|
pk = CPubKey(vAddrs[0]);
|
||||||
|
}
|
||||||
|
} else pk = _pk;
|
||||||
|
|
||||||
uint64_t deposits; int32_t isrealtime,kmdheight; uint32_t blocktime; const CChainParams& chainparams = Params();
|
uint64_t deposits; int32_t isrealtime,kmdheight; uint32_t blocktime; const CChainParams& chainparams = Params();
|
||||||
//fprintf(stderr,"create new block\n");
|
//fprintf(stderr,"create new block\n");
|
||||||
@@ -790,7 +793,7 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey, int32_t nHeight,
|
|||||||
}
|
}
|
||||||
if ( ASSETCHAINS_MARMARA != 0 && nHeight > 0 && (nHeight & 1) == 0 )
|
if ( ASSETCHAINS_MARMARA != 0 && nHeight > 0 && (nHeight & 1) == 0 )
|
||||||
scriptPubKey = Marmara_scriptPubKey(nHeight,pubkey);
|
scriptPubKey = Marmara_scriptPubKey(nHeight,pubkey);
|
||||||
return CreateNewBlock(scriptPubKey, gpucount, isStake);
|
return CreateNewBlock(pubkey,scriptPubKey, gpucount, isStake);
|
||||||
}
|
}
|
||||||
|
|
||||||
void komodo_broadcast(CBlock *pblock,int32_t limit)
|
void komodo_broadcast(CBlock *pblock,int32_t limit)
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ struct CBlockTemplate
|
|||||||
#define KOMODO_MAXGPUCOUNT 65
|
#define KOMODO_MAXGPUCOUNT 65
|
||||||
|
|
||||||
/** Generate a new block, without valid proof-of-work */
|
/** Generate a new block, without valid proof-of-work */
|
||||||
CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn, int32_t gpucount, bool isStake = false);
|
CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& scriptPubKeyIn, int32_t gpucount, bool isStake = false);
|
||||||
#ifdef ENABLE_WALLET
|
#ifdef ENABLE_WALLET
|
||||||
boost::optional<CScript> GetMinerScriptPubKey(CReserveKey& reservekey);
|
boost::optional<CScript> GetMinerScriptPubKey(CReserveKey& reservekey);
|
||||||
CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey, int32_t nHeight, int32_t gpucount, bool isStake = false);
|
CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey, int32_t nHeight, int32_t gpucount, bool isStake = false);
|
||||||
|
|||||||
@@ -158,7 +158,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
|
|||||||
for (unsigned int i = 0; i < sizeof(blockinfo)/sizeof(*blockinfo); ++i)
|
for (unsigned int i = 0; i < sizeof(blockinfo)/sizeof(*blockinfo); ++i)
|
||||||
{
|
{
|
||||||
// Simple block creation, nothing special yet:
|
// Simple block creation, nothing special yet:
|
||||||
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey,-1));
|
BOOST_CHECK(pblocktemplate = CreateNewBlock(CPubKey(),scriptPubKey,-1));
|
||||||
|
|
||||||
CBlock *pblock = &pblocktemplate->block; // pointer for convenience
|
CBlock *pblock = &pblocktemplate->block; // pointer for convenience
|
||||||
pblock->nVersion = 4;
|
pblock->nVersion = 4;
|
||||||
@@ -273,7 +273,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Just to make sure we can still make simple blocks
|
// Just to make sure we can still make simple blocks
|
||||||
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey,-1));
|
BOOST_CHECK(pblocktemplate = CreateNewBlock(CPubKey(),scriptPubKey,-1));
|
||||||
delete pblocktemplate;
|
delete pblocktemplate;
|
||||||
|
|
||||||
// block sigops > limit: 1000 CHECKMULTISIG + 1
|
// block sigops > limit: 1000 CHECKMULTISIG + 1
|
||||||
@@ -292,7 +292,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
|
|||||||
mempool.addUnchecked(hash, entry.Time(GetTime()).SpendsCoinbase(spendsCoinbase).FromTx(tx));
|
mempool.addUnchecked(hash, entry.Time(GetTime()).SpendsCoinbase(spendsCoinbase).FromTx(tx));
|
||||||
tx.vin[0].prevout.hash = hash;
|
tx.vin[0].prevout.hash = hash;
|
||||||
}
|
}
|
||||||
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey,-1));
|
BOOST_CHECK(pblocktemplate = CreateNewBlock(CPubKey(),scriptPubKey,-1));
|
||||||
delete pblocktemplate;
|
delete pblocktemplate;
|
||||||
mempool.clear();
|
mempool.clear();
|
||||||
|
|
||||||
@@ -313,14 +313,14 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
|
|||||||
mempool.addUnchecked(hash, entry.Time(GetTime()).SpendsCoinbase(spendsCoinbase).FromTx(tx));
|
mempool.addUnchecked(hash, entry.Time(GetTime()).SpendsCoinbase(spendsCoinbase).FromTx(tx));
|
||||||
tx.vin[0].prevout.hash = hash;
|
tx.vin[0].prevout.hash = hash;
|
||||||
}
|
}
|
||||||
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey,-1));
|
BOOST_CHECK(pblocktemplate = CreateNewBlock(CPubKey(),scriptPubKey,-1));
|
||||||
delete pblocktemplate;
|
delete pblocktemplate;
|
||||||
mempool.clear();
|
mempool.clear();
|
||||||
|
|
||||||
// orphan in mempool
|
// orphan in mempool
|
||||||
hash = tx.GetHash();
|
hash = tx.GetHash();
|
||||||
mempool.addUnchecked(hash, entry.Time(GetTime()).FromTx(tx));
|
mempool.addUnchecked(hash, entry.Time(GetTime()).FromTx(tx));
|
||||||
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey,-1));
|
BOOST_CHECK(pblocktemplate = CreateNewBlock(CPubKey(),scriptPubKey,-1));
|
||||||
delete pblocktemplate;
|
delete pblocktemplate;
|
||||||
mempool.clear();
|
mempool.clear();
|
||||||
|
|
||||||
@@ -338,7 +338,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
|
|||||||
tx.vout[0].nValue = 49000LL;
|
tx.vout[0].nValue = 49000LL;
|
||||||
hash = tx.GetHash();
|
hash = tx.GetHash();
|
||||||
mempool.addUnchecked(hash, entry.Time(GetTime()).SpendsCoinbase(true).FromTx(tx));
|
mempool.addUnchecked(hash, entry.Time(GetTime()).SpendsCoinbase(true).FromTx(tx));
|
||||||
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey,-1));
|
BOOST_CHECK(pblocktemplate = CreateNewBlock(CPubKey(),scriptPubKey,-1));
|
||||||
delete pblocktemplate;
|
delete pblocktemplate;
|
||||||
mempool.clear();
|
mempool.clear();
|
||||||
|
|
||||||
@@ -349,7 +349,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
|
|||||||
tx.vout[0].nValue = 0;
|
tx.vout[0].nValue = 0;
|
||||||
hash = tx.GetHash();
|
hash = tx.GetHash();
|
||||||
mempool.addUnchecked(hash, entry.Time(GetTime()).SpendsCoinbase(false).FromTx(tx));
|
mempool.addUnchecked(hash, entry.Time(GetTime()).SpendsCoinbase(false).FromTx(tx));
|
||||||
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey,-1));
|
BOOST_CHECK(pblocktemplate = CreateNewBlock(CPubKey(),scriptPubKey,-1));
|
||||||
delete pblocktemplate;
|
delete pblocktemplate;
|
||||||
mempool.clear();
|
mempool.clear();
|
||||||
|
|
||||||
@@ -367,7 +367,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
|
|||||||
tx.vout[0].nValue -= 10000;
|
tx.vout[0].nValue -= 10000;
|
||||||
hash = tx.GetHash();
|
hash = tx.GetHash();
|
||||||
mempool.addUnchecked(hash, entry.Time(GetTime()).SpendsCoinbase(false).FromTx(tx));
|
mempool.addUnchecked(hash, entry.Time(GetTime()).SpendsCoinbase(false).FromTx(tx));
|
||||||
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey,-1));
|
BOOST_CHECK(pblocktemplate = CreateNewBlock(CPubKey(),scriptPubKey,-1));
|
||||||
delete pblocktemplate;
|
delete pblocktemplate;
|
||||||
mempool.clear();
|
mempool.clear();
|
||||||
|
|
||||||
@@ -381,17 +381,17 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
|
|||||||
tx.vout[0].scriptPubKey = CScript() << OP_2;
|
tx.vout[0].scriptPubKey = CScript() << OP_2;
|
||||||
hash = tx.GetHash();
|
hash = tx.GetHash();
|
||||||
mempool.addUnchecked(hash, entry.Time(GetTime()).SpendsCoinbase(true).FromTx(tx));
|
mempool.addUnchecked(hash, entry.Time(GetTime()).SpendsCoinbase(true).FromTx(tx));
|
||||||
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey,-1));
|
BOOST_CHECK(pblocktemplate = CreateNewBlock(CPubKey(),scriptPubKey,-1));
|
||||||
delete pblocktemplate;
|
delete pblocktemplate;
|
||||||
mempool.clear();
|
mempool.clear();
|
||||||
|
|
||||||
// subsidy changing
|
// subsidy changing
|
||||||
int nHeight = chainActive.Height();
|
int nHeight = chainActive.Height();
|
||||||
chainActive.Tip()->SetHeight(209999);
|
chainActive.Tip()->SetHeight(209999);
|
||||||
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey,-1));
|
BOOST_CHECK(pblocktemplate = CreateNewBlock(CPubKey(),scriptPubKey,-1));
|
||||||
delete pblocktemplate;
|
delete pblocktemplate;
|
||||||
chainActive.Tip()->SetHeight(210000);
|
chainActive.Tip()->SetHeight(210000);
|
||||||
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey,-1));
|
BOOST_CHECK(pblocktemplate = CreateNewBlock(CPubKey(),scriptPubKey,-1));
|
||||||
delete pblocktemplate;
|
delete pblocktemplate;
|
||||||
chainActive.Tip()->SetHeight(nHeight);
|
chainActive.Tip()->SetHeight(nHeight);
|
||||||
|
|
||||||
@@ -423,7 +423,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
|
|||||||
mempool.addUnchecked(hash, entry.Time(GetTime()).SpendsCoinbase(true).FromTx(tx2));
|
mempool.addUnchecked(hash, entry.Time(GetTime()).SpendsCoinbase(true).FromTx(tx2));
|
||||||
BOOST_CHECK(!CheckFinalTx(tx2, LOCKTIME_MEDIAN_TIME_PAST));
|
BOOST_CHECK(!CheckFinalTx(tx2, LOCKTIME_MEDIAN_TIME_PAST));
|
||||||
|
|
||||||
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey,-1));
|
BOOST_CHECK(pblocktemplate = CreateNewBlock(CPubKey(),scriptPubKey,-1));
|
||||||
|
|
||||||
// Neither tx should have made it into the template.
|
// Neither tx should have made it into the template.
|
||||||
BOOST_CHECK_EQUAL(pblocktemplate->block.vtx.size(), 1);
|
BOOST_CHECK_EQUAL(pblocktemplate->block.vtx.size(), 1);
|
||||||
@@ -438,7 +438,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
|
|||||||
//BOOST_CHECK(CheckFinalTx(tx));
|
//BOOST_CHECK(CheckFinalTx(tx));
|
||||||
//BOOST_CHECK(CheckFinalTx(tx2));
|
//BOOST_CHECK(CheckFinalTx(tx2));
|
||||||
|
|
||||||
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey,-1));
|
BOOST_CHECK(pblocktemplate = CreateNewBlock(CPubKey(),scriptPubKey,-1));
|
||||||
BOOST_CHECK_EQUAL(pblocktemplate->block.vtx.size(), 2);
|
BOOST_CHECK_EQUAL(pblocktemplate->block.vtx.size(), 2);
|
||||||
delete pblocktemplate;
|
delete pblocktemplate;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user