-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
Coin selection
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export {}; | ||
//# sourceMappingURL=test-utxo-coinselection.d.ts.map |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { UTXO, UTXOLike } from "./utxo.js"; | ||
export type SpendTarget = { | ||
address: string; | ||
value: bigint; | ||
}; | ||
export type SelectedCoinsResult = { | ||
inputs: UTXO[]; | ||
spendOutputs: UTXO[]; | ||
changeOutputs: UTXO[]; | ||
}; | ||
/** | ||
* An **AbstractCoinSelector** provides a base class for other sub-classes to | ||
* implement the functionality for selecting UTXOs for a spend and to properly | ||
* handle spend and change outputs. | ||
* | ||
* This class is abstract and should not be used directly. Sub-classes should | ||
* implement the [[performSelection]] method to provide the actual coin | ||
* selection logic. | ||
* | ||
* @abstract | ||
*/ | ||
export declare abstract class AbstractCoinSelector { | ||
#private; | ||
get availableUXTOs(): UTXO[]; | ||
set availableUXTOs(value: UTXOLike[]); | ||
get spendOutputs(): UTXO[]; | ||
set spendOutputs(value: UTXOLike[]); | ||
get changeOutputs(): UTXO[]; | ||
set changeOutputs(value: UTXOLike[]); | ||
/** | ||
* Constructs a new AbstractCoinSelector instance with an empty UTXO array. | ||
*/ | ||
constructor(availableUXTOs?: UTXOLike[]); | ||
/** | ||
* This method should be implemented by sub-classes to provide the actual | ||
* coin selection logic. It should select UTXOs from the available UTXOs | ||
* that sum to the target amount and return the selected UTXOs as well as | ||
* the spend and change outputs. | ||
* @param target The target amount to select UTXOs for. | ||
*/ | ||
abstract performSelection(target: SpendTarget): SelectedCoinsResult; | ||
/** | ||
* Validates the provided UTXO instance. In order to be valid for coin | ||
* selection, the UTXO must have a valid address and denomination. | ||
* @param utxo The UTXO instance to validate. | ||
* @throws An error if the UTXO instance is invalid. | ||
*/ | ||
protected _validateUTXO(utxo: UTXO): void; | ||
} | ||
//# sourceMappingURL=abstract-coinselector.d.ts.map |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.