lnwallet: allow configurable net param for wallet create/open
This commit is contained in:
parent
98bbd314a7
commit
74ee5334f4
@ -89,7 +89,7 @@ func checkCreateDir(path string) error {
|
|||||||
// provided path.
|
// provided path.
|
||||||
// TODO(roasbeef): maybe pass in config after all for testing purposes?
|
// TODO(roasbeef): maybe pass in config after all for testing purposes?
|
||||||
func createWallet(privPass, pubPass, userSeed []byte,
|
func createWallet(privPass, pubPass, userSeed []byte,
|
||||||
dbPath string) error {
|
dbPath string, activeNet *chaincfg.Params) error {
|
||||||
// TODO(roasbeef): replace with tadge's seed format?
|
// TODO(roasbeef): replace with tadge's seed format?
|
||||||
hdSeed := userSeed
|
hdSeed := userSeed
|
||||||
var seedErr error
|
var seedErr error
|
||||||
@ -115,7 +115,7 @@ func createWallet(privPass, pubPass, userSeed []byte,
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
manager, err := waddrmgr.Create(namespace, hdSeed, []byte(pubPass),
|
manager, err := waddrmgr.Create(namespace, hdSeed, []byte(pubPass),
|
||||||
[]byte(privPass), ActiveNetParams, nil)
|
[]byte(privPass), activeNet, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -199,7 +199,7 @@ func promptPrivPassPhrase() ([]byte, error) {
|
|||||||
// openWallet returns a wallet. The function handles opening an existing wallet
|
// openWallet returns a wallet. The function handles opening an existing wallet
|
||||||
// database, the address manager and the transaction store and uses the values
|
// database, the address manager and the transaction store and uses the values
|
||||||
// to open a wallet.Wallet
|
// to open a wallet.Wallet
|
||||||
func openWallet(pubPass []byte, dbDir string) (*wallet.Wallet, walletdb.DB, error) {
|
func openWallet(pubPass []byte, dbDir string, activeNet *chaincfg.Params) (*wallet.Wallet, walletdb.DB, error) {
|
||||||
db, err := openDb(dbDir, walletDbName)
|
db, err := openDb(dbDir, walletDbName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, fmt.Errorf("Failed to open database: %v", err)
|
return nil, nil, fmt.Errorf("Failed to open database: %v", err)
|
||||||
@ -218,7 +218,7 @@ func openWallet(pubPass []byte, dbDir string) (*wallet.Wallet, walletdb.DB, erro
|
|||||||
ObtainSeed: promptSeed,
|
ObtainSeed: promptSeed,
|
||||||
ObtainPrivatePass: promptPrivPassPhrase,
|
ObtainPrivatePass: promptPrivPassPhrase,
|
||||||
}
|
}
|
||||||
w, err := wallet.Open(pubPass, ActiveNetParams, db, addrMgrNS, txMgrNS,
|
w, err := wallet.Open(pubPass, activeNet, db, addrMgrNS, txMgrNS,
|
||||||
cbs)
|
cbs)
|
||||||
return w, db, err
|
return w, db, err
|
||||||
}
|
}
|
||||||
|
@ -270,7 +270,7 @@ func NewLightningWallet(config *Config) (*LightningWallet, walletdb.DB, error) {
|
|||||||
|
|
||||||
// Attempt to create a new wallet
|
// Attempt to create a new wallet
|
||||||
if err := createWallet(config.PrivatePass, pubPass,
|
if err := createWallet(config.PrivatePass, pubPass,
|
||||||
config.HdSeed, dbPath); err != nil {
|
config.HdSeed, dbPath, config.NetParams); err != nil {
|
||||||
fmt.Fprintln(os.Stderr, err)
|
fmt.Fprintln(os.Stderr, err)
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
@ -280,7 +280,7 @@ func NewLightningWallet(config *Config) (*LightningWallet, walletdb.DB, error) {
|
|||||||
|
|
||||||
// Wallet has been created and been initialized at this point, open it
|
// Wallet has been created and been initialized at this point, open it
|
||||||
// along with all the required DB namepsaces, and the DB itself.
|
// along with all the required DB namepsaces, and the DB itself.
|
||||||
wallet, db, err := openWallet(pubPass, netDir)
|
wallet, db, err := openWallet(pubPass, netDir, config.NetParams)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user