Ejemplo n.º 1
0
// GetCurrentNet requests the network a bitcoin RPC server is running on.
func GetCurrentNet(rpc ServerConn) (btcwire.BitcoinNet, *btcjson.Error) {
	cmd := btcws.NewGetCurrentNetCmd(<-NewJSONID)
	request := NewServerRequest(cmd, nil)
	response := <-rpc.SendRequest(request)
	if response.Error() != nil {
		return 0, response.Error()
	}
	return btcwire.BitcoinNet(uint32(response.Result().(float64))), nil
}
Ejemplo n.º 2
0
// GetCurrentNet requests the network a bitcoin RPC server is running on.
func GetCurrentNet(rpc ServerConn) (btcwire.BitcoinNet, *btcjson.Error) {
	cmd := btcws.NewGetCurrentNetCmd(<-NewJSONID)
	response := <-rpc.SendRequest(NewServerRequest(cmd))

	var resultData uint32
	_, jsonErr := response.FinishUnmarshal(&resultData)
	if jsonErr != nil {
		return 0, jsonErr
	}
	return btcwire.BitcoinNet(resultData), nil
}
Ejemplo n.º 3
0
// GetCurrentNetAsync 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 GetCurrentNet for the blocking version and more details.
//
// NOTE: This is a btcd extension.
func (c *Client) GetCurrentNetAsync() FutureGetCurrentNetResult {
	id := c.NextID()
	cmd := btcws.NewGetCurrentNetCmd(id)

	return c.sendCmd(cmd)
}