<!-- This issue tracker is only for technical issues related to Bitcoin Core. General bitcoin questions and/or support requests are best directed to the Bitcoin StackExchange at https://bitcoin.stackexchange.com. For reporting security issues, please read instructions at https://bitcoincore.org/en/contact/. If the node is "stuck" during sync or giving "block checksum mismatch" errors, please ensure your hardware is stable by running memtest and observe CPU temperature with a load-test tool such as linpack before creating an issue! -->
<!-- Describe the issue -->
I would like to use bitcoin core to track watch-only addresses and create PSBTs. For my use case, I tried to use walletcreatefundedpsbt with fully specified inputs and outputs, mostly for the purpose of modifying the outputs to achieve a certain fee rate for the transaction. I define outputs with pre-fee amounts, then set fee_rate and subtractFeeFromOutputs.
Expected behavior
<!--- What behavior did you expect? -->
The RPC call should succeed and give me a PSBT where each output amount is a little less than the argument amount, to cover the fee.
Actual behavior
<!--- What was the actual behavior (provide screenshots if the issue is GUI-related)? -->
The call fails with "Insufficient funds". If I use getnewaddress and fund an output paying to this address instead, the call works as expected. The problem only appears when the output I am trying to spend is watch-only.
To reproduce
<!--- How reliably can you reproduce the issue, what are the steps to do so? -->
This script demonstrates the problem in a minimal scenario: https://gist.github.com/GambolingPangolin/587c46e9e5421a5401973406a0869519
System information
<!-- What version of Bitcoin Core are you using, where did you get it (website, self-compiled, etc)? -->
Bitcoin Core v0.21.1 downloaded from bitcoincore.org.
<!-- What type of machine are you observing the error on (OS/CPU and disk type)? -->
Ubuntu 20.04
<!-- GUI-related issue? What is your operating system and its version? If Linux, what is your desktop environment and graphical shell? -->
<!-- Any extra information that might be useful in the debugging process. -->
<!--- This is normally the contents of a `debug.log` or `config.log` file. Raw text or a link to a pastebin type site are preferred. -->