From 0d7763fb96a53541fa39e4879bb39f9a2350a33d Mon Sep 17 00:00:00 2001 From: "Johan T. Halseth" Date: Tue, 9 Feb 2021 14:57:33 +0100 Subject: [PATCH] walletunlocker: expose WalletExists --- walletunlocker/service.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/walletunlocker/service.go b/walletunlocker/service.go index 9855f22a..0c3c0b3d 100644 --- a/walletunlocker/service.go +++ b/walletunlocker/service.go @@ -160,6 +160,17 @@ func New(chainDir string, params *chaincfg.Params, noFreelistSync bool, } } +// WalletExists returns whether a wallet exists on the file path the +// UnlockerService is using. +func (u *UnlockerService) WalletExists() (bool, error) { + netDir := btcwallet.NetworkDir(u.chainDir, u.netParams) + loader := wallet.NewLoader( + u.netParams, netDir, u.noFreelistSync, u.dbTimeout, 0, + ) + + return loader.WalletExists() +} + // GenSeed is the first method that should be used to instantiate a new lnd // instance. This method allows a caller to generate a new aezeed cipher seed // given an optional passphrase. If provided, the passphrase will be necessary