Ejemplo n.º 1
0
// RescanEndHeightAsync 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 RescanEndHeight for the blocking version and more details.
//
// NOTE: This is a btcd extension and requires a websocket connection.
func (c *Client) RescanEndHeightAsync(startHeight int32,
	addresses []btcutil.Address, outpoints []*btcwire.OutPoint,
	endHeight int64) FutureRescanResult {

	// Not supported in HTTP POST mode.
	if c.config.HttpPostMode {
		return newFutureError(ErrNotificationsNotSupported)
	}

	// Ignore the notification if the client is not interested in
	// notifications.
	if c.ntfnHandlers == nil {
		return newNilFutureResult()
	}

	// Convert addresses to strings.
	addrs := make([]string, 0, len(addresses))
	for _, addr := range addresses {
		addrs = append(addrs, addr.EncodeAddress())
	}

	// Convert outpoints.
	ops := make([]btcws.OutPoint, 0, len(outpoints))
	for _, op := range outpoints {
		ops = append(ops, *btcws.NewOutPointFromWire(op))
	}

	id := c.NextID()
	cmd, err := btcws.NewRescanCmd(id, startHeight, addrs, ops, endHeight)
	if err != nil {
		return newFutureError(err)
	}

	return c.sendCmd(cmd)
}
Ejemplo n.º 2
0
// Rescan requests a blockchain rescan for transactions to any number of
// addresses and notifications to inform wallet about such transactions.
func Rescan(rpc ServerConn, beginBlock int32, addrs map[string]struct{}) *btcjson.Error {
	// NewRescanCmd cannot fail with no optargs, so omit the check.
	cmd, _ := btcws.NewRescanCmd(<-NewJSONID, beginBlock, addrs)
	request := NewServerRequest(cmd, nil)
	response := <-rpc.SendRequest(request)
	return response.Error()
}
Ejemplo n.º 3
0
// Rescan requests a blockchain rescan for transactions to any number of
// addresses and notifications to inform wallet about such transactions.
func Rescan(rpc ServerConn, beginBlock int32, addrs []string,
	outpoints []*btcwire.OutPoint) *btcjson.Error {

	// NewRescanCmd cannot fail with no optargs, so omit the check.
	ops := make([]btcws.OutPoint, len(outpoints))
	for i := range outpoints {
		ops[i] = *btcws.NewOutPointFromWire(outpoints[i])
	}
	cmd, _ := btcws.NewRescanCmd(<-NewJSONID, beginBlock, addrs, ops)
	response := <-rpc.SendRequest(NewServerRequest(cmd))
	_, jsonErr := response.FinishUnmarshal(nil)
	return jsonErr
}