forked from bitcoinjs/coinselect
-
Notifications
You must be signed in to change notification settings - Fork 2
/
witness.d.ts
69 lines (60 loc) · 1.44 KB
/
witness.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
export type IPaymentType = 'p2pkh' | 'p2sh' | 'p2tr' | 'p2wpkh' | 'p2wsh';
export interface IUtxo {
vout: number;
txid: string;
amount: string;
coinbase: boolean;
own: boolean;
confirmations: number;
}
export interface IOutputPayment {
type: 'payment';
address: string;
amount: string;
}
export interface IOutputSendMax {
type: 'send-max'; // only one in TX request
address: string;
amount?: typeof undefined;
}
export interface IOutputOpreturn {
type: 'opreturn';
dataHex: string;
amount?: typeof undefined;
address?: typeof undefined;
}
export interface IOutputChange {
type: 'change';
amount: string;
}
export type IFinalOutput =
| ComposeOutputPayment
| ComposeOutputSendMax
| ComposeOutputOpreturn;
export interface IChangeAddress {
address: string;
path: string;
}
export interface ICoinSelectParams {
utxos: IUtxo[];
outputs: IFinalOutput[];
feeRate: string | number;
changeAddress: IChangeAddress;
network: any;
txType: IPaymentType
baseFee?: number;
dustThreshold?: number;
}
export interface ICoinSelectResult {
type: 'final';
max?: string;
totalSpent: string;
fee: string;
feePerByte: string;
bytes: number;
inputs: IUtxo[];
outputs: (IFinalOutput | IOutputChange)[];
outputsPermutation: number[];
}
declare function coinSelect(params: ICoinSelectParams): ICoinSelectResult;
export = coinSelect;