forked from planetdecred/dcrlibwallet
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- rebase with planetdecred#257(dcr package PR), restructure multiwall…
…et to hold mutiple assets, fix crash while creating a wallet
- Loading branch information
Showing
15 changed files
with
1,925 additions
and
427 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package dcrlibwallet | ||
|
||
import ( | ||
// "context" | ||
// "fmt" | ||
"os" | ||
"path/filepath" | ||
|
||
"decred.org/dcrwallet/v2/errors" | ||
|
||
"github.com/asdine/storm" | ||
// "github.com/asdine/storm/q" | ||
|
||
bolt "go.etcd.io/bbolt" | ||
|
||
"github.com/planetdecred/dcrlibwallet/wallets/btc" | ||
) | ||
|
||
func initializeBTCWallet(rootDir, dbDriver, netType string) (*storm.DB, string, error) { | ||
var btcDB *storm.DB | ||
|
||
rootDir = filepath.Join(rootDir, netType, "btc") | ||
err := os.MkdirAll(rootDir, os.ModePerm) | ||
if err != nil { | ||
return btcDB, "", errors.Errorf("failed to create btc rootDir: %v", err) | ||
} | ||
|
||
err = initLogRotator(filepath.Join(rootDir, logFileName)) | ||
if err != nil { | ||
return btcDB, "", errors.Errorf("failed to init btc logRotator: %v", err.Error()) | ||
} | ||
|
||
btcDB, err = storm.Open(filepath.Join(rootDir, walletsDbName)) | ||
if err != nil { | ||
log.Errorf("Error opening btc wallets database: %s", err.Error()) | ||
if err == bolt.ErrTimeout { | ||
// timeout error occurs if storm fails to acquire a lock on the database file | ||
return btcDB, "", errors.E(ErrWalletDatabaseInUse) | ||
} | ||
return btcDB, "", errors.Errorf("error opening btc wallets database: %s", err.Error()) | ||
} | ||
|
||
// init database for saving/reading wallet objects | ||
err = btcDB.Init(&btc.Wallet{}) | ||
if err != nil { | ||
log.Errorf("Error initializing btc wallets database: %s", err.Error()) | ||
return btcDB, "", err | ||
} | ||
|
||
return btcDB, rootDir, nil | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.