|
4 | 4 |
|
5 | 5 | #include <test/util.h> |
6 | 6 |
|
7 | | -#include <chainparams.h> |
8 | | -#include <consensus/merkle.h> |
9 | 7 | #include <key_io.h> |
10 | | -#include <miner.h> |
11 | 8 | #include <outputtype.h> |
12 | | -#include <pow.h> |
13 | 9 | #include <script/standard.h> |
14 | | -#include <validation.h> |
15 | | -#include <validationinterface.h> |
16 | 10 | #ifdef ENABLE_WALLET |
17 | 11 | #include <wallet/wallet.h> |
18 | 12 | #endif |
@@ -44,41 +38,3 @@ void importaddress(CWallet& wallet, const std::string& address) |
44 | 38 | wallet.SetAddressBook(dest, /* label */ "", "receive"); |
45 | 39 | } |
46 | 40 | #endif // ENABLE_WALLET |
47 | | - |
48 | | -CTxIn generatetoaddress(const std::string& address) |
49 | | -{ |
50 | | - const auto dest = DecodeDestination(address); |
51 | | - assert(IsValidDestination(dest)); |
52 | | - const auto coinbase_script = GetScriptForDestination(dest); |
53 | | - |
54 | | - return MineBlock(coinbase_script); |
55 | | -} |
56 | | - |
57 | | -CTxIn MineBlock(const CScript& coinbase_scriptPubKey) |
58 | | -{ |
59 | | - auto block = PrepareBlock(coinbase_scriptPubKey); |
60 | | - |
61 | | - while (!CheckProofOfWork(block->GetHash(), block->nBits, Params().GetConsensus())) { |
62 | | - ++block->nNonce; |
63 | | - assert(block->nNonce); |
64 | | - } |
65 | | - |
66 | | - bool processed{ProcessNewBlock(Params(), block, true, nullptr)}; |
67 | | - assert(processed); |
68 | | - |
69 | | - return CTxIn{block->vtx[0]->GetHash(), 0}; |
70 | | -} |
71 | | - |
72 | | -std::shared_ptr<CBlock> PrepareBlock(const CScript& coinbase_scriptPubKey) |
73 | | -{ |
74 | | - auto block = std::make_shared<CBlock>( |
75 | | - BlockAssembler{Params()} |
76 | | - .CreateNewBlock(coinbase_scriptPubKey) |
77 | | - ->block); |
78 | | - |
79 | | - LOCK(cs_main); |
80 | | - block->nTime = ::ChainActive().Tip()->GetMedianTimePast() + 1; |
81 | | - block->hashMerkleRoot = BlockMerkleRoot(*block); |
82 | | - |
83 | | - return block; |
84 | | -} |
0 commit comments