Skip to content

Commit

Permalink
Use random password when using separate wallet
Browse files Browse the repository at this point in the history
  • Loading branch information
meyer9 committed Jan 30, 2018
1 parent 8c08e5a commit 89cd10f
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion bitcoin/phored/wallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"encoding/json"
"errors"
"fmt"
"math/rand"
"os"
"os/exec"
"path"
Expand Down Expand Up @@ -64,13 +65,27 @@ var connCfg = &rpcclient.ConnConfig{
DisableConnectOnNew: false,
}

var letters = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789")

func randSeq(n int) string {
b := make([]rune, n)
for i := range b {
b[i] = letters[rand.Intn(len(letters))]
}
return string(b)
}

func NewBitcoindWallet(mnemonic string, params *chaincfg.Params, repoPath string, trustedPeer string, binary string, username string, password string, useTor bool, torControlPort int, separateWallet bool) *BitcoindWallet {
seed := b39.NewSeed(mnemonic, "")
mPrivKey, _ := hd.NewMaster(seed, params)
mPubKey, _ := mPrivKey.Neuter()

connCfg.User = username
connCfg.Pass = password
if separateWallet {
connCfg.Pass = randSeq(20) // generate a random sequence for client-only daemon
} else {
connCfg.Pass = password
}

if trustedPeer != "" {
trustedPeer = strings.Split(trustedPeer, ":")[0]
Expand Down

0 comments on commit 89cd10f

Please sign in to comment.