lnwallet: update chainNotifier assignment to new BtcdNotifier constructor
This commit is contained in:
parent
3d478cdd3e
commit
25c1b7a491
@ -212,6 +212,9 @@ type LightningWallet struct {
|
|||||||
// websockets are used for notifications. If using Bitcoin Core,
|
// websockets are used for notifications. If using Bitcoin Core,
|
||||||
// notifications are either generated via long-polling or the usage of
|
// notifications are either generated via long-polling or the usage of
|
||||||
// ZeroMQ.
|
// ZeroMQ.
|
||||||
|
// TODO(roasbeef): make into interface need: getrawtransaction + gettxout
|
||||||
|
// * getrawtransaction -> verify proof of channel links
|
||||||
|
// * gettxout -> verify inputs to funding tx exist and are unspent
|
||||||
rpc *chain.RPCClient
|
rpc *chain.RPCClient
|
||||||
|
|
||||||
// All messages to the wallet are to be sent accross this channel.
|
// All messages to the wallet are to be sent accross this channel.
|
||||||
@ -314,7 +317,12 @@ func NewLightningWallet(config *Config) (*LightningWallet, walletdb.DB, error) {
|
|||||||
log.Printf("stored identity key pubkey hash in channeldb\n")
|
log.Printf("stored identity key pubkey hash in channeldb\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
chainNotifier, err := btcdnotify.NewBtcdNotifier(wallet)
|
rpcc, err := chain.NewRPCClient(l.cfg.NetParams, l.cfg.RpcHost,
|
||||||
|
l.cfg.RpcUser, l.cfg.RpcPass, l.cfg.CACert, false, 20)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
chainNotifier, err := btcdnotify.NewBtcdNotifier(wallet.NtfnServer, rpcc)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
@ -323,6 +331,7 @@ func NewLightningWallet(config *Config) (*LightningWallet, walletdb.DB, error) {
|
|||||||
return &LightningWallet{
|
return &LightningWallet{
|
||||||
db: walletDB,
|
db: walletDB,
|
||||||
chainNotifier: chainNotifier,
|
chainNotifier: chainNotifier,
|
||||||
|
rpc: rpcc,
|
||||||
Wallet: wallet,
|
Wallet: wallet,
|
||||||
ChannelDB: cdb,
|
ChannelDB: cdb,
|
||||||
msgChan: make(chan interface{}, msgBufferSize),
|
msgChan: make(chan interface{}, msgBufferSize),
|
||||||
@ -343,21 +352,23 @@ func (l *LightningWallet) Startup() error {
|
|||||||
if atomic.AddInt32(&l.started, 1) != 1 {
|
if atomic.AddInt32(&l.started, 1) != 1 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
// TODO(roasbeef): config...
|
|
||||||
|
|
||||||
rpcc, err := chain.NewRPCClient(l.cfg.NetParams, l.cfg.RpcHost,
|
// Establish an RPC connection in additino to starting the goroutines
|
||||||
l.cfg.RpcUser, l.cfg.RpcPass, l.cfg.CACert, false, 20)
|
// in the underlying wallet.
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Start the goroutines in the underlying wallet.
|
|
||||||
l.rpc = rpcc
|
|
||||||
if err := l.rpc.Start(); err != nil {
|
if err := l.rpc.Start(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
l.Start()
|
l.Start()
|
||||||
|
|
||||||
|
// Start the notification server. This is used so channel managment
|
||||||
|
// goroutines can be notified when a funding transaction reaches a
|
||||||
|
// sufficient number of confirmations, or when the input for the funding
|
||||||
|
// transaction is spent in an attempt at an uncooperative close by the
|
||||||
|
// counter party.
|
||||||
|
if err := l.chainNotifier.Start(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
// Pass the rpc client into the wallet so it can sync up to the current
|
// Pass the rpc client into the wallet so it can sync up to the current
|
||||||
// main chain.
|
// main chain.
|
||||||
l.SynchronizeRPC(l.rpc)
|
l.SynchronizeRPC(l.rpc)
|
||||||
@ -376,8 +387,11 @@ func (l *LightningWallet) Shutdown() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
l.Stop()
|
l.Stop()
|
||||||
|
|
||||||
l.rpc.Shutdown()
|
l.rpc.Shutdown()
|
||||||
|
|
||||||
|
l.chainNotifier.Stop()
|
||||||
|
|
||||||
close(l.quit)
|
close(l.quit)
|
||||||
l.wg.Wait()
|
l.wg.Wait()
|
||||||
return nil
|
return nil
|
||||||
@ -937,8 +951,7 @@ func (l *LightningWallet) handleFundingCounterPartySigs(msg *addCounterPartySigs
|
|||||||
ourKeySer := ourKey.PubKey().SerializeCompressed()
|
ourKeySer := ourKey.PubKey().SerializeCompressed()
|
||||||
theirKeySer := theirKey.SerializeCompressed()
|
theirKeySer := theirKey.SerializeCompressed()
|
||||||
scriptSig, err := spendMultiSig(redeemScript, ourKeySer, ourCommitSig,
|
scriptSig, err := spendMultiSig(redeemScript, ourKeySer, ourCommitSig,
|
||||||
theirKeySer,
|
theirKeySer, theirCommitSig)
|
||||||
theirCommitSig)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
msg.err <- err
|
msg.err <- err
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user