mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-03-04 09:48:19 +01:00
lnd: modify the daemon's initialization to use new wallet API's
This commit is contained in:
parent
abf658a719
commit
0d871dabb3
3 changed files with 18 additions and 11 deletions
|
@ -469,7 +469,6 @@ func (f *fundingManager) handleFundingComplete(fmsg *fundingCompleteMsg) {
|
||||||
// Append a sighash type of SigHashAll to the signature as it's the
|
// Append a sighash type of SigHashAll to the signature as it's the
|
||||||
// sighash type used implicitly within this type of channel for
|
// sighash type used implicitly within this type of channel for
|
||||||
// commitment transactions.
|
// commitment transactions.
|
||||||
commitSig = append(commitSig, byte(txscript.SigHashAll))
|
|
||||||
revokeKey := fmsg.msg.RevocationKey
|
revokeKey := fmsg.msg.RevocationKey
|
||||||
if err := resCtx.reservation.CompleteReservationSingle(revokeKey, fundingOut, commitSig); err != nil {
|
if err := resCtx.reservation.CompleteReservationSingle(revokeKey, fundingOut, commitSig); err != nil {
|
||||||
// TODO(roasbeef): better error logging: peerID, channelID, etc.
|
// TODO(roasbeef): better error logging: peerID, channelID, etc.
|
||||||
|
@ -521,7 +520,7 @@ func (f *fundingManager) handleFundingSignComplete(fmsg *fundingSignCompleteMsg)
|
||||||
// The remote peer has responded with a signature for our commitment
|
// The remote peer has responded with a signature for our commitment
|
||||||
// transaction. We'll verify the signature for validity, then commit
|
// transaction. We'll verify the signature for validity, then commit
|
||||||
// the state to disk as we can now open the channel.
|
// the state to disk as we can now open the channel.
|
||||||
commitSig := append(fmsg.msg.CommitSignature.Serialize(), byte(txscript.SigHashAll))
|
commitSig := fmsg.msg.CommitSignature.Serialize()
|
||||||
if err := resCtx.reservation.CompleteReservation(nil, commitSig); err != nil {
|
if err := resCtx.reservation.CompleteReservation(nil, commitSig); err != nil {
|
||||||
fndgLog.Errorf("unable to complete reservation sign complete: %v", err)
|
fndgLog.Errorf("unable to complete reservation sign complete: %v", err)
|
||||||
fmsg.peer.Disconnect()
|
fmsg.peer.Disconnect()
|
||||||
|
|
22
lnd.go
22
lnd.go
|
@ -18,6 +18,7 @@ import (
|
||||||
"github.com/lightningnetwork/lnd/channeldb"
|
"github.com/lightningnetwork/lnd/channeldb"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc"
|
"github.com/lightningnetwork/lnd/lnrpc"
|
||||||
"github.com/lightningnetwork/lnd/lnwallet"
|
"github.com/lightningnetwork/lnd/lnwallet"
|
||||||
|
"github.com/lightningnetwork/lnd/lnwallet/btcwallet"
|
||||||
"github.com/roasbeef/btcrpcclient"
|
"github.com/roasbeef/btcrpcclient"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -116,9 +117,8 @@ func lndMain() error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create, and start the lnwallet, which handles the core payment
|
// TODO(roasbeef): paarse config here select chosen WalletController
|
||||||
// channel logic, and exposes control via proxy state machines.
|
walletConfig := &btcwallet.Config{
|
||||||
walletConfig := &lnwallet.Config{
|
|
||||||
PrivatePass: []byte("hello"),
|
PrivatePass: []byte("hello"),
|
||||||
DataDir: filepath.Join(loadedConfig.DataDir, "lnwallet"),
|
DataDir: filepath.Join(loadedConfig.DataDir, "lnwallet"),
|
||||||
RpcHost: fmt.Sprintf("%v:%v", rpcIP[0], activeNetParams.rpcPort),
|
RpcHost: fmt.Sprintf("%v:%v", rpcIP[0], activeNetParams.rpcPort),
|
||||||
|
@ -127,7 +127,18 @@ func lndMain() error {
|
||||||
CACert: rpcCert,
|
CACert: rpcCert,
|
||||||
NetParams: activeNetParams.Params,
|
NetParams: activeNetParams.Params,
|
||||||
}
|
}
|
||||||
wallet, err := lnwallet.NewLightningWallet(walletConfig, chanDB, notifier)
|
wc, err := btcwallet.New(walletConfig)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Printf("unable to create wallet controller: %v\n", err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
signer := wc
|
||||||
|
bio := wc
|
||||||
|
|
||||||
|
// Create, and start the lnwallet, which handles the core payment
|
||||||
|
// channel logic, and exposes control via proxy state machines.
|
||||||
|
wallet, err := lnwallet.NewLightningWallet(chanDB, notifier,
|
||||||
|
wc, signer, bio, activeNetParams.Params)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("unable to create wallet: %v\n", err)
|
fmt.Printf("unable to create wallet: %v\n", err)
|
||||||
return err
|
return err
|
||||||
|
@ -138,9 +149,6 @@ func lndMain() error {
|
||||||
}
|
}
|
||||||
ltndLog.Info("LightningWallet opened")
|
ltndLog.Info("LightningWallet opened")
|
||||||
|
|
||||||
ec := &lnwallet.WaddrmgrEncryptorDecryptor{wallet.Manager}
|
|
||||||
chanDB.RegisterCryptoSystem(ec)
|
|
||||||
|
|
||||||
// Set up the core server which will listen for incoming peer
|
// Set up the core server which will listen for incoming peer
|
||||||
// connections.
|
// connections.
|
||||||
defaultListenAddrs := []string{
|
defaultListenAddrs := []string{
|
||||||
|
|
4
peer.go
4
peer.go
|
@ -218,8 +218,8 @@ func newPeer(conn net.Conn, server *server, btcNet wire.BitcoinNet, inbound bool
|
||||||
func (p *peer) loadActiveChannels(chans []*channeldb.OpenChannel) error {
|
func (p *peer) loadActiveChannels(chans []*channeldb.OpenChannel) error {
|
||||||
for _, dbChan := range chans {
|
for _, dbChan := range chans {
|
||||||
chanID := dbChan.ChanID
|
chanID := dbChan.ChanID
|
||||||
lnChan, err := lnwallet.NewLightningChannel(p.server.lnwallet,
|
lnChan, err := lnwallet.NewLightningChannel(p.server.lnwallet.Signer,
|
||||||
p.server.chainNotifier, p.server.chanDB, dbChan)
|
p.server.lnwallet, p.server.chainNotifier, dbChan)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue