From dccea8febadcc50c2a96a3d6f2a386aa0392fe73 Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Tue, 19 Dec 2023 14:12:51 +0100 Subject: [PATCH] multi: use new v2 modules everywhere --- address/go.mod | 6 +- address/go.sum | 2 + {btcutil => address}/p2a_address_test.go | 14 +- 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 | 4 +- blockchain/accept_test.go | 2 +- blockchain/bench_test.go | 4 +- blockchain/bip30_test.go | 4 +- blockchain/blockindex.go | 6 +- blockchain/blockindex_test.go | 4 +- 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/internal/testhelper/common.go | 8 +- blockchain/internal/workmath/difficulty.go | 2 +- blockchain/merkle.go | 6 +- blockchain/merkle_test.go | 6 +- blockchain/notifications_test.go | 2 +- blockchain/process.go | 6 +- blockchain/process_test.go | 6 +- blockchain/regtest_test.go | 10 +- 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 | 4 +- btcjson/chainsvrresults.go | 6 +- btcjson/chainsvrresults_test.go | 4 +- btcjson/submitpackage.go | 2 +- btcjson/submitpackage_test.go | 2 +- btcjson/walletsvrcmds.go | 2 +- btcjson/walletsvrcmds_test.go | 2 +- btcjson/walletsvrresults.go | 2 +- btcjson/walletsvrresults_test.go | 2 +- btcutil/README.md | 4 +- btcutil/amount.go | 2 +- btcutil/bloom/merkleblock_test.go | 2 +- btcutil/coinset/coins_test.go | 2 +- btcutil/go.mod | 5 +- btcutil/go.sum | 12 +- btcutil/txsort/README.md | 4 +- 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 | 60 ++++-- go.sum | 61 +++--- integration/bip0009_test.go | 4 +- integration/chain_test.go | 8 +- integration/csv_fork_test.go | 15 +- integration/getchaintips_test.go | 4 +- .../invalidate_reconsider_block_test.go | 2 +- integration/p2a_test.go | 8 +- integration/prune_test.go | 2 +- integration/rawtx_test.go | 8 +- integration/reorg_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 +- integration/sync_race_test.go | 4 +- log.go | 2 +- mempool/error.go | 2 +- mempool/estimatefee.go | 4 +- mempool/estimatefee_test.go | 6 +- mempool/interface.go | 6 +- mempool/mempool.go | 10 +- mempool/mempool_test.go | 15 +- mempool/mocks.go | 6 +- 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 +- netsync/manager_test.go | 10 +- 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/go.mod | 5 +- psbt/go.sum | 2 + psbt/psbt_test.go | 1 - psbt/updater.go | 1 - rpcadapters.go | 6 +- rpcclient/chain.go | 4 +- rpcclient/chain_test.go | 2 +- 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 ++--- rpcserver_test.go | 6 +- rpcwebsocket.go | 41 ++-- server.go | 12 +- server_test.go | 2 +- txscript/engine_p2a_test.go | 2 +- txscript/go.mod | 2 +- txscript/p2a_test.go | 2 +- 169 files changed, 732 insertions(+), 621 deletions(-) rename {btcutil => address}/p2a_address_test.go (90%) diff --git a/address/go.mod b/address/go.mod index d8ffe14c..b7ac07d9 100644 --- a/address/go.mod +++ b/address/go.mod @@ -1,18 +1,22 @@ module github.com/btcsuite/btcd/address/v2 -go 1.23.2 +go 1.25 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 + github.com/stretchr/testify v1.10.0 golang.org/x/crypto v0.40.0 ) require ( github.com/btcsuite/btcd/chainhash/v2 v2.0.0 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.0 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect golang.org/x/sys v0.35.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect ) // TODO(guggero): Remove this as soon as we have a tagged version of btcec. diff --git a/address/go.sum b/address/go.sum index f00516a7..78a19a3d 100644 --- a/address/go.sum +++ b/address/go.sum @@ -10,5 +10,7 @@ golang.org/x/crypto v0.40.0 h1:r4x+VvoG5Fm+eJcxMaY8CQM7Lb0l1lsmjGBQ6s8BfKM= golang.org/x/crypto v0.40.0/go.mod h1:Qr1vMER5WyS2dfPHAlsOj01wgLbsyWtFn/aY+5+ZdxY= golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI= golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= +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/p2a_address_test.go b/address/p2a_address_test.go similarity index 90% rename from btcutil/p2a_address_test.go rename to address/p2a_address_test.go index d22f067f..fd1308ad 100644 --- a/btcutil/p2a_address_test.go +++ b/address/p2a_address_test.go @@ -1,10 +1,10 @@ -package btcutil_test +package address_test import ( "testing" - "github.com/btcsuite/btcd/btcutil" - "github.com/btcsuite/btcd/chaincfg" + "github.com/btcsuite/btcd/address/v2" + "github.com/btcsuite/btcd/chaincfg/v2" "github.com/stretchr/testify/require" ) @@ -39,7 +39,7 @@ func TestAddressPayToAnchor(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - addr, err := btcutil.NewAddressPayToAnchor(tt.net) + addr, err := address.NewAddressPayToAnchor(tt.net) require.NoError(t, err) require.Equal(t, tt.wantAddress, addr.EncodeAddress()) @@ -101,7 +101,7 @@ func TestDecodeAddressP2A(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - addr, err := btcutil.DecodeAddress(tt.address, tt.net) + addr, err := address.DecodeAddress(tt.address, tt.net) if tt.wantErr { require.Error(t, err) return @@ -109,7 +109,7 @@ func TestDecodeAddressP2A(t *testing.T) { require.NoError(t, err) // Ensure the decoded address is of the correct P2A type. - p2aAddr, ok := addr.(*btcutil.AddressPayToAnchor) + p2aAddr, ok := addr.(*address.AddressPayToAnchor) require.True(t, ok, "expected *AddressPayToAnchor, got %T", addr) // Ensure round-trip encoding produces the canonical @@ -121,6 +121,6 @@ func TestDecodeAddressP2A(t *testing.T) { // TestNewAddressPayToAnchorNilNetwork tests that nil network returns error. func TestNewAddressPayToAnchorNilNetwork(t *testing.T) { - _, err := btcutil.NewAddressPayToAnchor(nil) + _, err := address.NewAddressPayToAnchor(nil) require.Error(t, err) } diff --git a/addrmgr/addrmanager.go b/addrmgr/addrmanager.go index bdfe9094..c99ae7c6 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 a4ed50b8..234f7004 100644 --- a/addrmgr/addrmanager_internal_test.go +++ b/addrmgr/addrmanager_internal_test.go @@ -6,7 +6,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 4afe5fd6..7bf2977c 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 ab7644b6..3e96dec9 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 b0453655..26cbcc1f 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 b4a26501..12e4137d 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 e86133a2..47806dce 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 f92035d5..f4683f3b 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 a409aacc..57dffc18 100644 --- a/blockchain/accept.go +++ b/blockchain/accept.go @@ -7,9 +7,9 @@ package blockchain import ( "fmt" - "github.com/btcsuite/btcd/btcutil" + "github.com/btcsuite/btcd/btcutil/v2" "github.com/btcsuite/btcd/database" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/wire/v2" ) // maybeAcceptBlock potentially accepts a block into the block chain and, if diff --git a/blockchain/accept_test.go b/blockchain/accept_test.go index ab96b420..8fbe7de7 100644 --- a/blockchain/accept_test.go +++ b/blockchain/accept_test.go @@ -8,7 +8,7 @@ import ( "testing" "github.com/btcsuite/btcd/blockchain/internal/testhelper" - "github.com/btcsuite/btcd/btcutil" + "github.com/btcsuite/btcd/btcutil/v2" ) // TestMaybeAcceptBlockReusesHeaderNode ensures that when a block header is diff --git a/blockchain/bench_test.go b/blockchain/bench_test.go index db6f4150..4cde870c 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/bip30_test.go b/blockchain/bip30_test.go index 09e84aba..44631c32 100644 --- a/blockchain/bip30_test.go +++ b/blockchain/bip30_test.go @@ -3,8 +3,8 @@ package blockchain import ( "testing" - "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/stretchr/testify/require" ) diff --git a/blockchain/blockindex.go b/blockchain/blockindex.go index ff04c5ba..b40dcdd9 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/blockindex_test.go b/blockchain/blockindex_test.go index 47a47e92..02209da7 100644 --- a/blockchain/blockindex_test.go +++ b/blockchain/blockindex_test.go @@ -8,9 +8,9 @@ import ( "math/rand" "testing" - "github.com/btcsuite/btcd/chaincfg" + "github.com/btcsuite/btcd/chaincfg/v2" "github.com/btcsuite/btcd/database" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/wire/v2" ) // countingDB wraps a database.DB and counts the number of Update calls. diff --git a/blockchain/chain.go b/blockchain/chain.go index fb624ef9..fd110458 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 995693f2..73e4255c 100644 --- a/blockchain/chain_test.go +++ b/blockchain/chain_test.go @@ -12,10 +12,10 @@ import ( "time" "github.com/btcsuite/btcd/blockchain/internal/testhelper" - "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 e85f5813..5d2c033c 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 e9e2c0b6..6620f0c8 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 c59004fd..d35383a5 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 74fc23ba..2ad17841 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 8c647c12..7b3bdc49 100644 --- a/blockchain/common_test.go +++ b/blockchain/common_test.go @@ -15,13 +15,13 @@ import ( "time" "github.com/btcsuite/btcd/blockchain/internal/testhelper" - "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 44959185..3b7e0041 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 56de7780..a2117d72 100644 --- a/blockchain/difficulty.go +++ b/blockchain/difficulty.go @@ -9,7 +9,7 @@ import ( "time" "github.com/btcsuite/btcd/blockchain/internal/workmath" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/chainhash/v2" ) // HashToBig converts a chainhash.Hash into a big.Int that can be used to diff --git a/blockchain/example_test.go b/blockchain/example_test.go index 8db57027..9a86440e 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 591414d1..0b182cd4 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 a17af451..f0cd1a15 100644 --- a/blockchain/fullblocktests/generate.go +++ b/blockchain/fullblocktests/generate.go @@ -17,14 +17,15 @@ import ( "runtime" "time" + "github.com/btcsuite/btcd/address/v2" "github.com/btcsuite/btcd/blockchain" "github.com/btcsuite/btcd/blockchain/internal/testhelper" "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 ( @@ -196,7 +197,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 2e36dcee..423ab788 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 2a56574a..ffcb4615 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 e545887f..19d8ee06 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 960a51d2..bb515b03 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 1af1d0a4..e79dbe1f 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 89ce6720..3780eb0d 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 b4487e60..28f608fb 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 3d4e9146..b4573276 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 cae9b3b9..53d089bc 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/internal/testhelper/common.go b/blockchain/internal/testhelper/common.go index 68109748..dedc9420 100644 --- a/blockchain/internal/testhelper/common.go +++ b/blockchain/internal/testhelper/common.go @@ -6,10 +6,10 @@ import ( "runtime" "github.com/btcsuite/btcd/blockchain/internal/workmath" - "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" ) var ( diff --git a/blockchain/internal/workmath/difficulty.go b/blockchain/internal/workmath/difficulty.go index 8ff7adad..9afff408 100644 --- a/blockchain/internal/workmath/difficulty.go +++ b/blockchain/internal/workmath/difficulty.go @@ -7,7 +7,7 @@ package workmath import ( "math/big" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/chainhash/v2" ) var ( diff --git a/blockchain/merkle.go b/blockchain/merkle.go index 086c3643..8249e2ff 100644 --- a/blockchain/merkle.go +++ b/blockchain/merkle.go @@ -10,9 +10,9 @@ import ( "io" "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 06eb7012..b5e5b6c5 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 fde58735..79748304 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 0c114f47..87f4deb4 100644 --- a/blockchain/process.go +++ b/blockchain/process.go @@ -8,10 +8,10 @@ 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" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/wire/v2" ) // BehaviorFlags is a bitmask defining tweaks to the normal behavior when diff --git a/blockchain/process_test.go b/blockchain/process_test.go index b24b4a04..7868dea9 100644 --- a/blockchain/process_test.go +++ b/blockchain/process_test.go @@ -7,9 +7,9 @@ import ( "time" "github.com/btcsuite/btcd/blockchain/internal/testhelper" - "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" ) diff --git a/blockchain/regtest_test.go b/blockchain/regtest_test.go index 1f554a57..b6c60587 100644 --- a/blockchain/regtest_test.go +++ b/blockchain/regtest_test.go @@ -4,11 +4,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" "github.com/stretchr/testify/require" ) diff --git a/blockchain/rolling_merkle.go b/blockchain/rolling_merkle.go index cd2c2ec7..e5052423 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 e425278b..9d744b85 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 614e030c..427050f6 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 031f0480..f0855ecc 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 88031019..68ba33e6 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 28f417a1..8e372416 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 34149e44..cacb1bb8 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 5e260b60..a423ad43 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 9b3bc992..f0cb76dc 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 f62f4b91..a6e7e2b1 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 9fb8f66e..15f90086 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 ddd59130..7e698ce0 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 493787a7..bb679697 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 1b691f00..ba48b5cf 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 e76a8b64..2c722512 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" ) // BTCPerkvB is the units used to represent Bitcoin transaction fees. diff --git a/btcjson/chainsvrcmds_test.go b/btcjson/chainsvrcmds_test.go index 38113a68..ef89525d 100644 --- a/btcjson/chainsvrcmds_test.go +++ b/btcjson/chainsvrcmds_test.go @@ -13,8 +13,8 @@ import ( "testing" "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" ) // TestChainSvrCmds tests all of the chain server commands marshal and unmarshal diff --git a/btcjson/chainsvrresults.go b/btcjson/chainsvrresults.go index 120ee797..3ee2b8b6 100644 --- a/btcjson/chainsvrresults.go +++ b/btcjson/chainsvrresults.go @@ -10,10 +10,10 @@ import ( "encoding/json" "fmt" - "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 18a7e291..fb681a9c 100644 --- a/btcjson/chainsvrresults_test.go +++ b/btcjson/chainsvrresults_test.go @@ -12,8 +12,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/submitpackage.go b/btcjson/submitpackage.go index d290a913..dd9392b4 100644 --- a/btcjson/submitpackage.go +++ b/btcjson/submitpackage.go @@ -4,7 +4,7 @@ import ( "encoding/json" "fmt" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/chainhash/v2" ) // JsonSubmitPackageCmd models the request payload for Bitcoin Core’s diff --git a/btcjson/submitpackage_test.go b/btcjson/submitpackage_test.go index a678dc51..eb844667 100644 --- a/btcjson/submitpackage_test.go +++ b/btcjson/submitpackage_test.go @@ -9,7 +9,7 @@ import ( "testing" "github.com/btcsuite/btcd/btcjson" - "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/chainhash/v2" "github.com/stretchr/testify/require" ) diff --git a/btcjson/walletsvrcmds.go b/btcjson/walletsvrcmds.go index 2613acf8..f3bc0570 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 0b5355e5..52a1c4d8 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 d85db0a6..2e3e36c2 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 fd44b066..86a10cd7 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 96548a36..17b9feaf 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 diff --git a/btcutil/amount.go b/btcutil/amount.go index bb70c9b1..d6016e66 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/merkleblock_test.go b/btcutil/bloom/merkleblock_test.go index 0e5fc004..100c6679 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 a4c432b5..a5cec1c7 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/go.mod b/btcutil/go.mod index deca2890..5113d657 100644 --- a/btcutil/go.mod +++ b/btcutil/go.mod @@ -14,16 +14,13 @@ require ( github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.0 github.com/kcalvinalvin/anet v0.0.0-20251112173137-d8ddc1f6dbee github.com/kkdai/bstream v1.0.0 - github.com/stretchr/testify v1.8.4 - golang.org/x/crypto v0.40.0 ) require ( github.com/btcsuite/btclog v1.0.0 // indirect github.com/decred/dcrd/crypto/blake256 v1.1.0 // indirect - github.com/pmezard/go-difflib v1.0.0 // indirect + golang.org/x/crypto v0.40.0 // indirect golang.org/x/sys v0.35.0 // indirect - gopkg.in/yaml.v3 v3.0.1 // indirect ) // TODO(guggero): Remove this as soon as we have a tagged version of address. diff --git a/btcutil/go.sum b/btcutil/go.sum index 10844f04..c74a145c 100644 --- a/btcutil/go.sum +++ b/btcutil/go.sum @@ -1,7 +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/btcec/v2 v2.4.0 h1:9JgnRkOL8J1UKuGlpJs7oL5tFRgrBgyM/uhwfS+cUiI= -github.com/btcsuite/btcd/btcec/v2 v2.4.0/go.mod h1:64BXFSNzV1koQHPqljB4LaD6lZPQEQNZ38zMImajCRo= github.com/btcsuite/btclog v1.0.0 h1:sEkpKJMmfGiyZjADwEIgB1NSwMyfdD1FB8v6+w1T0Ns= github.com/btcsuite/btclog v1.0.0/go.mod h1:w7xnGOhwT3lmrS4H3b/D1XAXxvh+tbhUm8xeHN2y3TQ= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= @@ -10,23 +8,17 @@ github.com/decred/dcrd/crypto/blake256 v1.1.0 h1:zPMNGQCm0g4QTY27fOCorQW7EryeQ/U github.com/decred/dcrd/crypto/blake256 v1.1.0/go.mod h1:2OfgNZ5wDpcsFmHmCK5gZTPcCXqlm2ArzUIkw9czNJo= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.0 h1:NMZiJj8QnKe1LgsbDayM4UoHwbvwDRwnI3hwNaAHRnc= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.0/go.mod h1:ZXNYxsqcloTdSy/rNShjYzMhyjf0LaoftYK0p+A3h40= -github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= -github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/kcalvinalvin/anet v0.0.0-20251112173137-d8ddc1f6dbee h1:FPP9HDkBbPyniu+u7FHZg+kKFX1WW0gxOGteJ0h3AJk= github.com/kcalvinalvin/anet v0.0.0-20251112173137-d8ddc1f6dbee/go.mod h1:N6sz6HwJAenJ6d+/xmSl0ikfV05ZrVGmjt1ryy/WOtE= 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/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= +github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= +github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= golang.org/x/crypto v0.40.0 h1:r4x+VvoG5Fm+eJcxMaY8CQM7Lb0l1lsmjGBQ6s8BfKM= golang.org/x/crypto v0.40.0/go.mod h1:Qr1vMER5WyS2dfPHAlsOj01wgLbsyWtFn/aY+5+ZdxY= golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI= golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= -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/txsort/README.md b/btcutil/txsort/README.md index dd04683d..bb7e9288 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). diff --git a/chaincfg/README.md b/chaincfg/README.md index 41b9a715..b0d7cca9 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 93193dcc..dc26adba 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 5f479003..8fc9a3c2 100644 --- a/cmd/addblock/config.go +++ b/cmd/addblock/config.go @@ -10,11 +10,11 @@ import ( "path/filepath" "slices" - "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 8eda8f8c..61415498 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 db38bc3e..a06020ee 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 d4ae5dfc..de71ab07 100644 --- a/cmd/findcheckpoint/config.go +++ b/cmd/findcheckpoint/config.go @@ -10,11 +10,11 @@ import ( "path/filepath" "slices" - "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 ec4a4b30..5abda990 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 0c91b6fb..5a24027b 100644 --- a/cmd/gencerts/gencerts.go +++ b/cmd/gencerts/gencerts.go @@ -11,7 +11,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 cb7ce6b2..06a8798b 100644 --- a/config.go +++ b/config.go @@ -22,16 +22,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" ) @@ -186,7 +187,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 } @@ -934,9 +935,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 705618f7..8e43fc04 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 75a3e31a..a9a0db65 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 9d63ed17..3c86d648 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 bcea56a2..aab2afc5 100644 --- a/database/cmd/dbtool/globalconfig.go +++ b/database/cmd/dbtool/globalconfig.go @@ -11,11 +11,11 @@ import ( "path/filepath" "slices" - "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 744e29f5..4e4d7d01 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 a3ee8c73..e1223deb 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 1110d0db..85e3fca2 100644 --- a/database/example_test.go +++ b/database/example_test.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" ) // This example demonstrates creating a new database. diff --git a/database/ffldb/bench_test.go b/database/ffldb/bench_test.go index 95e498b2..5f71dde3 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 7690a6ad..81cf7e72 100644 --- a/database/ffldb/blockio.go +++ b/database/ffldb/blockio.go @@ -22,9 +22,9 @@ import ( "sync" "syscall" - "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 60103aaa..caeb5fd2 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 01290bf0..9dbd3673 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 77596019..ebf6b0bd 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 36db769b..8bd8c6ba 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 2814dfaa..2e164afe 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 7c4dd851..ec1d242c 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 1999a6c2..d80cd426 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 04fe6cef..dc587fc2 100644 --- a/go.mod +++ b/go.mod @@ -1,39 +1,65 @@ module github.com/btcsuite/btcd +go 1.25 + require ( + github.com/btcsuite/btcd/address/v2 v2.0.0 github.com/btcsuite/btcd/btcec/v2 v2.4.0 - github.com/btcsuite/btcd/btcutil v1.2.0 - github.com/btcsuite/btcd/chaincfg/chainhash v1.2.0 + 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/v2transport v1.0.1 - github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f + github.com/btcsuite/btcd/wire/v2 v2.0.0 + github.com/btcsuite/btclog v1.0.0 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.4.0 - 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.8.4 + github.com/decred/dcrd/lru v1.1.3 + github.com/gorilla/websocket v1.5.3 + github.com/jessevdk/go-flags v1.6.1 + github.com/jrick/logrotate v1.1.2 + github.com/stretchr/testify v1.10.0 github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 - golang.org/x/crypto v0.25.0 - golang.org/x/sys v0.22.0 + golang.org/x/crypto v0.40.0 + golang.org/x/sys v0.35.0 pgregory.net/rapid v1.2.0 ) require ( github.com/aead/siphash v1.0.1 // indirect github.com/decred/dcrd/crypto/blake256 v1.1.0 // indirect - github.com/golang/snappy v0.0.4 // indirect + github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.0 // indirect + github.com/golang/snappy v1.0.0 // indirect github.com/kcalvinalvin/anet v0.0.0-20251112173137-d8ddc1f6dbee // 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 - github.com/stretchr/objx v0.5.0 // indirect - golang.org/x/net v0.24.0 // indirect + github.com/stretchr/objx v0.5.2 // indirect gopkg.in/yaml.v3 v3.0.1 // 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 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. retract ( @@ -65,7 +91,3 @@ retract ( v0.13.0-beta2 v0.13.0-beta ) - -go 1.25 - -replace github.com/btcsuite/btcd/btcutil => ./btcutil diff --git a/go.sum b/go.sum index 7153b6f6..44cb2b07 100644 --- a/go.sum +++ b/go.sum @@ -1,28 +1,23 @@ 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/btcec/v2 v2.4.0 h1:9JgnRkOL8J1UKuGlpJs7oL5tFRgrBgyM/uhwfS+cUiI= -github.com/btcsuite/btcd/btcec/v2 v2.4.0/go.mod h1:64BXFSNzV1koQHPqljB4LaD6lZPQEQNZ38zMImajCRo= -github.com/btcsuite/btcd/chaincfg/chainhash v1.2.0 h1:yMIg99+4aBvqfl/HzJRKfxTX9rGfikoI9uvFzterhc8= -github.com/btcsuite/btcd/chaincfg/chainhash v1.2.0/go.mod h1:Y72Ren9gfhlEvnwnT78BGcSNO2UMphTKLn9AorF+5rg= github.com/btcsuite/btcd/v2transport v1.0.1 h1:pIyyyBCPwd087K3Wdb/9tIvUubAQdzTJghjPgzTQVsE= github.com/btcsuite/btcd/v2transport v1.0.1/go.mod h1:N6H0HGSElVVJKntzaYHYVbW71DtWDLMw2yhwVRO3ZOE= -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/btclog v1.0.0 h1:sEkpKJMmfGiyZjADwEIgB1NSwMyfdD1FB8v6+w1T0Ns= +github.com/btcsuite/btclog v1.0.0/go.mod h1:w7xnGOhwT3lmrS4H3b/D1XAXxvh+tbhUm8xeHN2y3TQ= 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/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 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.1.0 h1:zPMNGQCm0g4QTY27fOCorQW7EryeQ/U0x++OzVrdms8= github.com/decred/dcrd/crypto/blake256 v1.1.0/go.mod h1:2OfgNZ5wDpcsFmHmCK5gZTPcCXqlm2ArzUIkw9czNJo= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.0 h1:NMZiJj8QnKe1LgsbDayM4UoHwbvwDRwnI3hwNaAHRnc= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.0/go.mod h1:ZXNYxsqcloTdSy/rNShjYzMhyjf0LaoftYK0p+A3h40= -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/decred/dcrd/lru v1.1.3 h1:w9EAbvGLyzm6jTjF83UKuqZEiUtJmvRhQDOCEIvSuE0= +github.com/decred/dcrd/lru v1.1.3/go.mod h1:Tw0i0pJyiLEx/oZdHLe1Wdv/Y7EGzAX+sYftnmxBR4o= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= @@ -33,22 +28,23 @@ github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrU 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/golang/snappy v1.0.0 h1:Oy607GVXHs7RtbggtPBnr2RmDArIsAefDwvrdWvRhGs= +github.com/golang/snappy v1.0.0/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 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= -github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg= +github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= -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/jessevdk/go-flags v1.6.1 h1:Cvu5U8UGrLay1rZfv/zP7iLpSHGUZ/Ou68T0iX1bBK4= +github.com/jessevdk/go-flags v1.6.1/go.mod h1:Mk8T1hIAWpOiJiHa9rJASDK2UGWji0EuPGBnNLMooyc= +github.com/jrick/logrotate v1.1.2 h1:6ePk462NCX7TfKtNp5JJ7MbA2YIslkpfgP03TlTYMN0= +github.com/jrick/logrotate v1.1.2/go.mod h1:f9tdWggSVK3iqavGpyvegq5IhNois7KXmasU6/N96OQ= github.com/kcalvinalvin/anet v0.0.0-20251112173137-d8ddc1f6dbee h1:FPP9HDkBbPyniu+u7FHZg+kKFX1WW0gxOGteJ0h3AJk= github.com/kcalvinalvin/anet v0.0.0-20251112173137-d8ddc1f6dbee/go.mod h1:N6sz6HwJAenJ6d+/xmSl0ikfV05ZrVGmjt1ryy/WOtE= -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= @@ -60,26 +56,22 @@ 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/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= -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/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= +github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= +github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= 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/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30= -golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M= +golang.org/x/crypto v0.40.0 h1:r4x+VvoG5Fm+eJcxMaY8CQM7Lb0l1lsmjGBQ6s8BfKM= +golang.org/x/crypto v0.40.0/go.mod h1:Qr1vMER5WyS2dfPHAlsOj01wgLbsyWtFn/aY+5+ZdxY= 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/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w= -golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8= +golang.org/x/net v0.41.0 h1:vBTly1HeNPEn3wtREYfy4GZ/NECgw2Cnl+nK6Nz3uvw= +golang.org/x/net v0.41.0/go.mod h1:B/K4NNqkfmg07DQYrbwvSluqCJOOXwUjeb/5lOisjbA= 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= @@ -90,13 +82,13 @@ golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7w 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.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= -golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI= +golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= 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/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= -golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= +golang.org/x/text v0.27.0 h1:4fGWRpyh641NLlecmyl4LOe6yDdfaYNrGb2zdfo4JV4= +golang.org/x/text v0.27.0/go.mod h1:1D28KMCvyooCX9hBiosv5Tz/+YLxj0j7XhWjpSUF7CU= 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= @@ -115,7 +107,6 @@ 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/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= pgregory.net/rapid v1.2.0 h1:keKAYRcjm+e1F0oAuU5F5+YPAWcyxNNRK2wud503Gnk= diff --git a/integration/bip0009_test.go b/integration/bip0009_test.go index 5d443d71..28801bef 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/chain_test.go b/integration/chain_test.go index 0f5cd94c..cfcd07cd 100644 --- a/integration/chain_test.go +++ b/integration/chain_test.go @@ -7,12 +7,12 @@ 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/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" "github.com/stretchr/testify/require" ) diff --git a/integration/csv_fork_test.go b/integration/csv_fork_test.go index 6b03af95..656f32cb 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 1570ba74..45750dd4 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/invalidate_reconsider_block_test.go b/integration/invalidate_reconsider_block_test.go index 4fe6ff00..88d836eb 100644 --- a/integration/invalidate_reconsider_block_test.go +++ b/integration/invalidate_reconsider_block_test.go @@ -3,7 +3,7 @@ package integration import ( "testing" - "github.com/btcsuite/btcd/chaincfg" + "github.com/btcsuite/btcd/chaincfg/v2" "github.com/btcsuite/btcd/integration/rpctest" ) diff --git a/integration/p2a_test.go b/integration/p2a_test.go index 8ca69d65..059e56b7 100644 --- a/integration/p2a_test.go +++ b/integration/p2a_test.go @@ -6,11 +6,11 @@ package integration import ( "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/integration/rpctest" - "github.com/btcsuite/btcd/txscript" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/txscript/v2" + "github.com/btcsuite/btcd/wire/v2" ) // TestPayToAnchorSimple tests creating and spending P2A outputs. diff --git a/integration/prune_test.go b/integration/prune_test.go index ac363cb8..ef69916f 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/rawtx_test.go b/integration/rawtx_test.go index f27f5176..a211d7d2 100644 --- a/integration/rawtx_test.go +++ b/integration/rawtx_test.go @@ -8,12 +8,12 @@ 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/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" "github.com/stretchr/testify/require" ) diff --git a/integration/reorg_test.go b/integration/reorg_test.go index e9463d49..bfdbe95c 100644 --- a/integration/reorg_test.go +++ b/integration/reorg_test.go @@ -5,7 +5,7 @@ import ( "time" "github.com/btcsuite/btcd/btcjson" - "github.com/btcsuite/btcd/chaincfg" + "github.com/btcsuite/btcd/chaincfg/v2" "github.com/btcsuite/btcd/integration/rpctest" "github.com/btcsuite/btcd/rpcclient" "github.com/stretchr/testify/require" diff --git a/integration/rpcserver_test.go b/integration/rpcserver_test.go index 7e90a36b..06496446 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 07371fb8..f89e2bfb 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 bad48a92..fd645f02 100644 --- a/integration/rpctest/memwallet.go +++ b/integration/rpctest/memwallet.go @@ -11,15 +11,16 @@ import ( "maps" "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 ( @@ -73,7 +74,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 @@ -87,7 +88,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 @@ -142,7 +143,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{ @@ -334,7 +335,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) @@ -351,7 +352,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 } @@ -366,7 +367,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() @@ -583,9 +584,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 8dddc750..b397bb00 100644 --- a/integration/rpctest/node.go +++ b/integration/rpctest/node.go @@ -13,7 +13,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 0e8c53db..1d3d42da 100644 --- a/integration/rpctest/rpc_harness.go +++ b/integration/rpctest/rpc_harness.go @@ -15,11 +15,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 ( @@ -256,7 +257,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 } @@ -387,7 +388,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 978f8d82..3fa8da2b 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 d4d76f2e..43771a8e 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/integration/sync_race_test.go b/integration/sync_race_test.go index 9d1bbced..68cd5ba6 100644 --- a/integration/sync_race_test.go +++ b/integration/sync_race_test.go @@ -9,9 +9,9 @@ import ( "testing" "time" - "github.com/btcsuite/btcd/chaincfg" + "github.com/btcsuite/btcd/chaincfg/v2" "github.com/btcsuite/btcd/integration/rpctest" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/wire/v2" "github.com/stretchr/testify/require" ) diff --git a/log.go b/log.go index 55be25ca..92a38eb0 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/btcd/v2transport" "github.com/btcsuite/btclog" diff --git a/mempool/error.go b/mempool/error.go index b0d42be4..21439f47 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 2d1794b7..359d285e 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 c1e09060..23edd329 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/interface.go b/mempool/interface.go index f6fe1f05..0408ae9d 100644 --- a/mempool/interface.go +++ b/mempool/interface.go @@ -4,9 +4,9 @@ import ( "time" "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" ) // TxMempool defines an interface that's used by other subsystems to interact diff --git a/mempool/mempool.go b/mempool/mempool.go index 212a07fa..cbb14a3c 100644 --- a/mempool/mempool.go +++ b/mempool/mempool.go @@ -16,12 +16,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" "github.com/davecgh/go-spew/spew" ) diff --git a/mempool/mempool_test.go b/mempool/mempool_test.go index e31b6043..7dc50b30 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/mocks.go b/mempool/mocks.go index e81309c5..6e476737 100644 --- a/mempool/mocks.go +++ b/mempool/mocks.go @@ -4,9 +4,9 @@ import ( "time" "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" "github.com/stretchr/testify/mock" ) diff --git a/mempool/policy.go b/mempool/policy.go index dd27b4b9..35dd20a7 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 aaa21bdb..ec5a34b1 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" "github.com/stretchr/testify/mock" ) @@ -362,7 +363,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 2c07f2ee..838a162d 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 5f270652..9a496de2 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 ba1d9777..1b5d3035 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 b92df277..783bb1eb 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 cc2fdfbf..ade62f88 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 31a6a4c5..c0e1b48a 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 6a873bd8..2e3ed543 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 73260c56..cf9c898b 100644 --- a/netsync/manager.go +++ b/netsync/manager.go @@ -11,13 +11,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/netsync/manager_test.go b/netsync/manager_test.go index b7e4b6bb..7e662fce 100644 --- a/netsync/manager_test.go +++ b/netsync/manager_test.go @@ -12,15 +12,15 @@ 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/database/ffldb" "github.com/btcsuite/btcd/mempool" "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/stretchr/testify/require" ) diff --git a/params.go b/params.go index 30daec8d..14213bbc 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 d2c66ff3..279aeafa 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 850557b8..425aac60 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 422c9c0a..8d17b56c 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 c1827785..7124941c 100644 --- a/peer/peer.go +++ b/peer/peer.go @@ -20,10 +20,10 @@ 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/v2transport" - "github.com/btcsuite/btcd/wire" + "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 54945968..40216720 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/go.mod b/psbt/go.mod index bf86db8b..f1e1cce5 100644 --- a/psbt/go.mod +++ b/psbt/go.mod @@ -1,10 +1,10 @@ module github.com/btcsuite/btcd/psbt/v2 -go 1.23.2 +go 1.25 require ( github.com/btcsuite/btcd/address/v2 v2.0.0 - github.com/btcsuite/btcd/btcec/v2 v2.3.2 + github.com/btcsuite/btcd/btcec/v2 v2.4.0 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 @@ -18,6 +18,7 @@ require ( github.com/btcsuite/btclog v1.0.0 // indirect github.com/decred/dcrd/crypto/blake256 v1.1.0 // indirect github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.0 // indirect + github.com/kcalvinalvin/anet v0.0.0-20251112173137-d8ddc1f6dbee // indirect github.com/pmezard/go-difflib v1.0.0 // indirect golang.org/x/crypto v0.40.0 // indirect golang.org/x/sys v0.35.0 // indirect diff --git a/psbt/go.sum b/psbt/go.sum index f8b25f4c..6efde215 100644 --- a/psbt/go.sum +++ b/psbt/go.sum @@ -6,6 +6,8 @@ github.com/decred/dcrd/crypto/blake256 v1.1.0 h1:zPMNGQCm0g4QTY27fOCorQW7EryeQ/U github.com/decred/dcrd/crypto/blake256 v1.1.0/go.mod h1:2OfgNZ5wDpcsFmHmCK5gZTPcCXqlm2ArzUIkw9czNJo= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.0 h1:NMZiJj8QnKe1LgsbDayM4UoHwbvwDRwnI3hwNaAHRnc= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.0/go.mod h1:ZXNYxsqcloTdSy/rNShjYzMhyjf0LaoftYK0p+A3h40= +github.com/kcalvinalvin/anet v0.0.0-20251112173137-d8ddc1f6dbee h1:FPP9HDkBbPyniu+u7FHZg+kKFX1WW0gxOGteJ0h3AJk= +github.com/kcalvinalvin/anet v0.0.0-20251112173137-d8ddc1f6dbee/go.mod h1:N6sz6HwJAenJ6d+/xmSl0ikfV05ZrVGmjt1ryy/WOtE= 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.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= diff --git a/psbt/psbt_test.go b/psbt/psbt_test.go index 1583b626..8b8b3a62 100644 --- a/psbt/psbt_test.go +++ b/psbt/psbt_test.go @@ -13,7 +13,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 33562c37..efd0a761 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 03905c7b..602c6c95 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 878a4007..e8b2f8b8 100644 --- a/rpcclient/chain.go +++ b/rpcclient/chain.go @@ -13,8 +13,8 @@ import ( "strings" "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 a946bf80..42e10069 100644 --- a/rpcclient/chain_test.go +++ b/rpcclient/chain_test.go @@ -13,7 +13,7 @@ import ( "testing" "time" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/wire/v2" "github.com/gorilla/websocket" "github.com/stretchr/testify/require" ) diff --git a/rpcclient/examples/btcdwebsockets/main.go b/rpcclient/examples/btcdwebsockets/main.go index fe3fc81b..66b8442f 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 c41b4414..33f68380 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 b7517cf2..ae44f5ac 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 d57367b2..2d53fcfd 100644 --- a/rpcclient/infrastructure.go +++ b/rpcclient/infrastructure.go @@ -27,7 +27,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 9de2f27e..c128f126 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 1f5cd480..5b6ff3f6 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 c72cabe5..910b1c9d 100644 --- a/rpcclient/rawtransactions.go +++ b/rpcclient/rawtransactions.go @@ -10,10 +10,11 @@ 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/btcutil/v2" + "github.com/btcsuite/btcd/chainhash/v2" + "github.com/btcsuite/btcd/wire/v2" ) const ( @@ -292,7 +293,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 { @@ -306,7 +307,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() } @@ -771,7 +772,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, @@ -786,7 +789,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() } @@ -818,8 +823,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) @@ -839,8 +845,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 f43c2007..020b67bd 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 bec0fad8..3a481aa4 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -26,20 +26,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" ) @@ -564,7 +565,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, @@ -576,8 +577,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, @@ -839,7 +840,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) @@ -1588,7 +1589,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))] } @@ -3127,7 +3128,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) @@ -3194,7 +3197,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, @@ -3578,7 +3581,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{ @@ -3655,32 +3658,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())) @@ -3755,7 +3758,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, @@ -3764,7 +3767,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", @@ -3801,7 +3804,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. @@ -3809,7 +3812,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/rpcserver_test.go b/rpcserver_test.go index 0aa93913..2e291da5 100644 --- a/rpcserver_test.go +++ b/rpcserver_test.go @@ -6,10 +6,10 @@ 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/btcsuite/btcd/mempool" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/wire/v2" "github.com/stretchr/testify/require" ) diff --git a/rpcwebsocket.go b/rpcwebsocket.go index 02f59d58..0d626882 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 68457929..15cf2bd6 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" ) diff --git a/server_test.go b/server_test.go index 2b07552c..9cbfad31 100644 --- a/server_test.go +++ b/server_test.go @@ -6,7 +6,7 @@ import ( "testing" "time" - "github.com/btcsuite/btcd/chaincfg" + "github.com/btcsuite/btcd/chaincfg/v2" "github.com/btcsuite/btcd/peer" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" diff --git a/txscript/engine_p2a_test.go b/txscript/engine_p2a_test.go index 7d2b2275..aa3a66f1 100644 --- a/txscript/engine_p2a_test.go +++ b/txscript/engine_p2a_test.go @@ -3,7 +3,7 @@ package txscript import ( "testing" - "github.com/btcsuite/btcd/wire" + "github.com/btcsuite/btcd/wire/v2" "github.com/stretchr/testify/require" ) diff --git a/txscript/go.mod b/txscript/go.mod index 24e3422d..3af52cd9 100644 --- a/txscript/go.mod +++ b/txscript/go.mod @@ -1,6 +1,6 @@ module github.com/btcsuite/btcd/txscript/v2 -go 1.23.2 +go 1.25 require ( github.com/btcsuite/btcd/address/v2 v2.0.0 diff --git a/txscript/p2a_test.go b/txscript/p2a_test.go index bb904574..4d5c8df0 100644 --- a/txscript/p2a_test.go +++ b/txscript/p2a_test.go @@ -4,7 +4,7 @@ import ( "encoding/hex" "testing" - "github.com/btcsuite/btcd/chaincfg" + "github.com/btcsuite/btcd/chaincfg/v2" ) // TestIsPayToAnchorScript tests the IsPayToAnchorScript function.