diff --git a/packages/utxo-lib/src/coinselect/inputs/accumulative.ts b/packages/utxo-lib/src/coinselect/inputs/accumulative.ts index 3c6176794de..24d6371baef 100644 --- a/packages/utxo-lib/src/coinselect/inputs/accumulative.ts +++ b/packages/utxo-lib/src/coinselect/inputs/accumulative.ts @@ -8,21 +8,16 @@ import { finalize, ZERO, } from '../coinselectUtils'; -import { - CoinSelectOptions, - CoinSelectInput, - CoinSelectOutput, - CoinSelectResult, -} from '../../types'; +import { CoinSelectInput, CoinSelectResult, CoinSelectAlgorithm } from '../../types'; // add inputs until we reach or surpass the target value (or deplete) // worst-case: O(n) -export function accumulative( - utxos0: CoinSelectInput[], - outputs: CoinSelectOutput[], - feeRate: number, - options: CoinSelectOptions, -): CoinSelectResult { +export const accumulative: CoinSelectAlgorithm = ( + utxos0, + outputs, + feeRate, + options, +): CoinSelectResult => { let inAccum = ZERO; const inputs: CoinSelectInput[] = []; const outAccum = sumOrNaN(outputs); @@ -80,4 +75,4 @@ export function accumulative( const fee = getFee(inputs, outputs, feeRate, options); return { fee }; -} +}; diff --git a/packages/utxo-lib/src/coinselect/inputs/bnb.ts b/packages/utxo-lib/src/coinselect/inputs/bnb.ts index 6a2e65236bd..40ebc4364c7 100644 --- a/packages/utxo-lib/src/coinselect/inputs/bnb.ts +++ b/packages/utxo-lib/src/coinselect/inputs/bnb.ts @@ -11,12 +11,7 @@ import { ZERO, OUTPUT_SCRIPT_LENGTH, } from '../coinselectUtils'; -import { - CoinSelectInput, - CoinSelectOutput, - CoinSelectOptions, - CoinSelectResult, -} from '../../types'; +import { CoinSelectInput, CoinSelectResult, CoinSelectAlgorithm } from '../../types'; const MAX_TRIES = 1000000; @@ -132,12 +127,7 @@ function search( * https://github.com/bitcoin/bitcoin/blob/b2ec0326fd76e64a6d0d7e4745506b29f60d0be5/src/wallet/coinselection.cpp */ -export function bnb( - utxos: CoinSelectInput[], - outputs: CoinSelectOutput[], - feeRate: number, - options: CoinSelectOptions, -): CoinSelectResult { +export const bnb: CoinSelectAlgorithm = (utxos, outputs, feeRate, options): CoinSelectResult => { if (options.baseFee) return { fee: 0 }; // TEMP: disable bnb algorithm for DOGE if (utxos.find(u => u.required)) return { fee: 0 }; // TODO: enable bnb algorithm if required utxos are defined @@ -200,4 +190,4 @@ export function bnb( } return { fee: 0 }; -} +};