2021-07-26 15:40:37 +02:00
|
|
|
declare module 'coinselect' {
|
2022-09-03 01:48:07 +02:00
|
|
|
export type CoinSelectTarget = {
|
|
|
|
address: string;
|
|
|
|
value?: number;
|
|
|
|
script?: {
|
|
|
|
length: number;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2022-09-10 13:11:28 +02:00
|
|
|
export type CoinSelectUtxo = {
|
2021-07-26 15:40:37 +02:00
|
|
|
vout: number;
|
|
|
|
value: number;
|
2024-03-23 22:31:49 +01:00
|
|
|
txid: string;
|
2022-09-03 01:48:07 +02:00
|
|
|
address?: string;
|
|
|
|
wif?: string;
|
|
|
|
txhex?: string;
|
|
|
|
script?: {
|
|
|
|
length: number;
|
|
|
|
};
|
2021-07-26 15:40:37 +02:00
|
|
|
};
|
|
|
|
|
2022-09-11 12:59:00 +02:00
|
|
|
export type CoinSelectReturnInput = {
|
2022-09-03 01:48:07 +02:00
|
|
|
vout: number;
|
|
|
|
value: number;
|
|
|
|
txid: string;
|
|
|
|
address?: string;
|
|
|
|
wif?: string;
|
|
|
|
txhex?: string;
|
|
|
|
script?: {
|
|
|
|
length: number;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
export type CoinSelectOutput = {
|
2024-02-18 15:42:42 +01:00
|
|
|
address?: string; // if output has no address - this is a change output
|
2022-09-03 01:48:07 +02:00
|
|
|
value: number;
|
|
|
|
};
|
|
|
|
|
|
|
|
export default function coinSelect(
|
2022-09-10 13:11:28 +02:00
|
|
|
utxos: CoinSelectUtxo[],
|
2022-09-03 01:48:07 +02:00
|
|
|
targets: CoinSelectTarget[],
|
2021-07-26 15:40:37 +02:00
|
|
|
feeRate: number,
|
|
|
|
changeAddress?: string,
|
|
|
|
): {
|
2022-09-11 12:59:00 +02:00
|
|
|
inputs: CoinSelectReturnInput[];
|
2022-09-03 01:48:07 +02:00
|
|
|
outputs: CoinSelectOutput[];
|
2021-07-26 15:40:37 +02:00
|
|
|
fee: number;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
declare module 'coinselect/split' {
|
|
|
|
type Utxo = {
|
|
|
|
vout: number;
|
|
|
|
value: number;
|
2024-03-23 22:31:49 +01:00
|
|
|
txid: string;
|
2021-07-26 15:40:37 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
export default function coinSelectSplit<U extends Utxo>(
|
|
|
|
utxos: U[],
|
|
|
|
targets: { address: string; value?: number }[],
|
|
|
|
feeRate: number,
|
|
|
|
changeAddress?: string,
|
|
|
|
): {
|
2022-09-03 01:48:07 +02:00
|
|
|
inputs: CoinselectReturnInput[];
|
2021-07-26 15:40:37 +02:00
|
|
|
outputs: {
|
|
|
|
address?: string;
|
|
|
|
value: number;
|
|
|
|
}[];
|
|
|
|
fee: number;
|
|
|
|
};
|
|
|
|
}
|