Implement BIP0065 changeover logic for v4 blocks.
This commit implements the changeover logic for version 4 blocks as described by BIP0065.
This commit is contained in:
parent
3d6afcffe7
commit
7811770d31
3 changed files with 21 additions and 2 deletions
|
@ -653,6 +653,16 @@ func (b *BlockChain) checkBlockHeaderContext(header *wire.BlockHeader, prevNode
|
||||||
}
|
}
|
||||||
|
|
||||||
if !fastAdd {
|
if !fastAdd {
|
||||||
|
// Reject version 3 blocks once a majority of the network has
|
||||||
|
// upgraded. This is part of BIP0065.
|
||||||
|
if header.Version < 4 && b.isMajorityVersion(4, prevNode,
|
||||||
|
b.chainParams.BlockRejectNumRequired) {
|
||||||
|
|
||||||
|
str := "new blocks with version %d are no longer valid"
|
||||||
|
str = fmt.Sprintf(str, header.Version)
|
||||||
|
return ruleError(ErrBlockVersionTooOld, str)
|
||||||
|
}
|
||||||
|
|
||||||
// Reject version 2 blocks once a majority of the network has
|
// Reject version 2 blocks once a majority of the network has
|
||||||
// upgraded. This is part of BIP0066.
|
// upgraded. This is part of BIP0066.
|
||||||
if header.Version < 3 && b.isMajorityVersion(3, prevNode,
|
if header.Version < 3 && b.isMajorityVersion(3, prevNode,
|
||||||
|
@ -1133,6 +1143,15 @@ func (b *BlockChain) checkConnectBlock(node *blockNode, block *btcutil.Block) er
|
||||||
scriptFlags |= txscript.ScriptVerifyDERSignatures
|
scriptFlags |= txscript.ScriptVerifyDERSignatures
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Enforce CHECKLOCKTIMEVERIFY for block versions 4+ once the majority
|
||||||
|
// of the network has upgraded to the enforcement threshold. This is
|
||||||
|
// part of BIP0065.
|
||||||
|
if blockHeader.Version >= 4 && b.isMajorityVersion(4, prevNode,
|
||||||
|
b.chainParams.BlockEnforceNumRequired) {
|
||||||
|
|
||||||
|
scriptFlags |= txscript.ScriptVerifyCheckLockTimeVerify
|
||||||
|
}
|
||||||
|
|
||||||
// Now that the inexpensive checks are done and have passed, verify the
|
// Now that the inexpensive checks are done and have passed, verify the
|
||||||
// transactions are actually allowed to spend the coins by running the
|
// transactions are actually allowed to spend the coins by running the
|
||||||
// expensive ECDSA signature check scripts. Doing this last helps
|
// expensive ECDSA signature check scripts. Doing this last helps
|
||||||
|
|
|
@ -24,7 +24,7 @@ const (
|
||||||
// will require changes to the generated block. Using the wire constant
|
// will require changes to the generated block. Using the wire constant
|
||||||
// for generated block version could allow creation of invalid blocks
|
// for generated block version could allow creation of invalid blocks
|
||||||
// for the updated version.
|
// for the updated version.
|
||||||
generatedBlockVersion = 3
|
generatedBlockVersion = 4
|
||||||
|
|
||||||
// minHighPriority is the minimum priority value that allows a
|
// minHighPriority is the minimum priority value that allows a
|
||||||
// transaction to be considered high priority.
|
// transaction to be considered high priority.
|
||||||
|
|
|
@ -11,7 +11,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// BlockVersion is the current latest supported block version.
|
// BlockVersion is the current latest supported block version.
|
||||||
const BlockVersion = 3
|
const BlockVersion = 4
|
||||||
|
|
||||||
// MaxBlockHeaderPayload is the maximum number of bytes a block header can be.
|
// MaxBlockHeaderPayload is the maximum number of bytes a block header can be.
|
||||||
// Version 4 bytes + Timestamp 4 bytes + Bits 4 bytes + Nonce 4 bytes +
|
// Version 4 bytes + Timestamp 4 bytes + Bits 4 bytes + Nonce 4 bytes +
|
||||||
|
|
Loading…
Reference in a new issue