2017-05-19 17:45:38 -06:00
|
|
|
package chain
|
|
|
|
|
|
|
|
import (
|
2021-08-25 15:58:28 -07:00
|
|
|
"github.com/lbryio/lbcd/txscript"
|
2017-05-19 17:45:38 -06:00
|
|
|
)
|
|
|
|
|
2018-03-20 18:04:36 -07: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.
|
|
|
|
watchListSize := len(req.ExternalAddrs) +
|
|
|
|
len(req.InternalAddrs) +
|
|
|
|
len(req.WatchedOutPoints)
|
|
|
|
|
|
|
|
watchList := make([][]byte, 0, watchListSize)
|
|
|
|
|
|
|
|
for _, addr := range req.ExternalAddrs {
|
|
|
|
p2shAddr, err := txscript.PayToAddrScript(addr)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
watchList = append(watchList, p2shAddr)
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, addr := range req.InternalAddrs {
|
|
|
|
p2shAddr, err := txscript.PayToAddrScript(addr)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
watchList = append(watchList, p2shAddr)
|
|
|
|
}
|
|
|
|
|
2018-06-14 22:02:40 -07:00
|
|
|
for _, addr := range req.WatchedOutPoints {
|
|
|
|
addr, err := txscript.PayToAddrScript(addr)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
watchList = append(watchList, addr)
|
2018-03-20 18:04:36 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return watchList, nil
|
|
|
|
}
|