@utexo/rgb-sdk 1.0.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.
@@ -0,0 +1,998 @@
1
+ /**
2
+ * RGB Crypto module types
3
+ *
4
+ * Type definitions for RGB-specific cryptographic operations including
5
+ * PSBT signing and key derivation for RGB protocol
6
+ */
7
+ /**
8
+ * Bitcoin network type
9
+ */
10
+ type Network = 'mainnet' | 'testnet' | 'testnet4' | 'signet' | 'regtest';
11
+ /**
12
+ * PSBT type (create_utxo or send)
13
+ */
14
+ type PsbtType = 'create_utxo' | 'send';
15
+ /**
16
+ * Network versions for BIP32
17
+ */
18
+ interface NetworkVersions {
19
+ bip32: {
20
+ public: number;
21
+ private: number;
22
+ };
23
+ wif: number;
24
+ }
25
+ /**
26
+ * Descriptors for wallet derivation
27
+ */
28
+ interface Descriptors {
29
+ external: string;
30
+ internal: string;
31
+ }
32
+ /**
33
+ * BDK SignOptions
34
+ */
35
+ interface BDKSignOptions {
36
+ }
37
+
38
+ interface SignPsbtOptions {
39
+ signOptions?: BDKSignOptions;
40
+ preprocess?: boolean;
41
+ }
42
+ /**
43
+ * Sign a PSBT using BDK
44
+ *
45
+ * Note: This function is async due to dependency loading and crypto operations.
46
+ *
47
+ * @param mnemonic - BIP39 mnemonic phrase (12 or 24 words)
48
+ * @param psbtBase64 - Base64 encoded PSBT string
49
+ * @param network - Bitcoin network ('mainnet' | 'testnet' | 'signet' | 'regtest')
50
+ * @param options - Optional signing options
51
+ * @param options.signOptions - BDK sign options (defaults used if not provided)
52
+ * @param options.preprocess - Force preprocessing (auto-detected by default)
53
+ * @returns Base64 encoded signed PSBT
54
+ * @throws {ValidationError} If mnemonic or PSBT format is invalid
55
+ * @throws {CryptoError} If signing fails
56
+ *
57
+ * @example
58
+ * ```typescript
59
+ * const signedPsbt = signPsbt(
60
+ * 'abandon abandon abandon...',
61
+ * 'cHNidP8BAIkBAAAAA...',
62
+ * 'testnet'
63
+ * );
64
+ * ```
65
+ */
66
+ declare function signPsbt(mnemonic: string, psbtBase64: string, network?: Network, options?: SignPsbtOptions): Promise<string>;
67
+ /**
68
+ * Legacy sync-named wrapper (still async under the hood).
69
+ */
70
+ declare function signPsbtSync(mnemonic: string, psbtBase64: string, network?: Network, options?: SignPsbtOptions): Promise<string>;
71
+ /**
72
+ * Sign a PSBT using a raw BIP39 seed (hex string or Uint8Array)
73
+ */
74
+ declare function signPsbtFromSeed(seed: string | Uint8Array, psbtBase64: string, network?: Network, options?: SignPsbtOptions): Promise<string>;
75
+ interface SignMessageParams {
76
+ message: string | Uint8Array;
77
+ seed: string | Uint8Array;
78
+ network?: Network;
79
+ }
80
+ interface VerifyMessageParams {
81
+ message: string | Uint8Array;
82
+ signature: string;
83
+ accountXpub: string;
84
+ network?: Network;
85
+ }
86
+ interface EstimateFeeResult {
87
+ fee: number;
88
+ vbytes: number;
89
+ feeRate: number;
90
+ }
91
+ declare function signMessage(params: SignMessageParams): Promise<string>;
92
+ declare function verifyMessage(params: VerifyMessageParams): Promise<boolean>;
93
+
94
+ interface GeneratedKeys {
95
+ mnemonic: string;
96
+ xpub: string;
97
+ accountXpubVanilla: string;
98
+ accountXpubColored: string;
99
+ masterFingerprint: string;
100
+ xpriv: string;
101
+ }
102
+ interface AccountXpubs {
103
+ account_xpub_vanilla: string;
104
+ account_xpub_colored: string;
105
+ }
106
+ /**
107
+ * Generate new wallet keys with a random mnemonic
108
+ * Mirrors rgb_lib::generate_keys (creates new 12-word mnemonic)
109
+ *
110
+ * @param bitcoinNetwork - Network string or number (default: 'regtest')
111
+ * @returns Promise resolving to generated keys including mnemonic, xpubs, and master fingerprint
112
+ * @throws {CryptoError} If key generation fails
113
+ *
114
+ * @example
115
+ * ```typescript
116
+ * const keys = await generateKeys('testnet');
117
+ * console.log('Mnemonic:', keys.mnemonic);
118
+ * console.log('Master Fingerprint:', keys.master_fingerprint);
119
+ * ```
120
+ */
121
+ declare function generateKeys(bitcoinNetwork?: string | number): Promise<GeneratedKeys>;
122
+ /**
123
+ * Derive wallet keys from existing mnemonic
124
+ * Takes a mnemonic phrase and derives all keys (xpubs, master fingerprint)
125
+ *
126
+ * This function is the counterpart to `generateKeys()` - instead of generating
127
+ * a new mnemonic, it derives keys from an existing one.
128
+ *
129
+ * @param bitcoinNetwork - Network string or number (default: 'regtest')
130
+ * @param mnemonic - BIP39 mnemonic phrase
131
+ * @returns Promise resolving to derived keys including mnemonic, xpubs, and master fingerprint
132
+ * @throws {ValidationError} If mnemonic is invalid
133
+ * @throws {CryptoError} If key derivation fails
134
+ *
135
+ * @example
136
+ * ```typescript
137
+ * const keys = await deriveKeysFromMnemonic('testnet', 'abandon abandon abandon...');
138
+ * console.log('Account XPub:', keys.account_xpub_vanilla);
139
+ * ```
140
+ */
141
+ declare function deriveKeysFromMnemonic(bitcoinNetwork: string | number | undefined, mnemonic: string): Promise<GeneratedKeys>;
142
+ /**
143
+ * Derive wallet keys directly from a BIP39 seed (hex string or Uint8Array)
144
+ */
145
+ declare function deriveKeysFromSeed(bitcoinNetwork: string | number | undefined, seed: string | Uint8Array): Promise<GeneratedKeys>;
146
+ /**
147
+ * Restore wallet keys from existing mnemonic (backward compatibility alias)
148
+ * @deprecated Use `deriveKeysFromMnemonic()` instead. This alias will be removed in a future version.
149
+ * @see deriveKeysFromMnemonic
150
+ */
151
+ declare function restoreKeys(bitcoinNetwork: string | number | undefined, mnemonic: string): Promise<GeneratedKeys>;
152
+ /**
153
+ * Get account xpubs from mnemonic (convenience function)
154
+ *
155
+ * @param bitcoinNetwork - Network string or number (default: 'regtest')
156
+ * @param mnemonic - BIP39 mnemonic phrase
157
+ * @returns Promise resolving to account xpubs for vanilla and colored keychains
158
+ * @throws {ValidationError} If mnemonic is invalid
159
+ * @throws {CryptoError} If key derivation fails
160
+ *
161
+ * @example
162
+ * ```typescript
163
+ * const xpubs = await accountXpubsFromMnemonic('testnet', 'abandon abandon abandon...');
164
+ * console.log('Vanilla XPub:', xpubs.account_xpub_vanilla);
165
+ * console.log('Colored XPub:', xpubs.account_xpub_colored);
166
+ * ```
167
+ */
168
+ /**
169
+ * Get master extended private key (xpriv) from mnemonic
170
+ *
171
+ * @param bitcoinNetwork - Network string or number (default: 'regtest')
172
+ * @param mnemonic - BIP39 mnemonic phrase (12 or 24 words)
173
+ * @returns Promise resolving to master xpriv (extended private key)
174
+ * @throws {ValidationError} If mnemonic is invalid
175
+ * @throws {CryptoError} If key derivation fails
176
+ *
177
+ * @example
178
+ * ```typescript
179
+ * const xpriv = await getXprivFromMnemonic('testnet', 'your mnemonic phrase here');
180
+ * console.log('Master xpriv:', xpriv);
181
+ * ```
182
+ */
183
+ declare function getXprivFromMnemonic(bitcoinNetwork: string | number | undefined, mnemonic: string): Promise<string>;
184
+ /**
185
+ * Get extended public key (xpub) from extended private key (xpriv)
186
+ *
187
+ * @param xpriv - Extended private key (base58 encoded)
188
+ * @returns Promise resolving to xpub (extended public key)
189
+ * @throws {CryptoError} If xpriv is invalid or derivation fails
190
+ *
191
+ * @example
192
+ * ```typescript
193
+ * const xpub = await getXpubFromXpriv('xprv...');
194
+ * console.log('xpub:', xpub);
195
+ * ```
196
+ */
197
+ declare function getXpubFromXpriv(xpriv: string, bitcoinNetwork?: string | number): Promise<string>;
198
+ /**
199
+ * Derive wallet keys from extended private key (xpriv)
200
+ * Similar to deriveKeysFromMnemonic but starts from xpriv instead of mnemonic
201
+ *
202
+ * @param bitcoinNetwork - Network string or number (default: 'regtest')
203
+ * @param xpriv - Extended private key (base58 encoded)
204
+ * @returns Promise resolving to generated keys (without mnemonic)
205
+ * @throws {ValidationError} If xpriv is invalid
206
+ * @throws {CryptoError} If key derivation fails
207
+ *
208
+ * @example
209
+ * ```typescript
210
+ * const keys = await deriveKeysFromXpriv('testnet', 'xprv...');
211
+ * console.log('Master Fingerprint:', keys.master_fingerprint);
212
+ * console.log('Account xpub vanilla:', keys.account_xpub_vanilla);
213
+ * ```
214
+ */
215
+ declare function deriveKeysFromXpriv(bitcoinNetwork: string | number | undefined, xpriv: string): Promise<GeneratedKeys>;
216
+ declare function accountXpubsFromMnemonic(bitcoinNetwork: string | number | undefined, mnemonic: string): Promise<AccountXpubs>;
217
+
218
+ type RGBHTTPClientParams = {
219
+ xpubVan: string;
220
+ xpubCol: string;
221
+ masterFingerprint: string;
222
+ rgbEndpoint: string;
223
+ };
224
+ interface FailTransfersRequest {
225
+ batchTransferIdx?: number;
226
+ noAssetOnly?: boolean;
227
+ skipSync?: boolean;
228
+ }
229
+ interface WalletBackupResponse {
230
+ message: string;
231
+ backupPath: string;
232
+ }
233
+ interface WalletRestoreResponse {
234
+ message: string;
235
+ }
236
+ interface RestoreWalletRequestModel {
237
+ backupFilePath: string;
238
+ password: string;
239
+ dataDir: string;
240
+ }
241
+ interface WitnessData {
242
+ amountSat: number;
243
+ blinding?: number;
244
+ }
245
+ interface InvoiceRequest {
246
+ amount: number;
247
+ assetId: string;
248
+ minConfirmations?: number;
249
+ durationSeconds?: number;
250
+ }
251
+ interface Recipient {
252
+ recipientId: string;
253
+ witnessData?: WitnessData;
254
+ amount: number;
255
+ transportEndpoints: string[];
256
+ }
257
+ interface IssueAssetNiaRequestModel {
258
+ ticker: string;
259
+ name: string;
260
+ amounts: number[];
261
+ precision: number;
262
+ }
263
+ interface IssueAssetIfaRequestModel {
264
+ ticker: string;
265
+ name: string;
266
+ precision: number;
267
+ amounts: number[];
268
+ inflationAmounts: number[];
269
+ replaceRightsNum: number;
270
+ rejectListUrl?: string;
271
+ }
272
+ interface SendAssetBeginRequestModel {
273
+ invoice: string;
274
+ witnessData?: WitnessData;
275
+ assetId?: string;
276
+ amount?: number;
277
+ feeRate?: number;
278
+ minConfirmations?: number;
279
+ }
280
+ interface SendAssetEndRequestModel {
281
+ signedPsbt: string;
282
+ skipSync?: boolean;
283
+ }
284
+ interface SendResult {
285
+ txid: string;
286
+ batchTransferIdx: number;
287
+ }
288
+ interface OperationResult {
289
+ txid: string;
290
+ batchTransferIdx: number;
291
+ }
292
+ interface CreateUtxosBeginRequestModel {
293
+ upTo?: boolean;
294
+ num?: number;
295
+ size?: number;
296
+ feeRate?: number;
297
+ }
298
+ interface CreateUtxosEndRequestModel {
299
+ signedPsbt: string;
300
+ skipSync?: boolean;
301
+ }
302
+ interface InflateAssetIfaRequestModel {
303
+ assetId: string;
304
+ inflationAmounts: number[];
305
+ feeRate?: number;
306
+ minConfirmations?: number;
307
+ }
308
+ interface InflateEndRequestModel {
309
+ signedPsbt: string;
310
+ }
311
+ interface SendBtcBeginRequestModel {
312
+ address: string;
313
+ amount: number;
314
+ feeRate: number;
315
+ skipSync?: boolean;
316
+ }
317
+ interface SendBtcEndRequestModel {
318
+ signedPsbt: string;
319
+ skipSync?: boolean;
320
+ }
321
+ interface GetFeeEstimationRequestModel {
322
+ blocks: number;
323
+ }
324
+ type GetFeeEstimationResponse = Record<string, number> | number;
325
+ declare enum TransactionType {
326
+ RGB_SEND = 0,
327
+ DRAIN = 1,
328
+ CREATE_UTXOS = 2,
329
+ USER = 3
330
+ }
331
+ interface BlockTime {
332
+ height: number;
333
+ timestamp: number;
334
+ }
335
+ interface Transaction {
336
+ transactionType: TransactionType;
337
+ txid: string;
338
+ received: number;
339
+ sent: number;
340
+ fee: number;
341
+ confirmationTime?: BlockTime;
342
+ }
343
+ declare enum TransferKind {
344
+ ISSUANCE = 0,
345
+ RECEIVE_BLIND = 1,
346
+ RECEIVE_WITNESS = 2,
347
+ SEND = 3,
348
+ INFLATION = 4
349
+ }
350
+ interface RgbTransfer {
351
+ idx: number;
352
+ batchTransferIdx: number;
353
+ createdAt: number;
354
+ updatedAt: number;
355
+ status: TransferStatus;
356
+ amount: number;
357
+ kind: TransferKind;
358
+ txid: string | null;
359
+ recipientId: string;
360
+ receiveUtxo: {
361
+ txid: string;
362
+ vout: number;
363
+ };
364
+ changeUtxo: {
365
+ txid: string;
366
+ vout: number;
367
+ } | null;
368
+ expiration: number;
369
+ transportEndpoints: {
370
+ endpoint: string;
371
+ transportType: number;
372
+ used: boolean;
373
+ }[];
374
+ }
375
+ declare enum TransferStatus {
376
+ WAITING_COUNTERPARTY = 0,
377
+ WAITING_CONFIRMATIONS = 1,
378
+ SETTLED = 2,
379
+ FAILED = 3
380
+ }
381
+ interface Unspent {
382
+ utxo: Utxo;
383
+ rgbAllocations: RgbAllocation[];
384
+ }
385
+ interface Utxo {
386
+ outpoint: {
387
+ txid: string;
388
+ vout: number;
389
+ };
390
+ btcAmount: number;
391
+ colorable: boolean;
392
+ }
393
+ interface RgbAllocation {
394
+ assetId: string;
395
+ amount: number;
396
+ settled: boolean;
397
+ }
398
+ interface Balance {
399
+ settled: number;
400
+ future: number;
401
+ spendable: number;
402
+ }
403
+ interface BtcBalance {
404
+ vanilla: Balance;
405
+ colored: Balance;
406
+ }
407
+ interface InvoiceReceiveData {
408
+ invoice: string;
409
+ recipientId: string;
410
+ expirationTimestamp: number;
411
+ batchTransferIdx: number;
412
+ }
413
+ interface AssetNIA {
414
+ /**
415
+ * @type {string}
416
+ * @memberof AssetNIA
417
+ * @example rgb:2dkSTbr-jFhznbPmo-TQafzswCN-av4gTsJjX-ttx6CNou5-M98k8Zd
418
+ */
419
+ assetId?: string;
420
+ /**
421
+ * @type {AssetIface}
422
+ * @memberof AssetNIA
423
+ */
424
+ assetIface?: AssetIface;
425
+ /**
426
+ * @type {string}
427
+ * @memberof AssetNIA
428
+ * @example USDT
429
+ */
430
+ ticker?: string;
431
+ /**
432
+ * @type {string}
433
+ * @memberof AssetNIA
434
+ * @example Tether
435
+ */
436
+ name?: string;
437
+ /**
438
+ * @type {string}
439
+ * @memberof AssetNIA
440
+ * @example asset details
441
+ */
442
+ details?: string;
443
+ /**
444
+ * @type {number}
445
+ * @memberof AssetNIA
446
+ * @example 0
447
+ */
448
+ precision?: number;
449
+ /**
450
+ * @type {number}
451
+ * @memberof AssetNIA
452
+ * @example 777
453
+ */
454
+ issuedSupply?: number;
455
+ /**
456
+ * @type {number}
457
+ * @memberof AssetNIA
458
+ * @example 1691160565
459
+ */
460
+ timestamp?: number;
461
+ /**
462
+ * @type {number}
463
+ * @memberof AssetNIA
464
+ * @example 1691161979
465
+ */
466
+ addedAt?: number;
467
+ /**
468
+ * @type {BtcBalance}
469
+ * @memberof AssetNIA
470
+ */
471
+ balance?: BtcBalance;
472
+ /**
473
+ * @type {Media}
474
+ * @memberof AssetNIA
475
+ */
476
+ media?: Media;
477
+ }
478
+ interface AssetIfa {
479
+ assetId: string;
480
+ ticker: string;
481
+ name: string;
482
+ details?: string;
483
+ precision: number;
484
+ initialSupply: number;
485
+ maxSupply: number;
486
+ knownCirculatingSupply: number;
487
+ timestamp: number;
488
+ addedAt: number;
489
+ balance: Balance;
490
+ media?: Media;
491
+ rejectListUrl?: string;
492
+ }
493
+ interface Media {
494
+ /**
495
+ * @type {string}
496
+ * @memberof Media
497
+ * @example /path/to/media
498
+ */
499
+ filePath?: string;
500
+ /**
501
+ * @type {string}
502
+ * @memberof Media
503
+ * @example text/plain
504
+ */
505
+ mime?: string;
506
+ }
507
+ declare enum AssetIface {
508
+ RGB20 = "RGB20",
509
+ RGB21 = "RGB21",
510
+ RGB25 = "RGB25"
511
+ }
512
+ declare enum AssetSchema {
513
+ Nia = "Nia",
514
+ Uda = "Uda",
515
+ Cfa = "Cfa"
516
+ }
517
+ /**
518
+ *
519
+ *
520
+ * @export
521
+ * @interface ListAssetsResponse
522
+ */
523
+ interface ListAssetsResponse {
524
+ /**
525
+ * @type {Array<AssetNIA>}
526
+ * @memberof ListAssetsResponse
527
+ */
528
+ nia?: Array<AssetNIA>;
529
+ /**
530
+ * @type {Array<AssetNIA>}
531
+ * @memberof ListAssetsResponse
532
+ */
533
+ uda?: Array<AssetNIA>;
534
+ /**
535
+ * @type {Array<AssetNIA>}
536
+ * @memberof ListAssetsResponse
537
+ */
538
+ cfa?: Array<AssetNIA>;
539
+ }
540
+ interface IssueAssetNIAResponse {
541
+ /**
542
+ * @type {AssetNIA}
543
+ * @memberof IssueAssetNIAResponse
544
+ */
545
+ asset?: AssetNIA;
546
+ }
547
+ /**
548
+ *
549
+ *
550
+ * @export
551
+ * @interface AssetBalanceResponse
552
+ */
553
+ interface AssetBalanceResponse {
554
+ /**
555
+ * @type {number}
556
+ * @memberof AssetBalanceResponse
557
+ * @example 777
558
+ */
559
+ settled?: number;
560
+ /**
561
+ * @type {number}
562
+ * @memberof AssetBalanceResponse
563
+ * @example 777
564
+ */
565
+ future?: number;
566
+ /**
567
+ * @type {number}
568
+ * @memberof AssetBalanceResponse
569
+ * @example 777
570
+ */
571
+ spendable?: number;
572
+ /**
573
+ * @type {number}
574
+ * @memberof AssetBalanceResponse
575
+ * @example 444
576
+ */
577
+ offchainOutbound?: number;
578
+ /**
579
+ * @type {number}
580
+ * @memberof AssetBalanceResponse
581
+ * @example 0
582
+ */
583
+ offchainInbound?: number;
584
+ }
585
+ interface DecodeRgbInvoiceResponse {
586
+ recipientId: string;
587
+ assetSchema?: string;
588
+ assetId?: string;
589
+ network: string;
590
+ assignment: Assignment;
591
+ assignmentName?: string;
592
+ expirationTimestamp?: number;
593
+ transportEndpoints: string[];
594
+ }
595
+ interface Assignment {
596
+ [key: string]: any;
597
+ }
598
+
599
+ /**
600
+ * Restore wallet from backup
601
+ * This should be called before creating a WalletManager instance
602
+ * @param params - Restore parameters including backup file path, password, and restore directory
603
+ * @returns Wallet restore response
604
+ */
605
+ declare const restoreFromBackup: (params: RestoreWalletRequestModel) => WalletRestoreResponse;
606
+ /**
607
+ * Generate a new wallet with keys
608
+ * @param network - Network string (default: 'regtest')
609
+ * @returns Generated keys including mnemonic, xpubs, and master fingerprint
610
+ */
611
+ declare const createWallet: (network?: string) => Promise<GeneratedKeys>;
612
+ type WalletInitParams = {
613
+ xpubVan: string;
614
+ xpubCol: string;
615
+ mnemonic?: string;
616
+ seed?: Uint8Array;
617
+ network?: string | number;
618
+ xpub?: string;
619
+ masterFingerprint: string;
620
+ transportEndpoint?: string;
621
+ indexerUrl?: string;
622
+ dataDir?: string;
623
+ };
624
+ /**
625
+ * Wallet Manager - High-level wallet interface combining RGB API client and cryptographic operations
626
+ *
627
+ * This class provides a unified interface for:
628
+ * - RGB operations (via RGBLibClient - local rgb-lib)
629
+ * - PSBT signing operations
630
+ * - Wallet state management
631
+ *
632
+ * @example
633
+ * ```typescript
634
+ * const keys = generateKeys('testnet');
635
+ * const wallet = new WalletManager({
636
+ * xpubVan: keys.accountXpubVanilla,
637
+ * xpubCol: keys.accountXpubColored,
638
+ * masterFingerprint: keys.masterFingerprint,
639
+ * mnemonic: keys.mnemonic,
640
+ * network: 'testnet',
641
+ * transportEndpoint: 'rpcs://proxy.iriswallet.com/0.2/json-rpc',
642
+ * indexerUrl: 'ssl://electrum.iriswallet.com:50013'
643
+ * });
644
+ *
645
+ * const balance = await wallet.getBtcBalance();
646
+ * ```
647
+ */
648
+ declare class WalletManager {
649
+ private readonly client;
650
+ private readonly xpub;
651
+ private readonly xpubVan;
652
+ private readonly xpubCol;
653
+ private mnemonic;
654
+ private seed;
655
+ private readonly network;
656
+ private readonly masterFingerprint;
657
+ private disposed;
658
+ private readonly dataDir;
659
+ constructor(params: WalletInitParams);
660
+ /**
661
+ * Get wallet's extended public keys
662
+ */
663
+ getXpub(): {
664
+ xpubVan: string;
665
+ xpubCol: string;
666
+ };
667
+ /**
668
+ * Get wallet's network
669
+ */
670
+ getNetwork(): Network;
671
+ /**
672
+ * Dispose of sensitive wallet data
673
+ * Clears mnemonic and seed from memory
674
+ * Idempotent - safe to call multiple times
675
+ */
676
+ dispose(): void;
677
+ /**
678
+ * Check if wallet has been disposed
679
+ */
680
+ isDisposed(): boolean;
681
+ /**
682
+ * Guard method to ensure wallet has not been disposed
683
+ * @throws {WalletError} if wallet has been disposed
684
+ */
685
+ private ensureNotDisposed;
686
+ registerWallet(): {
687
+ address: string;
688
+ btcBalance: BtcBalance;
689
+ };
690
+ getBtcBalance(): BtcBalance;
691
+ getAddress(): string;
692
+ listUnspents(): Unspent[];
693
+ listAssets(): ListAssetsResponse;
694
+ getAssetBalance(asset_id: string): AssetBalanceResponse;
695
+ createUtxosBegin(params: CreateUtxosBeginRequestModel): string;
696
+ createUtxosEnd(params: CreateUtxosEndRequestModel): number;
697
+ sendBegin(params: SendAssetBeginRequestModel): string;
698
+ sendEnd(params: SendAssetEndRequestModel): SendResult;
699
+ sendBtcBegin(params: SendBtcBeginRequestModel): string;
700
+ sendBtcEnd(params: SendBtcEndRequestModel): string;
701
+ estimateFeeRate(blocks: number): GetFeeEstimationResponse;
702
+ estimateFee(psbtBase64: string): Promise<EstimateFeeResult>;
703
+ sendBtc(params: SendBtcBeginRequestModel): Promise<string>;
704
+ blindReceive(params: InvoiceRequest): InvoiceReceiveData;
705
+ witnessReceive(params: InvoiceRequest): InvoiceReceiveData;
706
+ issueAssetNia(params: IssueAssetNiaRequestModel): AssetNIA;
707
+ issueAssetIfa(params: IssueAssetIfaRequestModel): AssetIfa;
708
+ inflateBegin(params: InflateAssetIfaRequestModel): string;
709
+ inflateEnd(params: InflateEndRequestModel): OperationResult;
710
+ /**
711
+ * Complete inflate operation: begin → sign → end
712
+ * @param params - Inflate parameters
713
+ * @param mnemonic - Optional mnemonic for signing
714
+ */
715
+ inflate(params: InflateAssetIfaRequestModel, mnemonic?: string): Promise<OperationResult>;
716
+ refreshWallet(): void;
717
+ listTransactions(): Transaction[];
718
+ listTransfers(asset_id?: string): RgbTransfer[];
719
+ failTransfers(params: FailTransfersRequest): boolean;
720
+ decodeRGBInvoice(params: {
721
+ invoice: string;
722
+ }): DecodeRgbInvoiceResponse;
723
+ createBackup(params: {
724
+ backupPath: string;
725
+ password: string;
726
+ }): WalletBackupResponse;
727
+ /**
728
+ * Sign a PSBT using the wallet's mnemonic or a provided mnemonic
729
+ * @param psbt - Base64 encoded PSBT
730
+ * @param mnemonic - Optional mnemonic (uses wallet's mnemonic if not provided)
731
+ */
732
+ signPsbt(psbt: string, mnemonic?: string): Promise<string>;
733
+ /**
734
+ * Complete send operation: begin → sign → end
735
+ * @param invoiceTransfer - Transfer invoice parameters
736
+ * @param mnemonic - Optional mnemonic for signing
737
+ */
738
+ send(invoiceTransfer: SendAssetBeginRequestModel, mnemonic?: string): Promise<SendResult>;
739
+ createUtxos({ upTo, num, size, feeRate }: {
740
+ upTo?: boolean;
741
+ num?: number;
742
+ size?: number;
743
+ feeRate?: number;
744
+ }): Promise<number>;
745
+ syncWallet(): void;
746
+ signMessage(message: string): Promise<string>;
747
+ verifyMessage(message: string, signature: string, accountXpub?: string): Promise<boolean>;
748
+ }
749
+ /**
750
+ * Factory function to create a WalletManager instance
751
+ * Provides a cleaner API than direct constructor
752
+ *
753
+ * @example
754
+ * ```typescript
755
+ * const keys = generateKeys('testnet');
756
+ * const wallet = createWalletManager({
757
+ * xpubVan: keys.accountXpubVanilla,
758
+ * xpubCol: keys.accountXpubColored,
759
+ * masterFingerprint: keys.masterFingerprint,
760
+ * mnemonic: keys.mnemonic,
761
+ * network: 'testnet',
762
+ * transportEndpoint: 'rpcs://proxy.iriswallet.com/0.2/json-rpc',
763
+ * indexerUrl: 'ssl://electrum.iriswallet.com:50013'
764
+ * });
765
+ * ```
766
+ */
767
+ declare function createWalletManager(params: WalletInitParams): WalletManager;
768
+ declare const wallet: WalletManager;
769
+
770
+ /**
771
+ * Custom error classes for the RGB SDK
772
+ */
773
+ /**
774
+ * Base SDK error class with error codes and context
775
+ */
776
+ declare class SDKError extends Error {
777
+ readonly code: string;
778
+ readonly statusCode?: number;
779
+ readonly cause?: Error;
780
+ constructor(message: string, code: string, statusCode?: number, cause?: Error);
781
+ /**
782
+ * Convert error to JSON for logging
783
+ */
784
+ toJSON(): {
785
+ name: string;
786
+ message: string;
787
+ code: string;
788
+ statusCode: number | undefined;
789
+ cause: string | undefined;
790
+ stack: string | undefined;
791
+ };
792
+ }
793
+ /**
794
+ * Network-related errors (API calls, connectivity)
795
+ */
796
+ declare class NetworkError extends SDKError {
797
+ constructor(message: string, statusCode?: number, cause?: Error);
798
+ }
799
+ /**
800
+ * Validation errors (invalid input parameters)
801
+ */
802
+ declare class ValidationError extends SDKError {
803
+ readonly field?: string;
804
+ constructor(message: string, field?: string);
805
+ }
806
+ /**
807
+ * Wallet-related errors (initialization, operations)
808
+ */
809
+ declare class WalletError extends SDKError {
810
+ constructor(message: string, code?: string, cause?: Error);
811
+ }
812
+ /**
813
+ * Cryptographic errors (signing, key derivation)
814
+ */
815
+ declare class CryptoError extends SDKError {
816
+ constructor(message: string, cause?: Error);
817
+ }
818
+ /**
819
+ * Configuration errors (missing or invalid configuration)
820
+ */
821
+ declare class ConfigurationError extends SDKError {
822
+ constructor(message: string, field?: string);
823
+ }
824
+ /**
825
+ * Bad request errors (400) - Invalid request parameters or data
826
+ */
827
+ declare class BadRequestError extends SDKError {
828
+ constructor(message: string, cause?: Error);
829
+ }
830
+ /**
831
+ * Not found errors (404) - Resource not found
832
+ */
833
+ declare class NotFoundError extends SDKError {
834
+ constructor(message: string, cause?: Error);
835
+ }
836
+ /**
837
+ * Conflict errors (409) - Resource conflict (e.g., wallet state already exists)
838
+ */
839
+ declare class ConflictError extends SDKError {
840
+ constructor(message: string, cause?: Error);
841
+ }
842
+ /**
843
+ * RGB Node errors (500, 502, 503, 504) - RGB Node server errors
844
+ */
845
+ declare class RgbNodeError extends SDKError {
846
+ constructor(message: string, statusCode: number, cause?: Error);
847
+ }
848
+
849
+ /**
850
+ * Logger utility for the SDK
851
+ * Provides structured logging with configurable log levels
852
+ */
853
+ declare enum LogLevel {
854
+ DEBUG = 0,
855
+ INFO = 1,
856
+ WARN = 2,
857
+ ERROR = 3,
858
+ NONE = 4
859
+ }
860
+ declare class Logger {
861
+ private level;
862
+ /**
863
+ * Set the log level
864
+ */
865
+ setLevel(level: LogLevel): void;
866
+ /**
867
+ * Get the current log level
868
+ */
869
+ getLevel(): LogLevel;
870
+ /**
871
+ * Log debug messages
872
+ */
873
+ debug(...args: unknown[]): void;
874
+ /**
875
+ * Log info messages
876
+ */
877
+ info(...args: unknown[]): void;
878
+ /**
879
+ * Log warning messages
880
+ */
881
+ warn(...args: unknown[]): void;
882
+ /**
883
+ * Log error messages
884
+ */
885
+ error(...args: unknown[]): void;
886
+ }
887
+ declare const logger: Logger;
888
+ /**
889
+ * Configure SDK logging
890
+ */
891
+ declare function configureLogging(level: LogLevel): void;
892
+
893
+ declare function isNode(): boolean;
894
+ declare function isBrowser(): boolean;
895
+ type Environment = 'node' | 'browser' | 'unknown';
896
+ declare function getEnvironment(): Environment;
897
+
898
+ declare function validateNetwork(network: string | number): asserts network is Network;
899
+ declare function normalizeNetwork(network: string | number): Network;
900
+ declare function validateMnemonic(mnemonic: unknown, field?: string): asserts mnemonic is string;
901
+ declare function validateBase64(base64: unknown, field?: string): asserts base64 is string;
902
+ declare function validatePsbt(psbt: unknown, field?: string): asserts psbt is string;
903
+ declare function validateHex(hex: unknown, field?: string): asserts hex is string;
904
+ declare function validateRequired<T>(value: T | null | undefined, field: string): asserts value is T;
905
+ declare function validateString(value: unknown, field: string): asserts value is string;
906
+
907
+ /**
908
+ * BIP32 derivation path constants
909
+ */
910
+ /**
911
+ * BIP86 (Taproot) purpose value
912
+ */
913
+ declare const DERIVATION_PURPOSE = 86;
914
+ /**
915
+ * Account index (account 0')
916
+ */
917
+ declare const DERIVATION_ACCOUNT = 0;
918
+ /**
919
+ * RGB keychain index
920
+ */
921
+ declare const KEYCHAIN_RGB = 0;
922
+ /**
923
+ * Bitcoin keychain index
924
+ */
925
+ declare const KEYCHAIN_BTC = 0;
926
+
927
+ /**
928
+ * Network-related constants
929
+ */
930
+ /**
931
+ * Coin type constants
932
+ */
933
+ declare const COIN_RGB_MAINNET = 827166;
934
+ declare const COIN_RGB_TESTNET = 827167;
935
+ declare const COIN_BITCOIN_MAINNET = 0;
936
+ declare const COIN_BITCOIN_TESTNET = 1;
937
+ /**
938
+ * Network string/number to Network type mapping
939
+ */
940
+ declare const NETWORK_MAP: {
941
+ readonly '0': "mainnet";
942
+ readonly '1': "testnet";
943
+ readonly '2': "testnet";
944
+ readonly '3': "regtest";
945
+ readonly signet: "signet";
946
+ readonly mainnet: "mainnet";
947
+ readonly testnet: "testnet";
948
+ readonly testnet4: "testnet4";
949
+ readonly regtest: "regtest";
950
+ };
951
+ /**
952
+ * BIP32 network version constants
953
+ * Note: testnet4 uses the same versions as testnet
954
+ */
955
+ declare const BIP32_VERSIONS: {
956
+ readonly mainnet: {
957
+ readonly public: 76067358;
958
+ readonly private: 76066276;
959
+ };
960
+ readonly testnet: {
961
+ readonly public: 70617039;
962
+ readonly private: 70615956;
963
+ };
964
+ readonly testnet4: {
965
+ readonly public: 70617039;
966
+ readonly private: 70615956;
967
+ };
968
+ readonly signet: {
969
+ readonly public: 70617039;
970
+ readonly private: 70615956;
971
+ };
972
+ readonly regtest: {
973
+ readonly public: 70617039;
974
+ readonly private: 70615956;
975
+ };
976
+ };
977
+
978
+ /**
979
+ * Default configuration values
980
+ */
981
+ /**
982
+ * Default network to use
983
+ */
984
+ declare const DEFAULT_NETWORK: "regtest";
985
+ /**
986
+ * Default API request timeout in milliseconds
987
+ */
988
+ declare const DEFAULT_API_TIMEOUT = 120000;
989
+ /**
990
+ * Default maximum number of retries for failed requests
991
+ */
992
+ declare const DEFAULT_MAX_RETRIES = 3;
993
+ /**
994
+ * Default log level
995
+ */
996
+ declare const DEFAULT_LOG_LEVEL = 3;
997
+
998
+ export { type AccountXpubs, type AssetBalanceResponse, type AssetIfa, AssetIface, type AssetNIA, AssetSchema, type Assignment, BIP32_VERSIONS, BadRequestError, type Balance, type BlockTime, type BtcBalance, COIN_BITCOIN_MAINNET, COIN_BITCOIN_TESTNET, COIN_RGB_MAINNET, COIN_RGB_TESTNET, ConfigurationError, ConflictError, type CreateUtxosBeginRequestModel, type CreateUtxosEndRequestModel, CryptoError, DEFAULT_API_TIMEOUT, DEFAULT_LOG_LEVEL, DEFAULT_MAX_RETRIES, DEFAULT_NETWORK, DERIVATION_ACCOUNT, DERIVATION_PURPOSE, type DecodeRgbInvoiceResponse, type Descriptors, type Environment, type FailTransfersRequest, type GeneratedKeys, type GetFeeEstimationRequestModel, type GetFeeEstimationResponse, type InflateAssetIfaRequestModel, type InflateEndRequestModel, type InvoiceReceiveData, type InvoiceRequest, type IssueAssetIfaRequestModel, type IssueAssetNIAResponse, type IssueAssetNiaRequestModel, KEYCHAIN_BTC, KEYCHAIN_RGB, type ListAssetsResponse, LogLevel, type Media, NETWORK_MAP, type Network, NetworkError, type NetworkVersions, NotFoundError, type OperationResult, type PsbtType, type RGBHTTPClientParams, type Recipient, type RestoreWalletRequestModel, type RgbAllocation, RgbNodeError, type RgbTransfer, SDKError, type SendAssetBeginRequestModel, type SendAssetEndRequestModel, type SendBtcBeginRequestModel, type SendBtcEndRequestModel, type SendResult, type SignPsbtOptions, type Transaction, TransactionType, TransferStatus, type Unspent, type Utxo, ValidationError, type WalletBackupResponse, WalletError, type WalletInitParams, WalletManager, type WalletRestoreResponse, type WitnessData, accountXpubsFromMnemonic, configureLogging, createWallet, createWalletManager, deriveKeysFromMnemonic, deriveKeysFromSeed, deriveKeysFromXpriv, generateKeys, getEnvironment, getXprivFromMnemonic, getXpubFromXpriv, isBrowser, isNode, logger, normalizeNetwork, restoreFromBackup, restoreKeys, signMessage, signPsbt, signPsbtFromSeed, signPsbtSync, validateBase64, validateHex, validateMnemonic, validateNetwork, validatePsbt, validateRequired, validateString, verifyMessage, wallet };