2017-05-20 01:45:38 +02:00
|
|
|
package chain
|
|
|
|
|
|
|
|
import (
|
2021-08-26 00:58:28 +02:00
|
|
|
"github.com/lbryio/lbcd/txscript"
|
2017-05-20 01:45:38 +02:00
|
|
|
)
|
|
|
|
|
2018-03-21 02:04:36 +01:00
|
|
|
// buildFilterBlocksWatchList constructs a watchlist used for matching against a
|
|
|
|
// cfilter from a FilterBlocksRequest. The watchlist will be populated with all
|
|
|
|
// external addresses, internal addresses, and outpoints contained in the
|
|
|
|
// request.
|
|
|
|
func buildFilterBlocksWatchList(req *FilterBlocksRequest) ([][]byte, error) {
|
|
|
|
// Construct a watch list containing the script addresses of all
|
|
|
|
// internal and external addresses that were requested, in addition to
|
|
|
|
// the set of outpoints currently being watched.
|
2022-09-16 18:13:09 +02:00
|
|
|
watchListSize := len(req.Addresses) +
|
2018-03-21 02:04:36 +01:00
|
|
|
len(req.WatchedOutPoints)
|
|
|
|
|
|
|
|
watchList := make([][]byte, 0, watchListSize)
|
|
|
|
|
2022-09-16 18:13:09 +02:00
|
|
|
for _, addr := range req.Addresses {
|
2018-03-21 02:04:36 +01:00
|
|
|
p2shAddr, err := txscript.PayToAddrScript(addr)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
watchList = append(watchList, p2shAddr)
|
|
|
|
}
|
|
|
|
|
2018-06-15 07:02:40 +02:00
|
|
|
for _, addr := range req.WatchedOutPoints {
|
|
|
|
addr, err := txscript.PayToAddrScript(addr)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
watchList = append(watchList, addr)
|
2018-03-21 02:04:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return watchList, nil
|
|
|
|
}
|