Skip to content

Commit

Permalink
Wallet name (#46)
Browse files Browse the repository at this point in the history
Add an option to use a readable wallet name for the distributed split
product, instead of a random UUID
  • Loading branch information
selfuryon authored Sep 13, 2023
2 parents 953f9ce + 149396e commit 3011c5b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ distributed-wallets: #Distributed-wallets section
path: ./wallet #Path to distributed wallet (Default: None)
passphrases: ./passphrases.txt #Path to file containing passphrases for unlocking/locking accounts (Default: None)
threshold: 2 #Threshlod value (Default: None)
walletname: myDKWallet
peers: #Peers dict, number of peers must be greater than threshold value (Default: None)
10: old1:9091
20: old2:9091
Expand Down
5 changes: 5 additions & 0 deletions cmd/split/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ type SplitRuntime struct {
threshold uint32
walletsMap map[uint64]utils.DWallet
peersIDs []uint64
walletName string
}

type AccountExtends struct {
Expand Down Expand Up @@ -64,6 +65,7 @@ func newSplitRuntime() (*SplitRuntime, error) {
sr.dWalletsPath = dWalletConfig.Path
sr.ndWalletsPath = ndWalletConfig.Path
sr.threshold = dWalletConfig.Threshold
sr.walletName = dWalletConfig.WalletName
utils.LogSplit.Debug().Msgf("getting input passwords from %s", ndWalletConfig.Passphrases)
sr.passphrasesIn, err = utils.GetAccountsPasswords(ndWalletConfig.Passphrases)
if err != nil {
Expand Down Expand Up @@ -96,6 +98,9 @@ func (sr *SplitRuntime) validate() error {

func (sr *SplitRuntime) createWallets() error {
walletName := uuid.New().String()
if sr.walletName != "" {
walletName = sr.walletName
}
for id, peer := range sr.peers {
res, err := regexp.Compile(`:.*`)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions utils/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type DWalletConfig struct {
Passphrases string
Peers Peers
Threshold uint32
WalletName string
}

func GetAccountsPasswords(path string) ([][]byte, error) {
Expand Down

0 comments on commit 3011c5b

Please sign in to comment.