From 844cdba5130dbbc201d06dba7c3a4363aff3f053 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Sun, 23 Apr 2017 19:17:54 -0700 Subject: [PATCH] lnwallet/btcwallet: unlock wallet during startup, not creation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit modifies the way we go about unlocking the wallet. With the latest changes to the API of btcwallet, we can on longer directly access the waddrmgr struct. As a result, we’re now forced to go _directly_ via the wallet to unlock the waddrmgr. The root LightingWallet has been modified to not request the root key until we finish starting the underlying wallet, so we can unlock the wallet in the Start() method. --- lnwallet/btcwallet/btcwallet.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lnwallet/btcwallet/btcwallet.go b/lnwallet/btcwallet/btcwallet.go index 71dabd9d1..197c6f884 100644 --- a/lnwallet/btcwallet/btcwallet.go +++ b/lnwallet/btcwallet/btcwallet.go @@ -94,10 +94,6 @@ func New(cfg *Config) (*BtcWallet, error) { } } - if err := wallet.Manager.Unlock(cfg.PrivatePass); err != nil { - return nil, err - } - // Create a special websockets rpc client for btcd which will be used // by the wallet for notifications, calls, etc. rpcc, err := chain.NewRPCClient(cfg.NetParams, cfg.RPCHost, @@ -139,6 +135,10 @@ func (b *BtcWallet) Start() error { // current main chain. b.wallet.SynchronizeRPC(b.rpc) + if err := b.wallet.Unlock(b.cfg.PrivatePass, nil); err != nil { + return err + } + return nil }