Reported by @kallewoof here: https://github.com/bitcoin/bitcoin/pull/13917#issuecomment-412459298

```
$ ./bitcoin-cli createpsbt "[]" "[{\"$(./bitcoin-cli getnewaddress)\":0.01}]"
cHNidP8BACoCAAAAAAFAQg8AAAAAABepFG6Rty1Vk+fUOR4v9E6R6YXDFkHwhwAAAAAAAA==
$ ./bitcoin-cli decodepsbt cHNidP8BACoCAAAAAAFAQg8AAAAAABepFG6Rty1Vk+fUOR4v9E6R6YXDFkHwhwAAAAAAAA==
error code: -22
error message:
TX decode failed CDataStream::read(): end of data: unspecified iostream_category error
```

template<typename T>
    OverrideStream<Stream>& operator<<(const T& obj)
    {
        
        ::Serialize(*this, obj);
        return (*this);
    }
    template<typename T>
    OverrideStream<Stream>& operator>>(T&& obj)
    {
        
        ::Unserialize(*this, obj);
        return (*this);
    }
    void write(const char* pch, size_t nSize)
    {
        stream->write(pch, nSize);
    }
    void read(char* pch, size_t nSize)
    {
        stream->read(pch, nSize);
    }
    int GetVersion() const { return nVersion; }
    int GetType() const { return nType; }
    size_t size() const { return stream->size(); }
};
template<typename S>
OverrideStream<S> WithOrVersion(S* s, int nVersionFlag)