// NotifySpent requests notifications for when a transaction is processed which // spends op. func NotifySpent(rpc ServerConn, outpoints []*btcwire.OutPoint) *btcjson.Error { ops := make([]btcws.OutPoint, 0, len(outpoints)) for _, op := range outpoints { ops = append(ops, *btcws.NewOutPointFromWire(op)) } cmd := btcws.NewNotifySpentCmd(<-NewJSONID, ops) response := <-rpc.SendRequest(NewServerRequest(cmd)) _, jsonErr := response.FinishUnmarshal(nil) return jsonErr }
// notifySpentInternal is the same as notifySpentAsync except it accepts // the converted outpoints as a parameter so the client can more efficiently // recreate the previous notification state on reconnect. func (c *Client) notifySpentInternal(outpoints []btcws.OutPoint) FutureNotifySpentResult { // 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() } id := c.NextID() cmd := btcws.NewNotifySpentCmd(id, outpoints) return c.sendCmd(cmd) }
// NotifySpentAsync 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 NotifySpent for the blocking version and more details. // // NOTE: This is a btcd extension and requires a websocket connection. func (c *Client) NotifySpentAsync(outpoints []*btcwire.OutPoint) FutureNotifySpentResult { // 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() } id := c.NextID() ops := make([]btcws.OutPoint, 0, len(outpoints)) for _, outpoint := range outpoints { ops = append(ops, *btcws.NewOutPointFromWire(outpoint)) } cmd := btcws.NewNotifySpentCmd(id, ops) return c.sendCmd(cmd) }
// NotifySpent requests notifications for when a transaction is processed which // spends op. func NotifySpent(rpc ServerConn, op *btcwire.OutPoint) *btcjson.Error { cmd := btcws.NewNotifySpentCmd(<-NewJSONID, op) request := NewServerRequest(cmd, nil) response := <-rpc.SendRequest(request) return response.Error() }