lnwallet: allow configurable net param for wallet create/open

This commit is contained in:
Olaoluwa Osuntokun 2016-02-02 23:42:19 -08:00
parent 98bbd314a7
commit 74ee5334f4
2 changed files with 6 additions and 6 deletions

@ -89,7 +89,7 @@ func checkCreateDir(path string) error {
// provided path.
// TODO(roasbeef): maybe pass in config after all for testing purposes?
func createWallet(privPass, pubPass, userSeed []byte,
dbPath string) error {
dbPath string, activeNet *chaincfg.Params) error {
// TODO(roasbeef): replace with tadge's seed format?
hdSeed := userSeed
var seedErr error
@ -115,7 +115,7 @@ func createWallet(privPass, pubPass, userSeed []byte,
return err
}
manager, err := waddrmgr.Create(namespace, hdSeed, []byte(pubPass),
[]byte(privPass), ActiveNetParams, nil)
[]byte(privPass), activeNet, nil)
if err != nil {
return err
}
@ -199,7 +199,7 @@ func promptPrivPassPhrase() ([]byte, error) {
// openWallet returns a wallet. The function handles opening an existing wallet
// database, the address manager and the transaction store and uses the values
// 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)
if err != nil {
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,
ObtainPrivatePass: promptPrivPassPhrase,
}
w, err := wallet.Open(pubPass, ActiveNetParams, db, addrMgrNS, txMgrNS,
w, err := wallet.Open(pubPass, activeNet, db, addrMgrNS, txMgrNS,
cbs)
return w, db, err
}

@ -270,7 +270,7 @@ func NewLightningWallet(config *Config) (*LightningWallet, walletdb.DB, error) {
// Attempt to create a new wallet
if err := createWallet(config.PrivatePass, pubPass,
config.HdSeed, dbPath); err != nil {
config.HdSeed, dbPath, config.NetParams); err != nil {
fmt.Fprintln(os.Stderr, 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
// 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 {
return nil, nil, err
}