Running bitcoind and bitcoin-cli with JSON RPC, 0.18.0 on testnet, having a nightmare trying to understand the inconsistency of this parameter's behaviour.
It works fine every time, until the remaining balance left in wallet will be lower than an undetermined amount. At that point, it decides to use all of the remainder as extra fees for the supposedly fee inclusive transaction, thereby failing to perform the subtractfeefromamount functionality.
Examples of my test results:
Balance 10000, sent 1000 - Balance 9000
Balance 3000, sent 1600 - Balance 1400
Balance 1400, sent 1300 - Balance 0
Balance 8700, sent 8400 - Balance 0
Balance 10000, sent 9500 - Balance 0
The format and values of all other parameters and code do not change between tests, only the amount for sending. I do not specify any parameters beyond subtractfee
There definitely seems to be some mechanism to use all the remainder for fees when the remainder is under a certain amount, but this is terrible and unpredictable, why does it happen and how can it be prevented? Should be reproduceable!
Thanks