Example #1
0
func main() {

	var quit1 chan int

	//create the daemon
	config := daemon.NewConfig()
	//config.Daemon.LocalhostOnly = true
	//config.DHT.Disabled = true
	config.Daemon.Port = 8080
	daemon := daemon.NewDaemon(config)

	//create aether server

	pubkey, seckey := cipher.GenerateDeterministicKeyPair([]byte("seed"))
	_ = seckey
	_ = pubkey

	a := aether.NewAetherServer(pubkey)

	a.RegisterWithDaemon(daemon)

	//start daemon mainloop
	go daemon.Start(quit1)

}
Example #2
0
func NewDeterministicWallet() Wallet {
	seed := NewDeterministicWalletSeed()
	pub, sec := cipher.GenerateDeterministicKeyPair(seed[:])
	return &DeterministicWallet{
		Filename: NewWalletFilename(seed.toWalletID()),
		Seed:     seed,
		Entry:    NewWalletEntryFromKeypair(pub, sec),
	}
}
Example #3
0
//Generate Deterministic Wallet
//generates a random seed if seed is ""
func NewWallet(seed string) Wallet {

	//if seed is blank, generate a new seed
	if seed == "" {
		seed_raw := cipher.SumSHA256(secp256k1.RandByte(64))
		seed = hex.EncodeToString(seed_raw[:])
	}

	pub, sec := cipher.GenerateDeterministicKeyPair([]byte(seed[:]))
	return Wallet{
		Meta: map[string]string{
			"filename": NewWalletFilename(),
			"seed":     seed,
			"type":     "deterministic",
			"coin":     "sky"},
		Entry: NewWalletEntryFromKeypair(pub, sec),
	}
}
Example #4
0
//creates chain and hosts
func runChain() {

	_, seckey := cipher.GenerateDeterministicKeyPair([]byte("seed"))
	bc := hashchain.NewBlockChain(seckey)

	for i := 0; i < 256; i++ {

		//write this data to the block
		s := fmt.Sprintf("test data: %v", i)

		block := bc.NewBlock(seckey, uint64(time.Now().Unix()), []byte(s))

		err := bc.ApplyBlock(block)
		if err != nil {
			log.Panic(err)
		}

		//do something with the data, if block is valid
	}

	_ = bc
}