1 | import { Psbt as PsbtBase } from 'bip174';
|
2 | import { KeyValue, PsbtGlobalUpdate, PsbtInput, PsbtInputUpdate, PsbtOutput, PsbtOutputUpdate, TransactionInput, TransactionOutput } from 'bip174/src/lib/interfaces';
|
3 | import { Signer, SignerAsync } from './ecpair';
|
4 | import { Network } from './networks';
|
5 | import { Transaction } from './transaction';
|
6 | export interface PsbtTxInput extends TransactionInput {
|
7 | hash: Buffer;
|
8 | }
|
9 | export interface PsbtTxOutput extends TransactionOutput {
|
10 | address: string | undefined;
|
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 | export declare class Psbt {
|
45 | readonly data: PsbtBase;
|
46 | static fromBase64(data: string, opts?: PsbtOptsOptional): Psbt;
|
47 | static fromHex(data: string, opts?: PsbtOptsOptional): Psbt;
|
48 | static fromBuffer(buffer: Buffer, opts?: PsbtOptsOptional): Psbt;
|
49 | private __CACHE;
|
50 | private opts;
|
51 | constructor(opts?: PsbtOptsOptional, data?: PsbtBase);
|
52 | readonly inputCount: number;
|
53 | version: number;
|
54 | locktime: number;
|
55 | readonly txInputs: PsbtTxInput[];
|
56 | readonly txOutputs: PsbtTxOutput[];
|
57 | combine(...those: Psbt[]): this;
|
58 | clone(): Psbt;
|
59 | setMaximumFeeRate(satoshiPerByte: number): void;
|
60 | setVersion(version: number): this;
|
61 | setLocktime(locktime: number): this;
|
62 | setInputSequence(inputIndex: number, sequence: number): this;
|
63 | addInputs(inputDatas: PsbtInputExtended[]): this;
|
64 | addInput(inputData: PsbtInputExtended): this;
|
65 | addOutputs(outputDatas: PsbtOutputExtended[]): this;
|
66 | addOutput(outputData: PsbtOutputExtended): this;
|
67 | extractTransaction(disableFeeCheck?: boolean): Transaction;
|
68 | getFeeRate(): number;
|
69 | getFee(): number;
|
70 | finalizeAllInputs(): this;
|
71 | finalizeInput(inputIndex: number, finalScriptsFunc?: FinalScriptsFunc): this;
|
72 | getInputType(inputIndex: number): AllScriptType;
|
73 | inputHasPubkey(inputIndex: number, pubkey: Buffer): boolean;
|
74 | inputHasHDKey(inputIndex: number, root: HDSigner): boolean;
|
75 | outputHasPubkey(outputIndex: number, pubkey: Buffer): boolean;
|
76 | outputHasHDKey(outputIndex: number, root: HDSigner): boolean;
|
77 | validateSignaturesOfAllInputs(): boolean;
|
78 | validateSignaturesOfInput(inputIndex: number, pubkey?: Buffer): boolean;
|
79 | signAllInputsHD(hdKeyPair: HDSigner, sighashTypes?: number[]): this;
|
80 | signAllInputsHDAsync(hdKeyPair: HDSigner | HDSignerAsync, sighashTypes?: number[]): Promise<void>;
|
81 | signInputHD(inputIndex: number, hdKeyPair: HDSigner, sighashTypes?: number[]): this;
|
82 | signInputHDAsync(inputIndex: number, hdKeyPair: HDSigner | HDSignerAsync, sighashTypes?: number[]): Promise<void>;
|
83 | signAllInputs(keyPair: Signer, sighashTypes?: number[]): this;
|
84 | signAllInputsAsync(keyPair: Signer | SignerAsync, sighashTypes?: number[]): Promise<void>;
|
85 | signInput(inputIndex: number, keyPair: Signer, sighashTypes?: number[]): this;
|
86 | signInputAsync(inputIndex: number, keyPair: Signer | SignerAsync, sighashTypes?: number[]): Promise<void>;
|
87 | toBuffer(): Buffer;
|
88 | toHex(): string;
|
89 | toBase64(): string;
|
90 | updateGlobal(updateData: PsbtGlobalUpdate): this;
|
91 | updateInput(inputIndex: number, updateData: PsbtInputUpdate): this;
|
92 | updateOutput(outputIndex: number, updateData: PsbtOutputUpdate): this;
|
93 | addUnknownKeyValToGlobal(keyVal: KeyValue): this;
|
94 | addUnknownKeyValToInput(inputIndex: number, keyVal: KeyValue): this;
|
95 | addUnknownKeyValToOutput(outputIndex: number, keyVal: KeyValue): this;
|
96 | clearFinalizedInput(inputIndex: number): this;
|
97 | }
|
98 | interface PsbtOptsOptional {
|
99 | network?: Network;
|
100 | maximumFeeRate?: number;
|
101 | }
|
102 | interface PsbtInputExtended extends PsbtInput, TransactionInput {
|
103 | }
|
104 | declare type PsbtOutputExtended = PsbtOutputExtendedAddress | PsbtOutputExtendedScript;
|
105 | interface PsbtOutputExtendedAddress extends PsbtOutput {
|
106 | address: string;
|
107 | value: number;
|
108 | }
|
109 | interface PsbtOutputExtendedScript extends PsbtOutput {
|
110 | script: Buffer;
|
111 | value: number;
|
112 | }
|
113 | interface HDSignerBase {
|
114 | |
115 |
|
116 |
|
117 | publicKey: Buffer;
|
118 | |
119 |
|
120 |
|
121 | fingerprint: Buffer;
|
122 | }
|
123 | interface HDSigner extends HDSignerBase {
|
124 | |
125 |
|
126 |
|
127 |
|
128 | derivePath(path: string): HDSigner;
|
129 | |
130 |
|
131 |
|
132 |
|
133 | sign(hash: Buffer): Buffer;
|
134 | }
|
135 |
|
136 |
|
137 |
|
138 | interface HDSignerAsync extends HDSignerBase {
|
139 | derivePath(path: string): HDSignerAsync;
|
140 | sign(hash: Buffer): Promise<Buffer>;
|
141 | }
|
142 |
|
143 |
|
144 |
|
145 |
|
146 |
|
147 |
|
148 | declare type FinalScriptsFunc = (inputIndex: number,
|
149 | input: PsbtInput,
|
150 | script: Buffer,
|
151 | isSegwit: boolean,
|
152 | isP2SH: boolean,
|
153 | isP2WSH: boolean) => {
|
154 | finalScriptSig: Buffer | undefined;
|
155 | finalScriptWitness: Buffer | undefined;
|
156 | };
|
157 | declare type AllScriptType = 'witnesspubkeyhash' | 'pubkeyhash' | 'multisig' | 'pubkey' | 'nonstandard' | 'p2sh-witnesspubkeyhash' | 'p2sh-pubkeyhash' | 'p2sh-multisig' | 'p2sh-pubkey' | 'p2sh-nonstandard' | 'p2wsh-pubkeyhash' | 'p2wsh-multisig' | 'p2wsh-pubkey' | 'p2wsh-nonstandard' | 'p2sh-p2wsh-pubkeyhash' | 'p2sh-p2wsh-multisig' | 'p2sh-p2wsh-pubkey' | 'p2sh-p2wsh-nonstandard';
|
158 | export {};
|