xpi-ts 0.2.22 → 0.2.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/lib/bitcore/crypto/point.js +2 -2
- package/dist/cjs/lib/bitcore/index.js +162 -162
- package/dist/esm/lib/bitcore/crypto/point.js +2 -2
- package/dist/esm/lib/bitcore/index.js +42 -42
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/lib/bitcore/address.d.ts +116 -0
- package/dist/types/lib/bitcore/address.d.ts.map +1 -1
- package/dist/types/lib/bitcore/block/block.d.ts +214 -0
- package/dist/types/lib/bitcore/block/block.d.ts.map +1 -1
- package/dist/types/lib/bitcore/block/blockheader.d.ts +220 -0
- package/dist/types/lib/bitcore/block/blockheader.d.ts.map +1 -1
- package/dist/types/lib/bitcore/block/merkleblock.d.ts +206 -0
- package/dist/types/lib/bitcore/block/merkleblock.d.ts.map +1 -1
- package/dist/types/lib/bitcore/crypto/bn.d.ts +224 -0
- package/dist/types/lib/bitcore/crypto/bn.d.ts.map +1 -1
- package/dist/types/lib/bitcore/crypto/ecdsa.d.ts +122 -0
- package/dist/types/lib/bitcore/crypto/ecdsa.d.ts.map +1 -1
- package/dist/types/lib/bitcore/crypto/hash.d.ts +56 -0
- package/dist/types/lib/bitcore/crypto/hash.d.ts.map +1 -1
- package/dist/types/lib/bitcore/crypto/index.d.ts +4 -0
- package/dist/types/lib/bitcore/crypto/index.d.ts.map +1 -1
- package/dist/types/lib/bitcore/crypto/musig2.d.ts +282 -0
- package/dist/types/lib/bitcore/crypto/musig2.d.ts.map +1 -1
- package/dist/types/lib/bitcore/crypto/point.d.ts +87 -0
- package/dist/types/lib/bitcore/crypto/point.d.ts.map +1 -1
- package/dist/types/lib/bitcore/crypto/random.d.ts +48 -0
- package/dist/types/lib/bitcore/crypto/random.d.ts.map +1 -1
- package/dist/types/lib/bitcore/crypto/schnorr.d.ts +203 -0
- package/dist/types/lib/bitcore/crypto/schnorr.d.ts.map +1 -1
- package/dist/types/lib/bitcore/crypto/signature.d.ts +452 -0
- package/dist/types/lib/bitcore/crypto/signature.d.ts.map +1 -1
- package/dist/types/lib/bitcore/crypto/sigtype.d.ts +46 -0
- package/dist/types/lib/bitcore/crypto/sigtype.d.ts.map +1 -1
- package/dist/types/lib/bitcore/encoding/base58.d.ts +68 -0
- package/dist/types/lib/bitcore/encoding/base58.d.ts.map +1 -1
- package/dist/types/lib/bitcore/encoding/base58check.d.ts +58 -0
- package/dist/types/lib/bitcore/encoding/base58check.d.ts.map +1 -1
- package/dist/types/lib/bitcore/encoding/bufferreader.d.ts +112 -0
- package/dist/types/lib/bitcore/encoding/bufferreader.d.ts.map +1 -1
- package/dist/types/lib/bitcore/encoding/bufferwriter.d.ts +144 -0
- package/dist/types/lib/bitcore/encoding/bufferwriter.d.ts.map +1 -1
- package/dist/types/lib/bitcore/encoding/varint.d.ts +86 -0
- package/dist/types/lib/bitcore/encoding/varint.d.ts.map +1 -1
- package/dist/types/lib/bitcore/errors.d.ts +4 -0
- package/dist/types/lib/bitcore/errors.d.ts.map +1 -1
- package/dist/types/lib/bitcore/hdprivatekey.d.ts +59 -0
- package/dist/types/lib/bitcore/hdprivatekey.d.ts.map +1 -1
- package/dist/types/lib/bitcore/hdpublickey.d.ts +145 -0
- package/dist/types/lib/bitcore/hdpublickey.d.ts.map +1 -1
- package/dist/types/lib/bitcore/index.d.ts +58 -54
- package/dist/types/lib/bitcore/index.d.ts.map +1 -1
- package/dist/types/lib/bitcore/message.d.ts +63 -0
- package/dist/types/lib/bitcore/message.d.ts.map +1 -1
- package/dist/types/lib/bitcore/mnemonic/errors.d.ts +4 -0
- package/dist/types/lib/bitcore/mnemonic/errors.d.ts.map +1 -1
- package/dist/types/lib/bitcore/mnemonic/index.d.ts +4 -0
- package/dist/types/lib/bitcore/mnemonic/index.d.ts.map +1 -1
- package/dist/types/lib/bitcore/mnemonic/mnemonic.d.ts +106 -0
- package/dist/types/lib/bitcore/mnemonic/mnemonic.d.ts.map +1 -1
- package/dist/types/lib/bitcore/mnemonic/pbkdf2.d.ts +13 -0
- package/dist/types/lib/bitcore/mnemonic/pbkdf2.d.ts.map +1 -1
- package/dist/types/lib/bitcore/mnemonic/words/english.d.ts +4 -0
- package/dist/types/lib/bitcore/mnemonic/words/english.d.ts.map +1 -1
- package/dist/types/lib/bitcore/mnemonic/words/french.d.ts +5 -0
- package/dist/types/lib/bitcore/mnemonic/words/french.d.ts.map +1 -1
- package/dist/types/lib/bitcore/mnemonic/words/index.d.ts +4 -0
- package/dist/types/lib/bitcore/mnemonic/words/index.d.ts.map +1 -1
- package/dist/types/lib/bitcore/musig2/index.d.ts +14 -0
- package/dist/types/lib/bitcore/musig2/index.d.ts.map +1 -1
- package/dist/types/lib/bitcore/musig2/session.d.ts +254 -0
- package/dist/types/lib/bitcore/musig2/session.d.ts.map +1 -1
- package/dist/types/lib/bitcore/musig2/signer.d.ts +212 -0
- package/dist/types/lib/bitcore/musig2/signer.d.ts.map +1 -1
- package/dist/types/lib/bitcore/networks.d.ts +17 -0
- package/dist/types/lib/bitcore/networks.d.ts.map +1 -1
- package/dist/types/lib/bitcore/opcode.d.ts +151 -0
- package/dist/types/lib/bitcore/opcode.d.ts.map +1 -1
- package/dist/types/lib/bitcore/privatekey.d.ts +80 -0
- package/dist/types/lib/bitcore/privatekey.d.ts.map +1 -1
- package/dist/types/lib/bitcore/publickey.d.ts +195 -0
- package/dist/types/lib/bitcore/publickey.d.ts.map +1 -1
- package/dist/types/lib/bitcore/script/chunk.d.ts +51 -0
- package/dist/types/lib/bitcore/script/chunk.d.ts.map +1 -1
- package/dist/types/lib/bitcore/script/interpreter/condition-stack.d.ts +60 -0
- package/dist/types/lib/bitcore/script/interpreter/condition-stack.d.ts.map +1 -1
- package/dist/types/lib/bitcore/script/interpreter/index.d.ts +23 -0
- package/dist/types/lib/bitcore/script/interpreter/index.d.ts.map +1 -1
- package/dist/types/lib/bitcore/script/interpreter/interpreter.d.ts +86 -0
- package/dist/types/lib/bitcore/script/interpreter/interpreter.d.ts.map +1 -1
- package/dist/types/lib/bitcore/script/interpreter/script-num.d.ts +115 -0
- package/dist/types/lib/bitcore/script/interpreter/script-num.d.ts.map +1 -1
- package/dist/types/lib/bitcore/script/interpreter/types.d.ts +119 -0
- package/dist/types/lib/bitcore/script/interpreter/types.d.ts.map +1 -1
- package/dist/types/lib/bitcore/script/taproot.d.ts +297 -0
- package/dist/types/lib/bitcore/script/taproot.d.ts.map +1 -1
- package/dist/types/lib/bitcore/script.d.ts +510 -0
- package/dist/types/lib/bitcore/script.d.ts.map +1 -1
- package/dist/types/lib/bitcore/taproot/musig2.d.ts +153 -0
- package/dist/types/lib/bitcore/taproot/musig2.d.ts.map +1 -1
- package/dist/types/lib/bitcore/transaction/input/multisig.d.ts +8 -0
- package/dist/types/lib/bitcore/transaction/input/multisig.d.ts.map +1 -1
- package/dist/types/lib/bitcore/transaction/input/multisigscripthash.d.ts +8 -0
- package/dist/types/lib/bitcore/transaction/input/multisigscripthash.d.ts.map +1 -1
- package/dist/types/lib/bitcore/transaction/input/publickey.d.ts +8 -0
- package/dist/types/lib/bitcore/transaction/input/publickey.d.ts.map +1 -1
- package/dist/types/lib/bitcore/transaction/input/publickeyhash.d.ts +14 -0
- package/dist/types/lib/bitcore/transaction/input/publickeyhash.d.ts.map +1 -1
- package/dist/types/lib/bitcore/transaction/input/taproot.d.ts +22 -0
- package/dist/types/lib/bitcore/transaction/input/taproot.d.ts.map +1 -1
- package/dist/types/lib/bitcore/transaction/input.d.ts +418 -0
- package/dist/types/lib/bitcore/transaction/input.d.ts.map +1 -1
- package/dist/types/lib/bitcore/transaction/outpoint.d.ts +110 -0
- package/dist/types/lib/bitcore/transaction/outpoint.d.ts.map +1 -1
- package/dist/types/lib/bitcore/transaction/output.d.ts +83 -0
- package/dist/types/lib/bitcore/transaction/output.d.ts.map +1 -1
- package/dist/types/lib/bitcore/transaction/sighash.d.ts +69 -0
- package/dist/types/lib/bitcore/transaction/sighash.d.ts.map +1 -1
- package/dist/types/lib/bitcore/transaction/signature.d.ts +98 -0
- package/dist/types/lib/bitcore/transaction/signature.d.ts.map +1 -1
- package/dist/types/lib/bitcore/transaction/transaction.d.ts +379 -0
- package/dist/types/lib/bitcore/transaction/transaction.d.ts.map +1 -1
- package/dist/types/lib/bitcore/transaction/unspentoutput.d.ts +61 -0
- package/dist/types/lib/bitcore/transaction/unspentoutput.d.ts.map +1 -1
- package/dist/types/lib/bitcore/unit.d.ts +140 -0
- package/dist/types/lib/bitcore/unit.d.ts.map +1 -1
- package/dist/types/lib/bitcore/uri.d.ts +34 -0
- package/dist/types/lib/bitcore/uri.d.ts.map +1 -1
- package/dist/types/lib/bitcore/util/base32.d.ts +55 -0
- package/dist/types/lib/bitcore/util/base32.d.ts.map +1 -1
- package/dist/types/lib/bitcore/util/bits.d.ts +76 -0
- package/dist/types/lib/bitcore/util/bits.d.ts.map +1 -1
- package/dist/types/lib/bitcore/util/buffer.d.ts +135 -0
- package/dist/types/lib/bitcore/util/buffer.d.ts.map +1 -1
- package/dist/types/lib/bitcore/util/convertBits.d.ts +15 -0
- package/dist/types/lib/bitcore/util/convertBits.d.ts.map +1 -1
- package/dist/types/lib/bitcore/util/js.d.ts +19 -0
- package/dist/types/lib/bitcore/util/js.d.ts.map +1 -1
- package/dist/types/lib/bitcore/util/merkle.d.ts +85 -0
- package/dist/types/lib/bitcore/util/merkle.d.ts.map +1 -1
- package/dist/types/lib/bitcore/util/preconditions.d.ts +29 -0
- package/dist/types/lib/bitcore/util/preconditions.d.ts.map +1 -1
- package/dist/types/lib/bitcore/util.d.ts +7 -0
- package/dist/types/lib/bitcore/util.d.ts.map +1 -1
- package/dist/types/lib/bitcore/xaddress.d.ts +117 -0
- package/dist/types/lib/bitcore/xaddress.d.ts.map +1 -1
- package/dist/types/lib/lokad.d.ts +292 -0
- package/dist/types/lib/lokad.d.ts.map +1 -1
- package/dist/types/lib/nft.d.ts +434 -0
- package/dist/types/lib/nft.d.ts.map +1 -1
- package/dist/types/lib/rank/api.d.ts +13 -0
- package/dist/types/lib/rank/api.d.ts.map +1 -1
- package/dist/types/lib/rank/index.d.ts +153 -0
- package/dist/types/lib/rank/index.d.ts.map +1 -1
- package/dist/types/lib/rank/opcode.d.ts +6 -2
- package/dist/types/lib/rank/opcode.d.ts.map +1 -1
- package/dist/types/lib/rank/script.d.ts +10 -0
- package/dist/types/lib/rank/script.d.ts.map +1 -1
- package/dist/types/lib/rank/transaction.d.ts +11 -0
- package/dist/types/lib/rank/transaction.d.ts.map +1 -1
- package/dist/types/lib/rpc.d.ts +176 -0
- package/dist/types/lib/rpc.d.ts.map +1 -1
- package/dist/types/utils/constants.d.ts +27 -0
- package/dist/types/utils/constants.d.ts.map +1 -1
- package/dist/types/utils/env.d.ts +15 -0
- package/dist/types/utils/env.d.ts.map +1 -1
- package/dist/types/utils/string.d.ts +57 -0
- package/dist/types/utils/string.d.ts.map +1 -1
- package/dist/types/utils/wallet.d.ts +43 -1
- package/dist/types/utils/wallet.d.ts.map +1 -1
- package/package.json +1 -1
- package/tsconfig.types.json +2 -1
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transaction implementation for Lotus
|
|
3
|
+
*
|
|
4
|
+
* Signature Handling:
|
|
5
|
+
* Lotus supports both ECDSA and Schnorr signatures, automatically detected by length:
|
|
6
|
+
* - 64 bytes = Schnorr signature
|
|
7
|
+
* - Other lengths (typically 70-72 bytes) = ECDSA signature (DER-encoded)
|
|
8
|
+
*
|
|
9
|
+
* The signing method can be specified when calling transaction.sign():
|
|
10
|
+
* - signingMethod: 'ecdsa' (default) or 'schnorr'
|
|
11
|
+
*
|
|
12
|
+
* Reference: lotusd/src/script/interpreter.cpp lines 1900-1908
|
|
13
|
+
*/
|
|
1
14
|
import { BufferReader } from '../encoding/bufferreader';
|
|
2
15
|
import { BufferWriter } from '../encoding/bufferwriter';
|
|
3
16
|
import { Signature, SignatureSigningMethod } from '../crypto/signature';
|
|
@@ -34,6 +47,9 @@ export interface TransactionObject {
|
|
|
34
47
|
changeIndex?: number;
|
|
35
48
|
fee?: number;
|
|
36
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* Represents a transaction, a set of inputs and outputs to change ownership of tokens
|
|
52
|
+
*/
|
|
37
53
|
export declare class Transaction {
|
|
38
54
|
static readonly DUST_AMOUNT = 546;
|
|
39
55
|
static readonly FEE_SECURITY_MARGIN = 150;
|
|
@@ -56,101 +72,461 @@ export declare class Transaction {
|
|
|
56
72
|
private _feePerByte?;
|
|
57
73
|
private _hash?;
|
|
58
74
|
private _txid?;
|
|
75
|
+
/**
|
|
76
|
+
* Get spent outputs for all inputs (required for SIGHASH_LOTUS)
|
|
77
|
+
*
|
|
78
|
+
* Returns an array of Output objects being spent by each input.
|
|
79
|
+
* This is required for SIGHASH_LOTUS signature algorithm.
|
|
80
|
+
*
|
|
81
|
+
* @returns Array of outputs, or undefined if any input is missing output info
|
|
82
|
+
*/
|
|
59
83
|
get spentOutputs(): Output[] | undefined;
|
|
60
84
|
constructor(serialized?: TransactionData | Transaction | Buffer | string);
|
|
61
85
|
static create(serialized?: TransactionData | Transaction | Buffer | string): Transaction;
|
|
86
|
+
/**
|
|
87
|
+
* Create a 'shallow' copy of the transaction, by serializing and deserializing
|
|
88
|
+
* it dropping any additional information that inputs and outputs may have hold
|
|
89
|
+
*/
|
|
62
90
|
static shallowCopy(transaction: Transaction): Transaction;
|
|
91
|
+
/**
|
|
92
|
+
* Create from buffer
|
|
93
|
+
*/
|
|
63
94
|
static fromBuffer(buffer: Buffer): Transaction;
|
|
95
|
+
/**
|
|
96
|
+
* Create from buffer reader
|
|
97
|
+
*/
|
|
64
98
|
static fromBufferReader(reader: BufferReader): Transaction;
|
|
99
|
+
/**
|
|
100
|
+
* Create from object
|
|
101
|
+
*/
|
|
65
102
|
static fromObject(arg: TransactionData | Transaction): Transaction;
|
|
103
|
+
/**
|
|
104
|
+
* Create from string
|
|
105
|
+
*/
|
|
66
106
|
static fromString(str: string): Transaction;
|
|
107
|
+
/**
|
|
108
|
+
* Get the transaction hash (little endian)
|
|
109
|
+
*/
|
|
67
110
|
get hash(): string;
|
|
68
111
|
get hashBuffer(): Buffer;
|
|
112
|
+
/**
|
|
113
|
+
* Get the transaction ID (little endian)
|
|
114
|
+
*/
|
|
69
115
|
get id(): string;
|
|
116
|
+
/**
|
|
117
|
+
* Get the transaction ID (little endian)
|
|
118
|
+
*/
|
|
70
119
|
get txid(): string;
|
|
71
120
|
get txidBuffer(): Buffer;
|
|
121
|
+
/**
|
|
122
|
+
* Get the total input amount
|
|
123
|
+
*/
|
|
72
124
|
get inputAmount(): number;
|
|
125
|
+
/**
|
|
126
|
+
* Get the total output amount
|
|
127
|
+
*/
|
|
73
128
|
get outputAmount(): number;
|
|
74
129
|
get version(): number;
|
|
130
|
+
/** Satoshi-per-byte ratio for transaction fee calculation */
|
|
75
131
|
feePerByte(feePerByte: number): void;
|
|
132
|
+
/**
|
|
133
|
+
* Set fee
|
|
134
|
+
*/
|
|
76
135
|
fee(amount: number): void;
|
|
136
|
+
/**
|
|
137
|
+
* Set fee per KB
|
|
138
|
+
*/
|
|
77
139
|
feePerKb(amount: number): void;
|
|
140
|
+
/**
|
|
141
|
+
* Set version
|
|
142
|
+
*/
|
|
78
143
|
set version(version: number);
|
|
144
|
+
/**
|
|
145
|
+
* Retrieve the little endian hash of the transaction (used for serialization)
|
|
146
|
+
*/
|
|
79
147
|
private _getHash;
|
|
148
|
+
/**
|
|
149
|
+
* Get transaction ID hash
|
|
150
|
+
*/
|
|
80
151
|
private _getTxid;
|
|
152
|
+
/**
|
|
153
|
+
* Iterate through each input in the transaction and return an array of hashes
|
|
154
|
+
*/
|
|
81
155
|
private _getTxInputHashes;
|
|
156
|
+
/**
|
|
157
|
+
* Iterate through each output in the transaction and return an array of hashes
|
|
158
|
+
*/
|
|
82
159
|
private _getTxOutputHashes;
|
|
160
|
+
/**
|
|
161
|
+
* Compute the merkle root and return the merkle root and the height of the merkle tree
|
|
162
|
+
*/
|
|
83
163
|
private _computeMerkleRoot;
|
|
164
|
+
/**
|
|
165
|
+
* Get the total input amount
|
|
166
|
+
*/
|
|
84
167
|
private _getInputAmount;
|
|
168
|
+
/**
|
|
169
|
+
* Get the total output amount
|
|
170
|
+
*/
|
|
85
171
|
private _getOutputAmount;
|
|
172
|
+
/**
|
|
173
|
+
* Initialize a new transaction
|
|
174
|
+
*/
|
|
86
175
|
private _newTransaction;
|
|
176
|
+
/**
|
|
177
|
+
* Serialize transaction to hex string
|
|
178
|
+
*/
|
|
87
179
|
serialize(unsafe?: boolean | {
|
|
88
180
|
disableAll?: boolean;
|
|
89
181
|
}): string;
|
|
182
|
+
/**
|
|
183
|
+
* Unchecked serialization (no validation)
|
|
184
|
+
*/
|
|
90
185
|
uncheckedSerialize(): string;
|
|
186
|
+
/**
|
|
187
|
+
* Checked serialization (with validation)
|
|
188
|
+
*/
|
|
91
189
|
checkedSerialize(opts?: {
|
|
92
190
|
disableAll?: boolean;
|
|
93
191
|
disableDustOutputs?: boolean;
|
|
94
192
|
disableIsFullySigned?: boolean;
|
|
95
193
|
}): string;
|
|
194
|
+
/**
|
|
195
|
+
* Get serialization error if any
|
|
196
|
+
*/
|
|
96
197
|
getSerializationError(opts?: {
|
|
97
198
|
disableAll?: boolean;
|
|
98
199
|
disableDustOutputs?: boolean;
|
|
99
200
|
disableIsFullySigned?: boolean;
|
|
100
201
|
}): Error | null;
|
|
202
|
+
/**
|
|
203
|
+
* Check for dust outputs
|
|
204
|
+
*/
|
|
101
205
|
private _hasDustOutputs;
|
|
206
|
+
/**
|
|
207
|
+
* Check for missing signatures
|
|
208
|
+
*/
|
|
102
209
|
private _isMissingSignatures;
|
|
210
|
+
/**
|
|
211
|
+
* Check if transaction has invalid satoshis
|
|
212
|
+
*/
|
|
103
213
|
private _hasInvalidSatoshis;
|
|
214
|
+
/**
|
|
215
|
+
* Check if transaction is fully signed
|
|
216
|
+
*/
|
|
104
217
|
isFullySigned(): boolean;
|
|
218
|
+
/**
|
|
219
|
+
* Convert to Buffer
|
|
220
|
+
*/
|
|
105
221
|
toBuffer(): Buffer;
|
|
222
|
+
/**
|
|
223
|
+
* Write to BufferWriter
|
|
224
|
+
*/
|
|
106
225
|
toBufferWriter(writer?: BufferWriter): BufferWriter;
|
|
226
|
+
/**
|
|
227
|
+
* Deserialize from Buffer
|
|
228
|
+
*/
|
|
107
229
|
fromBuffer(buffer: Buffer): Transaction;
|
|
230
|
+
/**
|
|
231
|
+
* Deserialize from BufferReader
|
|
232
|
+
*/
|
|
108
233
|
fromBufferReader(reader: BufferReader): Transaction;
|
|
234
|
+
/**
|
|
235
|
+
* Deserialize from hex string
|
|
236
|
+
*/
|
|
109
237
|
fromString(str: string): Transaction;
|
|
238
|
+
/**
|
|
239
|
+
* Convert to object
|
|
240
|
+
*/
|
|
110
241
|
toObject(): TransactionObject;
|
|
242
|
+
/**
|
|
243
|
+
* Convert to JSON
|
|
244
|
+
*/
|
|
111
245
|
toJSON: () => TransactionObject;
|
|
246
|
+
/**
|
|
247
|
+
* Deserialize from object
|
|
248
|
+
*/
|
|
112
249
|
fromObject(arg: TransactionData | Transaction): Transaction;
|
|
250
|
+
/**
|
|
251
|
+
* Add an input to the transaction
|
|
252
|
+
*/
|
|
113
253
|
addInput(input: Input): Transaction;
|
|
254
|
+
/**
|
|
255
|
+
* Add an output to the transaction
|
|
256
|
+
*/
|
|
114
257
|
addOutput(output: Output): Transaction;
|
|
258
|
+
/**
|
|
259
|
+
* Clone this transaction
|
|
260
|
+
*/
|
|
115
261
|
clone(): Transaction;
|
|
262
|
+
/**
|
|
263
|
+
* String representation
|
|
264
|
+
*/
|
|
116
265
|
toString(): string;
|
|
266
|
+
/**
|
|
267
|
+
* Inspect representation
|
|
268
|
+
*/
|
|
117
269
|
inspect(): string;
|
|
270
|
+
/**
|
|
271
|
+
* Add inputs from UTXOs
|
|
272
|
+
*/
|
|
118
273
|
from(utxos: UnspentOutput[] | UnspentOutputData[] | UnspentOutput | UnspentOutputData, pubkeys?: PublicKey[], threshold?: number, opts?: {
|
|
119
274
|
noSorting?: boolean;
|
|
120
275
|
}): Transaction;
|
|
276
|
+
/**
|
|
277
|
+
* Set change address
|
|
278
|
+
*/
|
|
121
279
|
change(address: Address | string): Transaction;
|
|
280
|
+
/**
|
|
281
|
+
* Add output to transaction
|
|
282
|
+
*/
|
|
122
283
|
to(address: Address | string | Array<{
|
|
123
284
|
address: Address | string;
|
|
124
285
|
satoshis: number;
|
|
125
286
|
}>, amount: number | string | bigint): Transaction;
|
|
287
|
+
/**
|
|
288
|
+
* Sign transaction
|
|
289
|
+
*
|
|
290
|
+
* Signs all inputs that can be signed with the provided private key(s).
|
|
291
|
+
* Supports multiple signature hash types including SIGHASH_LOTUS.
|
|
292
|
+
*
|
|
293
|
+
* Sighash Types:
|
|
294
|
+
* - SIGHASH_ALL | SIGHASH_FORKID (default): Signs all inputs and outputs
|
|
295
|
+
* - SIGHASH_ALL | SIGHASH_LOTUS | SIGHASH_FORKID: Uses Lotus merkle tree algorithm
|
|
296
|
+
* - Other combinations: SINGLE, ANYONECANPAY, etc.
|
|
297
|
+
*
|
|
298
|
+
* SIGHASH_LOTUS Requirements:
|
|
299
|
+
* - All inputs must have output information attached
|
|
300
|
+
* - Use transaction.from(utxo) to automatically attach output info
|
|
301
|
+
* - SIGHASH_LOTUS provides better scaling and validation efficiency
|
|
302
|
+
*
|
|
303
|
+
* @param privateKey - Private key(s) to sign with
|
|
304
|
+
* @param sigtype - Signature hash type (default: SIGHASH_ALL | SIGHASH_FORKID)
|
|
305
|
+
* @param signingMethod - 'ecdsa' or 'schnorr' (default: 'ecdsa')
|
|
306
|
+
* @returns this transaction (for chaining)
|
|
307
|
+
* @throws Error if SIGHASH_LOTUS is used but inputs are missing output info
|
|
308
|
+
*
|
|
309
|
+
* @example
|
|
310
|
+
* ```typescript
|
|
311
|
+
* // Standard signing with SIGHASH_FORKID
|
|
312
|
+
* tx.from(utxo).to(address, amount).sign(privateKey)
|
|
313
|
+
*
|
|
314
|
+
* // Sign with SIGHASH_LOTUS
|
|
315
|
+
* tx.from(utxo)
|
|
316
|
+
* .to(address, amount)
|
|
317
|
+
* .sign(privateKey, Signature.SIGHASH_ALL | Signature.SIGHASH_LOTUS | Signature.SIGHASH_FORKID)
|
|
318
|
+
*
|
|
319
|
+
* // Sign with Schnorr signatures
|
|
320
|
+
* tx.from(utxo).to(address, amount).sign(privateKey, null, 'schnorr')
|
|
321
|
+
* ```
|
|
322
|
+
*/
|
|
126
323
|
sign(privateKey: PrivateKey | string | Array<PrivateKey | string>, sigtype?: number | null, signingMethod?: SignatureSigningMethod): Transaction;
|
|
324
|
+
/**
|
|
325
|
+
* Signs the transaction using the Schnorr signature algorithm with SIGHASH_LOTUS.
|
|
326
|
+
*
|
|
327
|
+
* This method is a convenience wrapper for signing Taproot and Lotus-native transactions,
|
|
328
|
+
* as Taproot and SIGHASH_LOTUS require Schnorr signatures.
|
|
329
|
+
*
|
|
330
|
+
* - Uses SIGHASH_ALL | SIGHASH_LOTUS as the signature hash type.
|
|
331
|
+
* - Applies to all inputs, signing each individually.
|
|
332
|
+
* - Accepts a single private key, a WIF string, or an array of keys/WIFs.
|
|
333
|
+
*
|
|
334
|
+
* @param privateKey - Single private key, WIF string, or array of either.
|
|
335
|
+
* @returns This Transaction instance (for chaining).
|
|
336
|
+
*
|
|
337
|
+
* @example
|
|
338
|
+
* tx.signSchnorr(myTaprootKey)
|
|
339
|
+
* tx.signSchnorr(['key1', 'key2'])
|
|
340
|
+
*/
|
|
127
341
|
signSchnorr(privateKey: PrivateKey | string | Array<PrivateKey | string>): Transaction;
|
|
342
|
+
/**
|
|
343
|
+
* Get all MuSig2 Taproot inputs in this transaction
|
|
344
|
+
*
|
|
345
|
+
* Returns an array of MuSigTaprootInput instances that require
|
|
346
|
+
* multi-party signing coordination.
|
|
347
|
+
*
|
|
348
|
+
* @returns Array of MuSig2 Taproot inputs
|
|
349
|
+
*
|
|
350
|
+
* @example
|
|
351
|
+
* ```typescript
|
|
352
|
+
* const musigInputs = tx.getMuSig2Inputs()
|
|
353
|
+
* for (const input of musigInputs) {
|
|
354
|
+
* // Coordinate signing for each MuSig2 input
|
|
355
|
+
* }
|
|
356
|
+
* ```
|
|
357
|
+
*/
|
|
128
358
|
getMuSig2Inputs(): MuSig2TaprootInput[];
|
|
359
|
+
/**
|
|
360
|
+
* Get sighash for a MuSig2 Taproot input
|
|
361
|
+
*
|
|
362
|
+
* Computes the transaction hash that needs to be signed for a specific
|
|
363
|
+
* MuSig2 Taproot input using SIGHASH_ALL | SIGHASH_LOTUS.
|
|
364
|
+
*
|
|
365
|
+
* @param inputIndex - Index of the MuSig2 input
|
|
366
|
+
* @returns 32-byte sighash buffer to be signed
|
|
367
|
+
* @throws Error if input is not a MuSigTaprootInput
|
|
368
|
+
*
|
|
369
|
+
* @example
|
|
370
|
+
* ```typescript
|
|
371
|
+
* const sighash = tx.getMuSig2Sighash(0)
|
|
372
|
+
* // Use this sighash to coordinate MuSig2 signing
|
|
373
|
+
* ```
|
|
374
|
+
*/
|
|
129
375
|
getMuSig2Sighash(inputIndex: number): Buffer;
|
|
376
|
+
/**
|
|
377
|
+
* Add a public nonce for a MuSig2 input
|
|
378
|
+
*
|
|
379
|
+
* During Round 1 of MuSig2 signing, each signer generates and shares
|
|
380
|
+
* their public nonces. Use this method to add received nonces to the input.
|
|
381
|
+
*
|
|
382
|
+
* @param inputIndex - Index of the MuSig2 input
|
|
383
|
+
* @param signerIndex - Index of the signer (0-based)
|
|
384
|
+
* @param nonce - Public nonce pair [R1, R2] from the signer
|
|
385
|
+
* @returns this transaction (for chaining)
|
|
386
|
+
* @throws Error if input is not a MuSigTaprootInput
|
|
387
|
+
*
|
|
388
|
+
* @example
|
|
389
|
+
* ```typescript
|
|
390
|
+
* // Alice adds Bob's nonce
|
|
391
|
+
* tx.addMuSig2Nonce(0, 1, [bobR1, bobR2])
|
|
392
|
+
* ```
|
|
393
|
+
*/
|
|
130
394
|
addMuSig2Nonce(inputIndex: number, signerIndex: number, nonce: [Point, Point]): Transaction;
|
|
395
|
+
/**
|
|
396
|
+
* Add a partial signature for a MuSig2 input
|
|
397
|
+
*
|
|
398
|
+
* During Round 2 of MuSig2 signing, each signer generates and shares
|
|
399
|
+
* their partial signatures. Use this method to add received partial
|
|
400
|
+
* signatures to the input.
|
|
401
|
+
*
|
|
402
|
+
* @param inputIndex - Index of the MuSig2 input
|
|
403
|
+
* @param signerIndex - Index of the signer (0-based)
|
|
404
|
+
* @param partialSig - Partial signature from the signer
|
|
405
|
+
* @returns this transaction (for chaining)
|
|
406
|
+
* @throws Error if input is not a MuSigTaprootInput
|
|
407
|
+
*
|
|
408
|
+
* @example
|
|
409
|
+
* ```typescript
|
|
410
|
+
* // Alice adds Bob's partial signature
|
|
411
|
+
* tx.addMuSig2PartialSignature(0, 1, bobPartialSig)
|
|
412
|
+
* ```
|
|
413
|
+
*/
|
|
131
414
|
addMuSig2PartialSignature(inputIndex: number, signerIndex: number, partialSig: BN): Transaction;
|
|
415
|
+
/**
|
|
416
|
+
* Finalize all MuSig2 inputs
|
|
417
|
+
*
|
|
418
|
+
* Aggregates partial signatures for all MuSig2 inputs that have received
|
|
419
|
+
* all required partial signatures. This creates the final Schnorr signatures
|
|
420
|
+
* and adds them to the input scripts.
|
|
421
|
+
*
|
|
422
|
+
* @returns this transaction (for chaining)
|
|
423
|
+
* @throws Error if any MuSig2 input is missing partial signatures
|
|
424
|
+
*
|
|
425
|
+
* @example
|
|
426
|
+
* ```typescript
|
|
427
|
+
* // After all participants have shared partial signatures
|
|
428
|
+
* tx.finalizeMuSig2Signatures()
|
|
429
|
+
* console.log('Transaction ready to broadcast:', tx.serialize())
|
|
430
|
+
* ```
|
|
431
|
+
*/
|
|
132
432
|
finalizeMuSig2Signatures(): Transaction;
|
|
433
|
+
/**
|
|
434
|
+
* Get signatures for transaction
|
|
435
|
+
*
|
|
436
|
+
* Automatically detects input type and spending path, using appropriate sighash:
|
|
437
|
+
* - Taproot key-path: SIGHASH_ALL | SIGHASH_LOTUS (0x61) required
|
|
438
|
+
* - Taproot script-path: SIGHASH_ALL | SIGHASH_FORKID (0x41) default
|
|
439
|
+
* - Other inputs: SIGHASH_ALL | SIGHASH_FORKID (0x41)
|
|
440
|
+
*/
|
|
133
441
|
getSignatures(privKey: PrivateKey | string, sigtype?: number, signingMethod?: string): TransactionSignature[];
|
|
442
|
+
/**
|
|
443
|
+
* Apply signature to transaction
|
|
444
|
+
*/
|
|
134
445
|
applySignature(signature: TransactionSignature, signingMethod?: SignatureSigningMethod): Transaction;
|
|
446
|
+
/**
|
|
447
|
+
* Check if signature is valid
|
|
448
|
+
*/
|
|
135
449
|
isValidSignature(sig: TransactionSignature): boolean;
|
|
450
|
+
/**
|
|
451
|
+
* Verify signature
|
|
452
|
+
*/
|
|
136
453
|
verifySignature(sig: Signature, pubkey: PublicKey, nin: number, subscript: Script, satoshisBN: BN, flags?: number, signingMethod?: string): boolean;
|
|
454
|
+
/**
|
|
455
|
+
* Lock until date
|
|
456
|
+
*/
|
|
137
457
|
lockUntilDate(time: Date | number): Transaction;
|
|
458
|
+
/**
|
|
459
|
+
* Lock until block height
|
|
460
|
+
*/
|
|
138
461
|
lockUntilBlockHeight(height: number): Transaction;
|
|
462
|
+
/**
|
|
463
|
+
* Get lock time
|
|
464
|
+
*/
|
|
139
465
|
getLockTime(): Date | number | null;
|
|
466
|
+
/**
|
|
467
|
+
* Check if has all UTXO info
|
|
468
|
+
*/
|
|
140
469
|
hasAllUtxoInfo(): boolean;
|
|
470
|
+
/**
|
|
471
|
+
* Add data output
|
|
472
|
+
*/
|
|
141
473
|
addData(value: Buffer | string): Transaction;
|
|
474
|
+
/**
|
|
475
|
+
* Clear outputs
|
|
476
|
+
*/
|
|
142
477
|
clearOutputs(): Transaction;
|
|
478
|
+
/**
|
|
479
|
+
* Remove output
|
|
480
|
+
*/
|
|
143
481
|
removeOutput(index: number): void;
|
|
482
|
+
/**
|
|
483
|
+
* Sort transaction
|
|
484
|
+
*/
|
|
144
485
|
sort(): Transaction;
|
|
486
|
+
/**
|
|
487
|
+
* Sort inputs
|
|
488
|
+
*/
|
|
145
489
|
sortInputs(sortingFunction: (inputs: Input[]) => Input[]): Transaction;
|
|
490
|
+
/**
|
|
491
|
+
* Sort outputs
|
|
492
|
+
*/
|
|
146
493
|
sortOutputs(sortingFunction: (outputs: Output[]) => Output[]): Transaction;
|
|
494
|
+
/**
|
|
495
|
+
* Shuffle outputs
|
|
496
|
+
*/
|
|
147
497
|
shuffleOutputs(): Transaction;
|
|
498
|
+
/**
|
|
499
|
+
* Remove input
|
|
500
|
+
*/
|
|
148
501
|
removeInput(index: number): void;
|
|
502
|
+
/**
|
|
503
|
+
* Get fee
|
|
504
|
+
*/
|
|
149
505
|
getFee(): number;
|
|
506
|
+
/**
|
|
507
|
+
* Get change output
|
|
508
|
+
*/
|
|
150
509
|
getChangeOutput(): Output | null;
|
|
510
|
+
/**
|
|
511
|
+
* Verify transaction based on Lotus consensus rules
|
|
512
|
+
* Based on tx_check.cpp in lotusd
|
|
513
|
+
*/
|
|
151
514
|
verify(): string | boolean;
|
|
515
|
+
/**
|
|
516
|
+
* Verify all input scripts using the Interpreter
|
|
517
|
+
* This validates that each scriptSig properly satisfies its corresponding scriptPubkey
|
|
518
|
+
*
|
|
519
|
+
* @param flags - Script verification flags (optional, defaults to standard Lotus flags)
|
|
520
|
+
* @returns Object with success boolean and optional error message
|
|
521
|
+
*/
|
|
152
522
|
private _verifyScripts;
|
|
523
|
+
/**
|
|
524
|
+
* Check if coinbase
|
|
525
|
+
*/
|
|
153
526
|
isCoinbase(): boolean;
|
|
527
|
+
/**
|
|
528
|
+
* Add input without checking
|
|
529
|
+
*/
|
|
154
530
|
uncheckedAddInput(input: Input): Transaction;
|
|
155
531
|
private _newOutputOrder;
|
|
156
532
|
private _fromNonP2SH;
|
|
@@ -159,6 +535,9 @@ export declare class Transaction {
|
|
|
159
535
|
private _getUnspentValue;
|
|
160
536
|
private _clearSignatures;
|
|
161
537
|
private _estimateFee;
|
|
538
|
+
/**
|
|
539
|
+
* Calculate varint size for a number
|
|
540
|
+
*/
|
|
162
541
|
private static _getVarintSize;
|
|
163
542
|
private _estimateSize;
|
|
164
543
|
private _removeOutput;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../../../../../lib/bitcore/transaction/transaction.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../../../../../lib/bitcore/transaction/transaction.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAEvD,OAAO,EAAE,SAAS,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAA;AAGvE,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AACpC,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AAClE,OAAO,EACL,KAAK,EACL,WAAW,EAMX,kBAAkB,EACnB,MAAM,SAAS,CAAA;AAChB,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,EAAE,EAAE,EAAE,MAAM,cAAc,CAAA;AACjC,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAClD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAA;AAI5C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAErC,MAAM,WAAW,eAAe;IAC9B,OAAO,CAAC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,CAAC,eAAe;IAsBvB,OAAO,CAAC,YAAY;IA6EpB,OAAO,CAAC,iBAAiB;IAoDzB,OAAO,CAAC,mBAAmB;IAwB3B,OAAO,CAAC,gBAAgB;IAIxB,OAAO,CAAC,gBAAgB;IAMxB,OAAO,CAAC,YAAY;IAgBpB;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,cAAc;IAO7B,OAAO,CAAC,aAAa;IAsCrB,OAAO,CAAC,aAAa;IAKrB,OAAO,CAAC,UAAU;CAInB"}
|
|
@@ -26,6 +26,10 @@ export interface UnspentOutputObject {
|
|
|
26
26
|
scriptPubKey: string;
|
|
27
27
|
amount: number;
|
|
28
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* Represents an unspent output information: its script, associated amount and address,
|
|
31
|
+
* transaction id and output index.
|
|
32
|
+
*/
|
|
29
33
|
export declare class UnspentOutput {
|
|
30
34
|
readonly address?: Address;
|
|
31
35
|
readonly txId: string;
|
|
@@ -37,24 +41,81 @@ export declare class UnspentOutput {
|
|
|
37
41
|
readonly keyAggContext?: MuSig2KeyAggContext;
|
|
38
42
|
readonly mySignerIndex?: number;
|
|
39
43
|
constructor(data: UnspentOutputData);
|
|
44
|
+
/**
|
|
45
|
+
* Get the amount in XPI
|
|
46
|
+
*/
|
|
40
47
|
getXPI(): number;
|
|
48
|
+
/**
|
|
49
|
+
* Get the amount as a Unit object
|
|
50
|
+
*/
|
|
41
51
|
getUnit(): Unit;
|
|
52
|
+
/**
|
|
53
|
+
* Check if this unspent output is valid
|
|
54
|
+
*/
|
|
42
55
|
isValid(): boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Check if this unspent output is dust
|
|
58
|
+
*/
|
|
43
59
|
isDust(dustThreshold?: number): boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Convert to object representation
|
|
62
|
+
*/
|
|
44
63
|
toObject(): UnspentOutputObject;
|
|
64
|
+
/**
|
|
65
|
+
* Convert to JSON
|
|
66
|
+
*/
|
|
45
67
|
toJSON: () => UnspentOutputObject;
|
|
68
|
+
/**
|
|
69
|
+
* Debug representation
|
|
70
|
+
*/
|
|
46
71
|
inspect(): string;
|
|
72
|
+
/**
|
|
73
|
+
* Clone this unspent output
|
|
74
|
+
*/
|
|
47
75
|
clone(): UnspentOutput;
|
|
76
|
+
/**
|
|
77
|
+
* String representation: just "txid:index"
|
|
78
|
+
*/
|
|
48
79
|
toString(): string;
|
|
80
|
+
/**
|
|
81
|
+
* Check if this unspent output is a pay-to-public-key-hash output
|
|
82
|
+
*/
|
|
49
83
|
isPayToPublicKeyHash(): boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Check if this unspent output is a pay-to-script-hash output
|
|
86
|
+
*/
|
|
50
87
|
isPayToScriptHash(): boolean;
|
|
88
|
+
/**
|
|
89
|
+
* Check if this unspent output is a pay-to-taproot output
|
|
90
|
+
*/
|
|
51
91
|
isPayToTaproot(): boolean;
|
|
92
|
+
/**
|
|
93
|
+
* Get the address for this unspent output
|
|
94
|
+
*/
|
|
52
95
|
getAddress(): string | null;
|
|
96
|
+
/**
|
|
97
|
+
* Create from a list of unspent outputs
|
|
98
|
+
*/
|
|
53
99
|
static fromObject(obj: UnspentOutputData): UnspentOutput;
|
|
100
|
+
/**
|
|
101
|
+
* Create from a list of unspent outputs
|
|
102
|
+
*/
|
|
54
103
|
static fromObjects(objects: UnspentOutputData[]): UnspentOutput[];
|
|
104
|
+
/**
|
|
105
|
+
* Filter unspent outputs by address
|
|
106
|
+
*/
|
|
55
107
|
static filterByAddress(unspentOutputs: UnspentOutput[], address: string | Address): UnspentOutput[];
|
|
108
|
+
/**
|
|
109
|
+
* Filter unspent outputs by minimum amount
|
|
110
|
+
*/
|
|
56
111
|
static filterByMinAmount(unspentOutputs: UnspentOutput[], minAmount: number | bigint): UnspentOutput[];
|
|
112
|
+
/**
|
|
113
|
+
* Calculate total amount of unspent outputs
|
|
114
|
+
*/
|
|
57
115
|
static calculateTotal(unspentOutputs: UnspentOutput[]): number;
|
|
116
|
+
/**
|
|
117
|
+
* Select unspent outputs for a target amount (simple selection)
|
|
118
|
+
*/
|
|
58
119
|
static selectForAmount(unspentOutputs: UnspentOutput[], targetAmount: number | bigint): UnspentOutput[];
|
|
59
120
|
}
|
|
60
121
|
//# sourceMappingURL=unspentoutput.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unspentoutput.d.ts","sourceRoot":"","sources":["../../../../../lib/bitcore/transaction/unspentoutput.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAC9B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAA;AAC3D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAErC,MAAM,WAAW,iBAAiB;IAChC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAA;IACvC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAA;IACjC,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IAC1B,OAAO,CAAC,EAAE,OAAO,GAAG,MAAM,CAAA;IAE1B,cAAc,CAAC,EAAE,SAAS,GAAG,MAAM,GAAG,MAAM,CAAA;IAC5C,UAAU,CAAC,EAAE,MAAM,CAAA;IAEnB,aAAa,CAAC,EAAE,mBAAmB,CAAA;IACnC,aAAa,CAAC,EAAE,MAAM,CAAA;CACvB;AAED,MAAM,WAAW,mBA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