react-native-bdk-sdk 0.1.5 → 0.1.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/cpp/generated/bdk_ffi.cpp +122 -0
- package/cpp/generated/bdk_ffi.hpp +6 -0
- package/lib/commonjs/generated/bdk_ffi-ffi.js.map +1 -1
- package/lib/commonjs/generated/bdk_ffi.js +132 -7
- package/lib/commonjs/generated/bdk_ffi.js.map +1 -1
- package/lib/commonjs/index.js +14 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/wrapper.js +433 -0
- package/lib/commonjs/wrapper.js.map +1 -0
- package/lib/module/generated/bdk_ffi-ffi.js.map +1 -1
- package/lib/module/generated/bdk_ffi.js +128 -6
- package/lib/module/generated/bdk_ffi.js.map +1 -1
- package/lib/module/index.js +3 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/wrapper.js +427 -0
- package/lib/module/wrapper.js.map +1 -0
- package/lib/typescript/commonjs/src/generated/bdk_ffi-ffi.d.ts +6 -0
- package/lib/typescript/commonjs/src/generated/bdk_ffi-ffi.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/generated/bdk_ffi.d.ts +61 -2
- package/lib/typescript/commonjs/src/generated/bdk_ffi.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/index.d.ts +1 -0
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/wrapper.d.ts +168 -0
- package/lib/typescript/commonjs/src/wrapper.d.ts.map +1 -0
- package/lib/typescript/module/src/generated/bdk_ffi-ffi.d.ts +6 -0
- package/lib/typescript/module/src/generated/bdk_ffi-ffi.d.ts.map +1 -1
- package/lib/typescript/module/src/generated/bdk_ffi.d.ts +61 -2
- package/lib/typescript/module/src/generated/bdk_ffi.d.ts.map +1 -1
- package/lib/typescript/module/src/index.d.ts +1 -0
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/wrapper.d.ts +168 -0
- package/lib/typescript/module/src/wrapper.d.ts.map +1 -0
- package/package.json +3 -3
- package/src/generated/bdk_ffi-ffi.ts +20 -0
- package/src/generated/bdk_ffi.ts +232 -7
- package/src/index.tsx +3 -0
- package/src/wrapper.ts +614 -0
|
@@ -20,6 +20,14 @@ typeof process !== "object" ||
|
|
|
20
20
|
process?.env?.NODE_ENV !== "production" || false;
|
|
21
21
|
// Public interface members begin here.
|
|
22
22
|
|
|
23
|
+
/**
|
|
24
|
+
* Convert a scriptPubKey (hex) to an address string for the given network.
|
|
25
|
+
*/
|
|
26
|
+
export function addressFromScript(scriptHex, network) /*throws*/{
|
|
27
|
+
return FfiConverterString.lift(uniffiCaller.rustCallWithError(/*liftError:*/FfiConverterTypeBdkError.lift.bind(FfiConverterTypeBdkError), /*caller:*/callStatus => {
|
|
28
|
+
return nativeModule().ubrn_uniffi_bdk_ffi_fn_func_address_from_script(FfiConverterString.lower(scriptHex), FfiConverterTypeNetwork.lower(network), callStatus);
|
|
29
|
+
}, /*liftString:*/FfiConverterString.lift));
|
|
30
|
+
}
|
|
23
31
|
/**
|
|
24
32
|
* Generate an output descriptor string from a mnemonic using a standard BIP template.
|
|
25
33
|
*/
|
|
@@ -28,6 +36,14 @@ export function createDescriptor(mnemonic, template, keychain, network) /*throws
|
|
|
28
36
|
return nativeModule().ubrn_uniffi_bdk_ffi_fn_func_create_descriptor(FfiConverterTypeMnemonic.lower(mnemonic), FfiConverterTypeDescriptorTemplate.lower(template), FfiConverterTypeKeychainKind.lower(keychain), FfiConverterTypeNetwork.lower(network), callStatus);
|
|
29
37
|
}, /*liftString:*/FfiConverterString.lift));
|
|
30
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* Generate an output descriptor from a mnemonic string directly (convenience).
|
|
41
|
+
*/
|
|
42
|
+
export function createDescriptorFromString(mnemonic, template, keychain, network) /*throws*/{
|
|
43
|
+
return FfiConverterString.lift(uniffiCaller.rustCallWithError(/*liftError:*/FfiConverterTypeBdkError.lift.bind(FfiConverterTypeBdkError), /*caller:*/callStatus => {
|
|
44
|
+
return nativeModule().ubrn_uniffi_bdk_ffi_fn_func_create_descriptor_from_string(FfiConverterString.lower(mnemonic), FfiConverterTypeDescriptorTemplate.lower(template), FfiConverterTypeKeychainKind.lower(keychain), FfiConverterTypeNetwork.lower(network), callStatus);
|
|
45
|
+
}, /*liftString:*/FfiConverterString.lift));
|
|
46
|
+
}
|
|
31
47
|
/**
|
|
32
48
|
* Generate a public (watch-only) descriptor from an xpub string.
|
|
33
49
|
*/
|
|
@@ -46,12 +62,13 @@ export function createSingleKeyDescriptor(key, template, network) /*throws*/{
|
|
|
46
62
|
}
|
|
47
63
|
/**
|
|
48
64
|
* Async wallet factory — creates or loads a wallet without blocking the JS thread.
|
|
65
|
+
* Pass null for change_descriptor to use the main descriptor for both keychains.
|
|
49
66
|
*/
|
|
50
67
|
export async function createWallet(descriptor, changeDescriptor, network, dbPath, asyncOpts_) /*throws*/{
|
|
51
68
|
const __stack = uniffiIsDebug ? new Error().stack : undefined;
|
|
52
69
|
try {
|
|
53
70
|
return await uniffiRustCallAsync(/*rustCaller:*/uniffiCaller, /*rustFutureFunc:*/() => {
|
|
54
|
-
return nativeModule().ubrn_uniffi_bdk_ffi_fn_func_create_wallet(FfiConverterString.lower(descriptor),
|
|
71
|
+
return nativeModule().ubrn_uniffi_bdk_ffi_fn_func_create_wallet(FfiConverterString.lower(descriptor), FfiConverterOptionalString.lower(changeDescriptor), FfiConverterTypeNetwork.lower(network), FfiConverterString.lower(dbPath));
|
|
55
72
|
}, /*pollFunc:*/nativeModule().ubrn_ffi_bdk_ffi_rust_future_poll_u64, /*cancelFunc:*/nativeModule().ubrn_ffi_bdk_ffi_rust_future_cancel_u64, /*completeFunc:*/nativeModule().ubrn_ffi_bdk_ffi_rust_future_complete_u64, /*freeFunc:*/nativeModule().ubrn_ffi_bdk_ffi_rust_future_free_u64, /*liftFunc:*/FfiConverterTypeWallet.lift.bind(FfiConverterTypeWallet), /*liftString:*/FfiConverterString.lift, /*asyncOpts:*/asyncOpts_, /*errorHandler:*/FfiConverterTypeBdkError.lift.bind(FfiConverterTypeBdkError));
|
|
56
73
|
} catch (__error) {
|
|
57
74
|
if (uniffiIsDebug && __error instanceof Error) {
|
|
@@ -76,6 +93,14 @@ export function isValidAddress(address, network) {
|
|
|
76
93
|
return nativeModule().ubrn_uniffi_bdk_ffi_fn_func_is_valid_address(FfiConverterString.lower(address), FfiConverterTypeNetwork.lower(network), callStatus);
|
|
77
94
|
}, /*liftString:*/FfiConverterString.lift));
|
|
78
95
|
}
|
|
96
|
+
/**
|
|
97
|
+
* Validate a descriptor string for the given network without creating a wallet.
|
|
98
|
+
*/
|
|
99
|
+
export function validateDescriptor(descriptor, network) {
|
|
100
|
+
return FfiConverterBool.lift(uniffiCaller.rustCall(/*caller:*/callStatus => {
|
|
101
|
+
return nativeModule().ubrn_uniffi_bdk_ffi_fn_func_validate_descriptor(FfiConverterString.lower(descriptor), FfiConverterTypeNetwork.lower(network), callStatus);
|
|
102
|
+
}, /*liftString:*/FfiConverterString.lift));
|
|
103
|
+
}
|
|
79
104
|
/**
|
|
80
105
|
* Runtime version of the bdk_wallet crate.
|
|
81
106
|
*/
|
|
@@ -457,7 +482,11 @@ const FfiConverterTypeTxDetails = (() => {
|
|
|
457
482
|
feeRate: FfiConverterOptionalFloat64.read(from),
|
|
458
483
|
balanceDelta: FfiConverterInt64.read(from),
|
|
459
484
|
confirmationBlockTime: FfiConverterOptionalTypeConfirmationBlockTime.read(from),
|
|
460
|
-
txHex: FfiConverterString.read(from)
|
|
485
|
+
txHex: FfiConverterString.read(from),
|
|
486
|
+
version: FfiConverterInt32.read(from),
|
|
487
|
+
locktime: FfiConverterUInt32.read(from),
|
|
488
|
+
inputs: FfiConverterArrayTypeTxInput.read(from),
|
|
489
|
+
outputs: FfiConverterArrayTypeTxOutput.read(from)
|
|
461
490
|
};
|
|
462
491
|
}
|
|
463
492
|
write(value, into) {
|
|
@@ -469,9 +498,51 @@ const FfiConverterTypeTxDetails = (() => {
|
|
|
469
498
|
FfiConverterInt64.write(value.balanceDelta, into);
|
|
470
499
|
FfiConverterOptionalTypeConfirmationBlockTime.write(value.confirmationBlockTime, into);
|
|
471
500
|
FfiConverterString.write(value.txHex, into);
|
|
501
|
+
FfiConverterInt32.write(value.version, into);
|
|
502
|
+
FfiConverterUInt32.write(value.locktime, into);
|
|
503
|
+
FfiConverterArrayTypeTxInput.write(value.inputs, into);
|
|
504
|
+
FfiConverterArrayTypeTxOutput.write(value.outputs, into);
|
|
472
505
|
}
|
|
473
506
|
allocationSize(value) {
|
|
474
|
-
return FfiConverterString.allocationSize(value.txid) + FfiConverterUInt64.allocationSize(value.sent) + FfiConverterUInt64.allocationSize(value.received) + FfiConverterOptionalUInt64.allocationSize(value.fee) + FfiConverterOptionalFloat64.allocationSize(value.feeRate) + FfiConverterInt64.allocationSize(value.balanceDelta) + FfiConverterOptionalTypeConfirmationBlockTime.allocationSize(value.confirmationBlockTime) + FfiConverterString.allocationSize(value.txHex);
|
|
507
|
+
return FfiConverterString.allocationSize(value.txid) + FfiConverterUInt64.allocationSize(value.sent) + FfiConverterUInt64.allocationSize(value.received) + FfiConverterOptionalUInt64.allocationSize(value.fee) + FfiConverterOptionalFloat64.allocationSize(value.feeRate) + FfiConverterInt64.allocationSize(value.balanceDelta) + FfiConverterOptionalTypeConfirmationBlockTime.allocationSize(value.confirmationBlockTime) + FfiConverterString.allocationSize(value.txHex) + FfiConverterInt32.allocationSize(value.version) + FfiConverterUInt32.allocationSize(value.locktime) + FfiConverterArrayTypeTxInput.allocationSize(value.inputs) + FfiConverterArrayTypeTxOutput.allocationSize(value.outputs);
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
return new FFIConverter();
|
|
511
|
+
})();
|
|
512
|
+
/**
|
|
513
|
+
* Generated factory for {@link TxInput} record objects.
|
|
514
|
+
*/
|
|
515
|
+
export const TxInput = (() => {
|
|
516
|
+
const defaults = () => ({});
|
|
517
|
+
const create = (() => {
|
|
518
|
+
return uniffiCreateRecord(defaults);
|
|
519
|
+
})();
|
|
520
|
+
return Object.freeze({
|
|
521
|
+
create,
|
|
522
|
+
new: create,
|
|
523
|
+
defaults: () => Object.freeze(defaults())
|
|
524
|
+
});
|
|
525
|
+
})();
|
|
526
|
+
const FfiConverterTypeTxInput = (() => {
|
|
527
|
+
class FFIConverter extends AbstractFfiConverterByteArray {
|
|
528
|
+
read(from) {
|
|
529
|
+
return {
|
|
530
|
+
previousTxid: FfiConverterString.read(from),
|
|
531
|
+
previousVout: FfiConverterUInt32.read(from),
|
|
532
|
+
sequence: FfiConverterUInt32.read(from),
|
|
533
|
+
scriptSigHex: FfiConverterString.read(from),
|
|
534
|
+
witness: FfiConverterArrayString.read(from)
|
|
535
|
+
};
|
|
536
|
+
}
|
|
537
|
+
write(value, into) {
|
|
538
|
+
FfiConverterString.write(value.previousTxid, into);
|
|
539
|
+
FfiConverterUInt32.write(value.previousVout, into);
|
|
540
|
+
FfiConverterUInt32.write(value.sequence, into);
|
|
541
|
+
FfiConverterString.write(value.scriptSigHex, into);
|
|
542
|
+
FfiConverterArrayString.write(value.witness, into);
|
|
543
|
+
}
|
|
544
|
+
allocationSize(value) {
|
|
545
|
+
return FfiConverterString.allocationSize(value.previousTxid) + FfiConverterUInt32.allocationSize(value.previousVout) + FfiConverterUInt32.allocationSize(value.sequence) + FfiConverterString.allocationSize(value.scriptSigHex) + FfiConverterArrayString.allocationSize(value.witness);
|
|
475
546
|
}
|
|
476
547
|
}
|
|
477
548
|
return new FFIConverter();
|
|
@@ -508,6 +579,40 @@ const FfiConverterTypeTxOut = (() => {
|
|
|
508
579
|
}
|
|
509
580
|
return new FFIConverter();
|
|
510
581
|
})();
|
|
582
|
+
/**
|
|
583
|
+
* Generated factory for {@link TxOutput} record objects.
|
|
584
|
+
*/
|
|
585
|
+
export const TxOutput = (() => {
|
|
586
|
+
const defaults = () => ({});
|
|
587
|
+
const create = (() => {
|
|
588
|
+
return uniffiCreateRecord(defaults);
|
|
589
|
+
})();
|
|
590
|
+
return Object.freeze({
|
|
591
|
+
create,
|
|
592
|
+
new: create,
|
|
593
|
+
defaults: () => Object.freeze(defaults())
|
|
594
|
+
});
|
|
595
|
+
})();
|
|
596
|
+
const FfiConverterTypeTxOutput = (() => {
|
|
597
|
+
class FFIConverter extends AbstractFfiConverterByteArray {
|
|
598
|
+
read(from) {
|
|
599
|
+
return {
|
|
600
|
+
value: FfiConverterUInt64.read(from),
|
|
601
|
+
scriptPubkeyHex: FfiConverterString.read(from),
|
|
602
|
+
address: FfiConverterOptionalString.read(from)
|
|
603
|
+
};
|
|
604
|
+
}
|
|
605
|
+
write(value, into) {
|
|
606
|
+
FfiConverterUInt64.write(value.value, into);
|
|
607
|
+
FfiConverterString.write(value.scriptPubkeyHex, into);
|
|
608
|
+
FfiConverterOptionalString.write(value.address, into);
|
|
609
|
+
}
|
|
610
|
+
allocationSize(value) {
|
|
611
|
+
return FfiConverterUInt64.allocationSize(value.value) + FfiConverterString.allocationSize(value.scriptPubkeyHex) + FfiConverterOptionalString.allocationSize(value.address);
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
return new FFIConverter();
|
|
615
|
+
})();
|
|
511
616
|
const stringConverter = {
|
|
512
617
|
stringToBytes: s => uniffiCaller.rustCall(status => nativeModule().ubrn_uniffi_internal_fn_func_ffi__string_to_arraybuffer(s, status)),
|
|
513
618
|
bytesToString: ab => uniffiCaller.rustCall(status => nativeModule().ubrn_uniffi_internal_fn_func_ffi__arraybuffer_to_string(ab, status)),
|
|
@@ -3784,7 +3889,7 @@ export class Wallet extends UniffiAbstractObject {
|
|
|
3784
3889
|
constructor(descriptor, changeDescriptor, network, dbPath) /*throws*/{
|
|
3785
3890
|
super();
|
|
3786
3891
|
const pointer = uniffiCaller.rustCallWithError(/*liftError:*/FfiConverterTypeBdkError.lift.bind(FfiConverterTypeBdkError), /*caller:*/callStatus => {
|
|
3787
|
-
return nativeModule().ubrn_uniffi_bdk_ffi_fn_constructor_wallet_new(FfiConverterString.lower(descriptor),
|
|
3892
|
+
return nativeModule().ubrn_uniffi_bdk_ffi_fn_constructor_wallet_new(FfiConverterString.lower(descriptor), FfiConverterOptionalString.lower(changeDescriptor), FfiConverterTypeNetwork.lower(network), FfiConverterString.lower(dbPath), callStatus);
|
|
3788
3893
|
}, /*liftString:*/FfiConverterString.lift);
|
|
3789
3894
|
this[pointerLiteralSymbol] = pointer;
|
|
3790
3895
|
this[destructorGuardSymbol] = uniffiTypeWalletObjectFactory.bless(pointer);
|
|
@@ -4193,6 +4298,12 @@ const FfiConverterArrayTypeRecipient = new FfiConverterArray(FfiConverterTypeRec
|
|
|
4193
4298
|
// FfiConverter for Array<TxDetails>
|
|
4194
4299
|
const FfiConverterArrayTypeTxDetails = new FfiConverterArray(FfiConverterTypeTxDetails);
|
|
4195
4300
|
|
|
4301
|
+
// FfiConverter for Array<TxInput>
|
|
4302
|
+
const FfiConverterArrayTypeTxInput = new FfiConverterArray(FfiConverterTypeTxInput);
|
|
4303
|
+
|
|
4304
|
+
// FfiConverter for Array<TxOutput>
|
|
4305
|
+
const FfiConverterArrayTypeTxOutput = new FfiConverterArray(FfiConverterTypeTxOutput);
|
|
4306
|
+
|
|
4196
4307
|
// FfiConverter for Array<string>
|
|
4197
4308
|
const FfiConverterArrayString = new FfiConverterArray(FfiConverterString);
|
|
4198
4309
|
|
|
@@ -4217,16 +4328,22 @@ function uniffiEnsureInitialized() {
|
|
|
4217
4328
|
if (bindingsContractVersion !== scaffoldingContractVersion) {
|
|
4218
4329
|
throw new UniffiInternalError.ContractVersionMismatch(scaffoldingContractVersion, bindingsContractVersion);
|
|
4219
4330
|
}
|
|
4331
|
+
if (nativeModule().ubrn_uniffi_bdk_ffi_checksum_func_address_from_script() !== 50547) {
|
|
4332
|
+
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_bdk_ffi_checksum_func_address_from_script");
|
|
4333
|
+
}
|
|
4220
4334
|
if (nativeModule().ubrn_uniffi_bdk_ffi_checksum_func_create_descriptor() !== 166) {
|
|
4221
4335
|
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_bdk_ffi_checksum_func_create_descriptor");
|
|
4222
4336
|
}
|
|
4337
|
+
if (nativeModule().ubrn_uniffi_bdk_ffi_checksum_func_create_descriptor_from_string() !== 29727) {
|
|
4338
|
+
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_bdk_ffi_checksum_func_create_descriptor_from_string");
|
|
4339
|
+
}
|
|
4223
4340
|
if (nativeModule().ubrn_uniffi_bdk_ffi_checksum_func_create_public_descriptor() !== 10610) {
|
|
4224
4341
|
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_bdk_ffi_checksum_func_create_public_descriptor");
|
|
4225
4342
|
}
|
|
4226
4343
|
if (nativeModule().ubrn_uniffi_bdk_ffi_checksum_func_create_single_key_descriptor() !== 56046) {
|
|
4227
4344
|
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_bdk_ffi_checksum_func_create_single_key_descriptor");
|
|
4228
4345
|
}
|
|
4229
|
-
if (nativeModule().ubrn_uniffi_bdk_ffi_checksum_func_create_wallet() !==
|
|
4346
|
+
if (nativeModule().ubrn_uniffi_bdk_ffi_checksum_func_create_wallet() !== 59494) {
|
|
4230
4347
|
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_bdk_ffi_checksum_func_create_wallet");
|
|
4231
4348
|
}
|
|
4232
4349
|
if (nativeModule().ubrn_uniffi_bdk_ffi_checksum_func_export_wallet() !== 53701) {
|
|
@@ -4235,6 +4352,9 @@ function uniffiEnsureInitialized() {
|
|
|
4235
4352
|
if (nativeModule().ubrn_uniffi_bdk_ffi_checksum_func_is_valid_address() !== 14593) {
|
|
4236
4353
|
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_bdk_ffi_checksum_func_is_valid_address");
|
|
4237
4354
|
}
|
|
4355
|
+
if (nativeModule().ubrn_uniffi_bdk_ffi_checksum_func_validate_descriptor() !== 44572) {
|
|
4356
|
+
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_bdk_ffi_checksum_func_validate_descriptor");
|
|
4357
|
+
}
|
|
4238
4358
|
if (nativeModule().ubrn_uniffi_bdk_ffi_checksum_func_version() !== 5205) {
|
|
4239
4359
|
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_bdk_ffi_checksum_func_version");
|
|
4240
4360
|
}
|
|
@@ -4523,7 +4643,7 @@ function uniffiEnsureInitialized() {
|
|
|
4523
4643
|
if (nativeModule().ubrn_uniffi_bdk_ffi_checksum_constructor_txbuilder_new() !== 16691) {
|
|
4524
4644
|
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_bdk_ffi_checksum_constructor_txbuilder_new");
|
|
4525
4645
|
}
|
|
4526
|
-
if (nativeModule().ubrn_uniffi_bdk_ffi_checksum_constructor_wallet_new() !==
|
|
4646
|
+
if (nativeModule().ubrn_uniffi_bdk_ffi_checksum_constructor_wallet_new() !== 64812) {
|
|
4527
4647
|
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_bdk_ffi_checksum_constructor_wallet_new");
|
|
4528
4648
|
}
|
|
4529
4649
|
}
|
|
@@ -4552,8 +4672,10 @@ export default Object.freeze({
|
|
|
4552
4672
|
FfiConverterTypeSingleKeyDescriptorTemplate,
|
|
4553
4673
|
FfiConverterTypeTxBuilder,
|
|
4554
4674
|
FfiConverterTypeTxDetails,
|
|
4675
|
+
FfiConverterTypeTxInput,
|
|
4555
4676
|
FfiConverterTypeTxOrdering,
|
|
4556
4677
|
FfiConverterTypeTxOut,
|
|
4678
|
+
FfiConverterTypeTxOutput,
|
|
4557
4679
|
FfiConverterTypeWallet,
|
|
4558
4680
|
FfiConverterTypeWalletEvent,
|
|
4559
4681
|
FfiConverterTypeWordCount
|