drainTo

fun drainTo(script: Script): TxBuilder

Sets the address to drain excess coins to. Usually, when there are excess coins they are sent to a change address generated by the wallet. This option replaces the usual change address with an arbitrary ScriptPubKey of your choosing. Just as with a change output, if the drain output is not needed (the excess coins are too small) it will not be included in the resulting transaction. The only difference is that it is valid to use drainTo without setting any ordinary recipients with addRecipient (but it is perfectly fine to add recipients as well). If you choose not to set any recipients, you should either provide the utxos that the transaction should spend via addUtxos, or set drainWallet to spend all of them. When bumping the fees of a transaction made with this option, you probably want to use BumpFeeTxBuilder.allowShrinking to allow this output to be reduced to pay for the extra fees.