Skip to content

Commit

Permalink
chore: rename bnb to branchAndBound to be more explicit & remove conl…
Browse files Browse the repository at this point in the history
…lision with BNB token
  • Loading branch information
peter-sanderson committed Oct 30, 2024
1 parent aeab689 commit 2223463
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
4 changes: 2 additions & 2 deletions packages/utxo-lib/src/coinselect/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { accumulative } from './inputs/accumulative';
import { bnb } from './inputs/bnb';
import { branchAndBound } from './inputs/branchAndBound';
import { split } from './outputs/split';
import { sortByScore, anyOf } from './coinselectUtils';
import { tryConfirmed } from './tryconfirmed';
Expand All @@ -13,7 +13,7 @@ export function coinselect({ inputs, outputs, feeRate, ...options }: CoinSelectR
const sortedInputs =
options.sortingStrategy === 'none' ? inputs : inputs.sort(sortByScore(feeRate));

const algorithm = tryConfirmed(anyOf([bnb, accumulative]), options);
const algorithm = tryConfirmed(anyOf([branchAndBound, accumulative]), options);

return algorithm(sortedInputs, outputs, feeRate, options);
}
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,12 @@ function search(
* https://github.com/bitcoin/bitcoin/blob/b2ec0326fd76e64a6d0d7e4745506b29f60d0be5/src/wallet/coinselection.cpp
*/

export const bnb: CoinSelectAlgorithm = (utxos, outputs, feeRate, options): CoinSelectResult => {
export const branchAndBound: 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

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { bnb } from '../../src/coinselect/inputs/bnb';
import { branchAndBound } from '../../src/coinselect/inputs/branchAndBound';
import fixtures from '../__fixtures__/coinselect/bnb';
import * as utils from './test.utils';
import { CoinSelectOptions } from '../../src/types';
Expand All @@ -14,11 +14,11 @@ describe('coinselect: branchAndBound (bnb)', () => {
dustThreshold: f.dustThreshold,
} as CoinSelectOptions;

const actual = bnb(inputs, outputs, f.feeRate, options);
const actual = branchAndBound(inputs, outputs, f.feeRate, options);
expect(utils.serialize(actual)).toEqual(expected);

if (actual.inputs) {
const feedback = bnb(actual.inputs, actual.outputs, f.feeRate, options);
const feedback = branchAndBound(actual.inputs, actual.outputs, f.feeRate, options);
expect(utils.serialize(feedback)).toEqual(expected);
}
});
Expand Down

0 comments on commit 2223463

Please sign in to comment.