Exemplo n.º 1
0
func main() {
	registerFlags()
	flag.Parse()

	coin.SetAddressVersion(addressVersion)

	v, gb, err := createGenesisVisor(masterKeys, bcFile, bsFile)
	handleError(err)
	if destAddress != "" {
		addr, err := coin.DecodeBase58Address(destAddress)
		handleError(err)
		_, err = transferAllToAddress(v, gb, addr)
		handleError(err)
		fmt.Printf("Transferred genesis balance to %s\n", destAddress)
	}

	err = v.SaveBlockchain()
	handleError(err)
	fmt.Printf("Saved blockchain to %s\n", bcFile)
	err = v.SaveBlockSigs()
	handleError(err)
	fmt.Printf("Saved blockchain signatures to %s\n", bsFile)

	if showHelp {
		fmt.Println("To get the timestamp:")
		fmt.Printf("\tgo run cmd/blockchain/blockchain.go -i %s -timestamp=true\n",
			bcFile)
		fmt.Println("To get the genesis block signature:")
		fmt.Printf("\tgo run cmd/blocksigs/blocksigs.go -i %s\n", bsFile)
	}
}
Exemplo n.º 2
0
func setupMasterVisor() VisorConfig {
	cleanupVisor()
	coin.SetAddressVersion("test")
	c := NewVisorConfig()
	c.Config.IsMaster = true
	c.Config.MasterKeys = visor.NewWalletEntry()
	return c
}
Exemplo n.º 3
0
func setupMasterVisorConfig() VisorConfig {
	// Create testmaster.keys file
	coin.SetAddressVersion("test")
	c := NewVisorConfig()
	c.CoinHourBurnFactor = 0
	c.IsMaster = true
	c.MasterKeys = NewWalletEntry()
	return c
}
Exemplo n.º 4
0
func setupMasterVisor() VisorConfig {
	cleanupVisor()
	coin.SetAddressVersion("test")
	c := NewVisorConfig()
	c.Config.IsMaster = true
	mw := wallet.NewWalletEntry()
	c.Config.MasterKeys = mw
	c.Config.GenesisSignature = createGenesisSignature(mw)
	return c
}
Exemplo n.º 5
0
func setupMasterVisorConfig() VisorConfig {
	// Create testmaster.keys file
	coin.SetAddressVersion("test")
	c := NewVisorConfig()
	c.CoinHourBurnFactor = 0
	c.IsMaster = true
	mw := NewWalletEntry()
	c.MasterKeys = mw
	c.GenesisSignature = createGenesisSignature(mw)
	return c
}
Exemplo n.º 6
0
func createWallet(filename string, addressVersion string,
	populateTo int) *visor.ReadableWallet {
	coin.SetAddressVersion(addressVersion)
	w := visor.NewSimpleWallet()
	w.Populate(populateTo)
	rw := visor.NewReadableWallet(w)
	err := rw.SaveSafe(filename)
	if err != nil {
		fmt.Fprintf(os.Stderr, "Failed to write wallet to \"%s\"\n",
			filename)
		fmt.Fprintf(os.Stderr, "%v\n", err)
		return nil
	}
	return rw
}
Exemplo n.º 7
0
func main() {
	registerFlags()
	parseFlags()

	coin.SetAddressVersion(addressVersion)

	if outFile != "" {
		w, err := createWalletEntry(outFile)
		handleError(err)
		printWalletEntry(w, labelStdout, printAddress, printPublic,
			printSecret)
	}
	if inFile != "" {
		err := printWalletEntryFromFile(inFile, labelStdout, printAddress,
			printPublic, printSecret)
		handleError(err)
	}
}
Exemplo n.º 8
0
// Returns an appropriate VisorConfig and a master visor
func setupVisor() (VisorConfig, *visor.Visor) {
	coin.SetAddressVersion("test")

	// Make a new master visor + blockchain
	// Get the signed genesis block,
	mw := visor.NewWalletEntry()
	mvc := visor.NewVisorConfig()
	mvc.IsMaster = true
	mvc.MasterKeys = mw
	mvc.CoinHourBurnFactor = 0
	mv := visor.NewVisor(mvc)
	sb := mv.GetGenesisBlock()

	// Use the master values for a client configuration
	c := NewVisorConfig()
	c.Config.IsMaster = false
	c.Config.MasterKeys = mw
	c.Config.MasterKeys.Secret = coin.SecKey{}
	c.Config.GenesisTimestamp = sb.Block.Head.Time
	c.Config.GenesisSignature = sb.Sig
	return c, mv
}
Exemplo n.º 9
0
func configureDaemon(c *cli.Config) daemon.Config {
	coin.SetAddressVersion(c.AddressVersion)
	dc := daemon.NewConfig()
	dc.Peers.DataDirectory = c.DataDirectory
	dc.DHT.Disabled = c.DisableDHT
	dc.Peers.Disabled = c.DisablePEX
	dc.Daemon.DisableOutgoingConnections = c.DisableOutgoingConnections
	dc.Daemon.DisableIncomingConnections = c.DisableIncomingConnections
	dc.Daemon.DisableNetworking = c.DisableNetworking
	dc.Daemon.Port = c.Port
	dc.Daemon.Address = c.Address
	dc.Daemon.LocalhostOnly = c.LocalhostOnly
	if c.OutgoingConnectionsRate == 0 {
		c.OutgoingConnectionsRate = time.Millisecond
	}
	dc.Daemon.OutgoingRate = c.OutgoingConnectionsRate
	dc.Visor.Config.IsMaster = c.MasterChain
	dc.Visor.Config.CanSpend = c.CanSpend
	dc.Visor.Config.WalletFile = c.WalletFile
	dc.Visor.Config.WalletSizeMin = c.WalletSizeMin
	dc.Visor.Config.BlockchainFile = c.BlockchainFile
	dc.Visor.Config.BlockSigsFile = c.BlockSigsFile
	dc.Visor.Config.GenesisSignature = coin.MustSigFromHex(c.GenesisSignature)
	dc.Visor.Config.GenesisTimestamp = c.GenesisTimestamp
	if c.MasterChain {
		// The master chain should be reluctant to expire transactions
		dc.Visor.Config.UnconfirmedRefreshRate = time.Hour * 4096
	}

	dc.Visor.MasterKeysFile = c.MasterKeys
	if c.MasterChain {
		// Will panic if fails
		dc.Visor.LoadMasterKeys()
	} else {
		w := visor.ReadableWalletEntryFromPubkey(c.MasterPublic)
		dc.Visor.Config.MasterKeys = visor.WalletEntryFromReadable(&w)
	}
	return dc
}
Exemplo n.º 10
0
// Returns an appropriate VisorConfig and a master visor
func setupVisorConfig() (VisorConfig, *Visor) {
	coin.SetAddressVersion("test")

	// Make a new master visor + blockchain
	// Get the signed genesis block,
	mw := NewWalletEntry()
	mvc := NewVisorConfig()
	mvc.CoinHourBurnFactor = 0
	mvc.IsMaster = true
	mvc.MasterKeys = mw
	mvc.GenesisSignature = createGenesisSignature(mw)
	mv := NewVisor(mvc)

	// Use the master values for a client configuration
	c := NewVisorConfig()
	c.IsMaster = false
	c.GenesisSignature = mvc.GenesisSignature
	c.GenesisTimestamp = mvc.GenesisTimestamp
	c.MasterKeys = mw
	c.MasterKeys.Secret = coin.SecKey{}
	return c, mv
}