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
```

{
        
        if (!vch.empty())
            s.write((char*)vch.data(), vch.size() * sizeof(value_type));
    }
    template<typename T>
    CDataStream& operator<<(const T& obj)
    {
        
        ::Serialize(*this, obj);
        return (*this);
    }
    template<typename T>
    CDataStream& operator>>(T&& obj)
    {
        
        ::Unserialize(*this, obj);
        return (*this);
    }
    void GetAndClear(CSerializeData &d) {
        d.insert(d.end(), begin(), end());
        clear();
    }
    /**
     * XOR the contents of this stream with a certain key.
     *
     * @param[in] key    The key used to XOR the data in this stream.
     */
    void Xor(const std::vector<unsigned char>& key)