예제 #1
0
// CreateRawTransactionAsync returns an instance of a type that can be used to
// get the result of the RPC at some future time by invoking the Receive
// function on the returned instance.
//
// See CreateRawTransaction for the blocking version and more details.
func (c *Client) CreateRawTransactionAsync(inputs []btcjson.TransactionInput,
	amounts map[btcutil.Address]btcutil.Amount) FutureCreateRawTransactionResult {

	id := c.NextID()
	convertedAmts := make(map[string]int64, len(amounts))
	for addr, amount := range amounts {
		convertedAmts[addr.String()] = int64(amount)
	}
	cmd, err := btcjson.NewCreateRawTransactionCmd(id, inputs, convertedAmts)
	if err != nil {
		return newFutureError(err)
	}

	return c.sendCmd(cmd)
}
예제 #2
0
// 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 amounts map[string]int64
	err = json.Unmarshal([]byte(args[1].(string)), &amounts)
	if err != nil {
		return nil, err
	}

	return btcjson.NewCreateRawTransactionCmd("btcctl", inputs, amounts)
}
예제 #3
0
파일: btcctl.go 프로젝트: hsk81/btcd
// makeCreateRawTransaction generates the cmd structure for createrawtransaction
// commands.
func makeCreateRawTransaction(args []interface{}) (btcjson.Cmd, error) {
	// First unmarshal the JSON provided by the parameters into interfaces.
	var iinputs, iamounts interface{}
	err := json.Unmarshal([]byte(args[0].(string)), &iinputs)
	if err != nil {
		return nil, err
	}
	err = json.Unmarshal([]byte(args[1].(string)), &iamounts)
	if err != nil {
		return nil, err
	}

	// Validate and convert the interfaces to concrete types.
	inputs, amounts, err := btcjson.ConvertCreateRawTxParams(iinputs,
		iamounts)
	if err != nil {
		return nil, err
	}

	return btcjson.NewCreateRawTransactionCmd("btcctl", inputs, amounts)
}
예제 #4
0
// 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)
}