mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-02-07 06:44:16 +00:00
Make genesis coinbase unspendable.
This commit is contained in:
parent
282b58c5ea
commit
49d26f6e28
@ -67,6 +67,7 @@ public interface FullPrunedBlockStore extends BlockStore {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes a {@link StoredTransactionOutput} from the list of unspent TransactionOutputs
|
* Removes a {@link StoredTransactionOutput} from the list of unspent TransactionOutputs
|
||||||
|
* Note that the coinbase of the genesis block should NEVER be spendable and thus never in the list.
|
||||||
* @throws BlockStoreException if there is an underlying storage issue, or out was not in the list.
|
* @throws BlockStoreException if there is an underlying storage issue, or out was not in the list.
|
||||||
*/
|
*/
|
||||||
void removeUnspentTransactionOutput(StoredTransactionOutput out) throws BlockStoreException;
|
void removeUnspentTransactionOutput(StoredTransactionOutput out) throws BlockStoreException;
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
package com.google.bitcoin.store;
|
package com.google.bitcoin.store;
|
||||||
|
|
||||||
import com.google.bitcoin.core.*;
|
import com.google.bitcoin.core.*;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@ -196,12 +197,10 @@ public class H2FullPrunedBlockStore implements FullPrunedBlockStore {
|
|||||||
// Set up the genesis block. When we start out fresh, it is by
|
// Set up the genesis block. When we start out fresh, it is by
|
||||||
// definition the top of the chain.
|
// definition the top of the chain.
|
||||||
StoredBlock storedGenesisHeader = new StoredBlock(params.genesisBlock.cloneAsHeader(), params.genesisBlock.getWork(), 0);
|
StoredBlock storedGenesisHeader = new StoredBlock(params.genesisBlock.cloneAsHeader(), params.genesisBlock.getWork(), 0);
|
||||||
|
// The coinbase in the genesis block is not spendable. This is because of how the reference client inits
|
||||||
LinkedList<StoredTransaction> genesisTransactions = new LinkedList<StoredTransaction>();
|
// its database - the genesis transaction isn't actually in the db so its spent flags can never be updated.
|
||||||
for (Transaction tx : params.genesisBlock.getTransactions())
|
List<StoredTransaction> genesisTransactions = Lists.newLinkedList();
|
||||||
genesisTransactions.add(new StoredTransaction(tx, 0));
|
|
||||||
StoredUndoableBlock storedGenesis = new StoredUndoableBlock(params.genesisBlock.getHash(), genesisTransactions);
|
StoredUndoableBlock storedGenesis = new StoredUndoableBlock(params.genesisBlock.getHash(), genesisTransactions);
|
||||||
|
|
||||||
put(storedGenesisHeader, storedGenesis);
|
put(storedGenesisHeader, storedGenesis);
|
||||||
setChainHead(storedGenesisHeader);
|
setChainHead(storedGenesisHeader);
|
||||||
} catch (VerificationException e) {
|
} catch (VerificationException e) {
|
||||||
|
@ -19,6 +19,7 @@ package com.google.bitcoin.store;
|
|||||||
import com.google.bitcoin.core.*;
|
import com.google.bitcoin.core.*;
|
||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@ -238,12 +239,9 @@ public class MemoryFullPrunedBlockStore implements FullPrunedBlockStore {
|
|||||||
// Insert the genesis block.
|
// Insert the genesis block.
|
||||||
try {
|
try {
|
||||||
StoredBlock storedGenesisHeader = new StoredBlock(params.genesisBlock.cloneAsHeader(), params.genesisBlock.getWork(), 0);
|
StoredBlock storedGenesisHeader = new StoredBlock(params.genesisBlock.cloneAsHeader(), params.genesisBlock.getWork(), 0);
|
||||||
|
// The coinbase in the genesis block is not spendable
|
||||||
LinkedList<StoredTransaction> genesisTransactions = new LinkedList<StoredTransaction>();
|
List<StoredTransaction> genesisTransactions = Lists.newLinkedList();
|
||||||
for (Transaction tx : params.genesisBlock.getTransactions())
|
|
||||||
genesisTransactions.add(new StoredTransaction(tx, 0));
|
|
||||||
StoredUndoableBlock storedGenesis = new StoredUndoableBlock(params.genesisBlock.getHash(), genesisTransactions);
|
StoredUndoableBlock storedGenesis = new StoredUndoableBlock(params.genesisBlock.getHash(), genesisTransactions);
|
||||||
|
|
||||||
put(storedGenesisHeader, storedGenesis);
|
put(storedGenesisHeader, storedGenesis);
|
||||||
setChainHead(storedGenesisHeader);
|
setChainHead(storedGenesisHeader);
|
||||||
} catch (BlockStoreException e) {
|
} catch (BlockStoreException e) {
|
||||||
|
Loading…
Reference in New Issue
Block a user