orbis1-sdk-rn 0.0.9 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/README.md +9 -2
  2. package/android/src/main/java/com/orbis1sdk/RgbModule.kt +18 -3
  3. package/ios/Orbis1Sdk.mm +6 -3
  4. package/ios/Rgb.mm +6 -3
  5. package/ios/Rgb.swift +21 -8
  6. package/lib/module/Orbis1SDK.js +1 -0
  7. package/lib/module/Orbis1SDK.js.map +1 -1
  8. package/lib/module/core/NativeRgb.js.map +1 -1
  9. package/lib/module/core/Wallet.js +3 -1
  10. package/lib/module/core/Wallet.js.map +1 -1
  11. package/lib/module/features/gas-free/GasFreeModule.js +19 -15
  12. package/lib/module/features/gas-free/GasFreeModule.js.map +1 -1
  13. package/lib/module/features/gas-free/client/ServiceClient.js +0 -3
  14. package/lib/module/features/gas-free/client/ServiceClient.js.map +1 -1
  15. package/lib/module/features/gas-free/types/FeeQuote.js.map +1 -1
  16. package/lib/module/features/gas-free/types/GasFreeResult.js.map +1 -1
  17. package/lib/module/features/gas-free/utils/validation.js +7 -6
  18. package/lib/module/features/gas-free/utils/validation.js.map +1 -1
  19. package/lib/module/types/SDKConfig.js +22 -6
  20. package/lib/module/types/SDKConfig.js.map +1 -1
  21. package/lib/typescript/src/Orbis1SDK.d.ts.map +1 -1
  22. package/lib/typescript/src/core/NativeRgb.d.ts +1 -1
  23. package/lib/typescript/src/core/NativeRgb.d.ts.map +1 -1
  24. package/lib/typescript/src/core/Wallet.d.ts +3 -0
  25. package/lib/typescript/src/core/Wallet.d.ts.map +1 -1
  26. package/lib/typescript/src/features/gas-free/GasFreeModule.d.ts +3 -5
  27. package/lib/typescript/src/features/gas-free/GasFreeModule.d.ts.map +1 -1
  28. package/lib/typescript/src/features/gas-free/client/ServiceClient.d.ts.map +1 -1
  29. package/lib/typescript/src/features/gas-free/types/FeeQuote.d.ts +6 -2
  30. package/lib/typescript/src/features/gas-free/types/FeeQuote.d.ts.map +1 -1
  31. package/lib/typescript/src/features/gas-free/types/GasFreeRequest.d.ts +1 -1
  32. package/lib/typescript/src/features/gas-free/types/GasFreeRequest.d.ts.map +1 -1
  33. package/lib/typescript/src/features/gas-free/types/GasFreeResult.d.ts +0 -2
  34. package/lib/typescript/src/features/gas-free/types/GasFreeResult.d.ts.map +1 -1
  35. package/lib/typescript/src/features/gas-free/utils/validation.d.ts +16 -13
  36. package/lib/typescript/src/features/gas-free/utils/validation.d.ts.map +1 -1
  37. package/lib/typescript/src/types/SDKConfig.d.ts +132 -23
  38. package/lib/typescript/src/types/SDKConfig.d.ts.map +1 -1
  39. package/package.json +4 -4
  40. package/src/Orbis1SDK.ts +3 -2
  41. package/src/core/NativeRgb.ts +1 -0
  42. package/src/core/Wallet.ts +5 -0
  43. package/src/features/gas-free/GasFreeModule.ts +15 -12
  44. package/src/features/gas-free/client/ServiceClient.ts +0 -6
  45. package/src/features/gas-free/types/FeeQuote.ts +6 -2
  46. package/src/features/gas-free/types/GasFreeRequest.ts +1 -1
  47. package/src/features/gas-free/types/GasFreeResult.ts +0 -2
  48. package/src/features/gas-free/utils/validation.ts +14 -5
  49. package/src/types/SDKConfig.ts +58 -20
@@ -15,6 +15,8 @@ export interface WalletConfig {
15
15
  enabled: boolean;
16
16
  /** Wallet keys (mnemonic, xpubs, etc.) */
17
17
  keys: Keys;
18
+ /** Absolute path to directory where wallet data will be stored. If not provided, defaults to app documents directory. */
19
+ dataDir?: string;
18
20
  /** Supported asset schemas */
19
21
  supportedSchemas?: AssetSchema[];
20
22
  /** Maximum allocations per UTXO */
@@ -102,9 +104,13 @@ export declare const SDKOptionsSchema: z.ZodObject<{
102
104
  }>;
103
105
  /**
104
106
  * Zod schema for SDK configuration
107
+ *
108
+ * Note: `apiKey` is intentionally omitted here — it is validated manually in
109
+ * `validateSDKConfig` so it can be optional when Gas-Free / Watch Tower are off.
110
+ * Including it in Zod led to stale builds or edge cases surfacing as
111
+ * "apiKey: API key is required".
105
112
  */
106
113
  export declare const SDKConfigSchema: z.ZodObject<{
107
- apiKey: z.ZodString;
108
114
  environment: z.ZodDefault<z.ZodNativeEnum<typeof Environment>>;
109
115
  features: z.ZodOptional<z.ZodObject<{
110
116
  gasFree: z.ZodOptional<z.ZodObject<{
@@ -187,13 +193,9 @@ export declare const SDKConfigSchema: z.ZodObject<{
187
193
  }, {
188
194
  strictMode?: boolean | undefined;
189
195
  }>>;
190
- }, "strip", z.ZodTypeAny, {
191
- apiKey: string;
192
- environment: Environment;
193
- options?: {
194
- strictMode?: boolean | undefined;
195
- } | undefined;
196
- features?: z.objectOutputType<{
196
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
197
+ environment: z.ZodDefault<z.ZodNativeEnum<typeof Environment>>;
198
+ features: z.ZodOptional<z.ZodObject<{
197
199
  gasFree: z.ZodOptional<z.ZodObject<{
198
200
  enabled: z.ZodOptional<z.ZodBoolean>;
199
201
  timeout: z.ZodOptional<z.ZodNumber>;
@@ -214,18 +216,69 @@ export declare const SDKConfigSchema: z.ZodObject<{
214
216
  enabled?: boolean | undefined;
215
217
  pollingInterval?: number | undefined;
216
218
  }>>;
217
- }, z.ZodTypeAny, "passthrough"> | undefined;
218
- logging?: {
219
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
220
+ gasFree: z.ZodOptional<z.ZodObject<{
221
+ enabled: z.ZodOptional<z.ZodBoolean>;
222
+ timeout: z.ZodOptional<z.ZodNumber>;
223
+ }, "strip", z.ZodTypeAny, {
224
+ enabled?: boolean | undefined;
225
+ timeout?: number | undefined;
226
+ }, {
227
+ enabled?: boolean | undefined;
228
+ timeout?: number | undefined;
229
+ }>>;
230
+ watchTower: z.ZodOptional<z.ZodObject<{
231
+ enabled: z.ZodOptional<z.ZodBoolean>;
232
+ pollingInterval: z.ZodOptional<z.ZodNumber>;
233
+ }, "strip", z.ZodTypeAny, {
234
+ enabled?: boolean | undefined;
235
+ pollingInterval?: number | undefined;
236
+ }, {
237
+ enabled?: boolean | undefined;
238
+ pollingInterval?: number | undefined;
239
+ }>>;
240
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
241
+ gasFree: z.ZodOptional<z.ZodObject<{
242
+ enabled: z.ZodOptional<z.ZodBoolean>;
243
+ timeout: z.ZodOptional<z.ZodNumber>;
244
+ }, "strip", z.ZodTypeAny, {
245
+ enabled?: boolean | undefined;
246
+ timeout?: number | undefined;
247
+ }, {
248
+ enabled?: boolean | undefined;
249
+ timeout?: number | undefined;
250
+ }>>;
251
+ watchTower: z.ZodOptional<z.ZodObject<{
252
+ enabled: z.ZodOptional<z.ZodBoolean>;
253
+ pollingInterval: z.ZodOptional<z.ZodNumber>;
254
+ }, "strip", z.ZodTypeAny, {
255
+ enabled?: boolean | undefined;
256
+ pollingInterval?: number | undefined;
257
+ }, {
258
+ enabled?: boolean | undefined;
259
+ pollingInterval?: number | undefined;
260
+ }>>;
261
+ }, z.ZodTypeAny, "passthrough">>>;
262
+ logging: z.ZodOptional<z.ZodObject<{
263
+ level: z.ZodOptional<z.ZodNativeEnum<typeof LogLevel>>;
264
+ logger: z.ZodOptional<z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>>;
265
+ }, "strip", z.ZodTypeAny, {
219
266
  level?: LogLevel | undefined;
220
267
  logger?: ((...args: unknown[]) => unknown) | undefined;
221
- } | undefined;
222
- }, {
223
- apiKey: string;
224
- options?: {
268
+ }, {
269
+ level?: LogLevel | undefined;
270
+ logger?: ((...args: unknown[]) => unknown) | undefined;
271
+ }>>;
272
+ options: z.ZodOptional<z.ZodObject<{
273
+ strictMode: z.ZodOptional<z.ZodBoolean>;
274
+ }, "strip", z.ZodTypeAny, {
225
275
  strictMode?: boolean | undefined;
226
- } | undefined;
227
- environment?: Environment | undefined;
228
- features?: z.objectInputType<{
276
+ }, {
277
+ strictMode?: boolean | undefined;
278
+ }>>;
279
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
280
+ environment: z.ZodDefault<z.ZodNativeEnum<typeof Environment>>;
281
+ features: z.ZodOptional<z.ZodObject<{
229
282
  gasFree: z.ZodOptional<z.ZodObject<{
230
283
  enabled: z.ZodOptional<z.ZodBoolean>;
231
284
  timeout: z.ZodOptional<z.ZodNumber>;
@@ -246,21 +299,77 @@ export declare const SDKConfigSchema: z.ZodObject<{
246
299
  enabled?: boolean | undefined;
247
300
  pollingInterval?: number | undefined;
248
301
  }>>;
249
- }, z.ZodTypeAny, "passthrough"> | undefined;
250
- logging?: {
302
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
303
+ gasFree: z.ZodOptional<z.ZodObject<{
304
+ enabled: z.ZodOptional<z.ZodBoolean>;
305
+ timeout: z.ZodOptional<z.ZodNumber>;
306
+ }, "strip", z.ZodTypeAny, {
307
+ enabled?: boolean | undefined;
308
+ timeout?: number | undefined;
309
+ }, {
310
+ enabled?: boolean | undefined;
311
+ timeout?: number | undefined;
312
+ }>>;
313
+ watchTower: z.ZodOptional<z.ZodObject<{
314
+ enabled: z.ZodOptional<z.ZodBoolean>;
315
+ pollingInterval: z.ZodOptional<z.ZodNumber>;
316
+ }, "strip", z.ZodTypeAny, {
317
+ enabled?: boolean | undefined;
318
+ pollingInterval?: number | undefined;
319
+ }, {
320
+ enabled?: boolean | undefined;
321
+ pollingInterval?: number | undefined;
322
+ }>>;
323
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
324
+ gasFree: z.ZodOptional<z.ZodObject<{
325
+ enabled: z.ZodOptional<z.ZodBoolean>;
326
+ timeout: z.ZodOptional<z.ZodNumber>;
327
+ }, "strip", z.ZodTypeAny, {
328
+ enabled?: boolean | undefined;
329
+ timeout?: number | undefined;
330
+ }, {
331
+ enabled?: boolean | undefined;
332
+ timeout?: number | undefined;
333
+ }>>;
334
+ watchTower: z.ZodOptional<z.ZodObject<{
335
+ enabled: z.ZodOptional<z.ZodBoolean>;
336
+ pollingInterval: z.ZodOptional<z.ZodNumber>;
337
+ }, "strip", z.ZodTypeAny, {
338
+ enabled?: boolean | undefined;
339
+ pollingInterval?: number | undefined;
340
+ }, {
341
+ enabled?: boolean | undefined;
342
+ pollingInterval?: number | undefined;
343
+ }>>;
344
+ }, z.ZodTypeAny, "passthrough">>>;
345
+ logging: z.ZodOptional<z.ZodObject<{
346
+ level: z.ZodOptional<z.ZodNativeEnum<typeof LogLevel>>;
347
+ logger: z.ZodOptional<z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>>;
348
+ }, "strip", z.ZodTypeAny, {
251
349
  level?: LogLevel | undefined;
252
350
  logger?: ((...args: unknown[]) => unknown) | undefined;
253
- } | undefined;
254
- }>;
351
+ }, {
352
+ level?: LogLevel | undefined;
353
+ logger?: ((...args: unknown[]) => unknown) | undefined;
354
+ }>>;
355
+ options: z.ZodOptional<z.ZodObject<{
356
+ strictMode: z.ZodOptional<z.ZodBoolean>;
357
+ }, "strip", z.ZodTypeAny, {
358
+ strictMode?: boolean | undefined;
359
+ }, {
360
+ strictMode?: boolean | undefined;
361
+ }>>;
362
+ }, z.ZodTypeAny, "passthrough">>;
255
363
  /**
256
364
  * SDK Configuration
257
365
  */
258
366
  export interface SDKConfig {
259
367
  /**
260
368
  * API key for Orbis services (Watch Tower, Gas-Free, etc.).
261
- * Required for all backend services.
369
+ * Required when `features.gasFree.enabled` or `features.watchTower.enabled` is true.
370
+ * Omit for local RGB / wallet-only usage when those features are disabled.
262
371
  */
263
- apiKey: string;
372
+ apiKey?: string;
264
373
  /**
265
374
  * SDK environment (testnet or mainnet).
266
375
  * Determines which network and service endpoints to use.
@@ -1 +1 @@
1
- {"version":3,"file":"SDKConfig.d.ts","sourceRoot":"","sources":["../../../../src/types/SDKConfig.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAE5D;;GAEG;AACH,M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AAC,EAAE,OAAO,CAAC;KACtB,CAAC;CACH;AAED;;GAEG;AACH,eAAO,MAAM,kBAAkB,EAAE,OAAO,CAAC,SAAS,CASjD,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAiEzD;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,SAAS,GAAG,SAAS,CAuB9D"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "orbis1-sdk-rn",
3
- "version": "0.0.9",
3
+ "version": "0.2.0",
4
4
  "description": "Orbis1 SDK for React Native with RGB core, Watch Tower, and Gas-Free transfers.",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",
@@ -57,14 +57,14 @@
57
57
  ],
58
58
  "repository": {
59
59
  "type": "git",
60
- "url": "git+https://github.com/orgs/Orbis-1/orbis1-sdk-rn.git"
60
+ "url": "git+https://github.com/Orbis-1/orbis1-sdk-rn.git"
61
61
  },
62
62
  "author": "Orbis1 <dev@orbis1.io> (https://github.com/orgs/Orbis-1)",
63
63
  "license": "MIT",
64
64
  "bugs": {
65
- "url": "https://github.com/orgs/Orbis-1/orbis1-sdk-rn/issues"
65
+ "url": "https://github.com/Orbis-1/orbis1-sdk-rn/issues"
66
66
  },
67
- "homepage": "https://github.com/orgs/Orbis-1/orbis1-sdk-rn#readme",
67
+ "homepage": "https://github.com/Orbis-1/orbis1-sdk-rn#readme",
68
68
  "publishConfig": {
69
69
  "registry": "https://registry.npmjs.org/"
70
70
  },
package/src/Orbis1SDK.ts CHANGED
@@ -69,6 +69,7 @@ export class Orbis1SDK {
69
69
  : BitcoinNetwork.TESTNET4;
70
70
 
71
71
  this.wallet = new Wallet(this.config.wallet.keys, {
72
+ dataDir: this.config.wallet.dataDir,
72
73
  network,
73
74
  supportedSchemas: this.config.wallet.supportedSchemas,
74
75
  maxAllocationsPerUtxo: this.config.wallet.maxAllocationsPerUtxo,
@@ -147,7 +148,7 @@ export class Orbis1SDK {
147
148
  name: Feature.GAS_FREE,
148
149
  enabled: true,
149
150
  environment: this.config.environment,
150
- apiKey: this.config.apiKey,
151
+ apiKey: this.config.apiKey!,
151
152
  timeout: features.gasFree.timeout,
152
153
  });
153
154
  this.featureRegistry.register(Feature.GAS_FREE, gasFreeModule);
@@ -160,7 +161,7 @@ export class Orbis1SDK {
160
161
  name: Feature.WATCH_TOWER,
161
162
  enabled: true,
162
163
  environment: this.config.environment,
163
- apiKey: this.config.apiKey,
164
+ apiKey: this.config.apiKey!,
164
165
  });
165
166
  this.featureRegistry.register(Feature.WATCH_TOWER, watchTowerModule);
166
167
  await watchTowerModule.initialize(this.wallet, this.logger); // Wallet parameter ignored by Watch Tower
@@ -31,6 +31,7 @@ export interface Spec extends TurboModule {
31
31
  }>;
32
32
  restoreBackup(path: string, password: string): Promise<void>;
33
33
  initializeWallet(
34
+ dataDir: string | null,
34
35
  network: string,
35
36
  accountXpubVanilla: string,
36
37
  accountXpubColored: string,
@@ -2,6 +2,7 @@ import Rgb from './NativeRgb';
2
2
  import * as Interfaces from './Interfaces';
3
3
 
4
4
  export interface WalletOptions {
5
+ dataDir?: string;
5
6
  network?: Interfaces.BitcoinNetwork;
6
7
  supportedSchemas?: Interfaces.AssetSchema[];
7
8
  maxAllocationsPerUtxo?: number;
@@ -11,6 +12,7 @@ export interface WalletOptions {
11
12
  export class Wallet {
12
13
  private walletId: number | null = null;
13
14
  private keys: Interfaces.Keys;
15
+ private dataDir?: string;
14
16
  private network: Interfaces.BitcoinNetwork;
15
17
  private supportedSchemas: Interfaces.AssetSchema[];
16
18
  private maxAllocationsPerUtxo: number;
@@ -21,6 +23,7 @@ export class Wallet {
21
23
  * Creates a new Wallet instance with the provided keys and configuration.
22
24
  * @param keys - The cryptographic keys required for wallet operations (mnemonic, master fingerprint, xPubs)
23
25
  * @param options - Optional wallet configuration settings
26
+ * @param options.dataDir - Absolute path to directory where wallet data will be stored (optional, defaults to app documents directory)
24
27
  * @param options.network - The Bitcoin network to use (defaults to 'TESTNET4')
25
28
  * @param options.supportedSchemas - List of RGB asset schemas the wallet supports (defaults to CFA, NIA, UDA)
26
29
  * @param options.maxAllocationsPerUtxo - Maximum number of RGB allocations allowed per UTXO (defaults to 1)
@@ -28,6 +31,7 @@ export class Wallet {
28
31
  */
29
32
  constructor(keys: Interfaces.Keys, options?: WalletOptions) {
30
33
  this.keys = keys;
34
+ this.dataDir = options?.dataDir;
31
35
  this.network = options?.network || Interfaces.BitcoinNetwork.TESTNET4;
32
36
  this.supportedSchemas = options?.supportedSchemas || [
33
37
  Interfaces.AssetSchema.CFA,
@@ -57,6 +61,7 @@ export class Wallet {
57
61
  // Start initialization
58
62
  this.initializationPromise = (async () => {
59
63
  this.walletId = await Rgb.initializeWallet(
64
+ this.dataDir || null,
60
65
  this.network,
61
66
  this.keys.accountXpubVanilla,
62
67
  this.keys.accountXpubColored,
@@ -261,7 +261,6 @@ export class GasFreeModule implements IFeatureModule<GasFreeConfig> {
261
261
  const submitResult = await this.submitPSBT(
262
262
  feeQuote.quoteId,
263
263
  psbtResult,
264
- feeQuote.serviceFeeInvoice,
265
264
  request.assetId
266
265
  );
267
266
 
@@ -273,9 +272,7 @@ export class GasFreeModule implements IFeatureModule<GasFreeConfig> {
273
272
  submitResult.signedPsbtBase64
274
273
  );
275
274
 
276
- // Step 4: Notify service of successful broadcast.
277
- // The service uses txid to confirm the transaction landed in mempool
278
- // and calls its own wallet.refresh() to claim the RGB service fee.
275
+ // Step 4: Notify service of successful broadcast
279
276
  await this.verifyTransfer(feeQuote.quoteId, txid, userSignedPsbt);
280
277
 
281
278
  // Mark as verified
@@ -341,6 +338,7 @@ export class GasFreeModule implements IFeatureModule<GasFreeConfig> {
341
338
  assetId: request.assetId,
342
339
  numInputs: request.numInputs || 1, // defaults to 1 inputs if not provided (1 user input)
343
340
  numOutputs: request.numOutputs || 2, // defaults to 2 outputs if not provided (1 OP_RETURN, 1 user change <equal val as input>)
341
+ recipientInvoice: request.recipientInvoice,
344
342
  });
345
343
 
346
344
  // Check quote expiration
@@ -439,14 +437,17 @@ export class GasFreeModule implements IFeatureModule<GasFreeConfig> {
439
437
  service: decodedServiceInvoice,
440
438
  });
441
439
 
440
+ const recipientIsWitness = feeQuote.witnessUtxoFundingSats > 0;
441
+
442
442
  // Build recipient map for sendBegin
443
- // Note: Recipient requires assignment field with type and amount
443
+ // Note: Recipient requires assignment field with type and amount.
444
444
  // Important: Decoded invoices may have 'ANY' type (wildcard), but sendBegin
445
445
  // requires a concrete assignment type. Always use 'FUNGIBLE' for asset transfers.
446
446
  const recipientMap: Record<
447
447
  string,
448
448
  Array<{
449
449
  recipientId: string;
450
+ witnessData?: { amountSat: number; blinding?: number };
450
451
  assignment: { type: AssignmentType; amount: number };
451
452
  transportEndpoints: string[];
452
453
  }>
@@ -455,6 +456,12 @@ export class GasFreeModule implements IFeatureModule<GasFreeConfig> {
455
456
  {
456
457
  // Recipient 1: The actual transfer to the merchant / end recipient
457
458
  recipientId: decodedRecipientInvoice.recipientId,
459
+ ...(recipientIsWitness && {
460
+ witnessData: {
461
+ amountSat: feeQuote.witnessUtxoFundingSats,
462
+ blinding: 0, // Default blinding factor (rgb-lib requires this field)
463
+ },
464
+ }),
458
465
  assignment: {
459
466
  // Use FUNGIBLE type for asset transfers (invoice may have 'ANY' wildcard type)
460
467
  type: 'FUNGIBLE',
@@ -516,7 +523,6 @@ export class GasFreeModule implements IFeatureModule<GasFreeConfig> {
516
523
  *
517
524
  * @param quoteId - Quote ID from the fee quote
518
525
  * @param psbtResult - PSBT build result from buildPSBT()
519
- * @param serviceFeeInvoice - Service fee RGB invoice from the quote
520
526
  * @param assetId - Asset ID being transferred
521
527
  * @returns Submit result with service-signed PSBT
522
528
  *
@@ -525,7 +531,6 @@ export class GasFreeModule implements IFeatureModule<GasFreeConfig> {
525
531
  * const submitResult = await gasFree.submitPSBT(
526
532
  * quote.quoteId,
527
533
  * psbtResult,
528
- * quote.serviceFeeInvoice,
529
534
  * request.assetId
530
535
  * );
531
536
  * console.log('Service signed PSBT:', submitResult.signedPsbtBase64);
@@ -534,7 +539,6 @@ export class GasFreeModule implements IFeatureModule<GasFreeConfig> {
534
539
  async submitPSBT(
535
540
  quoteId: string,
536
541
  psbtResult: PSBTBuildResult,
537
- serviceFeeInvoice: string,
538
542
  assetId: string
539
543
  ): Promise<PSBTSubmitResult> {
540
544
  this.logger?.debug('Step 3: Reading consignment and submitting to service');
@@ -548,7 +552,6 @@ export class GasFreeModule implements IFeatureModule<GasFreeConfig> {
548
552
  quoteId,
549
553
  psbtBase64: psbtResult.unsignedPsbt,
550
554
  consignmentBase64,
551
- rgbInvoice: serviceFeeInvoice,
552
555
  });
553
556
 
554
557
  this.currentState.status = 'submitted';
@@ -620,7 +623,7 @@ export class GasFreeModule implements IFeatureModule<GasFreeConfig> {
620
623
  *
621
624
  * @param quoteId - Quote ID from the fee quote
622
625
  * @param txid - Transaction ID from broadcastTransfer()
623
- * @param signedPsbtBase64 - Fully-signed PSBT from broadcastTransfer()
626
+ * @param signedPsbtBase64 - Base64-encoded signed PSBT
624
627
  * @returns Verification result from the service
625
628
  *
626
629
  * @example
@@ -628,7 +631,7 @@ export class GasFreeModule implements IFeatureModule<GasFreeConfig> {
628
631
  * const verifyResult = await gasFree.verifyTransfer(
629
632
  * quote.quoteId,
630
633
  * broadcastResult.txid,
631
- * broadcastResult.userSignedPsbt
634
+ * signedPsbtBase64
632
635
  * );
633
636
  * console.log('Verification status:', verifyResult.status);
634
637
  * console.log('In mempool:', verifyResult.inMempool);
@@ -644,8 +647,8 @@ export class GasFreeModule implements IFeatureModule<GasFreeConfig> {
644
647
  const verifyResult = await this.serviceClient!.verifyTransfer({
645
648
  quoteId,
646
649
  transferSuccess: true,
647
- signedPsbtBase64,
648
650
  txid,
651
+ signedPsbtBase64,
649
652
  });
650
653
 
651
654
  this.logger?.debug('Transfer verified', {
@@ -197,12 +197,6 @@ export class ServiceClient implements IServiceClient {
197
197
  ]);
198
198
  }
199
199
 
200
- if (!request.rgbInvoice || request.rgbInvoice.trim().length === 0) {
201
- throw new InvalidPSBTError('RGB invoice is required', [
202
- 'rgbInvoice cannot be empty',
203
- ]);
204
- }
205
-
206
200
  // Make API request with retry
207
201
  try {
208
202
  return await retryWithBackoff(async () => {
@@ -50,10 +50,12 @@ export interface FeeQuote {
50
50
  serviceFeeAmount: number;
51
51
  /** Asset type for service fee */
52
52
  assetType?: string;
53
+ /** Satoshi amount needed to fund witness UTXO (0 for blinded invoices, typically 1000 for witness invoices) */
54
+ witnessUtxoFundingSats: number;
53
55
  /** Mining UTXO provided by backend */
54
56
  miningUTXO: MiningUTXO;
55
- /** Mining change UTXO details */
56
- miningChangeUTXO: MiningChangeUTXO;
57
+ /** Mining change UTXO details (undefined if entire mining UTXO is consumed) */
58
+ miningChangeUTXO?: MiningChangeUTXO;
57
59
  /** RGB invoice for service fee payment */
58
60
  serviceFeeInvoice: string;
59
61
  /** Service fee recipient ID (utxob) */
@@ -78,6 +80,8 @@ export interface FeeQuoteRequest {
78
80
  numInputs: number;
79
81
  /** Number of USER's transaction outputs (INCLUDES OP_RETURN, must be >= 2) */
80
82
  numOutputs: number;
83
+ /** RGB invoice for the recipient (mandatory) */
84
+ recipientInvoice: string;
81
85
  }
82
86
 
83
87
  /**
@@ -20,7 +20,7 @@ export interface GasFreeTransferRequest {
20
20
  /** Amount of RGB asset to send */
21
21
  amount: string;
22
22
 
23
- /** Recipient RGB invoice (blinded UTXO) */
23
+ /** Recipient RGB invoice (blinded UTXO or witness output) */
24
24
  recipientInvoice: string;
25
25
 
26
26
  /** Transport endpoints for RGB transfer (e.g., ['rpc://...']) */
@@ -16,8 +16,6 @@ export interface SubmitPSBTRequest {
16
16
  psbtBase64: string;
17
17
  /** Base64-encoded RGB consignment file (.rgbc) */
18
18
  consignmentBase64: string;
19
- /** RGB invoice string for service fee payment */
20
- rgbInvoice: string;
21
19
  }
22
20
 
23
21
  /**
@@ -66,8 +66,12 @@ export const FeeQuoteSchema = z.object({
66
66
  .number()
67
67
  .nonnegative('Service fee amount must be non-negative'),
68
68
  assetType: z.string().optional(),
69
+ witnessUtxoFundingSats: z
70
+ .number()
71
+ .int()
72
+ .nonnegative('Witness UTXO funding sats must be non-negative'),
69
73
  miningUTXO: MiningUTXOSchema,
70
- miningChangeUTXO: MiningChangeUTXOSchema,
74
+ miningChangeUTXO: MiningChangeUTXOSchema.optional(),
71
75
  serviceFeeInvoice: z.string().min(1, 'Service fee invoice must not be empty'),
72
76
  serviceFeeRecipientId: z
73
77
  .string()
@@ -88,16 +92,21 @@ export const FeeQuoteRequestSchema = z.object({
88
92
  .number()
89
93
  .int()
90
94
  .min(2, 'Number of outputs must be at least 2 (includes OP_RETURN)'),
95
+ recipientInvoice: z
96
+ .string()
97
+ .min(1, 'Recipient invoice cannot be empty')
98
+ .regex(/^rgb1?:/, 'Recipient invoice must start with rgb: or rgb1:'),
91
99
  }) satisfies z.ZodType<FeeQuoteRequest>;
92
100
 
93
101
  /**
94
102
  * Schema for Submit PSBT Request
95
103
  */
96
104
  export const SubmitPSBTRequestSchema = z.object({
97
- quoteId: z.string().min(1, 'Quote ID must not be empty'),
98
- psbtBase64: z.string().min(1, 'PSBT base64 must not be empty'),
99
- consignmentBase64: z.string().min(1, 'Consignment base64 must not be empty'),
100
- rgbInvoice: z.string().min(1, 'RGB invoice must not be empty'),
105
+ quoteId: z.string().uuid('Quote ID must be a valid UUID'),
106
+ psbtBase64: z.string().min(1, 'PSBT cannot be empty'),
107
+ consignmentBase64: z
108
+ .string()
109
+ .min(1, 'Consignment data is required (base64-encoded)'),
101
110
  }) satisfies z.ZodType<SubmitPSBTRequest>;
102
111
 
103
112
  /**
@@ -17,6 +17,8 @@ export interface WalletConfig {
17
17
  enabled: boolean;
18
18
  /** Wallet keys (mnemonic, xpubs, etc.) */
19
19
  keys: Keys;
20
+ /** Absolute path to directory where wallet data will be stored. If not provided, defaults to app documents directory. */
21
+ dataDir?: string;
20
22
  /** Supported asset schemas */
21
23
  supportedSchemas?: AssetSchema[];
22
24
  /** Maximum allocations per UTXO */
@@ -93,20 +95,26 @@ export const SDKOptionsSchema = z.object({
93
95
 
94
96
  /**
95
97
  * Zod schema for SDK configuration
98
+ *
99
+ * Note: `apiKey` is intentionally omitted here — it is validated manually in
100
+ * `validateSDKConfig` so it can be optional when Gas-Free / Watch Tower are off.
101
+ * Including it in Zod led to stale builds or edge cases surfacing as
102
+ * "apiKey: API key is required".
96
103
  */
97
- export const SDKConfigSchema = z.object({
98
- apiKey: z.string().min(1, 'API key is required'),
99
- environment: z.nativeEnum(Environment).default(Environment.MAINNET),
100
- features: z
101
- .object({
102
- gasFree: GasFreeFeatureConfigSchema.optional(),
103
- watchTower: WatchTowerFeatureConfigSchema.optional(),
104
- })
105
- .passthrough()
106
- .optional(),
107
- logging: LoggingConfigSchema.optional(),
108
- options: SDKOptionsSchema.optional(),
109
- });
104
+ export const SDKConfigSchema = z
105
+ .object({
106
+ environment: z.nativeEnum(Environment).default(Environment.MAINNET),
107
+ features: z
108
+ .object({
109
+ gasFree: GasFreeFeatureConfigSchema.optional(),
110
+ watchTower: WatchTowerFeatureConfigSchema.optional(),
111
+ })
112
+ .passthrough()
113
+ .optional(),
114
+ logging: LoggingConfigSchema.optional(),
115
+ options: SDKOptionsSchema.optional(),
116
+ })
117
+ .passthrough();
110
118
 
111
119
  /**
112
120
  * SDK Configuration
@@ -114,9 +122,10 @@ export const SDKConfigSchema = z.object({
114
122
  export interface SDKConfig {
115
123
  /**
116
124
  * API key for Orbis services (Watch Tower, Gas-Free, etc.).
117
- * Required for all backend services.
125
+ * Required when `features.gasFree.enabled` or `features.watchTower.enabled` is true.
126
+ * Omit for local RGB / wallet-only usage when those features are disabled.
118
127
  */
119
- apiKey: string;
128
+ apiKey?: string;
120
129
 
121
130
  /**
122
131
  * SDK environment (testnet or mainnet).
@@ -207,15 +216,38 @@ export function validateSDKConfig(config: SDKConfig): void {
207
216
  const path = err.path.join('.');
208
217
  return path ? `${path}: ${err.message}` : err.message;
209
218
  });
210
- throw new Error(
211
- `Configuration validation failed:\n - ${messages.join('\n - ')}`
212
- );
219
+ // No outer "Configuration validation failed" prefix — Orbis1SDK wraps once
220
+ throw new Error(messages.join('\n - '));
213
221
  }
214
222
  throw error;
215
223
  }
216
224
 
217
- // Validate API key prefix matches environment
218
- const apiKey = config.apiKey;
225
+ if (
226
+ config.apiKey !== undefined &&
227
+ config.apiKey !== null &&
228
+ typeof config.apiKey !== 'string'
229
+ ) {
230
+ throw new Error('apiKey must be a string when provided');
231
+ }
232
+
233
+ const needsApiKey =
234
+ config.features?.gasFree?.enabled === true ||
235
+ config.features?.watchTower?.enabled === true;
236
+
237
+ const apiKeyTrimmed =
238
+ typeof config.apiKey === 'string' ? config.apiKey.trim() : '';
239
+ const apiKey = apiKeyTrimmed.length > 0 ? apiKeyTrimmed : undefined;
240
+
241
+ if (needsApiKey && !apiKey) {
242
+ throw new Error(
243
+ 'API key is required when Gas-Free or Watch Tower is enabled'
244
+ );
245
+ }
246
+
247
+ if (!apiKey) {
248
+ return;
249
+ }
250
+
219
251
  const environment = config.environment ?? Environment.MAINNET;
220
252
 
221
253
  if (
@@ -249,8 +281,14 @@ export function validateSDKConfig(config: SDKConfig): void {
249
281
  * @returns Merged configuration with defaults
250
282
  */
251
283
  export function mergeWithDefaults(config: SDKConfig): SDKConfig {
284
+ const apiKeyNormalized =
285
+ typeof config.apiKey === 'string'
286
+ ? config.apiKey.trim() || undefined
287
+ : config.apiKey;
288
+
252
289
  return {
253
290
  ...config,
291
+ apiKey: apiKeyNormalized,
254
292
  environment: config.environment ?? Environment.MAINNET,
255
293
  features: {
256
294
  ...DEFAULT_SDK_CONFIG.features,