orbis1-sdk-rn 0.0.10 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -2
- package/android/src/main/java/com/orbis1sdk/RgbModule.kt +18 -4
- package/ios/Orbis1Sdk.mm +6 -3
- package/ios/Rgb.mm +6 -3
- package/ios/Rgb.swift +21 -8
- package/lib/module/Orbis1SDK.js +1 -0
- package/lib/module/Orbis1SDK.js.map +1 -1
- package/lib/module/core/NativeRgb.js.map +1 -1
- package/lib/module/core/Wallet.js +3 -1
- package/lib/module/core/Wallet.js.map +1 -1
- package/lib/module/features/gas-free/GasFreeModule.js +19 -40
- package/lib/module/features/gas-free/GasFreeModule.js.map +1 -1
- package/lib/module/features/gas-free/client/ServiceClient.js +0 -3
- package/lib/module/features/gas-free/client/ServiceClient.js.map +1 -1
- package/lib/module/features/gas-free/types/FeeQuote.js.map +1 -1
- package/lib/module/features/gas-free/types/GasFreeResult.js.map +1 -1
- package/lib/module/features/gas-free/utils/validation.js +7 -6
- package/lib/module/features/gas-free/utils/validation.js.map +1 -1
- package/lib/module/types/SDKConfig.js.map +1 -1
- package/lib/typescript/src/Orbis1SDK.d.ts.map +1 -1
- package/lib/typescript/src/core/NativeRgb.d.ts +1 -1
- package/lib/typescript/src/core/NativeRgb.d.ts.map +1 -1
- package/lib/typescript/src/core/Wallet.d.ts +3 -0
- package/lib/typescript/src/core/Wallet.d.ts.map +1 -1
- package/lib/typescript/src/features/gas-free/GasFreeModule.d.ts +3 -14
- package/lib/typescript/src/features/gas-free/GasFreeModule.d.ts.map +1 -1
- package/lib/typescript/src/features/gas-free/client/ServiceClient.d.ts.map +1 -1
- package/lib/typescript/src/features/gas-free/types/FeeQuote.d.ts +6 -2
- package/lib/typescript/src/features/gas-free/types/FeeQuote.d.ts.map +1 -1
- package/lib/typescript/src/features/gas-free/types/GasFreeRequest.d.ts +1 -1
- package/lib/typescript/src/features/gas-free/types/GasFreeRequest.d.ts.map +1 -1
- package/lib/typescript/src/features/gas-free/types/GasFreeResult.d.ts +0 -2
- package/lib/typescript/src/features/gas-free/types/GasFreeResult.d.ts.map +1 -1
- package/lib/typescript/src/features/gas-free/utils/validation.d.ts +16 -13
- package/lib/typescript/src/features/gas-free/utils/validation.d.ts.map +1 -1
- package/lib/typescript/src/types/SDKConfig.d.ts +2 -0
- package/lib/typescript/src/types/SDKConfig.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/Orbis1SDK.ts +1 -0
- package/src/core/NativeRgb.ts +1 -0
- package/src/core/Wallet.ts +5 -0
- package/src/features/gas-free/GasFreeModule.ts +16 -44
- package/src/features/gas-free/client/ServiceClient.ts +0 -6
- package/src/features/gas-free/types/FeeQuote.ts +6 -2
- package/src/features/gas-free/types/GasFreeRequest.ts +1 -1
- package/src/features/gas-free/types/GasFreeResult.ts +0 -2
- package/src/features/gas-free/utils/validation.ts +14 -5
- package/src/types/SDKConfig.ts +2 -0
|
@@ -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 */
|
|
@@ -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,MAAM,WAAW,YAAY;IAC3B,kCAAkC;IAClC,OAAO,EAAE,OAAO,CAAC;IACjB,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;KACzE,CAAC;IAEF;;OAEG;IACH,OAAO,CAAC,EAAE;QACR,8CAA8C;QAC9C,UAAU,CAAC,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.
|
|
3
|
+
"version": "0.2.1",
|
|
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/
|
|
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/
|
|
65
|
+
"url": "https://github.com/Orbis-1/orbis1-sdk-rn/issues"
|
|
66
66
|
},
|
|
67
|
-
"homepage": "https://github.com/
|
|
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,
|
package/src/core/NativeRgb.ts
CHANGED
package/src/core/Wallet.ts
CHANGED
|
@@ -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,
|
|
@@ -31,7 +31,7 @@ import type {
|
|
|
31
31
|
TransferState,
|
|
32
32
|
} from './types';
|
|
33
33
|
import { GasFreeError, GasFreeErrorCode } from './errors/GasFreeError';
|
|
34
|
-
import type { AssignmentType
|
|
34
|
+
import type { AssignmentType } from '../../core/Interfaces';
|
|
35
35
|
import { Feature } from '../../types/Feature';
|
|
36
36
|
|
|
37
37
|
/**
|
|
@@ -169,24 +169,6 @@ export class GasFreeModule implements IFeatureModule<GasFreeConfig> {
|
|
|
169
169
|
throw GasFreeError.notInitialized();
|
|
170
170
|
}
|
|
171
171
|
|
|
172
|
-
// Decode the recipient invoice up-front so we can inspect the seal type.
|
|
173
|
-
// This also validates the invoice format before touching the backend.
|
|
174
|
-
const decodedRecipientInvoice = await this.wallet!.decodeInvoice(
|
|
175
|
-
request.recipientInvoice
|
|
176
|
-
);
|
|
177
|
-
|
|
178
|
-
// Witness-output invoices (wvout:) are not yet supported for gas-free
|
|
179
|
-
// transfers because sendEnd requires additional changes to handle the
|
|
180
|
-
// extra Bitcoin output they introduce. Reject early so no backend call
|
|
181
|
-
// is made and the user gets a clear actionable message.
|
|
182
|
-
if (this.isWitnessRecipient(decodedRecipientInvoice)) {
|
|
183
|
-
throw new GasFreeError(
|
|
184
|
-
'Witness invoices (wvout) are not yet supported for gas-free transfers. ' +
|
|
185
|
-
'Please ask the recipient to generate a blinded-UTXO invoice instead.',
|
|
186
|
-
GasFreeErrorCode.INVALID_REQUEST
|
|
187
|
-
);
|
|
188
|
-
}
|
|
189
|
-
|
|
190
172
|
// Reset state
|
|
191
173
|
this.currentState = { status: 'idle' };
|
|
192
174
|
|
|
@@ -279,7 +261,6 @@ export class GasFreeModule implements IFeatureModule<GasFreeConfig> {
|
|
|
279
261
|
const submitResult = await this.submitPSBT(
|
|
280
262
|
feeQuote.quoteId,
|
|
281
263
|
psbtResult,
|
|
282
|
-
feeQuote.serviceFeeInvoice,
|
|
283
264
|
request.assetId
|
|
284
265
|
);
|
|
285
266
|
|
|
@@ -291,9 +272,7 @@ export class GasFreeModule implements IFeatureModule<GasFreeConfig> {
|
|
|
291
272
|
submitResult.signedPsbtBase64
|
|
292
273
|
);
|
|
293
274
|
|
|
294
|
-
// Step 4: Notify service of successful broadcast
|
|
295
|
-
// The service uses txid to confirm the transaction landed in mempool
|
|
296
|
-
// and calls its own wallet.refresh() to claim the RGB service fee.
|
|
275
|
+
// Step 4: Notify service of successful broadcast
|
|
297
276
|
await this.verifyTransfer(feeQuote.quoteId, txid, userSignedPsbt);
|
|
298
277
|
|
|
299
278
|
// Mark as verified
|
|
@@ -359,6 +338,7 @@ export class GasFreeModule implements IFeatureModule<GasFreeConfig> {
|
|
|
359
338
|
assetId: request.assetId,
|
|
360
339
|
numInputs: request.numInputs || 1, // defaults to 1 inputs if not provided (1 user input)
|
|
361
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,
|
|
362
342
|
});
|
|
363
343
|
|
|
364
344
|
// Check quote expiration
|
|
@@ -457,14 +437,17 @@ export class GasFreeModule implements IFeatureModule<GasFreeConfig> {
|
|
|
457
437
|
service: decodedServiceInvoice,
|
|
458
438
|
});
|
|
459
439
|
|
|
440
|
+
const recipientIsWitness = feeQuote.witnessUtxoFundingSats > 0;
|
|
441
|
+
|
|
460
442
|
// Build recipient map for sendBegin
|
|
461
|
-
// Note: Recipient requires assignment field with type and amount
|
|
443
|
+
// Note: Recipient requires assignment field with type and amount.
|
|
462
444
|
// Important: Decoded invoices may have 'ANY' type (wildcard), but sendBegin
|
|
463
445
|
// requires a concrete assignment type. Always use 'FUNGIBLE' for asset transfers.
|
|
464
446
|
const recipientMap: Record<
|
|
465
447
|
string,
|
|
466
448
|
Array<{
|
|
467
449
|
recipientId: string;
|
|
450
|
+
witnessData?: { amountSat: number; blinding?: number };
|
|
468
451
|
assignment: { type: AssignmentType; amount: number };
|
|
469
452
|
transportEndpoints: string[];
|
|
470
453
|
}>
|
|
@@ -473,6 +456,12 @@ export class GasFreeModule implements IFeatureModule<GasFreeConfig> {
|
|
|
473
456
|
{
|
|
474
457
|
// Recipient 1: The actual transfer to the merchant / end recipient
|
|
475
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
|
+
}),
|
|
476
465
|
assignment: {
|
|
477
466
|
// Use FUNGIBLE type for asset transfers (invoice may have 'ANY' wildcard type)
|
|
478
467
|
type: 'FUNGIBLE',
|
|
@@ -534,7 +523,6 @@ export class GasFreeModule implements IFeatureModule<GasFreeConfig> {
|
|
|
534
523
|
*
|
|
535
524
|
* @param quoteId - Quote ID from the fee quote
|
|
536
525
|
* @param psbtResult - PSBT build result from buildPSBT()
|
|
537
|
-
* @param serviceFeeInvoice - Service fee RGB invoice from the quote
|
|
538
526
|
* @param assetId - Asset ID being transferred
|
|
539
527
|
* @returns Submit result with service-signed PSBT
|
|
540
528
|
*
|
|
@@ -543,7 +531,6 @@ export class GasFreeModule implements IFeatureModule<GasFreeConfig> {
|
|
|
543
531
|
* const submitResult = await gasFree.submitPSBT(
|
|
544
532
|
* quote.quoteId,
|
|
545
533
|
* psbtResult,
|
|
546
|
-
* quote.serviceFeeInvoice,
|
|
547
534
|
* request.assetId
|
|
548
535
|
* );
|
|
549
536
|
* console.log('Service signed PSBT:', submitResult.signedPsbtBase64);
|
|
@@ -552,7 +539,6 @@ export class GasFreeModule implements IFeatureModule<GasFreeConfig> {
|
|
|
552
539
|
async submitPSBT(
|
|
553
540
|
quoteId: string,
|
|
554
541
|
psbtResult: PSBTBuildResult,
|
|
555
|
-
serviceFeeInvoice: string,
|
|
556
542
|
assetId: string
|
|
557
543
|
): Promise<PSBTSubmitResult> {
|
|
558
544
|
this.logger?.debug('Step 3: Reading consignment and submitting to service');
|
|
@@ -566,7 +552,6 @@ export class GasFreeModule implements IFeatureModule<GasFreeConfig> {
|
|
|
566
552
|
quoteId,
|
|
567
553
|
psbtBase64: psbtResult.unsignedPsbt,
|
|
568
554
|
consignmentBase64,
|
|
569
|
-
rgbInvoice: serviceFeeInvoice,
|
|
570
555
|
});
|
|
571
556
|
|
|
572
557
|
this.currentState.status = 'submitted';
|
|
@@ -638,7 +623,7 @@ export class GasFreeModule implements IFeatureModule<GasFreeConfig> {
|
|
|
638
623
|
*
|
|
639
624
|
* @param quoteId - Quote ID from the fee quote
|
|
640
625
|
* @param txid - Transaction ID from broadcastTransfer()
|
|
641
|
-
* @param signedPsbtBase64 -
|
|
626
|
+
* @param signedPsbtBase64 - Base64-encoded signed PSBT
|
|
642
627
|
* @returns Verification result from the service
|
|
643
628
|
*
|
|
644
629
|
* @example
|
|
@@ -646,7 +631,7 @@ export class GasFreeModule implements IFeatureModule<GasFreeConfig> {
|
|
|
646
631
|
* const verifyResult = await gasFree.verifyTransfer(
|
|
647
632
|
* quote.quoteId,
|
|
648
633
|
* broadcastResult.txid,
|
|
649
|
-
*
|
|
634
|
+
* signedPsbtBase64
|
|
650
635
|
* );
|
|
651
636
|
* console.log('Verification status:', verifyResult.status);
|
|
652
637
|
* console.log('In mempool:', verifyResult.inMempool);
|
|
@@ -662,8 +647,8 @@ export class GasFreeModule implements IFeatureModule<GasFreeConfig> {
|
|
|
662
647
|
const verifyResult = await this.serviceClient!.verifyTransfer({
|
|
663
648
|
quoteId,
|
|
664
649
|
transferSuccess: true,
|
|
665
|
-
signedPsbtBase64,
|
|
666
650
|
txid,
|
|
651
|
+
signedPsbtBase64,
|
|
667
652
|
});
|
|
668
653
|
|
|
669
654
|
this.logger?.debug('Transfer verified', {
|
|
@@ -676,19 +661,6 @@ export class GasFreeModule implements IFeatureModule<GasFreeConfig> {
|
|
|
676
661
|
return verifyResult;
|
|
677
662
|
}
|
|
678
663
|
|
|
679
|
-
/**
|
|
680
|
-
* Returns true if a decoded invoice targets a witness output (`wvout:`) seal.
|
|
681
|
-
*
|
|
682
|
-
* The `recipientId` returned by `decodeInvoice` for witness invoices follows
|
|
683
|
-
* the pattern `{network}:wvout:{sealData}` (e.g. `tb4:wvout:BYrJtiVZ-…`).
|
|
684
|
-
* Splitting on `:` and checking the second segment is more reliable than
|
|
685
|
-
* searching the raw invoice string.
|
|
686
|
-
*/
|
|
687
|
-
private isWitnessRecipient(decoded: InvoiceData): boolean {
|
|
688
|
-
const parts = decoded.recipientId.split(':');
|
|
689
|
-
return parts[1] === 'wvout';
|
|
690
|
-
}
|
|
691
|
-
|
|
692
664
|
/**
|
|
693
665
|
* Validate configuration
|
|
694
666
|
*/
|
|
@@ -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
|
|
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://...']) */
|
|
@@ -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().
|
|
98
|
-
psbtBase64: z.string().min(1, 'PSBT
|
|
99
|
-
consignmentBase64: z
|
|
100
|
-
|
|
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
|
/**
|
package/src/types/SDKConfig.ts
CHANGED
|
@@ -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 */
|