mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-03-30 15:08:33 +00:00
[DEV-18] Remove CSV and CLTV soft fork logic - convert to base protocol (#26)
* [DEV-18] changed CSV/CLTV to be regular op codes, and returned nop2 and nop3 to be regular nops * [DEV-18] remove csv/cltv flags - part 1 * [DEV-18] remove csv/cltv flags - part 2 * [DEV-18] remove csv/cltv activation rules * [DEV-18] remove csv/cltv activation rules * [DEV-18] csv_fork_test fixes * [DEV-18] readd chain params * [DEV-18] readd chain params and remove csv activation rules * [DEV-18] returned build flags to integration test * [DEV-18] make csv/cltv to pop the the first element of the stack instead of peeking it * [DEV-18] fix comments related to CSV/CLTV to remove any reference to soft fork * [DEV-18] fix comments related to CSV/CLTV to remove any reference to soft fork * [DEV-18] rename csv_fork_test.go to csv_fork.go * [DEV-18] change mTx location * [DEV-18] remove BIP0065Height * [DEV-18] add function isUpgradableNop for readability
This commit is contained in:
parent
44ce294d6b
commit
d472600155
@ -358,36 +358,13 @@ func (b *BlockChain) CalcSequenceLock(tx *btcutil.Tx, utxoView *UtxoViewpoint, m
|
||||
func (b *BlockChain) calcSequenceLock(node *blockNode, tx *btcutil.Tx, utxoView *UtxoViewpoint, mempool bool) (*SequenceLock, error) {
|
||||
// A value of -1 for each relative lock type represents a relative time
|
||||
// lock value that will allow a transaction to be included in a block
|
||||
// at any given height or time. This value is returned as the relative
|
||||
// lock time in the case that BIP 68 is disabled, or has not yet been
|
||||
// activated.
|
||||
// at any given height or time.
|
||||
sequenceLock := &SequenceLock{Seconds: -1, BlockHeight: -1}
|
||||
|
||||
// The sequence locks semantics are always active for transactions
|
||||
// within the mempool.
|
||||
csvSoftforkActive := mempool
|
||||
|
||||
// If we're performing block validation, then we need to query the BIP9
|
||||
// state.
|
||||
if !csvSoftforkActive {
|
||||
// Obtain the latest BIP9 version bits state for the
|
||||
// CSV-package soft-fork deployment. The adherence of sequence
|
||||
// locks depends on the current soft-fork state.
|
||||
csvState, err := b.deploymentState(node.parent, chaincfg.DeploymentCSV)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
csvSoftforkActive = csvState == ThresholdActive
|
||||
}
|
||||
|
||||
// If the transaction's version is less than 2, and BIP 68 has not yet
|
||||
// been activated then sequence locks are disabled. Additionally,
|
||||
// sequence locks don't apply to coinbase transactions Therefore, we
|
||||
// Sequence locks don't apply to coinbase transactions Therefore, we
|
||||
// return sequence lock values of -1 indicating that this transaction
|
||||
// can be included within a block at any given height or time.
|
||||
mTx := tx.MsgTx()
|
||||
sequenceLockActive := mTx.Version >= 2 && csvSoftforkActive
|
||||
if !sequenceLockActive || IsCoinBase(tx) {
|
||||
if IsCoinBase(tx) {
|
||||
return sequenceLock, nil
|
||||
}
|
||||
|
||||
@ -395,6 +372,7 @@ func (b *BlockChain) calcSequenceLock(node *blockNode, tx *btcutil.Tx, utxoView
|
||||
// inputs present in the mempool.
|
||||
nextHeight := node.height + 1
|
||||
|
||||
mTx := tx.MsgTx()
|
||||
for txInIndex, txIn := range mTx.TxIn {
|
||||
utxo := utxoView.LookupEntry(txIn.PreviousOutPoint)
|
||||
if utxo == nil {
|
||||
|
@ -118,18 +118,14 @@ func TestHaveBlock(t *testing.T) {
|
||||
func TestCalcSequenceLock(t *testing.T) {
|
||||
netParams := &chaincfg.SimNetParams
|
||||
|
||||
// We need to activate CSV in order to test the processing logic, so
|
||||
// manually craft the block version that's used to signal the soft-fork
|
||||
// activation.
|
||||
csvBit := netParams.Deployments[chaincfg.DeploymentCSV].BitNumber
|
||||
blockVersion := int32(0x20000000 | (uint32(1) << csvBit))
|
||||
blockVersion := int32(0x20000000)
|
||||
|
||||
// Generate enough synthetic blocks to activate CSV.
|
||||
// Generate enough synthetic blocks for the rest of the test
|
||||
chain := newFakeChain(netParams)
|
||||
node := chain.bestChain.Tip()
|
||||
blockTime := node.Header().Timestamp
|
||||
numBlocksToActivate := (netParams.MinerConfirmationWindow * 3)
|
||||
for i := uint32(0); i < numBlocksToActivate; i++ {
|
||||
numBlocksToGenerate := uint32(5)
|
||||
for i := uint32(0); i < numBlocksToGenerate; i++ {
|
||||
blockTime = blockTime.Add(time.Second)
|
||||
node = newFakeNode(node, blockVersion, 0, blockTime)
|
||||
chain.index.AddNode(node)
|
||||
@ -146,7 +142,7 @@ func TestCalcSequenceLock(t *testing.T) {
|
||||
}},
|
||||
})
|
||||
utxoView := NewUtxoViewpoint()
|
||||
utxoView.AddTxOuts(targetTx, int32(numBlocksToActivate)-4)
|
||||
utxoView.AddTxOuts(targetTx, int32(numBlocksToGenerate)-4)
|
||||
utxoView.SetBestHash(&node.hash)
|
||||
|
||||
// Create a utxo that spends the fake utxo created above for use in the
|
||||
@ -158,7 +154,7 @@ func TestCalcSequenceLock(t *testing.T) {
|
||||
Hash: *targetTx.Hash(),
|
||||
Index: 0,
|
||||
}
|
||||
prevUtxoHeight := int32(numBlocksToActivate) - 4
|
||||
prevUtxoHeight := int32(numBlocksToGenerate) - 4
|
||||
|
||||
// Obtain the median time past from the PoV of the input created above.
|
||||
// The MTP for the input is the MTP from the PoV of the block *prior*
|
||||
@ -170,7 +166,7 @@ func TestCalcSequenceLock(t *testing.T) {
|
||||
// the MTP will be calculated from the PoV of the yet-to-be-mined
|
||||
// block.
|
||||
nextMedianTime := node.CalcPastMedianTime().Unix()
|
||||
nextBlockHeight := int32(numBlocksToActivate) + 1
|
||||
nextBlockHeight := int32(numBlocksToGenerate) + 1
|
||||
|
||||
// Add an additional transaction which will serve as our unconfirmed
|
||||
// output.
|
||||
@ -195,29 +191,12 @@ func TestCalcSequenceLock(t *testing.T) {
|
||||
mempool bool
|
||||
want *SequenceLock
|
||||
}{
|
||||
// A transaction of version one should disable sequence locks
|
||||
// as the new sequence number semantics only apply to
|
||||
// transactions version 2 or higher.
|
||||
{
|
||||
tx: &wire.MsgTx{
|
||||
Version: 1,
|
||||
TxIn: []*wire.TxIn{{
|
||||
PreviousOutPoint: utxo,
|
||||
Sequence: LockTimeToSequence(false, 3),
|
||||
}},
|
||||
},
|
||||
view: utxoView,
|
||||
want: &SequenceLock{
|
||||
Seconds: -1,
|
||||
BlockHeight: -1,
|
||||
},
|
||||
},
|
||||
// A transaction with a single input with max sequence number.
|
||||
// This sequence number has the high bit set, so sequence locks
|
||||
// should be disabled.
|
||||
{
|
||||
tx: &wire.MsgTx{
|
||||
Version: 2,
|
||||
Version: 1,
|
||||
TxIn: []*wire.TxIn{{
|
||||
PreviousOutPoint: utxo,
|
||||
Sequence: wire.MaxTxInSequenceNum,
|
||||
@ -237,7 +216,7 @@ func TestCalcSequenceLock(t *testing.T) {
|
||||
// the targeted block.
|
||||
{
|
||||
tx: &wire.MsgTx{
|
||||
Version: 2,
|
||||
Version: 1,
|
||||
TxIn: []*wire.TxIn{{
|
||||
PreviousOutPoint: utxo,
|
||||
Sequence: LockTimeToSequence(true, 2),
|
||||
@ -255,7 +234,7 @@ func TestCalcSequenceLock(t *testing.T) {
|
||||
// chain.
|
||||
{
|
||||
tx: &wire.MsgTx{
|
||||
Version: 2,
|
||||
Version: 1,
|
||||
TxIn: []*wire.TxIn{{
|
||||
PreviousOutPoint: utxo,
|
||||
Sequence: LockTimeToSequence(true, 1024),
|
||||
@ -275,7 +254,7 @@ func TestCalcSequenceLock(t *testing.T) {
|
||||
// latest lock that isn't disabled.
|
||||
{
|
||||
tx: &wire.MsgTx{
|
||||
Version: 2,
|
||||
Version: 1,
|
||||
TxIn: []*wire.TxIn{{
|
||||
PreviousOutPoint: utxo,
|
||||
Sequence: LockTimeToSequence(true, 2560),
|
||||
@ -300,7 +279,7 @@ func TestCalcSequenceLock(t *testing.T) {
|
||||
// height of 2 meaning it can be included at height 3.
|
||||
{
|
||||
tx: &wire.MsgTx{
|
||||
Version: 2,
|
||||
Version: 1,
|
||||
TxIn: []*wire.TxIn{{
|
||||
PreviousOutPoint: utxo,
|
||||
Sequence: LockTimeToSequence(false, 3),
|
||||
@ -317,7 +296,7 @@ func TestCalcSequenceLock(t *testing.T) {
|
||||
// be the time further in the future.
|
||||
{
|
||||
tx: &wire.MsgTx{
|
||||
Version: 2,
|
||||
Version: 1,
|
||||
TxIn: []*wire.TxIn{{
|
||||
PreviousOutPoint: utxo,
|
||||
Sequence: LockTimeToSequence(true, 5120),
|
||||
@ -338,7 +317,7 @@ func TestCalcSequenceLock(t *testing.T) {
|
||||
// indicating it can be included at height 11.
|
||||
{
|
||||
tx: &wire.MsgTx{
|
||||
Version: 2,
|
||||
Version: 1,
|
||||
TxIn: []*wire.TxIn{{
|
||||
PreviousOutPoint: utxo,
|
||||
Sequence: LockTimeToSequence(false, 1),
|
||||
@ -358,7 +337,7 @@ func TestCalcSequenceLock(t *testing.T) {
|
||||
// further into the future for both inputs should be chosen.
|
||||
{
|
||||
tx: &wire.MsgTx{
|
||||
Version: 2,
|
||||
Version: 1,
|
||||
TxIn: []*wire.TxIn{{
|
||||
PreviousOutPoint: utxo,
|
||||
Sequence: LockTimeToSequence(true, 2560),
|
||||
@ -387,7 +366,7 @@ func TestCalcSequenceLock(t *testing.T) {
|
||||
// after that.
|
||||
{
|
||||
tx: &wire.MsgTx{
|
||||
Version: 2,
|
||||
Version: 1,
|
||||
TxIn: []*wire.TxIn{{
|
||||
PreviousOutPoint: unConfUtxo,
|
||||
Sequence: LockTimeToSequence(false, 2),
|
||||
@ -405,7 +384,7 @@ func TestCalcSequenceLock(t *testing.T) {
|
||||
// MTP of the *next* block.
|
||||
{
|
||||
tx: &wire.MsgTx{
|
||||
Version: 2,
|
||||
Version: 1,
|
||||
TxIn: []*wire.TxIn{{
|
||||
PreviousOutPoint: unConfUtxo,
|
||||
Sequence: LockTimeToSequence(true, 1024),
|
||||
|
@ -104,7 +104,6 @@ var regressionNetParams = &chaincfg.Params{
|
||||
PowLimitBits: 0x207fffff,
|
||||
CoinbaseMaturity: 100,
|
||||
BIP0034Height: 100000000, // Not active - Permit ver 1 blocks
|
||||
BIP0065Height: 1351, // Used by regression tests
|
||||
BIP0066Height: 1251, // Used by regression tests
|
||||
SubsidyReductionInterval: 150,
|
||||
TargetTimespan: time.Hour * 24 * 14, // 14 days
|
||||
@ -121,7 +120,7 @@ var regressionNetParams = &chaincfg.Params{
|
||||
RelayNonStdTxs: true,
|
||||
|
||||
// Address encoding magics
|
||||
PrivateKeyID: 0xef, // starts with 9 (uncompressed) or c (compressed)
|
||||
PrivateKeyID: 0xef, // starts with 9 (uncompressed) or c (compressed)
|
||||
|
||||
// BIP32 hierarchical deterministic extended key magics
|
||||
HDPrivateKeyID: [4]byte{0x04, 0x35, 0x83, 0x94}, // starts with tprv
|
||||
|
@ -709,8 +709,7 @@ func (b *BlockChain) checkBlockHeaderContext(header *wire.BlockHeader, prevNode
|
||||
// BIP0065, and BIP0066.
|
||||
params := b.chainParams
|
||||
if header.Version < 2 && blockHeight >= params.BIP0034Height ||
|
||||
header.Version < 3 && blockHeight >= params.BIP0066Height ||
|
||||
header.Version < 4 && blockHeight >= params.BIP0065Height {
|
||||
header.Version < 3 && blockHeight >= params.BIP0066Height {
|
||||
|
||||
str := "new blocks with version %d are no longer valid"
|
||||
str = fmt.Sprintf(str, header.Version)
|
||||
@ -741,21 +740,8 @@ func (b *BlockChain) checkBlockContext(block *btcutil.Block, prevNode *blockNode
|
||||
|
||||
fastAdd := flags&BFFastAdd == BFFastAdd
|
||||
if !fastAdd {
|
||||
// Obtain the latest state of the deployed CSV soft-fork in
|
||||
// order to properly guard the new validation behavior based on
|
||||
// the current BIP 9 version bits state.
|
||||
csvState, err := b.deploymentState(prevNode, chaincfg.DeploymentCSV)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Once the CSV soft-fork is fully active, we'll switch to
|
||||
// using the current median time past of the past block's
|
||||
// timestamps for all lock-time based checks.
|
||||
blockTime := header.Timestamp
|
||||
if csvState == ThresholdActive {
|
||||
blockTime = prevNode.CalcPastMedianTime()
|
||||
}
|
||||
blockTime := prevNode.CalcPastMedianTime()
|
||||
|
||||
// The height of this block is one more than the referenced
|
||||
// previous block.
|
||||
@ -1133,48 +1119,28 @@ func (b *BlockChain) checkConnectBlock(node *blockNode, block *btcutil.Block, vi
|
||||
scriptFlags |= txscript.ScriptVerifyDERSignatures
|
||||
}
|
||||
|
||||
// Enforce CHECKLOCKTIMEVERIFY for block versions 4+ once the historical
|
||||
// activation threshold has been reached. This is part of BIP0065.
|
||||
if blockHeader.Version >= 4 && node.height >= b.chainParams.BIP0065Height {
|
||||
scriptFlags |= txscript.ScriptVerifyCheckLockTimeVerify
|
||||
}
|
||||
// We obtain the MTP of the *previous* block in order to
|
||||
// determine if transactions in the current block are final.
|
||||
medianTime := node.parent.CalcPastMedianTime()
|
||||
|
||||
// Enforce CHECKSEQUENCEVERIFY during all block validation checks once
|
||||
// the soft-fork deployment is fully active.
|
||||
csvState, err := b.deploymentState(node.parent, chaincfg.DeploymentCSV)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if csvState == ThresholdActive {
|
||||
// If the CSV soft-fork is now active, then modify the
|
||||
// scriptFlags to ensure that the CSV op code is properly
|
||||
// validated during the script checks bleow.
|
||||
scriptFlags |= txscript.ScriptVerifyCheckSequenceVerify
|
||||
|
||||
// We obtain the MTP of the *previous* block in order to
|
||||
// determine if transactions in the current block are final.
|
||||
medianTime := node.parent.CalcPastMedianTime()
|
||||
|
||||
// Additionally, if the CSV soft-fork package is now active,
|
||||
// then we also enforce the relative sequence number based
|
||||
// lock-times within the inputs of all transactions in this
|
||||
// candidate block.
|
||||
for _, tx := range block.Transactions() {
|
||||
// A transaction can only be included within a block
|
||||
// once the sequence locks of *all* its inputs are
|
||||
// active.
|
||||
sequenceLock, err := b.calcSequenceLock(node, tx, view,
|
||||
false)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !SequenceLockActive(sequenceLock, node.height,
|
||||
medianTime) {
|
||||
str := fmt.Sprintf("block contains " +
|
||||
"transaction whose input sequence " +
|
||||
"locks are not met")
|
||||
return ruleError(ErrUnfinalizedTx, str)
|
||||
}
|
||||
// We also enforce the relative sequence number based
|
||||
// lock-times within the inputs of all transactions in this
|
||||
// candidate block.
|
||||
for _, tx := range block.Transactions() {
|
||||
// A transaction can only be included within a block
|
||||
// once the sequence locks of *all* its inputs are
|
||||
// active.
|
||||
sequenceLock, err := b.calcSequenceLock(node, tx, view,
|
||||
false)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !SequenceLockActive(sequenceLock, node.height,
|
||||
medianTime) {
|
||||
str := fmt.Sprintf("block contains " +
|
||||
"transaction whose input sequence " +
|
||||
"locks are not met")
|
||||
return ruleError(ErrUnfinalizedTx, str)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -87,11 +87,6 @@ const (
|
||||
// purposes.
|
||||
DeploymentTestDummy = iota
|
||||
|
||||
// DeploymentCSV defines the rule change deployment ID for the CSV
|
||||
// soft-fork package. The CSV package includes the deployment of BIPS
|
||||
// 68, 112, and 113.
|
||||
DeploymentCSV
|
||||
|
||||
// NOTE: DefinedDeployments must always come last since it is used to
|
||||
// determine how many defined deployments there currently are.
|
||||
|
||||
@ -184,7 +179,6 @@ type Params struct {
|
||||
// These fields define the block heights at which the specified softfork
|
||||
// BIP became active.
|
||||
BIP0034Height int32
|
||||
BIP0065Height int32
|
||||
BIP0066Height int32
|
||||
|
||||
// CoinbaseMaturity is the number of blocks required before newly mined
|
||||
@ -283,7 +277,6 @@ var MainNetParams = Params{
|
||||
PowLimit: mainPowLimit,
|
||||
PowLimitBits: 0x1d00ffff,
|
||||
BIP0034Height: 227931, // 000000000000024b89b42a942fe0d9fea3bb44ab7bd1b19115dd6a759c0808b8
|
||||
BIP0065Height: 388381, // 000000000000000004c2b624ed5d7756c508d90fd0da2c7c679febfa6c4735f0
|
||||
BIP0066Height: 363725, // 00000000000000000379eaa19dce8c9b722d46ae6a57c2f1a988119488b50931
|
||||
CoinbaseMaturity: 100,
|
||||
SubsidyReductionInterval: 210000,
|
||||
@ -328,11 +321,6 @@ var MainNetParams = Params{
|
||||
StartTime: 1199145601, // January 1, 2008 UTC
|
||||
ExpireTime: 1230767999, // December 31, 2008 UTC
|
||||
},
|
||||
DeploymentCSV: {
|
||||
BitNumber: 0,
|
||||
StartTime: 1462060800, // May 1st, 2016
|
||||
ExpireTime: 1493596800, // May 1st, 2017
|
||||
},
|
||||
},
|
||||
|
||||
// Mempool parameters
|
||||
@ -369,7 +357,6 @@ var RegressionNetParams = Params{
|
||||
PowLimitBits: 0x207fffff,
|
||||
CoinbaseMaturity: 100,
|
||||
BIP0034Height: 100000000, // Not active - Permit ver 1 blocks
|
||||
BIP0065Height: 1351, // Used by regression tests
|
||||
BIP0066Height: 1251, // Used by regression tests
|
||||
SubsidyReductionInterval: 150,
|
||||
TargetTimespan: time.Hour * 24 * 14, // 14 days
|
||||
@ -394,11 +381,6 @@ var RegressionNetParams = Params{
|
||||
StartTime: 0, // Always available for vote
|
||||
ExpireTime: math.MaxInt64, // Never expires
|
||||
},
|
||||
DeploymentCSV: {
|
||||
BitNumber: 0,
|
||||
StartTime: 0, // Always available for vote
|
||||
ExpireTime: math.MaxInt64, // Never expires
|
||||
},
|
||||
},
|
||||
|
||||
// Mempool parameters
|
||||
@ -439,7 +421,6 @@ var TestNet3Params = Params{
|
||||
PowLimit: testNet3PowLimit,
|
||||
PowLimitBits: 0x1d00ffff,
|
||||
BIP0034Height: 21111, // 0000000023b3a96d3484e5abb3755c413e7d41500f8e2a5c3f0dd01299cd8ef8
|
||||
BIP0065Height: 581885, // 00000000007f6655f22f98e72ed80d8b06dc761d5da09df0fa1dc4be4f861eb6
|
||||
BIP0066Height: 330776, // 000000002104c8c45e99a8853285a3b592602a3ccde2b832481da85e9e4ba182
|
||||
CoinbaseMaturity: 100,
|
||||
SubsidyReductionInterval: 210000,
|
||||
@ -477,11 +458,6 @@ var TestNet3Params = Params{
|
||||
StartTime: 1199145601, // January 1, 2008 UTC
|
||||
ExpireTime: 1230767999, // December 31, 2008 UTC
|
||||
},
|
||||
DeploymentCSV: {
|
||||
BitNumber: 0,
|
||||
StartTime: 1456790400, // March 1st, 2016
|
||||
ExpireTime: 1493596800, // May 1st, 2017
|
||||
},
|
||||
},
|
||||
|
||||
// Mempool parameters
|
||||
@ -521,7 +497,6 @@ var SimNetParams = Params{
|
||||
PowLimit: simNetPowLimit,
|
||||
PowLimitBits: 0x207fffff,
|
||||
BIP0034Height: 0, // Always active on simnet
|
||||
BIP0065Height: 0, // Always active on simnet
|
||||
BIP0066Height: 0, // Always active on simnet
|
||||
CoinbaseMaturity: 100,
|
||||
SubsidyReductionInterval: 210000,
|
||||
@ -547,11 +522,6 @@ var SimNetParams = Params{
|
||||
StartTime: 0, // Always available for vote
|
||||
ExpireTime: math.MaxInt64, // Never expires
|
||||
},
|
||||
DeploymentCSV: {
|
||||
BitNumber: 0,
|
||||
StartTime: 0, // Always available for vote
|
||||
ExpireTime: math.MaxInt64, // Never expires
|
||||
},
|
||||
},
|
||||
|
||||
// Mempool parameters
|
||||
|
@ -24,10 +24,6 @@ import (
|
||||
"github.com/daglabs/btcutil"
|
||||
)
|
||||
|
||||
const (
|
||||
csvKey = "csv"
|
||||
)
|
||||
|
||||
// makeTestOutput creates an on-chain output paying to a freshly generated
|
||||
// p2pkh output with the specified amount.
|
||||
func makeTestOutput(r *rpctest.Harness, t *testing.T,
|
||||
@ -94,18 +90,11 @@ func makeTestOutput(r *rpctest.Harness, t *testing.T,
|
||||
// them.
|
||||
//
|
||||
// Overview:
|
||||
// - Pre soft-fork:
|
||||
// - Transactions with non-final lock-times from the PoV of MTP should be
|
||||
// rejected from the mempool.
|
||||
// - Transactions within non-final MTP based lock-times should be accepted
|
||||
// in valid blocks.
|
||||
//
|
||||
// - Post soft-fork:
|
||||
// - Transactions with non-final lock-times from the PoV of MTP should be
|
||||
// rejected from the mempool and when found within otherwise valid blocks.
|
||||
// - Transactions with final lock-times from the PoV of MTP should be
|
||||
// accepted to the mempool and mined in future block.
|
||||
func TestBIP0113Activation(t *testing.T) {
|
||||
func TestBIP0113(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
btcdCfg := []string{"--rejectnonstd"}
|
||||
@ -175,39 +164,6 @@ func TestBIP0113Activation(t *testing.T) {
|
||||
"non-final, instead: %v", err)
|
||||
}
|
||||
|
||||
// However, since the block validation consensus rules haven't yet
|
||||
// activated, a block including the transaction should be accepted.
|
||||
txns := []*btcutil.Tx{btcutil.NewTx(tx)}
|
||||
block, err := r.GenerateAndSubmitBlock(txns, -1, time.Time{})
|
||||
if err != nil {
|
||||
t.Fatalf("unable to submit block: %v", err)
|
||||
}
|
||||
txid := tx.TxHash()
|
||||
assertTxInBlock(r, t, block.Hash(), &txid)
|
||||
|
||||
// At this point, the block height should be 103: we mined 101 blocks
|
||||
// to create a single mature output, then an additional block to create
|
||||
// a new output, and then mined a single block above to include our
|
||||
// transaction.
|
||||
assertChainHeight(r, t, 103)
|
||||
|
||||
// Next, mine enough blocks to ensure that the soft-fork becomes
|
||||
// activated. Assert that the block version of the second-to-last block
|
||||
// in the final range is active.
|
||||
|
||||
// Next, mine ensure blocks to ensure that the soft-fork becomes
|
||||
// active. We're at height 103 and we need 200 blocks to be mined after
|
||||
// the genesis target period, so we mine 196 blocks. This'll put us at
|
||||
// height 299. The getblockchaininfo call checks the state for the
|
||||
// block AFTER the current height.
|
||||
numBlocks := (r.ActiveNet.MinerConfirmationWindow * 2) - 4
|
||||
if _, err := r.Node.Generate(numBlocks); err != nil {
|
||||
t.Fatalf("unable to generate blocks: %v", err)
|
||||
}
|
||||
|
||||
assertChainHeight(r, t, 299)
|
||||
assertSoftForkStatus(r, t, csvKey, blockchain.ThresholdActive)
|
||||
|
||||
// The timeLockDeltas slice represents a series of deviations from the
|
||||
// current MTP which will be used to test border conditions w.r.t
|
||||
// transaction finality. -1 indicates 1 second prior to the MTP, 0
|
||||
@ -266,7 +222,7 @@ func TestBIP0113Activation(t *testing.T) {
|
||||
"due to being non-final, instead: %v", err)
|
||||
}
|
||||
|
||||
txns = []*btcutil.Tx{btcutil.NewTx(tx)}
|
||||
txns := []*btcutil.Tx{btcutil.NewTx(tx)}
|
||||
_, err := r.GenerateAndSubmitBlock(txns, -1, time.Time{})
|
||||
if err == nil && timeLockDelta >= 0 {
|
||||
t.Fatal("block should be rejected due to non-final " +
|
||||
@ -292,8 +248,7 @@ func createCSVOutput(r *rpctest.Harness, t *testing.T,
|
||||
// Our CSV script is simply: <sequenceLock> OP_CSV OP_DROP
|
||||
b := txscript.NewScriptBuilder().
|
||||
AddInt64(int64(sequenceLock)).
|
||||
AddOp(txscript.OP_CHECKSEQUENCEVERIFY).
|
||||
AddOp(txscript.OP_DROP)
|
||||
AddOp(txscript.OpCheckSequenceVerify)
|
||||
csvScript, err := b.Script()
|
||||
if err != nil {
|
||||
return nil, nil, nil, err
|
||||
@ -349,7 +304,7 @@ func spendCSVOutput(redeemScript []byte, csvUTXO *wire.OutPoint,
|
||||
tx.AddTxOut(targetOutput)
|
||||
|
||||
b := txscript.NewScriptBuilder().
|
||||
AddOp(txscript.OP_TRUE).
|
||||
AddOp(txscript.OpTrue).
|
||||
AddData(redeemScript)
|
||||
|
||||
sigScript, err := b.Script()
|
||||
@ -386,18 +341,9 @@ func assertTxInBlock(r *rpctest.Harness, t *testing.T, blockHash *chainhash.Hash
|
||||
"block %v", line, txid, blockHash)
|
||||
}
|
||||
|
||||
// TestBIP0068AndBIP0112Activation tests for the proper adherence to the BIP
|
||||
// 112 and BIP 68 rule-set after the activation of the CSV-package soft-fork.
|
||||
//
|
||||
// Overview:
|
||||
// - Pre soft-fork:
|
||||
// - A transaction spending a CSV output validly should be rejected from the
|
||||
// mempool, but accepted in a valid generated block including the
|
||||
// transaction.
|
||||
// - Post soft-fork:
|
||||
// - See the cases exercised within the table driven tests towards the end
|
||||
// of this test.
|
||||
func TestBIP0068AndBIP0112Activation(t *testing.T) {
|
||||
// TestBIP0068AndCsv tests for the proper adherence to the BIP 68
|
||||
// rule-set and the behaviour of OP_CHECKSEQUENCEVERIFY
|
||||
func TestBIP0068AndCsv(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
// We'd like the test proper evaluation and validation of the BIP 68
|
||||
@ -414,8 +360,6 @@ func TestBIP0068AndBIP0112Activation(t *testing.T) {
|
||||
}
|
||||
defer r.TearDown()
|
||||
|
||||
assertSoftForkStatus(r, t, csvKey, blockchain.ThresholdStarted)
|
||||
|
||||
harnessAddr, err := r.NewAddress()
|
||||
if err != nil {
|
||||
t.Fatalf("unable to obtain harness address: %v", err)
|
||||
@ -435,78 +379,21 @@ func TestBIP0068AndBIP0112Activation(t *testing.T) {
|
||||
PkScript: harnessScript,
|
||||
}
|
||||
|
||||
// As the soft-fork hasn't yet activated _any_ transaction version
|
||||
// which uses the CSV opcode should be accepted. Since at this point,
|
||||
// CSV doesn't actually exist, it's just a NOP.
|
||||
for txVersion := int32(0); txVersion < 3; txVersion++ {
|
||||
// Create a trivially spendable output with a CSV lock-time of
|
||||
// 10 relative blocks.
|
||||
redeemScript, testUTXO, tx, err := createCSVOutput(r, t, outputAmt,
|
||||
relativeBlockLock, false)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to create CSV encumbered output: %v", err)
|
||||
}
|
||||
|
||||
// As the transaction is p2sh it should be accepted into the
|
||||
// mempool and found within the next generated block.
|
||||
if _, err := r.Node.SendRawTransaction(tx, true); err != nil {
|
||||
t.Fatalf("unable to broadcast tx: %v", err)
|
||||
}
|
||||
blocks, err := r.Node.Generate(1)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to generate blocks: %v", err)
|
||||
}
|
||||
txid := tx.TxHash()
|
||||
assertTxInBlock(r, t, blocks[0], &txid)
|
||||
|
||||
// Generate a custom transaction which spends the CSV output.
|
||||
sequenceNum := blockchain.LockTimeToSequence(false, 10)
|
||||
spendingTx, err := spendCSVOutput(redeemScript, testUTXO,
|
||||
sequenceNum, sweepOutput, txVersion)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to spend csv output: %v", err)
|
||||
}
|
||||
|
||||
// This transaction should be rejected from the mempool since
|
||||
// CSV validation is already mempool policy pre-fork.
|
||||
_, err = r.Node.SendRawTransaction(spendingTx, true)
|
||||
if err == nil {
|
||||
t.Fatalf("transaction should have been rejected, but was " +
|
||||
"instead accepted")
|
||||
}
|
||||
|
||||
// However, this transaction should be accepted in a custom
|
||||
// generated block as CSV validation for scripts within blocks
|
||||
// shouldn't yet be active.
|
||||
txns := []*btcutil.Tx{btcutil.NewTx(spendingTx)}
|
||||
block, err := r.GenerateAndSubmitBlock(txns, -1, time.Time{})
|
||||
if err != nil {
|
||||
t.Fatalf("unable to submit block: %v", err)
|
||||
}
|
||||
txid = spendingTx.TxHash()
|
||||
assertTxInBlock(r, t, block.Hash(), &txid)
|
||||
}
|
||||
|
||||
// At this point, the block height should be 107: we started at height
|
||||
// 101, then generated 2 blocks in each loop iteration above.
|
||||
assertChainHeight(r, t, 107)
|
||||
|
||||
// With the height at 107 we need 200 blocks to be mined after the
|
||||
// With the height at 104 we need 200 blocks to be mined after the
|
||||
// genesis target period, so we mine 192 blocks. This'll put us at
|
||||
// height 299. The getblockchaininfo call checks the state for the
|
||||
// height 296. The getblockchaininfo call checks the state for the
|
||||
// block AFTER the current height.
|
||||
numBlocks := (r.ActiveNet.MinerConfirmationWindow * 2) - 8
|
||||
if _, err := r.Node.Generate(numBlocks); err != nil {
|
||||
t.Fatalf("unable to generate blocks: %v", err)
|
||||
}
|
||||
|
||||
assertChainHeight(r, t, 299)
|
||||
assertSoftForkStatus(r, t, csvKey, blockchain.ThresholdActive)
|
||||
assertChainHeight(r, t, 293)
|
||||
|
||||
// Knowing the number of outputs needed for the tests below, create a
|
||||
// fresh output for use within each of the test-cases below.
|
||||
const relativeTimeLock = 512
|
||||
const numTests = 8
|
||||
const numTests = 7
|
||||
type csvOutput struct {
|
||||
RedeemScript []byte
|
||||
Utxo *wire.OutPoint
|
||||
@ -519,7 +406,7 @@ func TestBIP0068AndBIP0112Activation(t *testing.T) {
|
||||
for i := 0; i < numTests; i++ {
|
||||
timeLock := relativeTimeLock
|
||||
isSeconds := true
|
||||
if i < 7 {
|
||||
if i < 6 {
|
||||
timeLock = relativeBlockLock
|
||||
isSeconds = false
|
||||
}
|
||||
@ -586,67 +473,59 @@ func TestBIP0068AndBIP0112Activation(t *testing.T) {
|
||||
tx *wire.MsgTx
|
||||
accept bool
|
||||
}{
|
||||
// A valid transaction with a single input a sequence number
|
||||
// creating a 100 block relative time-lock. This transaction
|
||||
// should be rejected as its version number is 1, and only tx
|
||||
// of version > 2 will trigger the CSV behavior.
|
||||
{
|
||||
tx: makeTxCase(blockchain.LockTimeToSequence(false, 100), 1),
|
||||
accept: false,
|
||||
},
|
||||
// A transaction of version 2 spending a single input. The
|
||||
// A transaction spending a single input. The
|
||||
// input has a relative time-lock of 1 block, but the disable
|
||||
// bit it set. The transaction should be rejected as a result.
|
||||
{
|
||||
tx: makeTxCase(
|
||||
blockchain.LockTimeToSequence(false, 1)|wire.SequenceLockTimeDisabled,
|
||||
2,
|
||||
1,
|
||||
),
|
||||
accept: false,
|
||||
},
|
||||
// A v2 transaction with a single input having a 9 block
|
||||
// A transaction with a single input having a 9 block
|
||||
// relative time lock. The referenced input is 11 blocks old,
|
||||
// but the CSV output requires a 10 block relative lock-time.
|
||||
// Therefore, the transaction should be rejected.
|
||||
{
|
||||
tx: makeTxCase(blockchain.LockTimeToSequence(false, 9), 2),
|
||||
tx: makeTxCase(blockchain.LockTimeToSequence(false, 9), 1),
|
||||
accept: false,
|
||||
},
|
||||
// A v2 transaction with a single input having a 10 block
|
||||
// A transaction with a single input having a 10 block
|
||||
// relative time lock. The referenced input is 11 blocks old so
|
||||
// the transaction should be accepted.
|
||||
{
|
||||
tx: makeTxCase(blockchain.LockTimeToSequence(false, 10), 2),
|
||||
tx: makeTxCase(blockchain.LockTimeToSequence(false, 10), 1),
|
||||
accept: true,
|
||||
},
|
||||
// A v2 transaction with a single input having a 11 block
|
||||
// A transaction with a single input having a 11 block
|
||||
// relative time lock. The input referenced has an input age of
|
||||
// 11 and the CSV op-code requires 10 blocks to have passed, so
|
||||
// this transaction should be accepted.
|
||||
{
|
||||
tx: makeTxCase(blockchain.LockTimeToSequence(false, 11), 2),
|
||||
tx: makeTxCase(blockchain.LockTimeToSequence(false, 11), 1),
|
||||
accept: true,
|
||||
},
|
||||
// A v2 transaction whose input has a 1000 blck relative time
|
||||
// A transaction whose input has a 1000 blck relative time
|
||||
// lock. This should be rejected as the input's age is only 11
|
||||
// blocks.
|
||||
{
|
||||
tx: makeTxCase(blockchain.LockTimeToSequence(false, 1000), 2),
|
||||
tx: makeTxCase(blockchain.LockTimeToSequence(false, 1000), 1),
|
||||
accept: false,
|
||||
},
|
||||
// A v2 transaction with a single input having a 512,000 second
|
||||
// A transaction with a single input having a 512,000 second
|
||||
// relative time-lock. This transaction should be rejected as 6
|
||||
// days worth of blocks haven't yet been mined. The referenced
|
||||
// input doesn't have sufficient age.
|
||||
{
|
||||
tx: makeTxCase(blockchain.LockTimeToSequence(true, 512000), 2),
|
||||
tx: makeTxCase(blockchain.LockTimeToSequence(true, 512000), 1),
|
||||
accept: false,
|
||||
},
|
||||
// A v2 transaction whose single input has a 512 second
|
||||
// A transaction whose single input has a 512 second
|
||||
// relative time-lock. This transaction should be accepted as
|
||||
// finalized.
|
||||
{
|
||||
tx: makeTxCase(blockchain.LockTimeToSequence(true, 512), 2),
|
||||
tx: makeTxCase(blockchain.LockTimeToSequence(true, 512), 1),
|
||||
accept: true,
|
||||
},
|
||||
}
|
@ -133,7 +133,7 @@ func newMemWallet(net *chaincfg.Params, harnessID uint32) (*memWallet, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
coinbaseAddr, err := keyToAddr(coinbaseKey)
|
||||
coinbaseAddr, err := keyToAddr(coinbaseKey, net)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -346,7 +346,7 @@ func (m *memWallet) newAddress() (btcutil.Address, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
addr, err := keyToAddr(privKey)
|
||||
addr, err := keyToAddr(privKey, m.net)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -560,9 +560,9 @@ func (m *memWallet) ConfirmedBalance() btcutil.Amount {
|
||||
}
|
||||
|
||||
// keyToAddr maps the passed private to corresponding p2pkh address.
|
||||
func keyToAddr(key *btcec.PrivateKey) (btcutil.Address, error) {
|
||||
func keyToAddr(key *btcec.PrivateKey, net *chaincfg.Params) (btcutil.Address, error) {
|
||||
serializedKey := key.PubKey().SerializeCompressed()
|
||||
pubKeyAddr, err := btcutil.NewAddressPubKey(serializedKey)
|
||||
pubKeyAddr, err := btcutil.NewAddressPubKey(serializedKey, net)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -288,7 +288,7 @@ func newPoolHarness(chainParams *chaincfg.Params) (*poolHarness, []spendableOutp
|
||||
// Generate associated pay-to-script-hash address and resulting payment
|
||||
// script.
|
||||
pubKeyBytes := signPub.SerializeCompressed()
|
||||
payPubKeyAddr, err := btcutil.NewAddressPubKey(pubKeyBytes)
|
||||
payPubKeyAddr, err := btcutil.NewAddressPubKey(pubKeyBytes, chainParams)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
28
rpcserver.go
28
rpcserver.go
@ -333,15 +333,15 @@ type gbtWorkState struct {
|
||||
prevHash *chainhash.Hash
|
||||
minTimestamp time.Time
|
||||
template *mining.BlockTemplate
|
||||
notifyMap map[chainhash.Hash]map[int64]chan struct{}
|
||||
timeSource blockchain.MedianTimeSource
|
||||
notifyMap map[chainhash.Hash]map[int64]chan struct{}
|
||||
timeSource blockchain.MedianTimeSource
|
||||
}
|
||||
|
||||
// newGbtWorkState returns a new instance of a gbtWorkState with all internal
|
||||
// fields initialized and ready to use.
|
||||
func newGbtWorkState(timeSource blockchain.MedianTimeSource) *gbtWorkState {
|
||||
return &gbtWorkState{
|
||||
notifyMap: make(map[chainhash.Hash]map[int64]chan struct{}),
|
||||
notifyMap: make(map[chainhash.Hash]map[int64]chan struct{}),
|
||||
timeSource: timeSource,
|
||||
}
|
||||
}
|
||||
@ -1198,15 +1198,6 @@ func handleGetBlockChainInfo(s *rpcServer, cmd interface{}, closeChan <-chan str
|
||||
Status: height >= params.BIP0066Height,
|
||||
},
|
||||
},
|
||||
{
|
||||
ID: "bip65",
|
||||
Version: 4,
|
||||
Reject: struct {
|
||||
Status bool `json:"status"`
|
||||
}{
|
||||
Status: height >= params.BIP0065Height,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
// Finally, query the BIP0009 version bits state for all currently
|
||||
@ -1219,9 +1210,6 @@ func handleGetBlockChainInfo(s *rpcServer, cmd interface{}, closeChan <-chan str
|
||||
case chaincfg.DeploymentTestDummy:
|
||||
forkName = "dummy"
|
||||
|
||||
case chaincfg.DeploymentCSV:
|
||||
forkName = "csv"
|
||||
|
||||
default:
|
||||
return nil, &btcjson.RPCError{
|
||||
Code: btcjson.ErrRPCInternal.Code,
|
||||
@ -1521,7 +1509,7 @@ func (state *gbtWorkState) updateBlockTemplate(s *rpcServer, useCoinbaseValue bo
|
||||
if template == nil || state.prevHash == nil ||
|
||||
!state.prevHash.IsEqual(latestHash) ||
|
||||
(state.lastTxUpdate != lastTxUpdate &&
|
||||
time.Now().After(state.lastGenerated.Add(time.Second *
|
||||
time.Now().After(state.lastGenerated.Add(time.Second*
|
||||
gbtRegenerateSeconds))) {
|
||||
|
||||
// Reset the previous best hash the block template was generated
|
||||
@ -1545,7 +1533,7 @@ func (state *gbtWorkState) updateBlockTemplate(s *rpcServer, useCoinbaseValue bo
|
||||
blkTemplate, err := generator.NewBlockTemplate(payAddr)
|
||||
if err != nil {
|
||||
return internalRPCError("Failed to create new block "+
|
||||
"template: "+ err.Error(), "")
|
||||
"template: "+err.Error(), "")
|
||||
}
|
||||
template = blkTemplate
|
||||
msgBlock = template.Block
|
||||
@ -2759,7 +2747,7 @@ func handlePing(s *rpcServer, cmd interface{}, closeChan <-chan struct{}) (inter
|
||||
nonce, err := wire.RandomUint64()
|
||||
if err != nil {
|
||||
return nil, internalRPCError("Not sending ping - failed to "+
|
||||
"generate nonce: "+ err.Error(), "")
|
||||
"generate nonce: "+err.Error(), "")
|
||||
}
|
||||
s.cfg.ConnMgr.BroadcastMessage(wire.NewMsgPing(nonce))
|
||||
|
||||
@ -3527,7 +3515,7 @@ func handleVerifyMessage(s *rpcServer, cmd interface{}, closeChan <-chan struct{
|
||||
} else {
|
||||
serializedPK = pk.SerializeUncompressed()
|
||||
}
|
||||
address, err := btcutil.NewAddressPubKey(serializedPK)
|
||||
address, err := btcutil.NewAddressPubKey(serializedPK, params)
|
||||
if err != nil {
|
||||
// Again mirror Bitcoin Core behavior, which treats error in public key
|
||||
// reconstruction as invalid signature.
|
||||
@ -4232,7 +4220,7 @@ func newRPCServer(config *rpcserverConfig) (*rpcServer, error) {
|
||||
gbtWorkState: newGbtWorkState(config.TimeSource),
|
||||
helpCacher: newHelpCacher(),
|
||||
requestProcessShutdown: make(chan struct{}),
|
||||
quit: make(chan int),
|
||||
quit: make(chan int),
|
||||
}
|
||||
if cfg.RPCUser != "" && cfg.RPCPass != "" {
|
||||
login := cfg.RPCUser + ":" + cfg.RPCPass
|
||||
|
@ -232,17 +232,15 @@
|
||||
["'abcdefghijklmnopqrstuvwxyz'", "HASH256 0x4c 0x20 0xca139bc10c2f660da42666f72e89a225936fc60f193c161124a672050c434671 EQUAL", "P2SH,STRICTENC", "OK"],
|
||||
|
||||
|
||||
["1","NOP1 CHECKLOCKTIMEVERIFY CHECKSEQUENCEVERIFY NOP4 NOP5 NOP6 NOP7 NOP8 NOP9 NOP10 1 EQUAL", "P2SH,STRICTENC", "OK"],
|
||||
["'NOP_1_to_10' NOP1 CHECKLOCKTIMEVERIFY CHECKSEQUENCEVERIFY NOP4 NOP5 NOP6 NOP7 NOP8 NOP9 NOP10","'NOP_1_to_10' EQUAL", "P2SH,STRICTENC", "OK"],
|
||||
["1","NOP1 NOP2 NOP3 NOP4 NOP5 NOP6 NOP7 NOP8 NOP9 NOP10 1 EQUAL", "P2SH,STRICTENC", "OK"],
|
||||
["'NOP_1_to_10' NOP1 NOP2 NOP3 NOP4 NOP5 NOP6 NOP7 NOP8 NOP9 NOP10","'NOP_1_to_10' EQUAL", "P2SH,STRICTENC", "OK"],
|
||||
|
||||
["1", "NOP", "P2SH,STRICTENC,DISCOURAGE_UPGRADABLE_NOPS", "OK", "Discourage NOPx flag allows OP_NOP"],
|
||||
|
||||
["0", "IF NOP10 ENDIF 1", "P2SH,STRICTENC,DISCOURAGE_UPGRADABLE_NOPS", "OK",
|
||||
"Discouraged NOPs are allowed if not executed"],
|
||||
|
||||
["0", "IF 0xba ELSE 1 ENDIF", "P2SH,STRICTENC", "OK", "opcodes above NOP10 invalid if executed"],
|
||||
["0", "IF 0xbb ELSE 1 ENDIF", "P2SH,STRICTENC", "OK"],
|
||||
["0", "IF 0xbc ELSE 1 ENDIF", "P2SH,STRICTENC", "OK"],
|
||||
["0", "IF 0xbc ELSE 1 ENDIF", "P2SH,STRICTENC", "OK", "opcodes above NOP10 invalid if executed"],
|
||||
["0", "IF 0xbd ELSE 1 ENDIF", "P2SH,STRICTENC", "OK"],
|
||||
["0", "IF 0xbe ELSE 1 ENDIF", "P2SH,STRICTENC", "OK"],
|
||||
["0", "IF 0xbf ELSE 1 ENDIF", "P2SH,STRICTENC", "OK"],
|
||||
@ -441,8 +439,8 @@
|
||||
["0", "HASH256", "P2SH,STRICTENC", "OK"],
|
||||
|
||||
["NOP", "NOP1 1", "P2SH,STRICTENC", "OK"],
|
||||
["NOP", "CHECKLOCKTIMEVERIFY 1", "P2SH,STRICTENC", "OK"],
|
||||
["NOP", "CHECKSEQUENCEVERIFY 1", "P2SH,STRICTENC", "OK"],
|
||||
["NOP", "NOP2 1", "P2SH,STRICTENC", "OK"],
|
||||
["NOP", "NOP3 1", "P2SH,STRICTENC", "OK"],
|
||||
["NOP", "NOP4 1", "P2SH,STRICTENC", "OK"],
|
||||
["NOP", "NOP5 1", "P2SH,STRICTENC", "OK"],
|
||||
["NOP", "NOP6 1", "P2SH,STRICTENC", "OK"],
|
||||
@ -700,7 +698,7 @@
|
||||
["0x17 0x3014021077777777777777777777777777777777020001", "0 CHECKSIG NOT", "", "OK", "Zero-length S is correctly encoded for DERSIG"],
|
||||
["0x27 0x302402107777777777777777777777777777777702108777777777777777777777777777777701", "0 CHECKSIG NOT", "", "OK", "Negative S is correctly encoded"],
|
||||
|
||||
["2147483648", "CHECKSEQUENCEVERIFY", "CHECKSEQUENCEVERIFY", "OK", "CSV passes if stack top bit 1 << 31 is set"],
|
||||
["TRUE 2147483648", "CHECKSEQUENCEVERIFY", "", "OK", "CSV passes if stack top bit 1 << 31 is set"],
|
||||
|
||||
["", "DEPTH", "P2SH,STRICTENC", "EVAL_FALSE", "Test the test: we should have an empty stack after scriptSig evaluation"],
|
||||
[" ", "DEPTH", "P2SH,STRICTENC", "EVAL_FALSE", "and multiple spaces should not change that."],
|
||||
@ -856,13 +854,13 @@
|
||||
["2 2 LSHIFT", "8 EQUAL", "P2SH,STRICTENC", "DISABLED_OPCODE", "disabled"],
|
||||
["2 1 RSHIFT", "1 EQUAL", "P2SH,STRICTENC", "DISABLED_OPCODE", "disabled"],
|
||||
|
||||
["1", "NOP1 CHECKLOCKTIMEVERIFY CHECKSEQUENCEVERIFY NOP4 NOP5 NOP6 NOP7 NOP8 NOP9 NOP10 2 EQUAL", "P2SH,STRICTENC", "EVAL_FALSE"],
|
||||
["'NOP_1_to_10' NOP1 CHECKLOCKTIMEVERIFY CHECKSEQUENCEVERIFY NOP4 NOP5 NOP6 NOP7 NOP8 NOP9 NOP10","'NOP_1_to_11' EQUAL", "P2SH,STRICTENC", "EVAL_FALSE"],
|
||||
["1", "NOP1 NOP2 NOP3 NOP4 NOP5 NOP6 NOP7 NOP8 NOP9 NOP10 2 EQUAL", "P2SH,STRICTENC", "EVAL_FALSE"],
|
||||
["'NOP_1_to_10' NOP1 NOP2 NOP3 NOP4 NOP5 NOP6 NOP7 NOP8 NOP9 NOP10","'NOP_1_to_11' EQUAL", "P2SH,STRICTENC", "EVAL_FALSE"],
|
||||
|
||||
["Ensure 100% coverage of discouraged NOPS"],
|
||||
["1", "NOP1", "P2SH,DISCOURAGE_UPGRADABLE_NOPS", "DISCOURAGE_UPGRADABLE_NOPS"],
|
||||
["1", "CHECKLOCKTIMEVERIFY", "P2SH,DISCOURAGE_UPGRADABLE_NOPS", "DISCOURAGE_UPGRADABLE_NOPS"],
|
||||
["1", "CHECKSEQUENCEVERIFY", "P2SH,DISCOURAGE_UPGRADABLE_NOPS", "DISCOURAGE_UPGRADABLE_NOPS"],
|
||||
["1", "NOP2", "P2SH,DISCOURAGE_UPGRADABLE_NOPS", "DISCOURAGE_UPGRADABLE_NOPS"],
|
||||
["1", "NOP3", "P2SH,DISCOURAGE_UPGRADABLE_NOPS", "DISCOURAGE_UPGRADABLE_NOPS"],
|
||||
["1", "NOP4", "P2SH,DISCOURAGE_UPGRADABLE_NOPS", "DISCOURAGE_UPGRADABLE_NOPS"],
|
||||
["1", "NOP5", "P2SH,DISCOURAGE_UPGRADABLE_NOPS", "DISCOURAGE_UPGRADABLE_NOPS"],
|
||||
["1", "NOP6", "P2SH,DISCOURAGE_UPGRADABLE_NOPS", "DISCOURAGE_UPGRADABLE_NOPS"],
|
||||
@ -873,13 +871,11 @@
|
||||
|
||||
["NOP10", "1", "P2SH,DISCOURAGE_UPGRADABLE_NOPS", "DISCOURAGE_UPGRADABLE_NOPS", "Discouraged NOP10 in scriptSig"],
|
||||
|
||||
["1 0x01 0xb9", "HASH160 0x14 0x15727299b05b45fdaf9ac9ecf7565cfe27c3e567 EQUAL",
|
||||
["1 0x01 0xbb", "HASH160 0x14 0x6b598ec091379f3d1a7f0532738e86accc36dc9f EQUAL",
|
||||
"P2SH,DISCOURAGE_UPGRADABLE_NOPS", "DISCOURAGE_UPGRADABLE_NOPS", "Discouraged NOP10 in redeemScript"],
|
||||
|
||||
["0x50","1", "P2SH,STRICTENC", "BAD_OPCODE", "opcode 0x50 is reserved"],
|
||||
["1", "IF 0xba ELSE 1 ENDIF", "P2SH,STRICTENC", "BAD_OPCODE", "opcodes above NOP10 invalid if executed"],
|
||||
["1", "IF 0xbb ELSE 1 ENDIF", "P2SH,STRICTENC", "BAD_OPCODE"],
|
||||
["1", "IF 0xbc ELSE 1 ENDIF", "P2SH,STRICTENC", "BAD_OPCODE"],
|
||||
["1", "IF 0xbc ELSE 1 ENDIF", "P2SH,STRICTENC", "BAD_OPCODE", "opcodes above NOP10 invalid if executed"],
|
||||
["1", "IF 0xbd ELSE 1 ENDIF", "P2SH,STRICTENC", "BAD_OPCODE"],
|
||||
["1", "IF 0xbe ELSE 1 ENDIF", "P2SH,STRICTENC", "BAD_OPCODE"],
|
||||
["1", "IF 0xbf ELSE 1 ENDIF", "P2SH,STRICTENC", "BAD_OPCODE"],
|
||||
@ -1000,7 +996,7 @@
|
||||
["1","RESERVED", "P2SH,STRICTENC", "BAD_OPCODE", "OP_RESERVED is reserved"],
|
||||
["1","RESERVED1", "P2SH,STRICTENC", "BAD_OPCODE", "OP_RESERVED1 is reserved"],
|
||||
["1","RESERVED2", "P2SH,STRICTENC", "BAD_OPCODE", "OP_RESERVED2 is reserved"],
|
||||
["1","0xba", "P2SH,STRICTENC", "BAD_OPCODE", "0xba == OP_NOP10 + 1"],
|
||||
["1","0xbc", "P2SH,STRICTENC", "BAD_OPCODE", "0xbc == OP_NOP10 + 1"],
|
||||
|
||||
["2147483648", "1ADD 1", "P2SH,STRICTENC", "UNKNOWN_ERROR", "We cannot do math on 5-byte integers"],
|
||||
["2147483648", "NEGATE 1", "P2SH,STRICTENC", "UNKNOWN_ERROR", "We cannot do math on 5-byte integers"],
|
||||
@ -1816,11 +1812,11 @@
|
||||
],
|
||||
|
||||
["CHECKSEQUENCEVERIFY tests"],
|
||||
["", "CHECKSEQUENCEVERIFY", "CHECKSEQUENCEVERIFY", "INVALID_STACK_OPERATION", "CSV automatically fails on a empty stack"],
|
||||
["-1", "CHECKSEQUENCEVERIFY", "CHECKSEQUENCEVERIFY", "NEGATIVE_LOCKTIME", "CSV automatically fails if stack top is negative"],
|
||||
["0x0100", "CHECKSEQUENCEVERIFY", "CHECKSEQUENCEVERIFY,MINIMALDATA", "UNKNOWN_ERROR", "CSV fails if stack top is not minimally encoded"],
|
||||
["0", "CHECKSEQUENCEVERIFY", "CHECKSEQUENCEVERIFY", "UNSATISFIED_LOCKTIME", "CSV fails if stack top bit 1 << 31 is set and the tx version < 2"],
|
||||
["4294967296", "CHECKSEQUENCEVERIFY", "CHECKSEQUENCEVERIFY", "UNSATISFIED_LOCKTIME",
|
||||
["", "CHECKSEQUENCEVERIFY", "", "INVALID_STACK_OPERATION", "CSV automatically fails on a empty stack"],
|
||||
["-1", "CHECKSEQUENCEVERIFY", "", "NEGATIVE_LOCKTIME", "CSV automatically fails if stack top is negative"],
|
||||
["0x0100", "CHECKSEQUENCEVERIFY", "MINIMALDATA", "UNKNOWN_ERROR", "CSV fails if stack top is not minimally encoded"],
|
||||
["0", "CHECKSEQUENCEVERIFY", "", "UNSATISFIED_LOCKTIME", "CSV fails if stack top bit 1 << 31 is set and the tx version < 2"],
|
||||
["4294967296", "CHECKSEQUENCEVERIFY", "", "UNSATISFIED_LOCKTIME",
|
||||
"CSV fails if stack top bit 1 << 31 is not set, and tx version < 2"],
|
||||
|
||||
["NULLFAIL should cover all signatures and signatures only"],
|
||||
|
@ -68,74 +68,74 @@
|
||||
|
||||
["By-height locks, with argument just beyond tx nLockTime"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "1 CHECKLOCKTIMEVERIFY 1"]],
|
||||
"010000000100010000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000", "P2SH,CHECKLOCKTIMEVERIFY"],
|
||||
"010000000100010000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000", "P2SH"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "499999999 CHECKLOCKTIMEVERIFY 1"]],
|
||||
"0100000001000100000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000fe64cd1d", "P2SH,CHECKLOCKTIMEVERIFY"],
|
||||
"0100000001000100000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000fe64cd1d", "P2SH"],
|
||||
|
||||
["By-time locks, with argument just beyond tx nLockTime (but within numerical boundaries)"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "500000001 CHECKLOCKTIMEVERIFY 1"]],
|
||||
"01000000010001000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000065cd1d", "P2SH,CHECKLOCKTIMEVERIFY"],
|
||||
"01000000010001000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000065cd1d", "P2SH"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "4294967295 CHECKLOCKTIMEVERIFY 1"]],
|
||||
"0100000001000100000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000feffffff", "P2SH,CHECKLOCKTIMEVERIFY"],
|
||||
"0100000001000100000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000feffffff", "P2SH"],
|
||||
|
||||
["Argument missing"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "CHECKLOCKTIMEVERIFY 1"]],
|
||||
"010000000100010000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000", "P2SH,CHECKLOCKTIMEVERIFY"],
|
||||
"010000000100010000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000", "P2SH"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "1"]],
|
||||
"010000000100010000000000000000000000000000000000000000000000000000000000000000000001b1010000000100000000000000000000000000", "P2SH,CHECKLOCKTIMEVERIFY"],
|
||||
"010000000100010000000000000000000000000000000000000000000000000000000000000000000001b1010000000100000000000000000000000000", "P2SH"],
|
||||
|
||||
["Argument negative with by-blockheight nLockTime=0"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "-1 CHECKLOCKTIMEVERIFY 1"]],
|
||||
"010000000100010000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000", "P2SH,CHECKLOCKTIMEVERIFY"],
|
||||
"010000000100010000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000", "P2SH"],
|
||||
|
||||
["Argument negative with by-blocktime nLockTime=500,000,000"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "-1 CHECKLOCKTIMEVERIFY 1"]],
|
||||
"01000000010001000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000065cd1d", "P2SH,CHECKLOCKTIMEVERIFY"],
|
||||
"01000000010001000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000065cd1d", "P2SH"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "1"]],
|
||||
"010000000100010000000000000000000000000000000000000000000000000000000000000000000004005194b1010000000100000000000000000002000000", "P2SH,CHECKLOCKTIMEVERIFY"],
|
||||
"010000000100010000000000000000000000000000000000000000000000000000000000000000000004005194b1010000000100000000000000000002000000", "P2SH"],
|
||||
|
||||
["Input locked"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "0 CHECKLOCKTIMEVERIFY 1"]],
|
||||
"010000000100010000000000000000000000000000000000000000000000000000000000000000000000ffffffff0100000000000000000000000000", "P2SH,CHECKLOCKTIMEVERIFY"],
|
||||
"010000000100010000000000000000000000000000000000000000000000000000000000000000000000ffffffff0100000000000000000000000000", "P2SH"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "0"]],
|
||||
"01000000010001000000000000000000000000000000000000000000000000000000000000000000000251b1ffffffff0100000000000000000002000000", "P2SH,CHECKLOCKTIMEVERIFY"],
|
||||
"01000000010001000000000000000000000000000000000000000000000000000000000000000000000251b1ffffffff0100000000000000000002000000", "P2SH"],
|
||||
|
||||
["Another input being unlocked isn't sufficient; the CHECKLOCKTIMEVERIFY-using input must be unlocked"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "0 CHECKLOCKTIMEVERIFY 1"] ,
|
||||
["0000000000000000000000000000000000000000000000000000000000000200", 1, "1"]],
|
||||
"010000000200010000000000000000000000000000000000000000000000000000000000000000000000ffffffff00020000000000000000000000000000000000000000000000000000000000000100000000000000000100000000000000000000000000", "P2SH,CHECKLOCKTIMEVERIFY"],
|
||||
"010000000200010000000000000000000000000000000000000000000000000000000000000000000000ffffffff00020000000000000000000000000000000000000000000000000000000000000100000000000000000100000000000000000000000000", "P2SH"],
|
||||
|
||||
["Argument/tx height/time mismatch, both versions"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "0 CHECKLOCKTIMEVERIFY 1"]],
|
||||
"01000000010001000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000065cd1d", "P2SH,CHECKLOCKTIMEVERIFY"],
|
||||
"01000000010001000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000065cd1d", "P2SH"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "0"]],
|
||||
"01000000010001000000000000000000000000000000000000000000000000000000000000000000000251b100000000010000000000000000000065cd1d", "P2SH,CHECKLOCKTIMEVERIFY"],
|
||||
"01000000010001000000000000000000000000000000000000000000000000000000000000000000000251b000000000010000000000000000000065cd1d", "P2SH"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "499999999 CHECKLOCKTIMEVERIFY 1"]],
|
||||
"01000000010001000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000065cd1d", "P2SH,CHECKLOCKTIMEVERIFY"],
|
||||
"01000000010001000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000065cd1d", "P2SH"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "500000000 CHECKLOCKTIMEVERIFY 1"]],
|
||||
"010000000100010000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000", "P2SH,CHECKLOCKTIMEVERIFY"],
|
||||
"010000000100010000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000", "P2SH"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "500000000 CHECKLOCKTIMEVERIFY 1"]],
|
||||
"0100000001000100000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000ff64cd1d", "P2SH,CHECKLOCKTIMEVERIFY"],
|
||||
"0100000001000100000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000ff64cd1d", "P2SH"],
|
||||
|
||||
["Argument 2^32 with nLockTime=2^32-1"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "4294967296 CHECKLOCKTIMEVERIFY 1"]],
|
||||
"0100000001000100000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000ffffffff", "P2SH,CHECKLOCKTIMEVERIFY"],
|
||||
"0100000001000100000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000ffffffff", "P2SH"],
|
||||
|
||||
["Same, but with nLockTime=2^31-1"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "2147483648 CHECKLOCKTIMEVERIFY 1"]],
|
||||
"0100000001000100000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000ffffff7f", "P2SH,CHECKLOCKTIMEVERIFY"],
|
||||
"0100000001000100000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000ffffff7f", "P2SH"],
|
||||
|
||||
["6 byte non-minimally-encoded arguments are invalid even if their contents are valid"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "0x06 0x000000000000 CHECKLOCKTIMEVERIFY 1"]],
|
||||
"010000000100010000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000", "P2SH,CHECKLOCKTIMEVERIFY"],
|
||||
"010000000100010000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000", "P2SH"],
|
||||
|
||||
["Failure due to failing CHECKLOCKTIMEVERIFY in scriptSig"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "1"]],
|
||||
"01000000010001000000000000000000000000000000000000000000000000000000000000000000000251b1000000000100000000000000000000000000", "P2SH,CHECKLOCKTIMEVERIFY"],
|
||||
"01000000010001000000000000000000000000000000000000000000000000000000000000000000000251b0000000000100000000000000000000000000", "P2SH"],
|
||||
|
||||
["Failure due to failing CHECKLOCKTIMEVERIFY in redeemScript"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "HASH160 0x14 0xc5b93064159b3b2d6ab506a41b1f50463771b988 EQUAL"]],
|
||||
"0100000001000100000000000000000000000000000000000000000000000000000000000000000000030251b1000000000100000000000000000000000000", "P2SH,CHECKLOCKTIMEVERIFY"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "HASH160 0x14 0x198821d0c372b25f4d25d71171164ac5a3a0f20d EQUAL"]],
|
||||
"0100000001000100000000000000000000000000000000000000000000000000000000000000000000030251b0000000000100000000000000000000000000", "P2SH"],
|
||||
|
||||
["A transaction with a non-standard DER signature."],
|
||||
[[["b1dbc81696c8a9c0fccd0693ab66d7c368dbc38c0def4e800685560ddd1b2132", 0, "DUP HASH160 0x14 0x4b3bd7eba3bc0284fd3007be7f3be275e94f5826 EQUALVERIFY CHECKSIG"]],
|
||||
@ -145,55 +145,49 @@
|
||||
|
||||
["By-height locks, with argument just beyond txin.nSequence"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "1 CHECKSEQUENCEVERIFY 1"]],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000", "P2SH,CHECKSEQUENCEVERIFY"],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000", "P2SH"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "4259839 CHECKSEQUENCEVERIFY 1"]],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000feff40000100000000000000000000000000", "P2SH,CHECKSEQUENCEVERIFY"],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000feff40000100000000000000000000000000", "P2SH"],
|
||||
|
||||
["By-time locks, with argument just beyond txin.nSequence (but within numerical boundries)"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "4194305 CHECKSEQUENCEVERIFY 1"]],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000000040000100000000000000000000000000", "P2SH,CHECKSEQUENCEVERIFY"],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000000040000100000000000000000000000000", "P2SH"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "4259839 CHECKSEQUENCEVERIFY 1"]],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000feff40000100000000000000000000000000", "P2SH,CHECKSEQUENCEVERIFY"],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000feff40000100000000000000000000000000", "P2SH"],
|
||||
|
||||
["Argument missing"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "CHECKSEQUENCEVERIFY 1"]],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000", "P2SH,CHECKSEQUENCEVERIFY"],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000", "P2SH"],
|
||||
|
||||
["Argument negative with by-blockheight txin.nSequence=0"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "-1 CHECKSEQUENCEVERIFY 1"]],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000", "P2SH,CHECKSEQUENCEVERIFY"],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000", "P2SH"],
|
||||
|
||||
["Argument negative with by-blocktime txin.nSequence=CTxIn::SEQUENCE_LOCKTIME_TYPE_FLAG"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "-1 CHECKSEQUENCEVERIFY 1"]],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000000040000100000000000000000000000000", "P2SH,CHECKSEQUENCEVERIFY"],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000000040000100000000000000000000000000", "P2SH"],
|
||||
|
||||
["Argument/tx height/time mismatch, both versions"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "0 CHECKSEQUENCEVERIFY 1"]],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000000040000100000000000000000000000000", "P2SH,CHECKSEQUENCEVERIFY"],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000000040000100000000000000000000000000", "P2SH"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "65535 CHECKSEQUENCEVERIFY 1"]],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000000040000100000000000000000000000000", "P2SH,CHECKSEQUENCEVERIFY"],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000000040000100000000000000000000000000", "P2SH"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "4194304 CHECKSEQUENCEVERIFY 1"]],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000", "P2SH,CHECKSEQUENCEVERIFY"],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000", "P2SH"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "4259839 CHECKSEQUENCEVERIFY 1"]],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000", "P2SH,CHECKSEQUENCEVERIFY"],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000", "P2SH"],
|
||||
|
||||
["6 byte non-minimally-encoded arguments are invalid even if their contents are valid"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "0x06 0x000000000000 CHECKSEQUENCEVERIFY 1"]],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000ffff00000100000000000000000000000000", "P2SH,CHECKSEQUENCEVERIFY"],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000ffff00000100000000000000000000000000", "P2SH"],
|
||||
|
||||
["Failure due to failing CHECKSEQUENCEVERIFY in scriptSig"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "1"]],
|
||||
"02000000010001000000000000000000000000000000000000000000000000000000000000000000000251b2000000000100000000000000000000000000", "P2SH,CHECKSEQUENCEVERIFY"],
|
||||
"02000000010001000000000000000000000000000000000000000000000000000000000000000000000251b0000000000100000000000000000000000000", "P2SH"],
|
||||
|
||||
["Failure due to failing CHECKSEQUENCEVERIFY in redeemScript"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "HASH160 0x14 0x7c17aff532f22beb54069942f9bf567a66133eaf EQUAL"]],
|
||||
"0200000001000100000000000000000000000000000000000000000000000000000000000000000000030251b2000000000100000000000000000000000000", "P2SH,CHECKSEQUENCEVERIFY"],
|
||||
|
||||
["Failure due to insufficient tx.nVersion (<2)"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "0 CHECKSEQUENCEVERIFY 1"]],
|
||||
"010000000100010000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000", "P2SH,CHECKSEQUENCEVERIFY"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "4194304 CHECKSEQUENCEVERIFY 1"]],
|
||||
"010000000100010000000000000000000000000000000000000000000000000000000000000000000000000040000100000000000000000000000000", "P2SH,CHECKSEQUENCEVERIFY"],
|
||||
"0200000001000100000000000000000000000000000000000000000000000000000000000000000000030251b1000000000100000000000000000000000000", "P2SH"],
|
||||
|
||||
|
||||
["The following tests for the fix of a btc bug in the handling of SIGHASH_SINGLE"],
|
||||
|
@ -117,43 +117,43 @@
|
||||
|
||||
["By-height locks, with argument == 0 and == tx nLockTime"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "0 CHECKLOCKTIMEVERIFY 1"]],
|
||||
"010000000100010000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000", "P2SH,CHECKLOCKTIMEVERIFY"],
|
||||
"010000000100010000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000", "P2SH"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "499999999 CHECKLOCKTIMEVERIFY 1"]],
|
||||
"0100000001000100000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000ff64cd1d", "P2SH,CHECKLOCKTIMEVERIFY"],
|
||||
"0100000001000100000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000ff64cd1d", "P2SH"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "0 CHECKLOCKTIMEVERIFY 1"]],
|
||||
"0100000001000100000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000ff64cd1d", "P2SH,CHECKLOCKTIMEVERIFY"],
|
||||
"0100000001000100000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000ff64cd1d", "P2SH"],
|
||||
|
||||
["By-time locks, with argument just beyond tx nLockTime (but within numerical boundaries)"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "500000000 CHECKLOCKTIMEVERIFY 1"]],
|
||||
"01000000010001000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000065cd1d", "P2SH,CHECKLOCKTIMEVERIFY"],
|
||||
"01000000010001000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000065cd1d", "P2SH"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "4294967295 CHECKLOCKTIMEVERIFY 1"]],
|
||||
"0100000001000100000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000ffffffff", "P2SH,CHECKLOCKTIMEVERIFY"],
|
||||
"0100000001000100000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000ffffffff", "P2SH"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "500000000 CHECKLOCKTIMEVERIFY 1"]],
|
||||
"0100000001000100000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000ffffffff", "P2SH,CHECKLOCKTIMEVERIFY"],
|
||||
"0100000001000100000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000ffffffff", "P2SH"],
|
||||
|
||||
["Any non-maxint nSequence is fine"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "0 CHECKLOCKTIMEVERIFY 1"]],
|
||||
"010000000100010000000000000000000000000000000000000000000000000000000000000000000000feffffff0100000000000000000000000000", "P2SH,CHECKLOCKTIMEVERIFY"],
|
||||
"010000000100010000000000000000000000000000000000000000000000000000000000000000000000feffffff0100000000000000000000000000", "P2SH"],
|
||||
|
||||
["The argument can be calculated rather than created directly by a PUSHDATA"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "499999999 1ADD CHECKLOCKTIMEVERIFY 1"]],
|
||||
"01000000010001000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000065cd1d", "P2SH,CHECKLOCKTIMEVERIFY"],
|
||||
"01000000010001000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000065cd1d", "P2SH"],
|
||||
|
||||
["Perhaps even by an ADD producing a 5-byte result that is out of bounds for other opcodes"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "2147483647 2147483647 ADD CHECKLOCKTIMEVERIFY 1"]],
|
||||
"0100000001000100000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000feffffff", "P2SH,CHECKLOCKTIMEVERIFY"],
|
||||
"0100000001000100000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000feffffff", "P2SH"],
|
||||
|
||||
["5 byte non-minimally-encoded arguments are valid"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "0x05 0x0000000000 CHECKLOCKTIMEVERIFY 1"]],
|
||||
"010000000100010000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000", "P2SH,CHECKLOCKTIMEVERIFY"],
|
||||
"010000000100010000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000", "P2SH"],
|
||||
|
||||
["Valid CHECKLOCKTIMEVERIFY in scriptSig"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "1"]],
|
||||
"01000000010001000000000000000000000000000000000000000000000000000000000000000000000251b1000000000100000000000000000001000000", "P2SH,CHECKLOCKTIMEVERIFY"],
|
||||
"01000000010001000000000000000000000000000000000000000000000000000000000000000000000251b0000000000100000000000000000001000000", "P2SH"],
|
||||
|
||||
["Valid CHECKLOCKTIMEVERIFY in redeemScript"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "HASH160 0x14 0xc5b93064159b3b2d6ab506a41b1f50463771b988 EQUAL"]],
|
||||
"0100000001000100000000000000000000000000000000000000000000000000000000000000000000030251b1000000000100000000000000000001000000", "P2SH,CHECKLOCKTIMEVERIFY"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "HASH160 0x14 0x105469277736a89dc89ce794f6db2ff926ce3b EQUAL"]],
|
||||
"0100000001000100000000000000000000000000000000000000000000000000000000000000000000040351b051000000000100000000000000000001000000", "P2SH"],
|
||||
|
||||
["A transaction with a non-standard DER signature."],
|
||||
[[["b1dbc81696c8a9c0fccd0693ab66d7c368dbc38c0def4e800685560ddd1b2132", 0, "DUP HASH160 0x14 0x4b3bd7eba3bc0284fd3007be7f3be275e94f5826 EQUALVERIFY CHECKSIG"]],
|
||||
@ -163,85 +163,85 @@
|
||||
|
||||
["By-height locks, with argument == 0 and == txin.nSequence"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "0 CHECKSEQUENCEVERIFY 1"]],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000", "P2SH,CHECKSEQUENCEVERIFY"],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000", "P2SH"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "65535 CHECKSEQUENCEVERIFY 1"]],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000ffff00000100000000000000000000000000", "P2SH,CHECKSEQUENCEVERIFY"],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000ffff00000100000000000000000000000000", "P2SH"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "65535 CHECKSEQUENCEVERIFY 1"]],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000ffffbf7f0100000000000000000000000000", "P2SH,CHECKSEQUENCEVERIFY"],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000ffffbf7f0100000000000000000000000000", "P2SH"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "0 CHECKSEQUENCEVERIFY 1"]],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000ffffbf7f0100000000000000000000000000", "P2SH,CHECKSEQUENCEVERIFY"],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000ffffbf7f0100000000000000000000000000", "P2SH"],
|
||||
|
||||
["By-time locks, with argument == 0 and == txin.nSequence"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "4194304 CHECKSEQUENCEVERIFY 1"]],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000000040000100000000000000000000000000", "P2SH,CHECKSEQUENCEVERIFY"],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000000040000100000000000000000000000000", "P2SH"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "4259839 CHECKSEQUENCEVERIFY 1"]],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000ffff40000100000000000000000000000000", "P2SH,CHECKSEQUENCEVERIFY"],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000ffff40000100000000000000000000000000", "P2SH"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "4259839 CHECKSEQUENCEVERIFY 1"]],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000ffffff7f0100000000000000000000000000", "P2SH,CHECKSEQUENCEVERIFY"],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000ffffff7f0100000000000000000000000000", "P2SH"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "4194304 CHECKSEQUENCEVERIFY 1"]],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000ffffff7f0100000000000000000000000000", "P2SH,CHECKSEQUENCEVERIFY"],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000ffffff7f0100000000000000000000000000", "P2SH"],
|
||||
|
||||
["Upper sequence with upper sequence is fine"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "2147483648 CHECKSEQUENCEVERIFY 1"]],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000000000800100000000000000000000000000", "P2SH,CHECKSEQUENCEVERIFY"],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000000000800100000000000000000000000000", "P2SH"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "4294967295 CHECKSEQUENCEVERIFY 1"]],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000000000800100000000000000000000000000", "P2SH,CHECKSEQUENCEVERIFY"],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000000000800100000000000000000000000000", "P2SH"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "2147483648 CHECKSEQUENCEVERIFY 1"]],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000feffffff0100000000000000000000000000", "P2SH,CHECKSEQUENCEVERIFY"],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000feffffff0100000000000000000000000000", "P2SH"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "4294967295 CHECKSEQUENCEVERIFY 1"]],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000feffffff0100000000000000000000000000", "P2SH,CHECKSEQUENCEVERIFY"],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000feffffff0100000000000000000000000000", "P2SH"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "2147483648 CHECKSEQUENCEVERIFY 1"]],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000ffffffff0100000000000000000000000000", "P2SH,CHECKSEQUENCEVERIFY"],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000ffffffff0100000000000000000000000000", "P2SH"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "4294967295 CHECKSEQUENCEVERIFY 1"]],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000ffffffff0100000000000000000000000000", "P2SH,CHECKSEQUENCEVERIFY"],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000ffffffff0100000000000000000000000000", "P2SH"],
|
||||
|
||||
["Argument 2^31 with various nSequence"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "2147483648 CHECKSEQUENCEVERIFY 1"]],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000ffffbf7f0100000000000000000000000000", "P2SH,CHECKSEQUENCEVERIFY"],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000ffffbf7f0100000000000000000000000000", "P2SH"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "2147483648 CHECKSEQUENCEVERIFY 1"]],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000ffffff7f0100000000000000000000000000", "P2SH,CHECKSEQUENCEVERIFY"],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000ffffff7f0100000000000000000000000000", "P2SH"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "2147483648 CHECKSEQUENCEVERIFY 1"]],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000ffffffff0100000000000000000000000000", "P2SH,CHECKSEQUENCEVERIFY"],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000ffffffff0100000000000000000000000000", "P2SH"],
|
||||
|
||||
["Argument 2^32-1 with various nSequence"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "4294967295 CHECKSEQUENCEVERIFY 1"]],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000ffffbf7f0100000000000000000000000000", "P2SH,CHECKSEQUENCEVERIFY"],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000ffffbf7f0100000000000000000000000000", "P2SH"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "4294967295 CHECKSEQUENCEVERIFY 1"]],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000ffffff7f0100000000000000000000000000", "P2SH,CHECKSEQUENCEVERIFY"],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000ffffff7f0100000000000000000000000000", "P2SH"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "4294967295 CHECKSEQUENCEVERIFY 1"]],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000ffffffff0100000000000000000000000000", "P2SH,CHECKSEQUENCEVERIFY"],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000ffffffff0100000000000000000000000000", "P2SH"],
|
||||
|
||||
["Argument 3<<31 with various nSequence"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "6442450944 CHECKSEQUENCEVERIFY 1"]],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000ffffbf7f0100000000000000000000000000", "P2SH,CHECKSEQUENCEVERIFY"],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000ffffbf7f0100000000000000000000000000", "P2SH"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "6442450944 CHECKSEQUENCEVERIFY 1"]],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000ffffff7f0100000000000000000000000000", "P2SH,CHECKSEQUENCEVERIFY"],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000ffffff7f0100000000000000000000000000", "P2SH"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "6442450944 CHECKSEQUENCEVERIFY 1"]],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000ffffffff0100000000000000000000000000", "P2SH,CHECKSEQUENCEVERIFY"],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000ffffffff0100000000000000000000000000", "P2SH"],
|
||||
|
||||
["5 byte non-minimally-encoded operandss are valid"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "0x05 0x0000000000 CHECKSEQUENCEVERIFY 1"]],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000", "P2SH,CHECKSEQUENCEVERIFY"],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000", "P2SH"],
|
||||
|
||||
["The argument can be calculated rather than created directly by a PUSHDATA"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "4194303 1ADD CHECKSEQUENCEVERIFY 1"]],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000000040000100000000000000000000000000", "P2SH,CHECKSEQUENCEVERIFY"],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000000040000100000000000000000000000000", "P2SH"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "4194304 1SUB CHECKSEQUENCEVERIFY 1"]],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000ffff00000100000000000000000000000000", "P2SH,CHECKSEQUENCEVERIFY"],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000ffff00000100000000000000000000000000", "P2SH"],
|
||||
|
||||
["An ADD producing a 5-byte result that sets CTxIn::SEQUENCE_LOCKTIME_DISABLE_FLAG"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "2147483647 65536 CHECKSEQUENCEVERIFY 1"]],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000", "P2SH,CHECKSEQUENCEVERIFY"],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000", "P2SH"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "2147483647 4259840 ADD CHECKSEQUENCEVERIFY 1"]],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000000040000100000000000000000000000000", "P2SH,CHECKSEQUENCEVERIFY"],
|
||||
"020000000100010000000000000000000000000000000000000000000000000000000000000000000000000040000100000000000000000000000000", "P2SH"],
|
||||
|
||||
["Valid CHECKSEQUENCEVERIFY in scriptSig"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "1"]],
|
||||
"02000000010001000000000000000000000000000000000000000000000000000000000000000000000251b2010000000100000000000000000000000000", "P2SH,CHECKSEQUENCEVERIFY"],
|
||||
"02000000010001000000000000000000000000000000000000000000000000000000000000000000000251b2010000000100000000000000000000000000", "P2SH"],
|
||||
|
||||
["Valid CHECKSEQUENCEVERIFY in redeemScript"],
|
||||
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "HASH160 0x14 0x7c17aff532f22beb54069942f9bf567a66133eaf EQUAL"]],
|
||||
"0200000001000100000000000000000000000000000000000000000000000000000000000000000000030251b2010000000100000000000000000000000000", "P2SH,CHECKSEQUENCEVERIFY"],
|
||||
"0200000001000100000000000000000000000000000000000000000000000000000000000000000000030251b2010000000100000000000000000000000000", "P2SH"],
|
||||
|
||||
["Make diffs cleaner by leaving a comment here without comma at the end"]
|
||||
]
|
||||
|
@ -29,16 +29,6 @@ const (
|
||||
// executed.
|
||||
ScriptDiscourageUpgradableNops
|
||||
|
||||
// ScriptVerifyCheckLockTimeVerify defines whether to verify that
|
||||
// a transaction output is spendable based on the locktime.
|
||||
// This is BIP0065.
|
||||
ScriptVerifyCheckLockTimeVerify
|
||||
|
||||
// ScriptVerifyCheckSequenceVerify defines whether to allow execution
|
||||
// pathways of a script to be restricted based on the age of the output
|
||||
// being spent. This is BIP0112.
|
||||
ScriptVerifyCheckSequenceVerify
|
||||
|
||||
// ScriptVerifyCleanStack defines that the stack must contain only
|
||||
// one stack element after evaluation and that the element must be
|
||||
// true if interpreted as a boolean. This is rule 6 of BIP0062.
|
||||
|
@ -212,20 +212,18 @@ const (
|
||||
OpCheckSigVerify = 0xad // 173
|
||||
OpCheckMultiSig = 0xae // 174
|
||||
OpCheckMultiSigVerify = 0xaf // 175
|
||||
OpNop1 = 0xb0 // 176
|
||||
OpNop2 = 0xb1 // 177
|
||||
OpCheckLockTimeVerify = 0xb1 // 177 - AKA OPNop2
|
||||
OpNop3 = 0xb2 // 178
|
||||
OpCheckSequenceVerify = 0xb2 // 178 - AKA OpNop3
|
||||
OpNop4 = 0xb3 // 179
|
||||
OpNop5 = 0xb4 // 180
|
||||
OpNop6 = 0xb5 // 181
|
||||
OpNop7 = 0xb6 // 182
|
||||
OpNop8 = 0xb7 // 183
|
||||
OpNop9 = 0xb8 // 184
|
||||
OpNop10 = 0xb9 // 185
|
||||
OpUnknown186 = 0xba // 186
|
||||
OpUnknown187 = 0xbb // 187
|
||||
OpCheckLockTimeVerify = 0xb0 // 176
|
||||
OpCheckSequenceVerify = 0xb1 // 177
|
||||
OpNop1 = 0xb2 // 178
|
||||
OpNop2 = 0xb3 // 179
|
||||
OpNop3 = 0xb4 // 180
|
||||
OpNop4 = 0xb5 // 181
|
||||
OpNop5 = 0xb6 // 182
|
||||
OpNop6 = 0xb7 // 183
|
||||
OpNop7 = 0xb8 // 184
|
||||
OpNop8 = 0xb9 // 185
|
||||
OpNop9 = 0xba // 186
|
||||
OpNop10 = 0xbb // 187
|
||||
OpUnknown188 = 0xbc // 188
|
||||
OpUnknown189 = 0xbd // 189
|
||||
OpUnknown190 = 0xbe // 190
|
||||
@ -500,6 +498,8 @@ var opcodeArray = [256]opcode{
|
||||
|
||||
// Reserved opcodes.
|
||||
OpNop1: {OpNop1, "OP_NOP1", 1, opcodeNop},
|
||||
OpNop2: {OpNop2, "OP_NOP2", 1, opcodeNop},
|
||||
OpNop3: {OpNop3, "OP_NOP3", 1, opcodeNop},
|
||||
OpNop4: {OpNop4, "OP_NOP4", 1, opcodeNop},
|
||||
OpNop5: {OpNop5, "OP_NOP5", 1, opcodeNop},
|
||||
OpNop6: {OpNop6, "OP_NOP6", 1, opcodeNop},
|
||||
@ -510,8 +510,6 @@ var opcodeArray = [256]opcode{
|
||||
|
||||
// Undefined opcodes.
|
||||
OpUnknown171: {OpUnknown171, "OP_UNKNOWN171", 1, opcodeInvalid},
|
||||
OpUnknown186: {OpUnknown186, "OP_UNKNOWN186", 1, opcodeInvalid},
|
||||
OpUnknown187: {OpUnknown187, "OP_UNKNOWN187", 1, opcodeInvalid},
|
||||
OpUnknown188: {OpUnknown188, "OP_UNKNOWN188", 1, opcodeInvalid},
|
||||
OpUnknown189: {OpUnknown189, "OP_UNKNOWN189", 1, opcodeInvalid},
|
||||
OpUnknown190: {OpUnknown190, "OP_UNKNOWN190", 1, opcodeInvalid},
|
||||
@ -617,6 +615,17 @@ type parsedOpcode struct {
|
||||
data []byte
|
||||
}
|
||||
|
||||
// isUpgradableNop returns whether or not the opcode is a numbered nop
|
||||
// that is intended to be upgradable by a soft fork
|
||||
func isUpgradableNop(pop *parsedOpcode) bool {
|
||||
switch pop.opcode.value {
|
||||
case OpNop1, OpNop2, OpNop3, OpNop4, OpNop5,
|
||||
OpNop6, OpNop7, OpNop8, OpNop9, OpNop10:
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// isDisabled returns whether or not the opcode is disabled and thus is always
|
||||
// bad to see in the instruction stream (even if turned off by a conditional).
|
||||
func (pop *parsedOpcode) isDisabled() bool {
|
||||
@ -906,9 +915,7 @@ func opcodeN(op *parsedOpcode, vm *Engine) error {
|
||||
// implies it generally does nothing, however, it will return an error when
|
||||
// the flag to discourage use of NOPs is set for select opcodes.
|
||||
func opcodeNop(op *parsedOpcode, vm *Engine) error {
|
||||
switch op.opcode.value {
|
||||
case OpNop1, OpNop4, OpNop5,
|
||||
OpNop6, OpNop7, OpNop8, OpNop9, OpNop10:
|
||||
if isUpgradableNop(op) {
|
||||
if vm.hasFlag(ScriptDiscourageUpgradableNops) {
|
||||
str := fmt.Sprintf("OP_NOP%d reserved for soft-fork "+
|
||||
"upgrades", op.opcode.value-(OpNop1-1))
|
||||
@ -1081,20 +1088,8 @@ func verifyLockTime(txLockTime, threshold, lockTime int64) error {
|
||||
|
||||
// opcodeCheckLockTimeVerify compares the top item on the data stack to the
|
||||
// LockTime field of the transaction containing the script signature
|
||||
// validating if the transaction outputs are spendable yet. If flag
|
||||
// ScriptVerifyCheckLockTimeVerify is not set, the code continues as if OP_NOP2
|
||||
// were executed.
|
||||
// validating if the transaction outputs are spendable yet.
|
||||
func opcodeCheckLockTimeVerify(op *parsedOpcode, vm *Engine) error {
|
||||
// If the ScriptVerifyCheckLockTimeVerify script flag is not set, treat
|
||||
// opcode as OP_NOP2 instead.
|
||||
if !vm.hasFlag(ScriptVerifyCheckLockTimeVerify) {
|
||||
if vm.hasFlag(ScriptDiscourageUpgradableNops) {
|
||||
return scriptError(ErrDiscourageUpgradableNOPs,
|
||||
"OP_NOP2 reserved for soft-fork upgrades")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// The current transaction locktime is a uint32 resulting in a maximum
|
||||
// locktime of 2^32-1 (the year 2106). However, scriptNums are signed
|
||||
// and therefore a standard 4-byte scriptNum would only support up to a
|
||||
@ -1102,9 +1097,9 @@ func opcodeCheckLockTimeVerify(op *parsedOpcode, vm *Engine) error {
|
||||
// here since it will support up to 2^39-1 which allows dates beyond the
|
||||
// current locktime limit.
|
||||
//
|
||||
// PeekByteArray is used here instead of PeekInt because we do not want
|
||||
// PopByteArray is used here instead of PopInt because we do not want
|
||||
// to be limited to a 4-byte integer for reasons specified above.
|
||||
so, err := vm.dstack.PeekByteArray(0)
|
||||
so, err := vm.dstack.PopByteArray()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -1155,19 +1150,8 @@ func opcodeCheckLockTimeVerify(op *parsedOpcode, vm *Engine) error {
|
||||
|
||||
// opcodeCheckSequenceVerify compares the top item on the data stack to the
|
||||
// LockTime field of the transaction containing the script signature
|
||||
// validating if the transaction outputs are spendable yet. If flag
|
||||
// ScriptVerifyCheckSequenceVerify is not set, the code continues as if OP_NOP3
|
||||
// were executed.
|
||||
// validating if the transaction outputs are spendable yet.
|
||||
func opcodeCheckSequenceVerify(op *parsedOpcode, vm *Engine) error {
|
||||
// If the ScriptVerifyCheckSequenceVerify script flag is not set, treat
|
||||
// opcode as OP_NOP3 instead.
|
||||
if !vm.hasFlag(ScriptVerifyCheckSequenceVerify) {
|
||||
if vm.hasFlag(ScriptDiscourageUpgradableNops) {
|
||||
return scriptError(ErrDiscourageUpgradableNOPs,
|
||||
"OP_NOP3 reserved for soft-fork upgrades")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// The current transaction sequence is a uint32 resulting in a maximum
|
||||
// sequence of 2^32-1. However, scriptNums are signed and therefore a
|
||||
@ -1176,9 +1160,9 @@ func opcodeCheckSequenceVerify(op *parsedOpcode, vm *Engine) error {
|
||||
// up to 2^39-1 which allows sequences beyond the current sequence
|
||||
// limit.
|
||||
//
|
||||
// PeekByteArray is used here instead of PeekInt because we do not want
|
||||
// PopByteArray is used here instead of PopInt because we do not want
|
||||
// to be limited to a 4-byte integer for reasons specified above.
|
||||
so, err := vm.dstack.PeekByteArray(0)
|
||||
so, err := vm.dstack.PopByteArray()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -1204,14 +1188,6 @@ func opcodeCheckSequenceVerify(op *parsedOpcode, vm *Engine) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Transaction version numbers not high enough to trigger CSV rules must
|
||||
// fail.
|
||||
if vm.tx.Version < 2 {
|
||||
str := fmt.Sprintf("invalid transaction version: %d",
|
||||
vm.tx.Version)
|
||||
return scriptError(ErrUnsatisfiedLockTime, str)
|
||||
}
|
||||
|
||||
// Sequence numbers with their most significant bit set are not
|
||||
// consensus constrained. Testing that the transaction's sequence
|
||||
// number does not have this bit set prevents using this property
|
||||
@ -2320,14 +2296,11 @@ var OpcodeByName = make(map[string]byte)
|
||||
|
||||
func init() {
|
||||
// Initialize the opcode name to value map using the contents of the
|
||||
// opcode array. Also add entries for "OP_FALSE", "OP_TRUE", and
|
||||
// "OP_NOP2" since they are aliases for "OP_0", "OP_1",
|
||||
// and "OP_CHECKLOCKTIMEVERIFY" respectively.
|
||||
// opcode array. Also add entries for "OP_FALSE" and "OP_TRUE"
|
||||
// since they are aliases for "OP_0" and "OP_1" respectively.
|
||||
for _, op := range opcodeArray {
|
||||
OpcodeByName[op.name] = op.value
|
||||
}
|
||||
OpcodeByName["OP_FALSE"] = OpFalse
|
||||
OpcodeByName["OP_TRUE"] = OpTrue
|
||||
OpcodeByName["OP_NOP2"] = OpCheckLockTimeVerify
|
||||
OpcodeByName["OP_NOP3"] = OpCheckSequenceVerify
|
||||
}
|
||||
|
@ -75,6 +75,7 @@ func TestOpcodeDisasm(t *testing.T) {
|
||||
0xa9: "OP_HASH160", 0xaa: "OP_HASH256",
|
||||
0xac: "OP_CHECKSIG", 0xad: "OP_CHECKSIGVERIFY",
|
||||
0xae: "OP_CHECKMULTISIG", 0xaf: "OP_CHECKMULTISIGVERIFY",
|
||||
0xb0: "OP_CHECKLOCKTIMEVERIFY", 0xb1: "OP_CHECKSEQUENCEVERIFY",
|
||||
0xfa: "OP_SMALLINTEGER", 0xfb: "OP_PUBKEYS",
|
||||
0xfd: "OP_PUBKEYHASH", 0xfe: "OP_PUBKEY",
|
||||
0xff: "OP_INVALIDOPCODE",
|
||||
@ -108,19 +109,9 @@ func TestOpcodeDisasm(t *testing.T) {
|
||||
data = []byte{val}
|
||||
expectedStr = strconv.Itoa(int(val))
|
||||
|
||||
// OP_NOP1 through OP_NOP10.
|
||||
case opcodeVal >= 0xb0 && opcodeVal <= 0xb9:
|
||||
switch opcodeVal {
|
||||
case 0xb1:
|
||||
// OP_NOP2 is an alias of OP_CHECKLOCKTIMEVERIFY
|
||||
expectedStr = "OP_CHECKLOCKTIMEVERIFY"
|
||||
case 0xb2:
|
||||
// OP_NOP3 is an alias of OP_CHECKSEQUENCEVERIFY
|
||||
expectedStr = "OP_CHECKSEQUENCEVERIFY"
|
||||
default:
|
||||
val := byte(opcodeVal - (0xb0 - 1))
|
||||
expectedStr = "OP_NOP" + strconv.Itoa(int(val))
|
||||
}
|
||||
case isNumberedNop(opcodeVal):
|
||||
val := byte(opcodeVal - (OpNop1 - 1))
|
||||
expectedStr = "OP_NOP" + strconv.Itoa(int(val))
|
||||
|
||||
// OP_UNKNOWN#.
|
||||
case isOpUnknown(opcodeVal):
|
||||
@ -174,19 +165,9 @@ func TestOpcodeDisasm(t *testing.T) {
|
||||
data = []byte{val}
|
||||
expectedStr = "OP_" + strconv.Itoa(int(val))
|
||||
|
||||
// OP_NOP1 through OP_NOP10.
|
||||
case opcodeVal >= 0xb0 && opcodeVal <= 0xb9:
|
||||
switch opcodeVal {
|
||||
case 0xb1:
|
||||
// OP_NOP2 is an alias of OP_CHECKLOCKTIMEVERIFY
|
||||
expectedStr = "OP_CHECKLOCKTIMEVERIFY"
|
||||
case 0xb2:
|
||||
// OP_NOP3 is an alias of OP_CHECKSEQUENCEVERIFY
|
||||
expectedStr = "OP_CHECKSEQUENCEVERIFY"
|
||||
default:
|
||||
val := byte(opcodeVal - (0xb0 - 1))
|
||||
expectedStr = "OP_NOP" + strconv.Itoa(int(val))
|
||||
}
|
||||
case isNumberedNop(opcodeVal):
|
||||
val := byte(opcodeVal - (OpNop1 - 1))
|
||||
expectedStr = "OP_NOP" + strconv.Itoa(int(val))
|
||||
|
||||
// OP_UNKNOWN#.
|
||||
case isOpUnknown(opcodeVal):
|
||||
@ -207,3 +188,7 @@ func TestOpcodeDisasm(t *testing.T) {
|
||||
func isOpUnknown(opcodeVal int) bool {
|
||||
return opcodeVal >= 0xba && opcodeVal <= 0xf9 || opcodeVal == 0xfc || opcodeVal == 0xab
|
||||
}
|
||||
|
||||
func isNumberedNop(opcodeVal int) bool {
|
||||
return opcodeVal >= OpNop1 && opcodeVal <= OpNop10
|
||||
}
|
||||
|
@ -135,10 +135,6 @@ func parseScriptFlags(flagStr string) (ScriptFlags, error) {
|
||||
switch flag {
|
||||
case "":
|
||||
// Nothing.
|
||||
case "CHECKLOCKTIMEVERIFY":
|
||||
flags |= ScriptVerifyCheckLockTimeVerify
|
||||
case "CHECKSEQUENCEVERIFY":
|
||||
flags |= ScriptVerifyCheckSequenceVerify
|
||||
case "CLEANSTACK":
|
||||
flags |= ScriptVerifyCleanStack
|
||||
case "DERSIG":
|
||||
@ -671,10 +667,6 @@ testloop:
|
||||
k, i, test)
|
||||
continue testloop
|
||||
}
|
||||
|
||||
if i == 93 {
|
||||
fmt.Printf("lalala")
|
||||
}
|
||||
vm, err := NewEngine(pkScript, tx.MsgTx(), k, flags, nil)
|
||||
if err != nil {
|
||||
t.Errorf("test (%d:%v:%d) failed to create "+
|
||||
|
@ -348,7 +348,7 @@ func TestSignTxOutput(t *testing.T) {
|
||||
|
||||
pk := (*btcec.PublicKey)(&key.PublicKey).
|
||||
SerializeUncompressed()
|
||||
address, err := btcutil.NewAddressPubKey(pk)
|
||||
address, err := btcutil.NewAddressPubKey(pk, &chaincfg.TestNet3Params)
|
||||
if err != nil {
|
||||
t.Errorf("failed to make address for %s: %v",
|
||||
msg, err)
|
||||
@ -385,7 +385,7 @@ func TestSignTxOutput(t *testing.T) {
|
||||
|
||||
pk := (*btcec.PublicKey)(&key.PublicKey).
|
||||
SerializeUncompressed()
|
||||
address, err := btcutil.NewAddressPubKey(pk)
|
||||
address, err := btcutil.NewAddressPubKey(pk, &chaincfg.TestNet3Params)
|
||||
if err != nil {
|
||||
t.Errorf("failed to make address for %s: %v",
|
||||
msg, err)
|
||||
@ -445,7 +445,7 @@ func TestSignTxOutput(t *testing.T) {
|
||||
|
||||
pk := (*btcec.PublicKey)(&key.PublicKey).
|
||||
SerializeCompressed()
|
||||
address, err := btcutil.NewAddressPubKey(pk)
|
||||
address, err := btcutil.NewAddressPubKey(pk, &chaincfg.TestNet3Params)
|
||||
if err != nil {
|
||||
t.Errorf("failed to make address for %s: %v",
|
||||
msg, err)
|
||||
@ -482,7 +482,7 @@ func TestSignTxOutput(t *testing.T) {
|
||||
|
||||
pk := (*btcec.PublicKey)(&key.PublicKey).
|
||||
SerializeCompressed()
|
||||
address, err := btcutil.NewAddressPubKey(pk)
|
||||
address, err := btcutil.NewAddressPubKey(pk, &chaincfg.TestNet3Params)
|
||||
if err != nil {
|
||||
t.Errorf("failed to make address for %s: %v",
|
||||
msg, err)
|
||||
@ -817,7 +817,7 @@ func TestSignTxOutput(t *testing.T) {
|
||||
|
||||
pk := (*btcec.PublicKey)(&key.PublicKey).
|
||||
SerializeUncompressed()
|
||||
address, err := btcutil.NewAddressPubKey(pk)
|
||||
address, err := btcutil.NewAddressPubKey(pk, &chaincfg.TestNet3Params)
|
||||
if err != nil {
|
||||
t.Errorf("failed to make address for %s: %v",
|
||||
msg, err)
|
||||
@ -872,7 +872,7 @@ func TestSignTxOutput(t *testing.T) {
|
||||
|
||||
pk := (*btcec.PublicKey)(&key.PublicKey).
|
||||
SerializeUncompressed()
|
||||
address, err := btcutil.NewAddressPubKey(pk)
|
||||
address, err := btcutil.NewAddressPubKey(pk, &chaincfg.TestNet3Params)
|
||||
if err != nil {
|
||||
t.Errorf("failed to make address for %s: %v",
|
||||
msg, err)
|
||||
@ -951,7 +951,7 @@ func TestSignTxOutput(t *testing.T) {
|
||||
|
||||
pk := (*btcec.PublicKey)(&key.PublicKey).
|
||||
SerializeCompressed()
|
||||
address, err := btcutil.NewAddressPubKey(pk)
|
||||
address, err := btcutil.NewAddressPubKey(pk, &chaincfg.TestNet3Params)
|
||||
if err != nil {
|
||||
t.Errorf("failed to make address for %s: %v",
|
||||
msg, err)
|
||||
@ -1005,7 +1005,7 @@ func TestSignTxOutput(t *testing.T) {
|
||||
|
||||
pk := (*btcec.PublicKey)(&key.PublicKey).
|
||||
SerializeCompressed()
|
||||
address, err := btcutil.NewAddressPubKey(pk)
|
||||
address, err := btcutil.NewAddressPubKey(pk, &chaincfg.TestNet3Params)
|
||||
if err != nil {
|
||||
t.Errorf("failed to make address for %s: %v",
|
||||
msg, err)
|
||||
@ -1084,7 +1084,7 @@ func TestSignTxOutput(t *testing.T) {
|
||||
|
||||
pk1 := (*btcec.PublicKey)(&key1.PublicKey).
|
||||
SerializeCompressed()
|
||||
address1, err := btcutil.NewAddressPubKey(pk1)
|
||||
address1, err := btcutil.NewAddressPubKey(pk1, &chaincfg.TestNet3Params)
|
||||
if err != nil {
|
||||
t.Errorf("failed to make address for %s: %v",
|
||||
msg, err)
|
||||
@ -1100,7 +1100,7 @@ func TestSignTxOutput(t *testing.T) {
|
||||
|
||||
pk2 := (*btcec.PublicKey)(&key2.PublicKey).
|
||||
SerializeCompressed()
|
||||
address2, err := btcutil.NewAddressPubKey(pk2)
|
||||
address2, err := btcutil.NewAddressPubKey(pk2, &chaincfg.TestNet3Params)
|
||||
if err != nil {
|
||||
t.Errorf("failed to make address 2 for %s: %v",
|
||||
msg, err)
|
||||
@ -1157,7 +1157,7 @@ func TestSignTxOutput(t *testing.T) {
|
||||
|
||||
pk1 := (*btcec.PublicKey)(&key1.PublicKey).
|
||||
SerializeCompressed()
|
||||
address1, err := btcutil.NewAddressPubKey(pk1)
|
||||
address1, err := btcutil.NewAddressPubKey(pk1, &chaincfg.TestNet3Params)
|
||||
if err != nil {
|
||||
t.Errorf("failed to make address for %s: %v",
|
||||
msg, err)
|
||||
@ -1173,7 +1173,7 @@ func TestSignTxOutput(t *testing.T) {
|
||||
|
||||
pk2 := (*btcec.PublicKey)(&key2.PublicKey).
|
||||
SerializeCompressed()
|
||||
address2, err := btcutil.NewAddressPubKey(pk2)
|
||||
address2, err := btcutil.NewAddressPubKey(pk2, &chaincfg.TestNet3Params)
|
||||
if err != nil {
|
||||
t.Errorf("failed to make address 2 for %s: %v",
|
||||
msg, err)
|
||||
@ -1259,7 +1259,7 @@ func TestSignTxOutput(t *testing.T) {
|
||||
|
||||
pk1 := (*btcec.PublicKey)(&key1.PublicKey).
|
||||
SerializeCompressed()
|
||||
address1, err := btcutil.NewAddressPubKey(pk1)
|
||||
address1, err := btcutil.NewAddressPubKey(pk1, &chaincfg.TestNet3Params)
|
||||
if err != nil {
|
||||
t.Errorf("failed to make address for %s: %v",
|
||||
msg, err)
|
||||
@ -1275,7 +1275,7 @@ func TestSignTxOutput(t *testing.T) {
|
||||
|
||||
pk2 := (*btcec.PublicKey)(&key2.PublicKey).
|
||||
SerializeCompressed()
|
||||
address2, err := btcutil.NewAddressPubKey(pk2)
|
||||
address2, err := btcutil.NewAddressPubKey(pk2, &chaincfg.TestNet3Params)
|
||||
if err != nil {
|
||||
t.Errorf("failed to make address 2 for %s: %v",
|
||||
msg, err)
|
||||
|
@ -33,8 +33,6 @@ const (
|
||||
ScriptDiscourageUpgradableNops |
|
||||
ScriptVerifyCleanStack |
|
||||
ScriptVerifyNullFail |
|
||||
ScriptVerifyCheckLockTimeVerify |
|
||||
ScriptVerifyCheckSequenceVerify |
|
||||
ScriptVerifyLowS
|
||||
)
|
||||
|
||||
@ -450,7 +448,7 @@ func ExtractPkScriptAddrs(pkScript []byte, chainParams *chaincfg.Params) (Script
|
||||
// Therefore the pubkey is the first item on the stack.
|
||||
// Skip the pubkey if it's invalid for some reason.
|
||||
requiredSigs = 1
|
||||
addr, err := btcutil.NewAddressPubKey(pops[0].data)
|
||||
addr, err := btcutil.NewAddressPubKey(pops[0].data, chainParams)
|
||||
if err == nil {
|
||||
addrs = append(addrs, addr)
|
||||
}
|
||||
@ -479,7 +477,7 @@ func ExtractPkScriptAddrs(pkScript []byte, chainParams *chaincfg.Params) (Script
|
||||
// Extract the public keys while skipping any that are invalid.
|
||||
addrs = make([]btcutil.Address, 0, numPubKeys)
|
||||
for i := 0; i < numPubKeys; i++ {
|
||||
addr, err := btcutil.NewAddressPubKey(pops[i+1].data)
|
||||
addr, err := btcutil.NewAddressPubKey(pops[i+1].data, chainParams)
|
||||
if err == nil {
|
||||
addrs = append(addrs, addr)
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ func mustParseShortForm(script string) []byte {
|
||||
// the tests as a helper since the only way it can fail is if there is an error
|
||||
// in the test source code.
|
||||
func newAddressPubKey(serializedPubKey []byte) btcutil.Address {
|
||||
addr, err := btcutil.NewAddressPubKey(serializedPubKey)
|
||||
addr, err := btcutil.NewAddressPubKey(serializedPubKey, &chaincfg.MainNetParams)
|
||||
if err != nil {
|
||||
panic("invalid public key in test source")
|
||||
}
|
||||
@ -529,23 +529,23 @@ func TestPayToAddrScript(t *testing.T) {
|
||||
}
|
||||
|
||||
// mainnet p2pk 13CG6SJ3yHUXo4Cr2RY4THLLJrNFuG3gUg
|
||||
p2pkCompressedMain, err := btcutil.NewAddressPubKey(hexToBytes("02192d" +
|
||||
"74d0cb94344c9569c2e77901573d8d7903c3ebec3a957724895dca52c6b4"))
|
||||
p2pkCompressedMain, err := btcutil.NewAddressPubKey(hexToBytes("02192d"+
|
||||
"74d0cb94344c9569c2e77901573d8d7903c3ebec3a957724895dca52c6b4"), &chaincfg.MainNetParams)
|
||||
if err != nil {
|
||||
t.Fatalf("Unable to create pubkey address (compressed): %v",
|
||||
err)
|
||||
}
|
||||
p2pkCompressed2Main, err := btcutil.NewAddressPubKey(hexToBytes("03b0b" +
|
||||
"d634234abbb1ba1e986e884185c61cf43e001f9137f23c2c409273eb16e65"))
|
||||
p2pkCompressed2Main, err := btcutil.NewAddressPubKey(hexToBytes("03b0b"+
|
||||
"d634234abbb1ba1e986e884185c61cf43e001f9137f23c2c409273eb16e65"), &chaincfg.MainNetParams)
|
||||
if err != nil {
|
||||
t.Fatalf("Unable to create pubkey address (compressed 2): %v",
|
||||
err)
|
||||
}
|
||||
|
||||
p2pkUncompressedMain, err := btcutil.NewAddressPubKey(hexToBytes("0411" +
|
||||
"db93e1dcdb8a016b49840f8c53bc1eb68a382e97b1482ecad7b148a6909a5" +
|
||||
"cb2e0eaddfb84ccf9744464f82e160bfa9b8b64f9d4c03f999b8643f656b4" +
|
||||
"12a3"))
|
||||
p2pkUncompressedMain, err := btcutil.NewAddressPubKey(hexToBytes("0411"+
|
||||
"db93e1dcdb8a016b49840f8c53bc1eb68a382e97b1482ecad7b148a6909a5"+
|
||||
"cb2e0eaddfb84ccf9744464f82e160bfa9b8b64f9d4c03f999b8643f656b4"+
|
||||
"12a3"), &chaincfg.MainNetParams)
|
||||
if err != nil {
|
||||
t.Fatalf("Unable to create pubkey address (uncompressed): %v",
|
||||
err)
|
||||
@ -631,23 +631,23 @@ func TestMultiSigScript(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
// mainnet p2pk 13CG6SJ3yHUXo4Cr2RY4THLLJrNFuG3gUg
|
||||
p2pkCompressedMain, err := btcutil.NewAddressPubKey(hexToBytes("02192d" +
|
||||
"74d0cb94344c9569c2e77901573d8d7903c3ebec3a957724895dca52c6b4"))
|
||||
p2pkCompressedMain, err := btcutil.NewAddressPubKey(hexToBytes("02192d"+
|
||||
"74d0cb94344c9569c2e77901573d8d7903c3ebec3a957724895dca52c6b4"), &chaincfg.MainNetParams)
|
||||
if err != nil {
|
||||
t.Fatalf("Unable to create pubkey address (compressed): %v",
|
||||
err)
|
||||
}
|
||||
p2pkCompressed2Main, err := btcutil.NewAddressPubKey(hexToBytes("03b0b" +
|
||||
"d634234abbb1ba1e986e884185c61cf43e001f9137f23c2c409273eb16e65"))
|
||||
p2pkCompressed2Main, err := btcutil.NewAddressPubKey(hexToBytes("03b0b"+
|
||||
"d634234abbb1ba1e986e884185c61cf43e001f9137f23c2c409273eb16e65"), &chaincfg.MainNetParams)
|
||||
if err != nil {
|
||||
t.Fatalf("Unable to create pubkey address (compressed 2): %v",
|
||||
err)
|
||||
}
|
||||
|
||||
p2pkUncompressedMain, err := btcutil.NewAddressPubKey(hexToBytes("0411" +
|
||||
"db93e1dcdb8a016b49840f8c53bc1eb68a382e97b1482ecad7b148a6909a5" +
|
||||
"cb2e0eaddfb84ccf9744464f82e160bfa9b8b64f9d4c03f999b8643f656b4" +
|
||||
"12a3"))
|
||||
p2pkUncompressedMain, err := btcutil.NewAddressPubKey(hexToBytes("0411"+
|
||||
"db93e1dcdb8a016b49840f8c53bc1eb68a382e97b1482ecad7b148a6909a5"+
|
||||
"cb2e0eaddfb84ccf9744464f82e160bfa9b8b64f9d4c03f999b8643f656b4"+
|
||||
"12a3"), &chaincfg.MainNetParams)
|
||||
if err != nil {
|
||||
t.Fatalf("Unable to create pubkey address (uncompressed): %v",
|
||||
err)
|
||||
|
Loading…
x
Reference in New Issue
Block a user