Skip to content

Commit 34c05b0

Browse files
committed
multi: scripted-diff: upgrade to btcd v2 modules
This commit was created by the script that can be found in btcsuite/btcd#2547. The commit might not yet compile and require some manual changes. But to make sure it can be fully reproduced by a reviewer, we keep it that way and keep all manual changes in a follow-up commit. We might want to "squash and merge" this PR to make sure the final commit that goes into master compiles fully.
1 parent 70a94ea commit 34c05b0

98 files changed

Lines changed: 794 additions & 985 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

chain/bitcoind_client.go

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@ import (
1010
"sync/atomic"
1111
"time"
1212

13+
"github.com/btcsuite/btcd/address/v2"
1314
"github.com/btcsuite/btcd/btcjson"
14-
"github.com/btcsuite/btcd/btcutil"
15-
"github.com/btcsuite/btcd/chaincfg/chainhash"
16-
"github.com/btcsuite/btcd/txscript"
17-
"github.com/btcsuite/btcd/wire"
15+
"github.com/btcsuite/btcd/btcutil/v2"
16+
"github.com/btcsuite/btcd/chainhash/v2"
17+
"github.com/btcsuite/btcd/txscript/v2"
18+
"github.com/btcsuite/btcd/wire/v2"
1819
"github.com/btcsuite/btcwallet/waddrmgr"
1920
"github.com/btcsuite/btcwallet/wtxmgr"
2021
"github.com/davecgh/go-spew/spew"
@@ -267,7 +268,7 @@ func (c *BitcoindClient) Notifications() <-chan interface{} {
267268
// transaction pays to any of the given addresses.
268269
//
269270
// NOTE: This is part of the chain.Interface interface.
270-
func (c *BitcoindClient) NotifyReceived(addrs []btcutil.Address) error {
271+
func (c *BitcoindClient) NotifyReceived(addrs []address.Address) error {
271272
c.updateWatchedFilters(addrs)
272273

273274
_ = c.NotifyBlocks()
@@ -385,10 +386,10 @@ func (c *BitcoindClient) shouldNotifyBlocks() bool {
385386
//
386387
// The current filters supported are of the following types:
387388
//
388-
// []btcutil.Address
389+
// []address.Address
389390
// []wire.OutPoint
390391
// []*wire.OutPoint
391-
// map[wire.OutPoint]btcutil.Address
392+
// map[wire.OutPoint]address.Address
392393
// []chainhash.Hash
393394
// []*chainhash.Hash
394395
func (c *BitcoindClient) LoadTxFilter(reset bool, filters ...interface{}) error {
@@ -401,8 +402,8 @@ func (c *BitcoindClient) LoadTxFilter(reset bool, filters ...interface{}) error
401402
// filter types, and the second to actually update our filters.
402403
for _, filter := range filters {
403404
switch filter := filter.(type) {
404-
case []btcutil.Address, []wire.OutPoint, []*wire.OutPoint,
405-
map[wire.OutPoint]btcutil.Address, []chainhash.Hash,
405+
case []address.Address, []wire.OutPoint, []*wire.OutPoint,
406+
map[wire.OutPoint]address.Address, []chainhash.Hash,
406407
[]*chainhash.Hash:
407408

408409
// Proceed to check the next filter type.
@@ -469,7 +470,7 @@ func (c *BitcoindClient) RescanBlocks(
469470
// Rescan rescans from the block with the given hash until the current block,
470471
// after adding the passed addresses and outpoints to the client's watch list.
471472
func (c *BitcoindClient) Rescan(blockHash *chainhash.Hash,
472-
addresses []btcutil.Address, outPoints map[wire.OutPoint]btcutil.Address) error {
473+
addresses []address.Address, outPoints map[wire.OutPoint]address.Address) error {
473474

474475
// A block hash is required to use as the starting point of the rescan.
475476
if blockHash == nil {
@@ -1355,7 +1356,7 @@ func (c *BitcoindClient) updateWatchedFilters(update any) {
13551356

13561357
switch update := update.(type) {
13571358
// We're adding the addresses to our filter.
1358-
case []btcutil.Address:
1359+
case []address.Address:
13591360
for _, addr := range update {
13601361
c.watchedAddresses[addr.String()] = struct{}{}
13611362
}
@@ -1373,7 +1374,7 @@ func (c *BitcoindClient) updateWatchedFilters(update any) {
13731374

13741375
// We're adding the outpoints that map to the scripts
13751376
// that we should scan for to our filter.
1376-
case map[wire.OutPoint]btcutil.Address:
1377+
case map[wire.OutPoint]address.Address:
13771378
for op := range update {
13781379
c.watchedOutPoints[op] = struct{}{}
13791380
}

chain/bitcoind_conn.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ import (
1010
"time"
1111

1212
"github.com/btcsuite/btcd/btcjson"
13-
"github.com/btcsuite/btcd/chaincfg"
14-
"github.com/btcsuite/btcd/chaincfg/chainhash"
13+
"github.com/btcsuite/btcd/chaincfg/v2"
14+
"github.com/btcsuite/btcd/chainhash/v2"
1515
"github.com/btcsuite/btcd/rpcclient"
16-
"github.com/btcsuite/btcd/wire"
16+
"github.com/btcsuite/btcd/wire/v2"
1717
"github.com/lightningnetwork/lnd/ticker"
1818
)
1919

chain/bitcoind_events.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import (
44
"encoding/json"
55
"fmt"
66

7-
"github.com/btcsuite/btcd/chaincfg/chainhash"
7+
"github.com/btcsuite/btcd/chainhash/v2"
88
"github.com/btcsuite/btcd/rpcclient"
9-
"github.com/btcsuite/btcd/wire"
9+
"github.com/btcsuite/btcd/wire/v2"
1010
)
1111

1212
// BitcoindEvents is the interface that must be satisfied by any type that

chain/bitcoind_events_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ import (
77
"testing"
88
"time"
99

10+
"github.com/btcsuite/btcd/address/v2"
1011
"github.com/btcsuite/btcd/btcec/v2"
11-
"github.com/btcsuite/btcd/btcutil"
12-
"github.com/btcsuite/btcd/chaincfg"
13-
"github.com/btcsuite/btcd/chaincfg/chainhash"
12+
"github.com/btcsuite/btcd/chaincfg/v2"
13+
"github.com/btcsuite/btcd/chainhash/v2"
1414
"github.com/btcsuite/btcd/integration/rpctest"
1515
"github.com/btcsuite/btcd/rpcclient"
16-
"github.com/btcsuite/btcd/txscript"
17-
"github.com/btcsuite/btcd/wire"
16+
"github.com/btcsuite/btcd/txscript/v2"
17+
"github.com/btcsuite/btcd/wire/v2"
1818
"github.com/stretchr/testify/require"
1919
)
2020

@@ -541,8 +541,8 @@ func randPubKeyHashScript() ([]byte, *btcec.PrivateKey, error) {
541541
return nil, nil, err
542542
}
543543

544-
pubKeyHash := btcutil.Hash160(privKey.PubKey().SerializeCompressed())
545-
addrScript, err := btcutil.NewAddressPubKeyHash(
544+
pubKeyHash := address.Hash160(privKey.PubKey().SerializeCompressed())
545+
addrScript, err := address.NewAddressPubKeyHash(
546546
pubKeyHash, &chaincfg.RegressionNetParams,
547547
)
548548
if err != nil {

chain/bitcoind_rpc_events.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import (
55
"sync"
66
"time"
77

8-
"github.com/btcsuite/btcd/chaincfg/chainhash"
8+
"github.com/btcsuite/btcd/chainhash/v2"
99
"github.com/btcsuite/btcd/rpcclient"
10-
"github.com/btcsuite/btcd/wire"
10+
"github.com/btcsuite/btcd/wire/v2"
1111
)
1212

1313
const (

chain/bitcoind_zmq_events.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ import (
99
"sync"
1010
"time"
1111

12-
"github.com/btcsuite/btcd/chaincfg/chainhash"
12+
"github.com/btcsuite/btcd/chainhash/v2"
1313
"github.com/btcsuite/btcd/rpcclient"
14-
"github.com/btcsuite/btcd/wire"
14+
"github.com/btcsuite/btcd/wire/v2"
1515
"github.com/lightninglabs/gozmq"
1616
)
1717

chain/block_filterer.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
package chain
22

33
import (
4-
"github.com/btcsuite/btcd/btcutil"
5-
"github.com/btcsuite/btcd/chaincfg"
6-
"github.com/btcsuite/btcd/txscript"
7-
"github.com/btcsuite/btcd/wire"
4+
"github.com/btcsuite/btcd/address/v2"
5+
"github.com/btcsuite/btcd/btcutil/v2"
6+
"github.com/btcsuite/btcd/chaincfg/v2"
7+
"github.com/btcsuite/btcd/txscript/v2"
8+
"github.com/btcsuite/btcd/wire/v2"
89
"github.com/btcsuite/btcwallet/waddrmgr"
910
)
1011

@@ -42,7 +43,7 @@ type BlockFilterer struct {
4243
// WathcedOutPoints is a global set of outpoints being tracked by the
4344
// wallet. This allows the block filterer to check for spends from an
4445
// outpoint we own.
45-
WatchedOutPoints map[wire.OutPoint]btcutil.Address
46+
WatchedOutPoints map[wire.OutPoint]address.Address
4647

4748
// FoundExternal is a two-layer map recording the scope and index of
4849
// external addresses found in a single block.
@@ -54,7 +55,7 @@ type BlockFilterer struct {
5455

5556
// FoundOutPoints is a set of outpoints found in a single block whose
5657
// address belongs to the wallet.
57-
FoundOutPoints map[wire.OutPoint]btcutil.Address
58+
FoundOutPoints map[wire.OutPoint]address.Address
5859

5960
// RelevantTxns records the transactions found in a particular block
6061
// that contained matches from an address in either ExReverseFilter or
@@ -87,7 +88,7 @@ func NewBlockFilterer(params *chaincfg.Params,
8788

8889
foundExternal := make(map[waddrmgr.KeyScope]map[uint32]struct{})
8990
foundInternal := make(map[waddrmgr.KeyScope]map[uint32]struct{})
90-
foundOutPoints := make(map[wire.OutPoint]btcutil.Address)
91+
foundOutPoints := make(map[wire.OutPoint]address.Address)
9192

9293
return &BlockFilterer{
9394
Params: params,
@@ -179,7 +180,7 @@ func (bf *BlockFilterer) FilterTx(tx *wire.MsgTx) bool {
179180
// added to set of external and internal found addresses, respectively. This
180181
// method returns true iff a non-zero number of the provided addresses are of
181182
// interest.
182-
func (bf *BlockFilterer) FilterOutputAddrs(addrs []btcutil.Address) bool {
183+
func (bf *BlockFilterer) FilterOutputAddrs(addrs []address.Address) bool {
183184
var isRelevant bool
184185
for _, addr := range addrs {
185186
addrStr := addr.EncodeAddress()

chain/block_filterer_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ import (
55
"testing"
66
"time"
77

8-
"github.com/btcsuite/btcd/btcutil"
9-
"github.com/btcsuite/btcd/chaincfg"
10-
"github.com/btcsuite/btcd/chaincfg/chainhash"
11-
"github.com/btcsuite/btcd/wire"
8+
"github.com/btcsuite/btcd/address/v2"
9+
"github.com/btcsuite/btcd/chaincfg/v2"
10+
"github.com/btcsuite/btcd/chainhash/v2"
11+
"github.com/btcsuite/btcd/wire/v2"
1212
"github.com/btcsuite/btcwallet/chain"
1313
)
1414

@@ -273,9 +273,9 @@ func TestBlockFiltererOneInOneOut(t *testing.T) {
273273

274274
// Add each of their single previous outpoints to the set of watched
275275
// outpoints to filter for.
276-
watchedOutPoints := make(map[wire.OutPoint]btcutil.Address)
277-
watchedOutPoints[firstTx.TxIn[0].PreviousOutPoint] = &btcutil.AddressWitnessPubKeyHash{}
278-
watchedOutPoints[lastTx.TxIn[0].PreviousOutPoint] = &btcutil.AddressWitnessPubKeyHash{}
276+
watchedOutPoints := make(map[wire.OutPoint]address.Address)
277+
watchedOutPoints[firstTx.TxIn[0].PreviousOutPoint] = &address.AddressWitnessPubKeyHash{}
278+
watchedOutPoints[lastTx.TxIn[0].PreviousOutPoint] = &address.AddressWitnessPubKeyHash{}
279279

280280
// Construct a filter request, watching only for the outpoints above,
281281
// and construct a block filterer.

chain/btcd.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@ import (
1111
"sync"
1212
"time"
1313

14+
"github.com/btcsuite/btcd/address/v2"
1415
"github.com/btcsuite/btcd/btcjson"
15-
"github.com/btcsuite/btcd/btcutil"
16-
"github.com/btcsuite/btcd/btcutil/gcs"
17-
"github.com/btcsuite/btcd/btcutil/gcs/builder"
18-
"github.com/btcsuite/btcd/chaincfg"
19-
"github.com/btcsuite/btcd/chaincfg/chainhash"
16+
"github.com/btcsuite/btcd/btcutil/v2"
17+
"github.com/btcsuite/btcd/btcutil/v2/gcs"
18+
"github.com/btcsuite/btcd/btcutil/v2/gcs/builder"
19+
"github.com/btcsuite/btcd/chaincfg/v2"
20+
"github.com/btcsuite/btcd/chainhash/v2"
2021
"github.com/btcsuite/btcd/rpcclient"
21-
"github.com/btcsuite/btcd/wire"
22+
"github.com/btcsuite/btcd/wire/v2"
2223
"github.com/btcsuite/btcwallet/waddrmgr"
2324
"github.com/btcsuite/btcwallet/wtxmgr"
2425
)
@@ -270,8 +271,8 @@ func (c *RPCClient) IsCurrent() bool {
270271
// allows us to map an outpoint to the address in the chain that it pays to.
271272
// This is useful when using BIP 158 filters as they include the prev pkScript
272273
// rather than the full outpoint.
273-
func (c *RPCClient) Rescan(startHash *chainhash.Hash, addrs []btcutil.Address,
274-
outPoints map[wire.OutPoint]btcutil.Address) error {
274+
func (c *RPCClient) Rescan(startHash *chainhash.Hash, addrs []address.Address,
275+
outPoints map[wire.OutPoint]address.Address) error {
275276

276277
flatOutpoints := make([]*wire.OutPoint, 0, len(outPoints))
277278
for ops := range outPoints {

chain/btcd_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package chain
33
import (
44
"testing"
55

6-
"github.com/btcsuite/btcd/chaincfg"
6+
"github.com/btcsuite/btcd/chaincfg/v2"
77
"github.com/btcsuite/btcd/rpcclient"
88
"github.com/stretchr/testify/require"
99
)

0 commit comments

Comments
 (0)