コード例 #1
0
ファイル: wallet.go プロジェクト: keepwalking1234/skycoin
func NewWalletRPC() *WalletRPC {
	rpc := WalletRPC{}

	//wallet directory
	//cleanup, pass as parameter during init

	DataDirectory := util.InitDataDir("")
	rpc.WalletDirectory = filepath.Join(DataDirectory, "wallets/")
	logger.Debug("Wallet Directory= %v", rpc.WalletDirectory)
	util.InitDataDir(rpc.WalletDirectory)

	rpc.Wallets = wallet.Wallets{}

	//util.InitDataDir(".skycoin")
	//util.InitDataDir(".skycoin/wallets")

	//if rpc.WalletDirectory != "" {
	w, err := wallet.LoadWallets(rpc.WalletDirectory)
	if err != nil {
		log.Panicf("Failed to load all wallets: %v", err)
	}
	rpc.Wallets = w
	//}
	if len(rpc.Wallets) == 0 {
		rpc.Wallets.Add(wallet.NewWallet("")) //deterministic
		if rpc.WalletDirectory != "" {
			errs := rpc.Wallets.Save(rpc.WalletDirectory)
			if len(errs) != 0 {
				log.Panicf("Failed to save wallets: %v", errs)
			}
		}
	}

	return &rpc
}
コード例 #2
0
ファイル: cli.go プロジェクト: RagnarDanneskjold/skycoin
func (self *Config) postProcess() {
	self.DataDirectory = util.InitDataDir(self.DataDirectory)
	if self.WebInterfaceCert == "" {
		self.WebInterfaceCert = filepath.Join(self.DataDirectory, "cert.pem")
	}
	if self.WebInterfaceKey == "" {
		self.WebInterfaceKey = filepath.Join(self.DataDirectory, "key.pem")
	}
	if self.MasterKeys == "" {
		self.MasterKeys = filepath.Join(self.DataDirectory, "master.keys")
	}
	if self.WalletFile == "" {
		self.WalletFile = filepath.Join(self.DataDirectory, "wallet.json")
	}
	if self.BlockchainFile == "" {
		self.BlockchainFile = filepath.Join(self.DataDirectory, "blockchain.bin")
	}
	if self.BlockSigsFile == "" {
		self.BlockSigsFile = filepath.Join(self.DataDirectory, "blockchain.sigs")
	}
	ll, err := logging.LogLevel(self.logLevel)
	if err != nil {
		log.Panic("Invalid -log-level %s: %v\n", self.logLevel, err)
	}
	self.LogLevel = ll
}
コード例 #3
0
ファイル: skycoin.go プロジェクト: keepwalking1234/skycoin
func (self *Config) postProcess() {

	//var GenesisSignatureStr string //only set if passed in command line arg
	//var GenesisAddressStr string   //only set if passed in command line arg
	//var BlockchainPubkeyStr string //only set if passed in command line arg
	//var BlockchainSeckeyStr string //only set if passed in command line arg

	var err error
	if GenesisSignatureStr != "" {
		self.GenesisSignature, err = cipher.SigFromHex(GenesisSignatureStr)
		if err != nil {
			log.Panic("Invalid Signature")
		}
	}
	if GenesisAddressStr != "" {
		self.GenesisAddress, err = cipher.DecodeBase58Address(GenesisAddressStr)
		if err != nil {
			log.Panic("Invalid Address")
		}
	}
	if BlockchainPubkeyStr != "" {
		self.BlockchainPubkey, err = cipher.PubKeyFromHex(BlockchainPubkeyStr)
		if err != nil {
			log.Panic("Invalid Pubkey")
		}
	}
	if BlockchainSeckeyStr != "" {
		self.BlockchainSeckey, err = cipher.SecKeyFromHex(BlockchainSeckeyStr)
		if err != nil {
			log.Panic("Invalid Seckey")
		}
		BlockchainSeckeyStr = ""
	}
	if BlockchainSeckeyStr != "" {
		self.BlockchainSeckey = cipher.SecKey{}
	}

	self.DataDirectory = util.InitDataDir(self.DataDirectory)
	if self.WebInterfaceCert == "" {
		self.WebInterfaceCert = filepath.Join(self.DataDirectory, "cert.pem")
	}
	if self.WebInterfaceKey == "" {
		self.WebInterfaceKey = filepath.Join(self.DataDirectory, "key.pem")
	}

	if self.BlockchainFile == "" {
		self.BlockchainFile = filepath.Join(self.DataDirectory, "blockchain.bin")
	}
	if self.BlockSigsFile == "" {
		self.BlockSigsFile = filepath.Join(self.DataDirectory, "blockchain.sigs")
	}
	if self.WalletDirectory == "" {
		self.WalletDirectory = filepath.Join(self.DataDirectory, "wallets/")
	}
	ll, err := logging.LogLevel(self.logLevel)
	if err != nil {
		log.Panic("Invalid -log-level %s: %v\n", self.logLevel, err)
	}
	self.LogLevel = ll
}
コード例 #4
0
ファイル: skycoin.go プロジェクト: Chao-Jia/skycoin
func (c *Config) postProcess() {
	var err error
	if GenesisSignatureStr != "" {
		c.GenesisSignature, err = cipher.SigFromHex(GenesisSignatureStr)
		panicIfError(err, "Invalid Signature")
	}
	if GenesisAddressStr != "" {
		c.GenesisAddress, err = cipher.DecodeBase58Address(GenesisAddressStr)
		panicIfError(err, "Invalid Address")
	}
	if BlockchainPubkeyStr != "" {
		c.BlockchainPubkey, err = cipher.PubKeyFromHex(BlockchainPubkeyStr)
		panicIfError(err, "Invalid Pubkey")
	}
	if BlockchainSeckeyStr != "" {
		c.BlockchainSeckey, err = cipher.SecKeyFromHex(BlockchainSeckeyStr)
		panicIfError(err, "Invalid Seckey")
		BlockchainSeckeyStr = ""
	}
	if BlockchainSeckeyStr != "" {
		c.BlockchainSeckey = cipher.SecKey{}
	}

	c.DataDirectory = util.InitDataDir(c.DataDirectory)
	if c.WebInterfaceCert == "" {
		c.WebInterfaceCert = filepath.Join(c.DataDirectory, "cert.pem")
	}
	if c.WebInterfaceKey == "" {
		c.WebInterfaceKey = filepath.Join(c.DataDirectory, "key.pem")
	}

	if c.BlockchainFile == "" {
		c.BlockchainFile = filepath.Join(c.DataDirectory, "blockchain.bin")
	}
	if c.BlockSigsFile == "" {
		c.BlockSigsFile = filepath.Join(c.DataDirectory, "blockchain.sigs")
	}
	if c.WalletDirectory == "" {
		c.WalletDirectory = filepath.Join(c.DataDirectory, "wallets/")
	}

	ll, err := logging.LogLevel(c.logLevel)
	panicIfError(err, "Invalid -log-level %s", c.logLevel)
	c.LogLevel = ll
}
コード例 #5
0
ファイル: mesh.go プロジェクト: skycoin/skycoin
func (c *Config) Parse() {
	// obtain values from flags
	c.fromFlags()
	// post process
	c.DataDirectory = util.InitDataDir(c.DataDirectory)
	// if HTTPS is turned off then cerk/key are never used
	if c.WebInterface.HTTPS == true {
		if c.WebInterface.Cert == "" {
			c.WebInterface.Cert = filepath.Join(c.DataDirectory, "cert.pem")
		}
		if c.WebInterface.Key == "" {
			c.WebInterface.Key = filepath.Join(c.DataDirectory, "key.pem")
		}
	}

	// initialize logger
	c.Log.InitLogger()
}