@@ -2,7 +2,7 @@ import * as ecc from '@bitcoin-js/tiny-secp256k1-asmjs'
22import { FeeOption , FeeRate , TxHash , checkFeeBounds } from '@xchainjs/xchain-client'
33import { getSeed } from '@xchainjs/xchain-crypto'
44import { Address } from '@xchainjs/xchain-util'
5- import { TxParams , UtxoClientParams } from '@xchainjs/xchain-utxo'
5+ import { TxParams , UtxoClientParams , UtxoSelectionPreferences } from '@xchainjs/xchain-utxo'
66import { HDKey } from '@scure/bip32'
77import * as Bitcoin from 'bitcoinjs-lib'
88import { ECPairFactory , ECPairInterface } from 'ecpair'
@@ -108,7 +108,7 @@ class ClientKeystore extends Client {
108108 * @returns {Promise<TxHash|string> } A promise that resolves to the transaction hash or an error message.
109109 * @throws {"memo too long" } Thrown if the memo is longer than 80 characters.
110110 */
111- async transfer ( params : TxParams & { feeRate ?: FeeRate } ) : Promise < TxHash > {
111+ async transfer ( params : TxParams & { feeRate ?: FeeRate ; utxoSelectionPreferences ?: UtxoSelectionPreferences } ) : Promise < TxHash > {
112112 // Set the default fee rate to `fast`
113113 const feeRate = params . feeRate || ( await this . getFeeRates ( ) ) [ FeeOption . Fast ]
114114
@@ -121,16 +121,20 @@ class ClientKeystore extends Client {
121121 // Get the Bitcoin keys
122122 const btcKeys = this . getBtcKeys ( this . phrase , fromAddressIndex )
123123
124+ // Merge default preferences with caller-provided preferences
125+ const mergedUtxoSelectionPreferences = {
126+ minimizeFee : true ,
127+ avoidDust : true ,
128+ minimizeInputs : false ,
129+ ...params . utxoSelectionPreferences ,
130+ }
131+
124132 // Prepare the transaction
125133 const { rawUnsignedTx } = await this . prepareTxEnhanced ( {
126134 ...params ,
127135 sender : this . getAddress ( fromAddressIndex ) ,
128136 feeRate,
129- utxoSelectionPreferences : {
130- minimizeFee : true ,
131- avoidDust : true ,
132- minimizeInputs : false ,
133- } ,
137+ utxoSelectionPreferences : mergedUtxoSelectionPreferences ,
134138 } )
135139
136140 // Build the PSBT
0 commit comments