コード例 #1
0
ファイル: pointctl.go プロジェクト: evansuva/pointcoind
// toSatoshi attempts to convert the passed string to a satoshi amount returned
// as an int64.  It returns the int64 packed into an interface so it can be used
// in the calls which expect interfaces.  An error will be returned if the string
// can't be converted first to a float64.
func toSatoshi(val string) (interface{}, error) {
	idx, err := strconv.ParseFloat(val, 64)
	if err != nil {
		return nil, err
	}
	amt, err := btcutil.NewAmount(idx)
	if err != nil {
		return nil, err
	}
	return int64(amt), nil
}
コード例 #2
0
ファイル: pointctl.go プロジェクト: evansuva/pointcoind
// makeCreateRawTransaction generates the cmd structure for createrawtransaction
// commands.
func makeCreateRawTransaction(args []interface{}) (btcjson.Cmd, error) {
	var inputs []btcjson.TransactionInput
	err := json.Unmarshal([]byte(args[0].(string)), &inputs)
	if err != nil {
		return nil, err
	}

	var famounts map[string]float64
	err = json.Unmarshal([]byte(args[1].(string)), &famounts)
	if err != nil {
		return nil, err
	}

	amounts := make(map[string]int64, len(famounts))
	for k, v := range famounts {
		amt, err := btcutil.NewAmount(v)
		if err != nil {
			return nil, err
		}
		amounts[k] = int64(amt)
	}

	return btcjson.NewCreateRawTransactionCmd("btcctl", inputs, amounts)
}