Change initial issuance output to 1

This commit is contained in:
nkostoulas 2018-05-17 14:36:21 +01:00
parent 7a3720a1d5
commit 1136ad3a96
6 changed files with 160 additions and 151 deletions

View file

@ -63,8 +63,8 @@ class BlockchainTest(BitcoinTestFramework):
assert 'total_amount' not in res
assert_equal(res['transactions'], 1)
assert_equal(res['height'], 200)
assert_equal(res['txouts'], 100)
assert_equal(res['bytes_serialized'], 3948),
assert_equal(res['txouts'], 1)
assert_equal(res['bytes_serialized'], 75),
assert_equal(len(res['bestblock']), 64)
assert_equal(len(res['hash_serialized']), 64)

File diff suppressed because one or more lines are too long

View file

@ -30,10 +30,10 @@ class WalletTest (BitcoinTestFramework):
def run_test (self):
# Check that there's 100 UTXOs on each of the nodes
assert_equal(len(self.nodes[0].listunspent()), 100)
assert_equal(len(self.nodes[1].listunspent()), 100)
assert_equal(len(self.nodes[2].listunspent()), 100)
# Check that there's 1 UTXO on each of the nodes
assert_equal(len(self.nodes[0].listunspent()), 1)
assert_equal(len(self.nodes[1].listunspent()), 1)
assert_equal(len(self.nodes[2].listunspent()), 1)
walletinfo = self.nodes[0].getwalletinfo()
assert_equal(walletinfo['balance']["bitcoin"], 21000000)

View file

@ -200,7 +200,7 @@ public:
genesis = CreateGenesisBlock(consensus, strNetworkID, 1296688602, genesisChallengeScript, 1);
if (initialFreeCoins != 0) {
AppendInitialIssuance(genesis, COutPoint(uint256(commit), 0), parentGenesisBlockHash, 100, initialFreeCoins/100, 0, 0, CScript() << OP_TRUE);
AppendInitialIssuance(genesis, COutPoint(uint256(commit), 0), parentGenesisBlockHash, 1, initialFreeCoins, 0, 0, CScript() << OP_TRUE);
}
consensus.hashGenesisBlock = genesis.GetHash();

View file

@ -48,7 +48,7 @@ BOOST_FIXTURE_TEST_CASE(tx_mempool_block_doublespend, TestChain100Setup)
spends[i].vout[0].nValue = 11*CENT;
spends[i].vout[0].scriptPubKey = scriptPubKey;
spends[i].vout[0].nAsset = Params().GetConsensus().pegged_asset;
spends[i].vout[1].nValue = MAX_MONEY/100-11*CENT;
spends[i].vout[1].nValue = MAX_MONEY-11*CENT;
spends[i].vout[1].nAsset = Params().GetConsensus().pegged_asset;
spends[i].vout[1].scriptPubKey = CScript();

View file

@ -2067,7 +2067,16 @@ bool ApplyTxInUndo(const CTxInUndo& undo, CCoinsViewCache& view, const COutPoint
CCoinsModifier coins = view.ModifyCoins(out.hash);
if (undo.nHeight != 0 ||
// Special-case genesis since nHeight is always 0, assume DB is clean
(Params().GenesisBlock().vtx[0]->GetHash() == out.hash && coins->IsPruned())) {
(Params().GenesisBlock().vtx[0]->GetHash() == out.hash && coins->IsPruned()) ||
// Special-case for initial issuance since being a single output nHeight is always 0
(Params().GenesisBlock().vtx.size() > 1 && [&]() {
for (const auto& tx : Params().GenesisBlock().vtx) {
if (tx->GetHash() == out.hash) {
return true;
}
}
return false;
}() && coins->IsPruned())) {
// undo data contains height: this is the last output of the prevout tx being spent
if (!coins->IsPruned())
fClean = fClean && error("%s: undo data overwriting existing transaction", __func__);