lnd+walletunlocker: remove macaroon dependency from UnlockerService

This commit is contained in:
Wilmer Paulino
2018-04-20 03:06:06 -04:00
parent e73b457e1f
commit b32e0ced45
3 changed files with 26 additions and 54 deletions

View File

@@ -8,7 +8,6 @@ import (
"github.com/lightningnetwork/lnd/aezeed"
"github.com/lightningnetwork/lnd/lnrpc"
"github.com/lightningnetwork/lnd/lnwallet/btcwallet"
"github.com/lightningnetwork/lnd/macaroons"
"github.com/roasbeef/btcd/chaincfg"
"github.com/roasbeef/btcwallet/wallet"
"golang.org/x/net/context"
@@ -67,13 +66,10 @@ type UnlockerService struct {
chainDir string
netParams *chaincfg.Params
authSvc *macaroons.Service
}
// New creates and returns a new UnlockerService.
func New(authSvc *macaroons.Service, chainDir string,
params *chaincfg.Params) *UnlockerService {
func New(chainDir string, params *chaincfg.Params) *UnlockerService {
return &UnlockerService{
InitMsgs: make(chan *WalletInitMsg, 1),
UnlockMsgs: make(chan *WalletUnlockMsg, 1),
@@ -216,15 +212,6 @@ func (u *UnlockerService) InitWallet(ctx context.Context,
return nil, err
}
// Attempt to create a password for the macaroon service.
if u.authSvc != nil {
err = u.authSvc.CreateUnlock(&password)
if err != nil {
return nil, fmt.Errorf("unable to create/unlock "+
"macaroon store: %v", err)
}
}
// With the cipher seed deciphered, and the auth service created, we'll
// now send over the wallet password and the seed. This will allow the
// daemon to initialize itself and startup.
@@ -277,15 +264,6 @@ func (u *UnlockerService) UnlockWallet(ctx context.Context,
return nil, err
}
// Attempt to create a password for the macaroon service.
if u.authSvc != nil {
err = u.authSvc.CreateUnlock(&password)
if err != nil {
return nil, fmt.Errorf("unable to create/unlock "+
"macaroon store: %v", err)
}
}
walletUnlockMsg := &WalletUnlockMsg{
Passphrase: password,
RecoveryWindow: recoveryWindow,

View File

@@ -67,7 +67,7 @@ func TestGenSeed(t *testing.T) {
defer func() {
os.RemoveAll(testDir)
}()
service := walletunlocker.New(nil, testDir, testNetParams)
service := walletunlocker.New(testDir, testNetParams)
// Now that the service has been created, we'll ask it to generate a
// new seed for us given a test passphrase.
@@ -108,7 +108,7 @@ func TestGenSeedGenerateEntropy(t *testing.T) {
defer func() {
os.RemoveAll(testDir)
}()
service := walletunlocker.New(nil, testDir, testNetParams)
service := walletunlocker.New(testDir, testNetParams)
// Now that the service has been created, we'll ask it to generate a
// new seed for us given a test passphrase. Note that we don't actually
@@ -148,7 +148,7 @@ func TestGenSeedInvalidEntropy(t *testing.T) {
defer func() {
os.RemoveAll(testDir)
}()
service := walletunlocker.New(nil, testDir, testNetParams)
service := walletunlocker.New(testDir, testNetParams)
// Now that the service has been created, we'll ask it to generate a
// new seed for us given a test passphrase. However, we'll be using an
@@ -186,7 +186,7 @@ func TestInitWallet(t *testing.T) {
}()
// Create new UnlockerService.
service := walletunlocker.New(nil, testDir, testNetParams)
service := walletunlocker.New(testDir, testNetParams)
// Once we have the unlocker service created, we'll now instantiate a
// new cipher seed instance.
@@ -287,7 +287,7 @@ func TestCreateWalletInvalidEntropy(t *testing.T) {
}()
// Create new UnlockerService.
service := walletunlocker.New(nil, testDir, testNetParams)
service := walletunlocker.New(testDir, testNetParams)
// We'll attempt to init the wallet with an invalid cipher seed and
// passphrase.
@@ -320,7 +320,7 @@ func TestUnlockWallet(t *testing.T) {
}()
// Create new UnlockerService.
service := walletunlocker.New(nil, testDir, testNetParams)
service := walletunlocker.New(testDir, testNetParams)
ctx := context.Background()
req := &lnrpc.UnlockWalletRequest{