@bitgo/sdk-coin-iota 1.8.2 → 1.9.1

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.
@@ -1,6 +1,9 @@
1
- import { AuditDecryptedKeyParams, BaseCoin, BitGoBase, KeyPair, ParsedTransaction, SignTransactionOptions, SignedTransaction, VerifyTransactionOptions, MultisigType, MPCAlgorithm, TssVerifyAddressOptions, PopulatedIntent, PrebuildTransactionWithIntentOptions } from '@bitgo/sdk-core';
1
+ import { AuditDecryptedKeyParams, BaseCoin, BitGoBase, KeyPair, MPCAlgorithm, MPCConsolidationRecoveryOptions, MPCRecoveryOptions, MPCSweepTxs, MPCTxs, MultisigType, ParsedTransaction, PopulatedIntent, PrebuildTransactionWithIntentOptions, SignedTransaction, SignTransactionOptions, TssVerifyAddressOptions, VerifyTransactionOptions } from '@bitgo/sdk-core';
2
2
  import { BaseCoin as StaticsBaseCoin, CoinFamily } from '@bitgo/statics';
3
3
  import { ExplainTransactionOptions, IotaParseTransactionOptions, TransactionExplanation } from './lib/iface';
4
+ export interface IotaRecoveryOptions extends MPCRecoveryOptions {
5
+ fullnodeRpcUrl?: string;
6
+ }
4
7
  /**
5
8
  * IOTA coin implementation.
6
9
  * Supports TSS (Threshold Signature Scheme) with EDDSA algorithm.
@@ -93,6 +96,106 @@ export declare class Iota extends BaseCoin {
93
96
  * @param params - Parameters containing unspents data
94
97
  */
95
98
  setCoinSpecificFieldsInIntent(intent: PopulatedIntent, params: PrebuildTransactionWithIntentOptions): void;
99
+ /**
100
+ * Builds funds recovery transaction(s) without BitGo
101
+ *
102
+ * @param {IotaRecoveryOptions} params parameters needed to construct and
103
+ * (maybe) sign the transaction
104
+ *
105
+ * @returns {MPCTx | MPCSweepTxs} array of the serialized transaction hex strings and indices
106
+ * of the addresses being swept
107
+ */
108
+ recover(params: IotaRecoveryOptions): Promise<MPCTxs | MPCSweepTxs>;
109
+ /**
110
+ * Checks whether the address holds a positive balance of the specified token.
111
+ */
112
+ private hasTokenBalance;
113
+ /**
114
+ * Consolidates funds from multiple receive addresses to the base address (index 0).
115
+ * If walletPassphrase is not provided, returns unsigned transactions for offline signing
116
+ * (cold/custody wallet recovery). Otherwise, returns signed transactions.
117
+ *
118
+ * @param params - Consolidation recovery parameters
119
+ * @param params.bitgoKey - The commonKeychain (combined TSS public key)
120
+ * @param params.startingScanIndex - Starting address index to scan (default: 1)
121
+ * @param params.endingScanIndex - Ending address index to scan (default: startingScanIndex + 20)
122
+ * @param params.walletPassphrase - Optional passphrase for signing (omit for unsigned transactions)
123
+ * @returns MPCTxs (signed) or MPCSweepTxs (unsigned) containing all consolidation transactions
124
+ * @throws Error if no addresses with funds are found in the scan range
125
+ */
126
+ recoverConsolidations(params: MPCConsolidationRecoveryOptions): Promise<MPCTxs | MPCSweepTxs>;
127
+ /**
128
+ * Gets the total coin balance for an address.
129
+ *
130
+ * @param address - IOTA address to query
131
+ * @param rpcUrl - Optional RPC URL override
132
+ * @param coinType - Optional coin type (defaults to native IOTA)
133
+ * @returns Total balance as a bigint
134
+ */
135
+ private getBalance;
136
+ /**
137
+ * Fetches owned objects for an address via fullnode RPC.
138
+ * Handles pagination to retrieve all objects.
139
+ *
140
+ * @param address - IOTA address to query
141
+ * @param rpcUrl - Optional RPC URL override
142
+ * @param coinType - Optional coin type to filter objects (defaults to native IOTA)
143
+ * @returns Array of owned objects with balance information
144
+ */
145
+ private fetchOwnedObjects;
146
+ /**
147
+ * Makes JSON-RPC call to IOTA fullnode.
148
+ *
149
+ * @param url - Fullnode RPC URL
150
+ * @param method - RPC method name
151
+ * @param params - RPC parameters
152
+ * @returns RPC result
153
+ * @throws Error if RPC call fails
154
+ */
155
+ private makeRpcCall;
156
+ /**
157
+ * Gets the public node RPC URL from the centralized environment configuration.
158
+ *
159
+ * @returns RPC URL for the current BitGo environment
160
+ */
161
+ protected getPublicNodeUrl(): string;
162
+ /**
163
+ * Gets the native coin type identifier for filtering owned objects.
164
+ *
165
+ * @returns Native coin type string
166
+ */
167
+ private getNativeCoinType;
168
+ /**
169
+ * Prepares gas configuration for a recovery transaction.
170
+ *
171
+ * Gas estimation is done via a dry-run of a temporary transaction, then
172
+ * multiplied by DEFAULT_GAS_OVERHEAD (1.1x) as a safety buffer.
173
+ *
174
+ * @param ownedObjects - Native IOTA coin objects to use as gas payment
175
+ * @param senderAddress - Sender address for the transaction
176
+ * @param params - Recovery parameters (includes recoveryDestination, rpcUrl)
177
+ * @param paymentObjects - Optional token objects for token recovery
178
+ * @returns Gas budget, gas price, gas objects array, and total native balance
179
+ */
180
+ private prepareGasAndObjects;
181
+ private recoverIotaToken;
182
+ private signRecoveryTransaction;
183
+ /**
184
+ * Fetches current reference gas price from fullnode.
185
+ *
186
+ * @param rpcUrl - Optional RPC URL override
187
+ * @returns Current gas price
188
+ */
189
+ private fetchGasPrice;
190
+ /**
191
+ * Estimates gas for a transaction via dry run.
192
+ *
193
+ * @param txBase64 - Transaction in base64 format
194
+ * @param rpcUrl - Optional RPC URL override
195
+ * @returns Estimated gas cost
196
+ */
197
+ private estimateGas;
198
+ private buildUnsignedSweepTransaction;
96
199
  /**
97
200
  * Validates and extracts transaction hex from parameters.
98
201
  * @param txHex - The transaction hex to validate
@@ -1 +1 @@
1
- {"version":3,"file":"iota.d.ts","sourceRoot":"","sources":["../../src/iota.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,QAAQ,EACR,SAAS,EACT,OAAO,EACP,iBAAiB,EACjB,sBAAsB,EACtB,iBAAiB,EACjB,wBAAwB,EACxB,YAAY,EAEZ,YAAY,EACZ,uBAAuB,EAEvB,eAAe,EACf,oCAAoC,EAGrC,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,QAAQ,IAAI,eAAe,EAAE,UAAU,EAAS,MAAM,gBAAgB,CAAC;AAMhF,OAAO,EACL,yBAAyB,EACzB,2BAA2B,EAC3B,sBAAsB,EAEvB,MAAM,aAAa,CAAC;AAGrB;;;GAGG;AACH,qB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