mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-07-02 19:44:03 +02:00
lnwallet: have wallet return db so it can be closed during shutdown
* Also remove some extra print statements from debugging * Separate out logic to create wallet from creating an ID
This commit is contained in:
@ -22,7 +22,6 @@ import (
|
||||
"bytes"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
@ -121,12 +120,10 @@ func createWallet(privPass, pubPass, userSeed []byte,
|
||||
return err
|
||||
}
|
||||
|
||||
err = manager.Close()
|
||||
if err != nil {
|
||||
if err := manager.Close(); err != nil {
|
||||
return err
|
||||
}
|
||||
err = db.Close()
|
||||
if err != nil {
|
||||
if err := db.Close(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@ -143,14 +140,12 @@ func openDb(directory string, dbname string) (walletdb.DB, error) {
|
||||
if err := checkCreateDir(directory); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
log.Printf("checkCreateDir(directory) returned\n")
|
||||
log.Printf("freezes here?\n")
|
||||
|
||||
// Open the database using the boltdb backend.
|
||||
wdb, err := walletdb.Open("bdb", dbPath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
log.Printf("walletdb.Open() returned\n")
|
||||
return wdb, nil
|
||||
}
|
||||
|
||||
@ -209,17 +204,14 @@ func openWallet(pubPass []byte, dbDir string) (*wallet.Wallet, walletdb.DB, erro
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("Failed to open database: %v", err)
|
||||
}
|
||||
log.Printf("openDb returned\n")
|
||||
addrMgrNS, err := db.Namespace(waddrmgrNamespaceKey)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
log.Printf("db.Namespace(waddrmgrNamespaceKey) returned\n")
|
||||
txMgrNS, err := db.Namespace(wtxmgrNamespaceKey)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
log.Printf("db.Namespace(wtxmgrNamespaceKey) returned\n")
|
||||
// TODO(roasbeef): pass these in as funcs instead, priv pass already
|
||||
// loaded into memory, use tadge's format to read HD seed.
|
||||
cbs := &waddrmgr.OpenCallbacks{
|
||||
@ -228,6 +220,5 @@ func openWallet(pubPass []byte, dbDir string) (*wallet.Wallet, walletdb.DB, erro
|
||||
}
|
||||
w, err := wallet.Open(pubPass, ActiveNetParams, db, addrMgrNS, txMgrNS,
|
||||
cbs)
|
||||
log.Printf("wallet.Open returned\n")
|
||||
return w, db, err
|
||||
}
|
||||
|
Reference in New Issue
Block a user