From 9f0efddc209f57214bc0b9539fbb63419a73b012 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Thu, 24 Aug 2017 18:54:17 -0700 Subject: [PATCH] multi: switch from btcrpcclient to rpcclient --- chainntnfs/btcdnotify/btcd.go | 18 +++++++++--------- chainntnfs/btcdnotify/driver.go | 6 +++--- chainntnfs/interface_test.go | 2 +- chainntnfs/neutrinonotify/neutrino.go | 4 ++-- chainregistry.go | 4 ++-- config.go | 8 ++++---- lnd_test.go | 8 ++++---- lnwallet/btcwallet/driver.go | 2 +- lnwallet/interface_test.go | 2 +- lnwallet/log.go | 4 ++-- networktest.go | 8 ++++---- routing/chainview/btcd.go | 16 ++++++++-------- routing/chainview/interface_test.go | 10 +++++----- routing/chainview/neutrino.go | 4 ++-- 14 files changed, 48 insertions(+), 48 deletions(-) diff --git a/chainntnfs/btcdnotify/btcd.go b/chainntnfs/btcdnotify/btcd.go index 8683ef05..365c05f9 100644 --- a/chainntnfs/btcdnotify/btcd.go +++ b/chainntnfs/btcdnotify/btcd.go @@ -10,8 +10,8 @@ import ( "github.com/lightningnetwork/lnd/chainntnfs" "github.com/roasbeef/btcd/btcjson" "github.com/roasbeef/btcd/chaincfg/chainhash" + "github.com/roasbeef/btcd/rpcclient" "github.com/roasbeef/btcd/wire" - "github.com/roasbeef/btcrpcclient" "github.com/roasbeef/btcutil" ) @@ -58,7 +58,7 @@ type BtcdNotifier struct { started int32 // To be used atomically. stopped int32 // To be used atomically. - chainConn *btcrpcclient.Client + chainConn *rpcclient.Client notificationCancels chan interface{} notificationRegistry chan interface{} @@ -90,7 +90,7 @@ var _ chainntnfs.ChainNotifier = (*BtcdNotifier)(nil) // New returns a new BtcdNotifier instance. This function assumes the btcd node // detailed in the passed configuration is already running, and willing to // accept new websockets clients. -func New(config *btcrpcclient.ConnConfig) (*BtcdNotifier, error) { +func New(config *rpcclient.ConnConfig) (*BtcdNotifier, error) { notifier := &BtcdNotifier{ notificationCancels: make(chan interface{}), notificationRegistry: make(chan interface{}), @@ -110,17 +110,17 @@ func New(config *btcrpcclient.ConnConfig) (*BtcdNotifier, error) { quit: make(chan struct{}), } - ntfnCallbacks := &btcrpcclient.NotificationHandlers{ + ntfnCallbacks := &rpcclient.NotificationHandlers{ OnBlockConnected: notifier.onBlockConnected, OnBlockDisconnected: notifier.onBlockDisconnected, OnRedeemingTx: notifier.onRedeemingTx, } - // Disable connecting to btcd within the btcrpcclient.New method. We + // Disable connecting to btcd within the rpcclient.New method. We // defer establishing the connection to our .Start() method. config.DisableConnectOnNew = true config.DisableAutoReconnect = false - chainConn, err := btcrpcclient.New(config, ntfnCallbacks) + chainConn, err := rpcclient.New(config, ntfnCallbacks) if err != nil { return nil, err } @@ -198,7 +198,7 @@ type blockNtfn struct { height int32 } -// onBlockConnected implements on OnBlockConnected callback for btcrpcclient. +// onBlockConnected implements on OnBlockConnected callback for rpcclient. // Ingesting a block updates the wallet's internal utxo state based on the // outputs created and destroyed within each block. func (b *BtcdNotifier) onBlockConnected(hash *chainhash.Hash, height int32, t time.Time) { @@ -216,11 +216,11 @@ func (b *BtcdNotifier) onBlockConnected(hash *chainhash.Hash, height int32, t ti }() } -// onBlockDisconnected implements on OnBlockDisconnected callback for btcrpcclient. +// onBlockDisconnected implements on OnBlockDisconnected callback for rpcclient. func (b *BtcdNotifier) onBlockDisconnected(hash *chainhash.Hash, height int32, t time.Time) { } -// onRedeemingTx implements on OnRedeemingTx callback for btcrpcclient. +// onRedeemingTx implements on OnRedeemingTx callback for rpcclient. func (b *BtcdNotifier) onRedeemingTx(tx *btcutil.Tx, details *btcjson.BlockDetails) { // Append this new transaction update to the end of the queue of new // chain updates. diff --git a/chainntnfs/btcdnotify/driver.go b/chainntnfs/btcdnotify/driver.go index 1d3777fa..7b159c37 100644 --- a/chainntnfs/btcdnotify/driver.go +++ b/chainntnfs/btcdnotify/driver.go @@ -4,7 +4,7 @@ import ( "fmt" "github.com/lightningnetwork/lnd/chainntnfs" - "github.com/roasbeef/btcrpcclient" + "github.com/roasbeef/btcd/rpcclient" ) // createNewNotifier creates a new instance of the ChainNotifier interface @@ -15,10 +15,10 @@ func createNewNotifier(args ...interface{}) (chainntnfs.ChainNotifier, error) { "expected 1, instead passed %v", len(args)) } - config, ok := args[0].(*btcrpcclient.ConnConfig) + config, ok := args[0].(*rpcclient.ConnConfig) if !ok { return nil, fmt.Errorf("first argument to btcdnotifier.New is " + - "incorrect, expected a *btcrpcclient.ConnConfig") + "incorrect, expected a *rpcclient.ConnConfig") } return New(config) diff --git a/chainntnfs/interface_test.go b/chainntnfs/interface_test.go index 3b50a358..37c65df7 100644 --- a/chainntnfs/interface_test.go +++ b/chainntnfs/interface_test.go @@ -18,7 +18,7 @@ import ( "github.com/roasbeef/btcd/btcec" "github.com/roasbeef/btcd/chaincfg" - "github.com/roasbeef/btcd/rpctest" + "github.com/roasbeef/btcd/integration/rpctest" "github.com/roasbeef/btcd/txscript" "github.com/roasbeef/btcd/wire" "github.com/roasbeef/btcutil" diff --git a/chainntnfs/neutrinonotify/neutrino.go b/chainntnfs/neutrinonotify/neutrino.go index ba5b2803..b2ac0ae7 100644 --- a/chainntnfs/neutrinonotify/neutrino.go +++ b/chainntnfs/neutrinonotify/neutrino.go @@ -10,8 +10,8 @@ import ( "github.com/lightninglabs/neutrino" "github.com/lightningnetwork/lnd/chainntnfs" "github.com/roasbeef/btcd/chaincfg/chainhash" + "github.com/roasbeef/btcd/rpcclient" "github.com/roasbeef/btcd/wire" - "github.com/roasbeef/btcrpcclient" "github.com/roasbeef/btcutil" "github.com/roasbeef/btcutil/gcs/builder" "github.com/roasbeef/btcwallet/waddrmgr" @@ -142,7 +142,7 @@ func (n *NeutrinoNotifier) Start() error { neutrino.StartBlock(startingPoint), neutrino.QuitChan(n.quit), neutrino.NotificationHandlers( - btcrpcclient.NotificationHandlers{ + rpcclient.NotificationHandlers{ OnFilteredBlockConnected: n.onFilteredBlockConnected, OnFilteredBlockDisconnected: n.onFilteredBlockDisconnected, }, diff --git a/chainregistry.go b/chainregistry.go index 5af8399a..c5cc50e8 100644 --- a/chainregistry.go +++ b/chainregistry.go @@ -21,7 +21,7 @@ import ( "github.com/lightningnetwork/lnd/lnwire" "github.com/lightningnetwork/lnd/routing/chainview" "github.com/roasbeef/btcd/chaincfg/chainhash" - "github.com/roasbeef/btcrpcclient" + "github.com/roasbeef/btcd/rpcclient" "github.com/roasbeef/btcwallet/chain" "github.com/roasbeef/btcwallet/walletdb" ) @@ -230,7 +230,7 @@ func newChainControlFromConfig(cfg *config, chanDB *channeldb.DB) (*chainControl btcdUser := homeChainConfig.RPCUser btcdPass := homeChainConfig.RPCPass - rpcConfig := &btcrpcclient.ConnConfig{ + rpcConfig := &rpcclient.ConnConfig{ Host: btcdHost, Endpoint: "ws", User: btcdUser, diff --git a/config.go b/config.go index 6800b4ae..cc8a7c87 100644 --- a/config.go +++ b/config.go @@ -481,8 +481,8 @@ func noiseDial(idPriv *btcec.PrivateKey) func(net.Addr) (net.Conn, error) { } func parseRPCParams(cConfig *chainConfig, net chainCode, funcName string) error { - // If the rpcuser and rpcpass paramters aren't set, then we'll attempt - // to automatically obtain the properm mcredentials for btcd and set + // If the rpcuser and rpcpass parameters aren't set, then we'll attempt + // to automatically obtain the proper credentials for btcd and set // them within the configuration. if cConfig.RPCUser != "" || cConfig.RPCPass != "" { return nil @@ -490,10 +490,10 @@ func parseRPCParams(cConfig *chainConfig, net chainCode, funcName string) error // If we're in simnet mode, then the running btcd instance won't read // the RPC credentials from the configuration. So if lnd wasn't - // specified the paramters, then we won't be able to start. + // specified the parameters, then we won't be able to start. if cConfig.SimNet { str := "%v: rpcuser and rpcpass must be set to your btcd " + - "node's RPC paramters" + "node's RPC parameters for simnet mode" return fmt.Errorf(str, funcName) } diff --git a/lnd_test.go b/lnd_test.go index 5d7a8100..c431030e 100644 --- a/lnd_test.go +++ b/lnd_test.go @@ -29,9 +29,9 @@ import ( "github.com/lightningnetwork/lnd/lnwire" "github.com/roasbeef/btcd/chaincfg" "github.com/roasbeef/btcd/chaincfg/chainhash" - "github.com/roasbeef/btcd/rpctest" + "github.com/roasbeef/btcd/integration/rpctest" + "github.com/roasbeef/btcd/rpcclient" "github.com/roasbeef/btcd/wire" - "github.com/roasbeef/btcrpcclient" "github.com/roasbeef/btcutil" "golang.org/x/net/context" "google.golang.org/grpc" @@ -3166,7 +3166,7 @@ func TestLightningNetworkDaemon(t *testing.T) { } }() - handlers := &btcrpcclient.NotificationHandlers{ + handlers := &rpcclient.NotificationHandlers{ OnTxAccepted: lndHarness.OnTxAccepted, } @@ -3201,7 +3201,7 @@ func TestLightningNetworkDaemon(t *testing.T) { // Turn off the btcd rpc logging, otherwise it will lead to panic. // TODO(andrew.shvv|roasbeef) Remove the hack after re-work the way the log // rotator os work. - btcrpcclient.UseLogger(btclog.Disabled) + rpcclient.UseLogger(btclog.Disabled) if err := btcdHarness.SetUp(true, 50); err != nil { ht.Fatalf("unable to set up mining node: %v", err) diff --git a/lnwallet/btcwallet/driver.go b/lnwallet/btcwallet/driver.go index ca34ab5b..16078572 100644 --- a/lnwallet/btcwallet/driver.go +++ b/lnwallet/btcwallet/driver.go @@ -23,7 +23,7 @@ func createNewWallet(args ...interface{}) (lnwallet.WalletController, error) { config, ok := args[0].(*Config) if !ok { return nil, fmt.Errorf("first argument to btcdnotifier.New is " + - "incorrect, expected a *btcrpcclient.ConnConfig") + "incorrect, expected a *rpcclient.ConnConfig") } return New(*config) diff --git a/lnwallet/interface_test.go b/lnwallet/interface_test.go index f31c72b9..c008492c 100644 --- a/lnwallet/interface_test.go +++ b/lnwallet/interface_test.go @@ -27,7 +27,7 @@ import ( _ "github.com/roasbeef/btcwallet/walletdb/bdb" "github.com/roasbeef/btcd/btcec" - "github.com/roasbeef/btcd/rpctest" + "github.com/roasbeef/btcd/integration/rpctest" "github.com/roasbeef/btcd/txscript" "github.com/roasbeef/btcd/wire" "github.com/roasbeef/btcutil" diff --git a/lnwallet/log.go b/lnwallet/log.go index 95b26405..478a2378 100644 --- a/lnwallet/log.go +++ b/lnwallet/log.go @@ -2,7 +2,7 @@ package lnwallet import ( "github.com/btcsuite/btclog" - "github.com/roasbeef/btcrpcclient" + "github.com/roasbeef/btcd/rpcclient" "github.com/roasbeef/btcwallet/chain" btcwallet "github.com/roasbeef/btcwallet/wallet" "github.com/roasbeef/btcwallet/wtxmgr" @@ -32,7 +32,7 @@ func UseLogger(logger btclog.Logger) { btcwallet.UseLogger(logger) wtxmgr.UseLogger(logger) - btcrpcclient.UseLogger(logger) + rpcclient.UseLogger(logger) chain.UseLogger(logger) } diff --git a/networktest.go b/networktest.go index cf4458e5..7c31a76a 100644 --- a/networktest.go +++ b/networktest.go @@ -30,10 +30,10 @@ import ( "github.com/lightningnetwork/lnd/macaroons" "github.com/roasbeef/btcd/chaincfg" "github.com/roasbeef/btcd/chaincfg/chainhash" - "github.com/roasbeef/btcd/rpctest" + "github.com/roasbeef/btcd/integration/rpctest" + "github.com/roasbeef/btcd/rpcclient" "github.com/roasbeef/btcd/txscript" "github.com/roasbeef/btcd/wire" - "github.com/roasbeef/btcrpcclient" "github.com/roasbeef/btcutil" ) @@ -118,7 +118,7 @@ type lightningNode struct { // newLightningNode creates a new test lightning node instance from the passed // rpc config and slice of extra arguments. -func newLightningNode(btcrpcConfig *btcrpcclient.ConnConfig, lndArgs []string) (*lightningNode, error) { +func newLightningNode(btcrpcConfig *rpcclient.ConnConfig, lndArgs []string) (*lightningNode, error) { var err error cfg := &config{ @@ -662,7 +662,7 @@ func (l *lightningNode) WaitForBlockchainSync(ctx context.Context) error { // The harness by default is created with two active nodes on the network: // Alice and Bob. type networkHarness struct { - rpcConfig btcrpcclient.ConnConfig + rpcConfig rpcclient.ConnConfig netParams *chaincfg.Params Miner *rpctest.Harness diff --git a/routing/chainview/btcd.go b/routing/chainview/btcd.go index 336623b8..41cc5736 100644 --- a/routing/chainview/btcd.go +++ b/routing/chainview/btcd.go @@ -7,8 +7,8 @@ import ( "time" "github.com/roasbeef/btcd/chaincfg/chainhash" + "github.com/roasbeef/btcd/rpcclient" "github.com/roasbeef/btcd/wire" - "github.com/roasbeef/btcrpcclient" ) // BtcdFilteredChainView is an implementation of the FilteredChainView @@ -23,7 +23,7 @@ type BtcdFilteredChainView struct { // bestHeight is the height of the latest block in the main chain. bestHeight int32 - btcdConn *btcrpcclient.Client + btcdConn *rpcclient.Client // newBlocks is the channel in which new filtered blocks are sent over. newBlocks chan *FilteredBlock @@ -61,7 +61,7 @@ var _ FilteredChainView = (*BtcdFilteredChainView)(nil) // NewBtcdFilteredChainView creates a new instance of a FilteredChainView from // RPC credentials for an active btcd instance. -func NewBtcdFilteredChainView(config btcrpcclient.ConnConfig) (*BtcdFilteredChainView, error) { +func NewBtcdFilteredChainView(config rpcclient.ConnConfig) (*BtcdFilteredChainView, error) { chainView := &BtcdFilteredChainView{ newBlocks: make(chan *FilteredBlock), staleBlocks: make(chan *FilteredBlock), @@ -72,16 +72,16 @@ func NewBtcdFilteredChainView(config btcrpcclient.ConnConfig) (*BtcdFilteredChai quit: make(chan struct{}), } - ntfnCallbacks := &btcrpcclient.NotificationHandlers{ + ntfnCallbacks := &rpcclient.NotificationHandlers{ OnBlockConnected: chainView.onBlockConnected, OnBlockDisconnected: chainView.onBlockDisconnected, } - // Disable connecting to btcd within the btcrpcclient.New method. We + // Disable connecting to btcd within the rpcclient.New method. We // defer establishing the connection to our .Start() method. config.DisableConnectOnNew = true config.DisableAutoReconnect = false - chainConn, err := btcrpcclient.New(&config, ntfnCallbacks) + chainConn, err := rpcclient.New(&config, ntfnCallbacks) if err != nil { return nil, err } @@ -153,7 +153,7 @@ type chainUpdate struct { blockHeight int32 } -// onBlockConnected implements on OnBlockConnected callback for btcrpcclient. +// onBlockConnected implements on OnBlockConnected callback for rpcclient. // Ingesting a block updates the wallet's internal utxo state based on the // outputs created and destroyed within each block. func (b *BtcdFilteredChainView) onBlockConnected(hash *chainhash.Hash, @@ -173,7 +173,7 @@ func (b *BtcdFilteredChainView) onBlockConnected(hash *chainhash.Hash, }() } -// onBlockDisconnected implements on OnBlockDisconnected callback for btcrpcclient. +// onBlockDisconnected implements on OnBlockDisconnected callback for rpcclient. func (b *BtcdFilteredChainView) onBlockDisconnected(hash *chainhash.Hash, height int32, t time.Time) { diff --git a/routing/chainview/interface_test.go b/routing/chainview/interface_test.go index ec7fdd33..d2e2308b 100644 --- a/routing/chainview/interface_test.go +++ b/routing/chainview/interface_test.go @@ -14,10 +14,10 @@ import ( "github.com/roasbeef/btcd/btcec" "github.com/roasbeef/btcd/chaincfg" "github.com/roasbeef/btcd/chaincfg/chainhash" - "github.com/roasbeef/btcd/rpctest" + "github.com/roasbeef/btcd/integration/rpctest" + "github.com/roasbeef/btcd/rpcclient" "github.com/roasbeef/btcd/txscript" "github.com/roasbeef/btcd/wire" - "github.com/roasbeef/btcrpcclient" "github.com/roasbeef/btcutil" "github.com/roasbeef/btcwallet/walletdb" @@ -473,12 +473,12 @@ var chainViewTests = []testCase{ var interfaceImpls = []struct { name string - chainViewInit func(rpcInfo btcrpcclient.ConnConfig, + chainViewInit func(rpcInfo rpcclient.ConnConfig, p2pAddr string) (func(), FilteredChainView, error) }{ { name: "p2p_neutrino", - chainViewInit: func(_ btcrpcclient.ConnConfig, p2pAddr string) (func(), FilteredChainView, error) { + chainViewInit: func(_ rpcclient.ConnConfig, p2pAddr string) (func(), FilteredChainView, error) { spvDir, err := ioutil.TempDir("", "neutrino") if err != nil { return nil, nil, err @@ -526,7 +526,7 @@ var interfaceImpls = []struct { }, { name: "btcd_websockets", - chainViewInit: func(config btcrpcclient.ConnConfig, _ string) (func(), FilteredChainView, error) { + chainViewInit: func(config rpcclient.ConnConfig, _ string) (func(), FilteredChainView, error) { chainView, err := NewBtcdFilteredChainView(config) if err != nil { return nil, nil, err diff --git a/routing/chainview/neutrino.go b/routing/chainview/neutrino.go index 84dd6996..bb3e51ca 100644 --- a/routing/chainview/neutrino.go +++ b/routing/chainview/neutrino.go @@ -7,8 +7,8 @@ import ( "github.com/lightninglabs/neutrino" "github.com/roasbeef/btcd/chaincfg/chainhash" + "github.com/roasbeef/btcd/rpcclient" "github.com/roasbeef/btcd/wire" - "github.com/roasbeef/btcrpcclient" "github.com/roasbeef/btcutil" "github.com/roasbeef/btcutil/gcs/builder" "github.com/roasbeef/btcwallet/waddrmgr" @@ -109,7 +109,7 @@ func (c *CfFilteredChainView) Start() error { neutrino.StartBlock(startingPoint), neutrino.QuitChan(c.quit), neutrino.NotificationHandlers( - btcrpcclient.NotificationHandlers{ + rpcclient.NotificationHandlers{ OnFilteredBlockConnected: c.onFilteredBlockConnected, OnFilteredBlockDisconnected: c.onFilteredBlockDisconnected, },