mirror of
https://github.com/btcsuite/btcd.git
synced 2026-08-15 12:50:17 +02:00
fullblocktests, testhelper: move standardCoinbaseScript to testhelper
standardCoinbaseScript is moved to testhelper and is exported. This allows test code in package blockchain to reuse the code without introducing an import cycle. This code is used in the testing code for invalidateblock and reconsiderblock that's added in the later commits.
This commit is contained in:
parent
9093243d8b
commit
59c7d10507
2 changed files with 9 additions and 9 deletions
|
|
@ -220,20 +220,12 @@ func pushDataScript(items ...[]byte) []byte {
|
|||
return script
|
||||
}
|
||||
|
||||
// standardCoinbaseScript returns a standard script suitable for use as the
|
||||
// signature script of the coinbase transaction of a new block. In particular,
|
||||
// it starts with the block height that is required by version 2 blocks.
|
||||
func standardCoinbaseScript(blockHeight int32, extraNonce uint64) ([]byte, error) {
|
||||
return txscript.NewScriptBuilder().AddInt64(int64(blockHeight)).
|
||||
AddInt64(int64(extraNonce)).Script()
|
||||
}
|
||||
|
||||
// createCoinbaseTx returns a coinbase transaction paying an appropriate
|
||||
// subsidy based on the passed block height. The coinbase signature script
|
||||
// conforms to the requirements of version 2 blocks.
|
||||
func (g *testGenerator) createCoinbaseTx(blockHeight int32) *wire.MsgTx {
|
||||
extraNonce := uint64(0)
|
||||
coinbaseScript, err := standardCoinbaseScript(blockHeight, extraNonce)
|
||||
coinbaseScript, err := testhelper.StandardCoinbaseScript(blockHeight, extraNonce)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,14 @@ var (
|
|||
LowFee = btcutil.Amount(1)
|
||||
)
|
||||
|
||||
// StandardCoinbaseScript returns a standard script suitable for use as the
|
||||
// signature script of the coinbase transaction of a new block. In particular,
|
||||
// it starts with the block height that is required by version 2 blocks.
|
||||
func StandardCoinbaseScript(blockHeight int32, extraNonce uint64) ([]byte, error) {
|
||||
return txscript.NewScriptBuilder().AddInt64(int64(blockHeight)).
|
||||
AddInt64(int64(extraNonce)).Script()
|
||||
}
|
||||
|
||||
// OpReturnScript returns a provably-pruneable OP_RETURN script with the
|
||||
// provided data.
|
||||
func OpReturnScript(data []byte) ([]byte, error) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue