Skip to content

Commit

Permalink
[Miner] Enable PoW block creations with custom coinbase script
Browse files Browse the repository at this point in the history
  • Loading branch information
furszy committed Apr 6, 2021
1 parent a4da3a8 commit 50d99bb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
10 changes: 6 additions & 4 deletions src/miner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,12 @@ int64_t nHPSTimerStart = 0;
std::unique_ptr<CBlockTemplate> CreateNewBlockWithKey(CReserveKey* reservekey, CWallet* pwallet)
{
CPubKey pubkey;
if (!reservekey->GetReservedKey(pubkey))
return nullptr;
if (!reservekey->GetReservedKey(pubkey)) return nullptr;
return CreateNewBlockWithScript(GetScriptForDestination(pubkey.GetID()), pwallet);
}

std::unique_ptr<CBlockTemplate> CreateNewBlockWithScript(const CScript& coinbaseScript, CWallet* pwallet)
{
const int nHeightNext = chainActive.Tip()->nHeight + 1;

// If we're building a late PoW block, don't continue
Expand All @@ -56,8 +59,7 @@ std::unique_ptr<CBlockTemplate> CreateNewBlockWithKey(CReserveKey* reservekey, C
return nullptr;
}

CScript scriptPubKey = GetScriptForDestination(pubkey.GetID());
return BlockAssembler(Params(), DEFAULT_PRINTPRIORITY).CreateNewBlock(scriptPubKey, pwallet, false);
return BlockAssembler(Params(), DEFAULT_PRINTPRIORITY).CreateNewBlock(coinbaseScript, pwallet, false);
}

bool ProcessBlockFound(const std::shared_ptr<const CBlock>& pblock, CWallet& wallet, Optional<CReserveKey>& reservekey)
Expand Down
3 changes: 2 additions & 1 deletion src/miner.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ static const bool DEFAULT_PRINTPRIORITY = false;
#ifdef ENABLE_WALLET
/** Run the miner threads */
void GenerateBitcoins(bool fGenerate, CWallet* pwallet, int nThreads);
/** Generate a new block, without valid proof-of-work */
/** Generate a new PoW block, without valid proof-of-work */
std::unique_ptr<CBlockTemplate> CreateNewBlockWithKey(CReserveKey* reservekey, CWallet* pwallet);
std::unique_ptr<CBlockTemplate> CreateNewBlockWithScript(const CScript& coinbaseScript, CWallet* pwallet);

void BitcoinMiner(CWallet* pwallet, bool fProofOfStake);
void ThreadStakeMinter();
Expand Down

0 comments on commit 50d99bb

Please sign in to comment.