Segregated witness rebased by sipa · Pull Request #8149 · bitcoin/bitcoin

This PR is a rebased and squashed version of #7910. As this is the form (in pieces or in whole) that we expect it to be merged in, I'm opening a separate pull request for it. I will leave the old o...