Fix wallet file name
This commit is contained in:
parent
4acc3ae271
commit
130cf66a90
|
@ -5,7 +5,7 @@ import "fmt"
|
|||
func (cli *CLI) createWallet(nodeID string) {
|
||||
wallets, _ := NewWallets(nodeID)
|
||||
address := wallets.CreateWallet()
|
||||
wallets.SaveToFile()
|
||||
wallets.SaveToFile(nodeID)
|
||||
|
||||
fmt.Printf("Your new address: %s\n", address)
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ func NewWallets(nodeID string) (*Wallets, error) {
|
|||
wallets := Wallets{}
|
||||
wallets.Wallets = make(map[string]*Wallet)
|
||||
|
||||
err := wallets.LoadFromFile()
|
||||
err := wallets.LoadFromFile(nodeID)
|
||||
|
||||
return &wallets, err
|
||||
}
|
||||
|
@ -54,7 +54,8 @@ func (ws Wallets) GetWallet(address string) Wallet {
|
|||
}
|
||||
|
||||
// LoadFromFile loads wallets from the file
|
||||
func (ws *Wallets) LoadFromFile() error {
|
||||
func (ws *Wallets) LoadFromFile(nodeID string) error {
|
||||
walletFile := fmt.Sprintf(walletFile, nodeID)
|
||||
if _, err := os.Stat(walletFile); os.IsNotExist(err) {
|
||||
return err
|
||||
}
|
||||
|
@ -78,8 +79,9 @@ func (ws *Wallets) LoadFromFile() error {
|
|||
}
|
||||
|
||||
// SaveToFile saves wallets to a file
|
||||
func (ws Wallets) SaveToFile() {
|
||||
func (ws Wallets) SaveToFile(nodeID string) {
|
||||
var content bytes.Buffer
|
||||
walletFile := fmt.Sprintf(walletFile, nodeID)
|
||||
|
||||
gob.Register(elliptic.P256())
|
||||
|
||||
|
|
Loading…
Reference in New Issue