rpcclient: Remove searchrawtransactions.

This removes support for the deprecated searchrawtransactions method
from the RPC client.

This is part of the overall removal of the deprecated address index.
This commit is contained in:
Dave Collins 2022-04-26 01:00:53 -05:00
parent 100701c9e9
commit a32fab1663
No known key found for this signature in database
GPG Key ID: B8904D9D9C93D1F2

View File

@ -394,133 +394,3 @@ func (c *Client) SendRawTransactionAsync(ctx context.Context, tx *wire.MsgTx, al
func (c *Client) SendRawTransaction(ctx context.Context, tx *wire.MsgTx, allowHighFees bool) (*chainhash.Hash, error) {
return c.SendRawTransactionAsync(ctx, tx, allowHighFees).Receive()
}
// FutureSearchRawTransactionsResult is a future promise to deliver the result
// of the SearchRawTransactionsAsync RPC invocation (or an applicable error).
type FutureSearchRawTransactionsResult cmdRes
// Receive waits for the response promised by the future and returns the
// found raw transactions.
func (r *FutureSearchRawTransactionsResult) Receive() ([]*wire.MsgTx, error) {
res, err := receiveFuture(r.ctx, r.c)
if err != nil {
return nil, err
}
// Unmarshal as an array of strings.
var searchRawTxnsResult []string
err = json.Unmarshal(res, &searchRawTxnsResult)
if err != nil {
return nil, err
}
// Decode and deserialize each transaction.
msgTxns := make([]*wire.MsgTx, 0, len(searchRawTxnsResult))
for _, hexTx := range searchRawTxnsResult {
// Decode the serialized transaction hex to raw bytes.
serializedTx, err := hex.DecodeString(hexTx)
if err != nil {
return nil, err
}
// Deserialize the transaction and add it to the result slice.
var msgTx wire.MsgTx
err = msgTx.Deserialize(bytes.NewReader(serializedTx))
if err != nil {
return nil, err
}
msgTxns = append(msgTxns, &msgTx)
}
return msgTxns, nil
}
// SearchRawTransactionsAsync 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 SearchRawTransactions for the blocking version and more details.
func (c *Client) SearchRawTransactionsAsync(ctx context.Context,
address stdaddr.Address, skip, count int, reverse bool,
filterAddrs []string) *FutureSearchRawTransactionsResult {
addr := address.String()
verbose := dcrjson.Int(0)
prevOut := dcrjson.Int(0)
cmd := chainjson.NewSearchRawTransactionsCmd(addr, verbose, &skip, &count,
prevOut, &reverse, &filterAddrs)
return (*FutureSearchRawTransactionsResult)(c.sendCmd(ctx, cmd))
}
// SearchRawTransactions returns transactions that involve the passed address.
//
// NOTE: Chain servers do not typically provide this capability unless it has
// specifically been enabled.
//
// See SearchRawTransactionsVerbose to retrieve a list of data structures with
// information about the transactions instead of the transactions themselves.
func (c *Client) SearchRawTransactions(ctx context.Context,
address stdaddr.Address, skip, count int,
reverse bool, filterAddrs []string) ([]*wire.MsgTx, error) {
return c.SearchRawTransactionsAsync(ctx, address, skip, count, reverse,
filterAddrs).Receive()
}
// FutureSearchRawTransactionsVerboseResult is a future promise to deliver the
// result of the SearchRawTransactionsVerboseAsync RPC invocation (or an
// applicable error).
type FutureSearchRawTransactionsVerboseResult cmdRes
// Receive waits for the response promised by the future and returns the
// found raw transactions.
func (r *FutureSearchRawTransactionsVerboseResult) Receive() ([]*chainjson.SearchRawTransactionsResult, error) {
res, err := receiveFuture(r.ctx, r.c)
if err != nil {
return nil, err
}
// Unmarshal as an array of raw transaction results.
var result []*chainjson.SearchRawTransactionsResult
err = json.Unmarshal(res, &result)
if err != nil {
return nil, err
}
return result, nil
}
// SearchRawTransactionsVerboseAsync 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 SearchRawTransactionsVerbose for the blocking version and more details.
func (c *Client) SearchRawTransactionsVerboseAsync(ctx context.Context,
address stdaddr.Address, skip, count int, includePrevOut bool, reverse bool,
filterAddrs *[]string) *FutureSearchRawTransactionsVerboseResult {
addr := address.String()
verbose := dcrjson.Int(1)
prevOut := dcrjson.Int(0)
if includePrevOut {
prevOut = dcrjson.Int(1)
}
cmd := chainjson.NewSearchRawTransactionsCmd(addr, verbose, &skip, &count,
prevOut, &reverse, filterAddrs)
return (*FutureSearchRawTransactionsVerboseResult)(c.sendCmd(ctx, cmd))
}
// SearchRawTransactionsVerbose returns a list of data structures that describe
// transactions which involve the passed address.
//
// NOTE: Chain servers do not typically provide this capability unless it has
// specifically been enabled.
//
// See SearchRawTransactions to retrieve a list of raw transactions instead.
func (c *Client) SearchRawTransactionsVerbose(ctx context.Context,
address stdaddr.Address, skip, count int, includePrevOut, reverse bool,
filterAddrs []string) ([]*chainjson.SearchRawTransactionsResult, error) {
return c.SearchRawTransactionsVerboseAsync(ctx, address, skip, count,
includePrevOut, reverse, &filterAddrs).Receive()
}