@bitgo/abstract-utxo 1.0.1-rc.0

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.
Files changed (48) hide show
  1. package/.eslintignore +5 -0
  2. package/CHANGELOG.md +11 -0
  3. package/LICENSE +191 -0
  4. package/README.md +1 -0
  5. package/dist/src/abstractUtxoCoin.d.ts +388 -0
  6. package/dist/src/abstractUtxoCoin.d.ts.map +1 -0
  7. package/dist/src/abstractUtxoCoin.js +955 -0
  8. package/dist/src/config.d.ts +7 -0
  9. package/dist/src/config.d.ts.map +1 -0
  10. package/dist/src/config.js +12 -0
  11. package/dist/src/index.d.ts +6 -0
  12. package/dist/src/index.d.ts.map +1 -0
  13. package/dist/src/index.js +18 -0
  14. package/dist/src/parseOutput.d.ts +22 -0
  15. package/dist/src/parseOutput.d.ts.map +1 -0
  16. package/dist/src/parseOutput.js +169 -0
  17. package/dist/src/recovery/RecoveryProvider.d.ts +18 -0
  18. package/dist/src/recovery/RecoveryProvider.d.ts.map +1 -0
  19. package/dist/src/recovery/RecoveryProvider.js +23 -0
  20. package/dist/src/recovery/backupKeyRecovery.d.ts +56 -0
  21. package/dist/src/recovery/backupKeyRecovery.d.ts.map +1 -0
  22. package/dist/src/recovery/backupKeyRecovery.js +273 -0
  23. package/dist/src/recovery/baseApi.d.ts +27 -0
  24. package/dist/src/recovery/baseApi.d.ts.map +1 -0
  25. package/dist/src/recovery/baseApi.js +73 -0
  26. package/dist/src/recovery/coingeckoApi.d.ts +9 -0
  27. package/dist/src/recovery/coingeckoApi.d.ts.map +1 -0
  28. package/dist/src/recovery/coingeckoApi.js +47 -0
  29. package/dist/src/recovery/crossChainRecovery.d.ts +95 -0
  30. package/dist/src/recovery/crossChainRecovery.d.ts.map +1 -0
  31. package/dist/src/recovery/crossChainRecovery.js +318 -0
  32. package/dist/src/recovery/index.d.ts +8 -0
  33. package/dist/src/recovery/index.d.ts.map +1 -0
  34. package/dist/src/recovery/index.js +20 -0
  35. package/dist/src/recovery/mempoolApi.d.ts +7 -0
  36. package/dist/src/recovery/mempoolApi.d.ts.map +1 -0
  37. package/dist/src/recovery/mempoolApi.js +33 -0
  38. package/dist/src/recovery/smartbitApi.d.ts +11 -0
  39. package/dist/src/recovery/smartbitApi.d.ts.map +1 -0
  40. package/dist/src/recovery/smartbitApi.js +36 -0
  41. package/dist/src/replayProtection.d.ts +5 -0
  42. package/dist/src/replayProtection.d.ts.map +1 -0
  43. package/dist/src/replayProtection.js +21 -0
  44. package/dist/src/sign.d.ts +29 -0
  45. package/dist/src/sign.d.ts.map +1 -0
  46. package/dist/src/sign.js +104 -0
  47. package/dist/tsconfig.tsbuildinfo +7371 -0
  48. package/package.json +55 -0
package/.eslintignore ADDED
@@ -0,0 +1,5 @@
1
+ node_modules
2
+ .idea
3
+ public
4
+ dist
5
+
package/CHANGELOG.md ADDED
@@ -0,0 +1,11 @@
1
+ # Change Log
2
+
3
+ All notable changes to this project will be documented in this file.
4
+ See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
+
6
+ ## 1.0.1-rc.0 (2022-06-10)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **abstract-utxo:** add bsv replay protection case ([5e166cb](https://github.com/BitGo/BitGoJS/commit/5e166cbbc89ff10bd59308debf8f43dd18de0c47))
package/LICENSE ADDED
@@ -0,0 +1,191 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ Copyright 2022 BitGo
180
+
181
+ Licensed under the Apache License, Version 2.0 (the "License");
182
+ you may not use this file except in compliance with the License.
183
+ You may obtain a copy of the License at
184
+
185
+ http://www.apache.org/licenses/LICENSE-2.0
186
+
187
+ Unless required by applicable law or agreed to in writing, software
188
+ distributed under the License is distributed on an "AS IS" BASIS,
189
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
190
+ See the License for the specific language governing permissions and
191
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1 @@
1
+ # BitGo abstract-utxo
@@ -0,0 +1,388 @@
1
+ /// <reference types="node" />
2
+ import * as utxolib from '@bitgo/utxo-lib';
3
+ import { Unspent } from '@bitgo/utxo-lib/dist/src/bitgo';
4
+ import { backupKeyRecovery, RecoverParams } from './recovery/backupKeyRecovery';
5
+ import { CrossChainRecoverySigned, CrossChainRecoveryUnsigned } from './recovery';
6
+ import { AddressCoinSpecific, BaseCoin, BitGoBase, ExtraPrebuildParamsOptions, HalfSignedUtxoTransaction, IRequestTracer, ITransactionExplanation as BaseTransactionExplanation, IWallet, Keychain, KeychainsTriplet, ParsedTransaction as BaseParsedTransaction, ParseTransactionOptions as BaseParseTransactionOptions, PrecreateBitGoOptions, PresignTransactionOptions, RequestTracer, SignedTransaction, SignTransactionOptions as BaseSignTransactionOptions, SupplementGenerateWalletOptions, TransactionParams as BaseTransactionParams, TransactionPrebuild as BaseTransactionPrebuild, Triple, VerificationOptions, VerifyAddressOptions as BaseVerifyAddressOptions, VerifyTransactionOptions as BaseVerifyTransactionOptions } from '@bitgo/sdk-core';
7
+ import { CustomChangeOptions } from './parseOutput';
8
+ import ScriptType2Of3 = utxolib.bitgo.outputScripts.ScriptType2Of3;
9
+ export interface VerifyAddressOptions extends BaseVerifyAddressOptions {
10
+ chain: number;
11
+ index: number;
12
+ }
13
+ export interface Output {
14
+ address: string;
15
+ amount: string | number;
16
+ external?: boolean;
17
+ needsCustomChangeKeySignatureVerification?: boolean;
18
+ }
19
+ export interface TransactionExplanation extends BaseTransactionExplanation<string, number> {
20
+ locktime: number;
21
+ outputs: Output[];
22
+ changeOutputs: Output[];
23
+ /**
24
+ * Number of input signatures per input.
25
+ */
26
+ inputSignatures: number[];
27
+ /**
28
+ * Highest input signature count for the transaction
29
+ */
30
+ signatures: number;
31
+ }
32
+ export interface TransactionInfo {
33
+ /** Maps txid to txhex. Required for offline signing. */
34
+ txHexes?: Record<string, string>;
35
+ changeAddresses?: string[];
36
+ unspents: Unspent[];
37
+ }
38
+ export interface ExplainTransactionOptions {
39
+ txHex: string;
40
+ txInfo?: TransactionInfo;
41
+ feeInfo?: string;
42
+ pubs?: Triple<string>;
43
+ }
44
+ export declare type UtxoNetwork = utxolib.Network;
45
+ export interface TransactionPrebuild extends BaseTransactionPrebuild {
46
+ txInfo?: TransactionInfo;
47
+ blockHeight?: number;
48
+ }
49
+ export interface TransactionParams extends BaseTransactionParams {
50
+ walletPassphrase?: string;
51
+ changeAddress?: string;
52
+ }
53
+ export interface ParseTransactionOptions extends BaseParseTransactionOptions {
54
+ txParams: TransactionParams;
55
+ txPrebuild: TransactionPrebuild;
56
+ wallet: IWallet;
57
+ verification?: VerificationOptions;
58
+ reqId?: IRequestTracer;
59
+ }
60
+ export interface ParsedTransaction extends BaseParsedTransaction {
61
+ keychains: {
62
+ user?: Keychain;
63
+ backup?: Keychain;
64
+ bitgo?: Keychain;
65
+ };
66
+ keySignatures: {
67
+ backupPub?: string;
68
+ bitgoPub?: string;
69
+ };
70
+ outputs: Output[];
71
+ missingOutputs: Output[];
72
+ explicitExternalOutputs: Output[];
73
+ implicitExternalOutputs: Output[];
74
+ changeOutputs: Output[];
75
+ explicitExternalSpendAmount: number;
76
+ implicitExternalSpendAmount: number;
77
+ needsCustomChangeKeySignatureVerification: boolean;
78
+ customChange?: CustomChangeOptions;
79
+ }
80
+ export interface GenerateAddressOptions {
81
+ addressType?: ScriptType2Of3;
82
+ keychains: {
83
+ pub: string;
84
+ aspKeyId?: string;
85
+ }[];
86
+ threshold?: number;
87
+ chain?: number;
88
+ index?: number;
89
+ segwit?: boolean;
90
+ bech32?: boolean;
91
+ }
92
+ export interface AddressDetails {
93
+ address: string;
94
+ chain: number;
95
+ index: number;
96
+ coin: string;
97
+ coinSpecific: AddressCoinSpecific;
98
+ addressType?: string;
99
+ }
100
+ export interface SignTransactionOptions extends BaseSignTransactionOptions {
101
+ /** Transaction prebuild from bitgo server */
102
+ txPrebuild: {
103
+ txHex: string;
104
+ txInfo: TransactionInfo;
105
+ };
106
+ /** xprv of user key or backup key */
107
+ prv: string;
108
+ /** xpubs triple for wallet (user, backup, bitgo) */
109
+ pubs: Triple<string>;
110
+ /** xpub for cosigner (defaults to bitgo) */
111
+ cosignerPub?: string;
112
+ /**
113
+ * When true, creates full-signed transaction without placeholder signatures.
114
+ * When false, creates half-signed transaction with placeholder signatures.
115
+ */
116
+ isLastSignature?: boolean;
117
+ }
118
+ export interface MultiSigAddress {
119
+ outputScript: Buffer;
120
+ redeemScript?: Buffer;
121
+ witnessScript?: Buffer;
122
+ address: string;
123
+ }
124
+ export interface RecoverFromWrongChainOptions {
125
+ txid: string;
126
+ recoveryAddress: string;
127
+ wallet: string;
128
+ walletPassphrase?: string;
129
+ xprv?: string;
130
+ /** @deprecated */
131
+ coin?: AbstractUtxoCoin;
132
+ recoveryCoin?: AbstractUtxoCoin;
133
+ signed?: boolean;
134
+ }
135
+ export interface AddressInfo {
136
+ txCount: number;
137
+ totalBalance: number;
138
+ }
139
+ export interface VerifyKeySignaturesOptions {
140
+ userKeychain?: Keychain;
141
+ keychainToVerify?: Keychain;
142
+ keySignature?: string;
143
+ }
144
+ export interface VerifyUserPublicKeyOptions {
145
+ userKeychain?: Keychain;
146
+ disableNetworking: boolean;
147
+ txParams: TransactionParams;
148
+ }
149
+ export interface VerifyTransactionOptions extends BaseVerifyTransactionOptions {
150
+ txPrebuild: TransactionPrebuild;
151
+ }
152
+ export interface UnspentParams {
153
+ id: string;
154
+ value: number;
155
+ valueString: string;
156
+ address: string;
157
+ blockHeight: number;
158
+ }
159
+ export declare abstract class AbstractUtxoCoin extends BaseCoin {
160
+ altScriptHash?: number;
161
+ supportAltScriptDestination?: boolean;
162
+ private readonly _network;
163
+ protected constructor(bitgo: BitGoBase, network: utxolib.Network);
164
+ get network(): utxolib.Network;
165
+ sweepWithSendMany(): boolean;
166
+ /** @deprecated */
167
+ static get validAddressTypes(): ScriptType2Of3[];
168
+ /**
169
+ * Returns the factor between the base unit and its smallest subdivison
170
+ * @return {number}
171
+ */
172
+ getBaseFactor(): number;
173
+ /**
174
+ * @deprecated
175
+ */
176
+ getCoinLibrary(): typeof utxolib;
177
+ /**
178
+ * Helper to get the version number for an address
179
+ */
180
+ protected getAddressVersion(address: string): number | undefined;
181
+ /**
182
+ * Helper to get the bech32 prefix for an address
183
+ */
184
+ protected getAddressPrefix(address: string): string | undefined;
185
+ /**
186
+ * Check if an address is valid
187
+ * @param address
188
+ * @param forceAltScriptSupport
189
+ */
190
+ isValidAddress(address: string, forceAltScriptSupport?: boolean): boolean;
191
+ /**
192
+ * Return boolean indicating whether input is valid public key for the coin.
193
+ *
194
+ * @param {String} pub the pub to be checked
195
+ * @returns {Boolean} is it valid?
196
+ */
197
+ isValidPub(pub: string): boolean;
198
+ /**
199
+ * Get the latest block height
200
+ * @param reqId
201
+ */
202
+ getLatestBlockHeight(reqId?: RequestTracer): Promise<number>;
203
+ /**
204
+ * Run custom coin logic after a transaction prebuild has been received from BitGo
205
+ * @param prebuild
206
+ */
207
+ postProcessPrebuild(prebuild: TransactionPrebuild): Promise<TransactionPrebuild>;
208
+ /**
209
+ * Find outputs that are within expected outputs but not within actual outputs, including duplicates
210
+ * @param expectedOutputs
211
+ * @param actualOutputs
212
+ * @returns {Array}
213
+ */
214
+ protected static findMissingOutputs(expectedOutputs: Output[], actualOutputs: Output[]): Output[];
215
+ /**
216
+ * Determine an address' type based on its witness and redeem script presence
217
+ * @param addressDetails
218
+ */
219
+ static inferAddressType(addressDetails: {
220
+ chain: number;
221
+ }): ScriptType2Of3 | null;
222
+ createTransactionFromHex(hex: string): utxolib.bitgo.UtxoTransaction;
223
+ /**
224
+ * Extract and fill transaction details such as internal/change spend, external spend (explicit vs. implicit), etc.
225
+ * @param params
226
+ * @returns {*}
227
+ */
228
+ parseTransaction(params: ParseTransactionOptions): Promise<ParsedTransaction>;
229
+ /**
230
+ * Decrypt the wallet's user private key and verify that the claimed public key matches
231
+ * @param {VerifyUserPublicKeyOptions} params
232
+ * @return {boolean}
233
+ * @protected
234
+ */
235
+ protected verifyUserPublicKey(params: VerifyUserPublicKeyOptions): boolean;
236
+ /**
237
+ * Verify signatures produced by the user key over the backup and bitgo keys.
238
+ *
239
+ * If set, these signatures ensure that the wallet keys cannot be changed after the wallet has been created.
240
+ * @param {VerifyKeySignaturesOptions} params
241
+ * @return {{backup: boolean, bitgo: boolean}}
242
+ */
243
+ protected verifyKeySignature(params: VerifyKeySignaturesOptions): boolean;
244
+ /**
245
+ * Verify signatures against the user private key over the change wallet extended keys
246
+ * @param {ParsedTransaction} tx
247
+ * @param {Keychain} userKeychain
248
+ * @return {boolean}
249
+ * @protected
250
+ */
251
+ protected verifyCustomChangeKeySignatures(tx: ParsedTransaction, userKeychain: Keychain): boolean;
252
+ /**
253
+ * Get the maximum percentage limit for pay-as-you-go outputs
254
+ *
255
+ * @protected
256
+ */
257
+ protected getPayGoLimit(allowPaygoOutput?: boolean): number;
258
+ /**
259
+ * Verify that a transaction prebuild complies with the original intention
260
+ *
261
+ * @param params
262
+ * @param params.txParams params object passed to send
263
+ * @param params.txPrebuild prebuild object returned by server
264
+ * @param params.txPrebuild.txHex prebuilt transaction's txHex form
265
+ * @param params.wallet Wallet object to obtain keys to verify against
266
+ * @param params.verification Object specifying some verification parameters
267
+ * @param params.verification.disableNetworking Disallow fetching any data from the internet for verification purposes
268
+ * @param params.verification.keychains Pass keychains manually rather than fetching them by id
269
+ * @param params.verification.addresses Address details to pass in for out-of-band verification
270
+ * @returns {boolean}
271
+ */
272
+ verifyTransaction(params: VerifyTransactionOptions): Promise<boolean>;
273
+ /**
274
+ * Make sure an address is valid and throw an error if it's not.
275
+ * @param params.address The address string on the network
276
+ * @param params.addressType
277
+ * @param params.keychains Keychain objects with xpubs
278
+ * @param params.coinSpecific Coin-specific details for the address such as a witness script
279
+ * @param params.chain Derivation chain
280
+ * @param params.index Derivation index
281
+ * @throws {InvalidAddressError}
282
+ * @throws {InvalidAddressDerivationPropertyError}
283
+ * @throws {UnexpectedAddressError}
284
+ */
285
+ isWalletAddress(params: VerifyAddressOptions): boolean;
286
+ /**
287
+ * Indicates whether coin supports a block target
288
+ * @returns {boolean}
289
+ */
290
+ supportsBlockTarget(): boolean;
291
+ /**
292
+ * @param addressType
293
+ * @returns true iff coin supports spending from unspentType
294
+ */
295
+ supportsAddressType(addressType: ScriptType2Of3): boolean;
296
+ /**
297
+ * @param chain
298
+ * @return true iff coin supports spending from chain
299
+ */
300
+ supportsAddressChain(chain: number): boolean;
301
+ keyIdsForSigning(): number[];
302
+ /**
303
+ * TODO(BG-11487): Remove addressType, segwit, and bech32 params in SDKv6
304
+ * Generate an address for a wallet based on a set of configurations
305
+ * @param params.addressType {string} Deprecated
306
+ * @param params.keychains {[object]} Array of objects with xpubs
307
+ * @param params.threshold {number} Minimum number of signatures
308
+ * @param params.chain {number} Derivation chain (see https://github.com/BitGo/unspents/blob/master/src/codes.ts for
309
+ * the corresponding address type of a given chain code)
310
+ * @param params.index {number} Derivation index
311
+ * @param params.segwit {boolean} Deprecated
312
+ * @param params.bech32 {boolean} Deprecated
313
+ * @returns {{chain: number, index: number, coin: number, coinSpecific: {outputScript, redeemScript}}}
314
+ */
315
+ generateAddress(params: GenerateAddressOptions): AddressDetails;
316
+ /**
317
+ * Assemble keychain and half-sign prebuilt transaction
318
+ * @param params - {@see SignTransactionOptions}
319
+ * @returns {Promise<SignedTransaction | HalfSignedUtxoTransaction>}
320
+ */
321
+ signTransaction(params: SignTransactionOptions): Promise<SignedTransaction | HalfSignedUtxoTransaction>;
322
+ /**
323
+ * @param unspent
324
+ * @returns {boolean}
325
+ */
326
+ isBitGoTaintedUnspent(unspent: Unspent): boolean;
327
+ /**
328
+ * @deprecated - use utxolib.bitgo.getDefaultSigHash(network) instead
329
+ * @returns {number}
330
+ */
331
+ get defaultSigHashType(): number;
332
+ /**
333
+ * @deprecated - use utxolib.bitcoin.verifySignature() instead
334
+ */
335
+ verifySignature(transaction: any, inputIndex: number, amount: number, verificationSettings?: {
336
+ signatureIndex?: number;
337
+ publicKey?: string;
338
+ }): boolean;
339
+ /**
340
+ * Decompose a raw transaction into useful information, such as the total amounts,
341
+ * change amounts, and transaction outputs.
342
+ * @param params
343
+ */
344
+ explainTransaction(params: ExplainTransactionOptions): Promise<TransactionExplanation>;
345
+ /**
346
+ * Create a multisig address of a given type from a list of keychains and a signing threshold
347
+ * @param addressType
348
+ * @param signatureThreshold
349
+ * @param keys
350
+ */
351
+ createMultiSigAddress(addressType: ScriptType2Of3, signatureThreshold: number, keys: Buffer[]): MultiSigAddress;
352
+ /**
353
+ * @deprecated - use {@see backupKeyRecovery}
354
+ * Builds a funds recovery transaction without BitGo
355
+ * @param params - {@see backupKeyRecovery}
356
+ */
357
+ recover(params: RecoverParams): ReturnType<typeof backupKeyRecovery>;
358
+ /**
359
+ * Recover coin that was sent to wrong chain
360
+ * @param params
361
+ * @param params.txid The txid of the faulty transaction
362
+ * @param params.recoveryAddress address to send recovered funds to
363
+ * @param params.wallet the wallet that received the funds
364
+ * @param params.recoveryCoin the coin type of the wallet that received the funds
365
+ * @param params.signed return a half-signed transaction (default=true)
366
+ * @param params.walletPassphrase the wallet passphrase
367
+ * @param params.xprv the unencrypted xprv (used instead of wallet passphrase)
368
+ * @returns {*}
369
+ */
370
+ recoverFromWrongChain(params: RecoverFromWrongChainOptions): Promise<CrossChainRecoverySigned | CrossChainRecoveryUnsigned>;
371
+ /**
372
+ * Generate bip32 key pair
373
+ *
374
+ * @param seed
375
+ * @returns {Object} object with generated pub and prv
376
+ */
377
+ generateKeyPair(seed: Buffer): {
378
+ pub: string;
379
+ prv: string;
380
+ };
381
+ getExtraPrebuildParams(buildParams: ExtraPrebuildParamsOptions): Promise<any>;
382
+ preCreateBitGo(params: PrecreateBitGoOptions): void;
383
+ presignTransaction(params: PresignTransactionOptions): Promise<any>;
384
+ supplementGenerateWallet(walletParams: SupplementGenerateWalletOptions, keychains: KeychainsTriplet): Promise<any>;
385
+ transactionDataAllowed(): boolean;
386
+ valuelessTransferAllowed(): boolean;
387
+ }
388
+ //# sourceMappingURL=abstractUtxoCoin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"abstractUtxoCoin.d.ts","sourceRoot":"","sources":["../../src/abstractUtxoCoin.ts"],"names":[],"mappings":";AAIA,OAAO,KAAK,OAAO,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAOL,OAAO,EAGR,MAAM,gCAAgC,CAAC;AAMxC,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAChF,OAAO,EAAE,wBAAwB,EAAE,0BAA0B,EAAqB,MAAM,YAAY,CAAC;AAErG,OAAO,EACL,mBAAmB,EAEnB,QAAQ,EACR,SAAS,EACT,0BAA0B,EAC1B,yBAAyB,EAIzB,cAAc,EACd,uBAAuB,IAAI,0BAA0B,EACrD,OAAO,EACP,QAAQ,EACR,gBAAgB,EAKhB,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