diff --git a/README.md b/README.md index a5395400..1aec39dc 100644 --- a/README.md +++ b/README.md @@ -105,8 +105,7 @@ intentionally causes an error by attempting to process a duplicate block. // Insert the main network genesis block. This is part of the initial // database setup. Like above, this typically would not be needed when // opening an existing database. - pver := btcwire.ProtocolVersion - genesisBlock := btcutil.NewBlock(&btcwire.GenesisBlock, pver) + genesisBlock := btcutil.NewBlock(&btcwire.GenesisBlock) _, err = db.InsertBlock(genesisBlock) if err != nil { fmt.Printf("Failed to insert genesis block: %v\n", err) diff --git a/doc.go b/doc.go index 04f70154..00932b3a 100644 --- a/doc.go +++ b/doc.go @@ -98,8 +98,7 @@ intentionally causes an error by attempting to process a duplicate block. // Insert the main network genesis block. This is part of the initial // database setup. Like above, this typically would not be needed when // opening an existing database. - pver := btcwire.ProtocolVersion - genesisBlock := btcutil.NewBlock(&btcwire.GenesisBlock, pver) + genesisBlock := btcutil.NewBlock(&btcwire.GenesisBlock) _, err = db.InsertBlock(genesisBlock) if err != nil { fmt.Printf("Failed to insert genesis block: %v\n", err) diff --git a/merkle_test.go b/merkle_test.go index cd2d4532..18ff1d20 100644 --- a/merkle_test.go +++ b/merkle_test.go @@ -7,13 +7,12 @@ package btcchain_test import ( "github.com/conformal/btcchain" "github.com/conformal/btcutil" - "github.com/conformal/btcwire" "testing" ) // TestMerkle tests the BuildMerkleTreeStore API. func TestMerkle(t *testing.T) { - block := btcutil.NewBlock(&Block100000, btcwire.ProtocolVersion) + block := btcutil.NewBlock(&Block100000) merkles := btcchain.BuildMerkleTreeStore(block) calculatedMerkleRoot := merkles[len(merkles)-1] wantMerkle := &Block100000.Header.MerkleRoot diff --git a/reorganization_test.go b/reorganization_test.go index 70fcf054..87afbe44 100644 --- a/reorganization_test.go +++ b/reorganization_test.go @@ -122,7 +122,7 @@ func loadBlocks(filename string) (blocks []*btcutil.Block, err error) { // read block dr.Read(rbytes) - block, err = btcutil.NewBlockFromBytes(rbytes, btcwire.ProtocolVersion) + block, err = btcutil.NewBlockFromBytes(rbytes) if err != nil { return } diff --git a/scriptval.go b/scriptval.go index 11852cdd..139fc630 100644 --- a/scriptval.go +++ b/scriptval.go @@ -29,7 +29,7 @@ type txProcessList struct { // validateTxIn validates a the script pair for the passed spending transaction // (along with the specific input index) and origin transaction (with the // specific output index). -func validateTxIn(txInIdx int, txin *btcwire.TxIn, txSha *btcwire.ShaHash, tx *btcwire.MsgTx, pver uint32, timestamp time.Time, originTx *btcwire.MsgTx) error { +func validateTxIn(txInIdx int, txin *btcwire.TxIn, txSha *btcwire.ShaHash, tx *btcwire.MsgTx, timestamp time.Time, originTx *btcwire.MsgTx) error { // If the input transaction has no previous input, there is nothing // to check. originTxIdx := txin.PreviousOutpoint.Index @@ -46,7 +46,7 @@ func validateTxIn(txInIdx int, txin *btcwire.TxIn, txSha *btcwire.ShaHash, tx *b sigScript := txin.SignatureScript pkScript := originTx.TxOut[originTxIdx].PkScript engine, err := btcscript.NewScript(sigScript, pkScript, txInIdx, tx, - pver, timestamp.After(btcscript.Bip16Activation)) + timestamp.After(btcscript.Bip16Activation)) if err != nil { return err } @@ -62,7 +62,7 @@ func validateTxIn(txInIdx int, txin *btcwire.TxIn, txSha *btcwire.ShaHash, tx *b // validateAllTxIn validates the scripts for all of the passed transaction // inputs using multiple goroutines. -func validateAllTxIn(txsha *btcwire.ShaHash, txValidator *btcwire.MsgTx, pver uint32, timestamp time.Time, job []*btcwire.TxIn, txStore map[btcwire.ShaHash]*txData) (err error) { +func validateAllTxIn(txsha *btcwire.ShaHash, txValidator *btcwire.MsgTx, timestamp time.Time, job []*btcwire.TxIn, txStore map[btcwire.ShaHash]*txData) (err error) { c := make(chan txValidate) resultErrors := make([]error, len(job)) @@ -87,7 +87,7 @@ func validateAllTxIn(txsha *btcwire.ShaHash, txValidator *btcwire.MsgTx, pver ui originTx = txInfo.tx } err := validateTxIn(txInIdx, job[txInIdx], txsha, txValidator, - pver, timestamp, originTx) + timestamp, originTx) r := txValidate{txInIdx, err} c <- r } @@ -122,11 +122,10 @@ func validateAllTxIn(txsha *btcwire.ShaHash, txValidator *btcwire.MsgTx, pver ui // checkBlockScripts executes and validates the scripts for all transactions in // the passed block. func checkBlockScripts(block *btcutil.Block, txStore map[btcwire.ShaHash]*txData) error { - pver := block.ProtocolVersion() timestamp := block.MsgBlock().Header.Timestamp for i, tx := range block.MsgBlock().Transactions { txHash, _ := block.TxSha(i) - err := validateAllTxIn(txHash, tx, pver, timestamp, tx.TxIn, txStore) + err := validateAllTxIn(txHash, tx, timestamp, tx.TxIn, txStore) if err != nil { return err } diff --git a/txlookup.go b/txlookup.go index db53ead3..2cfb7ba6 100644 --- a/txlookup.go +++ b/txlookup.go @@ -22,7 +22,7 @@ type txData struct { } // connectTransactions updates the passed map by applying transaction and -// spend information for all the transactions in the passed block. Only +// spend information for all the transactions in the passed block. Only // transactions in the passed map are updated. func connectTransactions(txStore map[btcwire.ShaHash]*txData, block *btcutil.Block) error { // Loop through all of the transactions in the block to see if any of @@ -243,7 +243,7 @@ func (b *BlockChain) fetchInputTransactions(node *blockNode, block *btcutil.Bloc } } - // Request the input transaction from the point of view of the node. + // Request the input transactions from the point of view of the node. txNeededStore, err := b.fetchTxList(node, txNeededList) if err != nil { return nil, err diff --git a/validate.go b/validate.go index c30e3ab6..5b7852f0 100644 --- a/validate.go +++ b/validate.go @@ -334,7 +334,7 @@ func countP2SHSigOps(msgTx *btcwire.MsgTx, isCoinBaseTx bool, txStore map[btcwir } // TODO(davec): Need to pass the cached version in. - txHash, err := msgTx.TxSha(btcwire.ProtocolVersion) + txHash, err := msgTx.TxSha() if err != nil { return 0, err } @@ -593,7 +593,7 @@ func checkTransactionInputs(tx *btcwire.MsgTx, txHeight int64, txStore map[btcwi } // TODO(davec): Need to pass the cached version in. - txHash, err := tx.TxSha(btcwire.ProtocolVersion) + txHash, err := tx.TxSha() if err != nil { return 0, err } diff --git a/validate_test.go b/validate_test.go index 1d84b8d3..3718049a 100644 --- a/validate_test.go +++ b/validate_test.go @@ -29,7 +29,7 @@ func TestCheckBlockSanity(t *testing.T) { // the main bitcoin network and ignore notifications. chain := btcchain.New(db, btcwire.MainNet, nil) - block := btcutil.NewBlock(&Block100000, btcwire.ProtocolVersion) + block := btcutil.NewBlock(&Block100000) err = chain.TstCheckBlockSanity(block) if err != nil { t.Errorf("CheckBlockSanity: %v", err)