multi: switch from btcrpcclient to rpcclient
This commit is contained in:
parent
ac128e4545
commit
9f0efddc20
@ -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.
|
||||
|
@ -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)
|
||||
|
@ -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"
|
||||
|
@ -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,
|
||||
},
|
||||
|
@ -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,
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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"
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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) {
|
||||
|
||||
|
@ -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
|
||||
|
@ -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,
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user