@utexo/rgb-sdk 1.0.5 → 1.0.6

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/index.cjs CHANGED
@@ -110,7 +110,7 @@ var CryptoError = class _CryptoError extends SDKError {
110
110
  }
111
111
  };
112
112
  var ConfigurationError = class _ConfigurationError extends SDKError {
113
- constructor(message, field) {
113
+ constructor(message, _field) {
114
114
  super(message, "CONFIGURATION_ERROR");
115
115
  this.name = "ConfigurationError";
116
116
  Object.setPrototypeOf(this, _ConfigurationError.prototype);
@@ -219,12 +219,12 @@ var mainnetPreset = {
219
219
  // TODO: Update to production network ID
220
220
  assets: [
221
221
  {
222
- assetId: "rgb:WPRv95Nj-icdrgPp-zpQhIp_-2TyJ~Ge-k~FvuMZ-~vVnkA0",
222
+ assetId: "rgb:nkHbmy97-R4cjRCe-j~VvT~E-0UQ0OW8-jOCCW6O-EqeCq9M",
223
223
  // TODO: Update to production asset ID
224
224
  tokenName: "tUSD",
225
225
  longName: "USDT",
226
226
  precision: 6,
227
- tokenId: 4
227
+ tokenId: 3
228
228
  }
229
229
  ]
230
230
  }),
@@ -234,12 +234,12 @@ var mainnetPreset = {
234
234
  // TODO: Update to production network ID
235
235
  assets: [
236
236
  {
237
- assetId: "rgb:WPRv95Nj-icdrgPp-zpQhIp_-2TyJ~Ge-k~FvuMZ-~vVnkA0",
237
+ assetId: "rgb:nkHbmy97-R4cjRCe-j~VvT~E-0UQ0OW8-jOCCW6O-EqeCq9M",
238
238
  // TODO: Update to production asset ID
239
239
  tokenName: "tUSD",
240
240
  longName: "USDT",
241
241
  precision: 6,
242
- tokenId: 4
242
+ tokenId: 3
243
243
  }
244
244
  ]
245
245
  }),
@@ -249,12 +249,12 @@ var mainnetPreset = {
249
249
  // TODO: Update to production network ID
250
250
  assets: [
251
251
  {
252
- assetId: "rgb:yJW4k8si-~8JdNfl-nM91qFu-r5rH_HS-1hM7jpi-L~lBf90",
252
+ assetId: "rgb:0yyfySrb-TArdWKB-6Y0yhUX-dbqMpN3-NnjsV2F-2fMhOI4",
253
253
  // TODO: Update to production asset ID
254
254
  tokenName: "tUSD",
255
255
  longName: "USDT",
256
256
  precision: 6,
257
- tokenId: 4
257
+ tokenId: 3
258
258
  }
259
259
  ]
260
260
  })
@@ -271,13 +271,18 @@ function getUtxoNetworkConfig(preset) {
271
271
  }
272
272
  var utexoNetworkMap = testnetPreset.networkMap;
273
273
  var utexoNetworkIdMap = testnetPreset.networkIdMap;
274
- function getDestinationAsset(senderNetwork, destinationNetwork, assetIdSender) {
275
- const destinationConfig = utexoNetworkIdMap[destinationNetwork];
274
+ function getDestinationAsset(senderNetwork, destinationNetwork, assetIdSender, networkIdMap) {
275
+ const config = networkIdMap ?? utexoNetworkIdMap;
276
+ const destinationConfig = config[destinationNetwork];
276
277
  if (assetIdSender == null) return destinationConfig.assets[0];
277
- const senderConfig = utexoNetworkIdMap[senderNetwork];
278
- const senderAsset = senderConfig.assets.find((a) => a.assetId === assetIdSender);
278
+ const senderConfig = config[senderNetwork];
279
+ const senderAsset = senderConfig.assets.find(
280
+ (a) => a.assetId === assetIdSender
281
+ );
279
282
  if (!senderAsset) return void 0;
280
- return destinationConfig.assets.find((a) => a.tokenId === senderAsset.tokenId);
283
+ return destinationConfig.assets.find(
284
+ (a) => a.tokenId === senderAsset.tokenId
285
+ );
281
286
  }
282
287
 
283
288
  // src/constants/network.ts
@@ -327,7 +332,13 @@ var DEFAULT_MAX_RETRIES = 3;
327
332
  var DEFAULT_LOG_LEVEL = 3;
328
333
 
329
334
  // src/utils/validation.ts
330
- var VALID_NETWORKS = ["mainnet", "testnet", "testnet4", "signet", "regtest"];
335
+ var VALID_NETWORKS = [
336
+ "mainnet",
337
+ "testnet",
338
+ "testnet4",
339
+ "signet",
340
+ "regtest"
341
+ ];
331
342
  function validateNetwork(network) {
332
343
  const key = String(network);
333
344
  const normalized = NETWORK_MAP[key];
@@ -366,6 +377,7 @@ function validateBase64(base64, field = "data") {
366
377
  try {
367
378
  Buffer.from(base64.trim(), "base64");
368
379
  } catch (error) {
380
+ console.error(error);
369
381
  throw new ValidationError(`Invalid base64 encoding for ${field}`, field);
370
382
  }
371
383
  }
@@ -373,7 +385,10 @@ function validatePsbt(psbt, field = "psbt") {
373
385
  validateBase64(psbt, field);
374
386
  const psbtString = String(psbt).trim();
375
387
  if (psbtString.length < 50) {
376
- throw new ValidationError(`${field} appears to be too short to be a valid PSBT`, field);
388
+ throw new ValidationError(
389
+ `${field} appears to be too short to be a valid PSBT`,
390
+ field
391
+ );
377
392
  }
378
393
  }
379
394
  function validateHex(hex, field = "data") {
@@ -397,11 +412,11 @@ function validateString(value, field) {
397
412
  }
398
413
  function mapNetworkToRgbLib(network) {
399
414
  const networkMap = {
400
- "mainnet": "Mainnet",
401
- "testnet": "Testnet",
402
- "testnet4": "Testnet4",
403
- "signet": "Signet",
404
- "regtest": "Regtest"
415
+ mainnet: "Mainnet",
416
+ testnet: "Testnet",
417
+ testnet4: "Testnet4",
418
+ signet: "Signet",
419
+ regtest: "Regtest"
405
420
  };
406
421
  const networkStr = String(network).toLowerCase();
407
422
  return networkMap[networkStr] || "Regtest";
@@ -412,7 +427,10 @@ var restoreWallet = (params) => {
412
427
  throw new ValidationError("Backup file not found", "backup");
413
428
  }
414
429
  if (!fs2__namespace.existsSync(dataDir)) {
415
- throw new ValidationError(`Restore directory does not exist: ${dataDir}`, "restoreDir");
430
+ throw new ValidationError(
431
+ `Restore directory does not exist: ${dataDir}`,
432
+ "restoreDir"
433
+ );
416
434
  }
417
435
  rgblib__default.default.restoreBackup(backupFilePath, password, dataDir);
418
436
  return {
@@ -422,7 +440,9 @@ var restoreWallet = (params) => {
422
440
  var restoreFromVss = (params) => {
423
441
  const anyLib = rgblib__default.default;
424
442
  if (typeof anyLib.restoreFromVss !== "function") {
425
- throw new WalletError("VSS restore is not available in the current rgb-lib build.");
443
+ throw new WalletError(
444
+ "VSS restore is not available in the current rgb-lib build."
445
+ );
426
446
  }
427
447
  if (!params.targetDir) {
428
448
  throw new ValidationError("targetDir is required", "targetDir");
@@ -465,7 +485,7 @@ var RGBLibClient = class {
465
485
  accountXpubColored: this.xpubCol,
466
486
  masterFingerprint: this.masterFingerprint,
467
487
  maxAllocationsPerUtxo: "1",
468
- vanillaKeychain: "1",
488
+ vanillaKeychain: "0",
469
489
  supportedSchemas: [
470
490
  rgblib__default.default.AssetSchema.Cfa,
471
491
  rgblib__default.default.AssetSchema.Nia,
@@ -476,7 +496,11 @@ var RGBLibClient = class {
476
496
  this.wallet = new rgblib__default.default.Wallet(new rgblib__default.default.WalletData(walletData));
477
497
  } catch (error) {
478
498
  console.log("error", error);
479
- throw new WalletError("Failed to initialize rgb-lib wallet", void 0, error);
499
+ throw new WalletError(
500
+ "Failed to initialize rgb-lib wallet",
501
+ void 0,
502
+ error
503
+ );
480
504
  }
481
505
  }
482
506
  /**
@@ -489,7 +513,11 @@ var RGBLibClient = class {
489
513
  try {
490
514
  this.online = this.wallet.goOnline(false, this.indexerUrl);
491
515
  } catch (error) {
492
- throw new WalletError("Failed to establish online connection", void 0, error);
516
+ throw new WalletError(
517
+ "Failed to establish online connection",
518
+ void 0,
519
+ error
520
+ );
493
521
  }
494
522
  }
495
523
  /**
@@ -526,7 +554,14 @@ var RGBLibClient = class {
526
554
  const size = params.size !== void 0 ? String(params.size) : null;
527
555
  const feeRate = params.feeRate ? String(params.feeRate) : "1";
528
556
  const skipSync = false;
529
- return this.wallet.createUtxosBegin(online, upTo, num, size, feeRate, skipSync);
557
+ return this.wallet.createUtxosBegin(
558
+ online,
559
+ upTo,
560
+ num,
561
+ size,
562
+ feeRate,
563
+ skipSync
564
+ );
530
565
  }
531
566
  createUtxosEnd(params) {
532
567
  const online = this.getOnline();
@@ -560,22 +595,33 @@ var RGBLibClient = class {
560
595
  transportEndpoints = [this.transportEndpoint];
561
596
  }
562
597
  if (!assetId) {
563
- throw new ValidationError("asset_id is required for send operation", "asset_id");
598
+ throw new ValidationError(
599
+ "asset_id is required for send operation",
600
+ "asset_id"
601
+ );
564
602
  }
565
603
  if (!recipientId) {
566
- throw new ValidationError("Could not extract recipient_id from invoice", "invoice");
604
+ throw new ValidationError(
605
+ "Could not extract recipient_id from invoice",
606
+ "invoice"
607
+ );
567
608
  }
568
609
  if (!amount) {
569
- throw new ValidationError("amount is required for send operation", "amount");
610
+ throw new ValidationError(
611
+ "amount is required for send operation",
612
+ "amount"
613
+ );
570
614
  }
571
615
  const assignment = { Fungible: amount };
572
616
  const recipientMap = {
573
- [assetId]: [{
574
- recipientId,
575
- witnessData,
576
- assignment,
577
- transportEndpoints
578
- }]
617
+ [assetId]: [
618
+ {
619
+ recipientId,
620
+ witnessData,
621
+ assignment,
622
+ transportEndpoints
623
+ }
624
+ ]
579
625
  };
580
626
  const psbt = this.wallet.sendBegin(
581
627
  online,
@@ -596,16 +642,25 @@ var RGBLibClient = class {
596
642
  const donation = params.donation ?? true;
597
643
  const { recipientMap } = params;
598
644
  if (!recipientMap || typeof recipientMap !== "object") {
599
- throw new ValidationError("recipientMap is required and must be a non-empty object", "recipientMap");
645
+ throw new ValidationError(
646
+ "recipientMap is required and must be a non-empty object",
647
+ "recipientMap"
648
+ );
600
649
  }
601
650
  const assetIds = Object.keys(recipientMap);
602
651
  if (assetIds.length === 0) {
603
- throw new ValidationError("recipientMap must contain at least one asset id", "recipientMap");
652
+ throw new ValidationError(
653
+ "recipientMap must contain at least one asset id",
654
+ "recipientMap"
655
+ );
604
656
  }
605
657
  for (const assetId of assetIds) {
606
658
  const recipients = recipientMap[assetId];
607
659
  if (!Array.isArray(recipients) || recipients.length === 0) {
608
- throw new ValidationError(`recipientMap["${assetId}"] must be a non-empty array of recipients`, "recipientMap");
660
+ throw new ValidationError(
661
+ `recipientMap["${assetId}"] must be a non-empty array of recipients`,
662
+ "recipientMap"
663
+ );
609
664
  }
610
665
  }
611
666
  const psbt = this.wallet.sendBegin(
@@ -650,8 +705,10 @@ var RGBLibClient = class {
650
705
  }
651
706
  }
652
707
  return result;
653
- } catch (error) {
654
- console.warn("rgb-lib estimation fee are not available, using default fee rate 2");
708
+ } catch (_error) {
709
+ console.warn(
710
+ "rgb-lib estimation fee are not available, using default fee rate 2"
711
+ );
655
712
  return 2;
656
713
  }
657
714
  }
@@ -693,14 +750,29 @@ var RGBLibClient = class {
693
750
  const amounts = params.amounts.map((a) => String(a));
694
751
  return this.wallet.issueAssetNIA(ticker, name, precision, amounts);
695
752
  }
753
+ // @ts-ignore
754
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
696
755
  issueAssetIfa(params) {
697
- throw new ValidationError("issueAssetIfa is not fully supported in rgb-lib. Use RGB Node server for IFA assets.", "asset");
756
+ throw new ValidationError(
757
+ "issueAssetIfa is not fully supported in rgb-lib. Use RGB Node server for IFA assets.",
758
+ "asset"
759
+ );
698
760
  }
761
+ // @ts-ignore
762
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
699
763
  inflateBegin(params) {
700
- throw new ValidationError("inflateBegin is not fully supported in rgb-lib. Use RGB Node server for inflation operations.", "asset");
764
+ throw new ValidationError(
765
+ "inflateBegin is not fully supported in rgb-lib. Use RGB Node server for inflation operations.",
766
+ "asset"
767
+ );
701
768
  }
769
+ // @ts-ignore
770
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
702
771
  inflateEnd(params) {
703
- throw new ValidationError("inflateEnd is not fully supported in rgb-lib. Use RGB Node server for inflation operations.", "asset");
772
+ throw new ValidationError(
773
+ "inflateEnd is not fully supported in rgb-lib. Use RGB Node server for inflation operations.",
774
+ "asset"
775
+ );
704
776
  }
705
777
  listAssets() {
706
778
  const filterAssetSchemas = [];
@@ -746,7 +818,12 @@ var RGBLibClient = class {
746
818
  const batchTransferIdx = params.batchTransferIdx !== void 0 ? params.batchTransferIdx : null;
747
819
  const noAssetOnly = params.noAssetOnly ?? false;
748
820
  const skipSync = params.skipSync ?? false;
749
- return this.wallet.failTransfers(online, batchTransferIdx, noAssetOnly, skipSync);
821
+ return this.wallet.failTransfers(
822
+ online,
823
+ batchTransferIdx,
824
+ noAssetOnly,
825
+ skipSync
826
+ );
750
827
  }
751
828
  deleteTransfers(params) {
752
829
  const batchTransferIdx = params.batchTransferIdx !== void 0 ? params.batchTransferIdx : null;
@@ -765,9 +842,15 @@ var RGBLibClient = class {
765
842
  throw new ValidationError("password is required", "password");
766
843
  }
767
844
  if (!fs2__namespace.existsSync(params.backupPath)) {
768
- throw new ValidationError(`Backup directory does not exist: ${params.backupPath}`, "backupPath");
845
+ throw new ValidationError(
846
+ `Backup directory does not exist: ${params.backupPath}`,
847
+ "backupPath"
848
+ );
769
849
  }
770
- const fullBackupPath = path3__namespace.join(params.backupPath, `${this.masterFingerprint}.backup`);
850
+ const fullBackupPath = path3__namespace.join(
851
+ params.backupPath,
852
+ `${this.masterFingerprint}.backup`
853
+ );
771
854
  this.wallet.backup(fullBackupPath, params.password);
772
855
  return {
773
856
  message: "Backup created successfully",
@@ -782,7 +865,9 @@ var RGBLibClient = class {
782
865
  const walletAny = this.wallet;
783
866
  const anyLib = rgblib__default.default;
784
867
  if (!walletAny || typeof anyLib.VssBackupClient !== "function" || typeof walletAny[methodName] !== "function") {
785
- throw new WalletError("VSS backup is not available in the current rgb-lib build.");
868
+ throw new WalletError(
869
+ "VSS backup is not available in the current rgb-lib build."
870
+ );
786
871
  }
787
872
  return { walletAny, anyLib };
788
873
  }
@@ -792,7 +877,9 @@ var RGBLibClient = class {
792
877
  configureVssBackup(config) {
793
878
  const walletAny = this.wallet;
794
879
  if (!walletAny || typeof walletAny.configureVssBackup !== "function") {
795
- throw new WalletError("VSS backup is not available in the current rgb-lib build.");
880
+ throw new WalletError(
881
+ "VSS backup is not available in the current rgb-lib build."
882
+ );
796
883
  }
797
884
  const mappedConfig = {
798
885
  server_url: config.serverUrl,
@@ -816,7 +903,9 @@ var RGBLibClient = class {
816
903
  disableVssAutoBackup() {
817
904
  const walletAny = this.wallet;
818
905
  if (!walletAny || typeof walletAny.disableVssAutoBackup !== "function") {
819
- throw new WalletError("VSS backup is not available in the current rgb-lib build.");
906
+ throw new WalletError(
907
+ "VSS backup is not available in the current rgb-lib build."
908
+ );
820
909
  }
821
910
  walletAny.disableVssAutoBackup();
822
911
  }
@@ -911,14 +1000,18 @@ function convertToArrayBuffer(data) {
911
1000
  const uint8 = new Uint8Array(data);
912
1001
  return uint8.buffer;
913
1002
  } catch (error) {
914
- throw new Error(`convertToArrayBuffer: Failed to convert data to ArrayBuffer: ${error instanceof Error ? error.message : String(error)}`);
1003
+ throw new Error(
1004
+ `convertToArrayBuffer: Failed to convert data to ArrayBuffer: ${error instanceof Error ? error.message : String(error)}`
1005
+ );
915
1006
  }
916
1007
  }
917
1008
  try {
918
1009
  const uint8 = new Uint8Array(data);
919
1010
  return uint8.buffer;
920
1011
  } catch (error) {
921
- throw new Error(`convertToArrayBuffer: Failed to convert data to ArrayBuffer: ${error instanceof Error ? error.message : String(error)}`);
1012
+ throw new Error(
1013
+ `convertToArrayBuffer: Failed to convert data to ArrayBuffer: ${error instanceof Error ? error.message : String(error)}`
1014
+ );
922
1015
  }
923
1016
  }
924
1017
  async function sha256(data) {
@@ -1040,14 +1133,18 @@ function normalizeSeedBuffer(seed) {
1040
1133
  try {
1041
1134
  seedBuffer = new Uint8Array(seed);
1042
1135
  } catch (error) {
1043
- throw new CryptoError(`Failed to convert seed to Uint8Array (buffer property invalid): ${error instanceof Error ? error.message : String(error)}`);
1136
+ throw new CryptoError(
1137
+ `Failed to convert seed to Uint8Array (buffer property invalid): ${error instanceof Error ? error.message : String(error)}`
1138
+ );
1044
1139
  }
1045
1140
  }
1046
1141
  } else {
1047
1142
  try {
1048
1143
  seedBuffer = new Uint8Array(seed);
1049
1144
  } catch (error) {
1050
- throw new CryptoError(`Failed to convert seed to Uint8Array: ${error instanceof Error ? error.message : String(error)}`);
1145
+ throw new CryptoError(
1146
+ `Failed to convert seed to Uint8Array: ${error instanceof Error ? error.message : String(error)}`
1147
+ );
1051
1148
  }
1052
1149
  }
1053
1150
  } else {
@@ -1077,7 +1174,9 @@ async function loadBaseDependencies() {
1077
1174
  const { createRequire } = await import(nodeModule);
1078
1175
  const requireFromModule = createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
1079
1176
  const bip392 = requireFromModule("bip39");
1080
- const eccModule2 = requireFromModule("@bitcoinerlab/secp256k1");
1177
+ const eccModule2 = requireFromModule(
1178
+ "@bitcoinerlab/secp256k1"
1179
+ );
1081
1180
  const ecc2 = eccModule2 && typeof eccModule2 === "object" && "default" in eccModule2 ? eccModule2.default : eccModule2;
1082
1181
  const bip322 = requireFromModule("bip32");
1083
1182
  return {
@@ -1128,7 +1227,9 @@ async function loadSignerDependencies() {
1128
1227
  const Psbt2 = bitcoinjs.Psbt;
1129
1228
  const payments2 = bitcoinjs.payments;
1130
1229
  const networks2 = bitcoinjs.networks;
1131
- const bip3412 = requireFromModule("bitcoinjs-lib/src/payments/bip341.js");
1230
+ const bip3412 = requireFromModule(
1231
+ "bitcoinjs-lib/src/payments/bip341.js"
1232
+ );
1132
1233
  const toXOnly2 = bip3412.toXOnly || ((pubkey) => Buffer.from(pubkey.slice(1)));
1133
1234
  return {
1134
1235
  ...base,
@@ -1181,14 +1282,23 @@ function normalizeSeedInput(seed, field = "seed") {
1181
1282
  if (typeof seed === "string") {
1182
1283
  const trimmed = seed.trim();
1183
1284
  if (!trimmed) {
1184
- throw new ValidationError(`${field} must be a non-empty hex string`, field);
1285
+ throw new ValidationError(
1286
+ `${field} must be a non-empty hex string`,
1287
+ field
1288
+ );
1185
1289
  }
1186
1290
  const hex = trimmed.startsWith("0x") ? trimmed.slice(2) : trimmed;
1187
1291
  if (hex.length % 2 !== 0) {
1188
- throw new ValidationError(`${field} hex string must have even length`, field);
1292
+ throw new ValidationError(
1293
+ `${field} hex string must have even length`,
1294
+ field
1295
+ );
1189
1296
  }
1190
1297
  if (hex.length !== 128) {
1191
- throw new ValidationError(`${field} must be 64 bytes (128 hex characters)`, field);
1298
+ throw new ValidationError(
1299
+ `${field} must be 64 bytes (128 hex characters)`,
1300
+ field
1301
+ );
1192
1302
  }
1193
1303
  if (!/^[0-9a-fA-F]+$/.test(hex)) {
1194
1304
  throw new ValidationError(`${field} must be a valid hex string`, field);
@@ -1206,7 +1316,10 @@ function normalizeSeedInput(seed, field = "seed") {
1206
1316
  }
1207
1317
  return new Uint8Array(seed);
1208
1318
  }
1209
- throw new ValidationError(`${field} must be a 64-byte hex string or Uint8Array`, field);
1319
+ throw new ValidationError(
1320
+ `${field} must be a 64-byte hex string or Uint8Array`,
1321
+ field
1322
+ );
1210
1323
  }
1211
1324
  function getCoinType(bitcoinNetwork, rgb) {
1212
1325
  const net = toNetworkName(bitcoinNetwork);
@@ -1302,7 +1415,10 @@ async function buildKeysOutputFromSeed(seed, bitcoinNetwork) {
1302
1415
  try {
1303
1416
  root = bip32.fromSeed(seedBuffer, versions);
1304
1417
  } catch (error) {
1305
- throw new CryptoError("Failed to create BIP32 root node from seed", error);
1418
+ throw new CryptoError(
1419
+ "Failed to create BIP32 root node from seed",
1420
+ error
1421
+ );
1306
1422
  }
1307
1423
  return buildGeneratedKeysFromRoot(root, normalizedNetwork, "");
1308
1424
  }
@@ -1322,7 +1438,9 @@ async function generateKeys2(bitcoinNetwork = "regtest") {
1322
1438
  try {
1323
1439
  const { bip39 } = await ensureBaseDependencies();
1324
1440
  if (!bip39 || typeof bip39.generateMnemonic !== "function") {
1325
- throw new Error("bip39 not loaded. Dependencies may not have initialized correctly.");
1441
+ throw new Error(
1442
+ "bip39 not loaded. Dependencies may not have initialized correctly."
1443
+ );
1326
1444
  }
1327
1445
  const mnemonic = bip39.generateMnemonic(128);
1328
1446
  return await buildKeysOutput(mnemonic, bitcoinNetwork);
@@ -1331,8 +1449,10 @@ async function generateKeys2(bitcoinNetwork = "regtest") {
1331
1449
  throw new CryptoError("Failed to load dependencies", error);
1332
1450
  }
1333
1451
  const errorMessage = error instanceof Error ? error.message : String(error);
1334
- error instanceof Error ? error.stack : void 0;
1335
- throw new CryptoError(`Failed to generate mnemonic: ${errorMessage}`, error);
1452
+ throw new CryptoError(
1453
+ `Failed to generate mnemonic: ${errorMessage}`,
1454
+ error
1455
+ );
1336
1456
  }
1337
1457
  }
1338
1458
  async function deriveKeysFromMnemonic(bitcoinNetwork = "regtest", mnemonic) {
@@ -1342,14 +1462,20 @@ async function deriveKeysFromMnemonic(bitcoinNetwork = "regtest", mnemonic) {
1342
1462
  const { bip39 } = await ensureBaseDependencies();
1343
1463
  const trimmedMnemonic = mnemonic.trim();
1344
1464
  if (!bip39 || !bip39.validateMnemonic(trimmedMnemonic)) {
1345
- throw new ValidationError("Invalid mnemonic format - failed BIP39 validation", "mnemonic");
1465
+ throw new ValidationError(
1466
+ "Invalid mnemonic format - failed BIP39 validation",
1467
+ "mnemonic"
1468
+ );
1346
1469
  }
1347
1470
  return await buildKeysOutput(trimmedMnemonic, normalizedNetwork);
1348
1471
  } catch (error) {
1349
1472
  if (error instanceof ValidationError) {
1350
1473
  throw error;
1351
1474
  }
1352
- throw new CryptoError("Failed to derive keys from mnemonic", error);
1475
+ throw new CryptoError(
1476
+ "Failed to derive keys from mnemonic",
1477
+ error
1478
+ );
1353
1479
  }
1354
1480
  }
1355
1481
  async function deriveKeysFromSeed(bitcoinNetwork = "regtest", seed) {
@@ -1397,7 +1523,10 @@ async function getXprivFromMnemonic(bitcoinNetwork = "regtest", mnemonic) {
1397
1523
  if (error instanceof ValidationError) {
1398
1524
  throw error;
1399
1525
  }
1400
- throw new CryptoError("Failed to derive xpriv from mnemonic", error);
1526
+ throw new CryptoError(
1527
+ "Failed to derive xpriv from mnemonic",
1528
+ error
1529
+ );
1401
1530
  }
1402
1531
  }
1403
1532
  async function getXpubFromXpriv(xpriv, bitcoinNetwork) {
@@ -1432,17 +1561,31 @@ async function accountXpubsFromMnemonic(bitcoinNetwork = "regtest", mnemonic) {
1432
1561
  try {
1433
1562
  const { bip39 } = await ensureBaseDependencies();
1434
1563
  if (!bip39 || !bip39.validateMnemonic(mnemonic)) {
1435
- throw new ValidationError("Invalid mnemonic format - failed BIP39 validation", "mnemonic");
1564
+ throw new ValidationError(
1565
+ "Invalid mnemonic format - failed BIP39 validation",
1566
+ "mnemonic"
1567
+ );
1436
1568
  }
1437
1569
  return {
1438
- account_xpub_vanilla: await getAccountXpub(mnemonic, bitcoinNetwork, false),
1439
- account_xpub_colored: await getAccountXpub(mnemonic, bitcoinNetwork, true)
1570
+ account_xpub_vanilla: await getAccountXpub(
1571
+ mnemonic,
1572
+ bitcoinNetwork,
1573
+ false
1574
+ ),
1575
+ account_xpub_colored: await getAccountXpub(
1576
+ mnemonic,
1577
+ bitcoinNetwork,
1578
+ true
1579
+ )
1440
1580
  };
1441
1581
  } catch (error) {
1442
1582
  if (error instanceof ValidationError) {
1443
1583
  throw error;
1444
1584
  }
1445
- throw new CryptoError("Failed to derive account xpubs from mnemonic", error);
1585
+ throw new CryptoError(
1586
+ "Failed to derive account xpubs from mnemonic",
1587
+ error
1588
+ );
1446
1589
  }
1447
1590
  }
1448
1591
 
@@ -1502,7 +1645,10 @@ function preprocessPsbtForBDK(psbtBase64, rootNode, fp, network, deps) {
1502
1645
  }
1503
1646
  const pubkeyBuffer = pubkey instanceof Buffer ? pubkey : Buffer.from(pubkey);
1504
1647
  const xOnly = toXOnly(pubkeyBuffer);
1505
- const p2tr = payments.p2tr({ internalPubkey: xOnly, network: bjsNet });
1648
+ const p2tr = payments.p2tr({
1649
+ internalPubkey: xOnly,
1650
+ network: bjsNet
1651
+ });
1506
1652
  const expectedScript = p2tr.output;
1507
1653
  if (!expectedScript) {
1508
1654
  return;
@@ -1530,7 +1676,7 @@ function preprocessPsbtForBDK(psbtBase64, rootNode, fp, network, deps) {
1530
1676
  if (!deriv.pubkey || !deriv.pubkey.equals(xOnly)) {
1531
1677
  deriv.pubkey = xOnly;
1532
1678
  }
1533
- } catch (e) {
1679
+ } catch (_e) {
1534
1680
  }
1535
1681
  });
1536
1682
  }
@@ -1562,7 +1708,7 @@ function detectPsbtType(psbtBase64, deps) {
1562
1708
  }
1563
1709
  }
1564
1710
  return "create_utxo";
1565
- } catch (e) {
1711
+ } catch (_e) {
1566
1712
  return "create_utxo";
1567
1713
  }
1568
1714
  }
@@ -1612,12 +1758,20 @@ async function signPsbtFromSeedInternal(seed, psbtBase64, network, options = {},
1612
1758
  try {
1613
1759
  rootNode = bip32.fromSeed(seedBuffer, versions);
1614
1760
  } catch (error) {
1615
- throw new CryptoError("Failed to derive root node from seed", error);
1761
+ throw new CryptoError(
1762
+ "Failed to derive root node from seed",
1763
+ error
1764
+ );
1616
1765
  }
1617
1766
  const fp = await getMasterFingerprint(rootNode);
1618
1767
  const psbtType = detectPsbtType(psbtBase64, deps);
1619
1768
  const needsPreprocessing = psbtType === "send";
1620
- const { external, internal } = deriveDescriptors(rootNode, fp, network, psbtType);
1769
+ const { external, internal } = deriveDescriptors(
1770
+ rootNode,
1771
+ fp,
1772
+ network,
1773
+ psbtType
1774
+ );
1621
1775
  let wallet2;
1622
1776
  try {
1623
1777
  wallet2 = bdk.Wallet.create(network, external, internal);
@@ -1627,7 +1781,13 @@ async function signPsbtFromSeedInternal(seed, psbtBase64, network, options = {},
1627
1781
  let processedPsbt = psbtBase64.trim();
1628
1782
  if (needsPreprocessing || options.preprocess) {
1629
1783
  try {
1630
- processedPsbt = preprocessPsbtForBDK(psbtBase64, rootNode, fp, network, deps);
1784
+ processedPsbt = preprocessPsbtForBDK(
1785
+ psbtBase64,
1786
+ rootNode,
1787
+ fp,
1788
+ network,
1789
+ deps
1790
+ );
1631
1791
  } catch (error) {
1632
1792
  throw new CryptoError("Failed to preprocess PSBT", error);
1633
1793
  }
@@ -1656,17 +1816,26 @@ async function signPsbt(mnemonic, psbtBase64, network = "testnet", options = {})
1656
1816
  let seed;
1657
1817
  try {
1658
1818
  seed = bip39.mnemonicToSeedSync(mnemonic);
1659
- } catch (error) {
1819
+ } catch (_error) {
1660
1820
  throw new ValidationError("Invalid mnemonic format", "mnemonic");
1661
1821
  }
1662
1822
  const normalizedNetwork = normalizeNetwork(network);
1663
1823
  const deps = await ensureSignerDependencies();
1664
- return await signPsbtFromSeedInternal(seed, psbtBase64, normalizedNetwork, options, deps);
1824
+ return await signPsbtFromSeedInternal(
1825
+ seed,
1826
+ psbtBase64,
1827
+ normalizedNetwork,
1828
+ options,
1829
+ deps
1830
+ );
1665
1831
  } catch (error) {
1666
1832
  if (error instanceof ValidationError || error instanceof CryptoError) {
1667
1833
  throw error;
1668
1834
  }
1669
- throw new CryptoError("Unexpected error during PSBT signing", error);
1835
+ throw new CryptoError(
1836
+ "Unexpected error during PSBT signing",
1837
+ error
1838
+ );
1670
1839
  }
1671
1840
  }
1672
1841
  async function signPsbtSync(mnemonic, psbtBase64, network = "testnet", options = {}) {
@@ -1676,7 +1845,13 @@ async function signPsbtFromSeed(seed, psbtBase64, network = "testnet", options =
1676
1845
  const normalizedSeed = normalizeSeedInput(seed);
1677
1846
  const normalizedNetwork = normalizeNetwork(network);
1678
1847
  const deps = await ensureSignerDependencies();
1679
- return signPsbtFromSeedInternal(normalizedSeed, psbtBase64, normalizedNetwork, options, deps);
1848
+ return signPsbtFromSeedInternal(
1849
+ normalizedSeed,
1850
+ psbtBase64,
1851
+ normalizedNetwork,
1852
+ options,
1853
+ deps
1854
+ );
1680
1855
  }
1681
1856
  function ensureMessageInput(message) {
1682
1857
  if (typeof message === "string") {
@@ -1691,7 +1866,10 @@ function ensureMessageInput(message) {
1691
1866
  }
1692
1867
  return Buffer.from(message);
1693
1868
  }
1694
- throw new ValidationError("message must be a string or Uint8Array", "message");
1869
+ throw new ValidationError(
1870
+ "message must be a string or Uint8Array",
1871
+ "message"
1872
+ );
1695
1873
  }
1696
1874
  async function deriveRootFromSeedInput(seed, network) {
1697
1875
  const { ecc, factory } = await ensureBaseDependencies();
@@ -1701,7 +1879,10 @@ async function deriveRootFromSeedInput(seed, network) {
1701
1879
  try {
1702
1880
  return bip32.fromSeed(normalizedSeed, versions);
1703
1881
  } catch (error) {
1704
- throw new CryptoError("Failed to create BIP32 root node from seed", error);
1882
+ throw new CryptoError(
1883
+ "Failed to create BIP32 root node from seed",
1884
+ error
1885
+ );
1705
1886
  }
1706
1887
  }
1707
1888
  var DEFAULT_RELATIVE_PATH = "0/0";
@@ -1726,7 +1907,9 @@ async function signMessage(params) {
1726
1907
  throw new CryptoError("Schnorr signing not supported by ECC module");
1727
1908
  }
1728
1909
  const messageHash = await sha256(messageBytes);
1729
- const signature = Buffer.from(ecc.signSchnorr(messageHash, privateKey)).toString("base64");
1910
+ const signature = Buffer.from(
1911
+ ecc.signSchnorr(messageHash, privateKey)
1912
+ ).toString("base64");
1730
1913
  return signature;
1731
1914
  }
1732
1915
  async function verifyMessage(params) {
@@ -1743,7 +1926,7 @@ async function verifyMessage(params) {
1743
1926
  let accountNode;
1744
1927
  try {
1745
1928
  accountNode = factory(ecc).fromBase58(accountXpub, versions);
1746
- } catch (error) {
1929
+ } catch (_error) {
1747
1930
  throw new ValidationError("Invalid account xpub provided", "accountXpub");
1748
1931
  }
1749
1932
  const child = accountNode.derivePath(relativePath);
@@ -1786,11 +1969,7 @@ function deriveVssSigningKeyFromMnemonic(mnemonic) {
1786
1969
  return Array.from(digest).map((b) => b.toString(16).padStart(2, "0")).join("");
1787
1970
  }
1788
1971
  var restoreFromBackup = (params) => {
1789
- const {
1790
- backupFilePath,
1791
- password,
1792
- dataDir
1793
- } = params;
1972
+ const { backupFilePath, password, dataDir } = params;
1794
1973
  if (!backupFilePath) {
1795
1974
  throw new ValidationError("backup file is required", "backup");
1796
1975
  }
@@ -1819,7 +1998,10 @@ var WalletManager = class {
1819
1998
  throw new ValidationError("xpubCol is required", "xpubCol");
1820
1999
  }
1821
2000
  if (!params.masterFingerprint) {
1822
- throw new ValidationError("masterFingerprint is required", "masterFingerprint");
2001
+ throw new ValidationError(
2002
+ "masterFingerprint is required",
2003
+ "masterFingerprint"
2004
+ );
1823
2005
  }
1824
2006
  this.network = normalizeNetwork(params.network ?? "regtest");
1825
2007
  this.xpubVan = params.xpubVan;
@@ -1828,7 +2010,12 @@ var WalletManager = class {
1828
2010
  this.mnemonic = params.mnemonic ?? null;
1829
2011
  this.xpub = params.xpub ?? null;
1830
2012
  this.masterFingerprint = params.masterFingerprint;
1831
- this.dataDir = params.dataDir ?? path3__namespace.default.join(process.cwd(), ".rgb-wallet", this.network, this.masterFingerprint);
2013
+ this.dataDir = params.dataDir ?? path3__namespace.default.join(
2014
+ process.cwd(),
2015
+ ".rgb-wallet",
2016
+ this.network,
2017
+ this.masterFingerprint
2018
+ );
1832
2019
  this.client = new RGBLibClient({
1833
2020
  xpubVan: params.xpubVan,
1834
2021
  xpubCol: params.xpubCol,
@@ -1842,7 +2029,7 @@ var WalletManager = class {
1842
2029
  async initialize() {
1843
2030
  console.log("initializing is not reqire");
1844
2031
  }
1845
- async goOnline(indexerUrl, skipConsistencyCheck) {
2032
+ async goOnline() {
1846
2033
  this.client.getOnline();
1847
2034
  }
1848
2035
  /**
@@ -2125,7 +2312,9 @@ var WalletManager = class {
2125
2312
  if (this.seed) {
2126
2313
  return await signPsbtFromSeed(this.seed, psbt, this.network);
2127
2314
  }
2128
- throw new WalletError("mnemonic is required. Provide it as parameter or initialize wallet with mnemonic.");
2315
+ throw new WalletError(
2316
+ "mnemonic is required. Provide it as parameter or initialize wallet with mnemonic."
2317
+ );
2129
2318
  }
2130
2319
  /**
2131
2320
  * Complete send operation: begin → sign → end
@@ -2138,7 +2327,12 @@ var WalletManager = class {
2138
2327
  const signedPsbt = await this.signPsbt(psbt, mnemonic);
2139
2328
  return await this.sendEnd({ signedPsbt });
2140
2329
  }
2141
- async createUtxos({ upTo, num, size, feeRate }) {
2330
+ async createUtxos({
2331
+ upTo,
2332
+ num,
2333
+ size,
2334
+ feeRate
2335
+ }) {
2142
2336
  this.ensureNotDisposed();
2143
2337
  const psbt = await this.createUtxosBegin({ upTo, num, size, feeRate });
2144
2338
  const signedPsbt = await this.signPsbt(psbt);
@@ -2153,7 +2347,9 @@ var WalletManager = class {
2153
2347
  throw new ValidationError("message is required", "message");
2154
2348
  }
2155
2349
  if (!this.seed) {
2156
- throw new WalletError("Wallet seed is required for message signing. Initialize the wallet with a seed.");
2350
+ throw new WalletError(
2351
+ "Wallet seed is required for message signing. Initialize the wallet with a seed."
2352
+ );
2157
2353
  }
2158
2354
  return signMessage({
2159
2355
  message,
@@ -2171,7 +2367,7 @@ var WalletManager = class {
2171
2367
  return verifyMessage({
2172
2368
  message,
2173
2369
  signature,
2174
- accountXpub: this.xpubVan,
2370
+ accountXpub: accountXpub ?? this.xpubVan,
2175
2371
  network: this.network
2176
2372
  });
2177
2373
  }
@@ -2191,25 +2387,25 @@ var wallet = new Proxy({}, {
2191
2387
 
2192
2388
  // src/utexo/utexo-protocol.ts
2193
2389
  var LightningProtocol = class {
2194
- async createLightningInvoice(params) {
2390
+ async createLightningInvoice(_params) {
2195
2391
  throw new Error("createLightningInvoice not implemented");
2196
2392
  }
2197
- async getLightningReceiveRequest(id) {
2393
+ async getLightningReceiveRequest(_id) {
2198
2394
  throw new Error("getLightningReceiveRequest not implemented");
2199
2395
  }
2200
- async getLightningSendRequest(id) {
2396
+ async getLightningSendRequest(_id) {
2201
2397
  throw new Error("getLightningSendRequest not implemented");
2202
2398
  }
2203
- async getLightningSendFeeEstimate(params) {
2399
+ async getLightningSendFeeEstimate(_params) {
2204
2400
  throw new Error("getLightningSendFeeEstimate not implemented");
2205
2401
  }
2206
- async payLightningInvoiceBegin(params) {
2402
+ async payLightningInvoiceBegin(_params) {
2207
2403
  throw new Error("payLightningInvoiceBegin not implemented");
2208
2404
  }
2209
- async payLightningInvoiceEnd(params) {
2405
+ async payLightningInvoiceEnd(_params) {
2210
2406
  throw new Error("payLightningInvoiceEnd not implemented");
2211
2407
  }
2212
- async payLightningInvoice(params, mnemonic) {
2408
+ async payLightningInvoice(_params, _mnemonic) {
2213
2409
  throw new Error("payLightningInvoice not implemented");
2214
2410
  }
2215
2411
  async listLightningPayments() {
@@ -2217,22 +2413,22 @@ var LightningProtocol = class {
2217
2413
  }
2218
2414
  };
2219
2415
  var OnchainProtocol = class {
2220
- async onchainReceive(params) {
2416
+ async onchainReceive(_params) {
2221
2417
  throw new Error("onchainReceive not implemented");
2222
2418
  }
2223
- async onchainSendBegin(params) {
2419
+ async onchainSendBegin(_params) {
2224
2420
  throw new Error("onchainSendBegin not implemented");
2225
2421
  }
2226
- async onchainSendEnd(params) {
2422
+ async onchainSendEnd(_params) {
2227
2423
  throw new Error("onchainSendEnd not implemented");
2228
2424
  }
2229
- async onchainSend(params, mnemonic) {
2425
+ async onchainSend(_params, _mnemonic) {
2230
2426
  throw new Error("onchainSend not implemented");
2231
2427
  }
2232
- async getOnchainSendStatus(send_id) {
2428
+ async getOnchainSendStatus(_send_id) {
2233
2429
  throw new Error("getOnchainSendStatus not implemented");
2234
2430
  }
2235
- async listOnchainTransfers(asset_id) {
2431
+ async listOnchainTransfers(_asset_id) {
2236
2432
  throw new Error("listOnchainTransfers not implemented");
2237
2433
  }
2238
2434
  };
@@ -2263,7 +2459,7 @@ var UTEXOProtocol = class extends LightningProtocol {
2263
2459
 
2264
2460
  // src/utexo/config/gateway.ts
2265
2461
  var DEFAULT_GATEWAY_BASE_URLS = {
2266
- mainnet: "https://gateway.utexo.tricorn.network/",
2462
+ mainnet: "https://gateway.utexo.utexo.com/",
2267
2463
  testnet: "https://dev.gateway.utexo.tricorn.network/"
2268
2464
  };
2269
2465
 
@@ -2288,19 +2484,19 @@ var encodeTransferStatus = (transferStatus) => {
2288
2484
  var UtexoBridgeApiClient = class {
2289
2485
  /**
2290
2486
  * Creates a new UtexoBridgeApiClient instance
2291
- *
2487
+ *
2292
2488
  * @param axiosInstance - Axios instance to use for HTTP requests (required)
2293
2489
  * @param basePath - Base path for API endpoints (defaults to '/v1/utexo/bridge')
2294
- *
2490
+ *
2295
2491
  * @example
2296
2492
  * ```typescript
2297
2493
  * import axios from 'axios';
2298
2494
  * import { UtexoBridgeApiClient } from './utexoBridge';
2299
- *
2495
+ *
2300
2496
  * const axiosInstance = axios.create({
2301
2497
  * baseURL: 'https://api.example.com'
2302
2498
  * });
2303
- *
2499
+ *
2304
2500
  * const client = new UtexoBridgeApiClient(axiosInstance);
2305
2501
  * ```
2306
2502
  */
@@ -2310,7 +2506,7 @@ var UtexoBridgeApiClient = class {
2310
2506
  }
2311
2507
  /**
2312
2508
  * Gets bridge-in signature for a transfer
2313
- *
2509
+ *
2314
2510
  * @param request - Bridge-in signature request data
2315
2511
  * @returns Promise resolving to bridge-in signature response
2316
2512
  * @throws {ApiError} If the request fails
@@ -2333,7 +2529,7 @@ var UtexoBridgeApiClient = class {
2333
2529
  }
2334
2530
  /**
2335
2531
  * Submits a signed transaction to the blockchain
2336
- *
2532
+ *
2337
2533
  * @param request - Submit transaction request data
2338
2534
  * @returns Promise resolving to transaction hash
2339
2535
  * @throws {ApiError} If the request fails
@@ -2347,7 +2543,7 @@ var UtexoBridgeApiClient = class {
2347
2543
  }
2348
2544
  /**
2349
2545
  * Verifies a bridge-in transaction after it has been sent
2350
- *
2546
+ *
2351
2547
  * @param request - Verify bridge-in request data
2352
2548
  * @returns Promise that resolves when verification is complete
2353
2549
  * @throws {ApiError} If the request fails
@@ -2357,7 +2553,7 @@ var UtexoBridgeApiClient = class {
2357
2553
  }
2358
2554
  /**
2359
2555
  * Gets receiver invoice by transfer ID and network ID
2360
- *
2556
+ *
2361
2557
  * @param transferId - Transfer ID
2362
2558
  * @param networkId - Network ID
2363
2559
  * @returns Promise resolving to invoice string
@@ -2370,21 +2566,21 @@ var UtexoBridgeApiClient = class {
2370
2566
  return data.invoice;
2371
2567
  }
2372
2568
  async getWithdrawTransfer(invoice, networkId) {
2373
- const { data } = await this.axios.get(
2374
- `${this.basePath}/transfers/history`,
2375
- {
2376
- params: {
2377
- "network_id": String(networkId),
2378
- "offset": String(0),
2379
- "limit": String(10),
2380
- "address": "rgb-address"
2381
- }
2569
+ const { data } = await this.axios.get(`${this.basePath}/transfers/history`, {
2570
+ params: {
2571
+ network_id: String(networkId),
2572
+ offset: String(0),
2573
+ limit: String(10),
2574
+ address: "rgb-address"
2382
2575
  }
2383
- );
2576
+ });
2384
2577
  if (data.transfers.length === 0) {
2385
2578
  return null;
2386
2579
  }
2387
- const withdrawTransfer = data.transfers.map((transfer) => ({ ...transfer, status: TransferStatuses[encodeTransferStatus(transfer.status)] })).find((transfer) => transfer.recipient.address === invoice);
2580
+ const withdrawTransfer = data.transfers.map((transfer) => ({
2581
+ ...transfer,
2582
+ status: TransferStatuses[encodeTransferStatus(transfer.status)]
2583
+ })).find((transfer) => transfer.recipient.address === invoice);
2388
2584
  if (!withdrawTransfer) {
2389
2585
  return null;
2390
2586
  }
@@ -2392,7 +2588,7 @@ var UtexoBridgeApiClient = class {
2392
2588
  }
2393
2589
  /**
2394
2590
  * Gets transfer information by mainnet invoice
2395
- *
2591
+ *
2396
2592
  * @param mainnetInvoice - Mainnet invoice string
2397
2593
  * @param networkId - Network ID
2398
2594
  * @returns Promise resolving to transfer information
@@ -2410,10 +2606,13 @@ var UtexoBridgeApiClient = class {
2410
2606
  }
2411
2607
  );
2412
2608
  if (data) {
2413
- return { ...data, status: TransferStatuses[encodeTransferStatus(data.status)] };
2609
+ return {
2610
+ ...data,
2611
+ status: TransferStatuses[encodeTransferStatus(data.status)]
2612
+ };
2414
2613
  }
2415
2614
  return data;
2416
- } catch (error) {
2615
+ } catch (_error) {
2417
2616
  console.log("Mainnet invoice not found");
2418
2617
  return null;
2419
2618
  }
@@ -2483,12 +2682,25 @@ function prepareUtxoBackupDirs(backupPath, masterFingerprint) {
2483
2682
  storeId,
2484
2683
  layer1TmpDir,
2485
2684
  utexoTmpDir,
2486
- layer1FinalPath: path3__namespace.default.join(backupPath, `${storeId}_layer1${BACKUP_FILE_SUFFIX}`),
2487
- utexoFinalPath: path3__namespace.default.join(backupPath, `${storeId}_utexo${BACKUP_FILE_SUFFIX}`)
2685
+ layer1FinalPath: path3__namespace.default.join(
2686
+ backupPath,
2687
+ `${storeId}_layer1${BACKUP_FILE_SUFFIX}`
2688
+ ),
2689
+ utexoFinalPath: path3__namespace.default.join(
2690
+ backupPath,
2691
+ `${storeId}_utexo${BACKUP_FILE_SUFFIX}`
2692
+ )
2488
2693
  };
2489
2694
  }
2490
2695
  function finalizeUtxoBackupPaths(params) {
2491
- const { layer1BackupPath, utexoBackupPath, layer1FinalPath, utexoFinalPath, layer1TmpDir, utexoTmpDir } = params;
2696
+ const {
2697
+ layer1BackupPath,
2698
+ utexoBackupPath,
2699
+ layer1FinalPath,
2700
+ utexoFinalPath,
2701
+ layer1TmpDir,
2702
+ utexoTmpDir
2703
+ } = params;
2492
2704
  fs2__namespace.default.renameSync(layer1BackupPath, layer1FinalPath);
2493
2705
  fs2__namespace.default.renameSync(utexoBackupPath, utexoFinalPath);
2494
2706
  fs2__namespace.default.rmdirSync(layer1TmpDir);
@@ -2504,7 +2716,13 @@ async function buildVssConfigFromMnemonic(mnemonic, serverUrl, networkPreset = "
2504
2716
  };
2505
2717
  }
2506
2718
  async function restoreUtxoWalletFromVss(params) {
2507
- const { mnemonic, targetDir, config: providedConfig, networkPreset = "testnet", vssServerUrl } = params;
2719
+ const {
2720
+ mnemonic,
2721
+ targetDir,
2722
+ config: providedConfig,
2723
+ networkPreset = "testnet",
2724
+ vssServerUrl
2725
+ } = params;
2508
2726
  if (!mnemonic || !mnemonic.trim()) {
2509
2727
  throw new ValidationError("mnemonic is required", "mnemonic");
2510
2728
  }
@@ -2512,13 +2730,23 @@ async function restoreUtxoWalletFromVss(params) {
2512
2730
  throw new ValidationError("targetDir is required", "targetDir");
2513
2731
  }
2514
2732
  const serverUrl = vssServerUrl ?? DEFAULT_VSS_SERVER_URL;
2515
- const config = providedConfig ?? await buildVssConfigFromMnemonic(mnemonic.trim(), serverUrl, networkPreset);
2733
+ const config = providedConfig ?? await buildVssConfigFromMnemonic(
2734
+ mnemonic.trim(),
2735
+ serverUrl,
2736
+ networkPreset
2737
+ );
2516
2738
  const presetConfig = getUtxoNetworkConfig(networkPreset);
2517
2739
  const layer1Network = String(presetConfig.networkMap.mainnet);
2518
2740
  const utexoNetwork = String(presetConfig.networkMap.utexo);
2519
2741
  const masterFingerprint = config.storeId.replace(/^wallet_/, "") || config.storeId;
2520
- const layer1Config = { ...config, storeId: `${config.storeId}_layer1` };
2521
- const utexoConfig = { ...config, storeId: `${config.storeId}_utexo` };
2742
+ const layer1Config = {
2743
+ ...config,
2744
+ storeId: `${config.storeId}_layer1`
2745
+ };
2746
+ const utexoConfig = {
2747
+ ...config,
2748
+ storeId: `${config.storeId}_utexo`
2749
+ };
2522
2750
  const { walletPath: layer1Path } = restoreFromVss({
2523
2751
  config: layer1Config,
2524
2752
  targetDir: path3__namespace.default.join(targetDir, layer1Network, masterFingerprint)
@@ -2532,10 +2760,16 @@ async function restoreUtxoWalletFromVss(params) {
2532
2760
  function restoreUtxoWalletFromBackup(params) {
2533
2761
  const { backupPath, password, targetDir, networkPreset = "testnet" } = params;
2534
2762
  if (!backupPath || !password || !targetDir) {
2535
- throw new ValidationError("backupPath, password, and targetDir are required", "restoreUtxoWalletFromBackup");
2763
+ throw new ValidationError(
2764
+ "backupPath, password, and targetDir are required",
2765
+ "restoreUtxoWalletFromBackup"
2766
+ );
2536
2767
  }
2537
2768
  if (!fs2__namespace.default.existsSync(backupPath) || !fs2__namespace.default.statSync(backupPath).isDirectory()) {
2538
- throw new ValidationError("backupPath must be an existing directory", "backupPath");
2769
+ throw new ValidationError(
2770
+ "backupPath must be an existing directory",
2771
+ "backupPath"
2772
+ );
2539
2773
  }
2540
2774
  const files = fs2__namespace.default.readdirSync(backupPath);
2541
2775
  const layer1File = files.find((f) => f.endsWith(LAYER1_BACKUP_SUFFIX));
@@ -2572,8 +2806,16 @@ function restoreUtxoWalletFromBackup(params) {
2572
2806
  fs2__namespace.default.mkdirSync(dir, { recursive: true });
2573
2807
  }
2574
2808
  }
2575
- restoreWallet({ backupFilePath: layer1BackupFile, password, dataDir: layer1DataDir });
2576
- restoreWallet({ backupFilePath: utexoBackupFile, password, dataDir: utexoDataDir });
2809
+ restoreWallet({
2810
+ backupFilePath: layer1BackupFile,
2811
+ password,
2812
+ dataDir: layer1DataDir
2813
+ });
2814
+ restoreWallet({
2815
+ backupFilePath: utexoBackupFile,
2816
+ password,
2817
+ dataDir: utexoDataDir
2818
+ });
2577
2819
  return {
2578
2820
  layer1Path: layer1DataDir,
2579
2821
  utexoPath: utexoDataDir,
@@ -2596,7 +2838,7 @@ var UTEXOWallet = class extends UTEXOProtocol {
2596
2838
  this.utexoRGBWallet = null;
2597
2839
  this.mnemonicOrSeed = mnemonicOrSeed;
2598
2840
  this.options = options;
2599
- const preset = options.network ?? "testnet";
2841
+ const preset = options.network ?? "mainnet";
2600
2842
  const networkConfig = getUtxoNetworkConfig(preset);
2601
2843
  this.networkMap = networkConfig.networkMap;
2602
2844
  this.networkIdMap = networkConfig.networkIdMap;
@@ -2617,7 +2859,7 @@ var UTEXOWallet = class extends UTEXOProtocol {
2617
2859
  });
2618
2860
  this.layer1RGBWallet = new WalletManager({
2619
2861
  xpubVan: this.layer1Keys.accountXpubVanilla,
2620
- xpubCol: this.layer1Keys.accountXpubVanilla,
2862
+ xpubCol: this.layer1Keys.accountXpubColored,
2621
2863
  masterFingerprint: this.layer1Keys.masterFingerprint,
2622
2864
  network: this.networkMap.mainnet,
2623
2865
  mnemonic: this.mnemonicOrSeed,
@@ -2626,12 +2868,15 @@ var UTEXOWallet = class extends UTEXOProtocol {
2626
2868
  }
2627
2869
  /**
2628
2870
  * Derive public keys from mnemonic or seed
2629
- * @param network - BitcoinNetwork identifier
2871
+ * @param network - BitcoinNetwork identifier
2630
2872
  * @returns Promise resolving to PublicKeys containing xpub, accountXpubVanilla, accountXpubColored, and masterFingerprint
2631
2873
  * @throws {ValidationError} If mnemonic is invalid
2632
2874
  */
2633
2875
  async derivePublicKeys(network) {
2634
- const generatedKeys = await deriveKeysFromMnemonicOrSeed(network, this.mnemonicOrSeed);
2876
+ const generatedKeys = await deriveKeysFromMnemonicOrSeed(
2877
+ network,
2878
+ this.mnemonicOrSeed
2879
+ );
2635
2880
  const { xpub, accountXpubVanilla, accountXpubColored, masterFingerprint } = generatedKeys;
2636
2881
  return { xpub, accountXpubVanilla, accountXpubColored, masterFingerprint };
2637
2882
  }
@@ -2653,7 +2898,7 @@ var UTEXOWallet = class extends UTEXOProtocol {
2653
2898
  // ==========================================
2654
2899
  // IWalletManager Implementation
2655
2900
  // ==========================================
2656
- async goOnline(indexerUrl, skipConsistencyCheck) {
2901
+ async goOnline() {
2657
2902
  this.ensureInitialized();
2658
2903
  throw new Error("goOnline not implemented");
2659
2904
  }
@@ -2805,12 +3050,21 @@ var UTEXOWallet = class extends UTEXOProtocol {
2805
3050
  this.ensureInitialized();
2806
3051
  const { backupPath, password } = params;
2807
3052
  if (!backupPath || !password) {
2808
- throw new ValidationError("backupPath and password are required", "createBackup");
3053
+ throw new ValidationError(
3054
+ "backupPath and password are required",
3055
+ "createBackup"
3056
+ );
2809
3057
  }
2810
3058
  const fp = this.utexoKeys.masterFingerprint;
2811
3059
  const { layer1TmpDir, utexoTmpDir, layer1FinalPath, utexoFinalPath } = prepareUtxoBackupDirs(backupPath, fp);
2812
- const layer1Result = await this.layer1RGBWallet.createBackup({ backupPath: layer1TmpDir, password });
2813
- const utexoResult = await this.utexoRGBWallet.createBackup({ backupPath: utexoTmpDir, password });
3060
+ const layer1Result = await this.layer1RGBWallet.createBackup({
3061
+ backupPath: layer1TmpDir,
3062
+ password
3063
+ });
3064
+ const utexoResult = await this.utexoRGBWallet.createBackup({
3065
+ backupPath: utexoTmpDir,
3066
+ password
3067
+ });
2814
3068
  finalizeUtxoBackupPaths({
2815
3069
  layer1BackupPath: layer1Result.backupPath,
2816
3070
  utexoBackupPath: utexoResult.backupPath,
@@ -2860,7 +3114,11 @@ var UTEXOWallet = class extends UTEXOProtocol {
2860
3114
  }
2861
3115
  const serverUrl = this.options.vssServerUrl ?? DEFAULT_VSS_SERVER_URL;
2862
3116
  const preset = this.options.network ?? "mainnet";
2863
- vssConfig = await buildVssConfigFromMnemonic(mnemonicToUse.trim(), serverUrl, preset);
3117
+ vssConfig = await buildVssConfigFromMnemonic(
3118
+ mnemonicToUse.trim(),
3119
+ serverUrl,
3120
+ preset
3121
+ );
2864
3122
  }
2865
3123
  const { layer1, utexo } = getVssConfigs(vssConfig);
2866
3124
  await this.layer1RGBWallet.vssBackup(layer1);
@@ -2879,11 +3137,18 @@ var UTEXOWallet = class extends UTEXOProtocol {
2879
3137
  } else {
2880
3138
  const mnemonicToUse = mnemonic ?? (typeof this.mnemonicOrSeed === "string" ? this.mnemonicOrSeed : null);
2881
3139
  if (!mnemonicToUse) {
2882
- throw new ValidationError("config or mnemonic required for vssBackupInfo", "config");
3140
+ throw new ValidationError(
3141
+ "config or mnemonic required for vssBackupInfo",
3142
+ "config"
3143
+ );
2883
3144
  }
2884
3145
  const serverUrl = this.options.vssServerUrl ?? DEFAULT_VSS_SERVER_URL;
2885
3146
  const preset = this.options.network ?? "mainnet";
2886
- vssConfig = await buildVssConfigFromMnemonic(mnemonicToUse.trim(), serverUrl, preset);
3147
+ vssConfig = await buildVssConfigFromMnemonic(
3148
+ mnemonicToUse.trim(),
3149
+ serverUrl,
3150
+ preset
3151
+ );
2887
3152
  }
2888
3153
  const { utexo } = getVssConfigs(vssConfig);
2889
3154
  return this.utexoRGBWallet.vssBackupInfo(utexo);
@@ -2901,23 +3166,26 @@ var UTEXOWallet = class extends UTEXOProtocol {
2901
3166
  return this.utexoRGBWallet.verifyMessage(message, signature, accountXpub);
2902
3167
  }
2903
3168
  /**
2904
- * Validates that the wallet has sufficient spendable balance for the given asset and amount.
2905
- * @param assetId - Asset ID to check balance for
2906
- * @param amount - Required amount (in asset units)
2907
- * @throws {ValidationError} If balance is not found or insufficient
2908
- */
3169
+ * Validates that the wallet has sufficient spendable balance for the given asset and amount.
3170
+ * @param assetId - Asset ID to check balance for
3171
+ * @param amount - Required amount (in asset units)
3172
+ * @throws {ValidationError} If balance is not found or insufficient
3173
+ */
2909
3174
  async validateBalance(assetId, amount) {
2910
3175
  const assetBalance = await this.getAssetBalance(assetId);
2911
3176
  if (!assetBalance || !assetBalance.spendable) {
2912
3177
  throw new ValidationError("Asset balance is not found", "assetBalance");
2913
3178
  }
2914
3179
  if (assetBalance.spendable < amount) {
2915
- throw new ValidationError(`Insufficient balance ${assetBalance.spendable} < ${amount}`, "amount");
3180
+ throw new ValidationError(
3181
+ `Insufficient balance ${assetBalance.spendable} < ${amount}`,
3182
+ "amount"
3183
+ );
2916
3184
  }
2917
3185
  }
2918
3186
  /**
2919
3187
  * Extracts invoice data and destination asset from a bridge transfer.
2920
- *
3188
+ *
2921
3189
  * @param bridgeTransfer - Bridge transfer response containing recipient invoice and token info
2922
3190
  * @returns Object containing invoice string, decoded invoice data, and destination asset
2923
3191
  * @throws {ValidationError} If destination asset is not supported
@@ -2925,9 +3193,14 @@ var UTEXOWallet = class extends UTEXOProtocol {
2925
3193
  async extractInvoiceAndAsset(bridgeTransfer) {
2926
3194
  const utexoInvoice = bridgeTransfer.recipient.address;
2927
3195
  const invoiceData = await this.decodeRGBInvoice({ invoice: utexoInvoice });
2928
- const destinationAsset = this.networkIdMap.utexo.getAssetById(bridgeTransfer.recipientToken.id);
3196
+ const destinationAsset = this.networkIdMap.utexo.getAssetById(
3197
+ bridgeTransfer.recipientToken.id
3198
+ );
2929
3199
  if (!destinationAsset) {
2930
- throw new ValidationError("Destination asset is not supported", "assetId");
3200
+ throw new ValidationError(
3201
+ "Destination asset is not supported",
3202
+ "assetId"
3203
+ );
2931
3204
  }
2932
3205
  return { utexoInvoice, invoiceData, destinationAsset };
2933
3206
  }
@@ -2936,9 +3209,17 @@ var UTEXOWallet = class extends UTEXOProtocol {
2936
3209
  */
2937
3210
  async onchainReceive(params) {
2938
3211
  this.ensureInitialized();
2939
- const destinationAsset = getDestinationAsset("mainnet", "utexo", params.assetId ?? null);
3212
+ const destinationAsset = getDestinationAsset(
3213
+ "mainnet",
3214
+ "utexo",
3215
+ params.assetId ?? null,
3216
+ this.networkIdMap
3217
+ );
2940
3218
  if (!destinationAsset) {
2941
- throw new ValidationError("Destination asset is not supported", "assetId");
3219
+ throw new ValidationError(
3220
+ "Destination asset is not supported",
3221
+ "assetId"
3222
+ );
2942
3223
  }
2943
3224
  if (!params.amount) {
2944
3225
  throw new ValidationError("Amount is required", "amount");
@@ -2972,7 +3253,10 @@ var UTEXOWallet = class extends UTEXOProtocol {
2972
3253
  }
2973
3254
  async onchainSendBegin(params) {
2974
3255
  this.ensureInitialized();
2975
- const bridgeTransfer = await this.bridge.getTransferByMainnetInvoice(params.invoice, this.networkIdMap.mainnet.networkId);
3256
+ const bridgeTransfer = await this.bridge.getTransferByMainnetInvoice(
3257
+ params.invoice,
3258
+ this.networkIdMap.mainnet.networkId
3259
+ );
2976
3260
  if (!bridgeTransfer) {
2977
3261
  console.log("External invoice UTEXO -> Mainnet initiated");
2978
3262
  return this.UTEXOToMainnetRGB(params);
@@ -2980,9 +3264,14 @@ var UTEXOWallet = class extends UTEXOProtocol {
2980
3264
  const utexoInvoice = bridgeTransfer.recipient.address;
2981
3265
  const invoiceData = await this.decodeRGBInvoice({ invoice: utexoInvoice });
2982
3266
  const bridgeAmount = bridgeTransfer.recipientAmount;
2983
- const destinationAsset = this.networkIdMap.utexo.getAssetById(bridgeTransfer.recipientToken.id);
3267
+ const destinationAsset = this.networkIdMap.utexo.getAssetById(
3268
+ bridgeTransfer.recipientToken.id
3269
+ );
2984
3270
  if (!destinationAsset) {
2985
- throw new ValidationError("Destination asset is not supported", "assetId");
3271
+ throw new ValidationError(
3272
+ "Destination asset is not supported",
3273
+ "assetId"
3274
+ );
2986
3275
  }
2987
3276
  const amount = toUnitsNumber(bridgeAmount, destinationAsset.precision);
2988
3277
  const isWitness = invoiceData.recipientId.includes("wvout:");
@@ -3003,27 +3292,46 @@ var UTEXOWallet = class extends UTEXOProtocol {
3003
3292
  }
3004
3293
  async onchainSendEnd(params) {
3005
3294
  this.ensureInitialized();
3006
- const sendResult = await this.utexoRGBWallet.sendEnd({ signedPsbt: params.signedPsbt });
3295
+ const sendResult = await this.utexoRGBWallet.sendEnd({
3296
+ signedPsbt: params.signedPsbt
3297
+ });
3007
3298
  return sendResult;
3008
3299
  }
3009
3300
  async onchainSend(params, mnemonic) {
3010
3301
  this.ensureInitialized();
3011
3302
  const psbt = await this.onchainSendBegin(params);
3012
3303
  const signed_psbt = await this.utexoRGBWallet.signPsbt(psbt, mnemonic);
3013
- return await this.onchainSendEnd({ signedPsbt: signed_psbt, invoice: params.invoice });
3304
+ return await this.onchainSendEnd({
3305
+ signedPsbt: signed_psbt,
3306
+ invoice: params.invoice
3307
+ });
3014
3308
  }
3015
3309
  async getOnchainSendStatus(invoice) {
3016
- const bridgeTransfer = await this.bridge.getTransferByMainnetInvoice(invoice, this.networkIdMap.mainnet.networkId);
3310
+ const bridgeTransfer = await this.bridge.getTransferByMainnetInvoice(
3311
+ invoice,
3312
+ this.networkIdMap.mainnet.networkId
3313
+ );
3017
3314
  if (!bridgeTransfer) {
3018
- const withdrawTransfer = await this.bridge.getWithdrawTransfer(invoice, this.networkIdMap.utexo.networkId);
3315
+ const withdrawTransfer = await this.bridge.getWithdrawTransfer(
3316
+ invoice,
3317
+ this.networkIdMap.utexo.networkId
3318
+ );
3019
3319
  if (!withdrawTransfer) {
3020
3320
  return null;
3021
3321
  }
3022
3322
  return withdrawTransfer.status;
3023
3323
  }
3024
3324
  const { invoiceData, destinationAsset } = await this.extractInvoiceAndAsset(bridgeTransfer);
3025
- const transfers = await this.utexoRGBWallet.listTransfers(destinationAsset.assetId);
3026
- const transfer = transfers.find((transfer2) => transfer2.recipientId === invoiceData.recipientId);
3325
+ const assets = await this.utexoRGBWallet.listAssets();
3326
+ const walletAsset = assets.nia.find(
3327
+ (a) => a.assetId === destinationAsset.assetId
3328
+ );
3329
+ const transfers = await this.utexoRGBWallet.listTransfers(
3330
+ walletAsset?.assetId
3331
+ );
3332
+ const transfer = transfers.find(
3333
+ (transfer2) => transfer2.recipientId === invoiceData.recipientId
3334
+ );
3027
3335
  if (transfer) {
3028
3336
  return transfer.status;
3029
3337
  }
@@ -3048,9 +3356,17 @@ var UTEXOWallet = class extends UTEXOProtocol {
3048
3356
  if (!asset.amount) {
3049
3357
  throw new ValidationError("Amount is required", "amount");
3050
3358
  }
3051
- const destinationAsset = getDestinationAsset("mainnet", "utexo", asset.assetId);
3359
+ const destinationAsset = getDestinationAsset(
3360
+ "mainnet",
3361
+ "utexo",
3362
+ asset.assetId,
3363
+ this.networkIdMap
3364
+ );
3052
3365
  if (!destinationAsset) {
3053
- throw new ValidationError("Destination asset is not supported", "assetId");
3366
+ throw new ValidationError(
3367
+ "Destination asset is not supported",
3368
+ "assetId"
3369
+ );
3054
3370
  }
3055
3371
  const destinationInvoice = await this.utexoRGBWallet.witnessReceive({
3056
3372
  assetId: "",
@@ -3079,7 +3395,10 @@ var UTEXOWallet = class extends UTEXOProtocol {
3079
3395
  }
3080
3396
  async payLightningInvoiceBegin(params) {
3081
3397
  this.ensureInitialized();
3082
- const bridgeTransfer = await this.bridge.getTransferByMainnetInvoice(params.lnInvoice, this.networkIdMap.mainnetLightning.networkId);
3398
+ const bridgeTransfer = await this.bridge.getTransferByMainnetInvoice(
3399
+ params.lnInvoice,
3400
+ this.networkIdMap.mainnetLightning.networkId
3401
+ );
3083
3402
  if (!bridgeTransfer) {
3084
3403
  console.log("External invoice UTEXO -> Mainnet Lightning initiated");
3085
3404
  return this.UtexoToMainnetLightning(params);
@@ -3104,70 +3423,119 @@ var UTEXOWallet = class extends UTEXOProtocol {
3104
3423
  }
3105
3424
  async payLightningInvoiceEnd(params) {
3106
3425
  this.ensureInitialized();
3107
- const sendResult = await this.utexoRGBWallet.sendEnd({ signedPsbt: params.signedPsbt });
3426
+ const sendResult = await this.utexoRGBWallet.sendEnd({
3427
+ signedPsbt: params.signedPsbt
3428
+ });
3108
3429
  return sendResult;
3109
3430
  }
3110
3431
  async payLightningInvoice(params, mnemonic) {
3111
3432
  this.ensureInitialized();
3112
3433
  const psbt = await this.payLightningInvoiceBegin(params);
3113
3434
  const signed_psbt = await this.utexoRGBWallet.signPsbt(psbt, mnemonic);
3114
- return await this.payLightningInvoiceEnd({ signedPsbt: signed_psbt, lnInvoice: params.lnInvoice });
3435
+ return await this.payLightningInvoiceEnd({
3436
+ signedPsbt: signed_psbt,
3437
+ lnInvoice: params.lnInvoice
3438
+ });
3115
3439
  }
3116
3440
  async getLightningSendRequest(lnInvoice) {
3117
3441
  this.ensureInitialized();
3118
- const bridgeTransfer = await this.bridge.getTransferByMainnetInvoice(lnInvoice, this.networkIdMap.mainnetLightning.networkId);
3442
+ const bridgeTransfer = await this.bridge.getTransferByMainnetInvoice(
3443
+ lnInvoice,
3444
+ this.networkIdMap.mainnetLightning.networkId
3445
+ );
3119
3446
  if (!bridgeTransfer) {
3120
- const withdrawTransfer = await this.bridge.getWithdrawTransfer(lnInvoice, this.networkIdMap.utexo.networkId);
3447
+ const withdrawTransfer = await this.bridge.getWithdrawTransfer(
3448
+ lnInvoice,
3449
+ this.networkIdMap.utexo.networkId
3450
+ );
3121
3451
  if (!withdrawTransfer) {
3122
3452
  return null;
3123
3453
  }
3124
3454
  return withdrawTransfer.status;
3125
3455
  }
3126
3456
  const { invoiceData, destinationAsset } = await this.extractInvoiceAndAsset(bridgeTransfer);
3127
- const transfers = await this.utexoRGBWallet.listTransfers(destinationAsset.assetId);
3128
- return transfers.length > 0 ? transfers.find((transfer) => transfer.recipientId === invoiceData.recipientId)?.status ?? null : null;
3457
+ const transfers = await this.utexoRGBWallet.listTransfers(
3458
+ destinationAsset.assetId
3459
+ );
3460
+ return transfers.length > 0 ? transfers.find(
3461
+ (transfer) => transfer.recipientId === invoiceData.recipientId
3462
+ )?.status ?? null : null;
3129
3463
  }
3130
3464
  async getLightningReceiveRequest(lnInvoice) {
3131
3465
  this.ensureInitialized();
3132
- const bridgeTransfer = await this.bridge.getTransferByMainnetInvoice(lnInvoice, this.networkIdMap.mainnetLightning.networkId);
3466
+ const bridgeTransfer = await this.bridge.getTransferByMainnetInvoice(
3467
+ lnInvoice,
3468
+ this.networkIdMap.mainnetLightning.networkId
3469
+ );
3133
3470
  if (!bridgeTransfer) {
3134
- const withdrawTransfer = await this.bridge.getWithdrawTransfer(lnInvoice, this.networkIdMap.utexo.networkId);
3471
+ const withdrawTransfer = await this.bridge.getWithdrawTransfer(
3472
+ lnInvoice,
3473
+ this.networkIdMap.utexo.networkId
3474
+ );
3135
3475
  if (!withdrawTransfer) {
3136
3476
  return null;
3137
3477
  }
3138
3478
  return withdrawTransfer.status;
3139
3479
  }
3140
3480
  const { invoiceData, destinationAsset } = await this.extractInvoiceAndAsset(bridgeTransfer);
3141
- const transfers = await this.utexoRGBWallet.listTransfers(destinationAsset.assetId);
3142
- return transfers.length > 0 ? transfers.find((transfer) => transfer.recipientId === invoiceData.recipientId)?.status ?? null : null;
3481
+ const transfers = await this.utexoRGBWallet.listTransfers(
3482
+ destinationAsset.assetId
3483
+ );
3484
+ return transfers.length > 0 ? transfers.find(
3485
+ (transfer) => transfer.recipientId === invoiceData.recipientId
3486
+ )?.status ?? null : null;
3143
3487
  }
3144
3488
  async UTEXOToMainnetRGB(params) {
3145
3489
  this.ensureInitialized();
3146
- const invoiceData = await this.decodeRGBInvoice({ invoice: params.invoice });
3490
+ const invoiceData = await this.decodeRGBInvoice({
3491
+ invoice: params.invoice
3492
+ });
3147
3493
  if (!params.assetId && !invoiceData.assetId) {
3148
- throw new ValidationError("Asset ID is required for external invoice", "assetId");
3494
+ throw new ValidationError(
3495
+ "Asset ID is required for external invoice",
3496
+ "assetId"
3497
+ );
3149
3498
  }
3150
3499
  const assetId = params.assetId ?? invoiceData.assetId;
3151
- const utexoAsset = getDestinationAsset("mainnet", "utexo", assetId ?? null);
3500
+ const utexoAsset = getDestinationAsset(
3501
+ "mainnet",
3502
+ "utexo",
3503
+ assetId ?? null,
3504
+ this.networkIdMap
3505
+ );
3152
3506
  if (!utexoAsset) {
3153
3507
  throw new ValidationError("UTEXO asset is not supported", "assetId");
3154
3508
  }
3155
- const destinationAsset = this.networkIdMap.mainnet.getAssetById(utexoAsset?.tokenId ?? 0);
3509
+ const destinationAsset = this.networkIdMap.mainnet.getAssetById(
3510
+ utexoAsset?.tokenId ?? 0
3511
+ );
3156
3512
  if (!destinationAsset) {
3157
- throw new ValidationError("Destination asset is not supported", "assetId");
3513
+ throw new ValidationError(
3514
+ "Destination asset is not supported",
3515
+ "assetId"
3516
+ );
3158
3517
  }
3159
3518
  if (!params.amount && !invoiceData.assignment.amount) {
3160
- throw new ValidationError("Amount is required for external invoice", "amount");
3519
+ throw new ValidationError(
3520
+ "Amount is required for external invoice",
3521
+ "amount"
3522
+ );
3161
3523
  }
3162
3524
  let amount;
3163
3525
  if (params.amount) {
3164
3526
  amount = params.amount;
3165
3527
  } else if (invoiceData.assignment.amount) {
3166
- amount = fromUnitsNumber(invoiceData.assignment.amount, destinationAsset.precision);
3528
+ amount = fromUnitsNumber(
3529
+ invoiceData.assignment.amount,
3530
+ destinationAsset.precision
3531
+ );
3167
3532
  } else {
3168
3533
  throw new ValidationError("Amount is required", "amount");
3169
3534
  }
3170
- await this.validateBalance(utexoAsset.assetId, toUnitsNumber(amount.toString(), utexoAsset.precision));
3535
+ await this.validateBalance(
3536
+ utexoAsset.assetId,
3537
+ toUnitsNumber(amount.toString(), utexoAsset.precision)
3538
+ );
3171
3539
  const payload = {
3172
3540
  sender: {
3173
3541
  address: "rgb-address",
@@ -3204,22 +3572,44 @@ var UTEXOWallet = class extends UTEXOProtocol {
3204
3572
  async UtexoToMainnetLightning(params) {
3205
3573
  this.ensureInitialized();
3206
3574
  if (!params.assetId) {
3207
- throw new ValidationError("Asset ID is required for external invoice", "assetId");
3575
+ throw new ValidationError(
3576
+ "Asset ID is required for external invoice",
3577
+ "assetId"
3578
+ );
3208
3579
  }
3209
3580
  const assetId = params.assetId;
3210
- const utexoAsset = getDestinationAsset("mainnet", "utexo", assetId ?? null);
3211
- const destinationAsset = this.networkIdMap.mainnet.getAssetById(utexoAsset?.tokenId ?? 0);
3581
+ const utexoAsset = getDestinationAsset(
3582
+ "mainnet",
3583
+ "utexo",
3584
+ assetId ?? null,
3585
+ this.networkIdMap
3586
+ );
3587
+ const destinationAsset = this.networkIdMap.mainnet.getAssetById(
3588
+ utexoAsset?.tokenId ?? 0
3589
+ );
3212
3590
  if (!destinationAsset) {
3213
- throw new ValidationError("Destination asset is not supported", "assetId");
3591
+ throw new ValidationError(
3592
+ "Destination asset is not supported",
3593
+ "assetId"
3594
+ );
3214
3595
  }
3215
3596
  if (!utexoAsset) {
3216
- throw new ValidationError("Destination asset is not supported", "assetId");
3597
+ throw new ValidationError(
3598
+ "Destination asset is not supported",
3599
+ "assetId"
3600
+ );
3217
3601
  }
3218
3602
  if (!params.amount) {
3219
- throw new ValidationError("Amount is required for external invoice", "amount");
3603
+ throw new ValidationError(
3604
+ "Amount is required for external invoice",
3605
+ "amount"
3606
+ );
3220
3607
  }
3221
3608
  const amount = params.amount;
3222
- await this.validateBalance(utexoAsset.assetId, toUnitsNumber(amount.toString(), utexoAsset.precision));
3609
+ await this.validateBalance(
3610
+ utexoAsset.assetId,
3611
+ toUnitsNumber(amount.toString(), utexoAsset.precision)
3612
+ );
3223
3613
  const bridgeOutTransfer = await this.bridge.getBridgeInSignature({
3224
3614
  sender: {
3225
3615
  address: "rgb-address",