Transaction filtering

**Ready to merge**

~~Needs tests.~~

Fixes #1011