From 02b83422420c94995919a091fd67a632a0c75e08 Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Tue, 19 Dec 2023 14:12:42 +0100 Subject: [PATCH 01/10] chainhash: move to top-level module, use v2 --- chaincfg/chainhash/go.mod | 3 --- {chaincfg/chainhash => chainhash}/README.md | 4 ++-- {chaincfg/chainhash => chainhash}/doc.go | 0 chainhash/go.mod | 3 +++ {chaincfg/chainhash => chainhash}/hash.go | 0 {chaincfg/chainhash => chainhash}/hash_test.go | 0 {chaincfg/chainhash => chainhash}/hashfuncs.go | 0 {chaincfg/chainhash => chainhash}/hashfuncs_test.go | 0 8 files changed, 5 insertions(+), 5 deletions(-) delete mode 100644 chaincfg/chainhash/go.mod rename {chaincfg/chainhash => chainhash}/README.md (90%) rename {chaincfg/chainhash => chainhash}/doc.go (100%) create mode 100644 chainhash/go.mod rename {chaincfg/chainhash => chainhash}/hash.go (100%) rename {chaincfg/chainhash => chainhash}/hash_test.go (100%) rename {chaincfg/chainhash => chainhash}/hashfuncs.go (100%) rename {chaincfg/chainhash => chainhash}/hashfuncs_test.go (100%) diff --git a/chaincfg/chainhash/go.mod b/chaincfg/chainhash/go.mod deleted file mode 100644 index 1d865254dd..0000000000 --- a/chaincfg/chainhash/go.mod +++ /dev/null @@ -1,3 +0,0 @@ -module github.com/btcsuite/btcd/chaincfg/chainhash - -go 1.17 diff --git a/chaincfg/chainhash/README.md b/chainhash/README.md similarity index 90% rename from chaincfg/chainhash/README.md rename to chainhash/README.md index b7ddf19ef7..fcffef7a1f 100644 --- a/chaincfg/chainhash/README.md +++ b/chainhash/README.md @@ -3,7 +3,7 @@ chainhash [![Build Status](https://github.com/btcsuite/btcd/workflows/Build%20and%20Test/badge.svg)](https://github.com/btcsuite/btcd/actions) [![ISC License](http://img.shields.io/badge/license-ISC-blue.svg)](http://copyfree.org) -[![GoDoc](https://img.shields.io/badge/godoc-reference-blue.svg)](https://pkg.go.dev/github.com/btcsuite/btcd/chaincfg/chainhash) +[![GoDoc](https://img.shields.io/badge/godoc-reference-blue.svg)](https://pkg.go.dev/github.com/btcsuite/btcd/chainhash/v2) ======= chainhash provides a generic hash type and associated functions that allows the @@ -12,7 +12,7 @@ specific hash algorithm to be abstracted. ## Installation and Updating ```bash -$ go get -u github.com/btcsuite/btcd/chaincfg/chainhash +$ go get -u github.com/btcsuite/btcd/chainhash/v2 ``` ## GPG Verification Key diff --git a/chaincfg/chainhash/doc.go b/chainhash/doc.go similarity index 100% rename from chaincfg/chainhash/doc.go rename to chainhash/doc.go diff --git a/chainhash/go.mod b/chainhash/go.mod new file mode 100644 index 0000000000..09980c5dac --- /dev/null +++ b/chainhash/go.mod @@ -0,0 +1,3 @@ +module github.com/btcsuite/btcd/chainhash/v2 + +go 1.19 diff --git a/chaincfg/chainhash/hash.go b/chainhash/hash.go similarity index 100% rename from chaincfg/chainhash/hash.go rename to chainhash/hash.go diff --git a/chaincfg/chainhash/hash_test.go b/chainhash/hash_test.go similarity index 100% rename from chaincfg/chainhash/hash_test.go rename to chainhash/hash_test.go diff --git a/chaincfg/chainhash/hashfuncs.go b/chainhash/hashfuncs.go similarity index 100% rename from chaincfg/chainhash/hashfuncs.go rename to chainhash/hashfuncs.go diff --git a/chaincfg/chainhash/hashfuncs_test.go b/chainhash/hashfuncs_test.go similarity index 100% rename from chaincfg/chainhash/hashfuncs_test.go rename to chainhash/hashfuncs_test.go From d8bd7c2ce4ef3fdc36764c76f1d6dc1e622700d5 Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Tue, 19 Dec 2023 14:12:43 +0100 Subject: [PATCH 02/10] btcec: use new chainhash/v2 module --- btcec/ecdsa/example_test.go | 2 +- btcec/go.mod | 9 ++++++--- btcec/go.sum | 2 -- btcec/schnorr/musig2/keys.go | 2 +- btcec/schnorr/musig2/nonces.go | 2 +- btcec/schnorr/musig2/sign.go | 2 +- btcec/schnorr/signature.go | 2 +- 7 files changed, 11 insertions(+), 10 deletions(-) diff --git a/btcec/ecdsa/example_test.go b/btcec/ecdsa/example_test.go index 409a95bd23..534150465a 100644 --- a/btcec/ecdsa/example_test.go +++ b/btcec/ecdsa/example_test.go @@ -10,7 +10,7 @@ import ( "github.com/btcsuite/btcd/btcec/v2" "github.com/btcsuite/btcd/btcec/v2/ecdsa" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/chainhash/v2" ) // This example demonstrates signing a message with a secp256k1 private key that diff --git a/btcec/go.mod b/btcec/go.mod index 452399cfc6..ef1007115a 100644 --- a/btcec/go.mod +++ b/btcec/go.mod @@ -1,9 +1,7 @@ module github.com/btcsuite/btcd/btcec/v2 -go 1.17 - require ( - github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 + github.com/btcsuite/btcd/chainhash/v2 v2.0.0 github.com/davecgh/go-spew v1.1.1 github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 github.com/stretchr/testify v1.8.0 @@ -14,3 +12,8 @@ require ( github.com/pmezard/go-difflib v1.0.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) + +// TODO(guggero): Remove once we have a tagged version of the chainhash package. +replace github.com/btcsuite/btcd/chainhash/v2 => ../chainhash + +go 1.19 diff --git a/btcec/go.sum b/btcec/go.sum index 73b8f2b5ac..b0e02ed8b7 100644 --- a/btcec/go.sum +++ b/btcec/go.sum @@ -1,5 +1,3 @@ -github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOFYSNEs0TFnxxnS9+4U= -github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= diff --git a/btcec/schnorr/musig2/keys.go b/btcec/schnorr/musig2/keys.go index 4ee63be2eb..364aee54cc 100644 --- a/btcec/schnorr/musig2/keys.go +++ b/btcec/schnorr/musig2/keys.go @@ -11,7 +11,7 @@ import ( "github.com/btcsuite/btcd/btcec/v2" "github.com/btcsuite/btcd/btcec/v2/schnorr" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/chainhash/v2" ) var ( diff --git a/btcec/schnorr/musig2/nonces.go b/btcec/schnorr/musig2/nonces.go index 988b199471..125d8b3059 100644 --- a/btcec/schnorr/musig2/nonces.go +++ b/btcec/schnorr/musig2/nonces.go @@ -11,7 +11,7 @@ import ( "github.com/btcsuite/btcd/btcec/v2" "github.com/btcsuite/btcd/btcec/v2/schnorr" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/chainhash/v2" ) const ( diff --git a/btcec/schnorr/musig2/sign.go b/btcec/schnorr/musig2/sign.go index 9204611dd6..67d194db28 100644 --- a/btcec/schnorr/musig2/sign.go +++ b/btcec/schnorr/musig2/sign.go @@ -11,7 +11,7 @@ import ( "github.com/btcsuite/btcd/btcec/v2" "github.com/btcsuite/btcd/btcec/v2/schnorr" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/chainhash/v2" ) var ( diff --git a/btcec/schnorr/signature.go b/btcec/schnorr/signature.go index 8876a6070d..945fea747a 100644 --- a/btcec/schnorr/signature.go +++ b/btcec/schnorr/signature.go @@ -6,7 +6,7 @@ import ( "fmt" "github.com/btcsuite/btcd/btcec/v2" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/chainhash/v2" secp "github.com/decred/dcrd/dcrec/secp256k1/v4" ecdsa_schnorr "github.com/decred/dcrd/dcrec/secp256k1/v4/schnorr" ) From 559c093d6ed4717ccaf56f23f413e18179c2a398 Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Tue, 19 Dec 2023 14:12:44 +0100 Subject: [PATCH 03/10] wire: make own module, use v2 --- wire/README.md | 4 ++-- wire/bench_test.go | 2 +- wire/blockheader.go | 2 +- wire/common.go | 2 +- wire/common_test.go | 2 +- wire/go.mod | 19 +++++++++++++++++++ wire/go.sum | 14 ++++++++++++++ wire/invvect.go | 2 +- wire/invvect_test.go | 2 +- wire/message.go | 2 +- wire/message_test.go | 2 +- wire/msgblock.go | 2 +- wire/msgblock_test.go | 2 +- wire/msgcfcheckpt.go | 2 +- wire/msgcfheaders.go | 2 +- wire/msgcfilter.go | 2 +- wire/msggetblocks.go | 2 +- wire/msggetblocks_test.go | 2 +- wire/msggetcfcheckpt.go | 2 +- wire/msggetcfheaders.go | 2 +- wire/msggetcfilters.go | 2 +- wire/msggetdata_test.go | 2 +- wire/msggetheaders.go | 2 +- wire/msggetheaders_test.go | 2 +- wire/msginv_test.go | 2 +- wire/msgmerkleblock.go | 2 +- wire/msgmerkleblock_test.go | 2 +- wire/msgnotfound_test.go | 2 +- wire/msgreject.go | 2 +- wire/msgtx.go | 2 +- wire/msgtx_test.go | 2 +- 31 files changed, 63 insertions(+), 30 deletions(-) create mode 100644 wire/go.mod create mode 100644 wire/go.sum diff --git a/wire/README.md b/wire/README.md index 8660bbfd54..33ded2d383 100644 --- a/wire/README.md +++ b/wire/README.md @@ -3,7 +3,7 @@ wire [![Build Status](https://github.com/btcsuite/btcd/workflows/Build%20and%20Test/badge.svg)](https://github.com/btcsuite/btcd/actions) [![ISC License](http://img.shields.io/badge/license-ISC-blue.svg)](http://copyfree.org) -[![GoDoc](https://img.shields.io/badge/godoc-reference-blue.svg)](https://pkg.go.dev/github.com/btcsuite/btcd/wire) +[![GoDoc](https://img.shields.io/badge/godoc-reference-blue.svg)](https://pkg.go.dev/github.com/btcsuite/btcd/wire/v2) ======= Package wire implements the bitcoin wire protocol. A comprehensive suite of @@ -19,7 +19,7 @@ protocol level. ## Installation and Updating ```bash -$ go get -u github.com/btcsuite/btcd/wire +$ go get -u github.com/btcsuite/btcd/wire/v2 ``` ## Bitcoin Message Overview diff --git a/wire/bench_test.go b/wire/bench_test.go index 5176c962e8..d8c28a5a15 100644 --- a/wire/bench_test.go +++ b/wire/bench_test.go @@ -13,7 +13,7 @@ import ( "os" "testing" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/chainhash/v2" ) // genesisCoinbaseTx is the coinbase transaction for the genesis blocks for diff --git a/wire/blockheader.go b/wire/blockheader.go index 9c9c2237e6..86a0aa6aef 100644 --- a/wire/blockheader.go +++ b/wire/blockheader.go @@ -9,7 +9,7 @@ import ( "io" "time" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/chainhash/v2" ) // MaxBlockHeaderPayload is the maximum number of bytes a block header can be. diff --git a/wire/common.go b/wire/common.go index 42c1797b32..4516b72ae8 100644 --- a/wire/common.go +++ b/wire/common.go @@ -12,7 +12,7 @@ import ( "math" "time" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/chainhash/v2" ) const ( diff --git a/wire/common_test.go b/wire/common_test.go index 46e3fa6613..b9b120e9e4 100644 --- a/wire/common_test.go +++ b/wire/common_test.go @@ -12,7 +12,7 @@ import ( "strings" "testing" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/chainhash/v2" "github.com/davecgh/go-spew/spew" ) diff --git a/wire/go.mod b/wire/go.mod new file mode 100644 index 0000000000..28d4a99042 --- /dev/null +++ b/wire/go.mod @@ -0,0 +1,19 @@ +module github.com/btcsuite/btcd/wire/v2 + +require ( + github.com/btcsuite/btcd/chainhash/v2 v2.0.0 + github.com/davecgh/go-spew v1.1.1 + github.com/stretchr/testify v1.8.4 + golang.org/x/crypto v0.17.0 +) + +require ( + github.com/pmezard/go-difflib v1.0.0 // indirect + golang.org/x/sys v0.15.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect +) + +// TODO(guggero): Remove once we have a tagged version of the chainhash package. +replace github.com/btcsuite/btcd/chainhash/v2 => ../chainhash + +go 1.19 diff --git a/wire/go.sum b/wire/go.sum new file mode 100644 index 0000000000..c629a6127c --- /dev/null +++ b/wire/go.sum @@ -0,0 +1,14 @@ +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= +golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= +golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= +golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/wire/invvect.go b/wire/invvect.go index 1e706642b4..5d72fef54c 100644 --- a/wire/invvect.go +++ b/wire/invvect.go @@ -8,7 +8,7 @@ import ( "fmt" "io" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/chainhash/v2" ) const ( diff --git a/wire/invvect_test.go b/wire/invvect_test.go index 1d02c09817..3f791ce08e 100644 --- a/wire/invvect_test.go +++ b/wire/invvect_test.go @@ -9,7 +9,7 @@ import ( "reflect" "testing" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/chainhash/v2" "github.com/davecgh/go-spew/spew" ) diff --git a/wire/message.go b/wire/message.go index 1f412fa6fa..f0d17826b1 100644 --- a/wire/message.go +++ b/wire/message.go @@ -10,7 +10,7 @@ import ( "io" "unicode/utf8" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/chainhash/v2" ) // MessageHeaderSize is the number of bytes in a bitcoin message header. diff --git a/wire/message_test.go b/wire/message_test.go index 7ba2e0639f..ab7b3dc845 100644 --- a/wire/message_test.go +++ b/wire/message_test.go @@ -13,7 +13,7 @@ import ( "testing" "time" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/chainhash/v2" "github.com/davecgh/go-spew/spew" ) diff --git a/wire/msgblock.go b/wire/msgblock.go index 4172949dc3..57c7828c1b 100644 --- a/wire/msgblock.go +++ b/wire/msgblock.go @@ -9,7 +9,7 @@ import ( "fmt" "io" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/chainhash/v2" ) // defaultTransactionAlloc is the default size used for the backing array diff --git a/wire/msgblock_test.go b/wire/msgblock_test.go index 2a861b208b..d62dc70c52 100644 --- a/wire/msgblock_test.go +++ b/wire/msgblock_test.go @@ -11,7 +11,7 @@ import ( "testing" "time" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/chainhash/v2" "github.com/davecgh/go-spew/spew" ) diff --git a/wire/msgcfcheckpt.go b/wire/msgcfcheckpt.go index fc3fd53295..c1ae665d07 100644 --- a/wire/msgcfcheckpt.go +++ b/wire/msgcfcheckpt.go @@ -9,7 +9,7 @@ import ( "fmt" "io" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/chainhash/v2" ) const ( diff --git a/wire/msgcfheaders.go b/wire/msgcfheaders.go index 40d30f9b46..5134a882e3 100644 --- a/wire/msgcfheaders.go +++ b/wire/msgcfheaders.go @@ -8,7 +8,7 @@ import ( "fmt" "io" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/chainhash/v2" ) const ( diff --git a/wire/msgcfilter.go b/wire/msgcfilter.go index 097590b2ce..35912a290a 100644 --- a/wire/msgcfilter.go +++ b/wire/msgcfilter.go @@ -8,7 +8,7 @@ import ( "fmt" "io" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/chainhash/v2" ) // FilterType is used to represent a filter type. diff --git a/wire/msggetblocks.go b/wire/msggetblocks.go index caf4400ca4..71a71876f5 100644 --- a/wire/msggetblocks.go +++ b/wire/msggetblocks.go @@ -8,7 +8,7 @@ import ( "fmt" "io" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/chainhash/v2" ) // MaxBlockLocatorsPerMsg is the maximum number of block locator hashes allowed diff --git a/wire/msggetblocks_test.go b/wire/msggetblocks_test.go index 376f7338b4..acedb8a854 100644 --- a/wire/msggetblocks_test.go +++ b/wire/msggetblocks_test.go @@ -10,7 +10,7 @@ import ( "reflect" "testing" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/chainhash/v2" "github.com/davecgh/go-spew/spew" ) diff --git a/wire/msggetcfcheckpt.go b/wire/msggetcfcheckpt.go index c30a86cecd..4df4c42085 100644 --- a/wire/msggetcfcheckpt.go +++ b/wire/msggetcfcheckpt.go @@ -7,7 +7,7 @@ package wire import ( "io" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/chainhash/v2" ) // MsgGetCFCheckpt is a request for filter headers at evenly spaced intervals diff --git a/wire/msggetcfheaders.go b/wire/msggetcfheaders.go index 03a1caf72f..0d8c50c8d4 100644 --- a/wire/msggetcfheaders.go +++ b/wire/msggetcfheaders.go @@ -7,7 +7,7 @@ package wire import ( "io" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/chainhash/v2" ) // MsgGetCFHeaders is a message similar to MsgGetHeaders, but for committed diff --git a/wire/msggetcfilters.go b/wire/msggetcfilters.go index 8002413826..34416af1b5 100644 --- a/wire/msggetcfilters.go +++ b/wire/msggetcfilters.go @@ -7,7 +7,7 @@ package wire import ( "io" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/chainhash/v2" ) // MaxGetCFiltersReqRange the maximum number of filters that may be requested in diff --git a/wire/msggetdata_test.go b/wire/msggetdata_test.go index a2dd465184..308c6b9697 100644 --- a/wire/msggetdata_test.go +++ b/wire/msggetdata_test.go @@ -10,7 +10,7 @@ import ( "reflect" "testing" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/chainhash/v2" "github.com/davecgh/go-spew/spew" ) diff --git a/wire/msggetheaders.go b/wire/msggetheaders.go index 0bbe42cb03..93efafcde9 100644 --- a/wire/msggetheaders.go +++ b/wire/msggetheaders.go @@ -8,7 +8,7 @@ import ( "fmt" "io" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/chainhash/v2" ) // MsgGetHeaders implements the Message interface and represents a bitcoin diff --git a/wire/msggetheaders_test.go b/wire/msggetheaders_test.go index 34a24ae3c4..28a75f1bec 100644 --- a/wire/msggetheaders_test.go +++ b/wire/msggetheaders_test.go @@ -10,7 +10,7 @@ import ( "reflect" "testing" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/chainhash/v2" "github.com/davecgh/go-spew/spew" ) diff --git a/wire/msginv_test.go b/wire/msginv_test.go index b7c7c6aec3..8700eba21e 100644 --- a/wire/msginv_test.go +++ b/wire/msginv_test.go @@ -10,7 +10,7 @@ import ( "reflect" "testing" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/chainhash/v2" "github.com/davecgh/go-spew/spew" ) diff --git a/wire/msgmerkleblock.go b/wire/msgmerkleblock.go index d2ee472178..c65e07e15c 100644 --- a/wire/msgmerkleblock.go +++ b/wire/msgmerkleblock.go @@ -8,7 +8,7 @@ import ( "fmt" "io" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/chainhash/v2" ) // maxFlagsPerMerkleBlock is the maximum number of flag bytes that could diff --git a/wire/msgmerkleblock_test.go b/wire/msgmerkleblock_test.go index 9837f8a973..829ff31461 100644 --- a/wire/msgmerkleblock_test.go +++ b/wire/msgmerkleblock_test.go @@ -12,7 +12,7 @@ import ( "testing" "time" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/chainhash/v2" "github.com/davecgh/go-spew/spew" ) diff --git a/wire/msgnotfound_test.go b/wire/msgnotfound_test.go index 69b9d07aea..3d724e81f0 100644 --- a/wire/msgnotfound_test.go +++ b/wire/msgnotfound_test.go @@ -10,7 +10,7 @@ import ( "reflect" "testing" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/chainhash/v2" "github.com/davecgh/go-spew/spew" ) diff --git a/wire/msgreject.go b/wire/msgreject.go index a00eeff6f6..f5a4b1eecc 100644 --- a/wire/msgreject.go +++ b/wire/msgreject.go @@ -8,7 +8,7 @@ import ( "fmt" "io" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/chainhash/v2" ) // RejectCode represents a numeric value by which a remote peer indicates diff --git a/wire/msgtx.go b/wire/msgtx.go index 7705504cc8..ec5f10628d 100644 --- a/wire/msgtx.go +++ b/wire/msgtx.go @@ -12,7 +12,7 @@ import ( "strconv" "strings" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/chainhash/v2" ) const ( diff --git a/wire/msgtx_test.go b/wire/msgtx_test.go index 5ec753b62d..cacd4baec9 100644 --- a/wire/msgtx_test.go +++ b/wire/msgtx_test.go @@ -11,7 +11,7 @@ import ( "reflect" "testing" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/chainhash/v2" "github.com/davecgh/go-spew/spew" "github.com/stretchr/testify/require" ) From f0baebe64bba8d9160e650e4204d9127d6353faf Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Tue, 19 Dec 2023 14:12:45 +0100 Subject: [PATCH 04/10] chaincfg: add own module, use v2 --- chaincfg/README.md | 6 +++--- chaincfg/deployment_time_frame.go | 2 +- chaincfg/doc.go | 2 +- chaincfg/genesis.go | 4 ++-- chaincfg/go.mod | 20 ++++++++++++++++++++ chaincfg/go.sum | 9 +++++++++ chaincfg/params.go | 4 ++-- chaincfg/register_test.go | 2 +- 8 files changed, 39 insertions(+), 10 deletions(-) create mode 100644 chaincfg/go.mod create mode 100644 chaincfg/go.sum diff --git a/chaincfg/README.md b/chaincfg/README.md index d1a534bafe..41b9a7156b 100644 --- a/chaincfg/README.md +++ b/chaincfg/README.md @@ -3,7 +3,7 @@ chaincfg [![Build Status](https://github.com/btcsuite/btcd/workflows/Build%20and%20Test/badge.svg)](https://github.com/btcsuite/btcd/actions) [![ISC License](http://img.shields.io/badge/license-ISC-blue.svg)](http://copyfree.org) -[![GoDoc](https://img.shields.io/badge/godoc-reference-blue.svg)](https://pkg.go.dev/github.com/btcsuite/btcd/chaincfg) +[![GoDoc](https://img.shields.io/badge/godoc-reference-blue.svg)](https://pkg.go.dev/github.com/btcsuite/btcd/chaincfg/v2) Package chaincfg defines chain configuration parameters for the three standard Bitcoin networks and provides the ability for callers to define their own custom @@ -25,7 +25,7 @@ import ( "log" "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/chaincfg" + "github.com/btcsuite/btcd/chaincfg/v2" ) var testnet = flag.Bool("testnet", false, "operate on the testnet Bitcoin network") @@ -56,7 +56,7 @@ func main() { ## Installation and Updating ```bash -$ go get -u github.com/btcsuite/btcd/chaincfg +$ go get -u github.com/btcsuite/btcd/chaincfg/v2 ``` ## GPG Verification Key diff --git a/chaincfg/deployment_time_frame.go b/chaincfg/deployment_time_frame.go index f26d429090..c334797643 100644 --- a/chaincfg/deployment_time_frame.go +++ b/chaincfg/deployment_time_frame.go @@ -4,7 +4,7 @@ import ( "fmt" "time" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/wire/v2" ) var ( diff --git a/chaincfg/doc.go b/chaincfg/doc.go index 65efb54f66..93193dcc95 100644 --- a/chaincfg/doc.go +++ b/chaincfg/doc.go @@ -26,7 +26,7 @@ // "log" // // "github.com/btcsuite/btcd/btcutil" -// "github.com/btcsuite/btcd/chaincfg" +// "github.com/btcsuite/btcd/chaincfg/v2" // ) // // var testnet = flag.Bool("testnet", false, "operate on the testnet Bitcoin network") diff --git a/chaincfg/genesis.go b/chaincfg/genesis.go index 73d286102b..172f68838b 100644 --- a/chaincfg/genesis.go +++ b/chaincfg/genesis.go @@ -7,8 +7,8 @@ package chaincfg import ( "time" - "github.com/btcsuite/btcd/chaincfg/chainhash" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/chainhash/v2" + "github.com/btcsuite/btcd/wire/v2" ) // genesisCoinbaseTx is the coinbase transaction for the genesis blocks for diff --git a/chaincfg/go.mod b/chaincfg/go.mod new file mode 100644 index 0000000000..0f5941a7dd --- /dev/null +++ b/chaincfg/go.mod @@ -0,0 +1,20 @@ +module github.com/btcsuite/btcd/chaincfg/v2 + +require ( + github.com/btcsuite/btcd/chainhash/v2 v2.0.0 + github.com/btcsuite/btcd/wire/v2 v2.0.0 + github.com/davecgh/go-spew v1.1.1 +) + +require ( + golang.org/x/crypto v0.17.0 // indirect + golang.org/x/sys v0.15.0 // indirect +) + +// TODO(guggero): Remove once we have a tagged version of the chainhash package. +replace github.com/btcsuite/btcd/chainhash/v2 => ../chainhash + +// TODO(guggero): Remove once we have a tagged version of the wire package. +replace github.com/btcsuite/btcd/wire/v2 => ../wire + +go 1.19 diff --git a/chaincfg/go.sum b/chaincfg/go.sum new file mode 100644 index 0000000000..5712b5ccc8 --- /dev/null +++ b/chaincfg/go.sum @@ -0,0 +1,9 @@ +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= +golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= +golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= +golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/chaincfg/params.go b/chaincfg/params.go index 3b38878b4a..b7fd7d0c6e 100644 --- a/chaincfg/params.go +++ b/chaincfg/params.go @@ -12,8 +12,8 @@ import ( "strings" "time" - "github.com/btcsuite/btcd/chaincfg/chainhash" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/chainhash/v2" + "github.com/btcsuite/btcd/wire/v2" ) // These variables are the chain proof-of-work limit parameters for each default diff --git a/chaincfg/register_test.go b/chaincfg/register_test.go index bcb5b3c6f6..884854b952 100644 --- a/chaincfg/register_test.go +++ b/chaincfg/register_test.go @@ -6,7 +6,7 @@ import ( "strings" "testing" - . "github.com/btcsuite/btcd/chaincfg" + . "github.com/btcsuite/btcd/chaincfg/v2" ) // Define some of the required parameters for a user-registered From a5345ac36670a0215acc213e2097da2c4efd4a6a Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Tue, 19 Dec 2023 14:12:46 +0100 Subject: [PATCH 05/10] address: move to top-level module, use v2 --- {btcutil => address}/address.go | 8 +- {btcutil => address}/address_test.go | 194 +++++++++--------- {btcutil => address}/base58/README.md | 14 +- {btcutil => address}/base58/alphabet.go | 0 {btcutil => address}/base58/base58.go | 0 {btcutil => address}/base58/base58_test.go | 2 +- .../base58/base58bench_test.go | 2 +- {btcutil => address}/base58/base58check.go | 0 .../base58/base58check_test.go | 2 +- {btcutil => address}/base58/cov_report.sh | 0 {btcutil => address}/base58/doc.go | 0 {btcutil => address}/base58/example_test.go | 2 +- {btcutil => address}/base58/genalphabet.go | 0 {btcutil => address}/bech32/README.md | 10 +- {btcutil => address}/bech32/bech32.go | 0 {btcutil => address}/bech32/bech32_test.go | 0 {btcutil => address}/bech32/doc.go | 0 {btcutil => address}/bech32/error.go | 0 {btcutil => address}/bech32/example_test.go | 2 +- {btcutil => address}/bech32/version.go | 0 address/go.mod | 28 +++ address/go.sum | 61 ++++++ {btcutil => address}/hash160.go | 2 +- address/internal_test.go | 134 ++++++++++++ btcutil/internal_test.go | 122 ----------- 25 files changed, 342 insertions(+), 241 deletions(-) rename {btcutil => address}/address.go (99%) rename {btcutil => address}/address_test.go (85%) rename {btcutil => address}/base58/README.md (65%) rename {btcutil => address}/base58/alphabet.go (100%) rename {btcutil => address}/base58/base58.go (100%) rename {btcutil => address}/base58/base58_test.go (98%) rename {btcutil => address}/base58/base58bench_test.go (95%) rename {btcutil => address}/base58/base58check.go (100%) rename {btcutil => address}/base58/base58check_test.go (97%) rename {btcutil => address}/base58/cov_report.sh (100%) rename {btcutil => address}/base58/doc.go (100%) rename {btcutil => address}/base58/example_test.go (97%) rename {btcutil => address}/base58/genalphabet.go (100%) rename {btcutil => address}/bech32/README.md (63%) rename {btcutil => address}/bech32/bech32.go (100%) rename {btcutil => address}/bech32/bech32_test.go (100%) rename {btcutil => address}/bech32/doc.go (100%) rename {btcutil => address}/bech32/error.go (100%) rename {btcutil => address}/bech32/example_test.go (96%) rename {btcutil => address}/bech32/version.go (100%) create mode 100644 address/go.mod create mode 100644 address/go.sum rename {btcutil => address}/hash160.go (97%) create mode 100644 address/internal_test.go diff --git a/btcutil/address.go b/address/address.go similarity index 99% rename from btcutil/address.go rename to address/address.go index d0367abfc8..ffda98c0ce 100644 --- a/btcutil/address.go +++ b/address/address.go @@ -2,7 +2,7 @@ // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. -package btcutil +package address import ( "bytes" @@ -11,10 +11,10 @@ import ( "fmt" "strings" + "github.com/btcsuite/btcd/address/v2/base58" + "github.com/btcsuite/btcd/address/v2/bech32" "github.com/btcsuite/btcd/btcec/v2" - "github.com/btcsuite/btcd/btcutil/base58" - "github.com/btcsuite/btcd/btcutil/bech32" - "github.com/btcsuite/btcd/chaincfg" + "github.com/btcsuite/btcd/chaincfg/v2" "golang.org/x/crypto/ripemd160" ) diff --git a/btcutil/address_test.go b/address/address_test.go similarity index 85% rename from btcutil/address_test.go rename to address/address_test.go index f5ae2ac0d5..c646cfbf4e 100644 --- a/btcutil/address_test.go +++ b/address/address_test.go @@ -2,7 +2,7 @@ // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. -package btcutil_test +package address_test import ( "bytes" @@ -12,9 +12,9 @@ import ( "strings" "testing" - "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/chaincfg" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/address/v2" + "github.com/btcsuite/btcd/chaincfg/v2" + "github.com/btcsuite/btcd/wire/v2" "golang.org/x/crypto/ripemd160" ) @@ -50,8 +50,8 @@ func TestAddresses(t *testing.T) { addr string encoded string valid bool - result btcutil.Address - f func() (btcutil.Address, error) + result address.Address + f func() (address.Address, error) net *chaincfg.Params }{ // Positive P2PKH tests. @@ -60,16 +60,16 @@ func TestAddresses(t *testing.T) { addr: "1MirQ9bwyQcGVJPwKUgapu5ouK2E2Ey4gX", encoded: "1MirQ9bwyQcGVJPwKUgapu5ouK2E2Ey4gX", valid: true, - result: btcutil.TstAddressPubKeyHash( + result: address.TstAddressPubKeyHash( [ripemd160.Size]byte{ 0xe3, 0x4c, 0xce, 0x70, 0xc8, 0x63, 0x73, 0x27, 0x3e, 0xfc, 0xc5, 0x4c, 0xe7, 0xd2, 0xa4, 0x91, 0xbb, 0x4a, 0x0e, 0x84}, chaincfg.MainNetParams.PubKeyHashAddrID), - f: func() (btcutil.Address, error) { + f: func() (address.Address, error) { pkHash := []byte{ 0xe3, 0x4c, 0xce, 0x70, 0xc8, 0x63, 0x73, 0x27, 0x3e, 0xfc, 0xc5, 0x4c, 0xe7, 0xd2, 0xa4, 0x91, 0xbb, 0x4a, 0x0e, 0x84} - return btcutil.NewAddressPubKeyHash(pkHash, &chaincfg.MainNetParams) + return address.NewAddressPubKeyHash(pkHash, &chaincfg.MainNetParams) }, net: &chaincfg.MainNetParams, }, @@ -78,16 +78,16 @@ func TestAddresses(t *testing.T) { addr: "12MzCDwodF9G1e7jfwLXfR164RNtx4BRVG", encoded: "12MzCDwodF9G1e7jfwLXfR164RNtx4BRVG", valid: true, - result: btcutil.TstAddressPubKeyHash( + result: address.TstAddressPubKeyHash( [ripemd160.Size]byte{ 0x0e, 0xf0, 0x30, 0x10, 0x7f, 0xd2, 0x6e, 0x0b, 0x6b, 0xf4, 0x05, 0x12, 0xbc, 0xa2, 0xce, 0xb1, 0xdd, 0x80, 0xad, 0xaa}, chaincfg.MainNetParams.PubKeyHashAddrID), - f: func() (btcutil.Address, error) { + f: func() (address.Address, error) { pkHash := []byte{ 0x0e, 0xf0, 0x30, 0x10, 0x7f, 0xd2, 0x6e, 0x0b, 0x6b, 0xf4, 0x05, 0x12, 0xbc, 0xa2, 0xce, 0xb1, 0xdd, 0x80, 0xad, 0xaa} - return btcutil.NewAddressPubKeyHash(pkHash, &chaincfg.MainNetParams) + return address.NewAddressPubKeyHash(pkHash, &chaincfg.MainNetParams) }, net: &chaincfg.MainNetParams, }, @@ -96,16 +96,16 @@ func TestAddresses(t *testing.T) { addr: "LM2WMpR1Rp6j3Sa59cMXMs1SPzj9eXpGc1", encoded: "LM2WMpR1Rp6j3Sa59cMXMs1SPzj9eXpGc1", valid: true, - result: btcutil.TstAddressPubKeyHash( + result: address.TstAddressPubKeyHash( [ripemd160.Size]byte{ 0x13, 0xc6, 0x0d, 0x8e, 0x68, 0xd7, 0x34, 0x9f, 0x5b, 0x4c, 0xa3, 0x62, 0xc3, 0x95, 0x4b, 0x15, 0x04, 0x50, 0x61, 0xb1}, CustomParams.PubKeyHashAddrID), - f: func() (btcutil.Address, error) { + f: func() (address.Address, error) { pkHash := []byte{ 0x13, 0xc6, 0x0d, 0x8e, 0x68, 0xd7, 0x34, 0x9f, 0x5b, 0x4c, 0xa3, 0x62, 0xc3, 0x95, 0x4b, 0x15, 0x04, 0x50, 0x61, 0xb1} - return btcutil.NewAddressPubKeyHash(pkHash, &customParams) + return address.NewAddressPubKeyHash(pkHash, &customParams) }, net: &customParams, }, @@ -114,16 +114,16 @@ func TestAddresses(t *testing.T) { addr: "mrX9vMRYLfVy1BnZbc5gZjuyaqH3ZW2ZHz", encoded: "mrX9vMRYLfVy1BnZbc5gZjuyaqH3ZW2ZHz", valid: true, - result: btcutil.TstAddressPubKeyHash( + result: address.TstAddressPubKeyHash( [ripemd160.Size]byte{ 0x78, 0xb3, 0x16, 0xa0, 0x86, 0x47, 0xd5, 0xb7, 0x72, 0x83, 0xe5, 0x12, 0xd3, 0x60, 0x3f, 0x1f, 0x1c, 0x8d, 0xe6, 0x8f}, chaincfg.TestNet3Params.PubKeyHashAddrID), - f: func() (btcutil.Address, error) { + f: func() (address.Address, error) { pkHash := []byte{ 0x78, 0xb3, 0x16, 0xa0, 0x86, 0x47, 0xd5, 0xb7, 0x72, 0x83, 0xe5, 0x12, 0xd3, 0x60, 0x3f, 0x1f, 0x1c, 0x8d, 0xe6, 0x8f} - return btcutil.NewAddressPubKeyHash(pkHash, &chaincfg.TestNet3Params) + return address.NewAddressPubKeyHash(pkHash, &chaincfg.TestNet3Params) }, net: &chaincfg.TestNet3Params, }, @@ -133,12 +133,12 @@ func TestAddresses(t *testing.T) { name: "p2pkh wrong hash length", addr: "", valid: false, - f: func() (btcutil.Address, error) { + f: func() (address.Address, error) { pkHash := []byte{ 0x00, 0x0e, 0xf0, 0x30, 0x10, 0x7f, 0xd2, 0x6e, 0x0b, 0x6b, 0xf4, 0x05, 0x12, 0xbc, 0xa2, 0xce, 0xb1, 0xdd, 0x80, 0xad, 0xaa} - return btcutil.NewAddressPubKeyHash(pkHash, &chaincfg.MainNetParams) + return address.NewAddressPubKeyHash(pkHash, &chaincfg.MainNetParams) }, net: &chaincfg.MainNetParams, }, @@ -158,12 +158,12 @@ func TestAddresses(t *testing.T) { addr: "3QJmV3qfvL9SuYo34YihAf3sRCW3qSinyC", encoded: "3QJmV3qfvL9SuYo34YihAf3sRCW3qSinyC", valid: true, - result: btcutil.TstAddressScriptHash( + result: address.TstAddressScriptHash( [ripemd160.Size]byte{ 0xf8, 0x15, 0xb0, 0x36, 0xd9, 0xbb, 0xbc, 0xe5, 0xe9, 0xf2, 0xa0, 0x0a, 0xbd, 0x1b, 0xf3, 0xdc, 0x91, 0xe9, 0x55, 0x10}, chaincfg.MainNetParams.ScriptHashAddrID), - f: func() (btcutil.Address, error) { + f: func() (address.Address, error) { script := []byte{ 0x52, 0x41, 0x04, 0x91, 0xbb, 0xa2, 0x51, 0x09, 0x12, 0xa5, 0xbd, 0x37, 0xda, 0x1f, 0xb5, 0xb1, 0x67, 0x30, 0x10, 0xe4, @@ -186,7 +186,7 @@ func TestAddresses(t *testing.T) { 0xdb, 0xfb, 0x1e, 0x75, 0x4e, 0x35, 0xfa, 0x1c, 0x78, 0x44, 0xc4, 0x1f, 0x32, 0x2a, 0x18, 0x63, 0xd4, 0x62, 0x13, 0x53, 0xae} - return btcutil.NewAddressScriptHash(script, &chaincfg.MainNetParams) + return address.NewAddressScriptHash(script, &chaincfg.MainNetParams) }, net: &chaincfg.MainNetParams, }, @@ -195,16 +195,16 @@ func TestAddresses(t *testing.T) { addr: "MVcg9uEvtWuP5N6V48EHfEtbz48qR8TKZ9", encoded: "MVcg9uEvtWuP5N6V48EHfEtbz48qR8TKZ9", valid: true, - result: btcutil.TstAddressScriptHash( + result: address.TstAddressScriptHash( [ripemd160.Size]byte{ 0xee, 0x34, 0xac, 0x67, 0x6b, 0xda, 0xf6, 0xe3, 0x70, 0xc8, 0xc8, 0x20, 0xb9, 0x48, 0xed, 0xfa, 0xd3, 0xa8, 0x73, 0xd8}, CustomParams.ScriptHashAddrID), - f: func() (btcutil.Address, error) { + f: func() (address.Address, error) { pkHash := []byte{ 0xEE, 0x34, 0xAC, 0x67, 0x6B, 0xDA, 0xF6, 0xE3, 0x70, 0xC8, 0xC8, 0x20, 0xB9, 0x48, 0xED, 0xFA, 0xD3, 0xA8, 0x73, 0xD8} - return btcutil.NewAddressScriptHashFromHash(pkHash, &customParams) + return address.NewAddressScriptHashFromHash(pkHash, &customParams) }, net: &customParams, }, @@ -216,16 +216,16 @@ func TestAddresses(t *testing.T) { addr: "3NukJ6fYZJ5Kk8bPjycAnruZkE5Q7UW7i8", encoded: "3NukJ6fYZJ5Kk8bPjycAnruZkE5Q7UW7i8", valid: true, - result: btcutil.TstAddressScriptHash( + result: address.TstAddressScriptHash( [ripemd160.Size]byte{ 0xe8, 0xc3, 0x00, 0xc8, 0x79, 0x86, 0xef, 0xa8, 0x4c, 0x37, 0xc0, 0x51, 0x99, 0x29, 0x01, 0x9e, 0xf8, 0x6e, 0xb5, 0xb4}, chaincfg.MainNetParams.ScriptHashAddrID), - f: func() (btcutil.Address, error) { + f: func() (address.Address, error) { hash := []byte{ 0xe8, 0xc3, 0x00, 0xc8, 0x79, 0x86, 0xef, 0xa8, 0x4c, 0x37, 0xc0, 0x51, 0x99, 0x29, 0x01, 0x9e, 0xf8, 0x6e, 0xb5, 0xb4} - return btcutil.NewAddressScriptHashFromHash(hash, &chaincfg.MainNetParams) + return address.NewAddressScriptHashFromHash(hash, &chaincfg.MainNetParams) }, net: &chaincfg.MainNetParams, }, @@ -235,16 +235,16 @@ func TestAddresses(t *testing.T) { addr: "2NBFNJTktNa7GZusGbDbGKRZTxdK9VVez3n", encoded: "2NBFNJTktNa7GZusGbDbGKRZTxdK9VVez3n", valid: true, - result: btcutil.TstAddressScriptHash( + result: address.TstAddressScriptHash( [ripemd160.Size]byte{ 0xc5, 0x79, 0x34, 0x2c, 0x2c, 0x4c, 0x92, 0x20, 0x20, 0x5e, 0x2c, 0xdc, 0x28, 0x56, 0x17, 0x04, 0x0c, 0x92, 0x4a, 0x0a}, chaincfg.TestNet3Params.ScriptHashAddrID), - f: func() (btcutil.Address, error) { + f: func() (address.Address, error) { hash := []byte{ 0xc5, 0x79, 0x34, 0x2c, 0x2c, 0x4c, 0x92, 0x20, 0x20, 0x5e, 0x2c, 0xdc, 0x28, 0x56, 0x17, 0x04, 0x0c, 0x92, 0x4a, 0x0a} - return btcutil.NewAddressScriptHashFromHash(hash, &chaincfg.TestNet3Params) + return address.NewAddressScriptHashFromHash(hash, &chaincfg.TestNet3Params) }, net: &chaincfg.TestNet3Params, }, @@ -254,12 +254,12 @@ func TestAddresses(t *testing.T) { name: "p2sh wrong hash length", addr: "", valid: false, - f: func() (btcutil.Address, error) { + f: func() (address.Address, error) { hash := []byte{ 0x00, 0xf8, 0x15, 0xb0, 0x36, 0xd9, 0xbb, 0xbc, 0xe5, 0xe9, 0xf2, 0xa0, 0x0a, 0xbd, 0x1b, 0xf3, 0xdc, 0x91, 0xe9, 0x55, 0x10} - return btcutil.NewAddressScriptHashFromHash(hash, &chaincfg.MainNetParams) + return address.NewAddressScriptHashFromHash(hash, &chaincfg.MainNetParams) }, net: &chaincfg.MainNetParams, }, @@ -270,20 +270,20 @@ func TestAddresses(t *testing.T) { addr: "02192d74d0cb94344c9569c2e77901573d8d7903c3ebec3a957724895dca52c6b4", encoded: "13CG6SJ3yHUXo4Cr2RY4THLLJrNFuG3gUg", valid: true, - result: btcutil.TstAddressPubKey( + result: address.TstAddressPubKey( []byte{ 0x02, 0x19, 0x2d, 0x74, 0xd0, 0xcb, 0x94, 0x34, 0x4c, 0x95, 0x69, 0xc2, 0xe7, 0x79, 0x01, 0x57, 0x3d, 0x8d, 0x79, 0x03, 0xc3, 0xeb, 0xec, 0x3a, 0x95, 0x77, 0x24, 0x89, 0x5d, 0xca, 0x52, 0xc6, 0xb4}, - btcutil.PKFCompressed, chaincfg.MainNetParams.PubKeyHashAddrID), - f: func() (btcutil.Address, error) { + address.PKFCompressed, chaincfg.MainNetParams.PubKeyHashAddrID), + f: func() (address.Address, error) { serializedPubKey := []byte{ 0x02, 0x19, 0x2d, 0x74, 0xd0, 0xcb, 0x94, 0x34, 0x4c, 0x95, 0x69, 0xc2, 0xe7, 0x79, 0x01, 0x57, 0x3d, 0x8d, 0x79, 0x03, 0xc3, 0xeb, 0xec, 0x3a, 0x95, 0x77, 0x24, 0x89, 0x5d, 0xca, 0x52, 0xc6, 0xb4} - return btcutil.NewAddressPubKey(serializedPubKey, &chaincfg.MainNetParams) + return address.NewAddressPubKey(serializedPubKey, &chaincfg.MainNetParams) }, net: &chaincfg.MainNetParams, }, @@ -292,20 +292,20 @@ func TestAddresses(t *testing.T) { addr: "03b0bd634234abbb1ba1e986e884185c61cf43e001f9137f23c2c409273eb16e65", encoded: "15sHANNUBSh6nDp8XkDPmQcW6n3EFwmvE6", valid: true, - result: btcutil.TstAddressPubKey( + result: address.TstAddressPubKey( []byte{ 0x03, 0xb0, 0xbd, 0x63, 0x42, 0x34, 0xab, 0xbb, 0x1b, 0xa1, 0xe9, 0x86, 0xe8, 0x84, 0x18, 0x5c, 0x61, 0xcf, 0x43, 0xe0, 0x01, 0xf9, 0x13, 0x7f, 0x23, 0xc2, 0xc4, 0x09, 0x27, 0x3e, 0xb1, 0x6e, 0x65}, - btcutil.PKFCompressed, chaincfg.MainNetParams.PubKeyHashAddrID), - f: func() (btcutil.Address, error) { + address.PKFCompressed, chaincfg.MainNetParams.PubKeyHashAddrID), + f: func() (address.Address, error) { serializedPubKey := []byte{ 0x03, 0xb0, 0xbd, 0x63, 0x42, 0x34, 0xab, 0xbb, 0x1b, 0xa1, 0xe9, 0x86, 0xe8, 0x84, 0x18, 0x5c, 0x61, 0xcf, 0x43, 0xe0, 0x01, 0xf9, 0x13, 0x7f, 0x23, 0xc2, 0xc4, 0x09, 0x27, 0x3e, 0xb1, 0x6e, 0x65} - return btcutil.NewAddressPubKey(serializedPubKey, &chaincfg.MainNetParams) + return address.NewAddressPubKey(serializedPubKey, &chaincfg.MainNetParams) }, net: &chaincfg.MainNetParams, }, @@ -315,7 +315,7 @@ func TestAddresses(t *testing.T) { "e0eaddfb84ccf9744464f82e160bfa9b8b64f9d4c03f999b8643f656b412a3", encoded: "12cbQLTFMXRnSzktFkuoG3eHoMeFtpTu3S", valid: true, - result: btcutil.TstAddressPubKey( + result: address.TstAddressPubKey( []byte{ 0x04, 0x11, 0xdb, 0x93, 0xe1, 0xdc, 0xdb, 0x8a, 0x01, 0x6b, 0x49, 0x84, 0x0f, 0x8c, 0x53, 0xbc, 0x1e, 0xb6, 0x8a, 0x38, @@ -324,8 +324,8 @@ func TestAddresses(t *testing.T) { 0xf9, 0x74, 0x44, 0x64, 0xf8, 0x2e, 0x16, 0x0b, 0xfa, 0x9b, 0x8b, 0x64, 0xf9, 0xd4, 0xc0, 0x3f, 0x99, 0x9b, 0x86, 0x43, 0xf6, 0x56, 0xb4, 0x12, 0xa3}, - btcutil.PKFUncompressed, chaincfg.MainNetParams.PubKeyHashAddrID), - f: func() (btcutil.Address, error) { + address.PKFUncompressed, chaincfg.MainNetParams.PubKeyHashAddrID), + f: func() (address.Address, error) { serializedPubKey := []byte{ 0x04, 0x11, 0xdb, 0x93, 0xe1, 0xdc, 0xdb, 0x8a, 0x01, 0x6b, 0x49, 0x84, 0x0f, 0x8c, 0x53, 0xbc, 0x1e, 0xb6, 0x8a, 0x38, @@ -334,7 +334,7 @@ func TestAddresses(t *testing.T) { 0xf9, 0x74, 0x44, 0x64, 0xf8, 0x2e, 0x16, 0x0b, 0xfa, 0x9b, 0x8b, 0x64, 0xf9, 0xd4, 0xc0, 0x3f, 0x99, 0x9b, 0x86, 0x43, 0xf6, 0x56, 0xb4, 0x12, 0xa3} - return btcutil.NewAddressPubKey(serializedPubKey, &chaincfg.MainNetParams) + return address.NewAddressPubKey(serializedPubKey, &chaincfg.MainNetParams) }, net: &chaincfg.MainNetParams, }, @@ -343,20 +343,20 @@ func TestAddresses(t *testing.T) { addr: "02192d74d0cb94344c9569c2e77901573d8d7903c3ebec3a957724895dca52c6b4", encoded: "mhiDPVP2nJunaAgTjzWSHCYfAqxxrxzjmo", valid: true, - result: btcutil.TstAddressPubKey( + result: address.TstAddressPubKey( []byte{ 0x02, 0x19, 0x2d, 0x74, 0xd0, 0xcb, 0x94, 0x34, 0x4c, 0x95, 0x69, 0xc2, 0xe7, 0x79, 0x01, 0x57, 0x3d, 0x8d, 0x79, 0x03, 0xc3, 0xeb, 0xec, 0x3a, 0x95, 0x77, 0x24, 0x89, 0x5d, 0xca, 0x52, 0xc6, 0xb4}, - btcutil.PKFCompressed, chaincfg.TestNet3Params.PubKeyHashAddrID), - f: func() (btcutil.Address, error) { + address.PKFCompressed, chaincfg.TestNet3Params.PubKeyHashAddrID), + f: func() (address.Address, error) { serializedPubKey := []byte{ 0x02, 0x19, 0x2d, 0x74, 0xd0, 0xcb, 0x94, 0x34, 0x4c, 0x95, 0x69, 0xc2, 0xe7, 0x79, 0x01, 0x57, 0x3d, 0x8d, 0x79, 0x03, 0xc3, 0xeb, 0xec, 0x3a, 0x95, 0x77, 0x24, 0x89, 0x5d, 0xca, 0x52, 0xc6, 0xb4} - return btcutil.NewAddressPubKey(serializedPubKey, &chaincfg.TestNet3Params) + return address.NewAddressPubKey(serializedPubKey, &chaincfg.TestNet3Params) }, net: &chaincfg.TestNet3Params, }, @@ -365,20 +365,20 @@ func TestAddresses(t *testing.T) { addr: "03b0bd634234abbb1ba1e986e884185c61cf43e001f9137f23c2c409273eb16e65", encoded: "mkPETRTSzU8MZLHkFKBmbKppxmdw9qT42t", valid: true, - result: btcutil.TstAddressPubKey( + result: address.TstAddressPubKey( []byte{ 0x03, 0xb0, 0xbd, 0x63, 0x42, 0x34, 0xab, 0xbb, 0x1b, 0xa1, 0xe9, 0x86, 0xe8, 0x84, 0x18, 0x5c, 0x61, 0xcf, 0x43, 0xe0, 0x01, 0xf9, 0x13, 0x7f, 0x23, 0xc2, 0xc4, 0x09, 0x27, 0x3e, 0xb1, 0x6e, 0x65}, - btcutil.PKFCompressed, chaincfg.TestNet3Params.PubKeyHashAddrID), - f: func() (btcutil.Address, error) { + address.PKFCompressed, chaincfg.TestNet3Params.PubKeyHashAddrID), + f: func() (address.Address, error) { serializedPubKey := []byte{ 0x03, 0xb0, 0xbd, 0x63, 0x42, 0x34, 0xab, 0xbb, 0x1b, 0xa1, 0xe9, 0x86, 0xe8, 0x84, 0x18, 0x5c, 0x61, 0xcf, 0x43, 0xe0, 0x01, 0xf9, 0x13, 0x7f, 0x23, 0xc2, 0xc4, 0x09, 0x27, 0x3e, 0xb1, 0x6e, 0x65} - return btcutil.NewAddressPubKey(serializedPubKey, &chaincfg.TestNet3Params) + return address.NewAddressPubKey(serializedPubKey, &chaincfg.TestNet3Params) }, net: &chaincfg.TestNet3Params, }, @@ -388,7 +388,7 @@ func TestAddresses(t *testing.T) { "cb2e0eaddfb84ccf9744464f82e160bfa9b8b64f9d4c03f999b8643f656b412a3", encoded: "mh8YhPYEAYs3E7EVyKtB5xrcfMExkkdEMF", valid: true, - result: btcutil.TstAddressPubKey( + result: address.TstAddressPubKey( []byte{ 0x04, 0x11, 0xdb, 0x93, 0xe1, 0xdc, 0xdb, 0x8a, 0x01, 0x6b, 0x49, 0x84, 0x0f, 0x8c, 0x53, 0xbc, 0x1e, 0xb6, 0x8a, 0x38, @@ -397,8 +397,8 @@ func TestAddresses(t *testing.T) { 0xf9, 0x74, 0x44, 0x64, 0xf8, 0x2e, 0x16, 0x0b, 0xfa, 0x9b, 0x8b, 0x64, 0xf9, 0xd4, 0xc0, 0x3f, 0x99, 0x9b, 0x86, 0x43, 0xf6, 0x56, 0xb4, 0x12, 0xa3}, - btcutil.PKFUncompressed, chaincfg.TestNet3Params.PubKeyHashAddrID), - f: func() (btcutil.Address, error) { + address.PKFUncompressed, chaincfg.TestNet3Params.PubKeyHashAddrID), + f: func() (address.Address, error) { serializedPubKey := []byte{ 0x04, 0x11, 0xdb, 0x93, 0xe1, 0xdc, 0xdb, 0x8a, 0x01, 0x6b, 0x49, 0x84, 0x0f, 0x8c, 0x53, 0xbc, 0x1e, 0xb6, 0x8a, 0x38, @@ -407,7 +407,7 @@ func TestAddresses(t *testing.T) { 0xf9, 0x74, 0x44, 0x64, 0xf8, 0x2e, 0x16, 0x0b, 0xfa, 0x9b, 0x8b, 0x64, 0xf9, 0xd4, 0xc0, 0x3f, 0x99, 0x9b, 0x86, 0x43, 0xf6, 0x56, 0xb4, 0x12, 0xa3} - return btcutil.NewAddressPubKey(serializedPubKey, &chaincfg.TestNet3Params) + return address.NewAddressPubKey(serializedPubKey, &chaincfg.TestNet3Params) }, net: &chaincfg.TestNet3Params, }, @@ -417,17 +417,17 @@ func TestAddresses(t *testing.T) { addr: "BC1QW508D6QEJXTDG4Y5R3ZARVARY0C5XW7KV8F3T4", encoded: "bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4", valid: true, - result: btcutil.TstAddressWitnessPubKeyHash( + result: address.TstAddressWitnessPubKeyHash( 0, [20]byte{ 0x75, 0x1e, 0x76, 0xe8, 0x19, 0x91, 0x96, 0xd4, 0x54, 0x94, 0x1c, 0x45, 0xd1, 0xb3, 0xa3, 0x23, 0xf1, 0x43, 0x3b, 0xd6}, chaincfg.MainNetParams.Bech32HRPSegwit), - f: func() (btcutil.Address, error) { + f: func() (address.Address, error) { pkHash := []byte{ 0x75, 0x1e, 0x76, 0xe8, 0x19, 0x91, 0x96, 0xd4, 0x54, 0x94, 0x1c, 0x45, 0xd1, 0xb3, 0xa3, 0x23, 0xf1, 0x43, 0x3b, 0xd6} - return btcutil.NewAddressWitnessPubKeyHash(pkHash, &chaincfg.MainNetParams) + return address.NewAddressWitnessPubKeyHash(pkHash, &chaincfg.MainNetParams) }, net: &chaincfg.MainNetParams, }, @@ -436,7 +436,7 @@ func TestAddresses(t *testing.T) { addr: "bc1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3qccfmv3", encoded: "bc1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3qccfmv3", valid: true, - result: btcutil.TstAddressWitnessScriptHash( + result: address.TstAddressWitnessScriptHash( 0, [32]byte{ 0x18, 0x63, 0x14, 0x3c, 0x14, 0xc5, 0x16, 0x68, @@ -444,13 +444,13 @@ func TestAddresses(t *testing.T) { 0x6c, 0x98, 0x56, 0x78, 0xcd, 0x4d, 0x27, 0xa1, 0xb8, 0xc6, 0x32, 0x96, 0x04, 0x90, 0x32, 0x62}, chaincfg.MainNetParams.Bech32HRPSegwit), - f: func() (btcutil.Address, error) { + f: func() (address.Address, error) { scriptHash := []byte{ 0x18, 0x63, 0x14, 0x3c, 0x14, 0xc5, 0x16, 0x68, 0x04, 0xbd, 0x19, 0x20, 0x33, 0x56, 0xda, 0x13, 0x6c, 0x98, 0x56, 0x78, 0xcd, 0x4d, 0x27, 0xa1, 0xb8, 0xc6, 0x32, 0x96, 0x04, 0x90, 0x32, 0x62} - return btcutil.NewAddressWitnessScriptHash(scriptHash, &chaincfg.MainNetParams) + return address.NewAddressWitnessScriptHash(scriptHash, &chaincfg.MainNetParams) }, net: &chaincfg.MainNetParams, }, @@ -459,17 +459,17 @@ func TestAddresses(t *testing.T) { addr: "tb1qw508d6qejxtdg4y5r3zarvary0c5xw7kxpjzsx", encoded: "tb1qw508d6qejxtdg4y5r3zarvary0c5xw7kxpjzsx", valid: true, - result: btcutil.TstAddressWitnessPubKeyHash( + result: address.TstAddressWitnessPubKeyHash( 0, [20]byte{ 0x75, 0x1e, 0x76, 0xe8, 0x19, 0x91, 0x96, 0xd4, 0x54, 0x94, 0x1c, 0x45, 0xd1, 0xb3, 0xa3, 0x23, 0xf1, 0x43, 0x3b, 0xd6}, chaincfg.TestNet3Params.Bech32HRPSegwit), - f: func() (btcutil.Address, error) { + f: func() (address.Address, error) { pkHash := []byte{ 0x75, 0x1e, 0x76, 0xe8, 0x19, 0x91, 0x96, 0xd4, 0x54, 0x94, 0x1c, 0x45, 0xd1, 0xb3, 0xa3, 0x23, 0xf1, 0x43, 0x3b, 0xd6} - return btcutil.NewAddressWitnessPubKeyHash(pkHash, &chaincfg.TestNet3Params) + return address.NewAddressWitnessPubKeyHash(pkHash, &chaincfg.TestNet3Params) }, net: &chaincfg.TestNet3Params, }, @@ -478,7 +478,7 @@ func TestAddresses(t *testing.T) { addr: "tb1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3q0sl5k7", encoded: "tb1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3q0sl5k7", valid: true, - result: btcutil.TstAddressWitnessScriptHash( + result: address.TstAddressWitnessScriptHash( 0, [32]byte{ 0x18, 0x63, 0x14, 0x3c, 0x14, 0xc5, 0x16, 0x68, @@ -486,13 +486,13 @@ func TestAddresses(t *testing.T) { 0x6c, 0x98, 0x56, 0x78, 0xcd, 0x4d, 0x27, 0xa1, 0xb8, 0xc6, 0x32, 0x96, 0x04, 0x90, 0x32, 0x62}, chaincfg.TestNet3Params.Bech32HRPSegwit), - f: func() (btcutil.Address, error) { + f: func() (address.Address, error) { scriptHash := []byte{ 0x18, 0x63, 0x14, 0x3c, 0x14, 0xc5, 0x16, 0x68, 0x04, 0xbd, 0x19, 0x20, 0x33, 0x56, 0xda, 0x13, 0x6c, 0x98, 0x56, 0x78, 0xcd, 0x4d, 0x27, 0xa1, 0xb8, 0xc6, 0x32, 0x96, 0x04, 0x90, 0x32, 0x62} - return btcutil.NewAddressWitnessScriptHash(scriptHash, &chaincfg.TestNet3Params) + return address.NewAddressWitnessScriptHash(scriptHash, &chaincfg.TestNet3Params) }, net: &chaincfg.TestNet3Params, }, @@ -501,7 +501,7 @@ func TestAddresses(t *testing.T) { addr: "tb1qqqqqp399et2xygdj5xreqhjjvcmzhxw4aywxecjdzew6hylgvsesrxh6hy", encoded: "tb1qqqqqp399et2xygdj5xreqhjjvcmzhxw4aywxecjdzew6hylgvsesrxh6hy", valid: true, - result: btcutil.TstAddressWitnessScriptHash( + result: address.TstAddressWitnessScriptHash( 0, [32]byte{ 0x00, 0x00, 0x00, 0xc4, 0xa5, 0xca, 0xd4, 0x62, @@ -509,13 +509,13 @@ func TestAddresses(t *testing.T) { 0x36, 0x2b, 0x99, 0xd5, 0xe9, 0x1c, 0x6c, 0xe2, 0x4d, 0x16, 0x5d, 0xab, 0x93, 0xe8, 0x64, 0x33}, chaincfg.TestNet3Params.Bech32HRPSegwit), - f: func() (btcutil.Address, error) { + f: func() (address.Address, error) { scriptHash := []byte{ 0x00, 0x00, 0x00, 0xc4, 0xa5, 0xca, 0xd4, 0x62, 0x21, 0xb2, 0xa1, 0x87, 0x90, 0x5e, 0x52, 0x66, 0x36, 0x2b, 0x99, 0xd5, 0xe9, 0x1c, 0x6c, 0xe2, 0x4d, 0x16, 0x5d, 0xab, 0x93, 0xe8, 0x64, 0x33} - return btcutil.NewAddressWitnessScriptHash(scriptHash, &chaincfg.TestNet3Params) + return address.NewAddressWitnessScriptHash(scriptHash, &chaincfg.TestNet3Params) }, net: &chaincfg.TestNet3Params, }, @@ -524,18 +524,18 @@ func TestAddresses(t *testing.T) { addr: "LTC1QW508D6QEJXTDG4Y5R3ZARVARY0C5XW7KGMN4N9", encoded: "ltc1qw508d6qejxtdg4y5r3zarvary0c5xw7kgmn4n9", valid: true, - result: btcutil.TstAddressWitnessPubKeyHash( + result: address.TstAddressWitnessPubKeyHash( 0, [20]byte{ 0x75, 0x1e, 0x76, 0xe8, 0x19, 0x91, 0x96, 0xd4, 0x54, 0x94, 0x1c, 0x45, 0xd1, 0xb3, 0xa3, 0x23, 0xf1, 0x43, 0x3b, 0xd6}, CustomParams.Bech32HRPSegwit, ), - f: func() (btcutil.Address, error) { + f: func() (address.Address, error) { pkHash := []byte{ 0x75, 0x1e, 0x76, 0xe8, 0x19, 0x91, 0x96, 0xd4, 0x54, 0x94, 0x1c, 0x45, 0xd1, 0xb3, 0xa3, 0x23, 0xf1, 0x43, 0x3b, 0xd6} - return btcutil.NewAddressWitnessPubKeyHash(pkHash, &customParams) + return address.NewAddressWitnessPubKeyHash(pkHash, &customParams) }, net: &customParams, }, @@ -546,7 +546,7 @@ func TestAddresses(t *testing.T) { addr: "bc1paardr2nczq0rx5rqpfwnvpzm497zvux64y0f7wjgcs7xuuuh2nnqwr2d5c", encoded: "bc1paardr2nczq0rx5rqpfwnvpzm497zvux64y0f7wjgcs7xuuuh2nnqwr2d5c", valid: true, - result: btcutil.TstAddressTaproot( + result: address.TstAddressTaproot( 1, [32]byte{ 0xef, 0x46, 0xd1, 0xaa, 0x78, 0x10, 0x1e, 0x33, 0x50, 0x60, 0x0a, 0x5d, 0x36, 0x04, 0x5b, 0xa9, @@ -554,14 +554,14 @@ func TestAddresses(t *testing.T) { 0x48, 0xc4, 0x3c, 0x6e, 0x73, 0x97, 0x54, 0xe6, }, chaincfg.MainNetParams.Bech32HRPSegwit, ), - f: func() (btcutil.Address, error) { + f: func() (address.Address, error) { scriptHash := []byte{ 0xef, 0x46, 0xd1, 0xaa, 0x78, 0x10, 0x1e, 0x33, 0x50, 0x60, 0x0a, 0x5d, 0x36, 0x04, 0x5b, 0xa9, 0x7c, 0x26, 0x70, 0xda, 0xa9, 0x1e, 0x9f, 0x3a, 0x48, 0xc4, 0x3c, 0x6e, 0x73, 0x97, 0x54, 0xe6, } - return btcutil.NewAddressTaproot( + return address.NewAddressTaproot( scriptHash, &chaincfg.MainNetParams, ) }, @@ -731,7 +731,7 @@ func TestAddresses(t *testing.T) { for _, test := range tests { // Decode addr and compare error against valid. - decoded, err := btcutil.DecodeAddress(test.addr, test.net) + decoded, err := address.DecodeAddress(test.addr, test.net) if (err == nil) != test.valid { t.Errorf("%v: decoding test failed: %v", test.name, err) return @@ -768,22 +768,22 @@ func TestAddresses(t *testing.T) { // Perform type-specific calculations. var saddr []byte switch d := decoded.(type) { - case *btcutil.AddressPubKeyHash: - saddr = btcutil.TstAddressSAddr(encoded) + case *address.AddressPubKeyHash: + saddr = address.TstAddressSAddr(encoded) - case *btcutil.AddressScriptHash: - saddr = btcutil.TstAddressSAddr(encoded) + case *address.AddressScriptHash: + saddr = address.TstAddressSAddr(encoded) - case *btcutil.AddressPubKey: + case *address.AddressPubKey: // Ignore the error here since the script // address is checked below. saddr, _ = hex.DecodeString(d.String()) - case *btcutil.AddressWitnessPubKeyHash: - saddr = btcutil.TstAddressSegwitSAddr(encoded) - case *btcutil.AddressWitnessScriptHash: - saddr = btcutil.TstAddressSegwitSAddr(encoded) - case *btcutil.AddressTaproot: - saddr = btcutil.TstAddressTaprootSAddr(encoded) + case *address.AddressWitnessPubKeyHash: + saddr = address.TstAddressSegwitSAddr(encoded) + case *address.AddressWitnessScriptHash: + saddr = address.TstAddressSegwitSAddr(encoded) + case *address.AddressTaproot: + saddr = address.TstAddressTaprootSAddr(encoded) } // Check script address, as well as the Hash160 method for P2PKH and @@ -794,28 +794,28 @@ func TestAddresses(t *testing.T) { return } switch a := decoded.(type) { - case *btcutil.AddressPubKeyHash: + case *address.AddressPubKeyHash: if h := a.Hash160()[:]; !bytes.Equal(saddr, h) { t.Errorf("%v: hashes do not match:\n%x != \n%x", test.name, saddr, h) return } - case *btcutil.AddressScriptHash: + case *address.AddressScriptHash: if h := a.Hash160()[:]; !bytes.Equal(saddr, h) { t.Errorf("%v: hashes do not match:\n%x != \n%x", test.name, saddr, h) return } - case *btcutil.AddressWitnessPubKeyHash: + case *address.AddressWitnessPubKeyHash: if hrp := a.Hrp(); test.net.Bech32HRPSegwit != hrp { t.Errorf("%v: hrps do not match:\n%x != \n%x", test.name, test.net.Bech32HRPSegwit, hrp) return } - expVer := test.result.(*btcutil.AddressWitnessPubKeyHash).WitnessVersion() + expVer := test.result.(*address.AddressWitnessPubKeyHash).WitnessVersion() if v := a.WitnessVersion(); v != expVer { t.Errorf("%v: witness versions do not match:\n%x != \n%x", test.name, expVer, v) @@ -828,14 +828,14 @@ func TestAddresses(t *testing.T) { return } - case *btcutil.AddressWitnessScriptHash: + case *address.AddressWitnessScriptHash: if hrp := a.Hrp(); test.net.Bech32HRPSegwit != hrp { t.Errorf("%v: hrps do not match:\n%x != \n%x", test.name, test.net.Bech32HRPSegwit, hrp) return } - expVer := test.result.(*btcutil.AddressWitnessScriptHash).WitnessVersion() + expVer := test.result.(*address.AddressWitnessScriptHash).WitnessVersion() if v := a.WitnessVersion(); v != expVer { t.Errorf("%v: witness versions do not match:\n%x != \n%x", test.name, expVer, v) diff --git a/btcutil/base58/README.md b/address/base58/README.md similarity index 65% rename from btcutil/base58/README.md rename to address/base58/README.md index abdb78155d..1fb7f27fc1 100644 --- a/btcutil/base58/README.md +++ b/address/base58/README.md @@ -1,9 +1,9 @@ base58 ========== -[![Build Status](http://img.shields.io/travis/btcsuite/btcutil.svg)](https://travis-ci.org/btcsuite/btcutil) +[![Build Status](https://github.com/btcsuite/btcd/workflows/Build%20and%20Test/badge.svg)](https://github.com/btcsuite/btcd/actions) [![ISC License](http://img.shields.io/badge/license-ISC-blue.svg)](http://copyfree.org) -[![GoDoc](https://img.shields.io/badge/godoc-reference-blue.svg)](http://godoc.org/github.com/btcsuite/btcd/btcutil/base58) +[![GoDoc](https://img.shields.io/badge/godoc-reference-blue.svg)](http://godoc.org/github.com/btcsuite/btcd/address/v2/base58) Package base58 provides an API for encoding and decoding to and from the modified base58 encoding. It also provides an API to do Base58Check encoding, @@ -14,18 +14,18 @@ A comprehensive suite of tests is provided to ensure proper functionality. ## Installation and Updating ```bash -$ go get -u github.com/btcsuite/btcd/btcutil/base58 +$ go get -u github.com/btcsuite/btcd/address/v2/base58 ``` ## Examples -* [Decode Example](http://godoc.org/github.com/btcsuite/btcd/btcutil/base58#example-Decode) +* [Decode Example](http://godoc.org/github.com/btcsuite/btcd/address/v2/base58#example-Decode) Demonstrates how to decode modified base58 encoded data. -* [Encode Example](http://godoc.org/github.com/btcsuite/btcd/btcutil/base58#example-Encode) +* [Encode Example](http://godoc.org/github.com/btcsuite/btcd/address/v2/base58#example-Encode) Demonstrates how to encode data using the modified base58 encoding scheme. -* [CheckDecode Example](http://godoc.org/github.com/btcsuite/btcd/btcutil/base58#example-CheckDecode) +* [CheckDecode Example](http://godoc.org/github.com/btcsuite/btcd/address/v2/base58#example-CheckDecode) Demonstrates how to decode Base58Check encoded data. -* [CheckEncode Example](http://godoc.org/github.com/btcsuite/btcd/btcutil/base58#example-CheckEncode) +* [CheckEncode Example](http://godoc.org/github.com/btcsuite/btcd/address/v2/base58#example-CheckEncode) Demonstrates how to encode data using the Base58Check encoding scheme. ## License diff --git a/btcutil/base58/alphabet.go b/address/base58/alphabet.go similarity index 100% rename from btcutil/base58/alphabet.go rename to address/base58/alphabet.go diff --git a/btcutil/base58/base58.go b/address/base58/base58.go similarity index 100% rename from btcutil/base58/base58.go rename to address/base58/base58.go diff --git a/btcutil/base58/base58_test.go b/address/base58/base58_test.go similarity index 98% rename from btcutil/base58/base58_test.go rename to address/base58/base58_test.go index eb7e4d4bcf..fc5098e3be 100644 --- a/btcutil/base58/base58_test.go +++ b/address/base58/base58_test.go @@ -9,7 +9,7 @@ import ( "encoding/hex" "testing" - "github.com/btcsuite/btcd/btcutil/base58" + "github.com/btcsuite/btcd/address/v2/base58" ) var stringTests = []struct { diff --git a/btcutil/base58/base58bench_test.go b/address/base58/base58bench_test.go similarity index 95% rename from btcutil/base58/base58bench_test.go rename to address/base58/base58bench_test.go index c7286e53c7..a16bd3a020 100644 --- a/btcutil/base58/base58bench_test.go +++ b/address/base58/base58bench_test.go @@ -8,7 +8,7 @@ import ( "bytes" "testing" - "github.com/btcsuite/btcd/btcutil/base58" + "github.com/btcsuite/btcd/address/v2/base58" ) var ( diff --git a/btcutil/base58/base58check.go b/address/base58/base58check.go similarity index 100% rename from btcutil/base58/base58check.go rename to address/base58/base58check.go diff --git a/btcutil/base58/base58check_test.go b/address/base58/base58check_test.go similarity index 97% rename from btcutil/base58/base58check_test.go rename to address/base58/base58check_test.go index e180b16391..8fa412b6cb 100644 --- a/btcutil/base58/base58check_test.go +++ b/address/base58/base58check_test.go @@ -7,7 +7,7 @@ package base58_test import ( "testing" - "github.com/btcsuite/btcd/btcutil/base58" + "github.com/btcsuite/btcd/address/v2/base58" ) var checkEncodingStringTests = []struct { diff --git a/btcutil/base58/cov_report.sh b/address/base58/cov_report.sh similarity index 100% rename from btcutil/base58/cov_report.sh rename to address/base58/cov_report.sh diff --git a/btcutil/base58/doc.go b/address/base58/doc.go similarity index 100% rename from btcutil/base58/doc.go rename to address/base58/doc.go diff --git a/btcutil/base58/example_test.go b/address/base58/example_test.go similarity index 97% rename from btcutil/base58/example_test.go rename to address/base58/example_test.go index babb35d3f4..803f575c68 100644 --- a/btcutil/base58/example_test.go +++ b/address/base58/example_test.go @@ -7,7 +7,7 @@ package base58_test import ( "fmt" - "github.com/btcsuite/btcd/btcutil/base58" + "github.com/btcsuite/btcd/address/v2/base58" ) // This example demonstrates how to decode modified base58 encoded data. diff --git a/btcutil/base58/genalphabet.go b/address/base58/genalphabet.go similarity index 100% rename from btcutil/base58/genalphabet.go rename to address/base58/genalphabet.go diff --git a/btcutil/bech32/README.md b/address/bech32/README.md similarity index 63% rename from btcutil/bech32/README.md rename to address/bech32/README.md index 471cd50ee9..eed355061c 100644 --- a/btcutil/bech32/README.md +++ b/address/bech32/README.md @@ -1,9 +1,9 @@ bech32 ========== -[![Build Status](http://img.shields.io/travis/btcsuite/btcutil.svg)](https://travis-ci.org/btcsuite/btcutil) +[![Build Status](https://github.com/btcsuite/btcd/workflows/Build%20and%20Test/badge.svg)](https://github.com/btcsuite/btcd/actions) [![ISC License](http://img.shields.io/badge/license-ISC-blue.svg)](http://copyfree.org) -[![GoDoc](https://godoc.org/github.com/btcsuite/btcd/btcutil/bech32?status.png)](http://godoc.org/github.com/btcsuite/btcd/btcutil/bech32) +[![GoDoc](https://godoc.org/github.com/btcsuite/btcd/address/v2/bech32?status.png)](http://godoc.org/github.com/btcsuite/btcd/address/v2/bech32) Package bech32 provides a Go implementation of the bech32 format specified in [BIP 173](https://github.com/bitcoin/bips/blob/master/bip-0173.mediawiki). @@ -13,14 +13,14 @@ Test vectors from BIP 173 are added to ensure compatibility with the BIP. ## Installation and Updating ```bash -$ go get -u github.com/btcsuite/btcd/btcutil/bech32 +$ go get -u github.com/btcsuite/btcd/address/v2/bech32 ``` ## Examples -* [Bech32 decode Example](http://godoc.org/github.com/btcsuite/btcd/btcutil/bech32#example-Bech32Decode) +* [Bech32 decode Example](http://godoc.org/github.com/btcsuite/btcd/address/v2/bech32#example-Bech32Decode) Demonstrates how to decode a bech32 encoded string. -* [Bech32 encode Example](http://godoc.org/github.com/btcsuite/btcd/btcutil/bech32#example-BechEncode) +* [Bech32 encode Example](http://godoc.org/github.com/btcsuite/btcd/address/v2/bech32#example-BechEncode) Demonstrates how to encode data into a bech32 string. ## License diff --git a/btcutil/bech32/bech32.go b/address/bech32/bech32.go similarity index 100% rename from btcutil/bech32/bech32.go rename to address/bech32/bech32.go diff --git a/btcutil/bech32/bech32_test.go b/address/bech32/bech32_test.go similarity index 100% rename from btcutil/bech32/bech32_test.go rename to address/bech32/bech32_test.go diff --git a/btcutil/bech32/doc.go b/address/bech32/doc.go similarity index 100% rename from btcutil/bech32/doc.go rename to address/bech32/doc.go diff --git a/btcutil/bech32/error.go b/address/bech32/error.go similarity index 100% rename from btcutil/bech32/error.go rename to address/bech32/error.go diff --git a/btcutil/bech32/example_test.go b/address/bech32/example_test.go similarity index 96% rename from btcutil/bech32/example_test.go rename to address/bech32/example_test.go index 290baaed6c..74ea4ea8fd 100644 --- a/btcutil/bech32/example_test.go +++ b/address/bech32/example_test.go @@ -8,7 +8,7 @@ import ( "encoding/hex" "fmt" - "github.com/btcsuite/btcd/btcutil/bech32" + "github.com/btcsuite/btcd/address/v2/bech32" ) // This example demonstrates how to decode a bech32 encoded string. diff --git a/btcutil/bech32/version.go b/address/bech32/version.go similarity index 100% rename from btcutil/bech32/version.go rename to address/bech32/version.go diff --git a/address/go.mod b/address/go.mod new file mode 100644 index 0000000000..42ef34e26a --- /dev/null +++ b/address/go.mod @@ -0,0 +1,28 @@ +module github.com/btcsuite/btcd/address/v2 + +require ( + github.com/btcsuite/btcd/btcec/v2 v2.3.2 + github.com/btcsuite/btcd/chaincfg/v2 v2.0.0 + github.com/btcsuite/btcd/wire/v2 v2.0.0 + golang.org/x/crypto v0.17.0 +) + +require ( + github.com/btcsuite/btcd/chainhash/v2 v2.0.0 // indirect + github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect + golang.org/x/sys v0.15.0 // indirect +) + +// TODO(guggero): Remove this as soon as we have a tagged version of btcec. +replace github.com/btcsuite/btcd/btcec/v2 => ../btcec + +// TODO(guggero): Remove this as soon as we have a tagged version of chaincfg. +replace github.com/btcsuite/btcd/chaincfg/v2 => ../chaincfg + +// TODO(guggero): Remove this as soon as we have a tagged version of chainhash. +replace github.com/btcsuite/btcd/chainhash/v2 => ../chainhash + +// TODO(guggero): Remove this as soon as we have a tagged version of wire. +replace github.com/btcsuite/btcd/wire/v2 => ../wire + +go 1.17 diff --git a/address/go.sum b/address/go.sum new file mode 100644 index 0000000000..546c86769e --- /dev/null +++ b/address/go.sum @@ -0,0 +1,61 @@ +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc= +github.com/decred/dcrd/crypto/blake256 v1.0.1/go.mod h1:2OfgNZ5wDpcsFmHmCK5gZTPcCXqlm2ArzUIkw9czNJo= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 h1:8UrgZ3GkP4i/CLijOJx79Yu+etlyjdBU4sfcs2WYQMs= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= +golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= +golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= +golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= +golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= +golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= +golang.org/x/term v0.15.0/go.mod h1:BDl952bC7+uMoWR75FIrCDx79TPU9oHkTZ9yRbYOrX0= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= +golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/btcutil/hash160.go b/address/hash160.go similarity index 97% rename from btcutil/hash160.go rename to address/hash160.go index fa26e09bf9..0575fa72e8 100644 --- a/btcutil/hash160.go +++ b/address/hash160.go @@ -2,7 +2,7 @@ // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. -package btcutil +package address import ( "crypto/sha256" diff --git a/address/internal_test.go b/address/internal_test.go new file mode 100644 index 0000000000..39a9b88328 --- /dev/null +++ b/address/internal_test.go @@ -0,0 +1,134 @@ +// Copyright (c) 2013-2017 The btcsuite developers +// Use of this source code is governed by an ISC +// license that can be found in the LICENSE file. + +/* +This test file is part of the address package rather than the +address_test package, so it can bridge access to the internals to properly test +cases which are either not possible or can't reliably be tested via the public +interface. The functions are only exported while the tests are being run. +*/ + +package address + +import ( + "github.com/btcsuite/btcd/address/v2/base58" + "github.com/btcsuite/btcd/address/v2/bech32" + "github.com/btcsuite/btcd/btcec/v2" + "golang.org/x/crypto/ripemd160" +) + +// TstAddressPubKeyHash makes an AddressPubKeyHash, setting the +// unexported fields with the parameters hash and netID. +func TstAddressPubKeyHash(hash [ripemd160.Size]byte, + netID byte) *AddressPubKeyHash { + + return &AddressPubKeyHash{ + hash: hash, + netID: netID, + } +} + +// TstAddressScriptHash makes an AddressScriptHash, setting the +// unexported fields with the parameters hash and netID. +func TstAddressScriptHash(hash [ripemd160.Size]byte, + netID byte) *AddressScriptHash { + + return &AddressScriptHash{ + hash: hash, + netID: netID, + } +} + +// TstAddressWitnessPubKeyHash creates an AddressWitnessPubKeyHash, initiating +// the fields as given. +func TstAddressWitnessPubKeyHash(version byte, program [20]byte, + hrp string) *AddressWitnessPubKeyHash { + + return &AddressWitnessPubKeyHash{ + AddressSegWit{ + hrp: hrp, + witnessVersion: version, + witnessProgram: program[:], + }, + } +} + +// TstAddressWitnessScriptHash creates an AddressWitnessScriptHash, initiating +// the fields as given. +func TstAddressWitnessScriptHash(version byte, program [32]byte, + hrp string) *AddressWitnessScriptHash { + + return &AddressWitnessScriptHash{ + AddressSegWit{ + hrp: hrp, + witnessVersion: version, + witnessProgram: program[:], + }, + } +} + +// TstAddressTaproot creates an AddressTaproot, initiating the fields as given. +func TstAddressTaproot(version byte, program [32]byte, + hrp string) *AddressTaproot { + + return &AddressTaproot{ + AddressSegWit{ + hrp: hrp, + witnessVersion: version, + witnessProgram: program[:], + }, + } +} + +// TstAddressPubKey makes an AddressPubKey, setting the unexported fields with +// the parameters. +func TstAddressPubKey(serializedPubKey []byte, pubKeyFormat PubKeyFormat, + netID byte) *AddressPubKey { + + pubKey, _ := btcec.ParsePubKey(serializedPubKey) + return &AddressPubKey{ + pubKeyFormat: pubKeyFormat, + pubKey: pubKey, + pubKeyHashID: netID, + } +} + +// TstAddressSAddr returns the expected script address bytes for +// P2PKH and P2SH bitcoin addresses. +func TstAddressSAddr(addr string) []byte { + decoded := base58.Decode(addr) + return decoded[1 : 1+ripemd160.Size] +} + +// TstAddressSegwitSAddr returns the expected witness program bytes for +// bech32 encoded P2WPKH and P2WSH bitcoin addresses. +func TstAddressSegwitSAddr(addr string) []byte { + _, data, err := bech32.Decode(addr) + if err != nil { + return []byte{} + } + + // First byte is version, rest is base 32 encoded data. + data, err = bech32.ConvertBits(data[1:], 5, 8, false) + if err != nil { + return []byte{} + } + return data +} + +// TstAddressTaprootSAddr returns the expected witness program bytes for a +// bech32m encoded P2TR bitcoin address. +func TstAddressTaprootSAddr(addr string) []byte { + _, data, err := bech32.Decode(addr) + if err != nil { + return []byte{} + } + + // First byte is version, rest is base 32 encoded data. + data, err = bech32.ConvertBits(data[1:], 5, 8, false) + if err != nil { + return []byte{} + } + return data +} diff --git a/btcutil/internal_test.go b/btcutil/internal_test.go index 211b6ae64b..e1a210615b 100644 --- a/btcutil/internal_test.go +++ b/btcutil/internal_test.go @@ -11,13 +11,6 @@ interface. The functions are only exported while the tests are being run. package btcutil -import ( - "github.com/btcsuite/btcd/btcec/v2" - "github.com/btcsuite/btcd/btcutil/base58" - "github.com/btcsuite/btcd/btcutil/bech32" - "golang.org/x/crypto/ripemd160" -) - // SetBlockBytes sets the internal serialized block byte buffer to the passed // buffer. It is used to inject errors and is only available to the test // package. @@ -30,118 +23,3 @@ func (b *Block) SetBlockBytes(buf []byte) { func TstAppDataDir(goos, appName string, roaming bool) string { return appDataDir(goos, appName, roaming) } - -// TstAddressPubKeyHash makes an AddressPubKeyHash, setting the -// unexported fields with the parameters hash and netID. -func TstAddressPubKeyHash(hash [ripemd160.Size]byte, - netID byte) *AddressPubKeyHash { - - return &AddressPubKeyHash{ - hash: hash, - netID: netID, - } -} - -// TstAddressScriptHash makes an AddressScriptHash, setting the -// unexported fields with the parameters hash and netID. -func TstAddressScriptHash(hash [ripemd160.Size]byte, - netID byte) *AddressScriptHash { - - return &AddressScriptHash{ - hash: hash, - netID: netID, - } -} - -// TstAddressWitnessPubKeyHash creates an AddressWitnessPubKeyHash, initiating -// the fields as given. -func TstAddressWitnessPubKeyHash(version byte, program [20]byte, - hrp string) *AddressWitnessPubKeyHash { - - return &AddressWitnessPubKeyHash{ - AddressSegWit{ - hrp: hrp, - witnessVersion: version, - witnessProgram: program[:], - }, - } -} - -// TstAddressWitnessScriptHash creates an AddressWitnessScriptHash, initiating -// the fields as given. -func TstAddressWitnessScriptHash(version byte, program [32]byte, - hrp string) *AddressWitnessScriptHash { - - return &AddressWitnessScriptHash{ - AddressSegWit{ - hrp: hrp, - witnessVersion: version, - witnessProgram: program[:], - }, - } -} - -// TstAddressTaproot creates an AddressTaproot, initiating the fields as given. -func TstAddressTaproot(version byte, program [32]byte, - hrp string) *AddressTaproot { - - return &AddressTaproot{ - AddressSegWit{ - hrp: hrp, - witnessVersion: version, - witnessProgram: program[:], - }, - } -} - -// TstAddressPubKey makes an AddressPubKey, setting the unexported fields with -// the parameters. -func TstAddressPubKey(serializedPubKey []byte, pubKeyFormat PubKeyFormat, - netID byte) *AddressPubKey { - - pubKey, _ := btcec.ParsePubKey(serializedPubKey) - return &AddressPubKey{ - pubKeyFormat: pubKeyFormat, - pubKey: pubKey, - pubKeyHashID: netID, - } -} - -// TstAddressSAddr returns the expected script address bytes for -// P2PKH and P2SH bitcoin addresses. -func TstAddressSAddr(addr string) []byte { - decoded := base58.Decode(addr) - return decoded[1 : 1+ripemd160.Size] -} - -// TstAddressSegwitSAddr returns the expected witness program bytes for -// bech32 encoded P2WPKH and P2WSH bitcoin addresses. -func TstAddressSegwitSAddr(addr string) []byte { - _, data, err := bech32.Decode(addr) - if err != nil { - return []byte{} - } - - // First byte is version, rest is base 32 encoded data. - data, err = bech32.ConvertBits(data[1:], 5, 8, false) - if err != nil { - return []byte{} - } - return data -} - -// TstAddressTaprootSAddr returns the expected witness program bytes for a -// bech32m encoded P2TR bitcoin address. -func TstAddressTaprootSAddr(addr string) []byte { - _, data, err := bech32.Decode(addr) - if err != nil { - return []byte{} - } - - // First byte is version, rest is base 32 encoded data. - data, err = bech32.ConvertBits(data[1:], 5, 8, false) - if err != nil { - return []byte{} - } - return data -} From 913cce6f221bf836ffcf555a2ec14f82c17d1ae7 Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Tue, 19 Dec 2023 14:12:48 +0100 Subject: [PATCH 06/10] txscript: turn into own module, use v2 --- txscript/bench_test.go | 4 +- txscript/engine.go | 4 +- txscript/engine_debug_test.go | 2 +- txscript/engine_test.go | 4 +- txscript/example_test.go | 22 +++--- txscript/go.mod | 44 +++++++++++ txscript/go.sum | 115 +++++++++++++++++++++++++++ txscript/hashcache.go | 4 +- txscript/hashcache_test.go | 2 +- txscript/opcode.go | 7 +- txscript/pkscript.go | 8 +- txscript/pkscript_test.go | 2 +- txscript/reference_test.go | 53 ++++++++++--- txscript/script.go | 2 +- txscript/script_test.go | 2 +- txscript/sigcache.go | 2 +- txscript/sigcache_test.go | 2 +- txscript/sighash.go | 4 +- txscript/sign.go | 31 ++++---- txscript/sign_test.go | 144 +++++++++++++++++----------------- txscript/sigvalidate.go | 4 +- txscript/standard.go | 57 +++++++------- txscript/standard_test.go | 119 ++++++++++++++-------------- txscript/taproot.go | 4 +- txscript/taproot_test.go | 5 +- 25 files changed, 419 insertions(+), 228 deletions(-) create mode 100644 txscript/go.mod create mode 100644 txscript/go.sum diff --git a/txscript/bench_test.go b/txscript/bench_test.go index 0d1aa91468..60232eeb69 100644 --- a/txscript/bench_test.go +++ b/txscript/bench_test.go @@ -10,8 +10,8 @@ import ( "io/ioutil" "testing" - "github.com/btcsuite/btcd/chaincfg" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/chaincfg/v2" + "github.com/btcsuite/btcd/wire/v2" ) var ( diff --git a/txscript/engine.go b/txscript/engine.go index 30206152b8..c7ffa50388 100644 --- a/txscript/engine.go +++ b/txscript/engine.go @@ -13,8 +13,8 @@ import ( "strings" "github.com/btcsuite/btcd/btcec/v2" - "github.com/btcsuite/btcd/chaincfg/chainhash" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/chainhash/v2" + "github.com/btcsuite/btcd/wire/v2" ) // ScriptFlags is a bitmask defining additional operations or tests that will be diff --git a/txscript/engine_debug_test.go b/txscript/engine_debug_test.go index 5ebfe3f3cf..6243fc4a1c 100644 --- a/txscript/engine_debug_test.go +++ b/txscript/engine_debug_test.go @@ -9,7 +9,7 @@ import ( "github.com/btcsuite/btcd/btcec/v2" "github.com/btcsuite/btcd/btcec/v2/schnorr" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/wire/v2" "github.com/stretchr/testify/require" ) diff --git a/txscript/engine_test.go b/txscript/engine_test.go index 51a899be33..67c4550bf7 100644 --- a/txscript/engine_test.go +++ b/txscript/engine_test.go @@ -8,8 +8,8 @@ package txscript import ( "testing" - "github.com/btcsuite/btcd/chaincfg/chainhash" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/chainhash/v2" + "github.com/btcsuite/btcd/wire/v2" ) // TestBadPC sets the pc to a deliberately bad result then confirms that Step diff --git a/txscript/example_test.go b/txscript/example_test.go index b8c7104b5a..bf0da517d3 100644 --- a/txscript/example_test.go +++ b/txscript/example_test.go @@ -9,12 +9,12 @@ import ( "encoding/hex" "fmt" + "github.com/btcsuite/btcd/address/v2" "github.com/btcsuite/btcd/btcec/v2" - "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/chaincfg" - "github.com/btcsuite/btcd/chaincfg/chainhash" - "github.com/btcsuite/btcd/txscript" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/chaincfg/v2" + "github.com/btcsuite/btcd/chainhash/v2" + "github.com/btcsuite/btcd/txscript/v2" + "github.com/btcsuite/btcd/wire/v2" ) // This example demonstrates creating a script which pays to a bitcoin address. @@ -26,14 +26,14 @@ func ExamplePayToAddrScript() { // the address type. It is also required for the upcoming call to // PayToAddrScript. addressStr := "12gpXQVcCL2qhTNQgyLVdCFG2Qs2px98nV" - address, err := btcutil.DecodeAddress(addressStr, &chaincfg.MainNetParams) + addr, err := address.DecodeAddress(addressStr, &chaincfg.MainNetParams) if err != nil { fmt.Println(err) return } // Create a public key script that pays to the address. - script, err := txscript.PayToAddrScript(address) + script, err := txscript.PayToAddrScript(addr) if err != nil { fmt.Println(err) return @@ -91,8 +91,8 @@ func ExampleSignTxOutput() { return } privKey, pubKey := btcec.PrivKeyFromBytes(privKeyBytes) - pubKeyHash := btcutil.Hash160(pubKey.SerializeCompressed()) - addr, err := btcutil.NewAddressPubKeyHash(pubKeyHash, + pubKeyHash := address.Hash160(pubKey.SerializeCompressed()) + addr, err := address.NewAddressPubKeyHash(pubKeyHash, &chaincfg.MainNetParams) if err != nil { fmt.Println(err) @@ -131,7 +131,7 @@ func ExampleSignTxOutput() { redeemTx.AddTxOut(txOut) // Sign the redeeming transaction. - lookupKey := func(a btcutil.Address) (*btcec.PrivateKey, bool, error) { + lookupKey := func(a address.Address) (*btcec.PrivateKey, bool, error) { // Ordinarily this function would involve looking up the private // key for the provided address, but since the only thing being // signed in this example uses the address associated with the @@ -187,7 +187,7 @@ func ExampleSignTxOutput() { func ExampleScriptTokenizer() { // Create a script to use in the example. Ordinarily this would come from // some other source. - hash160 := btcutil.Hash160([]byte("example")) + hash160 := address.Hash160([]byte("example")) script, err := txscript.NewScriptBuilder().AddOp(txscript.OP_DUP). AddOp(txscript.OP_HASH160).AddData(hash160). AddOp(txscript.OP_EQUALVERIFY).AddOp(txscript.OP_CHECKSIG).Script() diff --git a/txscript/go.mod b/txscript/go.mod new file mode 100644 index 0000000000..10afd994a1 --- /dev/null +++ b/txscript/go.mod @@ -0,0 +1,44 @@ +module github.com/btcsuite/btcd/txscript/v2 + +require ( + github.com/btcsuite/btcd/address/v2 v2.0.0 + github.com/btcsuite/btcd/btcec/v2 v2.3.2 + github.com/btcsuite/btcd/btcutil v1.1.4 + github.com/btcsuite/btcd/chaincfg/v2 v2.0.0 + github.com/btcsuite/btcd/chainhash/v2 v2.0.0 + github.com/btcsuite/btcd/wire/v2 v2.0.0 + github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f + github.com/davecgh/go-spew v1.1.1 + github.com/stretchr/testify v1.8.4 + golang.org/x/crypto v0.17.0 +) + +require ( + github.com/btcsuite/btcd v0.23.5-0.20231215221805-96c9fd8078fd // indirect + github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + golang.org/x/sys v0.15.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect +) + +require ( + github.com/decred/dcrd/crypto/blake256 v1.0.1 // indirect + github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 +) + +// TODO(guggero): Remove this as soon as we have a tagged version of address. +replace github.com/btcsuite/btcd/address/v2 => ../address + +// TODO(guggero): Remove this as soon as we have a tagged version of btcec. +replace github.com/btcsuite/btcd/btcec/v2 => ../btcec + +// TODO(guggero): Remove this as soon as we have a tagged version of chaincfg. +replace github.com/btcsuite/btcd/chaincfg/v2 => ../chaincfg + +// TODO(guggero): Remove this as soon as we have a tagged version of chainhash. +replace github.com/btcsuite/btcd/chainhash/v2 => ../chainhash + +// TODO(guggero): Remove this as soon as we have a tagged version of wire. +replace github.com/btcsuite/btcd/wire/v2 => ../wire + +go 1.19 diff --git a/txscript/go.sum b/txscript/go.sum new file mode 100644 index 0000000000..5248a07d6b --- /dev/null +++ b/txscript/go.sum @@ -0,0 +1,115 @@ +github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII= +github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ= +github.com/btcsuite/btcd v0.22.0-beta.0.20220111032746-97732e52810c/go.mod h1:tjmYdS6MLJ5/s0Fj4DbLgSbDHbEqLJrtnHecBFkdz5M= +github.com/btcsuite/btcd v0.23.5-0.20231215221805-96c9fd8078fd h1:js1gPwhcFflTZ7Nzl7WHaOTlTr5hIrR4n1NM4v9n4Kw= +github.com/btcsuite/btcd v0.23.5-0.20231215221805-96c9fd8078fd/go.mod h1:nm3Bko6zh6bWP60UxwoT5LzdGJsQJaPo6HjduXq9p6A= +github.com/btcsuite/btcd/btcutil v1.0.0/go.mod h1:Uoxwv0pqYWhD//tfTiipkxNfdhG9UrLwaeswfjfdF0A= +github.com/btcsuite/btcd/btcutil v1.1.0/go.mod h1:5OapHB7A2hBBWLm48mmw4MOHNJCcUBTwmWH/0Jn8VHE= +github.com/btcsuite/btcd/btcutil v1.1.4 h1:mWvWRLRIPuoeZsVRpc0xNCkfeNxWy1E4jIZ06ZpGI1A= +github.com/btcsuite/btcd/btcutil v1.1.4/go.mod h1:PSZZ4UitpLBWzxGd5VGOrLnmOjtPP/a6HaFo12zMs00= +github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= +github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0 h1:59Kx4K6lzOW5w6nFlA0v5+lk/6sjybR934QNHSJZPTQ= +github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= +github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f h1:bAs4lUbRJpnnkd9VhRV3jjAVU7DJVjMaK+IsvSeZvFo= +github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA= +github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg= +github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd/go.mod h1:HHNXQzUsZCxOoE+CPiyCTO6x34Zs86zZUiwtpXoGdtg= +github.com/btcsuite/goleveldb v0.0.0-20160330041536-7834afc9e8cd/go.mod h1:F+uVaaLLH7j4eDXPRvw78tMflu7Ie2bzYOH4Y8rRKBY= +github.com/btcsuite/goleveldb v1.0.0/go.mod h1:QiK9vBlgftBg6rWQIj6wFzbPfRjiykIEhBH4obrXJ/I= +github.com/btcsuite/snappy-go v0.0.0-20151229074030-0bdef8d06723/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc= +github.com/btcsuite/snappy-go v1.0.0/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc= +github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtEyQwv5/p4Mg4C0fgbePVuGr935/5ddU9Z3TmDRY= +github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs= +github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc= +github.com/decred/dcrd/crypto/blake256 v1.0.1 h1:7PltbUIQB7u/FfZ39+DGa/ShuMyJ5ilcvdfma9wOH6Y= +github.com/decred/dcrd/crypto/blake256 v1.0.1/go.mod h1:2OfgNZ5wDpcsFmHmCK5gZTPcCXqlm2ArzUIkw9czNJo= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 h1:8UrgZ3GkP4i/CLijOJx79Yu+etlyjdBU4sfcs2WYQMs= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0= +github.com/decred/dcrd/lru v1.0.0/go.mod h1:mxKOwFd7lFjN2GZYsiz/ecgqR6kkYAl+0pz0tEMk218= +github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= +github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= +github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= +github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= +github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= +github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= +github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= +github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= +github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= +github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ= +github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4= +github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= +github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= +github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= +github.com/onsi/gomega v1.4.1/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= +github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= +github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= +github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc= +golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= +golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= +golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200814200057-3d37ad5750ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= +golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= +google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= +google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= +google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= +google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= +google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= +gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/txscript/hashcache.go b/txscript/hashcache.go index 4a5f88fb24..da703f5888 100644 --- a/txscript/hashcache.go +++ b/txscript/hashcache.go @@ -10,8 +10,8 @@ import ( "math" "sync" - "github.com/btcsuite/btcd/chaincfg/chainhash" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/chainhash/v2" + "github.com/btcsuite/btcd/wire/v2" ) // calcHashPrevOuts calculates a single hash of all the previous outputs diff --git a/txscript/hashcache_test.go b/txscript/hashcache_test.go index 8d731820ec..2158cdd083 100644 --- a/txscript/hashcache_test.go +++ b/txscript/hashcache_test.go @@ -9,7 +9,7 @@ import ( "testing" "time" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/wire/v2" "github.com/davecgh/go-spew/spew" ) diff --git a/txscript/opcode.go b/txscript/opcode.go index 4918b991c5..7d3b1c506f 100644 --- a/txscript/opcode.go +++ b/txscript/opcode.go @@ -14,12 +14,11 @@ import ( "hash" "strings" - "golang.org/x/crypto/ripemd160" - "github.com/btcsuite/btcd/btcec/v2" "github.com/btcsuite/btcd/btcec/v2/ecdsa" - "github.com/btcsuite/btcd/chaincfg/chainhash" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/chainhash/v2" + "github.com/btcsuite/btcd/wire/v2" + "golang.org/x/crypto/ripemd160" ) // An opcode defines the information related to a txscript opcode. opfunc, if diff --git a/txscript/pkscript.go b/txscript/pkscript.go index 4998f97b2f..d5db651af0 100644 --- a/txscript/pkscript.go +++ b/txscript/pkscript.go @@ -5,11 +5,11 @@ import ( "errors" "fmt" + "github.com/btcsuite/btcd/address/v2" "github.com/btcsuite/btcd/btcec/v2" "github.com/btcsuite/btcd/btcec/v2/ecdsa" - "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/chaincfg" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/chaincfg/v2" + "github.com/btcsuite/btcd/wire/v2" "golang.org/x/crypto/ripemd160" ) @@ -149,7 +149,7 @@ func (s PkScript) Script() []byte { } // Address encodes the script into an address for the given chain. -func (s PkScript) Address(chainParams *chaincfg.Params) (btcutil.Address, error) { +func (s PkScript) Address(chainParams *chaincfg.Params) (address.Address, error) { _, addrs, _, err := ExtractPkScriptAddrs(s.Script(), chainParams) if err != nil { return nil, fmt.Errorf("unable to parse address: %v", err) diff --git a/txscript/pkscript_test.go b/txscript/pkscript_test.go index c82ab04e62..20f3e0c879 100644 --- a/txscript/pkscript_test.go +++ b/txscript/pkscript_test.go @@ -4,7 +4,7 @@ import ( "bytes" "testing" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/wire/v2" ) // TestParsePkScript ensures that the supported script types can be parsed diff --git a/txscript/reference_test.go b/txscript/reference_test.go index 59acdb8da7..a1862851f6 100644 --- a/txscript/reference_test.go +++ b/txscript/reference_test.go @@ -12,14 +12,15 @@ import ( "fmt" "io/fs" "io/ioutil" + "math" "path/filepath" "strconv" "strings" "testing" "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/chaincfg/chainhash" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/chainhash/v2" + "github.com/btcsuite/btcd/wire/v2" ) // scriptTestName returns a descriptive test name for the given reference script @@ -357,7 +358,7 @@ func testScripts(t *testing.T, tests [][]interface{}, useSigCache bool) { var ( witness wire.TxWitness - inputAmt btcutil.Amount + inputAmt int64 ) // When the first field of the test data is a slice it contains @@ -377,7 +378,7 @@ func testScripts(t *testing.T, tests [][]interface{}, useSigCache bool) { continue } - inputAmt, err = btcutil.NewAmount(witnessData[len(witnessData)-1].(float64)) + inputAmt, err = newAmount(witnessData[len(witnessData)-1].(float64)) if err != nil { t.Errorf("%s: can't parse input amt: %v", name, err) @@ -561,7 +562,7 @@ testloop: continue } - tx, err := btcutil.NewTxFromBytes(serializedTx) + tx, err := newTxFromBytes(serializedTx) if err != nil { t.Errorf("bad test (arg 2 not msgtx %v) %d: %v", err, i, test) @@ -648,7 +649,7 @@ testloop: }) } - for k, txin := range tx.MsgTx().TxIn { + for k, txin := range tx.TxIn { prevOut := prevOutFetcher.FetchPrevOutput( txin.PreviousOutPoint, ) @@ -660,7 +661,7 @@ testloop: // These are meant to fail, so as soon as the first // input fails the transaction has failed. (some of the // test txns have good inputs, too.. - vm, err := NewEngine(prevOut.PkScript, tx.MsgTx(), k, + vm, err := NewEngine(prevOut.PkScript, tx, k, flags, nil, nil, prevOut.Value, prevOutFetcher) if err != nil { continue testloop @@ -718,7 +719,7 @@ testloop: continue } - tx, err := btcutil.NewTxFromBytes(serializedTx) + tx, err := newTxFromBytes(serializedTx) if err != nil { t.Errorf("bad test (arg 2 not msgtx %v) %d: %v", err, i, test) @@ -805,7 +806,7 @@ testloop: }) } - for k, txin := range tx.MsgTx().TxIn { + for k, txin := range tx.TxIn { prevOut := prevOutFetcher.FetchPrevOutput( txin.PreviousOutPoint, ) @@ -814,7 +815,7 @@ testloop: k, i, test) continue testloop } - vm, err := NewEngine(prevOut.PkScript, tx.MsgTx(), k, + vm, err := NewEngine(prevOut.PkScript, tx, k, flags, nil, nil, prevOut.Value, prevOutFetcher) if err != nil { t.Errorf("test (%d:%v:%d) failed to create "+ @@ -1076,3 +1077,35 @@ func TestTaprootReferenceTests(t *testing.T) { t.Fatalf("unable to execute taproot test vectors: %v", err) } } + +func newAmount(f float64) (int64, error) { + // The amount is only considered invalid if it cannot be represented + // as an integer type. This may happen if f is NaN or +-Infinity. + switch { + case math.IsNaN(f): + fallthrough + case math.IsInf(f, 1): + fallthrough + case math.IsInf(f, -1): + return 0, errors.New("invalid bitcoin amount") + } + + return round(f * 1e8), nil +} + +func round(f float64) int64 { + if f < 0 { + return int64(f - 0.5) + } + return int64(f + 0.5) +} + +func newTxFromBytes(txBytes []byte) (*wire.MsgTx, error) { + var msgTx wire.MsgTx + err := msgTx.Deserialize(bytes.NewReader(txBytes)) + if err != nil { + return nil, err + } + + return &msgTx, nil +} diff --git a/txscript/script.go b/txscript/script.go index 18723067ee..9666dcb0b7 100644 --- a/txscript/script.go +++ b/txscript/script.go @@ -11,7 +11,7 @@ import ( "strings" "time" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/wire/v2" ) // Bip16Activation is the timestamp where BIP0016 is valid to use in the diff --git a/txscript/script_test.go b/txscript/script_test.go index a90e1940e5..a69a0ce056 100644 --- a/txscript/script_test.go +++ b/txscript/script_test.go @@ -9,7 +9,7 @@ import ( "reflect" "testing" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/wire/v2" ) // TestPushedData ensured the PushedData function extracts the expected data out diff --git a/txscript/sigcache.go b/txscript/sigcache.go index b7b1308968..5f0f9566cb 100644 --- a/txscript/sigcache.go +++ b/txscript/sigcache.go @@ -8,7 +8,7 @@ import ( "bytes" "sync" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/chainhash/v2" ) // sigCacheEntry represents an entry in the SigCache. Entries within the diff --git a/txscript/sigcache_test.go b/txscript/sigcache_test.go index f83b8350b1..bc25993fc8 100644 --- a/txscript/sigcache_test.go +++ b/txscript/sigcache_test.go @@ -10,7 +10,7 @@ import ( "github.com/btcsuite/btcd/btcec/v2" "github.com/btcsuite/btcd/btcec/v2/ecdsa" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/chainhash/v2" ) // genRandomSig returns a random message, a signature of the message under the diff --git a/txscript/sighash.go b/txscript/sighash.go index 7dc19ab5bd..b01aece863 100644 --- a/txscript/sighash.go +++ b/txscript/sighash.go @@ -13,8 +13,8 @@ import ( "io" "math" - "github.com/btcsuite/btcd/chaincfg/chainhash" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/chainhash/v2" + "github.com/btcsuite/btcd/wire/v2" ) // SigHashType represents hash type bits at the end of a signature. diff --git a/txscript/sign.go b/txscript/sign.go index 0a11e1b197..20a6d0dfda 100644 --- a/txscript/sign.go +++ b/txscript/sign.go @@ -7,13 +7,12 @@ package txscript import ( "errors" + "github.com/btcsuite/btcd/address/v2" "github.com/btcsuite/btcd/btcec/v2" - "github.com/btcsuite/btcd/btcec/v2/schnorr" - "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/btcec/v2/ecdsa" - "github.com/btcsuite/btcd/chaincfg" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/btcec/v2/schnorr" + "github.com/btcsuite/btcd/chaincfg/v2" + "github.com/btcsuite/btcd/wire/v2" ) // RawTxInWitnessSignature returns the serialized ECDA signature for the input @@ -225,7 +224,7 @@ func p2pkSignatureScript(tx *wire.MsgTx, idx int, subScript []byte, hashType Sig // the contract (i.e. nrequired signatures are provided). Since it is arguably // legal to not be able to sign any of the outputs, no error is returned. func signMultiSig(tx *wire.MsgTx, idx int, subScript []byte, hashType SigHashType, - addresses []btcutil.Address, nRequired int, kdb KeyDB) ([]byte, bool) { + addresses []address.Address, nRequired int, kdb KeyDB) ([]byte, bool) { // We start with a single OP_FALSE to work around the (now standard) // but in the reference implementation that causes a spurious pop at // the end of OP_CHECKMULTISIG. @@ -255,7 +254,7 @@ func signMultiSig(tx *wire.MsgTx, idx int, subScript []byte, hashType SigHashTyp func sign(chainParams *chaincfg.Params, tx *wire.MsgTx, idx int, subScript []byte, hashType SigHashType, kdb KeyDB, sdb ScriptDB) ([]byte, - ScriptClass, []btcutil.Address, int, error) { + ScriptClass, []address.Address, int, error) { class, addresses, nrequired, err := ExtractPkScriptAddrs(subScript, chainParams) @@ -322,7 +321,7 @@ func sign(chainParams *chaincfg.Params, tx *wire.MsgTx, idx int, // NOTE: This function is only valid for version 0 scripts. Since the function // does not accept a script version, the results are undefined for other script // versions. -func mergeMultiSig(tx *wire.MsgTx, idx int, addresses []btcutil.Address, +func mergeMultiSig(tx *wire.MsgTx, idx int, addresses []address.Address, nRequired int, pkScript, sigScript, prevScript []byte) []byte { // Nothing to merge if either the new or previous signature scripts are @@ -391,7 +390,7 @@ sigLoop: // All multisig addresses should be pubkey addresses // it is an error to call this internal function with // bad input. - pkaddr := addr.(*btcutil.AddressPubKey) + pkaddr := addr.(*address.AddressPubKey) pubKey := pkaddr.PubKey() @@ -445,7 +444,7 @@ sigLoop: // does not accept a script version, the results are undefined for other script // versions. func mergeScripts(chainParams *chaincfg.Params, tx *wire.MsgTx, idx int, - pkScript []byte, class ScriptClass, addresses []btcutil.Address, + pkScript []byte, class ScriptClass, addresses []address.Address, nRequired int, sigScript, prevScript []byte) []byte { // TODO(oga) the scripthash and multisig paths here are overly @@ -512,28 +511,28 @@ func mergeScripts(chainParams *chaincfg.Params, tx *wire.MsgTx, idx int, // KeyDB is an interface type provided to SignTxOutput, it encapsulates // any user state required to get the private keys for an address. type KeyDB interface { - GetKey(btcutil.Address) (*btcec.PrivateKey, bool, error) + GetKey(address.Address) (*btcec.PrivateKey, bool, error) } // KeyClosure implements KeyDB with a closure. -type KeyClosure func(btcutil.Address) (*btcec.PrivateKey, bool, error) +type KeyClosure func(address.Address) (*btcec.PrivateKey, bool, error) // GetKey implements KeyDB by returning the result of calling the closure. -func (kc KeyClosure) GetKey(address btcutil.Address) (*btcec.PrivateKey, bool, error) { +func (kc KeyClosure) GetKey(address address.Address) (*btcec.PrivateKey, bool, error) { return kc(address) } // ScriptDB is an interface type provided to SignTxOutput, it encapsulates any // user state required to get the scripts for an pay-to-script-hash address. type ScriptDB interface { - GetScript(btcutil.Address) ([]byte, error) + GetScript(address.Address) ([]byte, error) } // ScriptClosure implements ScriptDB with a closure. -type ScriptClosure func(btcutil.Address) ([]byte, error) +type ScriptClosure func(address.Address) ([]byte, error) // GetScript implements ScriptDB by returning the result of calling the closure. -func (sc ScriptClosure) GetScript(address btcutil.Address) ([]byte, error) { +func (sc ScriptClosure) GetScript(address address.Address) ([]byte, error) { return sc(address) } diff --git a/txscript/sign_test.go b/txscript/sign_test.go index b3cf5119d3..e09b8f2ce0 100644 --- a/txscript/sign_test.go +++ b/txscript/sign_test.go @@ -9,12 +9,12 @@ import ( "fmt" "testing" + "github.com/btcsuite/btcd/address/v2" "github.com/btcsuite/btcd/btcec/v2" "github.com/btcsuite/btcd/btcec/v2/schnorr" - "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/chaincfg" - "github.com/btcsuite/btcd/chaincfg/chainhash" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/chaincfg/v2" + "github.com/btcsuite/btcd/chainhash/v2" + "github.com/btcsuite/btcd/wire/v2" "github.com/stretchr/testify/require" ) @@ -25,12 +25,12 @@ type addressToKey struct { func mkGetKey(keys map[string]addressToKey) KeyDB { if keys == nil { - return KeyClosure(func(addr btcutil.Address) (*btcec.PrivateKey, + return KeyClosure(func(addr address.Address) (*btcec.PrivateKey, bool, error) { return nil, false, errors.New("nope") }) } - return KeyClosure(func(addr btcutil.Address) (*btcec.PrivateKey, + return KeyClosure(func(addr address.Address) (*btcec.PrivateKey, bool, error) { a2k, ok := keys[addr.EncodeAddress()] if !ok { @@ -42,11 +42,11 @@ func mkGetKey(keys map[string]addressToKey) KeyDB { func mkGetScript(scripts map[string][]byte) ScriptDB { if scripts == nil { - return ScriptClosure(func(addr btcutil.Address) ([]byte, error) { + return ScriptClosure(func(addr address.Address) ([]byte, error) { return nil, errors.New("nope") }) } - return ScriptClosure(func(addr btcutil.Address) ([]byte, error) { + return ScriptClosure(func(addr address.Address) ([]byte, error) { script, ok := scripts[addr.EncodeAddress()] if !ok { return nil, errors.New("nope") @@ -153,8 +153,8 @@ func TestSignTxOutput(t *testing.T) { } pk := key.PubKey().SerializeUncompressed() - address, err := btcutil.NewAddressPubKeyHash( - btcutil.Hash160(pk), &chaincfg.TestNet3Params) + address, err := address.NewAddressPubKeyHash( + address.Hash160(pk), &chaincfg.TestNet3Params) if err != nil { t.Errorf("failed to make address for %s: %v", msg, err) @@ -189,8 +189,8 @@ func TestSignTxOutput(t *testing.T) { } pk := key.PubKey().SerializeUncompressed() - address, err := btcutil.NewAddressPubKeyHash( - btcutil.Hash160(pk), &chaincfg.TestNet3Params) + address, err := address.NewAddressPubKeyHash( + address.Hash160(pk), &chaincfg.TestNet3Params) if err != nil { t.Errorf("failed to make address for %s: %v", msg, err) @@ -249,8 +249,8 @@ func TestSignTxOutput(t *testing.T) { } pk := key.PubKey().SerializeCompressed() - address, err := btcutil.NewAddressPubKeyHash( - btcutil.Hash160(pk), &chaincfg.TestNet3Params) + address, err := address.NewAddressPubKeyHash( + address.Hash160(pk), &chaincfg.TestNet3Params) if err != nil { t.Errorf("failed to make address for %s: %v", msg, err) @@ -287,8 +287,8 @@ func TestSignTxOutput(t *testing.T) { } pk := key.PubKey().SerializeCompressed() - address, err := btcutil.NewAddressPubKeyHash( - btcutil.Hash160(pk), &chaincfg.TestNet3Params) + address, err := address.NewAddressPubKeyHash( + address.Hash160(pk), &chaincfg.TestNet3Params) if err != nil { t.Errorf("failed to make address for %s: %v", msg, err) @@ -348,7 +348,7 @@ func TestSignTxOutput(t *testing.T) { } pk := key.PubKey().SerializeUncompressed() - address, err := btcutil.NewAddressPubKey(pk, + address, err := address.NewAddressPubKey(pk, &chaincfg.TestNet3Params) if err != nil { t.Errorf("failed to make address for %s: %v", @@ -386,7 +386,7 @@ func TestSignTxOutput(t *testing.T) { } pk := key.PubKey().SerializeUncompressed() - address, err := btcutil.NewAddressPubKey(pk, + address, err := address.NewAddressPubKey(pk, &chaincfg.TestNet3Params) if err != nil { t.Errorf("failed to make address for %s: %v", @@ -446,7 +446,7 @@ func TestSignTxOutput(t *testing.T) { } pk := key.PubKey().SerializeCompressed() - address, err := btcutil.NewAddressPubKey(pk, + address, err := address.NewAddressPubKey(pk, &chaincfg.TestNet3Params) if err != nil { t.Errorf("failed to make address for %s: %v", @@ -484,7 +484,7 @@ func TestSignTxOutput(t *testing.T) { } pk := key.PubKey().SerializeCompressed() - address, err := btcutil.NewAddressPubKey(pk, + address, err := address.NewAddressPubKey(pk, &chaincfg.TestNet3Params) if err != nil { t.Errorf("failed to make address for %s: %v", @@ -545,22 +545,22 @@ func TestSignTxOutput(t *testing.T) { } pk := key.PubKey().SerializeUncompressed() - address, err := btcutil.NewAddressPubKeyHash( - btcutil.Hash160(pk), &chaincfg.TestNet3Params) + addr, err := address.NewAddressPubKeyHash( + address.Hash160(pk), &chaincfg.TestNet3Params) if err != nil { t.Errorf("failed to make address for %s: %v", msg, err) break } - pkScript, err := PayToAddrScript(address) + pkScript, err := PayToAddrScript(addr) if err != nil { t.Errorf("failed to make pkscript "+ "for %s: %v", msg, err) break } - scriptAddr, err := btcutil.NewAddressScriptHash( + scriptAddr, err := address.NewAddressScriptHash( pkScript, &chaincfg.TestNet3Params) if err != nil { t.Errorf("failed to make p2sh addr for %s: %v", @@ -579,7 +579,7 @@ func TestSignTxOutput(t *testing.T) { if err := signAndCheck(msg, tx, i, inputAmounts[i], scriptPkScript, hashType, mkGetKey(map[string]addressToKey{ - address.EncodeAddress(): {key, false}, + addr.EncodeAddress(): {key, false}, }), mkGetScript(map[string][]byte{ scriptAddr.EncodeAddress(): pkScript, }), nil); err != nil { @@ -601,22 +601,22 @@ func TestSignTxOutput(t *testing.T) { } pk := key.PubKey().SerializeUncompressed() - address, err := btcutil.NewAddressPubKeyHash( - btcutil.Hash160(pk), &chaincfg.TestNet3Params) + addr, err := address.NewAddressPubKeyHash( + address.Hash160(pk), &chaincfg.TestNet3Params) if err != nil { t.Errorf("failed to make address for %s: %v", msg, err) break } - pkScript, err := PayToAddrScript(address) + pkScript, err := PayToAddrScript(addr) if err != nil { t.Errorf("failed to make pkscript "+ "for %s: %v", msg, err) break } - scriptAddr, err := btcutil.NewAddressScriptHash( + scriptAddr, err := address.NewAddressScriptHash( pkScript, &chaincfg.TestNet3Params) if err != nil { t.Errorf("failed to make p2sh addr for %s: %v", @@ -635,7 +635,7 @@ func TestSignTxOutput(t *testing.T) { sigScript, err := SignTxOutput(&chaincfg.TestNet3Params, tx, i, scriptPkScript, hashType, mkGetKey(map[string]addressToKey{ - address.EncodeAddress(): {key, false}, + addr.EncodeAddress(): {key, false}, }), mkGetScript(map[string][]byte{ scriptAddr.EncodeAddress(): pkScript, }), nil) @@ -650,7 +650,7 @@ func TestSignTxOutput(t *testing.T) { sigScript, err = SignTxOutput(&chaincfg.TestNet3Params, tx, i, scriptPkScript, hashType, mkGetKey(map[string]addressToKey{ - address.EncodeAddress(): {key, false}, + addr.EncodeAddress(): {key, false}, }), mkGetScript(map[string][]byte{ scriptAddr.EncodeAddress(): pkScript, }), nil) @@ -683,21 +683,21 @@ func TestSignTxOutput(t *testing.T) { } pk := key.PubKey().SerializeCompressed() - address, err := btcutil.NewAddressPubKeyHash( - btcutil.Hash160(pk), &chaincfg.TestNet3Params) + addr, err := address.NewAddressPubKeyHash( + address.Hash160(pk), &chaincfg.TestNet3Params) if err != nil { t.Errorf("failed to make address for %s: %v", msg, err) break } - pkScript, err := PayToAddrScript(address) + pkScript, err := PayToAddrScript(addr) if err != nil { t.Errorf("failed to make pkscript "+ "for %s: %v", msg, err) } - scriptAddr, err := btcutil.NewAddressScriptHash( + scriptAddr, err := address.NewAddressScriptHash( pkScript, &chaincfg.TestNet3Params) if err != nil { t.Errorf("failed to make p2sh addr for %s: %v", @@ -716,7 +716,7 @@ func TestSignTxOutput(t *testing.T) { if err := signAndCheck(msg, tx, i, inputAmounts[i], scriptPkScript, hashType, mkGetKey(map[string]addressToKey{ - address.EncodeAddress(): {key, true}, + addr.EncodeAddress(): {key, true}, }), mkGetScript(map[string][]byte{ scriptAddr.EncodeAddress(): pkScript, }), nil); err != nil { @@ -739,21 +739,21 @@ func TestSignTxOutput(t *testing.T) { } pk := key.PubKey().SerializeCompressed() - address, err := btcutil.NewAddressPubKeyHash( - btcutil.Hash160(pk), &chaincfg.TestNet3Params) + addr, err := address.NewAddressPubKeyHash( + address.Hash160(pk), &chaincfg.TestNet3Params) if err != nil { t.Errorf("failed to make address for %s: %v", msg, err) break } - pkScript, err := PayToAddrScript(address) + pkScript, err := PayToAddrScript(addr) if err != nil { t.Errorf("failed to make pkscript "+ "for %s: %v", msg, err) } - scriptAddr, err := btcutil.NewAddressScriptHash( + scriptAddr, err := address.NewAddressScriptHash( pkScript, &chaincfg.TestNet3Params) if err != nil { t.Errorf("failed to make p2sh addr for %s: %v", @@ -772,7 +772,7 @@ func TestSignTxOutput(t *testing.T) { sigScript, err := SignTxOutput(&chaincfg.TestNet3Params, tx, i, scriptPkScript, hashType, mkGetKey(map[string]addressToKey{ - address.EncodeAddress(): {key, true}, + addr.EncodeAddress(): {key, true}, }), mkGetScript(map[string][]byte{ scriptAddr.EncodeAddress(): pkScript, }), nil) @@ -787,7 +787,7 @@ func TestSignTxOutput(t *testing.T) { sigScript, err = SignTxOutput(&chaincfg.TestNet3Params, tx, i, scriptPkScript, hashType, mkGetKey(map[string]addressToKey{ - address.EncodeAddress(): {key, true}, + addr.EncodeAddress(): {key, true}, }), mkGetScript(map[string][]byte{ scriptAddr.EncodeAddress(): pkScript, }), nil) @@ -820,7 +820,7 @@ func TestSignTxOutput(t *testing.T) { } pk := key.PubKey().SerializeUncompressed() - address, err := btcutil.NewAddressPubKey(pk, + addr, err := address.NewAddressPubKey(pk, &chaincfg.TestNet3Params) if err != nil { t.Errorf("failed to make address for %s: %v", @@ -828,13 +828,13 @@ func TestSignTxOutput(t *testing.T) { break } - pkScript, err := PayToAddrScript(address) + pkScript, err := PayToAddrScript(addr) if err != nil { t.Errorf("failed to make pkscript "+ "for %s: %v", msg, err) } - scriptAddr, err := btcutil.NewAddressScriptHash( + scriptAddr, err := address.NewAddressScriptHash( pkScript, &chaincfg.TestNet3Params) if err != nil { t.Errorf("failed to make p2sh addr for %s: %v", @@ -853,7 +853,7 @@ func TestSignTxOutput(t *testing.T) { if err := signAndCheck(msg, tx, i, inputAmounts[i], scriptPkScript, hashType, mkGetKey(map[string]addressToKey{ - address.EncodeAddress(): {key, false}, + addr.EncodeAddress(): {key, false}, }), mkGetScript(map[string][]byte{ scriptAddr.EncodeAddress(): pkScript, }), nil); err != nil { @@ -876,7 +876,7 @@ func TestSignTxOutput(t *testing.T) { } pk := key.PubKey().SerializeUncompressed() - address, err := btcutil.NewAddressPubKey(pk, + addr, err := address.NewAddressPubKey(pk, &chaincfg.TestNet3Params) if err != nil { t.Errorf("failed to make address for %s: %v", @@ -884,13 +884,13 @@ func TestSignTxOutput(t *testing.T) { break } - pkScript, err := PayToAddrScript(address) + pkScript, err := PayToAddrScript(addr) if err != nil { t.Errorf("failed to make pkscript "+ "for %s: %v", msg, err) } - scriptAddr, err := btcutil.NewAddressScriptHash( + scriptAddr, err := address.NewAddressScriptHash( pkScript, &chaincfg.TestNet3Params) if err != nil { t.Errorf("failed to make p2sh addr for %s: %v", @@ -908,7 +908,7 @@ func TestSignTxOutput(t *testing.T) { sigScript, err := SignTxOutput(&chaincfg.TestNet3Params, tx, i, scriptPkScript, hashType, mkGetKey(map[string]addressToKey{ - address.EncodeAddress(): {key, false}, + addr.EncodeAddress(): {key, false}, }), mkGetScript(map[string][]byte{ scriptAddr.EncodeAddress(): pkScript, }), nil) @@ -923,7 +923,7 @@ func TestSignTxOutput(t *testing.T) { sigScript, err = SignTxOutput(&chaincfg.TestNet3Params, tx, i, scriptPkScript, hashType, mkGetKey(map[string]addressToKey{ - address.EncodeAddress(): {key, false}, + addr.EncodeAddress(): {key, false}, }), mkGetScript(map[string][]byte{ scriptAddr.EncodeAddress(): pkScript, }), nil) @@ -956,7 +956,7 @@ func TestSignTxOutput(t *testing.T) { } pk := key.PubKey().SerializeCompressed() - address, err := btcutil.NewAddressPubKey(pk, + addr, err := address.NewAddressPubKey(pk, &chaincfg.TestNet3Params) if err != nil { t.Errorf("failed to make address for %s: %v", @@ -964,13 +964,13 @@ func TestSignTxOutput(t *testing.T) { break } - pkScript, err := PayToAddrScript(address) + pkScript, err := PayToAddrScript(addr) if err != nil { t.Errorf("failed to make pkscript "+ "for %s: %v", msg, err) } - scriptAddr, err := btcutil.NewAddressScriptHash( + scriptAddr, err := address.NewAddressScriptHash( pkScript, &chaincfg.TestNet3Params) if err != nil { t.Errorf("failed to make p2sh addr for %s: %v", @@ -988,7 +988,7 @@ func TestSignTxOutput(t *testing.T) { if err := signAndCheck(msg, tx, i, inputAmounts[i], scriptPkScript, hashType, mkGetKey(map[string]addressToKey{ - address.EncodeAddress(): {key, true}, + addr.EncodeAddress(): {key, true}, }), mkGetScript(map[string][]byte{ scriptAddr.EncodeAddress(): pkScript, }), nil); err != nil { @@ -1011,7 +1011,7 @@ func TestSignTxOutput(t *testing.T) { } pk := key.PubKey().SerializeCompressed() - address, err := btcutil.NewAddressPubKey(pk, + addr, err := address.NewAddressPubKey(pk, &chaincfg.TestNet3Params) if err != nil { t.Errorf("failed to make address for %s: %v", @@ -1019,13 +1019,13 @@ func TestSignTxOutput(t *testing.T) { break } - pkScript, err := PayToAddrScript(address) + pkScript, err := PayToAddrScript(addr) if err != nil { t.Errorf("failed to make pkscript "+ "for %s: %v", msg, err) } - scriptAddr, err := btcutil.NewAddressScriptHash( + scriptAddr, err := address.NewAddressScriptHash( pkScript, &chaincfg.TestNet3Params) if err != nil { t.Errorf("failed to make p2sh addr for %s: %v", @@ -1043,7 +1043,7 @@ func TestSignTxOutput(t *testing.T) { sigScript, err := SignTxOutput(&chaincfg.TestNet3Params, tx, i, scriptPkScript, hashType, mkGetKey(map[string]addressToKey{ - address.EncodeAddress(): {key, true}, + addr.EncodeAddress(): {key, true}, }), mkGetScript(map[string][]byte{ scriptAddr.EncodeAddress(): pkScript, }), nil) @@ -1058,7 +1058,7 @@ func TestSignTxOutput(t *testing.T) { sigScript, err = SignTxOutput(&chaincfg.TestNet3Params, tx, i, scriptPkScript, hashType, mkGetKey(map[string]addressToKey{ - address.EncodeAddress(): {key, true}, + addr.EncodeAddress(): {key, true}, }), mkGetScript(map[string][]byte{ scriptAddr.EncodeAddress(): pkScript, }), nil) @@ -1091,7 +1091,7 @@ func TestSignTxOutput(t *testing.T) { } pk1 := key1.PubKey().SerializeCompressed() - address1, err := btcutil.NewAddressPubKey(pk1, + address1, err := address.NewAddressPubKey(pk1, &chaincfg.TestNet3Params) if err != nil { t.Errorf("failed to make address for %s: %v", @@ -1107,7 +1107,7 @@ func TestSignTxOutput(t *testing.T) { } pk2 := key2.PubKey().SerializeCompressed() - address2, err := btcutil.NewAddressPubKey(pk2, + address2, err := address.NewAddressPubKey(pk2, &chaincfg.TestNet3Params) if err != nil { t.Errorf("failed to make address 2 for %s: %v", @@ -1116,14 +1116,14 @@ func TestSignTxOutput(t *testing.T) { } pkScript, err := MultiSigScript( - []*btcutil.AddressPubKey{address1, address2}, + []*address.AddressPubKey{address1, address2}, 2) if err != nil { t.Errorf("failed to make pkscript "+ "for %s: %v", msg, err) } - scriptAddr, err := btcutil.NewAddressScriptHash( + scriptAddr, err := address.NewAddressScriptHash( pkScript, &chaincfg.TestNet3Params) if err != nil { t.Errorf("failed to make p2sh addr for %s: %v", @@ -1165,7 +1165,7 @@ func TestSignTxOutput(t *testing.T) { } pk1 := key1.PubKey().SerializeCompressed() - address1, err := btcutil.NewAddressPubKey(pk1, + address1, err := address.NewAddressPubKey(pk1, &chaincfg.TestNet3Params) if err != nil { t.Errorf("failed to make address for %s: %v", @@ -1181,7 +1181,7 @@ func TestSignTxOutput(t *testing.T) { } pk2 := key2.PubKey().SerializeCompressed() - address2, err := btcutil.NewAddressPubKey(pk2, + address2, err := address.NewAddressPubKey(pk2, &chaincfg.TestNet3Params) if err != nil { t.Errorf("failed to make address 2 for %s: %v", @@ -1190,14 +1190,14 @@ func TestSignTxOutput(t *testing.T) { } pkScript, err := MultiSigScript( - []*btcutil.AddressPubKey{address1, address2}, + []*address.AddressPubKey{address1, address2}, 2) if err != nil { t.Errorf("failed to make pkscript "+ "for %s: %v", msg, err) } - scriptAddr, err := btcutil.NewAddressScriptHash( + scriptAddr, err := address.NewAddressScriptHash( pkScript, &chaincfg.TestNet3Params) if err != nil { t.Errorf("failed to make p2sh addr for %s: %v", @@ -1269,7 +1269,7 @@ func TestSignTxOutput(t *testing.T) { } pk1 := key1.PubKey().SerializeCompressed() - address1, err := btcutil.NewAddressPubKey(pk1, + address1, err := address.NewAddressPubKey(pk1, &chaincfg.TestNet3Params) if err != nil { t.Errorf("failed to make address for %s: %v", @@ -1285,7 +1285,7 @@ func TestSignTxOutput(t *testing.T) { } pk2 := key2.PubKey().SerializeCompressed() - address2, err := btcutil.NewAddressPubKey(pk2, + address2, err := address.NewAddressPubKey(pk2, &chaincfg.TestNet3Params) if err != nil { t.Errorf("failed to make address 2 for %s: %v", @@ -1294,14 +1294,14 @@ func TestSignTxOutput(t *testing.T) { } pkScript, err := MultiSigScript( - []*btcutil.AddressPubKey{address1, address2}, + []*address.AddressPubKey{address1, address2}, 2) if err != nil { t.Errorf("failed to make pkscript "+ "for %s: %v", msg, err) } - scriptAddr, err := btcutil.NewAddressScriptHash( + scriptAddr, err := address.NewAddressScriptHash( pkScript, &chaincfg.TestNet3Params) if err != nil { t.Errorf("failed to make p2sh addr for %s: %v", diff --git a/txscript/sigvalidate.go b/txscript/sigvalidate.go index 0bd00c326d..b993ae4fce 100644 --- a/txscript/sigvalidate.go +++ b/txscript/sigvalidate.go @@ -10,8 +10,8 @@ import ( "github.com/btcsuite/btcd/btcec/v2" "github.com/btcsuite/btcd/btcec/v2/ecdsa" "github.com/btcsuite/btcd/btcec/v2/schnorr" - "github.com/btcsuite/btcd/chaincfg/chainhash" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/chainhash/v2" + "github.com/btcsuite/btcd/wire/v2" ) // signatureVerifier is an abstract interface that allows the op code execution diff --git a/txscript/standard.go b/txscript/standard.go index 5ef2ad167f..a5a8ad8b67 100644 --- a/txscript/standard.go +++ b/txscript/standard.go @@ -7,9 +7,9 @@ package txscript import ( "fmt" - "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/chaincfg" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/address/v2" + "github.com/btcsuite/btcd/chaincfg/v2" + "github.com/btcsuite/btcd/wire/v2" ) const ( @@ -831,44 +831,44 @@ func payToPubKeyScript(serializedPubKey []byte) ([]byte, error) { // PayToAddrScript creates a new script to pay a transaction output to a the // specified address. -func PayToAddrScript(addr btcutil.Address) ([]byte, error) { +func PayToAddrScript(addr address.Address) ([]byte, error) { const nilAddrErrStr = "unable to generate payment script for nil address" switch addr := addr.(type) { - case *btcutil.AddressPubKeyHash: + case *address.AddressPubKeyHash: if addr == nil { return nil, scriptError(ErrUnsupportedAddress, nilAddrErrStr) } return payToPubKeyHashScript(addr.ScriptAddress()) - case *btcutil.AddressScriptHash: + case *address.AddressScriptHash: if addr == nil { return nil, scriptError(ErrUnsupportedAddress, nilAddrErrStr) } return payToScriptHashScript(addr.ScriptAddress()) - case *btcutil.AddressPubKey: + case *address.AddressPubKey: if addr == nil { return nil, scriptError(ErrUnsupportedAddress, nilAddrErrStr) } return payToPubKeyScript(addr.ScriptAddress()) - case *btcutil.AddressWitnessPubKeyHash: + case *address.AddressWitnessPubKeyHash: if addr == nil { return nil, scriptError(ErrUnsupportedAddress, nilAddrErrStr) } return payToWitnessPubKeyHashScript(addr.ScriptAddress()) - case *btcutil.AddressWitnessScriptHash: + case *address.AddressWitnessScriptHash: if addr == nil { return nil, scriptError(ErrUnsupportedAddress, nilAddrErrStr) } return payToWitnessScriptHashScript(addr.ScriptAddress()) - case *btcutil.AddressTaproot: + case *address.AddressTaproot: if addr == nil { return nil, scriptError(ErrUnsupportedAddress, nilAddrErrStr) @@ -898,7 +898,7 @@ func NullDataScript(data []byte) ([]byte, error) { // nrequired of the keys in pubkeys are required to have signed the transaction // for success. An Error with the error code ErrTooManyRequiredSigs will be // returned if nrequired is larger than the number of keys provided. -func MultiSigScript(pubkeys []*btcutil.AddressPubKey, nrequired int) ([]byte, error) { +func MultiSigScript(pubkeys []*address.AddressPubKey, nrequired int) ([]byte, error) { if len(pubkeys) < nrequired { str := fmt.Sprintf("unable to generate multisig script with "+ "%d required signatures when there are only %d public "+ @@ -939,10 +939,10 @@ func PushedData(script []byte) ([][]byte, error) { // pubKeyHashToAddrs is a convenience function to attempt to convert the // passed hash to a pay-to-pubkey-hash address housed within an address // slice. It is used to consolidate common code. -func pubKeyHashToAddrs(hash []byte, params *chaincfg.Params) []btcutil.Address { +func pubKeyHashToAddrs(hash []byte, params *chaincfg.Params) []address.Address { // Skip the pubkey hash if it's invalid for some reason. - var addrs []btcutil.Address - addr, err := btcutil.NewAddressPubKeyHash(hash, params) + var addrs []address.Address + addr, err := address.NewAddressPubKeyHash(hash, params) if err == nil { addrs = append(addrs, addr) } @@ -952,10 +952,10 @@ func pubKeyHashToAddrs(hash []byte, params *chaincfg.Params) []btcutil.Address { // scriptHashToAddrs is a convenience function to attempt to convert the passed // hash to a pay-to-script-hash address housed within an address slice. It is // used to consolidate common code. -func scriptHashToAddrs(hash []byte, params *chaincfg.Params) []btcutil.Address { +func scriptHashToAddrs(hash []byte, params *chaincfg.Params) []address.Address { // Skip the hash if it's invalid for some reason. - var addrs []btcutil.Address - addr, err := btcutil.NewAddressScriptHashFromHash(hash, params) + var addrs []address.Address + addr, err := address.NewAddressScriptHashFromHash(hash, params) if err == nil { addrs = append(addrs, addr) } @@ -967,7 +967,8 @@ func scriptHashToAddrs(hash []byte, params *chaincfg.Params) []btcutil.Address { // 'standard' transaction script types. Any data such as public keys which are // invalid are omitted from the results. func ExtractPkScriptAddrs(pkScript []byte, - chainParams *chaincfg.Params) (ScriptClass, []btcutil.Address, int, error) { + chainParams *chaincfg.Params) (ScriptClass, []address.Address, int, + error) { // Check for pay-to-pubkey-hash script. if hash := extractPubKeyHash(pkScript); hash != nil { @@ -981,8 +982,8 @@ func ExtractPkScriptAddrs(pkScript []byte, // Check for pay-to-pubkey script. if data := extractPubKey(pkScript); data != nil { - var addrs []btcutil.Address - addr, err := btcutil.NewAddressPubKey(data, chainParams) + var addrs []address.Address + addr, err := address.NewAddressPubKey(data, chainParams) if err == nil { addrs = append(addrs, addr) } @@ -994,9 +995,9 @@ func ExtractPkScriptAddrs(pkScript []byte, details := extractMultisigScriptDetails(scriptVersion, pkScript, true) if details.valid { // Convert the public keys while skipping any that are invalid. - addrs := make([]btcutil.Address, 0, len(details.pubKeys)) + addrs := make([]address.Address, 0, len(details.pubKeys)) for _, pubkey := range details.pubKeys { - addr, err := btcutil.NewAddressPubKey(pubkey, chainParams) + addr, err := address.NewAddressPubKey(pubkey, chainParams) if err == nil { addrs = append(addrs, addr) } @@ -1011,8 +1012,8 @@ func ExtractPkScriptAddrs(pkScript []byte, } if hash := extractWitnessPubKeyHash(pkScript); hash != nil { - var addrs []btcutil.Address - addr, err := btcutil.NewAddressWitnessPubKeyHash(hash, chainParams) + var addrs []address.Address + addr, err := address.NewAddressWitnessPubKeyHash(hash, chainParams) if err == nil { addrs = append(addrs, addr) } @@ -1020,8 +1021,8 @@ func ExtractPkScriptAddrs(pkScript []byte, } if hash := extractWitnessV0ScriptHash(pkScript); hash != nil { - var addrs []btcutil.Address - addr, err := btcutil.NewAddressWitnessScriptHash(hash, chainParams) + var addrs []address.Address + addr, err := address.NewAddressWitnessScriptHash(hash, chainParams) if err == nil { addrs = append(addrs, addr) } @@ -1029,8 +1030,8 @@ func ExtractPkScriptAddrs(pkScript []byte, } if rawKey := extractWitnessV1KeyBytes(pkScript); rawKey != nil { - var addrs []btcutil.Address - addr, err := btcutil.NewAddressTaproot(rawKey, chainParams) + var addrs []address.Address + addr, err := address.NewAddressTaproot(rawKey, chainParams) if err == nil { addrs = append(addrs, addr) } diff --git a/txscript/standard_test.go b/txscript/standard_test.go index 283e2ccb7b..986b2c6b5b 100644 --- a/txscript/standard_test.go +++ b/txscript/standard_test.go @@ -11,9 +11,9 @@ import ( "reflect" "testing" - "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/chaincfg" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/address/v2" + "github.com/btcsuite/btcd/chaincfg/v2" + "github.com/btcsuite/btcd/wire/v2" ) // mustParseShortForm parses the passed short form script and returns the @@ -30,12 +30,12 @@ func mustParseShortForm(script string) []byte { return s } -// newAddressPubKey returns a new btcutil.AddressPubKey from the provided +// newAddressPubKey returns a new address.AddressPubKey from the provided // serialized public key. It panics if an error occurs. This is only used in // 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, +func newAddressPubKey(serializedPubKey []byte) address.Address { + addr, err := address.NewAddressPubKey(serializedPubKey, &chaincfg.MainNetParams) if err != nil { panic("invalid public key in test source") @@ -44,12 +44,12 @@ func newAddressPubKey(serializedPubKey []byte) btcutil.Address { return addr } -// newAddressPubKeyHash returns a new btcutil.AddressPubKeyHash from the +// newAddressPubKeyHash returns a new address.AddressPubKeyHash from the // provided hash. It panics if an error occurs. This is only used in the tests // as a helper since the only way it can fail is if there is an error in the // test source code. -func newAddressPubKeyHash(pkHash []byte) btcutil.Address { - addr, err := btcutil.NewAddressPubKeyHash(pkHash, &chaincfg.MainNetParams) +func newAddressPubKeyHash(pkHash []byte) address.Address { + addr, err := address.NewAddressPubKeyHash(pkHash, &chaincfg.MainNetParams) if err != nil { panic("invalid public key hash in test source") } @@ -57,12 +57,12 @@ func newAddressPubKeyHash(pkHash []byte) btcutil.Address { return addr } -// newAddressScriptHash returns a new btcutil.AddressScriptHash from the +// newAddressScriptHash returns a new address.AddressScriptHash from the // provided hash. It panics if an error occurs. This is only used in the tests // as a helper since the only way it can fail is if there is an error in the // test source code. -func newAddressScriptHash(scriptHash []byte) btcutil.Address { - addr, err := btcutil.NewAddressScriptHashFromHash(scriptHash, +func newAddressScriptHash(scriptHash []byte) address.Address { + addr, err := address.NewAddressScriptHashFromHash(scriptHash, &chaincfg.MainNetParams) if err != nil { panic("invalid script hash in test source") @@ -71,13 +71,14 @@ func newAddressScriptHash(scriptHash []byte) btcutil.Address { return addr } -// newAddressTaproot returns a new btcutil.AddressTaproot from the +// newAddressTaproot returns a new address.AddressTaproot from the // provided hash. It panics if an error occurs. This is only used in the tests // as a helper since the only way it can fail is if there is an error in the // test source code. -func newAddressTaproot(scriptHash []byte) btcutil.Address { - addr, err := btcutil.NewAddressTaproot(scriptHash, - &chaincfg.MainNetParams) +func newAddressTaproot(scriptHash []byte) address.Address { + addr, err := address.NewAddressTaproot( + scriptHash, &chaincfg.MainNetParams, + ) if err != nil { panic("invalid script hash in test source") } @@ -93,7 +94,7 @@ func TestExtractPkScriptAddrs(t *testing.T) { tests := []struct { name string script []byte - addrs []btcutil.Address + addrs []address.Address reqSigs int class ScriptClass }{ @@ -101,7 +102,7 @@ func TestExtractPkScriptAddrs(t *testing.T) { name: "standard p2pk with compressed pubkey (0x02)", script: hexToBytes("2102192d74d0cb94344c9569c2e779015" + "73d8d7903c3ebec3a957724895dca52c6b4ac"), - addrs: []btcutil.Address{ + addrs: []address.Address{ newAddressPubKey(hexToBytes("02192d74d0cb9434" + "4c9569c2e77901573d8d7903c3ebec3a9577" + "24895dca52c6b4")), @@ -115,7 +116,7 @@ func TestExtractPkScriptAddrs(t *testing.T) { "c1eb68a382e97b1482ecad7b148a6909a5cb2e0eaddf" + "b84ccf9744464f82e160bfa9b8b64f9d4c03f999b864" + "3f656b412a3ac"), - addrs: []btcutil.Address{ + addrs: []address.Address{ newAddressPubKey(hexToBytes("0411db93e1dcdb8a" + "016b49840f8c53bc1eb68a382e97b1482eca" + "d7b148a6909a5cb2e0eaddfb84ccf9744464" + @@ -131,7 +132,7 @@ func TestExtractPkScriptAddrs(t *testing.T) { "73d8d7903c3ebec3a957724895dca52c6b40d4526483" + "8c0bd96852662ce6a847b197376830160c6d2eb5e6a4" + "c44d33f453eac"), - addrs: []btcutil.Address{ + addrs: []address.Address{ newAddressPubKey(hexToBytes("06192d74d0cb9434" + "4c9569c2e77901573d8d7903c3ebec3a9577" + "24895dca52c6b40d45264838c0bd96852662" + @@ -145,7 +146,7 @@ func TestExtractPkScriptAddrs(t *testing.T) { name: "standard p2pk with compressed pubkey (0x03)", script: hexToBytes("2103b0bd634234abbb1ba1e986e884185" + "c61cf43e001f9137f23c2c409273eb16e65ac"), - addrs: []btcutil.Address{ + addrs: []address.Address{ newAddressPubKey(hexToBytes("03b0bd634234abbb" + "1ba1e986e884185c61cf43e001f9137f23c2" + "c409273eb16e65")), @@ -159,7 +160,7 @@ func TestExtractPkScriptAddrs(t *testing.T) { "c61cf43e001f9137f23c2c409273eb16e6537a576782" + "eba668a7ef8bd3b3cfb1edb7117ab65129b8a2e681f3" + "c1e0908ef7bac"), - addrs: []btcutil.Address{ + addrs: []address.Address{ newAddressPubKey(hexToBytes("04b0bd634234abbb" + "1ba1e986e884185c61cf43e001f9137f23c2" + "c409273eb16e6537a576782eba668a7ef8bd" + @@ -175,7 +176,7 @@ func TestExtractPkScriptAddrs(t *testing.T) { "c61cf43e001f9137f23c2c409273eb16e6537a576782" + "eba668a7ef8bd3b3cfb1edb7117ab65129b8a2e681f3" + "c1e0908ef7bac"), - addrs: []btcutil.Address{ + addrs: []address.Address{ newAddressPubKey(hexToBytes("07b0bd634234abbb" + "1ba1e986e884185c61cf43e001f9137f23c2" + "c409273eb16e6537a576782eba668a7ef8bd" + @@ -189,7 +190,7 @@ func TestExtractPkScriptAddrs(t *testing.T) { name: "standard p2pkh", script: hexToBytes("76a914ad06dd6ddee55cbca9a9e3713bd" + "7587509a3056488ac"), - addrs: []btcutil.Address{ + addrs: []address.Address{ newAddressPubKeyHash(hexToBytes("ad06dd6ddee5" + "5cbca9a9e3713bd7587509a30564")), }, @@ -200,7 +201,7 @@ func TestExtractPkScriptAddrs(t *testing.T) { name: "standard p2sh", script: hexToBytes("a91463bcc565f9e68ee0189dd5cc67f1b" + "0e5f02f45cb87"), - addrs: []btcutil.Address{ + addrs: []address.Address{ newAddressScriptHash(hexToBytes("63bcc565f9e6" + "8ee0189dd5cc67f1b0e5f02f45cb")), }, @@ -217,7 +218,7 @@ func TestExtractPkScriptAddrs(t *testing.T) { "1354d80e550078cb532a34bfa2fcfdeb7d76519aecc6" + "2770f5b0e4ef8551946d8a540911abe3e7854a26f39f" + "58b25c15342af52ae"), - addrs: []btcutil.Address{ + addrs: []address.Address{ newAddressPubKey(hexToBytes("04cc71eb30d653c0" + "c3163990c47b976f3fb3f37cccdcbedb169a" + "1dfef58bbfbfaff7d8a473e7e2e6d317b87b" + @@ -245,7 +246,7 @@ func TestExtractPkScriptAddrs(t *testing.T) { "2bbf781c5410d3f22a7a3a56ffefb2238af8627363bd" + "f2ed97c1f89784a1aecdb43384f11d2acc64443c7fc2" + "99cef0400421a53ae"), - addrs: []btcutil.Address{ + addrs: []address.Address{ newAddressPubKey(hexToBytes("04cb9c3c222c5f7a" + "7d3b9bd152f363a0b6d54c9eb312c4d4f9af" + "1e8551b6c421a6a4ab0e29105f24de20ff46" + @@ -321,7 +322,7 @@ func TestExtractPkScriptAddrs(t *testing.T) { "16e20626520666f756e6420696e207472616e7361637" + "4696f6e2036633533636439383731313965663739376" + "435616463636453ae"), - addrs: []btcutil.Address{}, + addrs: []address.Address{}, reqSigs: 1, class: MultiSigTy, }, @@ -329,7 +330,7 @@ func TestExtractPkScriptAddrs(t *testing.T) { name: "v1 p2tr witness-script-hash", script: hexToBytes("51201a82f7457a9ba6ab1074e9f50" + "053eefc637f8b046e389b636766bdc7d1f676f8"), - addrs: []btcutil.Address{newAddressTaproot( + addrs: []address.Address{newAddressTaproot( hexToBytes("1a82f7457a9ba6ab1074e9f50053eefc6" + "37f8b046e389b636766bdc7d1f676f8"))}, reqSigs: 1, @@ -345,7 +346,7 @@ func TestExtractPkScriptAddrs(t *testing.T) { "13963663463303363363039633539336333653931666" + "56465373032392131323364643432643235363339643" + "338613663663530616234636434340a00000053ae"), - addrs: []btcutil.Address{}, + addrs: []address.Address{}, reqSigs: 1, class: MultiSigTy, }, @@ -587,29 +588,29 @@ func TestCalcScriptInfo(t *testing.T) { } } -// bogusAddress implements the btcutil.Address interface so the tests can ensure +// bogusAddress implements the address.Address interface so the tests can ensure // unsupported address types are handled properly. type bogusAddress struct{} // EncodeAddress simply returns an empty string. It exists to satisfy the -// btcutil.Address interface. +// address.Address interface. func (b *bogusAddress) EncodeAddress() string { return "" } // ScriptAddress simply returns an empty byte slice. It exists to satisfy the -// btcutil.Address interface. +// address.Address interface. func (b *bogusAddress) ScriptAddress() []byte { return nil } -// IsForNet lies blatantly to satisfy the btcutil.Address interface. +// IsForNet lies blatantly to satisfy the address.Address interface. func (b *bogusAddress) IsForNet(chainParams *chaincfg.Params) bool { return true // why not? } // String simply returns an empty string. It exists to satisfy the -// btcutil.Address interface. +// address.Address interface. func (b *bogusAddress) String() string { return "" } @@ -620,7 +621,7 @@ func TestPayToAddrScript(t *testing.T) { t.Parallel() // 1MirQ9bwyQcGVJPwKUgapu5ouK2E2Ey4gX - p2pkhMain, err := btcutil.NewAddressPubKeyHash(hexToBytes("e34cce70c86"+ + p2pkhMain, err := address.NewAddressPubKeyHash(hexToBytes("e34cce70c86"+ "373273efcc54ce7d2a491bb4a0e84"), &chaincfg.MainNetParams) if err != nil { t.Fatalf("Unable to create public key hash address: %v", err) @@ -628,21 +629,21 @@ func TestPayToAddrScript(t *testing.T) { // Taken from transaction: // b0539a45de13b3e0403909b8bd1a555b8cbe45fd4e3f3fda76f3a5f52835c29d - p2shMain, _ := btcutil.NewAddressScriptHashFromHash(hexToBytes("e8c300"+ + p2shMain, _ := address.NewAddressScriptHashFromHash(hexToBytes("e8c300"+ "c87986efa84c37c0519929019ef86eb5b4"), &chaincfg.MainNetParams) if err != nil { t.Fatalf("Unable to create script hash address: %v", err) } // mainnet p2pk 13CG6SJ3yHUXo4Cr2RY4THLLJrNFuG3gUg - p2pkCompressedMain, err := btcutil.NewAddressPubKey(hexToBytes("02192d"+ + p2pkCompressedMain, err := address.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"+ + p2pkCompressed2Main, err := address.NewAddressPubKey(hexToBytes("03b0b"+ "d634234abbb1ba1e986e884185c61cf43e001f9137f23c2c409273eb16e65"), &chaincfg.MainNetParams) if err != nil { @@ -650,7 +651,7 @@ func TestPayToAddrScript(t *testing.T) { err) } - p2pkUncompressedMain, err := btcutil.NewAddressPubKey(hexToBytes("0411"+ + p2pkUncompressedMain, err := address.NewAddressPubKey(hexToBytes("0411"+ "db93e1dcdb8a016b49840f8c53bc1eb68a382e97b1482ecad7b148a6909a5"+ "cb2e0eaddfb84ccf9744464f82e160bfa9b8b64f9d4c03f999b8643f656b4"+ "12a3"), &chaincfg.MainNetParams) @@ -659,21 +660,21 @@ func TestPayToAddrScript(t *testing.T) { err) } - p2wsh, err := btcutil.NewAddressWitnessScriptHash(hexToBytes("e981bd992a43650657"+ + p2wsh, err := address.NewAddressWitnessScriptHash(hexToBytes("e981bd992a43650657"+ "d705ef7a30b2adc75a927ed42a4cf6b3da0f865a475fb4"), &chaincfg.MainNetParams) if err != nil { t.Fatalf("Unable to create p2wsh address: %v", err) } - p2tr, err := btcutil.NewAddressTaproot(hexToBytes("3a8e170b546c3b122ab9c175e"+ + p2tr, err := address.NewAddressTaproot(hexToBytes("3a8e170b546c3b122ab9c175e"+ "ff36fb344db2684fe96497eb51b440e75232709"), &chaincfg.MainNetParams) if err != nil { t.Fatalf("Unable to create p2tr address: %v", err) } - p2wpkh, err := btcutil.NewAddressWitnessPubKeyHash(hexToBytes("748e50366adb8"+ + p2wpkh, err := address.NewAddressWitnessPubKeyHash(hexToBytes("748e50366adb8"+ "ae4b0255e406a28f99d24b73cbc"), &chaincfg.MainNetParams) if err != nil { t.Fatalf("Unable to create p2wpkh address: %v", @@ -685,7 +686,7 @@ func TestPayToAddrScript(t *testing.T) { errUnsupportedAddress := scriptError(ErrUnsupportedAddress, "") tests := []struct { - in btcutil.Address + in address.Address expected string err error }{ @@ -748,12 +749,12 @@ func TestPayToAddrScript(t *testing.T) { }, // Supported address types with nil pointers. - {(*btcutil.AddressPubKeyHash)(nil), "", errUnsupportedAddress}, - {(*btcutil.AddressScriptHash)(nil), "", errUnsupportedAddress}, - {(*btcutil.AddressPubKey)(nil), "", errUnsupportedAddress}, - {(*btcutil.AddressWitnessPubKeyHash)(nil), "", errUnsupportedAddress}, - {(*btcutil.AddressWitnessScriptHash)(nil), "", errUnsupportedAddress}, - {(*btcutil.AddressTaproot)(nil), "", errUnsupportedAddress}, + {(*address.AddressPubKeyHash)(nil), "", errUnsupportedAddress}, + {(*address.AddressScriptHash)(nil), "", errUnsupportedAddress}, + {(*address.AddressPubKey)(nil), "", errUnsupportedAddress}, + {(*address.AddressWitnessPubKeyHash)(nil), "", errUnsupportedAddress}, + {(*address.AddressWitnessScriptHash)(nil), "", errUnsupportedAddress}, + {(*address.AddressTaproot)(nil), "", errUnsupportedAddress}, // Unsupported address type. {&bogusAddress{}, "", errUnsupportedAddress}, @@ -783,14 +784,14 @@ func TestMultiSigScript(t *testing.T) { t.Parallel() // mainnet p2pk 13CG6SJ3yHUXo4Cr2RY4THLLJrNFuG3gUg - p2pkCompressedMain, err := btcutil.NewAddressPubKey(hexToBytes("02192d"+ + p2pkCompressedMain, err := address.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"+ + p2pkCompressed2Main, err := address.NewAddressPubKey(hexToBytes("03b0b"+ "d634234abbb1ba1e986e884185c61cf43e001f9137f23c2c409273eb16e65"), &chaincfg.MainNetParams) if err != nil { @@ -798,7 +799,7 @@ func TestMultiSigScript(t *testing.T) { err) } - p2pkUncompressedMain, err := btcutil.NewAddressPubKey(hexToBytes("0411"+ + p2pkUncompressedMain, err := address.NewAddressPubKey(hexToBytes("0411"+ "db93e1dcdb8a016b49840f8c53bc1eb68a382e97b1482ecad7b148a6909a5"+ "cb2e0eaddfb84ccf9744464f82e160bfa9b8b64f9d4c03f999b8643f656b4"+ "12a3"), &chaincfg.MainNetParams) @@ -808,13 +809,13 @@ func TestMultiSigScript(t *testing.T) { } tests := []struct { - keys []*btcutil.AddressPubKey + keys []*address.AddressPubKey nrequired int expected string err error }{ { - []*btcutil.AddressPubKey{ + []*address.AddressPubKey{ p2pkCompressedMain, p2pkCompressed2Main, }, @@ -826,7 +827,7 @@ func TestMultiSigScript(t *testing.T) { nil, }, { - []*btcutil.AddressPubKey{ + []*address.AddressPubKey{ p2pkCompressedMain, p2pkCompressed2Main, }, @@ -838,7 +839,7 @@ func TestMultiSigScript(t *testing.T) { nil, }, { - []*btcutil.AddressPubKey{ + []*address.AddressPubKey{ p2pkCompressedMain, p2pkCompressed2Main, }, @@ -847,7 +848,7 @@ func TestMultiSigScript(t *testing.T) { scriptError(ErrTooManyRequiredSigs, ""), }, { - []*btcutil.AddressPubKey{ + []*address.AddressPubKey{ p2pkUncompressedMain, }, 1, @@ -858,7 +859,7 @@ func TestMultiSigScript(t *testing.T) { nil, }, { - []*btcutil.AddressPubKey{ + []*address.AddressPubKey{ p2pkUncompressedMain, }, 2, diff --git a/txscript/taproot.go b/txscript/taproot.go index 003eb19ae3..d7ec4236b6 100644 --- a/txscript/taproot.go +++ b/txscript/taproot.go @@ -10,8 +10,8 @@ import ( "github.com/btcsuite/btcd/btcec/v2" "github.com/btcsuite/btcd/btcec/v2/schnorr" - "github.com/btcsuite/btcd/chaincfg/chainhash" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/chainhash/v2" + "github.com/btcsuite/btcd/wire/v2" secp "github.com/decred/dcrd/dcrec/secp256k1/v4" ) diff --git a/txscript/taproot_test.go b/txscript/taproot_test.go index 01b3780e9c..8136569310 100644 --- a/txscript/taproot_test.go +++ b/txscript/taproot_test.go @@ -14,9 +14,8 @@ import ( "github.com/btcsuite/btcd/btcec/v2" "github.com/btcsuite/btcd/btcec/v2/schnorr" - "github.com/btcsuite/btcd/btcutil" "github.com/btcsuite/btcd/btcutil/hdkeychain" - "github.com/btcsuite/btcd/chaincfg" + "github.com/btcsuite/btcd/chaincfg/v2" secp "github.com/decred/dcrd/dcrec/secp256k1/v4" "github.com/stretchr/testify/require" ) @@ -255,7 +254,7 @@ func TestTaprootConstructKeyPath(t *testing.T) { tapKey := ComputeTaprootKeyNoScript(pubKey) - addr, err := btcutil.NewAddressTaproot( + addr, err := address.NewAddressTaproot( schnorr.SerializePubKey(tapKey), &chaincfg.MainNetParams, ) From 86b9b9ca8897ac3336ffb40bb85e008bfebc5785 Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Tue, 19 Dec 2023 14:12:49 +0100 Subject: [PATCH 07/10] btcutil: remove circular dependency, use v2 --- btcutil/amount_test.go | 2 +- btcutil/appdata_test.go | 2 +- btcutil/block.go | 4 +- btcutil/block_test.go | 6 +- btcutil/bloom/README.md | 2 +- btcutil/bloom/example_test.go | 6 +- btcutil/bloom/filter.go | 8 +- btcutil/bloom/filter_test.go | 8 +- btcutil/bloom/merkleblock.go | 21 ++++- btcutil/bloom/merkleblock_test.go | 8 +- btcutil/bloom/murmurhash3_test.go | 2 +- btcutil/certgen_test.go | 3 +- btcutil/coinset/coins.go | 6 +- btcutil/coinset/coins_test.go | 8 +- btcutil/example_test.go | 2 +- btcutil/gcs/builder/builder.go | 8 +- btcutil/gcs/builder/builder_test.go | 14 +-- btcutil/gcs/gcs.go | 2 +- btcutil/gcs/gcs_test.go | 2 +- btcutil/gcs/gcsbench_test.go | 2 +- btcutil/go.mod | 45 +++++++-- btcutil/go.sum | 123 +++---------------------- btcutil/hdkeychain/README.md | 12 +-- btcutil/hdkeychain/bench_test.go | 2 +- btcutil/hdkeychain/example_test.go | 4 +- btcutil/hdkeychain/extendedkey.go | 20 ++-- btcutil/hdkeychain/extendedkey_test.go | 2 +- btcutil/hdkeychain/test_coverage.txt | 20 ---- btcutil/psbt/creator.go | 2 +- btcutil/psbt/extractor.go | 4 +- btcutil/psbt/finalizer.go | 4 +- btcutil/psbt/partial_input.go | 4 +- btcutil/psbt/partial_output.go | 2 +- btcutil/psbt/psbt.go | 4 +- btcutil/psbt/psbt_test.go | 8 +- btcutil/psbt/signer.go | 2 +- btcutil/psbt/sort.go | 2 +- btcutil/psbt/sort_test.go | 4 +- btcutil/psbt/taproot.go | 4 +- btcutil/psbt/updater.go | 6 +- btcutil/psbt/utils.go | 4 +- btcutil/psbt/utils_test.go | 4 +- btcutil/tx.go | 4 +- btcutil/tx_test.go | 4 +- btcutil/txsort/txsort.go | 4 +- btcutil/txsort/txsort_test.go | 4 +- btcutil/wif.go | 9 +- btcutil/wif_test.go | 4 +- txscript/go.mod | 3 - txscript/go.sum | 95 ------------------- txscript/reference_test.go | 18 ++-- txscript/taproot_test.go | 91 ++++++++---------- 52 files changed, 222 insertions(+), 412 deletions(-) delete mode 100644 btcutil/hdkeychain/test_coverage.txt diff --git a/btcutil/amount_test.go b/btcutil/amount_test.go index 69498b07e2..7be29dcaa3 100644 --- a/btcutil/amount_test.go +++ b/btcutil/amount_test.go @@ -8,7 +8,7 @@ import ( "math" "testing" - . "github.com/btcsuite/btcd/btcutil" + . "github.com/btcsuite/btcd/btcutil/v2" ) func TestAmountCreation(t *testing.T) { diff --git a/btcutil/appdata_test.go b/btcutil/appdata_test.go index 061b1b5d80..c6995a8220 100644 --- a/btcutil/appdata_test.go +++ b/btcutil/appdata_test.go @@ -12,7 +12,7 @@ import ( "testing" "unicode" - "github.com/btcsuite/btcd/btcutil" + "github.com/btcsuite/btcd/btcutil/v2" ) // TestAppDataDir tests the API for AppDataDir to ensure it gives expected diff --git a/btcutil/block.go b/btcutil/block.go index 7d38abc4a0..155e9ce68f 100644 --- a/btcutil/block.go +++ b/btcutil/block.go @@ -9,8 +9,8 @@ import ( "fmt" "io" - "github.com/btcsuite/btcd/chaincfg/chainhash" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/chainhash/v2" + "github.com/btcsuite/btcd/wire/v2" ) // OutOfRangeError describes an error due to accessing an element that is out diff --git a/btcutil/block_test.go b/btcutil/block_test.go index 06e0ad2803..e5ae9830a4 100644 --- a/btcutil/block_test.go +++ b/btcutil/block_test.go @@ -11,9 +11,9 @@ import ( "testing" "time" - "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/chaincfg/chainhash" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/btcutil/v2" + "github.com/btcsuite/btcd/chainhash/v2" + "github.com/btcsuite/btcd/wire/v2" "github.com/davecgh/go-spew/spew" ) diff --git a/btcutil/bloom/README.md b/btcutil/bloom/README.md index 4a5c937f88..1d549abf89 100644 --- a/btcutil/bloom/README.md +++ b/btcutil/bloom/README.md @@ -15,7 +15,7 @@ report. ## Installation and Updating ```bash -$ go get -u github.com/btcsuite/btcd/btcutil/bloom +$ go get -u github.com/btcsuite/btcd/btcutil/v2/bloom ``` ## Examples diff --git a/btcutil/bloom/example_test.go b/btcutil/bloom/example_test.go index e5a148a5ba..600e212507 100644 --- a/btcutil/bloom/example_test.go +++ b/btcutil/bloom/example_test.go @@ -9,9 +9,9 @@ import ( "math/rand" "time" - "github.com/btcsuite/btcd/btcutil/bloom" - "github.com/btcsuite/btcd/chaincfg/chainhash" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/btcutil/v2/bloom" + "github.com/btcsuite/btcd/chainhash/v2" + "github.com/btcsuite/btcd/wire/v2" ) // This example demonstrates how to create a new bloom filter, add a transaction diff --git a/btcutil/bloom/filter.go b/btcutil/bloom/filter.go index 2eca228570..02e04764fc 100644 --- a/btcutil/bloom/filter.go +++ b/btcutil/bloom/filter.go @@ -9,10 +9,10 @@ import ( "math" "sync" - "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/chaincfg/chainhash" - "github.com/btcsuite/btcd/txscript" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/btcutil/v2" + "github.com/btcsuite/btcd/chainhash/v2" + "github.com/btcsuite/btcd/txscript/v2" + "github.com/btcsuite/btcd/wire/v2" ) // ln2Squared is simply the square of the natural log of 2. diff --git a/btcutil/bloom/filter_test.go b/btcutil/bloom/filter_test.go index c4b839ad17..15cb06a51e 100644 --- a/btcutil/bloom/filter_test.go +++ b/btcutil/bloom/filter_test.go @@ -9,10 +9,10 @@ import ( "encoding/hex" "testing" - "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/btcutil/bloom" - "github.com/btcsuite/btcd/chaincfg/chainhash" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/btcutil/v2" + "github.com/btcsuite/btcd/btcutil/v2/bloom" + "github.com/btcsuite/btcd/chainhash/v2" + "github.com/btcsuite/btcd/wire/v2" ) // TestFilterLarge ensures a maximum sized filter can be created. diff --git a/btcutil/bloom/merkleblock.go b/btcutil/bloom/merkleblock.go index 468aa72a05..fb903ffd5b 100644 --- a/btcutil/bloom/merkleblock.go +++ b/btcutil/bloom/merkleblock.go @@ -5,10 +5,9 @@ package bloom import ( - "github.com/btcsuite/btcd/blockchain" - "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/chaincfg/chainhash" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/btcutil/v2" + "github.com/btcsuite/btcd/chainhash/v2" + "github.com/btcsuite/btcd/wire/v2" ) // merkleBlock is used to house intermediate information needed to generate a @@ -41,7 +40,7 @@ func (m *merkleBlock) calcHash(height, pos uint32) *chainhash.Hash { } else { right = left } - res := blockchain.HashMerkleBranches(left, right) + res := HashMerkleBranches(left, right) return &res } @@ -124,3 +123,15 @@ func NewMerkleBlock(block *btcutil.Block, filter *Filter) (*wire.MsgMerkleBlock, } return &msgMerkleBlock, matchedIndices } + +// HashMerkleBranches takes two hashes, treated as the left and right tree +// nodes, and returns the hash of their concatenation. This is a helper +// function used to aid in the generation of a merkle tree. +func HashMerkleBranches(left, right *chainhash.Hash) chainhash.Hash { + // Concatenate the left and right nodes. + var hash [chainhash.HashSize * 2]byte + copy(hash[:chainhash.HashSize], left[:]) + copy(hash[chainhash.HashSize:], right[:]) + + return chainhash.DoubleHashH(hash[:]) +} diff --git a/btcutil/bloom/merkleblock_test.go b/btcutil/bloom/merkleblock_test.go index ae7b1f3430..0e5fc0049d 100644 --- a/btcutil/bloom/merkleblock_test.go +++ b/btcutil/bloom/merkleblock_test.go @@ -9,10 +9,10 @@ import ( "encoding/hex" "testing" - "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/btcutil/bloom" - "github.com/btcsuite/btcd/chaincfg/chainhash" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/btcutil/v2/bloom" + "github.com/btcsuite/btcd/btcutil/v2" + "github.com/btcsuite/btcd/chainhash/v2" + "github.com/btcsuite/btcd/wire/v2" ) func TestMerkleBlock3(t *testing.T) { diff --git a/btcutil/bloom/murmurhash3_test.go b/btcutil/bloom/murmurhash3_test.go index 9c102d5f8c..2916f251c5 100644 --- a/btcutil/bloom/murmurhash3_test.go +++ b/btcutil/bloom/murmurhash3_test.go @@ -7,7 +7,7 @@ package bloom_test import ( "testing" - "github.com/btcsuite/btcd/btcutil/bloom" + "github.com/btcsuite/btcd/btcutil/v2/bloom" ) // TestMurmurHash3 ensure the MurmurHash3 function produces the correct hash diff --git a/btcutil/certgen_test.go b/btcutil/certgen_test.go index 81aeea5d6a..66cd6a157c 100644 --- a/btcutil/certgen_test.go +++ b/btcutil/certgen_test.go @@ -11,8 +11,7 @@ import ( "testing" "time" - "github.com/btcsuite/btcd/btcutil" - //"github.com/davecgh/go-spew/spew" + "github.com/btcsuite/btcd/btcutil/v2" ) // TestNewTLSCertPair ensures the NewTLSCertPair function works as expected. diff --git a/btcutil/coinset/coins.go b/btcutil/coinset/coins.go index a0e680d8d6..7e551e2b69 100644 --- a/btcutil/coinset/coins.go +++ b/btcutil/coinset/coins.go @@ -9,9 +9,9 @@ import ( "errors" "sort" - "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/chaincfg/chainhash" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/btcutil/v2" + "github.com/btcsuite/btcd/chainhash/v2" + "github.com/btcsuite/btcd/wire/v2" ) // Coin represents a spendable transaction outpoint diff --git a/btcutil/coinset/coins_test.go b/btcutil/coinset/coins_test.go index 035a40cb99..b54c566642 100644 --- a/btcutil/coinset/coins_test.go +++ b/btcutil/coinset/coins_test.go @@ -11,10 +11,10 @@ import ( "fmt" "testing" - "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/btcutil/coinset" - "github.com/btcsuite/btcd/chaincfg/chainhash" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/btcutil/v2/coinset" + "github.com/btcsuite/btcd/btcutil/v2" + "github.com/btcsuite/btcd/chainhash/v2" + "github.com/btcsuite/btcd/wire/v2" ) type TestCoin struct { diff --git a/btcutil/example_test.go b/btcutil/example_test.go index 90be77b073..d4cd149f11 100644 --- a/btcutil/example_test.go +++ b/btcutil/example_test.go @@ -4,7 +4,7 @@ import ( "fmt" "math" - "github.com/btcsuite/btcd/btcutil" + "github.com/btcsuite/btcd/btcutil/v2" ) func ExampleAmount() { diff --git a/btcutil/gcs/builder/builder.go b/btcutil/gcs/builder/builder.go index 3a85ad0519..a9a6e3b01c 100644 --- a/btcutil/gcs/builder/builder.go +++ b/btcutil/gcs/builder/builder.go @@ -11,10 +11,10 @@ import ( "io" "math" - "github.com/btcsuite/btcd/btcutil/gcs" - "github.com/btcsuite/btcd/chaincfg/chainhash" - "github.com/btcsuite/btcd/txscript" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/btcutil/v2/gcs" + "github.com/btcsuite/btcd/chainhash/v2" + "github.com/btcsuite/btcd/txscript/v2" + "github.com/btcsuite/btcd/wire/v2" ) const ( diff --git a/btcutil/gcs/builder/builder_test.go b/btcutil/gcs/builder/builder_test.go index 59768380b1..f9b1100eb8 100644 --- a/btcutil/gcs/builder/builder_test.go +++ b/btcutil/gcs/builder/builder_test.go @@ -9,13 +9,13 @@ import ( "encoding/hex" "testing" - "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/btcutil/gcs" - "github.com/btcsuite/btcd/btcutil/gcs/builder" - "github.com/btcsuite/btcd/chaincfg" - "github.com/btcsuite/btcd/chaincfg/chainhash" - "github.com/btcsuite/btcd/txscript" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/btcutil/v2/gcs/builder" + "github.com/btcsuite/btcd/btcutil/v2/gcs" + "github.com/btcsuite/btcd/chaincfg/v2" + "github.com/btcsuite/btcd/chainhash/v2" + "github.com/btcsuite/btcd/txscript/v2" + "github.com/btcsuite/btcd/wire/v2" + "github.com/btcsuite/btcd/btcutil/v2" ) var ( diff --git a/btcutil/gcs/gcs.go b/btcutil/gcs/gcs.go index fca315d6db..ba08b941db 100644 --- a/btcutil/gcs/gcs.go +++ b/btcutil/gcs/gcs.go @@ -12,7 +12,7 @@ import ( "sort" "github.com/aead/siphash" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/wire/v2" "github.com/kkdai/bstream" ) diff --git a/btcutil/gcs/gcs_test.go b/btcutil/gcs/gcs_test.go index 8ae49f0507..dfa6d93682 100644 --- a/btcutil/gcs/gcs_test.go +++ b/btcutil/gcs/gcs_test.go @@ -11,7 +11,7 @@ import ( "math/rand" "testing" - "github.com/btcsuite/btcd/btcutil/gcs" + "github.com/btcsuite/btcd/btcutil/v2/gcs" ) var ( diff --git a/btcutil/gcs/gcsbench_test.go b/btcutil/gcs/gcsbench_test.go index 14125a16c0..6a743160cc 100644 --- a/btcutil/gcs/gcsbench_test.go +++ b/btcutil/gcs/gcsbench_test.go @@ -10,7 +10,7 @@ import ( "math/rand" "testing" - "github.com/btcsuite/btcd/btcutil/gcs" + "github.com/btcsuite/btcd/btcutil/v2/gcs" ) func genRandFilterElements(numElements uint) ([][]byte, error) { diff --git a/btcutil/go.mod b/btcutil/go.mod index 9718e6d5fd..4b31cd5a54 100644 --- a/btcutil/go.mod +++ b/btcutil/go.mod @@ -1,14 +1,41 @@ -module github.com/btcsuite/btcd/btcutil - -go 1.16 +module github.com/btcsuite/btcd/btcutil/v2 require ( github.com/aead/siphash v1.0.1 - github.com/btcsuite/btcd v0.23.5-0.20231215221805-96c9fd8078fd - github.com/btcsuite/btcd/btcec/v2 v2.1.3 - github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0 + github.com/btcsuite/btcd/address/v2 v2.0.0 + github.com/btcsuite/btcd/btcec/v2 v2.3.2 + github.com/btcsuite/btcd/chaincfg/v2 v2.0.0 + github.com/btcsuite/btcd/chainhash/v2 v2.0.0 + github.com/btcsuite/btcd/txscript/v2 v2.0.0 + github.com/btcsuite/btcd/wire/v2 v2.0.0 github.com/davecgh/go-spew v1.1.1 - github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 - github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23 - golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 + github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 + github.com/kkdai/bstream v1.0.0 +) + +require ( + github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f // indirect + github.com/decred/dcrd/crypto/blake256 v1.0.1 // indirect + golang.org/x/crypto v0.17.0 // indirect + golang.org/x/sys v0.15.0 // indirect ) + +// TODO(guggero): Remove this as soon as we have a tagged version of address. +replace github.com/btcsuite/btcd/address/v2 => ../address + +// TODO(guggero): Remove this as soon as we have a tagged version of btcec. +replace github.com/btcsuite/btcd/btcec/v2 => ../btcec + +// TODO(guggero): Remove this as soon as we have a tagged version of chaincfg. +replace github.com/btcsuite/btcd/chaincfg/v2 => ../chaincfg + +// TODO(guggero): Remove this as soon as we have a tagged version of chainhash. +replace github.com/btcsuite/btcd/chainhash/v2 => ../chainhash + +// TODO(guggero): Remove this as soon as we have a tagged version of txscript. +replace github.com/btcsuite/btcd/txscript/v2 => ../txscript + +// TODO(guggero): Remove this as soon as we have a tagged version of wire. +replace github.com/btcsuite/btcd/wire/v2 => ../wire + +go 1.19 diff --git a/btcutil/go.sum b/btcutil/go.sum index a57a5dd920..fe8d1bfd49 100644 --- a/btcutil/go.sum +++ b/btcutil/go.sum @@ -1,119 +1,22 @@ github.com/aead/siphash v1.0.1 h1:FwHfE/T45KPKYuuSAKyyvE+oPWcaQ+CUmFW0bPlM+kg= github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII= -github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ= -github.com/btcsuite/btcd v0.22.0-beta.0.20220111032746-97732e52810c/go.mod h1:tjmYdS6MLJ5/s0Fj4DbLgSbDHbEqLJrtnHecBFkdz5M= -github.com/btcsuite/btcd v0.23.4 h1:IzV6qqkfwbItOS/sg/aDfPDsjPP8twrCOE2R93hxMlQ= -github.com/btcsuite/btcd v0.23.4/go.mod h1:0QJIIN1wwIXF/3G/m87gIwGniDMDQqjVn4SZgnFpsYY= github.com/btcsuite/btcd v0.23.5-0.20231215221805-96c9fd8078fd h1:js1gPwhcFflTZ7Nzl7WHaOTlTr5hIrR4n1NM4v9n4Kw= -github.com/btcsuite/btcd v0.23.5-0.20231215221805-96c9fd8078fd/go.mod h1:nm3Bko6zh6bWP60UxwoT5LzdGJsQJaPo6HjduXq9p6A= -github.com/btcsuite/btcd/btcec/v2 v2.1.0/go.mod h1:2VzYrv4Gm4apmbVVsSq5bqf1Ec8v56E48Vt0Y/umPgA= -github.com/btcsuite/btcd/btcec/v2 v2.1.3 h1:xM/n3yIhHAhHy04z4i43C8p4ehixJZMsnrVJkgl+MTE= -github.com/btcsuite/btcd/btcec/v2 v2.1.3/go.mod h1:ctjw4H1kknNJmRN4iP1R7bTQ+v3GJkZBd6mui8ZsAZE= -github.com/btcsuite/btcd/btcutil v1.0.0/go.mod h1:Uoxwv0pqYWhD//tfTiipkxNfdhG9UrLwaeswfjfdF0A= -github.com/btcsuite/btcd/btcutil v1.1.0/go.mod h1:5OapHB7A2hBBWLm48mmw4MOHNJCcUBTwmWH/0Jn8VHE= -github.com/btcsuite/btcd/chaincfg/chainhash v1.0.0/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= -github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= +github.com/btcsuite/btcd/btcutil v1.1.4 h1:mWvWRLRIPuoeZsVRpc0xNCkfeNxWy1E4jIZ06ZpGI1A= github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0 h1:59Kx4K6lzOW5w6nFlA0v5+lk/6sjybR934QNHSJZPTQ= -github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f h1:bAs4lUbRJpnnkd9VhRV3jjAVU7DJVjMaK+IsvSeZvFo= github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA= -github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg= -github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd h1:R/opQEbFEy9JGkIguV40SvRY1uliPX8ifOvi6ICsFCw= -github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd/go.mod h1:HHNXQzUsZCxOoE+CPiyCTO6x34Zs86zZUiwtpXoGdtg= -github.com/btcsuite/goleveldb v0.0.0-20160330041536-7834afc9e8cd/go.mod h1:F+uVaaLLH7j4eDXPRvw78tMflu7Ie2bzYOH4Y8rRKBY= -github.com/btcsuite/goleveldb v1.0.0/go.mod h1:QiK9vBlgftBg6rWQIj6wFzbPfRjiykIEhBH4obrXJ/I= -github.com/btcsuite/snappy-go v0.0.0-20151229074030-0bdef8d06723/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc= -github.com/btcsuite/snappy-go v1.0.0/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc= -github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792 h1:R8vQdOQdZ9Y3SkEwmHoWBmX1DNXhXZqlTpq6s4tyJGc= -github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtEyQwv5/p4Mg4C0fgbePVuGr935/5ddU9Z3TmDRY= -github.com/btcsuite/winsvc v1.0.0 h1:J9B4L7e3oqhXOcm+2IuNApwzQec85lE+QaikUcCs+dk= -github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs= -github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/decred/dcrd/crypto/blake256 v1.0.0 h1:/8DMNYp9SGi5f0w7uCm6d6M4OU2rGFK09Y2A4Xv7EE0= -github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc= -github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 h1:YLtO71vCjJRCBcrPMtQ9nqBsqpA1m5sE92cU+pd5Mcc= -github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs= -github.com/decred/dcrd/lru v1.0.0 h1:Kbsb1SFDsIlaupWPwsPp+dkxiBY1frcS07PCPgotKz8= -github.com/decred/dcrd/lru v1.0.0/go.mod h1:mxKOwFd7lFjN2GZYsiz/ecgqR6kkYAl+0pz0tEMk218= -github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= -github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= -github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= -github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= -github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= -github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= -github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= -github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= -github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= -github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= -github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= -github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= -github.com/jessevdk/go-flags v1.4.0 h1:4IU2WS7AumrZ/40jfhf4QVDMsQwqA7VEHozFRrGARJA= -github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= -github.com/jrick/logrotate v1.0.0 h1:lQ1bL/n9mBNeIXoTUoYRlK4dHuNJVofX9oWqBtPnSzI= -github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ= -github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23 h1:FOOIBWrEkLgmlgGfMuZT83xIwfPDxEI2OHu6xUmJMFE= -github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4= -github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= -github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= -github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= -github.com/onsi/gomega v1.4.1/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= -github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= -github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= -github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= +github.com/decred/dcrd/crypto/blake256 v1.0.1 h1:7PltbUIQB7u/FfZ39+DGa/ShuMyJ5ilcvdfma9wOH6Y= +github.com/decred/dcrd/crypto/blake256 v1.0.1/go.mod h1:2OfgNZ5wDpcsFmHmCK5gZTPcCXqlm2ArzUIkw9czNJo= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 h1:8UrgZ3GkP4i/CLijOJx79Yu+etlyjdBU4sfcs2WYQMs= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0= +github.com/kkdai/bstream v1.0.0 h1:Se5gHwgp2VT2uHfDrkbbgbgEvV9cimLELwrPJctSjg8= +github.com/kkdai/bstream v1.0.0/go.mod h1:FDnDOHt5Yx4p3FaHcioFT0QjDOtgUpvjeZqAs+NVZZA= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY= -github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc= -golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnkZWQJsqcURM6tKiBApRjXI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200814200057-3d37ad5750ed h1:J22ig1FUekjjkmZUM7pTKixYm8DvrYsvrBZdunYeIuQ= -golang.org/x/sys v0.0.0-20200814200057-3d37ad5750ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= -google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= -google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= -google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= -google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= -google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= -gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= -gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= +golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= +golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= +golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/btcutil/hdkeychain/README.md b/btcutil/hdkeychain/README.md index eaf57d7c58..162d2fba01 100644 --- a/btcutil/hdkeychain/README.md +++ b/btcutil/hdkeychain/README.md @@ -1,9 +1,9 @@ hdkeychain ========== -[![Build Status](http://img.shields.io/travis/btcsuite/btcutil.svg)](https://travis-ci.org/btcsuite/btcutil) +[![Build Status](https://github.com/btcsuite/btcd/workflows/Build%20and%20Test/badge.svg)](https://github.com/btcsuite/btcd/actions) [![ISC License](http://img.shields.io/badge/license-ISC-blue.svg)](http://copyfree.org) -[![GoDoc](http://img.shields.io/badge/godoc-reference-blue.svg)](http://godoc.org/github.com/btcsuite/btcd/btcutil/hdkeychain) +[![GoDoc](http://img.shields.io/badge/godoc-reference-blue.svg)](http://godoc.org/github.com/btcsuite/btcd/btcutil/v2/hdkeychain) Package hdkeychain provides an API for bitcoin hierarchical deterministic extended keys (BIP0032). @@ -39,18 +39,18 @@ report. ## Installation and Updating ```bash -$ go get -u github.com/btcsuite/btcd/btcutil/hdkeychain +$ go get -u github.com/btcsuite/btcd/btcutil/v2/hdkeychain ``` ## Examples -* [NewMaster Example](http://godoc.org/github.com/btcsuite/btcd/btcutil/hdkeychain#example-NewMaster) +* [NewMaster Example](http://godoc.org/github.com/btcsuite/btcd/btcutil/v2/hdkeychain#example-NewMaster) Demonstrates how to generate a cryptographically random seed then use it to create a new master node (extended key). -* [Default Wallet Layout Example](http://godoc.org/github.com/btcsuite/btcd/btcutil/hdkeychain#example-package--DefaultWalletLayout) +* [Default Wallet Layout Example](http://godoc.org/github.com/btcsuite/btcd/btcutil/v2/hdkeychain#example-package--DefaultWalletLayout) Demonstrates the default hierarchical deterministic wallet layout as described in BIP0032. -* [Audits Use Case Example](http://godoc.org/github.com/btcsuite/btcd/btcutil/hdkeychain#example-package--Audits) +* [Audits Use Case Example](http://godoc.org/github.com/btcsuite/btcd/btcutil/v2/hdkeychain#example-package--Audits) Demonstrates the audits use case in BIP0032. ## License diff --git a/btcutil/hdkeychain/bench_test.go b/btcutil/hdkeychain/bench_test.go index 285ef3e8d6..9a76040942 100644 --- a/btcutil/hdkeychain/bench_test.go +++ b/btcutil/hdkeychain/bench_test.go @@ -7,7 +7,7 @@ package hdkeychain_test import ( "testing" - "github.com/btcsuite/btcd/btcutil/hdkeychain" + "github.com/btcsuite/btcd/btcutil/v2/hdkeychain" ) // bip0032MasterPriv1 is the master private extended key from the first set of diff --git a/btcutil/hdkeychain/example_test.go b/btcutil/hdkeychain/example_test.go index 8ea4244df1..5f4575b52e 100644 --- a/btcutil/hdkeychain/example_test.go +++ b/btcutil/hdkeychain/example_test.go @@ -7,8 +7,8 @@ package hdkeychain_test import ( "fmt" - "github.com/btcsuite/btcd/btcutil/hdkeychain" - "github.com/btcsuite/btcd/chaincfg" + "github.com/btcsuite/btcd/btcutil/v2/hdkeychain" + "github.com/btcsuite/btcd/chaincfg/v2" ) // This example demonstrates how to generate a cryptographically random seed diff --git a/btcutil/hdkeychain/extendedkey.go b/btcutil/hdkeychain/extendedkey.go index 0bbb1e7d19..4a80eb2f16 100644 --- a/btcutil/hdkeychain/extendedkey.go +++ b/btcutil/hdkeychain/extendedkey.go @@ -18,11 +18,11 @@ import ( "fmt" "math/big" + "github.com/btcsuite/btcd/address/v2" + "github.com/btcsuite/btcd/address/v2/base58" "github.com/btcsuite/btcd/btcec/v2" - "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/btcutil/base58" - "github.com/btcsuite/btcd/chaincfg" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/chaincfg/v2" + "github.com/btcsuite/btcd/chainhash/v2" ) const ( @@ -376,7 +376,7 @@ func (k *ExtendedKey) Derive(i uint32) (*ExtendedKey, error) { // The fingerprint of the parent for the derived child is the first 4 // bytes of the RIPEMD160(SHA256(parentPubKey)). - parentFP := btcutil.Hash160(k.pubKeyBytes())[:4] + parentFP := address.Hash160(k.pubKeyBytes())[:4] return NewExtendedKey(k.version, childKey, childChainCode, parentFP, k.depth+1, i, isPrivate), nil } @@ -462,7 +462,7 @@ func (k *ExtendedKey) DeriveNonStandard(i uint32) (*ExtendedKey, error) { childKey = childKeyPub.SerializeCompressed() } - parentFP := btcutil.Hash160(k.pubKeyBytes())[:4] + parentFP := address.Hash160(k.pubKeyBytes())[:4] return NewExtendedKey(k.version, childKey, childChainCode, parentFP, k.depth+1, i, isPrivate), nil } @@ -554,9 +554,11 @@ func (k *ExtendedKey) ECPrivKey() (*btcec.PrivateKey, error) { // Address converts the extended key to a standard bitcoin pay-to-pubkey-hash // address for the passed network. -func (k *ExtendedKey) Address(net *chaincfg.Params) (*btcutil.AddressPubKeyHash, error) { - pkHash := btcutil.Hash160(k.pubKeyBytes()) - return btcutil.NewAddressPubKeyHash(pkHash, net) +func (k *ExtendedKey) Address(net *chaincfg.Params) (*address.AddressPubKeyHash, + error) { + + pkHash := address.Hash160(k.pubKeyBytes()) + return address.NewAddressPubKeyHash(pkHash, net) } // paddedAppend appends the src byte slice to dst, returning the new slice. diff --git a/btcutil/hdkeychain/extendedkey_test.go b/btcutil/hdkeychain/extendedkey_test.go index 05ec2d6d37..ba01f94b44 100644 --- a/btcutil/hdkeychain/extendedkey_test.go +++ b/btcutil/hdkeychain/extendedkey_test.go @@ -17,7 +17,7 @@ import ( "reflect" "testing" - "github.com/btcsuite/btcd/chaincfg" + "github.com/btcsuite/btcd/chaincfg/v2" secp_ecdsa "github.com/decred/dcrd/dcrec/secp256k1/v4" ) diff --git a/btcutil/hdkeychain/test_coverage.txt b/btcutil/hdkeychain/test_coverage.txt deleted file mode 100644 index c0bc7ef035..0000000000 --- a/btcutil/hdkeychain/test_coverage.txt +++ /dev/null @@ -1,20 +0,0 @@ - -github.com/conformal/btcutil/hdkeychain/extendedkey.go ExtendedKey.String 100.00% (18/18) -github.com/conformal/btcutil/hdkeychain/extendedkey.go ExtendedKey.Zero 100.00% (9/9) -github.com/conformal/btcutil/hdkeychain/extendedkey.go ExtendedKey.pubKeyBytes 100.00% (7/7) -github.com/conformal/btcutil/hdkeychain/extendedkey.go ExtendedKey.Neuter 100.00% (6/6) -github.com/conformal/btcutil/hdkeychain/extendedkey.go ExtendedKey.ECPrivKey 100.00% (4/4) -github.com/conformal/btcutil/hdkeychain/extendedkey.go zero 100.00% (3/3) -github.com/conformal/btcutil/hdkeychain/extendedkey.go ExtendedKey.SetNet 100.00% (3/3) -github.com/conformal/btcutil/hdkeychain/extendedkey.go ExtendedKey.Address 100.00% (2/2) -github.com/conformal/btcutil/hdkeychain/extendedkey.go newExtendedKey 100.00% (1/1) -github.com/conformal/btcutil/hdkeychain/extendedkey.go ExtendedKey.IsPrivate 100.00% (1/1) -github.com/conformal/btcutil/hdkeychain/extendedkey.go ExtendedKey.ParentFingerprint 100.00% (1/1) -github.com/conformal/btcutil/hdkeychain/extendedkey.go ExtendedKey.ECPubKey 100.00% (1/1) -github.com/conformal/btcutil/hdkeychain/extendedkey.go ExtendedKey.IsForNet 100.00% (1/1) -github.com/conformal/btcutil/hdkeychain/extendedkey.go NewKeyFromString 95.83% (23/24) -github.com/conformal/btcutil/hdkeychain/extendedkey.go ExtendedKey.Child 91.67% (33/36) -github.com/conformal/btcutil/hdkeychain/extendedkey.go NewMaster 91.67% (11/12) -github.com/conformal/btcutil/hdkeychain/extendedkey.go GenerateSeed 85.71% (6/7) -github.com/conformal/btcutil/hdkeychain ----------------------------- 95.59% (130/136) - diff --git a/btcutil/psbt/creator.go b/btcutil/psbt/creator.go index a5f832e0dd..1394a6f869 100644 --- a/btcutil/psbt/creator.go +++ b/btcutil/psbt/creator.go @@ -5,7 +5,7 @@ package psbt import ( - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/wire/v2" ) // MinTxVersion is the lowest transaction version that we'll permit. diff --git a/btcutil/psbt/extractor.go b/btcutil/psbt/extractor.go index 365e2f1bba..cf7e7b66db 100644 --- a/btcutil/psbt/extractor.go +++ b/btcutil/psbt/extractor.go @@ -12,8 +12,8 @@ package psbt import ( "bytes" - "github.com/btcsuite/btcd/txscript" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/txscript/v2" + "github.com/btcsuite/btcd/wire/v2" ) // Extract takes a finalized psbt.Packet and outputs a finalized transaction diff --git a/btcutil/psbt/finalizer.go b/btcutil/psbt/finalizer.go index 3c2edd5557..9bf2915aac 100644 --- a/btcutil/psbt/finalizer.go +++ b/btcutil/psbt/finalizer.go @@ -16,8 +16,8 @@ import ( "fmt" "github.com/btcsuite/btcd/btcec/v2/schnorr" - "github.com/btcsuite/btcd/txscript" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/txscript/v2" + "github.com/btcsuite/btcd/wire/v2" ) // isFinalized considers this input finalized if it contains at least one of diff --git a/btcutil/psbt/partial_input.go b/btcutil/psbt/partial_input.go index 73595d2513..2e784be3f3 100644 --- a/btcutil/psbt/partial_input.go +++ b/btcutil/psbt/partial_input.go @@ -6,8 +6,8 @@ import ( "io" "sort" - "github.com/btcsuite/btcd/txscript" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/txscript/v2" + "github.com/btcsuite/btcd/wire/v2" ) // PInput is a struct encapsulating all the data that can be attached to any diff --git a/btcutil/psbt/partial_output.go b/btcutil/psbt/partial_output.go index 86e476457d..94b5d33f42 100644 --- a/btcutil/psbt/partial_output.go +++ b/btcutil/psbt/partial_output.go @@ -5,7 +5,7 @@ import ( "io" "sort" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/wire/v2" ) // POutput is a struct encapsulating all the data that can be attached diff --git a/btcutil/psbt/psbt.go b/btcutil/psbt/psbt.go index 964061bdc5..05d08a5a14 100644 --- a/btcutil/psbt/psbt.go +++ b/btcutil/psbt/psbt.go @@ -13,8 +13,8 @@ import ( "errors" "io" - "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/btcutil/v2" + "github.com/btcsuite/btcd/wire/v2" ) // psbtMagicLength is the length of the magic bytes used to signal the start of diff --git a/btcutil/psbt/psbt_test.go b/btcutil/psbt/psbt_test.go index 2309b07e40..cc5b3d6ec7 100644 --- a/btcutil/psbt/psbt_test.go +++ b/btcutil/psbt/psbt_test.go @@ -12,10 +12,10 @@ import ( "strings" "testing" - "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/chaincfg/chainhash" - "github.com/btcsuite/btcd/txscript" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/btcutil/v2" + "github.com/btcsuite/btcd/chainhash/v2" + "github.com/btcsuite/btcd/txscript/v2" + "github.com/btcsuite/btcd/wire/v2" "github.com/davecgh/go-spew/spew" "github.com/stretchr/testify/require" ) diff --git a/btcutil/psbt/signer.go b/btcutil/psbt/signer.go index dcbcf93fa3..ad5e7fd3dd 100644 --- a/btcutil/psbt/signer.go +++ b/btcutil/psbt/signer.go @@ -10,7 +10,7 @@ package psbt // is in the correct state. import ( - "github.com/btcsuite/btcd/txscript" + "github.com/btcsuite/btcd/txscript/v2" ) // SignOutcome is a enum-like value that expresses the outcome of a call to the diff --git a/btcutil/psbt/sort.go b/btcutil/psbt/sort.go index 2232d68feb..11454ba273 100644 --- a/btcutil/psbt/sort.go +++ b/btcutil/psbt/sort.go @@ -4,7 +4,7 @@ import ( "bytes" "sort" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/chainhash/v2" ) // InPlaceSort modifies the passed packet's wire TX inputs and outputs to be diff --git a/btcutil/psbt/sort_test.go b/btcutil/psbt/sort_test.go index 3dee0f48d8..4423d8b11a 100644 --- a/btcutil/psbt/sort_test.go +++ b/btcutil/psbt/sort_test.go @@ -4,8 +4,8 @@ import ( "reflect" "testing" - "github.com/btcsuite/btcd/chaincfg/chainhash" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/chainhash/v2" + "github.com/btcsuite/btcd/wire/v2" ) func TestInPlaceSort(t *testing.T) { diff --git a/btcutil/psbt/taproot.go b/btcutil/psbt/taproot.go index b9df860c95..8522aff5d2 100644 --- a/btcutil/psbt/taproot.go +++ b/btcutil/psbt/taproot.go @@ -4,8 +4,8 @@ import ( "bytes" "github.com/btcsuite/btcd/btcec/v2/schnorr" - "github.com/btcsuite/btcd/txscript" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/txscript/v2" + "github.com/btcsuite/btcd/wire/v2" ) const ( diff --git a/btcutil/psbt/updater.go b/btcutil/psbt/updater.go index 66c8d1d83c..26329f8ac5 100644 --- a/btcutil/psbt/updater.go +++ b/btcutil/psbt/updater.go @@ -14,9 +14,9 @@ import ( "bytes" "crypto/sha256" - "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/txscript" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/txscript/v2" + "github.com/btcsuite/btcd/wire/v2" + "github.com/btcsuite/btcutil/v2" ) // Updater encapsulates the role 'Updater' as specified in BIP174; it accepts diff --git a/btcutil/psbt/utils.go b/btcutil/psbt/utils.go index 85bc82f529..39142a4ee5 100644 --- a/btcutil/psbt/utils.go +++ b/btcutil/psbt/utils.go @@ -12,8 +12,8 @@ import ( "io" "sort" - "github.com/btcsuite/btcd/txscript" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/txscript/v2" + "github.com/btcsuite/btcd/wire/v2" ) // WriteTxWitness is a utility function due to non-exported witness diff --git a/btcutil/psbt/utils_test.go b/btcutil/psbt/utils_test.go index 90593ffca5..28eaa96eeb 100644 --- a/btcutil/psbt/utils_test.go +++ b/btcutil/psbt/utils_test.go @@ -5,8 +5,8 @@ import ( "reflect" "testing" - "github.com/btcsuite/btcd/chaincfg/chainhash" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/chainhash/v2" + "github.com/btcsuite/btcd/wire/v2" ) func TestSumUtxoInputValues(t *testing.T) { diff --git a/btcutil/tx.go b/btcutil/tx.go index 5633fef90e..50223919a3 100644 --- a/btcutil/tx.go +++ b/btcutil/tx.go @@ -8,8 +8,8 @@ import ( "bytes" "io" - "github.com/btcsuite/btcd/chaincfg/chainhash" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/chainhash/v2" + "github.com/btcsuite/btcd/wire/v2" ) // TxIndexUnknown is the value returned for a transaction index that is unknown. diff --git a/btcutil/tx_test.go b/btcutil/tx_test.go index 71b7488e9d..52447aed56 100644 --- a/btcutil/tx_test.go +++ b/btcutil/tx_test.go @@ -10,8 +10,8 @@ import ( "reflect" "testing" - "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/btcutil/v2" + "github.com/btcsuite/btcd/chainhash/v2" "github.com/davecgh/go-spew/spew" ) diff --git a/btcutil/txsort/txsort.go b/btcutil/txsort/txsort.go index f72a7db970..b8bb96c39e 100644 --- a/btcutil/txsort/txsort.go +++ b/btcutil/txsort/txsort.go @@ -11,8 +11,8 @@ import ( "bytes" "sort" - "github.com/btcsuite/btcd/chaincfg/chainhash" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/chainhash/v2" + "github.com/btcsuite/btcd/wire/v2" ) // InPlaceSort modifies the passed transaction inputs and outputs to be sorted diff --git a/btcutil/txsort/txsort_test.go b/btcutil/txsort/txsort_test.go index dd2149294e..ba0f37bd5c 100644 --- a/btcutil/txsort/txsort_test.go +++ b/btcutil/txsort/txsort_test.go @@ -11,8 +11,8 @@ import ( "path/filepath" "testing" - "github.com/btcsuite/btcd/btcutil/txsort" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/btcutil/v2/txsort" + "github.com/btcsuite/btcd/wire/v2" ) // TestSort ensures the transaction sorting works according to the BIP. diff --git a/btcutil/wif.go b/btcutil/wif.go index 26316dd7ff..4ea06aa5c2 100644 --- a/btcutil/wif.go +++ b/btcutil/wif.go @@ -8,10 +8,11 @@ import ( "bytes" "errors" + "github.com/btcsuite/btcd/address/v2" + "github.com/btcsuite/btcd/address/v2/base58" "github.com/btcsuite/btcd/btcec/v2" - "github.com/btcsuite/btcd/btcutil/base58" - "github.com/btcsuite/btcd/chaincfg" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/chaincfg/v2" + "github.com/btcsuite/btcd/chainhash/v2" ) // ErrMalformedPrivateKey describes an error where a WIF-encoded private @@ -112,7 +113,7 @@ func DecodeWIF(wif string) (*WIF, error) { } cksum := chainhash.DoubleHashB(tosum)[:4] if !bytes.Equal(cksum, decoded[decodedLen-4:]) { - return nil, ErrChecksumMismatch + return nil, address.ErrChecksumMismatch } netID := decoded[0] diff --git a/btcutil/wif_test.go b/btcutil/wif_test.go index c255c1b54f..e2c2c69aaf 100644 --- a/btcutil/wif_test.go +++ b/btcutil/wif_test.go @@ -10,8 +10,8 @@ import ( "testing" "github.com/btcsuite/btcd/btcec/v2" - . "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/chaincfg" + . "github.com/btcsuite/btcd/btcutil/v2" + "github.com/btcsuite/btcd/chaincfg/v2" ) func TestEncodeDecodeWIF(t *testing.T) { diff --git a/txscript/go.mod b/txscript/go.mod index 10afd994a1..02035fcc62 100644 --- a/txscript/go.mod +++ b/txscript/go.mod @@ -3,7 +3,6 @@ module github.com/btcsuite/btcd/txscript/v2 require ( github.com/btcsuite/btcd/address/v2 v2.0.0 github.com/btcsuite/btcd/btcec/v2 v2.3.2 - github.com/btcsuite/btcd/btcutil v1.1.4 github.com/btcsuite/btcd/chaincfg/v2 v2.0.0 github.com/btcsuite/btcd/chainhash/v2 v2.0.0 github.com/btcsuite/btcd/wire/v2 v2.0.0 @@ -14,8 +13,6 @@ require ( ) require ( - github.com/btcsuite/btcd v0.23.5-0.20231215221805-96c9fd8078fd // indirect - github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect golang.org/x/sys v0.15.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/txscript/go.sum b/txscript/go.sum index 5248a07d6b..cd6267d562 100644 --- a/txscript/go.sum +++ b/txscript/go.sum @@ -1,115 +1,20 @@ -github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII= -github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ= -github.com/btcsuite/btcd v0.22.0-beta.0.20220111032746-97732e52810c/go.mod h1:tjmYdS6MLJ5/s0Fj4DbLgSbDHbEqLJrtnHecBFkdz5M= -github.com/btcsuite/btcd v0.23.5-0.20231215221805-96c9fd8078fd h1:js1gPwhcFflTZ7Nzl7WHaOTlTr5hIrR4n1NM4v9n4Kw= -github.com/btcsuite/btcd v0.23.5-0.20231215221805-96c9fd8078fd/go.mod h1:nm3Bko6zh6bWP60UxwoT5LzdGJsQJaPo6HjduXq9p6A= -github.com/btcsuite/btcd/btcutil v1.0.0/go.mod h1:Uoxwv0pqYWhD//tfTiipkxNfdhG9UrLwaeswfjfdF0A= -github.com/btcsuite/btcd/btcutil v1.1.0/go.mod h1:5OapHB7A2hBBWLm48mmw4MOHNJCcUBTwmWH/0Jn8VHE= -github.com/btcsuite/btcd/btcutil v1.1.4 h1:mWvWRLRIPuoeZsVRpc0xNCkfeNxWy1E4jIZ06ZpGI1A= -github.com/btcsuite/btcd/btcutil v1.1.4/go.mod h1:PSZZ4UitpLBWzxGd5VGOrLnmOjtPP/a6HaFo12zMs00= -github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= -github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0 h1:59Kx4K6lzOW5w6nFlA0v5+lk/6sjybR934QNHSJZPTQ= -github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f h1:bAs4lUbRJpnnkd9VhRV3jjAVU7DJVjMaK+IsvSeZvFo= github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA= -github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg= -github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd/go.mod h1:HHNXQzUsZCxOoE+CPiyCTO6x34Zs86zZUiwtpXoGdtg= -github.com/btcsuite/goleveldb v0.0.0-20160330041536-7834afc9e8cd/go.mod h1:F+uVaaLLH7j4eDXPRvw78tMflu7Ie2bzYOH4Y8rRKBY= -github.com/btcsuite/goleveldb v1.0.0/go.mod h1:QiK9vBlgftBg6rWQIj6wFzbPfRjiykIEhBH4obrXJ/I= -github.com/btcsuite/snappy-go v0.0.0-20151229074030-0bdef8d06723/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc= -github.com/btcsuite/snappy-go v1.0.0/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc= -github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtEyQwv5/p4Mg4C0fgbePVuGr935/5ddU9Z3TmDRY= -github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs= -github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc= github.com/decred/dcrd/crypto/blake256 v1.0.1 h1:7PltbUIQB7u/FfZ39+DGa/ShuMyJ5ilcvdfma9wOH6Y= github.com/decred/dcrd/crypto/blake256 v1.0.1/go.mod h1:2OfgNZ5wDpcsFmHmCK5gZTPcCXqlm2ArzUIkw9czNJo= -github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 h1:8UrgZ3GkP4i/CLijOJx79Yu+etlyjdBU4sfcs2WYQMs= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0= -github.com/decred/dcrd/lru v1.0.0/go.mod h1:mxKOwFd7lFjN2GZYsiz/ecgqR6kkYAl+0pz0tEMk218= -github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= -github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= -github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= -github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= -github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= -github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= -github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= -github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= -github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= -github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= -github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= -github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= -github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ= -github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4= -github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= -github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= -github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= -github.com/onsi/gomega v1.4.1/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= -github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= -github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= -github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= -github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc= -golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= -golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200814200057-3d37ad5750ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= -google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= -google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= -google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= -google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= -google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= -gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= -gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/txscript/reference_test.go b/txscript/reference_test.go index a1862851f6..b582f669b0 100644 --- a/txscript/reference_test.go +++ b/txscript/reference_test.go @@ -18,7 +18,6 @@ import ( "strings" "testing" - "github.com/btcsuite/btcd/btcutil" "github.com/btcsuite/btcd/chainhash/v2" "github.com/btcsuite/btcd/wire/v2" ) @@ -917,7 +916,8 @@ func executeTaprootRefTest(t *testing.T, testCase taprootJsonTest) { if err != nil { t.Fatalf("unable to decode hex: %v", err) } - tx, err := btcutil.NewTxFromBytes(txHex) + tx := &wire.MsgTx{} + err = tx.Deserialize(bytes.NewReader(txHex)) if err != nil { t.Fatalf("unable to decode hex: %v", err) } @@ -940,7 +940,7 @@ func executeTaprootRefTest(t *testing.T, testCase taprootJsonTest) { } prevOutFetcher.AddPrevOut( - tx.MsgTx().TxIn[i].PreviousOutPoint, &txOut, + tx.TxIn[i].PreviousOutPoint, &txOut, ) if i == testCase.Index { @@ -954,10 +954,10 @@ func executeTaprootRefTest(t *testing.T, testCase taprootJsonTest) { } makeVM := func() *Engine { - hashCache := NewTxSigHashes(tx.MsgTx(), prevOutFetcher) + hashCache := NewTxSigHashes(tx, prevOutFetcher) vm, err := NewEngine( - prevOut.PkScript, tx.MsgTx(), testCase.Index, + prevOut.PkScript, tx, testCase.Index, flags, nil, hashCache, prevOut.Value, prevOutFetcher, ) if err != nil { @@ -968,7 +968,7 @@ func executeTaprootRefTest(t *testing.T, testCase taprootJsonTest) { } if testCase.Success != nil { - tx.MsgTx().TxIn[testCase.Index].SignatureScript, err = hex.DecodeString( + tx.TxIn[testCase.Index].SignatureScript, err = hex.DecodeString( testCase.Success.ScriptSig, ) if err != nil { @@ -985,7 +985,7 @@ func executeTaprootRefTest(t *testing.T, testCase taprootJsonTest) { witness = append(witness, witElem) } - tx.MsgTx().TxIn[testCase.Index].Witness = witness + tx.TxIn[testCase.Index].Witness = witness vm := makeVM() @@ -997,7 +997,7 @@ func executeTaprootRefTest(t *testing.T, testCase taprootJsonTest) { } if testCase.Failure != nil { - tx.MsgTx().TxIn[testCase.Index].SignatureScript, err = hex.DecodeString( + tx.TxIn[testCase.Index].SignatureScript, err = hex.DecodeString( testCase.Failure.ScriptSig, ) if err != nil { @@ -1014,7 +1014,7 @@ func executeTaprootRefTest(t *testing.T, testCase taprootJsonTest) { witness = append(witness, witElem) } - tx.MsgTx().TxIn[testCase.Index].Witness = witness + tx.TxIn[testCase.Index].Witness = witness vm := makeVM() diff --git a/txscript/taproot_test.go b/txscript/taproot_test.go index 8136569310..3b88927861 100644 --- a/txscript/taproot_test.go +++ b/txscript/taproot_test.go @@ -6,42 +6,51 @@ package txscript import ( "bytes" - "encoding/hex" "fmt" prand "math/rand" "testing" "testing/quick" + "github.com/btcsuite/btcd/address/v2" "github.com/btcsuite/btcd/btcec/v2" "github.com/btcsuite/btcd/btcec/v2/schnorr" - "github.com/btcsuite/btcd/btcutil/hdkeychain" "github.com/btcsuite/btcd/chaincfg/v2" secp "github.com/decred/dcrd/dcrec/secp256k1/v4" "github.com/stretchr/testify/require" ) var ( - testPubBytes, _ = hex.DecodeString("F9308A019258C31049344F85F89D5229B" + - "531C845836F99B08601F113BCE036F9") - - // rootKey is the test root key defined in the test vectors: + // privateKeys are four private keys derived from the seed mentioned in + // the BIP86 spec // https://github.com/bitcoin/bips/blob/master/bip-0086.mediawiki - rootKey, _ = hdkeychain.NewKeyFromString( - "xprv9s21ZrQH143K3GJpoapnV8SFfukcVBSfeCficPSGfubmSFDxo1kuHnLi" + - "sriDvSnRRuL2Qrg5ggqHKNVpxR86QEC8w35uxmGoggxtQTPvfUu", - ) - - // accountPath is the base path for BIP86 (m/86'/0'/0'). - accountPath = []uint32{ - 86 + hdkeychain.HardenedKeyStart, hdkeychain.HardenedKeyStart, - hdkeychain.HardenedKeyStart, + privateKeys = [][]byte{ + // m/86'/0'/0'/0/0 + hexToBytes( + "41f41d69260df4cf277826a9b65a3717e4eeddbeedf637f212ca" + + "096576479361", + ), + // m/86'/0'/0'/0/1 + hexToBytes( + "86c68ac0ed7df88cbdd08a847c6d639f87d1234d40503abf3ac1" + + "78ef7ddc05dd", + ), + // m/86'/0'/0'/1/0 + hexToBytes( + "6ccbca4a02ac648702dde463d9c1b0d328a4df1e068ef9dc2bc7" + + "88b33a4f0412", + ), + // m/86'/0'/0'/1/1 + hexToBytes( + "c8d522210e3bc028586dcb7cf7dce3937440ad8132765ecdfa2f" + + "f78d0e9a5d32", + ), } - expectedExternalAddresses = []string{ + + expectedAddresses = []string{ "bc1p5cyxnuxmeuwuvkwfem96lqzszd02n6xdcjrs20cac6yqjjwudpxqkedrcr", "bc1p4qhjn9zdvkux4e44uhx8tc55attvtyu358kutcqkudyccelu0was9fqzwh", - } - expectedInternalAddresses = []string{ "bc1p3qkhfews2uk44qtvauqyr2ttdsw7svhkl9nkm9s9c3x4ax5h60wqwruhk7", + "bc1ptdg60grjk9t3qqcqczp4tlyy3z47yrx9nhlrjsmw36q5a72lhdrs9f00nj", } ) @@ -241,46 +250,22 @@ func TestTaprootTweakNoMutation(t *testing.T) { // TestTaprootConstructKeyPath tests the key spend only taproot construction. func TestTaprootConstructKeyPath(t *testing.T) { - checkPath := func(branch uint32, expectedAddresses []string) { - path, err := derivePath(rootKey, append(accountPath, branch)) - require.NoError(t, err) - - for index, expectedAddr := range expectedAddresses { - extendedKey, err := path.Derive(uint32(index)) - require.NoError(t, err) - - pubKey, err := extendedKey.ECPubKey() - require.NoError(t, err) + t.Parallel() - tapKey := ComputeTaprootKeyNoScript(pubKey) + for idx, key := range privateKeys { + key := key + _, pubKey := btcec.PrivKeyFromBytes(key) - addr, err := address.NewAddressTaproot( - schnorr.SerializePubKey(tapKey), - &chaincfg.MainNetParams, - ) - require.NoError(t, err) + tapKey := ComputeTaprootKeyNoScript(pubKey) - require.Equal(t, expectedAddr, addr.String()) - } - } - checkPath(0, expectedExternalAddresses) - checkPath(1, expectedInternalAddresses) -} - -func derivePath(key *hdkeychain.ExtendedKey, path []uint32) ( - *hdkeychain.ExtendedKey, error) { + addr, err := address.NewAddressTaproot( + schnorr.SerializePubKey(tapKey), + &chaincfg.MainNetParams, + ) + require.NoError(t, err) - var ( - currentKey = key - err error - ) - for _, pathPart := range path { - currentKey, err = currentKey.Derive(pathPart) - if err != nil { - return nil, err - } + require.Equal(t, expectedAddresses[idx], addr.String()) } - return currentKey, nil } // TestTapscriptCommitmentVerification that given a valid control block, proof From 2bca13cf7c384f7f45c61daff8732fd92023ce62 Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Tue, 19 Dec 2023 14:12:50 +0100 Subject: [PATCH 08/10] psbt: move to top-level module, use v2, remove btcutil dep --- btcutil/psbt/go.mod | 22 ----- btcutil/psbt/go.sum | 109 ----------------------- {btcutil/psbt => psbt}/bip32.go | 0 {btcutil/psbt => psbt}/creator.go | 0 {btcutil/psbt => psbt}/extractor.go | 0 {btcutil/psbt => psbt}/finalizer.go | 0 psbt/go.mod | 46 ++++++++++ psbt/go.sum | 23 +++++ {btcutil/psbt => psbt}/partial_input.go | 0 {btcutil/psbt => psbt}/partial_output.go | 0 {btcutil/psbt => psbt}/partialsig.go | 0 {btcutil/psbt => psbt}/psbt.go | 0 {btcutil/psbt => psbt}/psbt_test.go | 7 +- {btcutil/psbt => psbt}/signer.go | 0 {btcutil/psbt => psbt}/sort.go | 0 {btcutil/psbt => psbt}/sort_test.go | 0 {btcutil/psbt => psbt}/taproot.go | 0 {btcutil/psbt => psbt}/types.go | 0 {btcutil/psbt => psbt}/updater.go | 9 +- {btcutil/psbt => psbt}/utils.go | 0 {btcutil/psbt => psbt}/utils_test.go | 0 21 files changed, 80 insertions(+), 136 deletions(-) delete mode 100644 btcutil/psbt/go.mod delete mode 100644 btcutil/psbt/go.sum rename {btcutil/psbt => psbt}/bip32.go (100%) rename {btcutil/psbt => psbt}/creator.go (100%) rename {btcutil/psbt => psbt}/extractor.go (100%) rename {btcutil/psbt => psbt}/finalizer.go (100%) create mode 100644 psbt/go.mod create mode 100644 psbt/go.sum rename {btcutil/psbt => psbt}/partial_input.go (100%) rename {btcutil/psbt => psbt}/partial_output.go (100%) rename {btcutil/psbt => psbt}/partialsig.go (100%) rename {btcutil/psbt => psbt}/psbt.go (100%) rename {btcutil/psbt => psbt}/psbt_test.go (99%) rename {btcutil/psbt => psbt}/signer.go (100%) rename {btcutil/psbt => psbt}/sort.go (100%) rename {btcutil/psbt => psbt}/sort_test.go (100%) rename {btcutil/psbt => psbt}/taproot.go (100%) rename {btcutil/psbt => psbt}/types.go (100%) rename {btcutil/psbt => psbt}/updater.go (98%) rename {btcutil/psbt => psbt}/utils.go (100%) rename {btcutil/psbt => psbt}/utils_test.go (100%) diff --git a/btcutil/psbt/go.mod b/btcutil/psbt/go.mod deleted file mode 100644 index b5c4461d86..0000000000 --- a/btcutil/psbt/go.mod +++ /dev/null @@ -1,22 +0,0 @@ -module github.com/btcsuite/btcd/btcutil/psbt - -go 1.17 - -require ( - github.com/btcsuite/btcd v0.23.0 - github.com/btcsuite/btcd/btcec/v2 v2.1.3 - github.com/btcsuite/btcd/btcutil v1.1.3 - github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0 - github.com/davecgh/go-spew v1.1.1 - github.com/stretchr/testify v1.7.0 -) - -require ( - github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f // indirect - github.com/decred/dcrd/crypto/blake256 v1.0.0 // indirect - github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect - github.com/pmezard/go-difflib v1.0.0 // indirect - golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 // indirect - golang.org/x/sys v0.0.0-20200814200057-3d37ad5750ed // indirect - gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect -) diff --git a/btcutil/psbt/go.sum b/btcutil/psbt/go.sum deleted file mode 100644 index c9d8388f8e..0000000000 --- a/btcutil/psbt/go.sum +++ /dev/null @@ -1,109 +0,0 @@ -github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII= -github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ= -github.com/btcsuite/btcd v0.22.0-beta.0.20220111032746-97732e52810c/go.mod h1:tjmYdS6MLJ5/s0Fj4DbLgSbDHbEqLJrtnHecBFkdz5M= -github.com/btcsuite/btcd v0.23.0 h1:V2/ZgjfDFIygAX3ZapeigkVBoVUtOJKSwrhZdlpSvaA= -github.com/btcsuite/btcd v0.23.0/go.mod h1:0QJIIN1wwIXF/3G/m87gIwGniDMDQqjVn4SZgnFpsYY= -github.com/btcsuite/btcd/btcec/v2 v2.1.0/go.mod h1:2VzYrv4Gm4apmbVVsSq5bqf1Ec8v56E48Vt0Y/umPgA= -github.com/btcsuite/btcd/btcec/v2 v2.1.3 h1:xM/n3yIhHAhHy04z4i43C8p4ehixJZMsnrVJkgl+MTE= -github.com/btcsuite/btcd/btcec/v2 v2.1.3/go.mod h1:ctjw4H1kknNJmRN4iP1R7bTQ+v3GJkZBd6mui8ZsAZE= -github.com/btcsuite/btcd/btcutil v1.0.0/go.mod h1:Uoxwv0pqYWhD//tfTiipkxNfdhG9UrLwaeswfjfdF0A= -github.com/btcsuite/btcd/btcutil v1.1.0/go.mod h1:5OapHB7A2hBBWLm48mmw4MOHNJCcUBTwmWH/0Jn8VHE= -github.com/btcsuite/btcd/btcutil v1.1.3 h1:xfbtw8lwpp0G6NwSHb+UE67ryTFHJAiNuipusjXSohQ= -github.com/btcsuite/btcd/btcutil v1.1.3/go.mod h1:UR7dsSJzJUfMmFiiLlIrMq1lS9jh9EdCV7FStZSnpi0= -github.com/btcsuite/btcd/chaincfg/chainhash v1.0.0/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= -github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= -github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0 h1:59Kx4K6lzOW5w6nFlA0v5+lk/6sjybR934QNHSJZPTQ= -github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= -github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f h1:bAs4lUbRJpnnkd9VhRV3jjAVU7DJVjMaK+IsvSeZvFo= -github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA= -github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg= -github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd/go.mod h1:HHNXQzUsZCxOoE+CPiyCTO6x34Zs86zZUiwtpXoGdtg= -github.com/btcsuite/goleveldb v0.0.0-20160330041536-7834afc9e8cd/go.mod h1:F+uVaaLLH7j4eDXPRvw78tMflu7Ie2bzYOH4Y8rRKBY= -github.com/btcsuite/goleveldb v1.0.0/go.mod h1:QiK9vBlgftBg6rWQIj6wFzbPfRjiykIEhBH4obrXJ/I= -github.com/btcsuite/snappy-go v0.0.0-20151229074030-0bdef8d06723/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc= -github.com/btcsuite/snappy-go v1.0.0/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc= -github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtEyQwv5/p4Mg4C0fgbePVuGr935/5ddU9Z3TmDRY= -github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs= -github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/decred/dcrd/crypto/blake256 v1.0.0 h1:/8DMNYp9SGi5f0w7uCm6d6M4OU2rGFK09Y2A4Xv7EE0= -github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc= -github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 h1:YLtO71vCjJRCBcrPMtQ9nqBsqpA1m5sE92cU+pd5Mcc= -github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs= -github.com/decred/dcrd/lru v1.0.0/go.mod h1:mxKOwFd7lFjN2GZYsiz/ecgqR6kkYAl+0pz0tEMk218= -github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= -github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= -github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= -github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= -github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= -github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= -github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= -github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= -github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= -github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= -github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= -github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ= -github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4= -github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= -github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= -github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= -github.com/onsi/gomega v1.4.1/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= -github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= -github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= -github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc= -golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnkZWQJsqcURM6tKiBApRjXI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200814200057-3d37ad5750ed h1:J22ig1FUekjjkmZUM7pTKixYm8DvrYsvrBZdunYeIuQ= -golang.org/x/sys v0.0.0-20200814200057-3d37ad5750ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= -google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= -google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= -google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= -google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= -google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= -gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= -gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/btcutil/psbt/bip32.go b/psbt/bip32.go similarity index 100% rename from btcutil/psbt/bip32.go rename to psbt/bip32.go diff --git a/btcutil/psbt/creator.go b/psbt/creator.go similarity index 100% rename from btcutil/psbt/creator.go rename to psbt/creator.go diff --git a/btcutil/psbt/extractor.go b/psbt/extractor.go similarity index 100% rename from btcutil/psbt/extractor.go rename to psbt/extractor.go diff --git a/btcutil/psbt/finalizer.go b/psbt/finalizer.go similarity index 100% rename from btcutil/psbt/finalizer.go rename to psbt/finalizer.go diff --git a/psbt/go.mod b/psbt/go.mod new file mode 100644 index 0000000000..2ccbfe34ce --- /dev/null +++ b/psbt/go.mod @@ -0,0 +1,46 @@ +module github.com/btcsuite/btcd/psbt/v2 + +require ( + github.com/btcsuite/btcd/address/v2 v2.0.0 + github.com/btcsuite/btcd/btcec/v2 v2.3.2 + github.com/btcsuite/btcd/btcutil/v2 v2.0.0 + github.com/btcsuite/btcd/chainhash/v2 v2.0.0 + github.com/btcsuite/btcd/txscript/v2 v2.0.0 + github.com/btcsuite/btcd/wire/v2 v2.0.0 + github.com/davecgh/go-spew v1.1.1 + github.com/stretchr/testify v1.8.4 +) + +require ( + github.com/btcsuite/btcd/chaincfg/v2 v2.0.0 // indirect + github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f // indirect + github.com/decred/dcrd/crypto/blake256 v1.0.1 // indirect + github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + golang.org/x/crypto v0.17.0 // indirect + golang.org/x/sys v0.15.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect +) + +// TODO(guggero): Remove this as soon as we have a tagged version of btcec. +replace github.com/btcsuite/btcd/btcec/v2 => ../btcec + +// TODO(guggero): Remove this as soon as we have a tagged version of btcutil. +replace github.com/btcsuite/btcd/btcutil/v2 => ../btcutil + +// TODO(guggero): Remove this as soon as we have a tagged version of chaincfg. +replace github.com/btcsuite/btcd/chaincfg/v2 => ../chaincfg + +// TODO(guggero): Remove this as soon as we have a tagged version of chainhash. +replace github.com/btcsuite/btcd/chainhash/v2 => ../chainhash + +// TODO(guggero): Remove this as soon as we have a tagged version of address. +replace github.com/btcsuite/btcd/address/v2 => ../address + +// TODO(guggero): Remove this as soon as we have a tagged version of txscript. +replace github.com/btcsuite/btcd/txscript/v2 => ../txscript + +// TODO(guggero): Remove this as soon as we have a tagged version of wire. +replace github.com/btcsuite/btcd/wire/v2 => ../wire + +go 1.19 diff --git a/psbt/go.sum b/psbt/go.sum new file mode 100644 index 0000000000..5131ede33b --- /dev/null +++ b/psbt/go.sum @@ -0,0 +1,23 @@ +github.com/btcsuite/btcd v0.23.5-0.20231215221805-96c9fd8078fd h1:js1gPwhcFflTZ7Nzl7WHaOTlTr5hIrR4n1NM4v9n4Kw= +github.com/btcsuite/btcd/btcutil v1.1.4 h1:mWvWRLRIPuoeZsVRpc0xNCkfeNxWy1E4jIZ06ZpGI1A= +github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0 h1:59Kx4K6lzOW5w6nFlA0v5+lk/6sjybR934QNHSJZPTQ= +github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f h1:bAs4lUbRJpnnkd9VhRV3jjAVU7DJVjMaK+IsvSeZvFo= +github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/decred/dcrd/crypto/blake256 v1.0.1 h1:7PltbUIQB7u/FfZ39+DGa/ShuMyJ5ilcvdfma9wOH6Y= +github.com/decred/dcrd/crypto/blake256 v1.0.1/go.mod h1:2OfgNZ5wDpcsFmHmCK5gZTPcCXqlm2ArzUIkw9czNJo= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 h1:8UrgZ3GkP4i/CLijOJx79Yu+etlyjdBU4sfcs2WYQMs= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= +golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= +golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= +golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/btcutil/psbt/partial_input.go b/psbt/partial_input.go similarity index 100% rename from btcutil/psbt/partial_input.go rename to psbt/partial_input.go diff --git a/btcutil/psbt/partial_output.go b/psbt/partial_output.go similarity index 100% rename from btcutil/psbt/partial_output.go rename to psbt/partial_output.go diff --git a/btcutil/psbt/partialsig.go b/psbt/partialsig.go similarity index 100% rename from btcutil/psbt/partialsig.go rename to psbt/partialsig.go diff --git a/btcutil/psbt/psbt.go b/psbt/psbt.go similarity index 100% rename from btcutil/psbt/psbt.go rename to psbt/psbt.go diff --git a/btcutil/psbt/psbt_test.go b/psbt/psbt_test.go similarity index 99% rename from btcutil/psbt/psbt_test.go rename to psbt/psbt_test.go index cc5b3d6ec7..4d677fb30f 100644 --- a/btcutil/psbt/psbt_test.go +++ b/psbt/psbt_test.go @@ -20,6 +20,11 @@ import ( "github.com/stretchr/testify/require" ) +const ( + // SatoshiPerBitcoin is the number of satoshi in one bitcoin (1 BTC). + SatoshiPerBitcoin = 1e8 +) + // Test vectors from: // // https://github.com/bitcoin/bips/blob/master/bip-0174.mediawiki#test-vectors @@ -1471,7 +1476,7 @@ func TestWitnessForNonWitnessUtxo(t *testing.T) { }}, TxOut: []*wire.TxOut{{ PkScript: outPkScript, - Value: 1.9 * btcutil.SatoshiPerBitcoin, + Value: 1.9 * SatoshiPerBitcoin, }}, }, Inputs: []PInput{{}}, diff --git a/btcutil/psbt/signer.go b/psbt/signer.go similarity index 100% rename from btcutil/psbt/signer.go rename to psbt/signer.go diff --git a/btcutil/psbt/sort.go b/psbt/sort.go similarity index 100% rename from btcutil/psbt/sort.go rename to psbt/sort.go diff --git a/btcutil/psbt/sort_test.go b/psbt/sort_test.go similarity index 100% rename from btcutil/psbt/sort_test.go rename to psbt/sort_test.go diff --git a/btcutil/psbt/taproot.go b/psbt/taproot.go similarity index 100% rename from btcutil/psbt/taproot.go rename to psbt/taproot.go diff --git a/btcutil/psbt/types.go b/psbt/types.go similarity index 100% rename from btcutil/psbt/types.go rename to psbt/types.go diff --git a/btcutil/psbt/updater.go b/psbt/updater.go similarity index 98% rename from btcutil/psbt/updater.go rename to psbt/updater.go index 26329f8ac5..33562c37bb 100644 --- a/btcutil/psbt/updater.go +++ b/psbt/updater.go @@ -14,9 +14,10 @@ import ( "bytes" "crypto/sha256" + "github.com/btcsuite/btcd/address/v2" "github.com/btcsuite/btcd/txscript/v2" "github.com/btcsuite/btcd/wire/v2" - "github.com/btcsuite/btcutil/v2" + "github.com/btcsuite/btcd/btcutil/v2" ) // Updater encapsulates the role 'Updater' as specified in BIP174; it accepts @@ -125,7 +126,7 @@ func (u *Updater) addPartialSignature(inIndex int, sig []byte, if pInput.RedeemScript != nil { outIndex := u.Upsbt.UnsignedTx.TxIn[inIndex].PreviousOutPoint.Index scriptPubKey := pInput.NonWitnessUtxo.TxOut[outIndex].PkScript - scriptHash := btcutil.Hash160(pInput.RedeemScript) + scriptHash := address.Hash160(pInput.RedeemScript) scriptHashScript, err := txscript.NewScriptBuilder(). AddOp(txscript.OP_HASH160). @@ -155,7 +156,7 @@ func (u *Updater) addPartialSignature(inIndex int, sig []byte, var script []byte if pInput.RedeemScript != nil { - scriptHash := btcutil.Hash160(pInput.RedeemScript) + scriptHash := address.Hash160(pInput.RedeemScript) scriptHashScript, err := txscript.NewScriptBuilder(). AddOp(txscript.OP_HASH160). AddData(scriptHash). @@ -195,7 +196,7 @@ func (u *Updater) addPartialSignature(inIndex int, sig []byte, } } else { // Otherwise, this is a p2wkh input. - pubkeyHash := btcutil.Hash160(pubkey) + pubkeyHash := address.Hash160(pubkey) pubkeyHashScript, err := txscript.NewScriptBuilder(). AddOp(txscript.OP_0). AddData(pubkeyHash). diff --git a/btcutil/psbt/utils.go b/psbt/utils.go similarity index 100% rename from btcutil/psbt/utils.go rename to psbt/utils.go diff --git a/btcutil/psbt/utils_test.go b/psbt/utils_test.go similarity index 100% rename from btcutil/psbt/utils_test.go rename to psbt/utils_test.go From d97d6a41e93f0f32fa6486ec177491b82abc613c Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Tue, 19 Dec 2023 14:12:51 +0100 Subject: [PATCH 09/10] multi: use new v2 modules everywhere --- addrmgr/addrmanager.go | 4 +- addrmgr/addrmanager_internal_test.go | 2 +- addrmgr/addrmanager_test.go | 2 +- addrmgr/internal_test.go | 2 +- addrmgr/knownaddress.go | 2 +- addrmgr/knownaddress_test.go | 2 +- addrmgr/network.go | 2 +- addrmgr/network_test.go | 2 +- blockchain/accept.go | 2 +- blockchain/bench_test.go | 4 +- blockchain/blockindex.go | 6 +- blockchain/chain.go | 10 +- blockchain/chain_test.go | 8 +- blockchain/chainio.go | 6 +- blockchain/chainio_test.go | 2 +- blockchain/chainview_test.go | 2 +- blockchain/checkpoints.go | 8 +- blockchain/common_test.go | 10 +- blockchain/compress.go | 2 +- blockchain/difficulty.go | 2 +- blockchain/example_test.go | 4 +- blockchain/fullblocks_test.go | 10 +- blockchain/fullblocktests/generate.go | 13 +- blockchain/fullblocktests/params.go | 6 +- blockchain/indexers/addrindex.go | 33 ++-- blockchain/indexers/addrindex_test.go | 2 +- blockchain/indexers/blocklogger.go | 2 +- blockchain/indexers/cfindex.go | 12 +- blockchain/indexers/common.go | 2 +- blockchain/indexers/manager.go | 6 +- blockchain/indexers/txindex.go | 6 +- blockchain/interfaces.go | 4 +- blockchain/merkle.go | 6 +- blockchain/merkle_test.go | 6 +- blockchain/notifications_test.go | 2 +- blockchain/process.go | 4 +- blockchain/rolling_merkle.go | 4 +- blockchain/rolling_merkle_test.go | 2 +- blockchain/scriptval.go | 6 +- blockchain/scriptval_test.go | 2 +- blockchain/thresholdstate.go | 4 +- blockchain/thresholdstate_test.go | 2 +- blockchain/upgrade.go | 4 +- blockchain/utxocache.go | 8 +- blockchain/utxocache_test.go | 8 +- blockchain/utxoviewpoint.go | 8 +- blockchain/validate.go | 10 +- blockchain/validate_test.go | 8 +- blockchain/versionbits.go | 2 +- blockchain/weight.go | 6 +- btcjson/chainsvrcmds.go | 2 +- btcjson/chainsvrcmds_test.go | 2 +- btcjson/chainsvrresults.go | 6 +- btcjson/chainsvrresults_test.go | 4 +- btcjson/walletsvrcmds.go | 2 +- btcjson/walletsvrcmds_test.go | 2 +- btcjson/walletsvrresults.go | 2 +- btcjson/walletsvrresults_test.go | 2 +- btcutil/README.md | 6 +- btcutil/amount.go | 2 +- btcutil/bloom/filter_test.go | 3 +- btcutil/bloom/merkleblock_test.go | 2 +- btcutil/coinset/coins_test.go | 2 +- btcutil/gcs/README.md | 2 +- btcutil/gcs/builder/builder_test.go | 6 +- btcutil/txsort/README.md | 6 +- btcutil/wif_test.go | 3 +- chaincfg/README.md | 2 +- chaincfg/doc.go | 2 +- cmd/addblock/config.go | 6 +- cmd/addblock/import.go | 6 +- cmd/btcctl/config.go | 4 +- cmd/findcheckpoint/config.go | 6 +- cmd/findcheckpoint/findcheckpoint.go | 4 +- cmd/gencerts/gencerts.go | 2 +- config.go | 15 +- connmgr/seed.go | 4 +- database/cmd/dbtool/fetchblock.go | 2 +- database/cmd/dbtool/fetchblockregion.go | 2 +- database/cmd/dbtool/globalconfig.go | 6 +- database/cmd/dbtool/insecureimport.go | 6 +- database/cmd/dbtool/loadheaders.go | 2 +- database/example_test.go | 6 +- database/ffldb/bench_test.go | 4 +- database/ffldb/blockio.go | 4 +- database/ffldb/db.go | 6 +- database/ffldb/driver.go | 2 +- database/ffldb/driver_test.go | 6 +- database/ffldb/interface_test.go | 8 +- database/ffldb/whitebox_test.go | 6 +- database/interface.go | 4 +- docs/json_rpc_api.md | 10 +- go.mod | 47 +++-- go.sum | 39 ++-- integration/bip0009_test.go | 4 +- integration/csv_fork_test.go | 15 +- integration/getchaintips_test.go | 4 +- integration/prune_test.go | 2 +- integration/rpcserver_test.go | 4 +- integration/rpctest/blockgen.go | 15 +- integration/rpctest/memwallet.go | 31 +-- integration/rpctest/node.go | 2 +- integration/rpctest/rpc_harness.go | 13 +- integration/rpctest/rpc_harness_test.go | 10 +- integration/rpctest/utils.go | 2 +- log.go | 2 +- mempool/error.go | 2 +- mempool/estimatefee.go | 4 +- mempool/estimatefee_test.go | 6 +- mempool/mempool.go | 10 +- mempool/mempool_test.go | 15 +- mempool/policy.go | 6 +- mempool/policy_test.go | 13 +- mining/cpuminer/cpuminer.go | 11 +- mining/mining.go | 19 +- mining/mining_test.go | 2 +- mining/policy.go | 4 +- mining/policy_test.go | 6 +- netsync/blocklogger.go | 2 +- netsync/interface.go | 8 +- netsync/manager.go | 8 +- params.go | 4 +- peer/doc.go | 2 +- peer/example_test.go | 4 +- peer/log.go | 6 +- peer/peer.go | 6 +- peer/peer_test.go | 6 +- psbt/partialsig.go | 1 + psbt/psbt_test.go | 1 - psbt/updater.go | 1 - rpcadapters.go | 6 +- rpcclient/chain.go | 4 +- rpcclient/chain_test.go | 9 +- rpcclient/example_test.go | 1 + rpcclient/examples/btcdwebsockets/main.go | 4 +- .../examples/btcwalletwebsockets/main.go | 2 +- rpcclient/extensions.go | 14 +- rpcclient/infrastructure.go | 2 +- rpcclient/mining.go | 13 +- rpcclient/notify.go | 27 +-- rpcclient/rawtransactions.go | 29 +-- rpcclient/wallet.go | 184 ++++++++++++------ rpcserver.go | 49 ++--- rpcwebsocket.go | 41 ++-- server.go | 12 +- 145 files changed, 653 insertions(+), 532 deletions(-) diff --git a/addrmgr/addrmanager.go b/addrmgr/addrmanager.go index bdfe9094ce..c99ae7c66e 100644 --- a/addrmgr/addrmanager.go +++ b/addrmgr/addrmanager.go @@ -23,8 +23,8 @@ import ( "sync/atomic" "time" - "github.com/btcsuite/btcd/chaincfg/chainhash" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/chainhash/v2" + "github.com/btcsuite/btcd/wire/v2" ) // AddrManager provides a concurrency safe address manager for caching potential diff --git a/addrmgr/addrmanager_internal_test.go b/addrmgr/addrmanager_internal_test.go index 1d13f78e6e..4421859b00 100644 --- a/addrmgr/addrmanager_internal_test.go +++ b/addrmgr/addrmanager_internal_test.go @@ -8,7 +8,7 @@ import ( "testing" "time" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/wire/v2" ) // randAddr generates a *wire.NetAddressV2 backed by a random IPv4/IPv6 diff --git a/addrmgr/addrmanager_test.go b/addrmgr/addrmanager_test.go index 4afe5fd601..7bf2977c9a 100644 --- a/addrmgr/addrmanager_test.go +++ b/addrmgr/addrmanager_test.go @@ -13,7 +13,7 @@ import ( "time" "github.com/btcsuite/btcd/addrmgr" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/wire/v2" ) // naTest is used to describe a test to be performed against the NetAddressKey diff --git a/addrmgr/internal_test.go b/addrmgr/internal_test.go index ab7644b6ca..3e96dec971 100644 --- a/addrmgr/internal_test.go +++ b/addrmgr/internal_test.go @@ -7,7 +7,7 @@ package addrmgr import ( "time" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/wire/v2" ) func TstKnownAddressIsBad(ka *KnownAddress) bool { diff --git a/addrmgr/knownaddress.go b/addrmgr/knownaddress.go index b045365508..26cbcc1f65 100644 --- a/addrmgr/knownaddress.go +++ b/addrmgr/knownaddress.go @@ -8,7 +8,7 @@ import ( "sync" "time" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/wire/v2" ) // KnownAddress tracks information about a known network address that is used diff --git a/addrmgr/knownaddress_test.go b/addrmgr/knownaddress_test.go index b4a2650140..12e4137d65 100644 --- a/addrmgr/knownaddress_test.go +++ b/addrmgr/knownaddress_test.go @@ -10,7 +10,7 @@ import ( "time" "github.com/btcsuite/btcd/addrmgr" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/wire/v2" ) func TestChance(t *testing.T) { diff --git a/addrmgr/network.go b/addrmgr/network.go index 95555a69c5..6180516f0e 100644 --- a/addrmgr/network.go +++ b/addrmgr/network.go @@ -8,7 +8,7 @@ import ( "fmt" "net" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/wire/v2" ) var ( diff --git a/addrmgr/network_test.go b/addrmgr/network_test.go index f4bc5d88f7..cc1e73a9a9 100644 --- a/addrmgr/network_test.go +++ b/addrmgr/network_test.go @@ -10,7 +10,7 @@ import ( "time" "github.com/btcsuite/btcd/addrmgr" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/wire/v2" ) // TestIPTypes ensures the various functions which determine the type of an IP diff --git a/blockchain/accept.go b/blockchain/accept.go index 935963148f..a1d4d09181 100644 --- a/blockchain/accept.go +++ b/blockchain/accept.go @@ -7,7 +7,7 @@ package blockchain import ( "fmt" - "github.com/btcsuite/btcd/btcutil" + "github.com/btcsuite/btcd/btcutil/v2" "github.com/btcsuite/btcd/database" ) diff --git a/blockchain/bench_test.go b/blockchain/bench_test.go index db6f415013..4cde870cc2 100644 --- a/blockchain/bench_test.go +++ b/blockchain/bench_test.go @@ -7,8 +7,8 @@ package blockchain import ( "testing" - "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/btcutil/v2" + "github.com/btcsuite/btcd/wire/v2" ) // BenchmarkIsCoinBase performs a simple benchmark against the IsCoinBase diff --git a/blockchain/blockindex.go b/blockchain/blockindex.go index ca3235f79f..20e98b37aa 100644 --- a/blockchain/blockindex.go +++ b/blockchain/blockindex.go @@ -10,10 +10,10 @@ import ( "sync" "time" - "github.com/btcsuite/btcd/chaincfg" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/chaincfg/v2" + "github.com/btcsuite/btcd/chainhash/v2" "github.com/btcsuite/btcd/database" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/wire/v2" ) // blockStatus is a bit field representing the validation state of the block. diff --git a/blockchain/chain.go b/blockchain/chain.go index 60420022ac..2716fcdc66 100644 --- a/blockchain/chain.go +++ b/blockchain/chain.go @@ -11,12 +11,12 @@ import ( "sync" "time" - "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/chaincfg" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/btcutil/v2" + "github.com/btcsuite/btcd/chaincfg/v2" + "github.com/btcsuite/btcd/chainhash/v2" "github.com/btcsuite/btcd/database" - "github.com/btcsuite/btcd/txscript" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/txscript/v2" + "github.com/btcsuite/btcd/wire/v2" ) const ( diff --git a/blockchain/chain_test.go b/blockchain/chain_test.go index 1ac08f9a76..1a5a2279e2 100644 --- a/blockchain/chain_test.go +++ b/blockchain/chain_test.go @@ -10,10 +10,10 @@ import ( "testing" "time" - "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/chaincfg" - "github.com/btcsuite/btcd/chaincfg/chainhash" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/btcutil/v2" + "github.com/btcsuite/btcd/chaincfg/v2" + "github.com/btcsuite/btcd/chainhash/v2" + "github.com/btcsuite/btcd/wire/v2" ) // TestHaveBlock tests the HaveBlock API to ensure proper functionality. diff --git a/blockchain/chainio.go b/blockchain/chainio.go index 75474021f8..5067a9cbbf 100644 --- a/blockchain/chainio.go +++ b/blockchain/chainio.go @@ -12,10 +12,10 @@ import ( "sync" "time" - "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/btcutil/v2" + "github.com/btcsuite/btcd/chainhash/v2" "github.com/btcsuite/btcd/database" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/wire/v2" ) const ( diff --git a/blockchain/chainio_test.go b/blockchain/chainio_test.go index 630af14e1c..ccd1716050 100644 --- a/blockchain/chainio_test.go +++ b/blockchain/chainio_test.go @@ -12,7 +12,7 @@ import ( "testing" "github.com/btcsuite/btcd/database" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/wire/v2" ) // TestErrNotInMainChain ensures the functions related to errNotInMainChain work diff --git a/blockchain/chainview_test.go b/blockchain/chainview_test.go index c59004fdaf..d35383a511 100644 --- a/blockchain/chainview_test.go +++ b/blockchain/chainview_test.go @@ -10,7 +10,7 @@ import ( "reflect" "testing" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/wire/v2" ) // testNoncePrng provides a deterministic prng for the nonce in generated fake diff --git a/blockchain/checkpoints.go b/blockchain/checkpoints.go index 74fc23bacb..2ad1784111 100644 --- a/blockchain/checkpoints.go +++ b/blockchain/checkpoints.go @@ -8,10 +8,10 @@ import ( "fmt" "time" - "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/chaincfg" - "github.com/btcsuite/btcd/chaincfg/chainhash" - "github.com/btcsuite/btcd/txscript" + "github.com/btcsuite/btcd/btcutil/v2" + "github.com/btcsuite/btcd/chaincfg/v2" + "github.com/btcsuite/btcd/chainhash/v2" + "github.com/btcsuite/btcd/txscript/v2" ) // CheckpointConfirmations is the number of blocks before the end of the current diff --git a/blockchain/common_test.go b/blockchain/common_test.go index 1973689ea1..e618d852bc 100644 --- a/blockchain/common_test.go +++ b/blockchain/common_test.go @@ -14,13 +14,13 @@ import ( "strings" "time" - "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/chaincfg" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/btcutil/v2" + "github.com/btcsuite/btcd/chaincfg/v2" + "github.com/btcsuite/btcd/chainhash/v2" "github.com/btcsuite/btcd/database" _ "github.com/btcsuite/btcd/database/ffldb" - "github.com/btcsuite/btcd/txscript" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/txscript/v2" + "github.com/btcsuite/btcd/wire/v2" ) const ( diff --git a/blockchain/compress.go b/blockchain/compress.go index 4495918558..3b7e0041b2 100644 --- a/blockchain/compress.go +++ b/blockchain/compress.go @@ -6,7 +6,7 @@ package blockchain import ( "github.com/btcsuite/btcd/btcec/v2" - "github.com/btcsuite/btcd/txscript" + "github.com/btcsuite/btcd/txscript/v2" ) // ----------------------------------------------------------------------------- diff --git a/blockchain/difficulty.go b/blockchain/difficulty.go index 1fa850cc37..9149e99280 100644 --- a/blockchain/difficulty.go +++ b/blockchain/difficulty.go @@ -8,7 +8,7 @@ import ( "math/big" "time" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/chainhash/v2" ) var ( diff --git a/blockchain/example_test.go b/blockchain/example_test.go index 8db570273d..9a86440ef6 100644 --- a/blockchain/example_test.go +++ b/blockchain/example_test.go @@ -11,8 +11,8 @@ import ( "path/filepath" "github.com/btcsuite/btcd/blockchain" - "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/chaincfg" + "github.com/btcsuite/btcd/btcutil/v2" + "github.com/btcsuite/btcd/chaincfg/v2" "github.com/btcsuite/btcd/database" _ "github.com/btcsuite/btcd/database/ffldb" ) diff --git a/blockchain/fullblocks_test.go b/blockchain/fullblocks_test.go index d6bcf799af..4489c13bdb 100644 --- a/blockchain/fullblocks_test.go +++ b/blockchain/fullblocks_test.go @@ -14,13 +14,13 @@ import ( "github.com/btcsuite/btcd/blockchain" "github.com/btcsuite/btcd/blockchain/fullblocktests" - "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/chaincfg" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/btcutil/v2" + "github.com/btcsuite/btcd/chaincfg/v2" + "github.com/btcsuite/btcd/chainhash/v2" "github.com/btcsuite/btcd/database" _ "github.com/btcsuite/btcd/database/ffldb" - "github.com/btcsuite/btcd/txscript" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/txscript/v2" + "github.com/btcsuite/btcd/wire/v2" ) const ( diff --git a/blockchain/fullblocktests/generate.go b/blockchain/fullblocktests/generate.go index 4c551c05e0..3060aac851 100644 --- a/blockchain/fullblocktests/generate.go +++ b/blockchain/fullblocktests/generate.go @@ -18,13 +18,14 @@ import ( "runtime" "time" + "github.com/btcsuite/btcd/address/v2" "github.com/btcsuite/btcd/blockchain" "github.com/btcsuite/btcd/btcec/v2" - "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/chaincfg" - "github.com/btcsuite/btcd/chaincfg/chainhash" - "github.com/btcsuite/btcd/txscript" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/btcutil/v2" + "github.com/btcsuite/btcd/chaincfg/v2" + "github.com/btcsuite/btcd/chainhash/v2" + "github.com/btcsuite/btcd/txscript/v2" + "github.com/btcsuite/btcd/wire/v2" ) const ( @@ -216,7 +217,7 @@ func makeTestGenerator(params *chaincfg.Params) (testGenerator, error) { // payToScriptHashScript returns a standard pay-to-script-hash for the provided // redeem script. func payToScriptHashScript(redeemScript []byte) []byte { - redeemScriptHash := btcutil.Hash160(redeemScript) + redeemScriptHash := address.Hash160(redeemScript) script, err := txscript.NewScriptBuilder(). AddOp(txscript.OP_HASH160).AddData(redeemScriptHash). AddOp(txscript.OP_EQUAL).Script() diff --git a/blockchain/fullblocktests/params.go b/blockchain/fullblocktests/params.go index 4679036ff6..e5b4bc8510 100644 --- a/blockchain/fullblocktests/params.go +++ b/blockchain/fullblocktests/params.go @@ -9,9 +9,9 @@ import ( "math/big" "time" - "github.com/btcsuite/btcd/chaincfg" - "github.com/btcsuite/btcd/chaincfg/chainhash" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/chaincfg/v2" + "github.com/btcsuite/btcd/chainhash/v2" + "github.com/btcsuite/btcd/wire/v2" ) // newHashFromStr converts the passed big-endian hex string into a diff --git a/blockchain/indexers/addrindex.go b/blockchain/indexers/addrindex.go index 7eaaab06b7..0b589fd741 100644 --- a/blockchain/indexers/addrindex.go +++ b/blockchain/indexers/addrindex.go @@ -9,13 +9,14 @@ import ( "fmt" "sync" + "github.com/btcsuite/btcd/address/v2" "github.com/btcsuite/btcd/blockchain" - "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/chaincfg" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/btcutil/v2" + "github.com/btcsuite/btcd/chaincfg/v2" + "github.com/btcsuite/btcd/chainhash/v2" "github.com/btcsuite/btcd/database" - "github.com/btcsuite/btcd/txscript" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/txscript/v2" + "github.com/btcsuite/btcd/wire/v2" ) const ( @@ -541,27 +542,27 @@ func dbRemoveAddrIndexEntries(bucket internalBucket, addrKey [addrKeySize]byte, // addrToKey converts known address types to an addrindex key. An error is // returned for unsupported types. -func addrToKey(addr btcutil.Address) ([addrKeySize]byte, error) { +func addrToKey(addr address.Address) ([addrKeySize]byte, error) { switch addr := addr.(type) { - case *btcutil.AddressPubKeyHash: + case *address.AddressPubKeyHash: var result [addrKeySize]byte result[0] = addrKeyTypePubKeyHash copy(result[1:], addr.Hash160()[:]) return result, nil - case *btcutil.AddressScriptHash: + case *address.AddressScriptHash: var result [addrKeySize]byte result[0] = addrKeyTypeScriptHash copy(result[1:], addr.Hash160()[:]) return result, nil - case *btcutil.AddressPubKey: + case *address.AddressPubKey: var result [addrKeySize]byte result[0] = addrKeyTypePubKeyHash copy(result[1:], addr.AddressPubKeyHash().Hash160()[:]) return result, nil - case *btcutil.AddressWitnessScriptHash: + case *address.AddressWitnessScriptHash: var result [addrKeySize]byte result[0] = addrKeyTypeWitnessScriptHash @@ -570,23 +571,23 @@ func addrToKey(addr btcutil.Address) ([addrKeySize]byte, error) { // all address entries within the database uniform and compact, // we use a hash160 here to reduce the size of the salient data // push to 20-bytes. - copy(result[1:], btcutil.Hash160(addr.ScriptAddress())) + copy(result[1:], address.Hash160(addr.ScriptAddress())) return result, nil - case *btcutil.AddressWitnessPubKeyHash: + case *address.AddressWitnessPubKeyHash: var result [addrKeySize]byte result[0] = addrKeyTypeWitnessPubKeyHash copy(result[1:], addr.Hash160()[:]) return result, nil - case *btcutil.AddressTaproot: + case *address.AddressTaproot: var result [addrKeySize]byte result[0] = addrKeyTypeTaprootPubKey // Taproot outputs are actually just the 32-byte public key. // Similar to the P2WSH outputs, we'll map these to 20-bytes // via the hash160. - copy(result[1:], btcutil.Hash160(addr.ScriptAddress())) + copy(result[1:], address.Hash160(addr.ScriptAddress())) return result, nil } @@ -820,7 +821,7 @@ func (idx *AddrIndex) DisconnectBlock(dbTx database.Tx, block *btcutil.Block, // that involve a given address. // // This function is safe for concurrent access. -func (idx *AddrIndex) TxRegionsForAddress(dbTx database.Tx, addr btcutil.Address, +func (idx *AddrIndex) TxRegionsForAddress(dbTx database.Tx, addr address.Address, numToSkip, numRequested uint32, reverse bool) ([]database.BlockRegion, uint32, error) { addrKey, err := addrToKey(addr) @@ -946,7 +947,7 @@ func (idx *AddrIndex) RemoveUnconfirmedTx(hash *chainhash.Hash) { // Unsupported address types are ignored and will result in no results. // // This function is safe for concurrent access. -func (idx *AddrIndex) UnconfirmedTxnsForAddress(addr btcutil.Address) []*btcutil.Tx { +func (idx *AddrIndex) UnconfirmedTxnsForAddress(addr address.Address) []*btcutil.Tx { // Ignore unsupported address types. addrKey, err := addrToKey(addr) if err != nil { diff --git a/blockchain/indexers/addrindex_test.go b/blockchain/indexers/addrindex_test.go index e545887f8b..19d8ee0692 100644 --- a/blockchain/indexers/addrindex_test.go +++ b/blockchain/indexers/addrindex_test.go @@ -9,7 +9,7 @@ import ( "fmt" "testing" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/wire/v2" ) // addrIndexBucket provides a mock address index database bucket by implementing diff --git a/blockchain/indexers/blocklogger.go b/blockchain/indexers/blocklogger.go index 960a51d2c1..bb515b03df 100644 --- a/blockchain/indexers/blocklogger.go +++ b/blockchain/indexers/blocklogger.go @@ -8,7 +8,7 @@ import ( "sync" "time" - "github.com/btcsuite/btcd/btcutil" + "github.com/btcsuite/btcd/btcutil/v2" "github.com/btcsuite/btclog" ) diff --git a/blockchain/indexers/cfindex.go b/blockchain/indexers/cfindex.go index 1af1d0a421..e79dbe1ff7 100644 --- a/blockchain/indexers/cfindex.go +++ b/blockchain/indexers/cfindex.go @@ -8,13 +8,13 @@ import ( "errors" "github.com/btcsuite/btcd/blockchain" - "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/btcutil/gcs" - "github.com/btcsuite/btcd/btcutil/gcs/builder" - "github.com/btcsuite/btcd/chaincfg" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/btcutil/v2" + "github.com/btcsuite/btcd/btcutil/v2/gcs" + "github.com/btcsuite/btcd/btcutil/v2/gcs/builder" + "github.com/btcsuite/btcd/chaincfg/v2" + "github.com/btcsuite/btcd/chainhash/v2" "github.com/btcsuite/btcd/database" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/wire/v2" ) const ( diff --git a/blockchain/indexers/common.go b/blockchain/indexers/common.go index 89ce6720b5..3780eb0d5d 100644 --- a/blockchain/indexers/common.go +++ b/blockchain/indexers/common.go @@ -12,7 +12,7 @@ import ( "errors" "github.com/btcsuite/btcd/blockchain" - "github.com/btcsuite/btcd/btcutil" + "github.com/btcsuite/btcd/btcutil/v2" "github.com/btcsuite/btcd/database" ) diff --git a/blockchain/indexers/manager.go b/blockchain/indexers/manager.go index b4487e60fd..28f608fbe1 100644 --- a/blockchain/indexers/manager.go +++ b/blockchain/indexers/manager.go @@ -9,10 +9,10 @@ import ( "fmt" "github.com/btcsuite/btcd/blockchain" - "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/btcutil/v2" + "github.com/btcsuite/btcd/chainhash/v2" "github.com/btcsuite/btcd/database" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/wire/v2" ) var ( diff --git a/blockchain/indexers/txindex.go b/blockchain/indexers/txindex.go index 3d4e914677..b4573276f7 100644 --- a/blockchain/indexers/txindex.go +++ b/blockchain/indexers/txindex.go @@ -9,10 +9,10 @@ import ( "fmt" "github.com/btcsuite/btcd/blockchain" - "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/btcutil/v2" + "github.com/btcsuite/btcd/chainhash/v2" "github.com/btcsuite/btcd/database" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/wire/v2" ) const ( diff --git a/blockchain/interfaces.go b/blockchain/interfaces.go index cae9b3b9f0..53d089bc08 100644 --- a/blockchain/interfaces.go +++ b/blockchain/interfaces.go @@ -1,8 +1,8 @@ package blockchain import ( - "github.com/btcsuite/btcd/chaincfg" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/chaincfg/v2" + "github.com/btcsuite/btcd/chainhash/v2" ) // ChainCtx is an interface that abstracts away blockchain parameters. diff --git a/blockchain/merkle.go b/blockchain/merkle.go index a1a50a2bd5..b44578b5c6 100644 --- a/blockchain/merkle.go +++ b/blockchain/merkle.go @@ -9,9 +9,9 @@ import ( "fmt" "math" - "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/chaincfg/chainhash" - "github.com/btcsuite/btcd/txscript" + "github.com/btcsuite/btcd/btcutil/v2" + "github.com/btcsuite/btcd/chainhash/v2" + "github.com/btcsuite/btcd/txscript/v2" ) const ( diff --git a/blockchain/merkle_test.go b/blockchain/merkle_test.go index 06eb7012a2..b5e5b6c526 100644 --- a/blockchain/merkle_test.go +++ b/blockchain/merkle_test.go @@ -8,9 +8,9 @@ import ( "fmt" "testing" - "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/chaincfg/chainhash" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/btcutil/v2" + "github.com/btcsuite/btcd/chainhash/v2" + "github.com/btcsuite/btcd/wire/v2" "github.com/stretchr/testify/require" ) diff --git a/blockchain/notifications_test.go b/blockchain/notifications_test.go index fde58735df..797483046a 100644 --- a/blockchain/notifications_test.go +++ b/blockchain/notifications_test.go @@ -7,7 +7,7 @@ package blockchain import ( "testing" - "github.com/btcsuite/btcd/chaincfg" + "github.com/btcsuite/btcd/chaincfg/v2" ) // TestNotifications ensures that notification callbacks are fired on events. diff --git a/blockchain/process.go b/blockchain/process.go index 64d5c1e14f..5855b2590e 100644 --- a/blockchain/process.go +++ b/blockchain/process.go @@ -8,8 +8,8 @@ import ( "fmt" "time" - "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/btcutil/v2" + "github.com/btcsuite/btcd/chainhash/v2" "github.com/btcsuite/btcd/database" ) diff --git a/blockchain/rolling_merkle.go b/blockchain/rolling_merkle.go index cd2c2ec7e6..e5052423f4 100644 --- a/blockchain/rolling_merkle.go +++ b/blockchain/rolling_merkle.go @@ -3,8 +3,8 @@ package blockchain import ( "math/bits" - "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/btcutil/v2" + "github.com/btcsuite/btcd/chainhash/v2" ) // rollingMerkleTreeStore calculates the merkle root by only allocating O(logN) diff --git a/blockchain/rolling_merkle_test.go b/blockchain/rolling_merkle_test.go index e425278bdd..9d744b857c 100644 --- a/blockchain/rolling_merkle_test.go +++ b/blockchain/rolling_merkle_test.go @@ -3,7 +3,7 @@ package blockchain import ( "testing" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/chainhash/v2" "github.com/stretchr/testify/require" ) diff --git a/blockchain/scriptval.go b/blockchain/scriptval.go index 614e030c86..427050f6de 100644 --- a/blockchain/scriptval.go +++ b/blockchain/scriptval.go @@ -10,9 +10,9 @@ import ( "runtime" "time" - "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/txscript" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/btcutil/v2" + "github.com/btcsuite/btcd/txscript/v2" + "github.com/btcsuite/btcd/wire/v2" ) // txValidateItem holds a transaction along with which input to validate. diff --git a/blockchain/scriptval_test.go b/blockchain/scriptval_test.go index 031f04801f..f0855ecc96 100644 --- a/blockchain/scriptval_test.go +++ b/blockchain/scriptval_test.go @@ -8,7 +8,7 @@ import ( "fmt" "testing" - "github.com/btcsuite/btcd/txscript" + "github.com/btcsuite/btcd/txscript/v2" ) // TestCheckBlockScripts ensures that validating the all of the scripts in a diff --git a/blockchain/thresholdstate.go b/blockchain/thresholdstate.go index d62c2de3c2..cf7aa4b2a2 100644 --- a/blockchain/thresholdstate.go +++ b/blockchain/thresholdstate.go @@ -8,8 +8,8 @@ import ( "fmt" "time" - "github.com/btcsuite/btcd/chaincfg/chainhash" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/chainhash/v2" + "github.com/btcsuite/btcd/wire/v2" ) // ThresholdState define the various threshold states used when voting on diff --git a/blockchain/thresholdstate_test.go b/blockchain/thresholdstate_test.go index 8d527137e3..b87ae07aee 100644 --- a/blockchain/thresholdstate_test.go +++ b/blockchain/thresholdstate_test.go @@ -7,7 +7,7 @@ package blockchain import ( "testing" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/chainhash/v2" ) // TestThresholdStateStringer tests the stringized output for the diff --git a/blockchain/upgrade.go b/blockchain/upgrade.go index 34149e44a8..cacb1bb8c3 100644 --- a/blockchain/upgrade.go +++ b/blockchain/upgrade.go @@ -11,9 +11,9 @@ import ( "fmt" "time" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/chainhash/v2" "github.com/btcsuite/btcd/database" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/wire/v2" ) const ( diff --git a/blockchain/utxocache.go b/blockchain/utxocache.go index af7a3b7b6f..af39381837 100644 --- a/blockchain/utxocache.go +++ b/blockchain/utxocache.go @@ -10,11 +10,11 @@ import ( "sync" "time" - "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/btcutil/v2" + "github.com/btcsuite/btcd/chainhash/v2" "github.com/btcsuite/btcd/database" - "github.com/btcsuite/btcd/txscript" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/txscript/v2" + "github.com/btcsuite/btcd/wire/v2" ) // mapSlice is a slice of maps for utxo entries. The slice of maps are needed to diff --git a/blockchain/utxocache_test.go b/blockchain/utxocache_test.go index 20b2a5b34a..8f7ec835fc 100644 --- a/blockchain/utxocache_test.go +++ b/blockchain/utxocache_test.go @@ -13,12 +13,12 @@ import ( "testing" "time" - "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/chaincfg" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/btcutil/v2" + "github.com/btcsuite/btcd/chaincfg/v2" + "github.com/btcsuite/btcd/chainhash/v2" "github.com/btcsuite/btcd/database" "github.com/btcsuite/btcd/database/ffldb" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/wire/v2" ) func TestMapSlice(t *testing.T) { diff --git a/blockchain/utxoviewpoint.go b/blockchain/utxoviewpoint.go index fdd165c095..38f6e1bb1d 100644 --- a/blockchain/utxoviewpoint.go +++ b/blockchain/utxoviewpoint.go @@ -7,11 +7,11 @@ package blockchain import ( "fmt" - "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/btcutil/v2" + "github.com/btcsuite/btcd/chainhash/v2" "github.com/btcsuite/btcd/database" - "github.com/btcsuite/btcd/txscript" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/txscript/v2" + "github.com/btcsuite/btcd/wire/v2" ) // txoFlags is a bitmask defining additional information and state for a diff --git a/blockchain/validate.go b/blockchain/validate.go index 02d36134b1..db3d9cc96e 100644 --- a/blockchain/validate.go +++ b/blockchain/validate.go @@ -12,11 +12,11 @@ import ( "math/big" "time" - "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/chaincfg" - "github.com/btcsuite/btcd/chaincfg/chainhash" - "github.com/btcsuite/btcd/txscript" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/btcutil/v2" + "github.com/btcsuite/btcd/chaincfg/v2" + "github.com/btcsuite/btcd/chainhash/v2" + "github.com/btcsuite/btcd/txscript/v2" + "github.com/btcsuite/btcd/wire/v2" ) const ( diff --git a/blockchain/validate_test.go b/blockchain/validate_test.go index ddd59130c1..7e698ce0b8 100644 --- a/blockchain/validate_test.go +++ b/blockchain/validate_test.go @@ -10,10 +10,10 @@ import ( "testing" "time" - "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/chaincfg" - "github.com/btcsuite/btcd/chaincfg/chainhash" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/btcutil/v2" + "github.com/btcsuite/btcd/chaincfg/v2" + "github.com/btcsuite/btcd/chainhash/v2" + "github.com/btcsuite/btcd/wire/v2" ) // TestSequenceLocksActive tests the SequenceLockActive function to ensure it diff --git a/blockchain/versionbits.go b/blockchain/versionbits.go index 371d4f20e0..dfa88a5578 100644 --- a/blockchain/versionbits.go +++ b/blockchain/versionbits.go @@ -5,7 +5,7 @@ package blockchain import ( - "github.com/btcsuite/btcd/chaincfg" + "github.com/btcsuite/btcd/chaincfg/v2" ) const ( diff --git a/blockchain/weight.go b/blockchain/weight.go index 1b691f0086..ba48b5cf6c 100644 --- a/blockchain/weight.go +++ b/blockchain/weight.go @@ -7,9 +7,9 @@ package blockchain import ( "fmt" - "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/txscript" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/btcutil/v2" + "github.com/btcsuite/btcd/txscript/v2" + "github.com/btcsuite/btcd/wire/v2" ) const ( diff --git a/btcjson/chainsvrcmds.go b/btcjson/chainsvrcmds.go index aa1d4415da..9246778135 100644 --- a/btcjson/chainsvrcmds.go +++ b/btcjson/chainsvrcmds.go @@ -13,7 +13,7 @@ import ( "fmt" "reflect" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/wire/v2" ) // AddNodeSubCmd defines the type used in the addnode JSON-RPC command for the diff --git a/btcjson/chainsvrcmds_test.go b/btcjson/chainsvrcmds_test.go index 99983288b1..0b4dd74541 100644 --- a/btcjson/chainsvrcmds_test.go +++ b/btcjson/chainsvrcmds_test.go @@ -13,7 +13,7 @@ import ( "testing" "github.com/btcsuite/btcd/btcjson" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/wire/v2" ) // TestChainSvrCmds tests all of the chain server commands marshal and unmarshal diff --git a/btcjson/chainsvrresults.go b/btcjson/chainsvrresults.go index 41b93f8570..5f8c81011e 100644 --- a/btcjson/chainsvrresults.go +++ b/btcjson/chainsvrresults.go @@ -9,10 +9,10 @@ import ( "encoding/hex" "encoding/json" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/chainhash/v2" - "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/btcutil/v2" + "github.com/btcsuite/btcd/wire/v2" ) // GetBlockHeaderVerboseResult models the data from the getblockheader command when diff --git a/btcjson/chainsvrresults_test.go b/btcjson/chainsvrresults_test.go index 8a11197af2..616266c8d1 100644 --- a/btcjson/chainsvrresults_test.go +++ b/btcjson/chainsvrresults_test.go @@ -11,8 +11,8 @@ import ( "testing" "github.com/btcsuite/btcd/btcjson" - "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/btcutil/v2" + "github.com/btcsuite/btcd/chainhash/v2" "github.com/davecgh/go-spew/spew" ) diff --git a/btcjson/walletsvrcmds.go b/btcjson/walletsvrcmds.go index 979ab0c25b..9bc77922ff 100644 --- a/btcjson/walletsvrcmds.go +++ b/btcjson/walletsvrcmds.go @@ -12,7 +12,7 @@ import ( "encoding/json" "fmt" - "github.com/btcsuite/btcd/btcutil" + "github.com/btcsuite/btcd/btcutil/v2" ) // AddMultisigAddressCmd defines the addmutisigaddress JSON-RPC command. diff --git a/btcjson/walletsvrcmds_test.go b/btcjson/walletsvrcmds_test.go index 0b5355e511..52a1c4d864 100644 --- a/btcjson/walletsvrcmds_test.go +++ b/btcjson/walletsvrcmds_test.go @@ -12,7 +12,7 @@ import ( "testing" "github.com/btcsuite/btcd/btcjson" - "github.com/btcsuite/btcd/btcutil" + "github.com/btcsuite/btcd/btcutil/v2" ) // TestWalletSvrCmds tests all of the wallet server commands marshal and diff --git a/btcjson/walletsvrresults.go b/btcjson/walletsvrresults.go index d85db0a6fa..2e3e36c260 100644 --- a/btcjson/walletsvrresults.go +++ b/btcjson/walletsvrresults.go @@ -8,7 +8,7 @@ import ( "encoding/json" "fmt" - "github.com/btcsuite/btcd/txscript" + "github.com/btcsuite/btcd/txscript/v2" ) // CreateWalletResult models the result of the createwallet command. diff --git a/btcjson/walletsvrresults_test.go b/btcjson/walletsvrresults_test.go index fd44b066b8..86a10cd799 100644 --- a/btcjson/walletsvrresults_test.go +++ b/btcjson/walletsvrresults_test.go @@ -10,7 +10,7 @@ import ( "reflect" "testing" - "github.com/btcsuite/btcd/txscript" + "github.com/btcsuite/btcd/txscript/v2" "github.com/davecgh/go-spew/spew" ) diff --git a/btcutil/README.md b/btcutil/README.md index ad32607ca5..17b9feaf49 100644 --- a/btcutil/README.md +++ b/btcutil/README.md @@ -1,9 +1,9 @@ btcutil ======= -[![Build Status](https://github.com/btcsuite/btcd/btcutil/workflows/Build%20and%20Test/badge.svg)](https://github.com/btcsuite/btcd/btcutil/actions) +[![Build Status](https://github.com/btcsuite/btcd/workflows/Build%20and%20Test/badge.svg)](https://github.com/btcsuite/btcd/actions) [![ISC License](https://img.shields.io/badge/license-ISC-blue.svg)](http://copyfree.org) -[![GoDoc](https://img.shields.io/badge/godoc-reference-blue.svg)](https://godoc.org/github.com/btcsuite/btcd/btcutil) +[![GoDoc](https://img.shields.io/badge/godoc-reference-blue.svg)](https://godoc.org/github.com/btcsuite/btcd/btcutil/v2) Package btcutil provides bitcoin-specific convenience functions and types. A comprehensive suite of tests is provided to ensure proper functionality. See @@ -20,7 +20,7 @@ provided. ## Installation and Updating ```bash -$ go get -u github.com/btcsuite/btcd/btcutil +$ go get -u github.com/btcsuite/btcd/btcutil/v2 ``` ## GPG Verification Key diff --git a/btcutil/amount.go b/btcutil/amount.go index bb70c9b11d..d6016e6602 100644 --- a/btcutil/amount.go +++ b/btcutil/amount.go @@ -74,7 +74,7 @@ func round(f float64) Amount { // NewAmount is for specifically for converting BTC to Satoshi. // For creating a new Amount with an int64 value which denotes a quantity of Satoshi, // do a simple type conversion from type int64 to Amount. -// See GoDoc for example: http://godoc.org/github.com/btcsuite/btcd/btcutil#example-Amount +// See GoDoc for example: http://godoc.org/github.com/btcsuite/btcd/btcutil/v2#example-Amount func NewAmount(f float64) (Amount, error) { // The amount is only considered invalid if it cannot be represented // as an integer type. This may happen if f is NaN or +-Infinity. diff --git a/btcutil/bloom/filter_test.go b/btcutil/bloom/filter_test.go index 15cb06a51e..d5cadd4cbf 100644 --- a/btcutil/bloom/filter_test.go +++ b/btcutil/bloom/filter_test.go @@ -9,6 +9,7 @@ import ( "encoding/hex" "testing" + "github.com/btcsuite/btcd/address/v2" "github.com/btcsuite/btcd/btcutil/v2" "github.com/btcsuite/btcd/btcutil/v2/bloom" "github.com/btcsuite/btcd/chainhash/v2" @@ -222,7 +223,7 @@ func TestFilterInsertKey(t *testing.T) { f := bloom.NewFilter(2, 0, 0.001, wire.BloomUpdateAll) f.Add(wif.SerializePubKey()) - f.Add(btcutil.Hash160(wif.SerializePubKey())) + f.Add(address.Hash160(wif.SerializePubKey())) want, err := hex.DecodeString("038fc16b080000000000000001") if err != nil { diff --git a/btcutil/bloom/merkleblock_test.go b/btcutil/bloom/merkleblock_test.go index 0e5fc0049d..100c6679fd 100644 --- a/btcutil/bloom/merkleblock_test.go +++ b/btcutil/bloom/merkleblock_test.go @@ -9,8 +9,8 @@ import ( "encoding/hex" "testing" - "github.com/btcsuite/btcd/btcutil/v2/bloom" "github.com/btcsuite/btcd/btcutil/v2" + "github.com/btcsuite/btcd/btcutil/v2/bloom" "github.com/btcsuite/btcd/chainhash/v2" "github.com/btcsuite/btcd/wire/v2" ) diff --git a/btcutil/coinset/coins_test.go b/btcutil/coinset/coins_test.go index b54c566642..276ecf632b 100644 --- a/btcutil/coinset/coins_test.go +++ b/btcutil/coinset/coins_test.go @@ -11,8 +11,8 @@ import ( "fmt" "testing" - "github.com/btcsuite/btcd/btcutil/v2/coinset" "github.com/btcsuite/btcd/btcutil/v2" + "github.com/btcsuite/btcd/btcutil/v2/coinset" "github.com/btcsuite/btcd/chainhash/v2" "github.com/btcsuite/btcd/wire/v2" ) diff --git a/btcutil/gcs/README.md b/btcutil/gcs/README.md index ee0c120401..ff9b14e33a 100644 --- a/btcutil/gcs/README.md +++ b/btcutil/gcs/README.md @@ -15,7 +15,7 @@ A comprehensive suite of tests is provided to ensure proper functionality. ## Installation and Updating ```bash -$ go get -u github.com/btcsuite/btcd/btcutil/gcs +$ go get -u github.com/btcsuite/btcd/btcutil/v2/gcs ``` ## License diff --git a/btcutil/gcs/builder/builder_test.go b/btcutil/gcs/builder/builder_test.go index f9b1100eb8..64fdf7cdab 100644 --- a/btcutil/gcs/builder/builder_test.go +++ b/btcutil/gcs/builder/builder_test.go @@ -9,13 +9,13 @@ import ( "encoding/hex" "testing" - "github.com/btcsuite/btcd/btcutil/v2/gcs/builder" + "github.com/btcsuite/btcd/address/v2" "github.com/btcsuite/btcd/btcutil/v2/gcs" + "github.com/btcsuite/btcd/btcutil/v2/gcs/builder" "github.com/btcsuite/btcd/chaincfg/v2" "github.com/btcsuite/btcd/chainhash/v2" "github.com/btcsuite/btcd/txscript/v2" "github.com/btcsuite/btcd/wire/v2" - "github.com/btcsuite/btcd/btcutil/v2" ) var ( @@ -77,7 +77,7 @@ func TestUseBlockHash(t *testing.T) { } // btcutil.Address - addr, err := btcutil.DecodeAddress(testAddr, &chaincfg.MainNetParams) + addr, err := address.DecodeAddress(testAddr, &chaincfg.MainNetParams) if err != nil { t.Fatalf("Address decode failed: %s", err.Error()) } diff --git a/btcutil/txsort/README.md b/btcutil/txsort/README.md index cb8e4130d1..bb7e9288f0 100644 --- a/btcutil/txsort/README.md +++ b/btcutil/txsort/README.md @@ -1,9 +1,9 @@ txsort ====== -[![Build Status](http://img.shields.io/travis/btcsuite/btcutil.svg)](https://travis-ci.org/btcsuite/btcutil) +[![Build Status](https://github.com/btcsuite/btcd/workflows/Build%20and%20Test/badge.svg)](https://github.com/btcsuite/btcd/actions) [![ISC License](http://img.shields.io/badge/license-ISC-blue.svg)](http://copyfree.org) -[![GoDoc](http://img.shields.io/badge/godoc-reference-blue.svg)](http://godoc.org/github.com/btcsuite/btcd/btcutil/txsort) +[![GoDoc](http://img.shields.io/badge/godoc-reference-blue.svg)](http://godoc.org/github.com/btcsuite/btcd/btcutil/v2/txsort) Package txsort provides the transaction sorting according to [BIP 69](https://github.com/bitcoin/bips/blob/master/bip-0069.mediawiki). @@ -22,7 +22,7 @@ A comprehensive suite of tests is provided to ensure proper functionality. ## Installation and Updating ```bash -$ go get -u github.com/btcsuite/btcd/btcutil/txsort +$ go get -u github.com/btcsuite/btcd/btcutil/v2/txsort ``` ## License diff --git a/btcutil/wif_test.go b/btcutil/wif_test.go index e2c2c69aaf..37d3e46e97 100644 --- a/btcutil/wif_test.go +++ b/btcutil/wif_test.go @@ -9,6 +9,7 @@ import ( "encoding/hex" "testing" + "github.com/btcsuite/btcd/address/v2" "github.com/btcsuite/btcd/btcec/v2" . "github.com/btcsuite/btcd/btcutil/v2" "github.com/btcsuite/btcd/chaincfg/v2" @@ -119,7 +120,7 @@ func TestEncodeDecodeWIF(t *testing.T) { { name: "decodeInvalidChecksumWif", wif: "5HueCGU8rMjxEXxiPuD5BDku4MkFqeZyd4dZ1jvhTVqvbTLvyTj", - err: ErrChecksumMismatch, + err: address.ErrChecksumMismatch, }, } diff --git a/chaincfg/README.md b/chaincfg/README.md index 41b9a7156b..b0d7cca9c5 100644 --- a/chaincfg/README.md +++ b/chaincfg/README.md @@ -24,7 +24,7 @@ import ( "fmt" "log" - "github.com/btcsuite/btcd/btcutil" + "github.com/btcsuite/btcd/btcutil/v2" "github.com/btcsuite/btcd/chaincfg/v2" ) diff --git a/chaincfg/doc.go b/chaincfg/doc.go index 93193dcc95..dc26adba8c 100644 --- a/chaincfg/doc.go +++ b/chaincfg/doc.go @@ -25,7 +25,7 @@ // "fmt" // "log" // -// "github.com/btcsuite/btcd/btcutil" +// "github.com/btcsuite/btcd/btcutil/v2" // "github.com/btcsuite/btcd/chaincfg/v2" // ) // diff --git a/cmd/addblock/config.go b/cmd/addblock/config.go index ffcc0eca79..a6edfddbf0 100644 --- a/cmd/addblock/config.go +++ b/cmd/addblock/config.go @@ -9,11 +9,11 @@ import ( "os" "path/filepath" - "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/chaincfg" + "github.com/btcsuite/btcd/btcutil/v2" + "github.com/btcsuite/btcd/chaincfg/v2" "github.com/btcsuite/btcd/database" _ "github.com/btcsuite/btcd/database/ffldb" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/wire/v2" flags "github.com/jessevdk/go-flags" ) diff --git a/cmd/addblock/import.go b/cmd/addblock/import.go index 8eda8f8c9b..6141549833 100644 --- a/cmd/addblock/import.go +++ b/cmd/addblock/import.go @@ -13,10 +13,10 @@ import ( "github.com/btcsuite/btcd/blockchain" "github.com/btcsuite/btcd/blockchain/indexers" - "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/btcutil/v2" + "github.com/btcsuite/btcd/chainhash/v2" "github.com/btcsuite/btcd/database" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/wire/v2" ) var zeroHash = chainhash.Hash{} diff --git a/cmd/btcctl/config.go b/cmd/btcctl/config.go index 13342e6295..fe96e01f66 100644 --- a/cmd/btcctl/config.go +++ b/cmd/btcctl/config.go @@ -14,8 +14,8 @@ import ( "strings" "github.com/btcsuite/btcd/btcjson" - "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/chaincfg" + "github.com/btcsuite/btcd/btcutil/v2" + "github.com/btcsuite/btcd/chaincfg/v2" flags "github.com/jessevdk/go-flags" ) diff --git a/cmd/findcheckpoint/config.go b/cmd/findcheckpoint/config.go index 203ed27faf..25c553b6d0 100644 --- a/cmd/findcheckpoint/config.go +++ b/cmd/findcheckpoint/config.go @@ -9,11 +9,11 @@ import ( "os" "path/filepath" - "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/chaincfg" + "github.com/btcsuite/btcd/btcutil/v2" + "github.com/btcsuite/btcd/chaincfg/v2" "github.com/btcsuite/btcd/database" _ "github.com/btcsuite/btcd/database/ffldb" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/wire/v2" flags "github.com/jessevdk/go-flags" ) diff --git a/cmd/findcheckpoint/findcheckpoint.go b/cmd/findcheckpoint/findcheckpoint.go index ec4a4b30ff..5abda99045 100644 --- a/cmd/findcheckpoint/findcheckpoint.go +++ b/cmd/findcheckpoint/findcheckpoint.go @@ -10,8 +10,8 @@ import ( "path/filepath" "github.com/btcsuite/btcd/blockchain" - "github.com/btcsuite/btcd/chaincfg" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/chaincfg/v2" + "github.com/btcsuite/btcd/chainhash/v2" "github.com/btcsuite/btcd/database" ) diff --git a/cmd/gencerts/gencerts.go b/cmd/gencerts/gencerts.go index c0a27ad37b..e6a8f1b8cc 100644 --- a/cmd/gencerts/gencerts.go +++ b/cmd/gencerts/gencerts.go @@ -12,7 +12,7 @@ import ( "strings" "time" - "github.com/btcsuite/btcd/btcutil" + "github.com/btcsuite/btcd/btcutil/v2" flags "github.com/jessevdk/go-flags" ) diff --git a/config.go b/config.go index 1fe0767f63..0135c37130 100644 --- a/config.go +++ b/config.go @@ -21,16 +21,17 @@ import ( "strings" "time" + "github.com/btcsuite/btcd/address/v2" "github.com/btcsuite/btcd/blockchain" - "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/chaincfg" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/btcutil/v2" + "github.com/btcsuite/btcd/chaincfg/v2" + "github.com/btcsuite/btcd/chainhash/v2" "github.com/btcsuite/btcd/connmgr" "github.com/btcsuite/btcd/database" _ "github.com/btcsuite/btcd/database/ffldb" "github.com/btcsuite/btcd/mempool" "github.com/btcsuite/btcd/peer" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/wire/v2" "github.com/btcsuite/go-socks/socks" flags "github.com/jessevdk/go-flags" ) @@ -182,7 +183,7 @@ type config struct { oniondial func(string, string, time.Duration) (net.Conn, error) dial func(string, string, time.Duration) (net.Conn, error) addCheckpoints []chaincfg.Checkpoint - miningAddrs []btcutil.Address + miningAddrs []address.Address minRelayTxFee btcutil.Amount whitelists []*net.IPNet } @@ -931,9 +932,9 @@ func loadConfig() (*config, []string, error) { } // Check mining addresses are valid and saved parsed versions. - cfg.miningAddrs = make([]btcutil.Address, 0, len(cfg.MiningAddrs)) + cfg.miningAddrs = make([]address.Address, 0, len(cfg.MiningAddrs)) for _, strAddr := range cfg.MiningAddrs { - addr, err := btcutil.DecodeAddress(strAddr, activeNetParams.Params) + addr, err := address.DecodeAddress(strAddr, activeNetParams.Params) if err != nil { str := "%s: mining address '%s' failed to decode: %v" err := fmt.Errorf(str, funcName, strAddr, err) diff --git a/connmgr/seed.go b/connmgr/seed.go index 4c26160d8f..744b45036d 100644 --- a/connmgr/seed.go +++ b/connmgr/seed.go @@ -11,8 +11,8 @@ import ( "strconv" "time" - "github.com/btcsuite/btcd/chaincfg" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/chaincfg/v2" + "github.com/btcsuite/btcd/wire/v2" ) const ( diff --git a/database/cmd/dbtool/fetchblock.go b/database/cmd/dbtool/fetchblock.go index 75a3e31a8f..a9a0db652a 100644 --- a/database/cmd/dbtool/fetchblock.go +++ b/database/cmd/dbtool/fetchblock.go @@ -9,7 +9,7 @@ import ( "errors" "time" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/chainhash/v2" "github.com/btcsuite/btcd/database" ) diff --git a/database/cmd/dbtool/fetchblockregion.go b/database/cmd/dbtool/fetchblockregion.go index 9d63ed172a..3c86d64898 100644 --- a/database/cmd/dbtool/fetchblockregion.go +++ b/database/cmd/dbtool/fetchblockregion.go @@ -10,7 +10,7 @@ import ( "strconv" "time" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/chainhash/v2" "github.com/btcsuite/btcd/database" ) diff --git a/database/cmd/dbtool/globalconfig.go b/database/cmd/dbtool/globalconfig.go index 4e58168a33..117c8aea67 100644 --- a/database/cmd/dbtool/globalconfig.go +++ b/database/cmd/dbtool/globalconfig.go @@ -10,11 +10,11 @@ import ( "os" "path/filepath" - "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/chaincfg" + "github.com/btcsuite/btcd/btcutil/v2" + "github.com/btcsuite/btcd/chaincfg/v2" "github.com/btcsuite/btcd/database" _ "github.com/btcsuite/btcd/database/ffldb" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/wire/v2" ) var ( diff --git a/database/cmd/dbtool/insecureimport.go b/database/cmd/dbtool/insecureimport.go index 744e29f57b..4e4d7d01d7 100644 --- a/database/cmd/dbtool/insecureimport.go +++ b/database/cmd/dbtool/insecureimport.go @@ -12,10 +12,10 @@ import ( "sync" "time" - "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/btcutil/v2" + "github.com/btcsuite/btcd/chainhash/v2" "github.com/btcsuite/btcd/database" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/wire/v2" ) // importCmd defines the configuration options for the insecureimport command. diff --git a/database/cmd/dbtool/loadheaders.go b/database/cmd/dbtool/loadheaders.go index a3ee8c735b..e1223deb84 100644 --- a/database/cmd/dbtool/loadheaders.go +++ b/database/cmd/dbtool/loadheaders.go @@ -7,7 +7,7 @@ package main import ( "time" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/chainhash/v2" "github.com/btcsuite/btcd/database" ) diff --git a/database/example_test.go b/database/example_test.go index b64baf2c8e..a3a426cddd 100644 --- a/database/example_test.go +++ b/database/example_test.go @@ -11,11 +11,11 @@ import ( "os" "path/filepath" - "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/chaincfg" + "github.com/btcsuite/btcd/btcutil/v2" + "github.com/btcsuite/btcd/chaincfg/v2" "github.com/btcsuite/btcd/database" _ "github.com/btcsuite/btcd/database/ffldb" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/wire/v2" ) // This example demonstrates creating a new database. diff --git a/database/ffldb/bench_test.go b/database/ffldb/bench_test.go index 95e498b274..5f71dde30a 100644 --- a/database/ffldb/bench_test.go +++ b/database/ffldb/bench_test.go @@ -9,8 +9,8 @@ import ( "path/filepath" "testing" - "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/chaincfg" + "github.com/btcsuite/btcd/btcutil/v2" + "github.com/btcsuite/btcd/chaincfg/v2" "github.com/btcsuite/btcd/database" ) diff --git a/database/ffldb/blockio.go b/database/ffldb/blockio.go index 2b415a17b0..cc593fec42 100644 --- a/database/ffldb/blockio.go +++ b/database/ffldb/blockio.go @@ -20,9 +20,9 @@ import ( "strings" "sync" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/chainhash/v2" "github.com/btcsuite/btcd/database" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/wire/v2" ) const ( diff --git a/database/ffldb/db.go b/database/ffldb/db.go index 8fc4d32646..4adb8c80c6 100644 --- a/database/ffldb/db.go +++ b/database/ffldb/db.go @@ -14,11 +14,11 @@ import ( "sort" "sync" - "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/btcutil/v2" + "github.com/btcsuite/btcd/chainhash/v2" "github.com/btcsuite/btcd/database" "github.com/btcsuite/btcd/database/internal/treap" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/wire/v2" "github.com/syndtr/goleveldb/leveldb" "github.com/syndtr/goleveldb/leveldb/comparer" ldberrors "github.com/syndtr/goleveldb/leveldb/errors" diff --git a/database/ffldb/driver.go b/database/ffldb/driver.go index 28ab8277e9..c8ddbf4bd1 100644 --- a/database/ffldb/driver.go +++ b/database/ffldb/driver.go @@ -8,7 +8,7 @@ import ( "fmt" "github.com/btcsuite/btcd/database" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/wire/v2" "github.com/btcsuite/btclog" ) diff --git a/database/ffldb/driver_test.go b/database/ffldb/driver_test.go index 38a84ee2f9..951ea71c55 100644 --- a/database/ffldb/driver_test.go +++ b/database/ffldb/driver_test.go @@ -12,9 +12,9 @@ import ( "reflect" "testing" - "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/chaincfg" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/btcutil/v2" + "github.com/btcsuite/btcd/chaincfg/v2" + "github.com/btcsuite/btcd/chainhash/v2" "github.com/btcsuite/btcd/database" "github.com/btcsuite/btcd/database/ffldb" ) diff --git a/database/ffldb/interface_test.go b/database/ffldb/interface_test.go index b0f275c5de..e99312d79b 100644 --- a/database/ffldb/interface_test.go +++ b/database/ffldb/interface_test.go @@ -25,11 +25,11 @@ import ( "testing" "time" - "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/chaincfg" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/btcutil/v2" + "github.com/btcsuite/btcd/chaincfg/v2" + "github.com/btcsuite/btcd/chainhash/v2" "github.com/btcsuite/btcd/database" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/wire/v2" ) var ( diff --git a/database/ffldb/whitebox_test.go b/database/ffldb/whitebox_test.go index cc7c13d45f..955234dd4c 100644 --- a/database/ffldb/whitebox_test.go +++ b/database/ffldb/whitebox_test.go @@ -17,10 +17,10 @@ import ( "path/filepath" "testing" - "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/chaincfg" + "github.com/btcsuite/btcd/btcutil/v2" + "github.com/btcsuite/btcd/chaincfg/v2" "github.com/btcsuite/btcd/database" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/wire/v2" "github.com/syndtr/goleveldb/leveldb" ldberrors "github.com/syndtr/goleveldb/leveldb/errors" ) diff --git a/database/interface.go b/database/interface.go index 7efc7c55f6..b26a429b81 100644 --- a/database/interface.go +++ b/database/interface.go @@ -8,8 +8,8 @@ package database import ( - "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/btcutil/v2" + "github.com/btcsuite/btcd/chainhash/v2" ) // Cursor represents a cursor over key/value pairs and nested buckets of a diff --git a/docs/json_rpc_api.md b/docs/json_rpc_api.md index 2c7d455457..f23d935daf 100644 --- a/docs/json_rpc_api.md +++ b/docs/json_rpc_api.md @@ -1113,7 +1113,7 @@ import ( "path/filepath" "github.com/btcsuite/btcd/rpcclient" - "github.com/btcsuite/btcd/btcutil" + "github.com/btcsuite/btcd/btcutil/v2" ) func main() { @@ -1175,9 +1175,9 @@ import ( "path/filepath" "time" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/chainhash/v2" "github.com/btcsuite/btcd/rpcclient" - "github.com/btcsuite/btcd/btcutil" + "github.com/btcsuite/btcd/btcutil/v2" ) func main() { @@ -1267,9 +1267,9 @@ import ( "path/filepath" "time" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/chainhash/v2" "github.com/btcsuite/btcd/rpcclient" - "github.com/btcsuite/btcd/btcutil" + "github.com/btcsuite/btcd/btcutil/v2" ) func main() { diff --git a/go.mod b/go.mod index 977682aae2..def1fcd392 100644 --- a/go.mod +++ b/go.mod @@ -1,35 +1,58 @@ module github.com/btcsuite/btcd require ( - github.com/btcsuite/btcd/btcec/v2 v2.1.3 - github.com/btcsuite/btcd/btcutil v1.1.0 - github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0 + github.com/btcsuite/btcd/address/v2 v2.0.0 + github.com/btcsuite/btcd/btcec/v2 v2.3.2 + github.com/btcsuite/btcd/btcutil/v2 v2.0.0 + github.com/btcsuite/btcd/chaincfg/v2 v2.0.0 + github.com/btcsuite/btcd/chainhash/v2 v2.0.0 + github.com/btcsuite/btcd/txscript/v2 v2.0.0 + github.com/btcsuite/btcd/wire/v2 v2.0.0 github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792 github.com/btcsuite/winsvc v1.0.0 github.com/davecgh/go-spew v1.1.1 - github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 github.com/decred/dcrd/lru v1.0.0 github.com/gorilla/websocket v1.5.0 github.com/jessevdk/go-flags v1.4.0 github.com/jrick/logrotate v1.0.0 - github.com/stretchr/testify v1.7.0 + github.com/stretchr/testify v1.8.4 github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 - golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 - golang.org/x/sys v0.0.0-20200814200057-3d37ad5750ed + golang.org/x/crypto v0.17.0 + golang.org/x/sys v0.15.0 ) require ( github.com/aead/siphash v1.0.1 // indirect - github.com/decred/dcrd/crypto/blake256 v1.0.0 // indirect + github.com/decred/dcrd/crypto/blake256 v1.0.1 // indirect + github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect github.com/golang/snappy v0.0.4 // indirect - github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23 // indirect + github.com/kkdai/bstream v1.0.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect ) -replace github.com/btcsuite/btcd/btcutil => ./btcutil +// TODO(guggero): Remove this as soon as we have a tagged version of address. +replace github.com/btcsuite/btcd/address/v2 => ./address + +// TODO(guggero): Remove this as soon as we have a tagged version of btcec. +replace github.com/btcsuite/btcd/btcec/v2 => ./btcec + +// TODO(guggero): Remove this as soon as we have a tagged version of btcutil. +replace github.com/btcsuite/btcd/btcutil/v2 => ./btcutil + +// TODO(guggero): Remove this as soon as we have a tagged version of chaincfg. +replace github.com/btcsuite/btcd/chaincfg/v2 => ./chaincfg + +// TODO(guggero): Remove this as soon as we have a tagged version of chainhash. +replace github.com/btcsuite/btcd/chainhash/v2 => ./chainhash + +// TODO(guggero): Remove this as soon as we have a tagged version of txscript. +replace github.com/btcsuite/btcd/txscript/v2 => ./txscript + +// TODO(guggero): Remove this as soon as we have a tagged version of wire. +replace github.com/btcsuite/btcd/wire/v2 => ./wire // The retract statements below fixes an accidental push of the tags of a btcd // fork. @@ -63,4 +86,4 @@ retract ( v0.13.0-beta ) -go 1.17 +go 1.19 diff --git a/go.sum b/go.sum index 9944f70ec3..dbc840f074 100644 --- a/go.sum +++ b/go.sum @@ -1,12 +1,5 @@ github.com/aead/siphash v1.0.1 h1:FwHfE/T45KPKYuuSAKyyvE+oPWcaQ+CUmFW0bPlM+kg= github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII= -github.com/btcsuite/btcd v0.23.5-0.20231215221805-96c9fd8078fd/go.mod h1:nm3Bko6zh6bWP60UxwoT5LzdGJsQJaPo6HjduXq9p6A= -github.com/btcsuite/btcd/btcec/v2 v2.1.3 h1:xM/n3yIhHAhHy04z4i43C8p4ehixJZMsnrVJkgl+MTE= -github.com/btcsuite/btcd/btcec/v2 v2.1.3/go.mod h1:ctjw4H1kknNJmRN4iP1R7bTQ+v3GJkZBd6mui8ZsAZE= -github.com/btcsuite/btcd/chaincfg/chainhash v1.0.0/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= -github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= -github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0 h1:59Kx4K6lzOW5w6nFlA0v5+lk/6sjybR934QNHSJZPTQ= -github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f h1:bAs4lUbRJpnnkd9VhRV3jjAVU7DJVjMaK+IsvSeZvFo= github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA= github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd h1:R/opQEbFEy9JGkIguV40SvRY1uliPX8ifOvi6ICsFCw= @@ -15,13 +8,12 @@ github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792 h1:R8vQdOQdZ9Y3 github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtEyQwv5/p4Mg4C0fgbePVuGr935/5ddU9Z3TmDRY= github.com/btcsuite/winsvc v1.0.0 h1:J9B4L7e3oqhXOcm+2IuNApwzQec85lE+QaikUcCs+dk= github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/decred/dcrd/crypto/blake256 v1.0.0 h1:/8DMNYp9SGi5f0w7uCm6d6M4OU2rGFK09Y2A4Xv7EE0= -github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc= -github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 h1:YLtO71vCjJRCBcrPMtQ9nqBsqpA1m5sE92cU+pd5Mcc= -github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs= +github.com/decred/dcrd/crypto/blake256 v1.0.1 h1:7PltbUIQB7u/FfZ39+DGa/ShuMyJ5ilcvdfma9wOH6Y= +github.com/decred/dcrd/crypto/blake256 v1.0.1/go.mod h1:2OfgNZ5wDpcsFmHmCK5gZTPcCXqlm2ArzUIkw9czNJo= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 h1:8UrgZ3GkP4i/CLijOJx79Yu+etlyjdBU4sfcs2WYQMs= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0= github.com/decred/dcrd/lru v1.0.0 h1:Kbsb1SFDsIlaupWPwsPp+dkxiBY1frcS07PCPgotKz8= github.com/decred/dcrd/lru v1.0.0/go.mod h1:mxKOwFd7lFjN2GZYsiz/ecgqR6kkYAl+0pz0tEMk218= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= @@ -46,8 +38,8 @@ github.com/jessevdk/go-flags v1.4.0 h1:4IU2WS7AumrZ/40jfhf4QVDMsQwqA7VEHozFRrGAR github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/jrick/logrotate v1.0.0 h1:lQ1bL/n9mBNeIXoTUoYRlK4dHuNJVofX9oWqBtPnSzI= github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ= -github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23 h1:FOOIBWrEkLgmlgGfMuZT83xIwfPDxEI2OHu6xUmJMFE= -github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4= +github.com/kkdai/bstream v1.0.0 h1:Se5gHwgp2VT2uHfDrkbbgbgEvV9cimLELwrPJctSjg8= +github.com/kkdai/bstream v1.0.0/go.mod h1:FDnDOHt5Yx4p3FaHcioFT0QjDOtgUpvjeZqAs+NVZZA= github.com/nxadm/tail v1.4.4 h1:DQuhQpB1tVlglWS2hLQ5OV6B5r8aGxSrPc5Qo6uTN78= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= @@ -59,19 +51,19 @@ github.com/onsi/gomega v1.10.1 h1:o0+MgICZLuZ7xjH7Vx6zS/zcu93/BEp1VwkIW1mEXCE= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY= github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnkZWQJsqcURM6tKiBApRjXI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= +golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc h1:zK/HqS5bZxDptfPJNq8v7vJfXtkU7r9TLIoSr1bXaP4= golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -81,12 +73,13 @@ golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200814200057-3d37ad5750ed h1:J22ig1FUekjjkmZUM7pTKixYm8DvrYsvrBZdunYeIuQ= golang.org/x/sys v0.0.0-20200814200057-3d37ad5750ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= +golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= -golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= @@ -105,5 +98,5 @@ gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWD gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/integration/bip0009_test.go b/integration/bip0009_test.go index 5b64480410..134b446902 100644 --- a/integration/bip0009_test.go +++ b/integration/bip0009_test.go @@ -15,8 +15,8 @@ import ( "time" "github.com/btcsuite/btcd/blockchain" - "github.com/btcsuite/btcd/chaincfg" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/chaincfg/v2" + "github.com/btcsuite/btcd/chainhash/v2" "github.com/btcsuite/btcd/integration/rpctest" ) diff --git a/integration/csv_fork_test.go b/integration/csv_fork_test.go index 6b03af95de..656f32cbc4 100644 --- a/integration/csv_fork_test.go +++ b/integration/csv_fork_test.go @@ -15,14 +15,15 @@ import ( "testing" "time" + "github.com/btcsuite/btcd/address/v2" "github.com/btcsuite/btcd/blockchain" "github.com/btcsuite/btcd/btcec/v2" - "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/chaincfg" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/btcutil/v2" + "github.com/btcsuite/btcd/chaincfg/v2" + "github.com/btcsuite/btcd/chainhash/v2" "github.com/btcsuite/btcd/integration/rpctest" - "github.com/btcsuite/btcd/txscript" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/txscript/v2" + "github.com/btcsuite/btcd/wire/v2" ) const ( @@ -43,7 +44,7 @@ func makeTestOutput(r *rpctest.Harness, t *testing.T, // Using the key created above, generate a pkScript which it's able to // spend. - a, err := btcutil.NewAddressPubKey(key.PubKey().SerializeCompressed(), r.ActiveNet) + a, err := address.NewAddressPubKey(key.PubKey().SerializeCompressed(), r.ActiveNet) if err != nil { return nil, nil, nil, err } @@ -303,7 +304,7 @@ func createCSVOutput(r *rpctest.Harness, t *testing.T, // Using the script generated above, create a P2SH output which will be // accepted into the mempool. - p2shAddr, err := btcutil.NewAddressScriptHash(csvScript, r.ActiveNet) + p2shAddr, err := address.NewAddressScriptHash(csvScript, r.ActiveNet) if err != nil { return nil, nil, nil, err } diff --git a/integration/getchaintips_test.go b/integration/getchaintips_test.go index 1570ba740c..45750dd4d5 100644 --- a/integration/getchaintips_test.go +++ b/integration/getchaintips_test.go @@ -6,8 +6,8 @@ import ( "testing" "github.com/btcsuite/btcd/btcjson" - "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/chaincfg" + "github.com/btcsuite/btcd/btcutil/v2" + "github.com/btcsuite/btcd/chaincfg/v2" "github.com/btcsuite/btcd/integration/rpctest" "github.com/stretchr/testify/require" ) diff --git a/integration/prune_test.go b/integration/prune_test.go index ac363cb8ca..ef69916fd6 100644 --- a/integration/prune_test.go +++ b/integration/prune_test.go @@ -11,7 +11,7 @@ package integration import ( "testing" - "github.com/btcsuite/btcd/chaincfg" + "github.com/btcsuite/btcd/chaincfg/v2" "github.com/btcsuite/btcd/integration/rpctest" "github.com/stretchr/testify/require" ) diff --git a/integration/rpcserver_test.go b/integration/rpcserver_test.go index 7e90a36b5c..0649644682 100644 --- a/integration/rpcserver_test.go +++ b/integration/rpcserver_test.go @@ -17,8 +17,8 @@ import ( "time" "github.com/btcsuite/btcd/blockchain" - "github.com/btcsuite/btcd/chaincfg" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/chaincfg/v2" + "github.com/btcsuite/btcd/chainhash/v2" "github.com/btcsuite/btcd/integration/rpctest" "github.com/btcsuite/btcd/rpcclient" ) diff --git a/integration/rpctest/blockgen.go b/integration/rpctest/blockgen.go index 07371fb8a1..f89e2bfb72 100644 --- a/integration/rpctest/blockgen.go +++ b/integration/rpctest/blockgen.go @@ -11,13 +11,14 @@ import ( "runtime" "time" + "github.com/btcsuite/btcd/address/v2" "github.com/btcsuite/btcd/blockchain" - "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/chaincfg" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/btcutil/v2" + "github.com/btcsuite/btcd/chaincfg/v2" + "github.com/btcsuite/btcd/chainhash/v2" "github.com/btcsuite/btcd/mining" - "github.com/btcsuite/btcd/txscript" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/txscript/v2" + "github.com/btcsuite/btcd/wire/v2" ) // solveBlock attempts to find a nonce which makes the passed block header hash @@ -97,7 +98,7 @@ func standardCoinbaseScript(nextBlockHeight int32, extraNonce uint64) ([]byte, e // createCoinbaseTx returns a coinbase transaction paying an appropriate // subsidy based on the passed block height to the provided address. func createCoinbaseTx(coinbaseScript []byte, nextBlockHeight int32, - addr btcutil.Address, mineTo []wire.TxOut, + addr address.Address, mineTo []wire.TxOut, net *chaincfg.Params) (*btcutil.Tx, error) { // Create the script to pay to the provided payment address. @@ -134,7 +135,7 @@ func createCoinbaseTx(coinbaseScript []byte, nextBlockHeight int32, // second is used. Passing nil for the previous block results in a block that // builds off of the genesis block for the specified chain. func CreateBlock(prevBlock *btcutil.Block, inclusionTxs []*btcutil.Tx, - blockVersion int32, blockTime time.Time, miningAddr btcutil.Address, + blockVersion int32, blockTime time.Time, miningAddr address.Address, mineTo []wire.TxOut, net *chaincfg.Params) (*btcutil.Block, error) { var ( diff --git a/integration/rpctest/memwallet.go b/integration/rpctest/memwallet.go index d084e99feb..88d752d2e7 100644 --- a/integration/rpctest/memwallet.go +++ b/integration/rpctest/memwallet.go @@ -10,15 +10,16 @@ import ( "fmt" "sync" + "github.com/btcsuite/btcd/address/v2" "github.com/btcsuite/btcd/blockchain" "github.com/btcsuite/btcd/btcec/v2" - "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/btcutil/hdkeychain" - "github.com/btcsuite/btcd/chaincfg" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/btcutil/v2" + "github.com/btcsuite/btcd/btcutil/v2/hdkeychain" + "github.com/btcsuite/btcd/chaincfg/v2" + "github.com/btcsuite/btcd/chainhash/v2" "github.com/btcsuite/btcd/rpcclient" - "github.com/btcsuite/btcd/txscript" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/txscript/v2" + "github.com/btcsuite/btcd/wire/v2" ) var ( @@ -72,7 +73,7 @@ type undoEntry struct { // hierarchy which promotes reproducibility between harness test runs. type memWallet struct { coinbaseKey *btcec.PrivateKey - coinbaseAddr btcutil.Address + coinbaseAddr address.Address // hdRoot is the root master private key for the wallet. hdRoot *hdkeychain.ExtendedKey @@ -86,7 +87,7 @@ type memWallet struct { // addrs tracks all addresses belonging to the wallet. The addresses // are indexed by their keypath from the hdRoot. - addrs map[uint32]btcutil.Address + addrs map[uint32]address.Address // utxos is the set of utxos spendable by the wallet. utxos map[wire.OutPoint]*utxo @@ -141,7 +142,7 @@ func newMemWallet(net *chaincfg.Params, harnessID uint32) (*memWallet, error) { // Track the coinbase generation address to ensure we properly track // newly generated bitcoin we can spend. - addrs := make(map[uint32]btcutil.Address) + addrs := make(map[uint32]address.Address) addrs[0] = coinbaseAddr return &memWallet{ @@ -335,7 +336,7 @@ func (m *memWallet) unwindBlock(update *chainUpdate) { // newAddress returns a new address from the wallet's hd key chain. It also // loads the address into the RPC client's transaction filter to ensure any // transactions that involve it are delivered via the notifications. -func (m *memWallet) newAddress() (btcutil.Address, error) { +func (m *memWallet) newAddress() (address.Address, error) { index := m.hdIndex childKey, err := m.hdRoot.Derive(index) @@ -352,7 +353,7 @@ func (m *memWallet) newAddress() (btcutil.Address, error) { return nil, err } - err = m.rpc.LoadTxFilter(false, []btcutil.Address{addr}, nil) + err = m.rpc.LoadTxFilter(false, []address.Address{addr}, nil) if err != nil { return nil, err } @@ -367,7 +368,7 @@ func (m *memWallet) newAddress() (btcutil.Address, error) { // NewAddress returns a fresh address spendable by the wallet. // // This function is safe for concurrent access. -func (m *memWallet) NewAddress() (btcutil.Address, error) { +func (m *memWallet) NewAddress() (address.Address, error) { m.Lock() defer m.Unlock() @@ -584,9 +585,11 @@ func (m *memWallet) ConfirmedBalance() btcutil.Amount { } // keyToAddr maps the passed private to corresponding p2pkh address. -func keyToAddr(key *btcec.PrivateKey, net *chaincfg.Params) (btcutil.Address, error) { +func keyToAddr(key *btcec.PrivateKey, net *chaincfg.Params) (address.Address, + error) { + serializedKey := key.PubKey().SerializeCompressed() - pubKeyAddr, err := btcutil.NewAddressPubKey(serializedKey, net) + pubKeyAddr, err := address.NewAddressPubKey(serializedKey, net) if err != nil { return nil, err } diff --git a/integration/rpctest/node.go b/integration/rpctest/node.go index f9e0d4c152..2bf2fecbaf 100644 --- a/integration/rpctest/node.go +++ b/integration/rpctest/node.go @@ -14,7 +14,7 @@ import ( "runtime" "time" - "github.com/btcsuite/btcd/btcutil" + "github.com/btcsuite/btcd/btcutil/v2" rpc "github.com/btcsuite/btcd/rpcclient" ) diff --git a/integration/rpctest/rpc_harness.go b/integration/rpctest/rpc_harness.go index 2cb7e56d26..0b6b58d946 100644 --- a/integration/rpctest/rpc_harness.go +++ b/integration/rpctest/rpc_harness.go @@ -16,11 +16,12 @@ import ( "testing" "time" - "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/chaincfg" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/address/v2" + "github.com/btcsuite/btcd/btcutil/v2" + "github.com/btcsuite/btcd/chaincfg/v2" + "github.com/btcsuite/btcd/chainhash/v2" "github.com/btcsuite/btcd/rpcclient" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/wire/v2" ) const ( @@ -258,7 +259,7 @@ func (h *Harness) SetUp(createTestChain bool, numMatureOutputs uint32) error { // Filter transactions that pay to the coinbase associated with the // wallet. - filterAddrs := []btcutil.Address{h.wallet.coinbaseAddr} + filterAddrs := []address.Address{h.wallet.coinbaseAddr} if err := h.Client.LoadTxFilter(true, filterAddrs, nil); err != nil { return err } @@ -382,7 +383,7 @@ func (h *Harness) connectRPCClient() error { // wallet. // // This function is safe for concurrent access. -func (h *Harness) NewAddress() (btcutil.Address, error) { +func (h *Harness) NewAddress() (address.Address, error) { return h.wallet.NewAddress() } diff --git a/integration/rpctest/rpc_harness_test.go b/integration/rpctest/rpc_harness_test.go index 978f8d8290..3fa8da2ba1 100644 --- a/integration/rpctest/rpc_harness_test.go +++ b/integration/rpctest/rpc_harness_test.go @@ -14,11 +14,11 @@ import ( "testing" "time" - "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/chaincfg" - "github.com/btcsuite/btcd/chaincfg/chainhash" - "github.com/btcsuite/btcd/txscript" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/btcutil/v2" + "github.com/btcsuite/btcd/chaincfg/v2" + "github.com/btcsuite/btcd/chainhash/v2" + "github.com/btcsuite/btcd/txscript/v2" + "github.com/btcsuite/btcd/wire/v2" ) func testSendOutputs(r *Harness, t *testing.T) { diff --git a/integration/rpctest/utils.go b/integration/rpctest/utils.go index d4d76f2ee6..43771a8e44 100644 --- a/integration/rpctest/utils.go +++ b/integration/rpctest/utils.go @@ -8,7 +8,7 @@ import ( "reflect" "time" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/chainhash/v2" "github.com/btcsuite/btcd/rpcclient" ) diff --git a/log.go b/log.go index 71accc7c9c..0c24cf973a 100644 --- a/log.go +++ b/log.go @@ -20,7 +20,7 @@ import ( "github.com/btcsuite/btcd/mining/cpuminer" "github.com/btcsuite/btcd/netsync" "github.com/btcsuite/btcd/peer" - "github.com/btcsuite/btcd/txscript" + "github.com/btcsuite/btcd/txscript/v2" "github.com/btcsuite/btclog" "github.com/jrick/logrotate/rotator" diff --git a/mempool/error.go b/mempool/error.go index b0d42be420..21439f47a2 100644 --- a/mempool/error.go +++ b/mempool/error.go @@ -6,7 +6,7 @@ package mempool import ( "github.com/btcsuite/btcd/blockchain" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/wire/v2" ) // RuleError identifies a rule violation. It is used to indicate that diff --git a/mempool/estimatefee.go b/mempool/estimatefee.go index 2d1794b797..359d285e42 100644 --- a/mempool/estimatefee.go +++ b/mempool/estimatefee.go @@ -16,8 +16,8 @@ import ( "strings" "sync" - "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/btcutil/v2" + "github.com/btcsuite/btcd/chainhash/v2" "github.com/btcsuite/btcd/mining" ) diff --git a/mempool/estimatefee_test.go b/mempool/estimatefee_test.go index c1e0906096..23edd329f7 100644 --- a/mempool/estimatefee_test.go +++ b/mempool/estimatefee_test.go @@ -9,10 +9,10 @@ import ( "math/rand" "testing" - "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/btcutil/v2" + "github.com/btcsuite/btcd/chainhash/v2" "github.com/btcsuite/btcd/mining" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/wire/v2" ) // newTestFeeEstimator creates a feeEstimator with some different parameters diff --git a/mempool/mempool.go b/mempool/mempool.go index a80d8ee4f4..bb19b9a7fc 100644 --- a/mempool/mempool.go +++ b/mempool/mempool.go @@ -15,12 +15,12 @@ import ( "github.com/btcsuite/btcd/blockchain" "github.com/btcsuite/btcd/blockchain/indexers" "github.com/btcsuite/btcd/btcjson" - "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/chaincfg" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/btcutil/v2" + "github.com/btcsuite/btcd/chaincfg/v2" + "github.com/btcsuite/btcd/chainhash/v2" "github.com/btcsuite/btcd/mining" - "github.com/btcsuite/btcd/txscript" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/txscript/v2" + "github.com/btcsuite/btcd/wire/v2" ) const ( diff --git a/mempool/mempool_test.go b/mempool/mempool_test.go index f0f8404cc7..43ace7bb8c 100644 --- a/mempool/mempool_test.go +++ b/mempool/mempool_test.go @@ -12,13 +12,14 @@ import ( "testing" "time" + "github.com/btcsuite/btcd/address/v2" "github.com/btcsuite/btcd/blockchain" "github.com/btcsuite/btcd/btcec/v2" - "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/chaincfg" - "github.com/btcsuite/btcd/chaincfg/chainhash" - "github.com/btcsuite/btcd/txscript" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/btcutil/v2" + "github.com/btcsuite/btcd/chaincfg/v2" + "github.com/btcsuite/btcd/chainhash/v2" + "github.com/btcsuite/btcd/txscript/v2" + "github.com/btcsuite/btcd/wire/v2" ) // fakeChain is used by the pool harness to provide generated test utxos and @@ -133,7 +134,7 @@ type poolHarness struct { // payAddr is the p2sh address for the signing key and is used for the // payment address throughout the tests. signKey *btcec.PrivateKey - payAddr btcutil.Address + payAddr address.Address payScript []byte chainParams *chaincfg.Params @@ -296,7 +297,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, chainParams) + payPubKeyAddr, err := address.NewAddressPubKey(pubKeyBytes, chainParams) if err != nil { return nil, nil, err } diff --git a/mempool/policy.go b/mempool/policy.go index 758f7e06a9..5f5a0f321d 100644 --- a/mempool/policy.go +++ b/mempool/policy.go @@ -9,9 +9,9 @@ import ( "time" "github.com/btcsuite/btcd/blockchain" - "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/txscript" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/btcutil/v2" + "github.com/btcsuite/btcd/txscript/v2" + "github.com/btcsuite/btcd/wire/v2" ) const ( diff --git a/mempool/policy_test.go b/mempool/policy_test.go index 1b29d71f1f..f502022ccc 100644 --- a/mempool/policy_test.go +++ b/mempool/policy_test.go @@ -9,12 +9,13 @@ import ( "testing" "time" + "github.com/btcsuite/btcd/address/v2" "github.com/btcsuite/btcd/btcec/v2" - "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/chaincfg" - "github.com/btcsuite/btcd/chaincfg/chainhash" - "github.com/btcsuite/btcd/txscript" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/btcutil/v2" + "github.com/btcsuite/btcd/chaincfg/v2" + "github.com/btcsuite/btcd/chainhash/v2" + "github.com/btcsuite/btcd/txscript/v2" + "github.com/btcsuite/btcd/wire/v2" ) // TestCalcMinRequiredTxRelayFee tests the calcMinRequiredTxRelayFee API. @@ -292,7 +293,7 @@ func TestCheckTransactionStandard(t *testing.T) { Sequence: wire.MaxTxInSequenceNum, } addrHash := [20]byte{0x01} - addr, err := btcutil.NewAddressPubKeyHash(addrHash[:], + addr, err := address.NewAddressPubKeyHash(addrHash[:], &chaincfg.TestNet3Params) if err != nil { t.Fatalf("NewAddressPubKeyHash: unexpected error: %v", err) diff --git a/mining/cpuminer/cpuminer.go b/mining/cpuminer/cpuminer.go index 2c07f2ee1f..838a162d2b 100644 --- a/mining/cpuminer/cpuminer.go +++ b/mining/cpuminer/cpuminer.go @@ -12,12 +12,13 @@ import ( "sync" "time" + "github.com/btcsuite/btcd/address/v2" "github.com/btcsuite/btcd/blockchain" - "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/chaincfg" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/btcutil/v2" + "github.com/btcsuite/btcd/chaincfg/v2" + "github.com/btcsuite/btcd/chainhash/v2" "github.com/btcsuite/btcd/mining" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/wire/v2" ) const ( @@ -59,7 +60,7 @@ type Config struct { // MiningAddrs is a list of payment addresses to use for the generated // blocks. Each generated block will randomly choose one of them. - MiningAddrs []btcutil.Address + MiningAddrs []address.Address // ProcessBlock defines the function to call with any solved blocks. // It typically must run the provided block through the same set of diff --git a/mining/mining.go b/mining/mining.go index efc0ae235a..321204e053 100644 --- a/mining/mining.go +++ b/mining/mining.go @@ -10,12 +10,13 @@ import ( "fmt" "time" + "github.com/btcsuite/btcd/address/v2" "github.com/btcsuite/btcd/blockchain" - "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/chaincfg" - "github.com/btcsuite/btcd/chaincfg/chainhash" - "github.com/btcsuite/btcd/txscript" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/btcutil/v2" + "github.com/btcsuite/btcd/chaincfg/v2" + "github.com/btcsuite/btcd/chainhash/v2" + "github.com/btcsuite/btcd/txscript/v2" + "github.com/btcsuite/btcd/wire/v2" ) const ( @@ -250,7 +251,9 @@ func standardCoinbaseScript(nextBlockHeight int32, extraNonce uint64) ([]byte, e // // See the comment for NewBlockTemplate for more information about why the nil // address handling is useful. -func createCoinbaseTx(params *chaincfg.Params, coinbaseScript []byte, nextBlockHeight int32, addr btcutil.Address) (*btcutil.Tx, error) { +func createCoinbaseTx(params *chaincfg.Params, coinbaseScript []byte, + nextBlockHeight int32, addr address.Address) (*btcutil.Tx, error) { + // Create the script to pay to the provided payment address if one was // specified. Otherwise create a script that allows the coinbase to be // redeemable by anyone. @@ -440,7 +443,9 @@ func NewBlkTmplGenerator(policy *Policy, params *chaincfg.Params, // | transactions (while block size | | // | <= policy.BlockMinSize) | | // ----------------------------------- -- -func (g *BlkTmplGenerator) NewBlockTemplate(payToAddress btcutil.Address) (*BlockTemplate, error) { +func (g *BlkTmplGenerator) NewBlockTemplate( + payToAddress address.Address) (*BlockTemplate, error) { + // Extend the most recently known best block. best := g.chain.BestSnapshot() nextBlockHeight := best.Height + 1 diff --git a/mining/mining_test.go b/mining/mining_test.go index ba1d97771c..1b5d30350a 100644 --- a/mining/mining_test.go +++ b/mining/mining_test.go @@ -9,7 +9,7 @@ import ( "math/rand" "testing" - "github.com/btcsuite/btcd/btcutil" + "github.com/btcsuite/btcd/btcutil/v2" ) // TestTxFeePrioHeap ensures the priority queue for transaction fees and diff --git a/mining/policy.go b/mining/policy.go index 6213c2b336..da00ed5ae5 100644 --- a/mining/policy.go +++ b/mining/policy.go @@ -6,8 +6,8 @@ package mining import ( "github.com/btcsuite/btcd/blockchain" - "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/btcutil/v2" + "github.com/btcsuite/btcd/wire/v2" ) const ( diff --git a/mining/policy_test.go b/mining/policy_test.go index cc2fdfbfb2..ade62f88ab 100644 --- a/mining/policy_test.go +++ b/mining/policy_test.go @@ -9,9 +9,9 @@ import ( "testing" "github.com/btcsuite/btcd/blockchain" - "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/chaincfg/chainhash" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/btcutil/v2" + "github.com/btcsuite/btcd/chainhash/v2" + "github.com/btcsuite/btcd/wire/v2" ) // newHashFromStr converts the passed big-endian hex string into a diff --git a/netsync/blocklogger.go b/netsync/blocklogger.go index 31a6a4c509..c0e1b48ab1 100644 --- a/netsync/blocklogger.go +++ b/netsync/blocklogger.go @@ -10,7 +10,7 @@ import ( "time" "github.com/btcsuite/btcd/blockchain" - "github.com/btcsuite/btcd/btcutil" + "github.com/btcsuite/btcd/btcutil/v2" "github.com/btcsuite/btclog" ) diff --git a/netsync/interface.go b/netsync/interface.go index 6a873bd888..2e3ed5431e 100644 --- a/netsync/interface.go +++ b/netsync/interface.go @@ -6,12 +6,12 @@ package netsync import ( "github.com/btcsuite/btcd/blockchain" - "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/chaincfg" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/btcutil/v2" + "github.com/btcsuite/btcd/chaincfg/v2" + "github.com/btcsuite/btcd/chainhash/v2" "github.com/btcsuite/btcd/mempool" "github.com/btcsuite/btcd/peer" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/wire/v2" ) // PeerNotifier exposes methods to notify peers of status changes to diff --git a/netsync/manager.go b/netsync/manager.go index 41ba70aa6a..37f7326129 100644 --- a/netsync/manager.go +++ b/netsync/manager.go @@ -13,13 +13,13 @@ import ( "time" "github.com/btcsuite/btcd/blockchain" - "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/chaincfg" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/btcutil/v2" + "github.com/btcsuite/btcd/chaincfg/v2" + "github.com/btcsuite/btcd/chainhash/v2" "github.com/btcsuite/btcd/database" "github.com/btcsuite/btcd/mempool" peerpkg "github.com/btcsuite/btcd/peer" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/wire/v2" ) const ( diff --git a/params.go b/params.go index b4d1453dfb..eeb0fd4e0a 100644 --- a/params.go +++ b/params.go @@ -5,8 +5,8 @@ package main import ( - "github.com/btcsuite/btcd/chaincfg" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/chaincfg/v2" + "github.com/btcsuite/btcd/wire/v2" ) // activeNetParams is a pointer to the parameters specific to the diff --git a/peer/doc.go b/peer/doc.go index d2c66ff3cd..279aeafa06 100644 --- a/peer/doc.go +++ b/peer/doc.go @@ -145,6 +145,6 @@ raw message bytes using a format similar to hexdump -C. # Bitcoin Improvement Proposals This package supports all BIPS supported by the wire package. -(https://pkg.go.dev/github.com/btcsuite/btcd/wire#hdr-Bitcoin_Improvement_Proposals) +(https://pkg.go.dev/github.com/btcsuite/btcd/wire/v2#hdr-Bitcoin_Improvement_Proposals) */ package peer diff --git a/peer/example_test.go b/peer/example_test.go index d4662a2b4c..83ecc53d88 100644 --- a/peer/example_test.go +++ b/peer/example_test.go @@ -10,9 +10,9 @@ import ( "net" "time" - "github.com/btcsuite/btcd/chaincfg" + "github.com/btcsuite/btcd/chaincfg/v2" "github.com/btcsuite/btcd/peer" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/wire/v2" ) // mockRemotePeer creates a basic inbound peer listening on the simnet port for diff --git a/peer/log.go b/peer/log.go index 71bebd0d51..0989569292 100644 --- a/peer/log.go +++ b/peer/log.go @@ -9,9 +9,9 @@ import ( "strings" "time" - "github.com/btcsuite/btcd/chaincfg/chainhash" - "github.com/btcsuite/btcd/txscript" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/chainhash/v2" + "github.com/btcsuite/btcd/txscript/v2" + "github.com/btcsuite/btcd/wire/v2" "github.com/btcsuite/btclog" ) diff --git a/peer/peer.go b/peer/peer.go index aa66cea98f..ad72e7ebc2 100644 --- a/peer/peer.go +++ b/peer/peer.go @@ -19,9 +19,9 @@ import ( "time" "github.com/btcsuite/btcd/blockchain" - "github.com/btcsuite/btcd/chaincfg" - "github.com/btcsuite/btcd/chaincfg/chainhash" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/chaincfg/v2" + "github.com/btcsuite/btcd/chainhash/v2" + "github.com/btcsuite/btcd/wire/v2" "github.com/btcsuite/go-socks/socks" "github.com/davecgh/go-spew/spew" "github.com/decred/dcrd/lru" diff --git a/peer/peer_test.go b/peer/peer_test.go index 9df90c233d..60d74ab6c8 100644 --- a/peer/peer_test.go +++ b/peer/peer_test.go @@ -13,10 +13,10 @@ import ( "testing" "time" - "github.com/btcsuite/btcd/chaincfg" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/chaincfg/v2" + "github.com/btcsuite/btcd/chainhash/v2" "github.com/btcsuite/btcd/peer" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/wire/v2" "github.com/btcsuite/go-socks/socks" ) diff --git a/psbt/partialsig.go b/psbt/partialsig.go index dfb7004999..9d24c49b80 100644 --- a/psbt/partialsig.go +++ b/psbt/partialsig.go @@ -2,6 +2,7 @@ package psbt import ( "bytes" + "github.com/btcsuite/btcd/btcec/v2" "github.com/btcsuite/btcd/btcec/v2/ecdsa" ) diff --git a/psbt/psbt_test.go b/psbt/psbt_test.go index 4d677fb30f..4128fe5e04 100644 --- a/psbt/psbt_test.go +++ b/psbt/psbt_test.go @@ -12,7 +12,6 @@ import ( "strings" "testing" - "github.com/btcsuite/btcd/btcutil/v2" "github.com/btcsuite/btcd/chainhash/v2" "github.com/btcsuite/btcd/txscript/v2" "github.com/btcsuite/btcd/wire/v2" diff --git a/psbt/updater.go b/psbt/updater.go index 33562c37bb..efd0a761f8 100644 --- a/psbt/updater.go +++ b/psbt/updater.go @@ -17,7 +17,6 @@ import ( "github.com/btcsuite/btcd/address/v2" "github.com/btcsuite/btcd/txscript/v2" "github.com/btcsuite/btcd/wire/v2" - "github.com/btcsuite/btcd/btcutil/v2" ) // Updater encapsulates the role 'Updater' as specified in BIP174; it accepts diff --git a/rpcadapters.go b/rpcadapters.go index 5a6800c532..b783586fa6 100644 --- a/rpcadapters.go +++ b/rpcadapters.go @@ -8,12 +8,12 @@ import ( "sync/atomic" "github.com/btcsuite/btcd/blockchain" - "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/btcutil/v2" + "github.com/btcsuite/btcd/chainhash/v2" "github.com/btcsuite/btcd/mempool" "github.com/btcsuite/btcd/netsync" "github.com/btcsuite/btcd/peer" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/wire/v2" ) // rpcPeer provides a peer for use with the RPC server and implements the diff --git a/rpcclient/chain.go b/rpcclient/chain.go index b21665991f..c34fc1a34a 100644 --- a/rpcclient/chain.go +++ b/rpcclient/chain.go @@ -11,8 +11,8 @@ import ( "encoding/json" "github.com/btcsuite/btcd/btcjson" - "github.com/btcsuite/btcd/chaincfg/chainhash" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/chainhash/v2" + "github.com/btcsuite/btcd/wire/v2" ) // FutureGetBestBlockHashResult is a future promise to deliver the result of a diff --git a/rpcclient/chain_test.go b/rpcclient/chain_test.go index de8d3a740e..c22f391b08 100644 --- a/rpcclient/chain_test.go +++ b/rpcclient/chain_test.go @@ -2,13 +2,14 @@ package rpcclient import ( "errors" - "github.com/gorilla/websocket" "net/http" "net/http/httptest" "strings" "sync" "testing" "time" + + "github.com/gorilla/websocket" ) var upgrader = websocket.Upgrader{} @@ -145,7 +146,7 @@ func TestClientConnectedToWSServerRunner(t *testing.T) { } testTable := []TestTableItem{ - TestTableItem{ + { Name: "TestGetChainTxStatsAsyncSuccessTx", TestCase: func(t *testing.T) { client, serverReceivedChannel, cleanup := makeClient(t) @@ -158,7 +159,7 @@ func TestClientConnectedToWSServerRunner(t *testing.T) { } }, }, - TestTableItem{ + { Name: "TestGetChainTxStatsAsyncShutdownError", TestCase: func(t *testing.T) { client, _, cleanup := makeClient(t) @@ -191,7 +192,7 @@ func TestClientConnectedToWSServerRunner(t *testing.T) { } }, }, - TestTableItem{ + { Name: "TestGetBestBlockHashAsync", TestCase: func(t *testing.T) { client, serverReceivedChannel, cleanup := makeClient(t) diff --git a/rpcclient/example_test.go b/rpcclient/example_test.go index 9ba9adadef..9b3ac0f36c 100644 --- a/rpcclient/example_test.go +++ b/rpcclient/example_test.go @@ -6,6 +6,7 @@ package rpcclient import ( "fmt" + "github.com/btcsuite/btcd/btcjson" ) diff --git a/rpcclient/examples/btcdwebsockets/main.go b/rpcclient/examples/btcdwebsockets/main.go index e3f4c13e40..0c65648149 100644 --- a/rpcclient/examples/btcdwebsockets/main.go +++ b/rpcclient/examples/btcdwebsockets/main.go @@ -10,9 +10,9 @@ import ( "path/filepath" "time" - "github.com/btcsuite/btcd/btcutil" + "github.com/btcsuite/btcd/btcutil/v2" "github.com/btcsuite/btcd/rpcclient" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/wire/v2" ) func main() { diff --git a/rpcclient/examples/btcwalletwebsockets/main.go b/rpcclient/examples/btcwalletwebsockets/main.go index 3cbd9a3667..aee9e22393 100644 --- a/rpcclient/examples/btcwalletwebsockets/main.go +++ b/rpcclient/examples/btcwalletwebsockets/main.go @@ -10,7 +10,7 @@ import ( "path/filepath" "time" - "github.com/btcsuite/btcd/btcutil" + "github.com/btcsuite/btcd/btcutil/v2" "github.com/btcsuite/btcd/rpcclient" "github.com/davecgh/go-spew/spew" ) diff --git a/rpcclient/extensions.go b/rpcclient/extensions.go index b7517cf26e..ae44f5acf2 100644 --- a/rpcclient/extensions.go +++ b/rpcclient/extensions.go @@ -12,10 +12,10 @@ import ( "encoding/json" "fmt" + "github.com/btcsuite/btcd/address/v2" "github.com/btcsuite/btcd/btcjson" - "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/chaincfg/chainhash" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/chainhash/v2" + "github.com/btcsuite/btcd/wire/v2" ) // FutureDebugLevelResult is a future promise to deliver the result of a @@ -129,7 +129,9 @@ func (r FutureListAddressTransactionsResult) Receive() ([]btcjson.ListTransactio // See ListAddressTransactions for the blocking version and more details. // // NOTE: This is a btcd extension. -func (c *Client) ListAddressTransactionsAsync(addresses []btcutil.Address, account string) FutureListAddressTransactionsResult { +func (c *Client) ListAddressTransactionsAsync(addresses []address.Address, + account string) FutureListAddressTransactionsResult { + // Convert addresses to strings. addrs := make([]string, 0, len(addresses)) for _, addr := range addresses { @@ -143,7 +145,9 @@ func (c *Client) ListAddressTransactionsAsync(addresses []btcutil.Address, accou // with the provided addresses. // // NOTE: This is a btcwallet extension. -func (c *Client) ListAddressTransactions(addresses []btcutil.Address, account string) ([]btcjson.ListTransactionsResult, error) { +func (c *Client) ListAddressTransactions(addresses []address.Address, + account string) ([]btcjson.ListTransactionsResult, error) { + return c.ListAddressTransactionsAsync(addresses, account).Receive() } diff --git a/rpcclient/infrastructure.go b/rpcclient/infrastructure.go index cf683db0ca..bd3ba2ee3d 100644 --- a/rpcclient/infrastructure.go +++ b/rpcclient/infrastructure.go @@ -26,7 +26,7 @@ import ( "time" "github.com/btcsuite/btcd/btcjson" - "github.com/btcsuite/btcd/chaincfg" + "github.com/btcsuite/btcd/chaincfg/v2" "github.com/btcsuite/go-socks/socks" "github.com/btcsuite/websocket" ) diff --git a/rpcclient/mining.go b/rpcclient/mining.go index 9de2f27ed6..c128f126af 100644 --- a/rpcclient/mining.go +++ b/rpcclient/mining.go @@ -9,9 +9,10 @@ import ( "encoding/json" "errors" + "github.com/btcsuite/btcd/address/v2" "github.com/btcsuite/btcd/btcjson" - "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/btcutil/v2" + "github.com/btcsuite/btcd/chainhash/v2" ) // FutureGenerateResult is a future promise to deliver the result of a @@ -98,13 +99,17 @@ func (f FutureGenerateToAddressResult) Receive() ([]*chainhash.Hash, error) { // the returned instance. // // See GenerateToAddress for the blocking version and more details. -func (c *Client) GenerateToAddressAsync(numBlocks int64, address btcutil.Address, maxTries *int64) FutureGenerateToAddressResult { +func (c *Client) GenerateToAddressAsync(numBlocks int64, + address address.Address, maxTries *int64) FutureGenerateToAddressResult { + cmd := btcjson.NewGenerateToAddressCmd(numBlocks, address.EncodeAddress(), maxTries) return c.SendCmd(cmd) } // GenerateToAddress generates numBlocks blocks to the given address and returns their hashes. -func (c *Client) GenerateToAddress(numBlocks int64, address btcutil.Address, maxTries *int64) ([]*chainhash.Hash, error) { +func (c *Client) GenerateToAddress(numBlocks int64, + address address.Address, maxTries *int64) ([]*chainhash.Hash, error) { + return c.GenerateToAddressAsync(numBlocks, address, maxTries).Receive() } diff --git a/rpcclient/notify.go b/rpcclient/notify.go index 1c2814c313..813c13a06f 100644 --- a/rpcclient/notify.go +++ b/rpcclient/notify.go @@ -13,10 +13,11 @@ import ( "fmt" "time" + "github.com/btcsuite/btcd/address/v2" "github.com/btcsuite/btcd/btcjson" - "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/chaincfg/chainhash" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/btcutil/v2" + "github.com/btcsuite/btcd/chainhash/v2" + "github.com/btcsuite/btcd/wire/v2" ) var ( @@ -1079,7 +1080,9 @@ func (c *Client) notifyReceivedInternal(addresses []string) FutureNotifyReceived // NOTE: This is a btcd extension and requires a websocket connection. // // Deprecated: Use LoadTxFilterAsync instead. -func (c *Client) NotifyReceivedAsync(addresses []btcutil.Address) FutureNotifyReceivedResult { +func (c *Client) NotifyReceivedAsync( + addresses []address.Address) FutureNotifyReceivedResult { + // Not supported in HTTP POST mode. if c.config.HTTPPostMode { return newFutureError(ErrWebsocketsRequired) @@ -1119,7 +1122,7 @@ func (c *Client) NotifyReceivedAsync(addresses []btcutil.Address) FutureNotifyRe // NOTE: This is a btcd extension and requires a websocket connection. // // Deprecated: Use LoadTxFilter instead. -func (c *Client) NotifyReceived(addresses []btcutil.Address) error { +func (c *Client) NotifyReceived(addresses []address.Address) error { return c.NotifyReceivedAsync(addresses).Receive() } @@ -1152,7 +1155,7 @@ func (r FutureRescanResult) Receive() error { // // Deprecated: Use RescanBlocksAsync instead. func (c *Client) RescanAsync(startBlock *chainhash.Hash, - addresses []btcutil.Address, + addresses []address.Address, outpoints []*wire.OutPoint) FutureRescanResult { // Not supported in HTTP POST mode. @@ -1217,7 +1220,7 @@ func (c *Client) RescanAsync(startBlock *chainhash.Hash, // // Deprecated: Use RescanBlocks instead. func (c *Client) Rescan(startBlock *chainhash.Hash, - addresses []btcutil.Address, + addresses []address.Address, outpoints []*wire.OutPoint) error { return c.RescanAsync(startBlock, addresses, outpoints).Receive() @@ -1233,7 +1236,7 @@ func (c *Client) Rescan(startBlock *chainhash.Hash, // // Deprecated: Use RescanBlocksAsync instead. func (c *Client) RescanEndBlockAsync(startBlock *chainhash.Hash, - addresses []btcutil.Address, outpoints []*wire.OutPoint, + addresses []address.Address, outpoints []*wire.OutPoint, endBlock *chainhash.Hash) FutureRescanResult { // Not supported in HTTP POST mode. @@ -1295,7 +1298,7 @@ func (c *Client) RescanEndBlockAsync(startBlock *chainhash.Hash, // // Deprecated: Use RescanBlocks instead. func (c *Client) RescanEndHeight(startBlock *chainhash.Hash, - addresses []btcutil.Address, outpoints []*wire.OutPoint, + addresses []address.Address, outpoints []*wire.OutPoint, endBlock *chainhash.Hash) error { return c.RescanEndBlockAsync(startBlock, addresses, outpoints, @@ -1327,7 +1330,7 @@ func (r FutureLoadTxFilterResult) Receive() error { // // NOTE: This is a btcd extension ported from github.com/decred/dcrrpcclient // and requires a websocket connection. -func (c *Client) LoadTxFilterAsync(reload bool, addresses []btcutil.Address, +func (c *Client) LoadTxFilterAsync(reload bool, addresses []address.Address, outPoints []wire.OutPoint) FutureLoadTxFilterResult { addrStrs := make([]string, len(addresses)) @@ -1352,6 +1355,8 @@ func (c *Client) LoadTxFilterAsync(reload bool, addresses []btcutil.Address, // // NOTE: This is a btcd extension ported from github.com/decred/dcrrpcclient // and requires a websocket connection. -func (c *Client) LoadTxFilter(reload bool, addresses []btcutil.Address, outPoints []wire.OutPoint) error { +func (c *Client) LoadTxFilter(reload bool, addresses []address.Address, + outPoints []wire.OutPoint) error { + return c.LoadTxFilterAsync(reload, addresses, outPoints).Receive() } diff --git a/rpcclient/rawtransactions.go b/rpcclient/rawtransactions.go index 1df6195220..98a6eeb169 100644 --- a/rpcclient/rawtransactions.go +++ b/rpcclient/rawtransactions.go @@ -9,10 +9,11 @@ import ( "encoding/hex" "encoding/json" + "github.com/btcsuite/btcd/address/v2" "github.com/btcsuite/btcd/btcjson" - "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/chaincfg/chainhash" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/btcutil/v2" + "github.com/btcsuite/btcd/chainhash/v2" + "github.com/btcsuite/btcd/wire/v2" ) const ( @@ -291,7 +292,7 @@ func (r FutureCreateRawTransactionResult) Receive() (*wire.MsgTx, error) { // // See CreateRawTransaction for the blocking version and more details. func (c *Client) CreateRawTransactionAsync(inputs []btcjson.TransactionInput, - amounts map[btcutil.Address]btcutil.Amount, lockTime *int64) FutureCreateRawTransactionResult { + amounts map[address.Address]btcutil.Amount, lockTime *int64) FutureCreateRawTransactionResult { convertedAmts := make(map[string]float64, len(amounts)) for addr, amount := range amounts { @@ -305,7 +306,7 @@ func (c *Client) CreateRawTransactionAsync(inputs []btcjson.TransactionInput, // and sending to the provided addresses. If the inputs are either nil or an // empty slice, it is interpreted as an empty slice. func (c *Client) CreateRawTransaction(inputs []btcjson.TransactionInput, - amounts map[btcutil.Address]btcutil.Amount, lockTime *int64) (*wire.MsgTx, error) { + amounts map[address.Address]btcutil.Amount, lockTime *int64) (*wire.MsgTx, error) { return c.CreateRawTransactionAsync(inputs, amounts, lockTime).Receive() } @@ -770,7 +771,9 @@ func (r FutureSearchRawTransactionsResult) Receive() ([]*wire.MsgTx, error) { // function on the returned instance. // // See SearchRawTransactions for the blocking version and more details. -func (c *Client) SearchRawTransactionsAsync(address btcutil.Address, skip, count int, reverse bool, filterAddrs []string) FutureSearchRawTransactionsResult { +func (c *Client) SearchRawTransactionsAsync(address address.Address, skip, + count int, reverse bool, filterAddrs []string) FutureSearchRawTransactionsResult { + addr := address.EncodeAddress() verbose := btcjson.Int(0) cmd := btcjson.NewSearchRawTransactionsCmd(addr, verbose, &skip, &count, @@ -785,7 +788,9 @@ func (c *Client) SearchRawTransactionsAsync(address btcutil.Address, skip, count // // See SearchRawTransactionsVerbose to retrieve a list of data structures with // information about the transactions instead of the transactions themselves. -func (c *Client) SearchRawTransactions(address btcutil.Address, skip, count int, reverse bool, filterAddrs []string) ([]*wire.MsgTx, error) { +func (c *Client) SearchRawTransactions(address address.Address, skip, count int, + reverse bool, filterAddrs []string) ([]*wire.MsgTx, error) { + return c.SearchRawTransactionsAsync(address, skip, count, reverse, filterAddrs).Receive() } @@ -817,8 +822,9 @@ func (r FutureSearchRawTransactionsVerboseResult) Receive() ([]*btcjson.SearchRa // function on the returned instance. // // See SearchRawTransactionsVerbose for the blocking version and more details. -func (c *Client) SearchRawTransactionsVerboseAsync(address btcutil.Address, skip, - count int, includePrevOut, reverse bool, filterAddrs *[]string) FutureSearchRawTransactionsVerboseResult { +func (c *Client) SearchRawTransactionsVerboseAsync(address address.Address, skip, + count int, includePrevOut, reverse bool, + filterAddrs *[]string) FutureSearchRawTransactionsVerboseResult { addr := address.EncodeAddress() verbose := btcjson.Int(1) @@ -838,8 +844,9 @@ func (c *Client) SearchRawTransactionsVerboseAsync(address btcutil.Address, skip // specifically been enabled. // // See SearchRawTransactions to retrieve a list of raw transactions instead. -func (c *Client) SearchRawTransactionsVerbose(address btcutil.Address, skip, - count int, includePrevOut, reverse bool, filterAddrs []string) ([]*btcjson.SearchRawTransactionsResult, error) { +func (c *Client) SearchRawTransactionsVerbose(address address.Address, skip, + count int, includePrevOut, reverse bool, + filterAddrs []string) ([]*btcjson.SearchRawTransactionsResult, error) { return c.SearchRawTransactionsVerboseAsync(address, skip, count, includePrevOut, reverse, &filterAddrs).Receive() diff --git a/rpcclient/wallet.go b/rpcclient/wallet.go index 7b7e7212c9..ae5ca012bb 100644 --- a/rpcclient/wallet.go +++ b/rpcclient/wallet.go @@ -8,11 +8,12 @@ import ( "encoding/json" "strconv" + "github.com/btcsuite/btcd/address/v2" "github.com/btcsuite/btcd/btcjson" - "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/chaincfg" - "github.com/btcsuite/btcd/chaincfg/chainhash" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/btcutil/v2" + "github.com/btcsuite/btcd/chaincfg/v2" + "github.com/btcsuite/btcd/chainhash/v2" + "github.com/btcsuite/btcd/wire/v2" ) // ***************************** @@ -244,7 +245,9 @@ func (c *Client) ListUnspentMinMaxAsync(minConf, maxConf int) FutureListUnspentR // function on the returned instance. // // See ListUnspentMinMaxAddresses for the blocking version and more details. -func (c *Client) ListUnspentMinMaxAddressesAsync(minConf, maxConf int, addrs []btcutil.Address) FutureListUnspentResult { +func (c *Client) ListUnspentMinMaxAddressesAsync(minConf, maxConf int, + addrs []address.Address) FutureListUnspentResult { + addrStrs := make([]string, 0, len(addrs)) for _, a := range addrs { addrStrs = append(addrStrs, a.EncodeAddress()) @@ -278,7 +281,9 @@ func (c *Client) ListUnspentMinMax(minConf, maxConf int) ([]btcjson.ListUnspentR // ListUnspentMinMaxAddresses returns all unspent transaction outputs that pay // to any of specified addresses in a wallet using the specified number of // minimum and maximum number of confirmations as a filter. -func (c *Client) ListUnspentMinMaxAddresses(minConf, maxConf int, addrs []btcutil.Address) ([]btcjson.ListUnspentResult, error) { +func (c *Client) ListUnspentMinMaxAddresses(minConf, maxConf int, + addrs []address.Address) ([]btcjson.ListUnspentResult, error) { + return c.ListUnspentMinMaxAddressesAsync(minConf, maxConf, addrs).Receive() } @@ -536,7 +541,9 @@ func (r FutureSendToAddressResult) Receive() (*chainhash.Hash, error) { // returned instance. // // See SendToAddress for the blocking version and more details. -func (c *Client) SendToAddressAsync(address btcutil.Address, amount btcutil.Amount) FutureSendToAddressResult { +func (c *Client) SendToAddressAsync(address address.Address, + amount btcutil.Amount) FutureSendToAddressResult { + addr := address.EncodeAddress() cmd := btcjson.NewSendToAddressCmd(addr, amount.ToBTC(), nil, nil) return c.SendCmd(cmd) @@ -550,7 +557,9 @@ func (c *Client) SendToAddressAsync(address btcutil.Address, amount btcutil.Amou // // NOTE: This function requires to the wallet to be unlocked. See the // WalletPassphrase function for more details. -func (c *Client) SendToAddress(address btcutil.Address, amount btcutil.Amount) (*chainhash.Hash, error) { +func (c *Client) SendToAddress(address address.Address, + amount btcutil.Amount) (*chainhash.Hash, error) { + return c.SendToAddressAsync(address, amount).Receive() } @@ -559,7 +568,7 @@ func (c *Client) SendToAddress(address btcutil.Address, amount btcutil.Amount) ( // function on the returned instance. // // See SendToAddressComment for the blocking version and more details. -func (c *Client) SendToAddressCommentAsync(address btcutil.Address, +func (c *Client) SendToAddressCommentAsync(address address.Address, amount btcutil.Amount, comment, commentTo string) FutureSendToAddressResult { @@ -581,7 +590,10 @@ func (c *Client) SendToAddressCommentAsync(address btcutil.Address, // // NOTE: This function requires to the wallet to be unlocked. See the // WalletPassphrase function for more details. -func (c *Client) SendToAddressComment(address btcutil.Address, amount btcutil.Amount, comment, commentTo string) (*chainhash.Hash, error) { +func (c *Client) SendToAddressComment(address address.Address, + amount btcutil.Amount, comment, commentTo string) (*chainhash.Hash, + error) { + return c.SendToAddressCommentAsync(address, amount, comment, commentTo).Receive() } @@ -615,7 +627,9 @@ func (r FutureSendFromResult) Receive() (*chainhash.Hash, error) { // returned instance. // // See SendFrom for the blocking version and more details. -func (c *Client) SendFromAsync(fromAccount string, toAddress btcutil.Address, amount btcutil.Amount) FutureSendFromResult { +func (c *Client) SendFromAsync(fromAccount string, toAddress address.Address, + amount btcutil.Amount) FutureSendFromResult { + addr := toAddress.EncodeAddress() cmd := btcjson.NewSendFromCmd(fromAccount, addr, amount.ToBTC(), nil, nil, nil) @@ -630,7 +644,9 @@ func (c *Client) SendFromAsync(fromAccount string, toAddress btcutil.Address, am // // NOTE: This function requires to the wallet to be unlocked. See the // WalletPassphrase function for more details. -func (c *Client) SendFrom(fromAccount string, toAddress btcutil.Address, amount btcutil.Amount) (*chainhash.Hash, error) { +func (c *Client) SendFrom(fromAccount string, toAddress address.Address, + amount btcutil.Amount) (*chainhash.Hash, error) { + return c.SendFromAsync(fromAccount, toAddress, amount).Receive() } @@ -639,7 +655,10 @@ func (c *Client) SendFrom(fromAccount string, toAddress btcutil.Address, amount // the returned instance. // // See SendFromMinConf for the blocking version and more details. -func (c *Client) SendFromMinConfAsync(fromAccount string, toAddress btcutil.Address, amount btcutil.Amount, minConfirms int) FutureSendFromResult { +func (c *Client) SendFromMinConfAsync(fromAccount string, + toAddress address.Address, amount btcutil.Amount, + minConfirms int) FutureSendFromResult { + addr := toAddress.EncodeAddress() cmd := btcjson.NewSendFromCmd(fromAccount, addr, amount.ToBTC(), &minConfirms, nil, nil) @@ -655,7 +674,9 @@ func (c *Client) SendFromMinConfAsync(fromAccount string, toAddress btcutil.Addr // // NOTE: This function requires to the wallet to be unlocked. See the // WalletPassphrase function for more details. -func (c *Client) SendFromMinConf(fromAccount string, toAddress btcutil.Address, amount btcutil.Amount, minConfirms int) (*chainhash.Hash, error) { +func (c *Client) SendFromMinConf(fromAccount string, toAddress address.Address, + amount btcutil.Amount, minConfirms int) (*chainhash.Hash, error) { + return c.SendFromMinConfAsync(fromAccount, toAddress, amount, minConfirms).Receive() } @@ -666,7 +687,7 @@ func (c *Client) SendFromMinConf(fromAccount string, toAddress btcutil.Address, // // See SendFromComment for the blocking version and more details. func (c *Client) SendFromCommentAsync(fromAccount string, - toAddress btcutil.Address, amount btcutil.Amount, minConfirms int, + toAddress address.Address, amount btcutil.Amount, minConfirms int, comment, commentTo string) FutureSendFromResult { addr := toAddress.EncodeAddress() @@ -686,7 +707,7 @@ func (c *Client) SendFromCommentAsync(fromAccount string, // // NOTE: This function requires to the wallet to be unlocked. See the // WalletPassphrase function for more details. -func (c *Client) SendFromComment(fromAccount string, toAddress btcutil.Address, +func (c *Client) SendFromComment(fromAccount string, toAddress address.Address, amount btcutil.Amount, minConfirms int, comment, commentTo string) (*chainhash.Hash, error) { @@ -723,7 +744,9 @@ func (r FutureSendManyResult) Receive() (*chainhash.Hash, error) { // returned instance. // // See SendMany for the blocking version and more details. -func (c *Client) SendManyAsync(fromAccount string, amounts map[btcutil.Address]btcutil.Amount) FutureSendManyResult { +func (c *Client) SendManyAsync(fromAccount string, + amounts map[address.Address]btcutil.Amount) FutureSendManyResult { + convertedAmounts := make(map[string]float64, len(amounts)) for addr, amount := range amounts { convertedAmounts[addr.EncodeAddress()] = amount.ToBTC() @@ -740,7 +763,9 @@ func (c *Client) SendManyAsync(fromAccount string, amounts map[btcutil.Address]b // // NOTE: This function requires to the wallet to be unlocked. See the // WalletPassphrase function for more details. -func (c *Client) SendMany(fromAccount string, amounts map[btcutil.Address]btcutil.Amount) (*chainhash.Hash, error) { +func (c *Client) SendMany(fromAccount string, + amounts map[address.Address]btcutil.Amount) (*chainhash.Hash, error) { + return c.SendManyAsync(fromAccount, amounts).Receive() } @@ -750,7 +775,7 @@ func (c *Client) SendMany(fromAccount string, amounts map[btcutil.Address]btcuti // // See SendManyMinConf for the blocking version and more details. func (c *Client) SendManyMinConfAsync(fromAccount string, - amounts map[btcutil.Address]btcutil.Amount, + amounts map[address.Address]btcutil.Amount, minConfirms int) FutureSendManyResult { convertedAmounts := make(map[string]float64, len(amounts)) @@ -772,7 +797,7 @@ func (c *Client) SendManyMinConfAsync(fromAccount string, // NOTE: This function requires to the wallet to be unlocked. See the // WalletPassphrase function for more details. func (c *Client) SendManyMinConf(fromAccount string, - amounts map[btcutil.Address]btcutil.Amount, + amounts map[address.Address]btcutil.Amount, minConfirms int) (*chainhash.Hash, error) { return c.SendManyMinConfAsync(fromAccount, amounts, minConfirms).Receive() @@ -784,7 +809,7 @@ func (c *Client) SendManyMinConf(fromAccount string, // // See SendManyComment for the blocking version and more details. func (c *Client) SendManyCommentAsync(fromAccount string, - amounts map[btcutil.Address]btcutil.Amount, minConfirms int, + amounts map[address.Address]btcutil.Amount, minConfirms int, comment string) FutureSendManyResult { convertedAmounts := make(map[string]float64, len(amounts)) @@ -807,7 +832,7 @@ func (c *Client) SendManyCommentAsync(fromAccount string, // NOTE: This function requires to the wallet to be unlocked. See the // WalletPassphrase function for more details. func (c *Client) SendManyComment(fromAccount string, - amounts map[btcutil.Address]btcutil.Amount, minConfirms int, + amounts map[address.Address]btcutil.Amount, minConfirms int, comment string) (*chainhash.Hash, error) { return c.SendManyCommentAsync(fromAccount, amounts, minConfirms, @@ -828,7 +853,7 @@ type FutureAddMultisigAddressResult struct { // Receive waits for the Response promised by the future and returns the // multisignature address that requires the specified number of signatures for // the provided addresses. -func (r FutureAddMultisigAddressResult) Receive() (btcutil.Address, error) { +func (r FutureAddMultisigAddressResult) Receive() (address.Address, error) { res, err := ReceiveFuture(r.responseChannel) if err != nil { return nil, err @@ -841,7 +866,7 @@ func (r FutureAddMultisigAddressResult) Receive() (btcutil.Address, error) { return nil, err } - return btcutil.DecodeAddress(addr, r.network) + return address.DecodeAddress(addr, r.network) } // AddMultisigAddressAsync returns an instance of a type that can be used to get @@ -849,7 +874,10 @@ func (r FutureAddMultisigAddressResult) Receive() (btcutil.Address, error) { // the returned instance. // // See AddMultisigAddress for the blocking version and more details. -func (c *Client) AddMultisigAddressAsync(requiredSigs int, addresses []btcutil.Address, account string) FutureAddMultisigAddressResult { +func (c *Client) AddMultisigAddressAsync(requiredSigs int, + addresses []address.Address, + account string) FutureAddMultisigAddressResult { + addrs := make([]string, 0, len(addresses)) for _, addr := range addresses { addrs = append(addrs, addr.String()) @@ -865,7 +893,9 @@ func (c *Client) AddMultisigAddressAsync(requiredSigs int, addresses []btcutil.A // AddMultisigAddress adds a multisignature address that requires the specified // number of signatures for the provided addresses to the wallet. -func (c *Client) AddMultisigAddress(requiredSigs int, addresses []btcutil.Address, account string) (btcutil.Address, error) { +func (c *Client) AddMultisigAddress(requiredSigs int, + addresses []address.Address, account string) (address.Address, error) { + return c.AddMultisigAddressAsync(requiredSigs, addresses, account).Receive() } @@ -896,7 +926,9 @@ func (r FutureCreateMultisigResult) Receive() (*btcjson.CreateMultiSigResult, er // the returned instance. // // See CreateMultisig for the blocking version and more details. -func (c *Client) CreateMultisigAsync(requiredSigs int, addresses []btcutil.Address) FutureCreateMultisigResult { +func (c *Client) CreateMultisigAsync(requiredSigs int, + addresses []address.Address) FutureCreateMultisigResult { + addrs := make([]string, 0, len(addresses)) for _, addr := range addresses { addrs = append(addrs, addr.String()) @@ -909,7 +941,9 @@ func (c *Client) CreateMultisigAsync(requiredSigs int, addresses []btcutil.Addre // CreateMultisig creates a multisignature address that requires the specified // number of signatures for the provided addresses and returns the // multisignature address and script needed to redeem it. -func (c *Client) CreateMultisig(requiredSigs int, addresses []btcutil.Address) (*btcjson.CreateMultiSigResult, error) { +func (c *Client) CreateMultisig(requiredSigs int, + addresses []address.Address) (*btcjson.CreateMultiSigResult, error) { + return c.CreateMultisigAsync(requiredSigs, addresses).Receive() } @@ -1068,7 +1102,7 @@ type FutureGetNewAddressResult struct { // Receive waits for the Response promised by the future and returns a new // address. -func (r FutureGetNewAddressResult) Receive() (btcutil.Address, error) { +func (r FutureGetNewAddressResult) Receive() (address.Address, error) { res, err := ReceiveFuture(r.responseChannel) if err != nil { return nil, err @@ -1081,7 +1115,7 @@ func (r FutureGetNewAddressResult) Receive() (btcutil.Address, error) { return nil, err } - return btcutil.DecodeAddress(addr, r.network) + return address.DecodeAddress(addr, r.network) } // GetNewAddressAsync returns an instance of a type that can be used to get the @@ -1100,7 +1134,7 @@ func (c *Client) GetNewAddressAsync(account string) FutureGetNewAddressResult { // GetNewAddress returns a new address, and decodes based on the client's // chain params. -func (c *Client) GetNewAddress(account string) (btcutil.Address, error) { +func (c *Client) GetNewAddress(account string) (address.Address, error) { return c.GetNewAddressAsync(account).Receive() } @@ -1120,7 +1154,9 @@ func (c *Client) GetNewAddressTypeAsync(account, addrType string) FutureGetNewAd // GetNewAddressType returns a new address, and decodes based on the client's // chain params. -func (c *Client) GetNewAddressType(account, addrType string) (btcutil.Address, error) { +func (c *Client) GetNewAddressType(account, + addrType string) (address.Address, error) { + return c.GetNewAddressTypeAsync(account, addrType).Receive() } @@ -1134,7 +1170,7 @@ type FutureGetRawChangeAddressResult struct { // Receive waits for the Response promised by the future and returns a new // address for receiving change that will be associated with the provided // account. Note that this is only for raw transactions and NOT for normal use. -func (r FutureGetRawChangeAddressResult) Receive() (btcutil.Address, error) { +func (r FutureGetRawChangeAddressResult) Receive() (address.Address, error) { res, err := ReceiveFuture(r.responseChannel) if err != nil { return nil, err @@ -1147,7 +1183,7 @@ func (r FutureGetRawChangeAddressResult) Receive() (btcutil.Address, error) { return nil, err } - return btcutil.DecodeAddress(addr, r.network) + return address.DecodeAddress(addr, r.network) } // GetRawChangeAddressAsync returns an instance of a type that can be used to @@ -1167,7 +1203,7 @@ func (c *Client) GetRawChangeAddressAsync(account string) FutureGetRawChangeAddr // GetRawChangeAddress returns a new address for receiving change that will be // associated with the provided account. Note that this is only for raw // transactions and NOT for normal use. -func (c *Client) GetRawChangeAddress(account string) (btcutil.Address, error) { +func (c *Client) GetRawChangeAddress(account string) (address.Address, error) { return c.GetRawChangeAddressAsync(account).Receive() } @@ -1188,7 +1224,9 @@ func (c *Client) GetRawChangeAddressTypeAsync(account, addrType string) FutureGe // GetRawChangeAddressType returns a new address for receiving change that will // be associated with the provided account. Note that this is only for raw // transactions and NOT for normal use. -func (c *Client) GetRawChangeAddressType(account, addrType string) (btcutil.Address, error) { +func (c *Client) GetRawChangeAddressType(account, + addrType string) (address.Address, error) { + return c.GetRawChangeAddressTypeAsync(account, addrType).Receive() } @@ -1201,7 +1239,7 @@ type FutureAddWitnessAddressResult struct { // Receive waits for the Response promised by the future and returns the new // address. -func (r FutureAddWitnessAddressResult) Receive() (btcutil.Address, error) { +func (r FutureAddWitnessAddressResult) Receive() (address.Address, error) { res, err := ReceiveFuture(r.responseChannel) if err != nil { return nil, err @@ -1214,7 +1252,7 @@ func (r FutureAddWitnessAddressResult) Receive() (btcutil.Address, error) { return nil, err } - return btcutil.DecodeAddress(addr, r.network) + return address.DecodeAddress(addr, r.network) } // AddWitnessAddressAsync returns an instance of a type that can be used to get @@ -1233,7 +1271,7 @@ func (c *Client) AddWitnessAddressAsync(address string) FutureAddWitnessAddressR // AddWitnessAddress adds a witness address for a script and returns the new // address (P2SH of the witness script). -func (c *Client) AddWitnessAddress(address string) (btcutil.Address, error) { +func (c *Client) AddWitnessAddress(address string) (address.Address, error) { return c.AddWitnessAddressAsync(address).Receive() } @@ -1246,7 +1284,7 @@ type FutureGetAccountAddressResult struct { // Receive waits for the Response promised by the future and returns the current // Bitcoin address for receiving payments to the specified account. -func (r FutureGetAccountAddressResult) Receive() (btcutil.Address, error) { +func (r FutureGetAccountAddressResult) Receive() (address.Address, error) { res, err := ReceiveFuture(r.responseChannel) if err != nil { return nil, err @@ -1259,7 +1297,7 @@ func (r FutureGetAccountAddressResult) Receive() (btcutil.Address, error) { return nil, err } - return btcutil.DecodeAddress(addr, r.network) + return address.DecodeAddress(addr, r.network) } // GetAccountAddressAsync returns an instance of a type that can be used to get @@ -1278,7 +1316,7 @@ func (c *Client) GetAccountAddressAsync(account string) FutureGetAccountAddressR // GetAccountAddress returns the current Bitcoin address for receiving payments // to the specified account. -func (c *Client) GetAccountAddress(account string) (btcutil.Address, error) { +func (c *Client) GetAccountAddress(account string) (address.Address, error) { return c.GetAccountAddressAsync(account).Receive() } @@ -1309,14 +1347,14 @@ func (r FutureGetAccountResult) Receive() (string, error) { // returned instance. // // See GetAccount for the blocking version and more details. -func (c *Client) GetAccountAsync(address btcutil.Address) FutureGetAccountResult { +func (c *Client) GetAccountAsync(address address.Address) FutureGetAccountResult { addr := address.EncodeAddress() cmd := btcjson.NewGetAccountCmd(addr) return c.SendCmd(cmd) } // GetAccount returns the account associated with the passed address. -func (c *Client) GetAccount(address btcutil.Address) (string, error) { +func (c *Client) GetAccount(address address.Address) (string, error) { return c.GetAccountAsync(address).Receive() } @@ -1336,14 +1374,14 @@ func (r FutureSetAccountResult) Receive() error { // returned instance. // // See SetAccount for the blocking version and more details. -func (c *Client) SetAccountAsync(address btcutil.Address, account string) FutureSetAccountResult { +func (c *Client) SetAccountAsync(address address.Address, account string) FutureSetAccountResult { addr := address.EncodeAddress() cmd := btcjson.NewSetAccountCmd(addr, account) return c.SendCmd(cmd) } // SetAccount sets the account associated with the passed address. -func (c *Client) SetAccount(address btcutil.Address, account string) error { +func (c *Client) SetAccount(address address.Address, account string) error { return c.SetAccountAsync(address, account).Receive() } @@ -1356,7 +1394,7 @@ type FutureGetAddressesByAccountResult struct { // Receive waits for the Response promised by the future and returns the list of // addresses associated with the passed account. -func (r FutureGetAddressesByAccountResult) Receive() ([]btcutil.Address, error) { +func (r FutureGetAddressesByAccountResult) Receive() ([]address.Address, error) { res, err := ReceiveFuture(r.responseChannel) if err != nil { return nil, err @@ -1369,9 +1407,9 @@ func (r FutureGetAddressesByAccountResult) Receive() ([]btcutil.Address, error) return nil, err } - addresses := make([]btcutil.Address, len(addrStrings)) + addresses := make([]address.Address, len(addrStrings)) for i, addrString := range addrStrings { - addresses[i], err = btcutil.DecodeAddress(addrString, r.network) + addresses[i], err = address.DecodeAddress(addrString, r.network) if err != nil { return nil, err } @@ -1396,7 +1434,7 @@ func (c *Client) GetAddressesByAccountAsync(account string) FutureGetAddressesBy // GetAddressesByAccount returns the list of addresses associated with the // passed account. -func (c *Client) GetAddressesByAccount(account string) ([]btcutil.Address, error) { +func (c *Client) GetAddressesByAccount(account string) ([]address.Address, error) { return c.GetAddressesByAccountAsync(account).Receive() } @@ -1544,14 +1582,18 @@ func (r FutureValidateAddressResult) Receive() (*btcjson.ValidateAddressWalletRe // the returned instance. // // See ValidateAddress for the blocking version and more details. -func (c *Client) ValidateAddressAsync(address btcutil.Address) FutureValidateAddressResult { +func (c *Client) ValidateAddressAsync( + address address.Address) FutureValidateAddressResult { + addr := address.EncodeAddress() cmd := btcjson.NewValidateAddressCmd(addr) return c.SendCmd(cmd) } // ValidateAddress returns information about the given bitcoin address. -func (c *Client) ValidateAddress(address btcutil.Address) (*btcjson.ValidateAddressWalletResult, error) { +func (c *Client) ValidateAddress( + address address.Address) (*btcjson.ValidateAddressWalletResult, error) { + return c.ValidateAddressAsync(address).Receive() } @@ -1954,7 +1996,9 @@ func (r FutureGetReceivedByAddressResult) Receive() (btcutil.Amount, error) { // function on the returned instance. // // See GetReceivedByAddress for the blocking version and more details. -func (c *Client) GetReceivedByAddressAsync(address btcutil.Address) FutureGetReceivedByAddressResult { +func (c *Client) GetReceivedByAddressAsync( + address address.Address) FutureGetReceivedByAddressResult { + addr := address.EncodeAddress() cmd := btcjson.NewGetReceivedByAddressCmd(addr, nil) return c.SendCmd(cmd) @@ -1966,7 +2010,9 @@ func (c *Client) GetReceivedByAddressAsync(address btcutil.Address) FutureGetRec // // See GetReceivedByAddressMinConf to override the minimum number of // confirmations. -func (c *Client) GetReceivedByAddress(address btcutil.Address) (btcutil.Amount, error) { +func (c *Client) GetReceivedByAddress(address address.Address) (btcutil.Amount, + error) { + return c.GetReceivedByAddressAsync(address).Receive() } @@ -1975,7 +2021,9 @@ func (c *Client) GetReceivedByAddress(address btcutil.Address) (btcutil.Amount, // function on the returned instance. // // See GetReceivedByAddressMinConf for the blocking version and more details. -func (c *Client) GetReceivedByAddressMinConfAsync(address btcutil.Address, minConfirms int) FutureGetReceivedByAddressResult { +func (c *Client) GetReceivedByAddressMinConfAsync(address address.Address, + minConfirms int) FutureGetReceivedByAddressResult { + addr := address.EncodeAddress() cmd := btcjson.NewGetReceivedByAddressCmd(addr, &minConfirms) return c.SendCmd(cmd) @@ -1985,7 +2033,9 @@ func (c *Client) GetReceivedByAddressMinConfAsync(address btcutil.Address, minCo // address with at least the specified number of minimum confirmations. // // See GetReceivedByAddress to use the default minimum number of confirmations. -func (c *Client) GetReceivedByAddressMinConf(address btcutil.Address, minConfirms int) (btcutil.Amount, error) { +func (c *Client) GetReceivedByAddressMinConf(address address.Address, + minConfirms int) (btcutil.Amount, error) { + return c.GetReceivedByAddressMinConfAsync(address, minConfirms).Receive() } @@ -2264,7 +2314,9 @@ func (r FutureSignMessageResult) Receive() (string, error) { // returned instance. // // See SignMessage for the blocking version and more details. -func (c *Client) SignMessageAsync(address btcutil.Address, message string) FutureSignMessageResult { +func (c *Client) SignMessageAsync(address address.Address, + message string) FutureSignMessageResult { + addr := address.EncodeAddress() cmd := btcjson.NewSignMessageCmd(addr, message) return c.SendCmd(cmd) @@ -2274,7 +2326,9 @@ func (c *Client) SignMessageAsync(address btcutil.Address, message string) Futur // // NOTE: This function requires to the wallet to be unlocked. See the // WalletPassphrase function for more details. -func (c *Client) SignMessage(address btcutil.Address, message string) (string, error) { +func (c *Client) SignMessage(address address.Address, message string) (string, + error) { + return c.SignMessageAsync(address, message).Receive() } @@ -2305,7 +2359,9 @@ func (r FutureVerifyMessageResult) Receive() (bool, error) { // returned instance. // // See VerifyMessage for the blocking version and more details. -func (c *Client) VerifyMessageAsync(address btcutil.Address, signature, message string) FutureVerifyMessageResult { +func (c *Client) VerifyMessageAsync(address address.Address, signature, + message string) FutureVerifyMessageResult { + addr := address.EncodeAddress() cmd := btcjson.NewVerifyMessageCmd(addr, signature, message) return c.SendCmd(cmd) @@ -2315,7 +2371,9 @@ func (c *Client) VerifyMessageAsync(address btcutil.Address, signature, message // // NOTE: This function requires to the wallet to be unlocked. See the // WalletPassphrase function for more details. -func (c *Client) VerifyMessage(address btcutil.Address, signature, message string) (bool, error) { +func (c *Client) VerifyMessage(address address.Address, signature, + message string) (bool, error) { + return c.VerifyMessageAsync(address, signature, message).Receive() } @@ -2351,7 +2409,9 @@ func (r FutureDumpPrivKeyResult) Receive() (*btcutil.WIF, error) { // returned instance. // // See DumpPrivKey for the blocking version and more details. -func (c *Client) DumpPrivKeyAsync(address btcutil.Address) FutureDumpPrivKeyResult { +func (c *Client) DumpPrivKeyAsync( + address address.Address) FutureDumpPrivKeyResult { + addr := address.EncodeAddress() cmd := btcjson.NewDumpPrivKeyCmd(addr) return c.SendCmd(cmd) @@ -2362,7 +2422,7 @@ func (c *Client) DumpPrivKeyAsync(address btcutil.Address) FutureDumpPrivKeyResu // // NOTE: This function requires to the wallet to be unlocked. See the // WalletPassphrase function for more details. -func (c *Client) DumpPrivKey(address btcutil.Address) (*btcutil.WIF, error) { +func (c *Client) DumpPrivKey(address address.Address) (*btcutil.WIF, error) { return c.DumpPrivKeyAsync(address).Receive() } diff --git a/rpcserver.go b/rpcserver.go index 94980c463f..8cd973914e 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -27,20 +27,21 @@ import ( "sync/atomic" "time" + "github.com/btcsuite/btcd/address/v2" "github.com/btcsuite/btcd/blockchain" "github.com/btcsuite/btcd/blockchain/indexers" "github.com/btcsuite/btcd/btcec/v2/ecdsa" "github.com/btcsuite/btcd/btcjson" - "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/chaincfg" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/btcutil/v2" + "github.com/btcsuite/btcd/chaincfg/v2" + "github.com/btcsuite/btcd/chainhash/v2" "github.com/btcsuite/btcd/database" "github.com/btcsuite/btcd/mempool" "github.com/btcsuite/btcd/mining" "github.com/btcsuite/btcd/mining/cpuminer" "github.com/btcsuite/btcd/peer" - "github.com/btcsuite/btcd/txscript" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/txscript/v2" + "github.com/btcsuite/btcd/wire/v2" "github.com/btcsuite/websocket" ) @@ -557,7 +558,7 @@ func handleCreateRawTransaction(s *rpcServer, cmd interface{}, closeChan <-chan } // Decode the provided address. - addr, err := btcutil.DecodeAddress(encodedAddr, params) + addr, err := address.DecodeAddress(encodedAddr, params) if err != nil { return nil, &btcjson.RPCError{ Code: btcjson.ErrRPCInvalidAddressOrKey, @@ -569,8 +570,8 @@ func handleCreateRawTransaction(s *rpcServer, cmd interface{}, closeChan <-chan // the network encoded with the address matches the network the // server is currently on. switch addr.(type) { - case *btcutil.AddressPubKeyHash: - case *btcutil.AddressScriptHash: + case *address.AddressPubKeyHash: + case *address.AddressScriptHash: default: return nil, &btcjson.RPCError{ Code: btcjson.ErrRPCInvalidAddressOrKey, @@ -849,7 +850,7 @@ func handleDecodeScript(s *rpcServer, cmd interface{}, closeChan <-chan struct{} } // Convert the script itself to a pay-to-script-hash address. - p2sh, err := btcutil.NewAddressScriptHash(script, s.cfg.ChainParams) + p2sh, err := address.NewAddressScriptHash(script, s.cfg.ChainParams) if err != nil { context := "Failed to convert script to pay-to-script-hash" return nil, internalRPCError(err.Error(), context) @@ -1595,7 +1596,7 @@ func (state *gbtWorkState) updateBlockTemplate(s *rpcServer, useCoinbaseValue bo // Choose a payment address at random if the caller requests a // full coinbase as opposed to only the pertinent details needed // to create their own coinbase. - var payAddr btcutil.Address + var payAddr address.Address if !useCoinbaseValue { payAddr = cfg.miningAddrs[rand.Intn(len(cfg.miningAddrs))] } @@ -3116,7 +3117,9 @@ func createVinListPrevOut(s *rpcServer, mtx *wire.MsgTx, chainParams *chaincfg.P // fetchMempoolTxnsForAddress queries the address index for all unconfirmed // transactions that involve the provided address. The results will be limited // by the number to skip and the number requested. -func fetchMempoolTxnsForAddress(s *rpcServer, addr btcutil.Address, numToSkip, numRequested uint32) ([]*btcutil.Tx, uint32) { +func fetchMempoolTxnsForAddress(s *rpcServer, addr address.Address, numToSkip, + numRequested uint32) ([]*btcutil.Tx, uint32) { + // There are no entries to return when there are less available than the // number being skipped. mpTxns := s.cfg.AddrIndex.UnconfirmedTxnsForAddress(addr) @@ -3166,7 +3169,7 @@ func handleSearchRawTransactions(s *rpcServer, cmd interface{}, closeChan <-chan // Attempt to decode the supplied address. params := s.cfg.ChainParams - addr, err := btcutil.DecodeAddress(c.Address, params) + addr, err := address.DecodeAddress(c.Address, params) if err != nil { return nil, &btcjson.RPCError{ Code: btcjson.ErrRPCInvalidAddressOrKey, @@ -3550,7 +3553,7 @@ func handleSignMessageWithPrivKey(s *rpcServer, cmd interface{}, closeChan <-cha switch err { case btcutil.ErrMalformedPrivateKey: message = "Malformed private key" - case btcutil.ErrChecksumMismatch: + case address.ErrChecksumMismatch: message = "Private key checksum mismatch" } return nil, &btcjson.RPCError{ @@ -3634,32 +3637,32 @@ func handleValidateAddress(s *rpcServer, cmd interface{}, closeChan <-chan struc c := cmd.(*btcjson.ValidateAddressCmd) result := btcjson.ValidateAddressChainResult{} - addr, err := btcutil.DecodeAddress(c.Address, s.cfg.ChainParams) + addr, err := address.DecodeAddress(c.Address, s.cfg.ChainParams) if err != nil { // Return the default value (false) for IsValid. return result, nil } switch addr := addr.(type) { - case *btcutil.AddressPubKeyHash: + case *address.AddressPubKeyHash: result.IsScript = btcjson.Bool(false) result.IsWitness = btcjson.Bool(false) - case *btcutil.AddressScriptHash: + case *address.AddressScriptHash: result.IsScript = btcjson.Bool(true) result.IsWitness = btcjson.Bool(false) - case *btcutil.AddressPubKey: + case *address.AddressPubKey: result.IsScript = btcjson.Bool(false) result.IsWitness = btcjson.Bool(false) - case *btcutil.AddressWitnessPubKeyHash: + case *address.AddressWitnessPubKeyHash: result.IsScript = btcjson.Bool(false) result.IsWitness = btcjson.Bool(true) result.WitnessVersion = btcjson.Int32(int32(addr.WitnessVersion())) result.WitnessProgram = btcjson.String(hex.EncodeToString(addr.WitnessProgram())) - case *btcutil.AddressWitnessScriptHash: + case *address.AddressWitnessScriptHash: result.IsScript = btcjson.Bool(true) result.IsWitness = btcjson.Bool(true) result.WitnessVersion = btcjson.Int32(int32(addr.WitnessVersion())) @@ -3734,7 +3737,7 @@ func handleVerifyMessage(s *rpcServer, cmd interface{}, closeChan <-chan struct{ // Decode the provided address. params := s.cfg.ChainParams - addr, err := btcutil.DecodeAddress(c.Address, params) + addr, err := address.DecodeAddress(c.Address, params) if err != nil { return nil, &btcjson.RPCError{ Code: btcjson.ErrRPCInvalidAddressOrKey, @@ -3743,7 +3746,7 @@ func handleVerifyMessage(s *rpcServer, cmd interface{}, closeChan <-chan struct{ } // Only P2PKH addresses are valid for signing. - if _, ok := addr.(*btcutil.AddressPubKeyHash); !ok { + if _, ok := addr.(*address.AddressPubKeyHash); !ok { return nil, &btcjson.RPCError{ Code: btcjson.ErrRPCType, Message: "Address is not a pay-to-pubkey-hash address", @@ -3780,7 +3783,7 @@ func handleVerifyMessage(s *rpcServer, cmd interface{}, closeChan <-chan struct{ } else { serializedPK = pk.SerializeUncompressed() } - address, err := btcutil.NewAddressPubKey(serializedPK, params) + addr2, err := address.NewAddressPubKey(serializedPK, params) if err != nil { // Again mirror Bitcoin Core behavior, which treats error in public key // reconstruction as invalid signature. @@ -3788,7 +3791,7 @@ func handleVerifyMessage(s *rpcServer, cmd interface{}, closeChan <-chan struct{ } // Return boolean if addresses match. - return address.EncodeAddress() == c.Address, nil + return addr2.EncodeAddress() == c.Address, nil } // handleVersion implements the version command. diff --git a/rpcwebsocket.go b/rpcwebsocket.go index aedbcf90b6..f916d2cb82 100644 --- a/rpcwebsocket.go +++ b/rpcwebsocket.go @@ -20,14 +20,15 @@ import ( "sync" "time" + "github.com/btcsuite/btcd/address/v2" "github.com/btcsuite/btcd/blockchain" "github.com/btcsuite/btcd/btcjson" - "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/chaincfg" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/btcutil/v2" + "github.com/btcsuite/btcd/chaincfg/v2" + "github.com/btcsuite/btcd/chainhash/v2" "github.com/btcsuite/btcd/database" - "github.com/btcsuite/btcd/txscript" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/txscript/v2" + "github.com/btcsuite/btcd/wire/v2" "github.com/btcsuite/websocket" "golang.org/x/crypto/ripemd160" ) @@ -296,15 +297,15 @@ func newWSClientFilter(addresses []string, unspentOutPoints []wire.OutPoint, par // on the type of address passed as an argument. // // NOTE: This extension was ported from github.com/decred/dcrd -func (f *wsClientFilter) addAddress(a btcutil.Address) { +func (f *wsClientFilter) addAddress(a address.Address) { switch a := a.(type) { - case *btcutil.AddressPubKeyHash: + case *address.AddressPubKeyHash: f.pubKeyHashes[*a.Hash160()] = struct{}{} return - case *btcutil.AddressScriptHash: + case *address.AddressScriptHash: f.scriptHashes[*a.Hash160()] = struct{}{} return - case *btcutil.AddressPubKey: + case *address.AddressPubKey: serializedPubKey := a.ScriptAddress() switch len(serializedPubKey) { case 33: // compressed @@ -331,7 +332,7 @@ func (f *wsClientFilter) addAddressStr(s string, params *chaincfg.Params) { // If address can't be decoded, no point in saving it since it should also // impossible to create the address from an inspected transaction output // script. - a, err := btcutil.DecodeAddress(s, params) + a, err := address.DecodeAddress(s, params) if err != nil { return } @@ -342,15 +343,15 @@ func (f *wsClientFilter) addAddressStr(s string, params *chaincfg.Params) { // wsClientFilter. // // NOTE: This extension was ported from github.com/decred/dcrd -func (f *wsClientFilter) existsAddress(a btcutil.Address) bool { +func (f *wsClientFilter) existsAddress(a address.Address) bool { switch a := a.(type) { - case *btcutil.AddressPubKeyHash: + case *address.AddressPubKeyHash: _, ok := f.pubKeyHashes[*a.Hash160()] return ok - case *btcutil.AddressScriptHash: + case *address.AddressScriptHash: _, ok := f.scriptHashes[*a.Hash160()] return ok - case *btcutil.AddressPubKey: + case *address.AddressPubKey: serializedPubKey := a.ScriptAddress() switch len(serializedPubKey) { case 33: // compressed @@ -380,15 +381,15 @@ func (f *wsClientFilter) existsAddress(a btcutil.Address) bool { // wsClientFilter. // // NOTE: This extension was ported from github.com/decred/dcrd -func (f *wsClientFilter) removeAddress(a btcutil.Address) { +func (f *wsClientFilter) removeAddress(a address.Address) { switch a := a.(type) { - case *btcutil.AddressPubKeyHash: + case *address.AddressPubKeyHash: delete(f.pubKeyHashes, *a.Hash160()) return - case *btcutil.AddressScriptHash: + case *address.AddressScriptHash: delete(f.scriptHashes, *a.Hash160()) return - case *btcutil.AddressPubKey: + case *address.AddressPubKey: serializedPubKey := a.ScriptAddress() switch len(serializedPubKey) { case 33: // compressed @@ -412,7 +413,7 @@ func (f *wsClientFilter) removeAddress(a btcutil.Address) { // // NOTE: This extension was ported from github.com/decred/dcrd func (f *wsClientFilter) removeAddressStr(s string, params *chaincfg.Params) { - a, err := btcutil.DecodeAddress(s, params) + a, err := address.DecodeAddress(s, params) if err == nil { f.removeAddress(a) } else { @@ -2231,7 +2232,7 @@ func handleStopNotifyReceived(wsc *wsClient, icmd interface{}) (interface{}, err // properly, the function returns an error. Otherwise, nil is returned. func checkAddressValidity(addrs []string, params *chaincfg.Params) error { for _, addr := range addrs { - _, err := btcutil.DecodeAddress(addr, params) + _, err := address.DecodeAddress(addr, params) if err != nil { return &btcjson.RPCError{ Code: btcjson.ErrRPCInvalidAddressOrKey, diff --git a/server.go b/server.go index 356326ab1c..d99010d3f9 100644 --- a/server.go +++ b/server.go @@ -25,10 +25,10 @@ import ( "github.com/btcsuite/btcd/addrmgr" "github.com/btcsuite/btcd/blockchain" "github.com/btcsuite/btcd/blockchain/indexers" - "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/btcutil/bloom" - "github.com/btcsuite/btcd/chaincfg" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/btcutil/v2" + "github.com/btcsuite/btcd/btcutil/v2/bloom" + "github.com/btcsuite/btcd/chaincfg/v2" + "github.com/btcsuite/btcd/chainhash/v2" "github.com/btcsuite/btcd/connmgr" "github.com/btcsuite/btcd/database" "github.com/btcsuite/btcd/mempool" @@ -36,8 +36,8 @@ import ( "github.com/btcsuite/btcd/mining/cpuminer" "github.com/btcsuite/btcd/netsync" "github.com/btcsuite/btcd/peer" - "github.com/btcsuite/btcd/txscript" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/txscript/v2" + "github.com/btcsuite/btcd/wire/v2" "github.com/decred/dcrd/lru" ) From 09aab7dc72a9ab4bb62bd31754f1d6b1780ec5b3 Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Tue, 19 Dec 2023 14:12:52 +0100 Subject: [PATCH 10/10] multi: update make and CI goals with new packages --- .github/workflows/go.yml | 25 +++++++++++++++++++++++-- .gitignore | 4 +--- Makefile | 28 +++++++++++++++++++++------- 3 files changed, 45 insertions(+), 12 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index c1625428d3..29e32008f2 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -45,6 +45,13 @@ jobs: flag-name: btcd parallel: true + - name: Send address + uses: shogo82148/actions-goveralls@v1 + with: + path-to-profile: address/coverage.txt + flag-name: address + parallel: true + - name: Send btcec uses: shogo82148/actions-goveralls@v1 with: @@ -52,6 +59,20 @@ jobs: flag-name: btcec parallel: true + - name: Send chaincfg + uses: shogo82148/actions-goveralls@v1 + with: + path-to-profile: chaincfg/coverage.txt + flag-name: chaincfg + parallel: true + + - name: Send chaincfg coverage for chainhash package + uses: shogo82148/actions-goveralls@v1 + with: + path-to-profile: chaincfg/chainhash/coverage.txt + flag-name: chaincfgchainhash + parallel: true + - name: Send btcutil coverage uses: shogo82148/actions-goveralls@v1 with: @@ -62,8 +83,8 @@ jobs: - name: Send btcutil coverage for psbt package uses: shogo82148/actions-goveralls@v1 with: - path-to-profile: btcutil/psbt/coverage.txt - flag-name: btcutilpsbt + path-to-profile: psbt/coverage.txt + flag-name: psbt parallel: true - name: Notify coveralls all reports sent diff --git a/.gitignore b/.gitignore index 5c29ccd9b5..38e857ac68 100644 --- a/.gitignore +++ b/.gitignore @@ -37,9 +37,7 @@ _testmain.go profile.tmp profile.cov coverage.txt -btcec/coverage.txt -btcutil/coverage.txt -btcutil/psbt/coverage.txt +coverage.txt.bak # vim *.swp diff --git a/Makefile b/Makefile index 5bfb1aa6a5..c2d80c3978 100644 --- a/Makefile +++ b/Makefile @@ -93,9 +93,14 @@ check: unit unit: @$(call print, "Running unit tests.") $(GOTEST_DEV) ./... -test.timeout=20m + cd address; $(GOTEST_DEV) ./... -test.timeout=20m cd btcec; $(GOTEST_DEV) ./... -test.timeout=20m cd btcutil; $(GOTEST_DEV) ./... -test.timeout=20m - cd btcutil/psbt; $(GOTEST_DEV) ./... -test.timeout=20m + cd chaincfg; $(GOTEST_DEV) ./... -test.timeout=20m + cd chainhash; $(GOTEST_DEV) ./... -test.timeout=20m + cd txscript; $(GOTEST_DEV) ./... -test.timeout=20m + cd psbt; $(GOTEST_DEV) ./... -test.timeout=20m + cd wire; $(GOTEST_DEV) ./... -test.timeout=20m unit-cover: $(GOACC_BIN) @$(call print, "Running unit coverage tests.") @@ -103,18 +108,26 @@ unit-cover: $(GOACC_BIN) # We need to remove the /v2 pathing from the module to have it work # nicely with the CI tool we use to render live code coverage. + cd address; $(GOACC_BIN) ./...; sed -i.bak 's/v2\///g' coverage.txt cd btcec; $(GOACC_BIN) ./...; sed -i.bak 's/v2\///g' coverage.txt - - cd btcutil; $(GOACC_BIN) ./... - - cd btcutil/psbt; $(GOACC_BIN) ./... + cd btcutil; $(GOACC_BIN) ./...; sed -i.bak 's/v2\///g' coverage.txt + cd chaincfg; $(GOACC_BIN) ./...; sed -i.bak 's/v2\///g' coverage.txt + cd chainhash; $(GOACC_BIN) ./...; sed -i.bak 's/v2\///g' coverage.txt + cd txscript; $(GOACC_BIN) ./...; sed -i.bak 's/v2\///g' coverage.txt + cd psbt; $(GOACC_BIN) ./...; sed -i.bak 's/v2\///g' coverage.txt + cd wire; $(GOACC_BIN) ./...; sed -i.bak 's/v2\///g' coverage.txt unit-race: @$(call print, "Running unit race tests.") env CGO_ENABLED=1 GORACE="history_size=7 halt_on_errors=1" $(GOTEST) -race -test.timeout=20m ./... + cd address; env CGO_ENABLED=1 GORACE="history_size=7 halt_on_errors=1" $(GOTEST) -race -test.timeout=20m ./... cd btcec; env CGO_ENABLED=1 GORACE="history_size=7 halt_on_errors=1" $(GOTEST) -race -test.timeout=20m ./... cd btcutil; env CGO_ENABLED=1 GORACE="history_size=7 halt_on_errors=1" $(GOTEST) -race -test.timeout=20m ./... - cd btcutil/psbt; env CGO_ENABLED=1 GORACE="history_size=7 halt_on_errors=1" $(GOTEST) -race -test.timeout=20m ./... + cd chaincfg; env CGO_ENABLED=1 GORACE="history_size=7 halt_on_errors=1" $(GOTEST) -race -test.timeout=20m ./... + cd chainhash; env CGO_ENABLED=1 GORACE="history_size=7 halt_on_errors=1" $(GOTEST) -race -test.timeout=20m ./... + cd txscript; env CGO_ENABLED=1 GORACE="history_size=7 halt_on_errors=1" $(GOTEST) -race -test.timeout=20m ./... + cd psbt; env CGO_ENABLED=1 GORACE="history_size=7 halt_on_errors=1" $(GOTEST) -race -test.timeout=20m ./... + cd wire; env CGO_ENABLED=1 GORACE="history_size=7 halt_on_errors=1" $(GOTEST) -race -test.timeout=20m ./... # ========= # UTILITIES @@ -132,7 +145,8 @@ lint: $(LINT_BIN) clean: @$(call print, "Cleaning source.$(NC)") - $(RM) coverage.txt btcec/coverage.txt btcutil/coverage.txt btcutil/psbt/coverage.txt + find . -name coverage.txt | xargs echo + find . -name coverage.txt.bak | xargs echo .PHONY: all \ default \