mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-02-15 11:45:51 +00:00
Check depth of spent coinbases during connectTransactions.
This commit is contained in:
parent
c789b757f3
commit
ef6e1b89ca
@ -86,7 +86,6 @@ public class FullPrunedBlockChain extends AbstractBlockChain {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//TODO: Remove lots of duplicated code in the two connectTransactions
|
//TODO: Remove lots of duplicated code in the two connectTransactions
|
||||||
//TODO: More checking can be done here (eg spent-coinbase depth check)
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected TransactionOutputChanges connectTransactions(int height, Block block)
|
protected TransactionOutputChanges connectTransactions(int height, Block block)
|
||||||
@ -132,6 +131,11 @@ public class FullPrunedBlockChain extends AbstractBlockChain {
|
|||||||
in.getOutpoint().getIndex());
|
in.getOutpoint().getIndex());
|
||||||
if (prevOut == null)
|
if (prevOut == null)
|
||||||
throw new VerificationException("Attempted to spend a non-existent or already spent output!");
|
throw new VerificationException("Attempted to spend a non-existent or already spent output!");
|
||||||
|
// Coinbases can't be spent until they mature, to avoid re-orgs destroying entire transaction
|
||||||
|
// chains. The assumption is there will ~never be re-orgs deeper than the spendable coinbase
|
||||||
|
// chain depth.
|
||||||
|
if (height - prevOut.getHeight() < params.getSpendableCoinbaseDepth())
|
||||||
|
throw new VerificationException("Tried to spend coinbase at depth " + (height - prevOut.getHeight()));
|
||||||
// TODO: Check we're not spending the genesis transaction here. Satoshis code won't allow it.
|
// TODO: Check we're not spending the genesis transaction here. Satoshis code won't allow it.
|
||||||
if (enforceBIP16) {
|
if (enforceBIP16) {
|
||||||
try {
|
try {
|
||||||
@ -206,6 +210,8 @@ public class FullPrunedBlockChain extends AbstractBlockChain {
|
|||||||
in.getOutpoint().getIndex());
|
in.getOutpoint().getIndex());
|
||||||
if (prevOut == null)
|
if (prevOut == null)
|
||||||
throw new VerificationException("Attempted spend of a non-existent or already spent output!");
|
throw new VerificationException("Attempted spend of a non-existent or already spent output!");
|
||||||
|
if (newBlock.getHeight() - prevOut.getHeight() < params.getSpendableCoinbaseDepth())
|
||||||
|
throw new VerificationException("Tried to spend coinbase at depth " + (newBlock.getHeight() - prevOut.getHeight()));
|
||||||
if (enforcePayToScriptHash) {
|
if (enforcePayToScriptHash) {
|
||||||
try {
|
try {
|
||||||
Script script = new Script(params, prevOut.getScriptBytes(), 0, prevOut.getScriptBytes().length);
|
Script script = new Script(params, prevOut.getScriptBytes(), 0, prevOut.getScriptBytes().length);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user