示例#1
0
func CheckFactomBalance() (int64, int64, error) {
	ecBalance, err := factom.GetECBalance(ECAddressStr)
	if err != nil {
		return 0, 0, err
	}

	fBalance, err := factom.GetFactoidBalance(FAddressStr)
	if err != nil {
		return 0, 0, err
	}
	return fBalance, ecBalance, nil
}
示例#2
0
func main() {

	var (
		sflag = flag.String("s", "localhost:8088", "address of api server")
		wflag = flag.String("w", "localhost:8089", "address of wallet api server")
	)
	flag.Parse()
	//args := flag.Args()

	factom.SetFactomdServer(*sflag)
	factom.SetWalletServer(*wflag)

	fmt.Println("Using factomd at", *sflag)
	fmt.Println("Using factom-walletd at", *wflag)

	e := new(factom.Entry)

	ecAddr, _ := factom.GetECAddress("Es2Rf7iM6PdsqfYCo3D1tnAR65SkLENyWJG1deUzpRMQmbh9F3eG")
	bal, err := factom.GetECBalance(ecAddr.String())
	if err != nil {
		fmt.Println(err)
		return
	}

	fmt.Println("address", ecAddr, "has a balance of", bal)

	e.ExtIDs = append(e.ExtIDs, []byte("id"))
	e.Content = []byte("payload")

	c := factom.NewChain(e)

	txID, err := factom.CommitChain(c, ecAddr)
	if err != nil {
		fmt.Println(err)
		return
	}

	fmt.Println("commiting txid:", txID)

	hash, err := factom.RevealChain(c)
	if err != nil {
		fmt.Println(err)
		return
	}
	fmt.Println("revealed entry:", hash)

	i := 0
	for {
		e.Content = []byte(strconv.Itoa(i))

		//c.ChainID

		txID, err := factom.CommitEntry(e, ecAddr)
		if err != nil {
			fmt.Println(err)
			return
		}

		fmt.Println("commiting txid:", txID)

		hash, err := factom.RevealEntry(e)
		if err != nil {
			fmt.Println(err)
			return
		}
		fmt.Println("revealed entry:", hash)
		time.Sleep(2 * time.Millisecond)
		i++
	}

}
示例#3
0
		}

		c := factom.NewChain(e)

		if factom.ChainExists(c.ChainID) {
			errorln("Chain", c.ChainID, "already exists")
			return
		}

		// get the ec address from the wallet
		ec, err := factom.FetchECAddress(ecpub)
		if err != nil {
			errorln(err)
			return
		}
		balance, err := factom.GetECBalance(ecpub)
		if err != nil {
			errorln(err)
			return
		}
		if balance == 0 {
			errorln("Entry Credit balance is zero")
			return
		}
		// commit the chain
		txID, err := factom.CommitChain(c, ec)
		if err != nil {
			errorln(err)
			return
		}
		fmt.Println("Commiting Chain Transaction ID:", txID)
示例#4
0
			fmt.Println(cmd.helpMsg)
			return
		}
		addr := args[0]

		switch factom.AddressStringType(addr) {
		case factom.FactoidPub:
			b, err := factom.GetFactoidBalance(addr)
			if err != nil {
				errorln(err)
			} else {
				fmt.Println(factoshiToFactoid(b))
			}
			return
		case factom.ECPub:
			c, err := factom.GetECBalance(addr)
			if err != nil {
				errorln(err)
			} else {
				fmt.Println(c)
			}
			return
		}

		// if -r flag is present, resolve dns address then get the fct and ec
		// blance
		if *res {
			f, e, err := factom.GetDnsBalance(addr)
			if err != nil {
				fmt.Println(err)
				return