From 0d871dabb38c5b0d92b099f189e230b6b0edc54f Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Fri, 12 Aug 2016 15:56:57 -0700 Subject: [PATCH] lnd: modify the daemon's initialization to use new wallet API's --- fundingmanager.go | 3 +-- lnd.go | 22 +++++++++++++++------- peer.go | 4 ++-- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/fundingmanager.go b/fundingmanager.go index 3748f77a8..c38f13f8a 100644 --- a/fundingmanager.go +++ b/fundingmanager.go @@ -469,7 +469,6 @@ func (f *fundingManager) handleFundingComplete(fmsg *fundingCompleteMsg) { // Append a sighash type of SigHashAll to the signature as it's the // sighash type used implicitly within this type of channel for // commitment transactions. - commitSig = append(commitSig, byte(txscript.SigHashAll)) revokeKey := fmsg.msg.RevocationKey if err := resCtx.reservation.CompleteReservationSingle(revokeKey, fundingOut, commitSig); err != nil { // 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 // transaction. We'll verify the signature for validity, then commit // 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 { fndgLog.Errorf("unable to complete reservation sign complete: %v", err) fmsg.peer.Disconnect() diff --git a/lnd.go b/lnd.go index efcb9a1d5..74b801cf1 100644 --- a/lnd.go +++ b/lnd.go @@ -18,6 +18,7 @@ import ( "github.com/lightningnetwork/lnd/channeldb" "github.com/lightningnetwork/lnd/lnrpc" "github.com/lightningnetwork/lnd/lnwallet" + "github.com/lightningnetwork/lnd/lnwallet/btcwallet" "github.com/roasbeef/btcrpcclient" ) @@ -116,9 +117,8 @@ func lndMain() error { return err } - // Create, and start the lnwallet, which handles the core payment - // channel logic, and exposes control via proxy state machines. - walletConfig := &lnwallet.Config{ + // TODO(roasbeef): paarse config here select chosen WalletController + walletConfig := &btcwallet.Config{ PrivatePass: []byte("hello"), DataDir: filepath.Join(loadedConfig.DataDir, "lnwallet"), RpcHost: fmt.Sprintf("%v:%v", rpcIP[0], activeNetParams.rpcPort), @@ -127,7 +127,18 @@ func lndMain() error { CACert: rpcCert, 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 { fmt.Printf("unable to create wallet: %v\n", err) return err @@ -138,9 +149,6 @@ func lndMain() error { } ltndLog.Info("LightningWallet opened") - ec := &lnwallet.WaddrmgrEncryptorDecryptor{wallet.Manager} - chanDB.RegisterCryptoSystem(ec) - // Set up the core server which will listen for incoming peer // connections. defaultListenAddrs := []string{ diff --git a/peer.go b/peer.go index a37fdf90b..db8b21067 100644 --- a/peer.go +++ b/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 { for _, dbChan := range chans { chanID := dbChan.ChanID - lnChan, err := lnwallet.NewLightningChannel(p.server.lnwallet, - p.server.chainNotifier, p.server.chanDB, dbChan) + lnChan, err := lnwallet.NewLightningChannel(p.server.lnwallet.Signer, + p.server.lnwallet, p.server.chainNotifier, dbChan) if err != nil { return err }