Example #1
0
func NewECAddressString(n uint64) string {
	pub := NewECAddressPublicKeyString(n)
	ecAddress, err := factoid.PublicKeyStringToECAddressString(pub)
	if err != nil {
		panic(err)
	}
	return ecAddress
}
Example #2
0
func InitializeBalance() {
	var once sync.Once
	onceBody := func() {
		w, err := wallet.NewMapDBWallet()
		if err != nil {
			panic(err)
		}

		fa, err := factom.GetFactoidAddress(FaucetAddressPriv)
		err = w.InsertFCTAddress(fa)
		if err != nil {
			panic(err)
		}

		priv, _, _ := testHelper.NewFactoidAddressStrings(Seed)

		FKey, err = primitives.NewPrivateKeyFromHex(priv)
		if err != nil {
			panic(err)
		}
		ECKey, err = primitives.NewPrivateKeyFromHex(priv)
		if err != nil {
			panic(err)
		}

		FAddressStr, err = factoid.PublicKeyStringToFactoidAddressString(FKey.PublicKeyString())
		if err != nil {
			panic(err)
		}

		ECAddressStr, err = factoid.PublicKeyStringToECAddressString(ECKey.PublicKeyString())
		if err != nil {
			panic(err)
		}

		ECAddress, err = factom.MakeECAddress(ECKey.Key[:32])
		if err != nil {
			panic(err)
		}

		go wsapi.Start(w, fmt.Sprintf(":%d", 8089))
		defer func() {
			time.Sleep(10 * time.Millisecond)
			wsapi.Stop()
		}()

		TopupFAddress()
		TopupECAddress()
	}
	once.Do(onceBody)
}