func (w *SCWallet) SetSeed(seed []byte) { w.NextSeed = seed w.RootSeed = seed b := new(database.ByteStore) b.SetBytes(w.RootSeed) w.db.PutRaw([]byte(fct.W_SEEDS), fct.CURRENT_SEED[:], b) w.db.PutRaw([]byte(fct.W_SEEDS), w.RootSeed[:32], b) w.db.PutRaw([]byte(fct.W_SEED_HEADS), w.RootSeed[:32], b) }
func (w *SCWallet) NewSeed(data []byte) { if len(data) == 0 { return } // No data, no change hasher := sha512.New() hasher.Write(data) seedhash := hasher.Sum(nil) w.NextSeed = seedhash w.RootSeed = seedhash b := new(database.ByteStore) b.SetBytes(w.RootSeed) w.db.PutRaw([]byte(fct.W_SEEDS), fct.CURRENT_SEED[:], b) w.db.PutRaw([]byte(fct.W_SEEDS), w.RootSeed[:32], b) w.db.PutRaw([]byte(fct.W_SEED_HEADS), w.RootSeed[:32], b) }
func (w *SCWallet) GetSeed() []byte { iroot := w.db.GetRaw([]byte(fct.W_SEEDS), fct.CURRENT_SEED[:]) if iroot == nil { randomstuff := make([]byte, 1024) rand.Read(randomstuff) w.NewSeed(randomstuff) } hasher := sha512.New() hasher.Write([]byte(w.NextSeed)) seedhash := hasher.Sum(nil) w.NextSeed = seedhash b := new(database.ByteStore) b.SetBytes(w.NextSeed) w.db.PutRaw([]byte(fct.W_SEED_HEADS), w.RootSeed[:32], b) return w.NextSeed }