diff --git a/.gitignore b/.gitignore index 7e59e334..8f3c40a3 100644 --- a/.gitignore +++ b/.gitignore @@ -7,7 +7,6 @@ .atom/ .buildlog/ .history -_DelSyncFiles .svn/ migrate_working_dir/ .vscode/settings.json diff --git a/CHANGELOG.md b/CHANGELOG.md index ce5fdccb..fb8917ea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,22 +1,55 @@ +## [0.3.0] +Updated Rust ( Bdk to latest version 0.26.0 ) and Flutter dependencies. + +#### APIs changed + + - The descriptor and changeDescriptor arguments on the wallet constructor now take a `Descriptor` instead of a String. + +#### APIs added + + - Added RpcConfig, BlockchainConfig.rpc + - Added Descriptor type with the following named constructors: + - Default `create` constructor, that requires a descriptor in String format and a Network + - newBip44 constructor returns a Descriptor with structure pkh(key/44'/{0,1}'/0'/{0,1}/*) + - newBip44Public constructor returns a Descriptor with structure pkh(key/{0,1}/*) + - newBip49 constructor returns a Descriptor with structure sh(wpkh(key/49'/{0,1}'/0'/{0,1}/*)) + - newBip49Public constructor returns a Descriptor with structure sh(wpkh(key/{0,1}/*)) + - newBip84 constructor returns a Descriptor with structure wpkh(key/84'/{0,1}'/0'/{0,1}/*) + - newBip84Public constructor returns a Descriptor with structure wpkh(key/{0,1}/*) + - asString returns the public version of the output descriptor in String format + - asPrivateString returns the private version of the output descriptor if available, otherwise, return the public version + +### Fixed + +- Dependencies Upgraded + ## [0.2.3] + ### Fixed + - pub.dev analysis score ## [0.2.2] + ### Fixed + - pub.dev analysis score ## [0.2.1] + ### Fixed + - pub.dev static analysis warning - removing internal helper functions from public api ## [0.2.0] + Updated API to match bdk-ffi ## [0.1.4] #### Functionality Added + - Generate Mnemonic method - Create Descriptors - Create Extended Key diff --git a/README.md b/README.md index cfc6d697..e2e65ecc 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ To use the `bdk_flutter` package in your project, add it as a dependency in your ```dart dependencies: - bdk_flutter: ^0.2.3 + bdk_flutter: ^0.3.0 ``` `bdk-flutter` can then be imported and used in your Flutter code. For example: ```dart @@ -20,19 +20,35 @@ import 'package:bdk_flutter/bdk_flutter.dart'; // .... -final externalDescriptor = "wpkh([b8b575c2/84'/1'/0'/0]tprv8icWtRzy9CWgFxpGMLSdAeE4wWyz39XGc6SwykeTo13tYm14JkVVQAf7jz8DDarCgNJrG3aEPJEqchDWeJdiaWpS3FwbLB9SzsN57V7qxB/*)" -final internalDescriptor = "wpkh([b8b575c2/84'/1'/0'/1]tprv8icWtRzy9CWgFxpGMLSdAeE4wWyz39XGc6SwykeTo13tYm14JkVVQAf7jz8DDarCgNJrG3aEPJEqchDWeJdiaWpS3FwbLB9SzsN57V7qxB/*)" - - final blockchain = await Blockchain.create( - config: BlockchainConfig.electrum( - config: ElectrumConfig( - stopGap: 10, - timeout: 5, - retry: 5, - url: "ssl://electrum.blockstream.info:60002"))); - final wallet = await Wallet.create( externalDescriptor, internalDescriptor, Network.TESTNET, databaseConfig: const DatabaseConfig.memory()); - final addressInfo = await wallet.getAddress(addressIndex: AddressIndex.New); - await wallet.sync(blockchain); +final mnemonic = await Mnemonic.create(WordCount.Words12); + +final descriptorSecretKey = await DescriptorSecretKey.create( network: Network.Testnet, + mnemonic: mnemonic ); + +final externalDescriptor = await Descriptor.newBip44( descriptorSecretKey: descriptorSecretKey, + network: Network.Testnet, + keyChainKind: KeyChainKind.External ); + + + final internalDescriptor = await Descriptor.newBip44( descriptorSecretKey: descriptorSecretKey, + network: Network.Testnet, + keyChainKind: KeyChainKind.Internal ); + + final blockchain = await Blockchain.create( config: BlockchainConfig.electrum( + config: ElectrumConfig( + stopGap: 10, + timeout: 5, + retry: 5, + url: "ssl://electrum.blockstream.info:60002"))); + + final wallet = await Wallet.create( descriptor: externalDescriptor, + changeDescriptor: internalDescriptor, + network: Network.TESTNET, + databaseConfig: const DatabaseConfig.memory()); + + final addressInfo = await wallet.getAddress( addressIndex: AddressIndex.New ); + + await wallet.sync( blockchain ); ``` ### API Documentation diff --git a/analysis_options.yaml b/analysis_options.yaml index 603d647c..0923c17f 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -1,8 +1,9 @@ include: package:lints/recommended.yaml # Additional information about this file can be found at # https://dart.dev/guides/language/analysis-options + analyzer: exclude: - lib/src/generated/bindings.dart - - lib/src/generated/bindings.freezed.dart - + - lib/src/generated/bridge_definitions.dart + - lib/src/generated/bridge_definitions.freezed.dart diff --git a/android/src/main/jniLibs/arm64-v8a/librust.so b/android/src/main/jniLibs/arm64-v8a/librust.so index ebba6cc8..044418e8 100755 Binary files a/android/src/main/jniLibs/arm64-v8a/librust.so and b/android/src/main/jniLibs/arm64-v8a/librust.so differ diff --git a/android/src/main/jniLibs/armeabi-v7a/librust.so b/android/src/main/jniLibs/armeabi-v7a/librust.so index d893db3d..5996ea83 100755 Binary files a/android/src/main/jniLibs/armeabi-v7a/librust.so and b/android/src/main/jniLibs/armeabi-v7a/librust.so differ diff --git a/android/src/main/jniLibs/x86/librust.so b/android/src/main/jniLibs/x86/librust.so index a593b307..94a6eb15 100755 Binary files a/android/src/main/jniLibs/x86/librust.so and b/android/src/main/jniLibs/x86/librust.so differ diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index 81f7e2ad..94ba2b98 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -1,5 +1,5 @@ PODS: - - bdk_flutter (0.1.4): + - bdk_flutter (0.2.3): - Flutter - Flutter (1.0.0) @@ -14,7 +14,7 @@ EXTERNAL SOURCES: :path: Flutter SPEC CHECKSUMS: - bdk_flutter: c6950c633e8208ba7d61cb1de14b215d62270b76 + bdk_flutter: e78411cd1fb06a522180fac6276ebc1989ba480a Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854 PODFILE CHECKSUM: ef19549a9bc3046e7bb7d2fab4d021637c0c58a3 diff --git a/example/lib/main.dart b/example/lib/main.dart index 030d58bb..5b8373b6 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -15,13 +15,13 @@ class MyApp extends StatefulWidget { class _MyAppState extends State { late Wallet aliceWallet; - - late Blockchain blockchain; + Descriptor? aliceDescriptor; + late Descriptor aliceChangeDescriptor; + Blockchain? blockchain; @override void initState() { restoreWallet(); - createDescriptorSecret(); super.initState(); } @@ -33,9 +33,9 @@ class _MyAppState extends State { } restoreWallet() async { + await createDescriptorSecret(); aliceWallet = await Wallet.create( - descriptor: - "wpkh(tprv8ZgxMBicQKsPczV7D2zfMr7oUzHDhNPEuBUgrwRoWM3ijLRvhG87xYiqh9JFLPqojuhmqwMdo1oJzbe5GUpxCbDHnqyGhQa5Jg1Wt6rc9di/84'/1'/0'/1/*)", + descriptor: aliceDescriptor!, network: Network.Testnet, databaseConfig: const DatabaseConfig.memory()); if (kDebugMode) { @@ -50,39 +50,48 @@ class _MyAppState extends State { network: Network.Testnet, mnemonic: mnemonic, ); + final descriptor = await Descriptor.newBip44( + descriptorSecretKey: descriptorSecretKey, + network: Network.Testnet, + keyChainKind: KeychainKind.External); - final path = await DerivationPath.create(path: "m/84'/1'/0'"); - final xprv = await descriptorSecretKey.asString(); - final sec = await descriptorSecretKey.secretBytes(); - final xpub = await descriptorSecretKey.asPublic(); - final xpubString = xpub.asString(); - final derivedXprv = await descriptorSecretKey.extend(path); - final derivedXpub = await xpub.extend(path); - final derivedXprvStr = await derivedXprv.asString(); - final derivedXpubStr = derivedXpub.asString(); - if (kDebugMode) { - print("sec: $sec"); - print("xpub: $xpubString"); - print("xprv: $xprv"); - print("derivedXpub: $derivedXpubStr"); - print("derivedXprv: $derivedXprvStr"); + setState(() { + aliceDescriptor = descriptor; + }); + } + + initElectrumBlockchain(bool isElectrum) async { + if (blockchain == null) { + if (!isElectrum) { + blockchain = await Blockchain.create( + config: BlockchainConfig.rpc( + config: RpcConfig( + url: 'http://127.0.0.1:18446', + authUserPass: + UserPass(username: 'polaruser', password: 'polarpass'), + network: Network.Regtest, + walletName: 'default'))); + } else { + blockchain = await Blockchain.create( + config: BlockchainConfig.electrum( + config: ElectrumConfig( + stopGap: 10, + timeout: 5, + retry: 5, + url: "ssl://electrum.blockstream.info:60002", + validateDomain: true))); + } } } sync() async { - blockchain = await Blockchain.create( - config: BlockchainConfig.electrum( - config: ElectrumConfig( - stopGap: 10, - timeout: 5, - retry: 5, - url: "ssl://electrum.blockstream.info:60002"))); - aliceWallet.sync(blockchain); + await initElectrumBlockchain(true); + aliceWallet.sync(blockchain!); } getNewAddress() async { final alice = - await aliceWallet.getAddress(addressIndex: AddressIndex.LastUnused); + await aliceWallet.getAddress(addressIndex: AddressIndex.New); if (kDebugMode) { print(alice.address); print(alice.index); @@ -146,7 +155,7 @@ class _MyAppState extends State { } Future getBlockHeight() async { - final res = await blockchain.getHeight(); + final res = await blockchain!.getHeight(); if (kDebugMode) { print(res); } @@ -155,7 +164,7 @@ class _MyAppState extends State { getBlockHash() async { final height = await getBlockHeight(); - final blockHash = await blockchain.getBlockHash(height); + final blockHash = await blockchain!.getBlockHash(height); if (kDebugMode) { print(blockHash); } @@ -163,15 +172,15 @@ class _MyAppState extends State { sendBit() async { final txBuilder = TxBuilder(); - final address = await Address.create( - address: "tb1ql7w62elx9ucw4pj5lgw4l028hmuw80sndtntxt"); + final address = + await Address.create(address: "mv4rnyY3Su5gjcDNzbMLKBQkBicCtHUtFB"); final script = await address.scriptPubKey(); final psbt = await txBuilder - .addRecipient(script, 1000) + .addRecipient(script, 700) .feeRate(1.1) .finish(aliceWallet); final res = await aliceWallet.sign(psbt); - await blockchain.broadcast(res); + await blockchain!.broadcast(res); sync(); } diff --git a/example/pubspec.lock b/example/pubspec.lock index 3bfbd9d9..7cac78b5 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -42,7 +42,7 @@ packages: path: ".." relative: true source: path - version: "0.2.3" + version: "0.3.0" boolean_selector: dependency: transitive description: @@ -201,7 +201,7 @@ packages: name: flutter_rust_bridge url: "https://pub.dartlang.org" source: hosted - version: "1.54.0" + version: "1.60.0" flutter_test: dependency: "direct dev" description: flutter diff --git a/ios/Classes/bindings.h b/ios/Classes/bindings.h index f03007f2..831a70bf 100644 --- a/ios/Classes/bindings.h +++ b/ios/Classes/bindings.h @@ -3,6 +3,8 @@ #include typedef struct _Dart_Handle* Dart_Handle; +typedef struct DartCObject DartCObject; + typedef int64_t DartPort; typedef bool (*DartPostCObjectFnType)(DartPort port_id, void *message); @@ -18,6 +20,7 @@ typedef struct wire_ElectrumConfig { uint8_t retry; uint8_t *timeout; uint64_t stop_gap; + bool validate_domain; } wire_ElectrumConfig; typedef struct wire_BlockchainConfig_Electrum { @@ -36,9 +39,35 @@ typedef struct wire_BlockchainConfig_Esplora { struct wire_EsploraConfig *config; } wire_BlockchainConfig_Esplora; +typedef struct wire_UserPass { + struct wire_uint_8_list *username; + struct wire_uint_8_list *password; +} wire_UserPass; + +typedef struct wire_RpcSyncParams { + uint64_t start_script_count; + uint64_t start_time; + bool force_start_time; + uint64_t poll_rate_sec; +} wire_RpcSyncParams; + +typedef struct wire_RpcConfig { + struct wire_uint_8_list *url; + struct wire_uint_8_list *auth_cookie; + struct wire_UserPass *auth_user_pass; + int32_t network; + struct wire_uint_8_list *wallet_name; + struct wire_RpcSyncParams *sync_params; +} wire_RpcConfig; + +typedef struct wire_BlockchainConfig_Rpc { + struct wire_RpcConfig *config; +} wire_BlockchainConfig_Rpc; + typedef union BlockchainConfigKind { struct wire_BlockchainConfig_Electrum *Electrum; struct wire_BlockchainConfig_Esplora *Esplora; + struct wire_BlockchainConfig_Rpc *Rpc; } BlockchainConfigKind; typedef struct wire_BlockchainConfig { @@ -74,6 +103,10 @@ typedef struct wire_list_out_point { int32_t len; } wire_list_out_point; +typedef struct wire_BdkDescriptor { + const void *ptr; +} wire_BdkDescriptor; + typedef struct wire_DatabaseConfig_Memory { } wire_DatabaseConfig_Memory; @@ -106,11 +139,11 @@ typedef struct wire_DatabaseConfig { union DatabaseConfigKind *kind; } wire_DatabaseConfig; -typedef struct WireSyncReturnStruct { - uint8_t *ptr; - int32_t len; - bool success; -} WireSyncReturnStruct; +typedef struct wire_FeeRate { + float field0; +} wire_FeeRate; + +typedef struct DartCObject *WireSyncReturn; void store_dart_post_cobject(DartPostCObjectFnType ptr); @@ -140,6 +173,8 @@ void wire_extract_tx(int64_t port_, struct wire_uint_8_list *psbt_str); void wire_get_fee_rate(int64_t port_, struct wire_uint_8_list *psbt_str); +void wire_get_fee_amount(int64_t port_, struct wire_uint_8_list *psbt_str); + void wire_combine_psbt(int64_t port_, struct wire_uint_8_list *psbt_str, struct wire_uint_8_list *other); @@ -168,6 +203,45 @@ void wire_bump_fee_tx_builder_finish(int64_t port_, bool enable_rbf, uint32_t *n_sequence); +void wire_new_descriptor(int64_t port_, struct wire_uint_8_list *descriptor, int32_t network); + +void wire_new_bip44_descriptor(int64_t port_, + int32_t key_chain_kind, + struct wire_uint_8_list *secret_key, + int32_t network); + +void wire_new_bip44_public(int64_t port_, + int32_t key_chain_kind, + struct wire_uint_8_list *public_key, + int32_t network, + struct wire_uint_8_list *fingerprint); + +void wire_new_bip49_descriptor(int64_t port_, + int32_t key_chain_kind, + struct wire_uint_8_list *secret_key, + int32_t network); + +void wire_new_bip49_public(int64_t port_, + int32_t key_chain_kind, + struct wire_uint_8_list *public_key, + int32_t network, + struct wire_uint_8_list *fingerprint); + +void wire_new_bip84_descriptor(int64_t port_, + int32_t key_chain_kind, + struct wire_uint_8_list *secret_key, + int32_t network); + +void wire_new_bip84_public(int64_t port_, + int32_t key_chain_kind, + struct wire_uint_8_list *public_key, + int32_t network, + struct wire_uint_8_list *fingerprint); + +void wire_as_string_private(int64_t port_, struct wire_BdkDescriptor descriptor); + +void wire_as_string(int64_t port_, struct wire_BdkDescriptor descriptor); + void wire_descriptor_secret_extend(int64_t port_, struct wire_uint_8_list *xprv, struct wire_uint_8_list *path); @@ -203,8 +277,8 @@ void wire_init_address(int64_t port_, struct wire_uint_8_list *address); void wire_address_to_script_pubkey_hex(int64_t port_, struct wire_uint_8_list *address); void wire_wallet_init(int64_t port_, - struct wire_uint_8_list *descriptor, - struct wire_uint_8_list *change_descriptor, + struct wire_BdkDescriptor descriptor, + struct wire_BdkDescriptor *change_descriptor, int32_t network, struct wire_DatabaseConfig *database_config); @@ -235,10 +309,16 @@ void wire_generate_seed_from_string(int64_t port_, struct wire_uint_8_list *mnem void wire_generate_seed_from_entropy(int64_t port_, struct wire_uint_8_list *entropy); +void wire_as_sat_per_vb__method__FeeRate(int64_t port_, struct wire_FeeRate *that); + +struct wire_BdkDescriptor new_BdkDescriptor(void); + struct wire_BlockchainInstance new_BlockchainInstance(void); struct wire_WalletInstance new_WalletInstance(void); +struct wire_BdkDescriptor *new_box_autoadd_BdkDescriptor_0(void); + struct wire_BlockchainConfig *new_box_autoadd_blockchain_config_0(void); struct wire_DatabaseConfig *new_box_autoadd_database_config_0(void); @@ -249,6 +329,12 @@ struct wire_EsploraConfig *new_box_autoadd_esplora_config_0(void); float *new_box_autoadd_f32_0(float value); +struct wire_FeeRate *new_box_autoadd_fee_rate_0(void); + +struct wire_RpcConfig *new_box_autoadd_rpc_config_0(void); + +struct wire_RpcSyncParams *new_box_autoadd_rpc_sync_params_0(void); + struct wire_SledDbConfiguration *new_box_autoadd_sled_db_configuration_0(void); struct wire_SqliteDbConfiguration *new_box_autoadd_sqlite_db_configuration_0(void); @@ -259,12 +345,18 @@ uint64_t *new_box_autoadd_u64_0(uint64_t value); uint8_t *new_box_autoadd_u8_0(uint8_t value); +struct wire_UserPass *new_box_autoadd_user_pass_0(void); + struct wire_list_out_point *new_list_out_point_0(int32_t len); struct wire_list_script_amount *new_list_script_amount_0(int32_t len); struct wire_uint_8_list *new_uint_8_list_0(int32_t len); +void drop_opaque_BdkDescriptor(const void *ptr); + +const void *share_opaque_BdkDescriptor(const void *ptr); + void drop_opaque_BlockchainInstance(const void *ptr); const void *share_opaque_BlockchainInstance(const void *ptr); @@ -277,11 +369,13 @@ union BlockchainConfigKind *inflate_BlockchainConfig_Electrum(void); union BlockchainConfigKind *inflate_BlockchainConfig_Esplora(void); +union BlockchainConfigKind *inflate_BlockchainConfig_Rpc(void); + union DatabaseConfigKind *inflate_DatabaseConfig_Sqlite(void); union DatabaseConfigKind *inflate_DatabaseConfig_Sled(void); -void free_WireSyncReturnStruct(struct WireSyncReturnStruct val); +void free_WireSyncReturn(WireSyncReturn ptr); static int64_t dummy_method_to_enforce_bundling(void) { int64_t dummy_var = 0; @@ -292,9 +386,19 @@ static int64_t dummy_method_to_enforce_bundling(void) { dummy_var ^= ((int64_t) (void*) wire_psbt_to_txid); dummy_var ^= ((int64_t) (void*) wire_extract_tx); dummy_var ^= ((int64_t) (void*) wire_get_fee_rate); + dummy_var ^= ((int64_t) (void*) wire_get_fee_amount); dummy_var ^= ((int64_t) (void*) wire_combine_psbt); dummy_var ^= ((int64_t) (void*) wire_tx_builder_finish); dummy_var ^= ((int64_t) (void*) wire_bump_fee_tx_builder_finish); + dummy_var ^= ((int64_t) (void*) wire_new_descriptor); + dummy_var ^= ((int64_t) (void*) wire_new_bip44_descriptor); + dummy_var ^= ((int64_t) (void*) wire_new_bip44_public); + dummy_var ^= ((int64_t) (void*) wire_new_bip49_descriptor); + dummy_var ^= ((int64_t) (void*) wire_new_bip49_public); + dummy_var ^= ((int64_t) (void*) wire_new_bip84_descriptor); + dummy_var ^= ((int64_t) (void*) wire_new_bip84_public); + dummy_var ^= ((int64_t) (void*) wire_as_string_private); + dummy_var ^= ((int64_t) (void*) wire_as_string); dummy_var ^= ((int64_t) (void*) wire_descriptor_secret_extend); dummy_var ^= ((int64_t) (void*) wire_descriptor_secret_derive); dummy_var ^= ((int64_t) (void*) wire_descriptor_secret_as_secret_bytes); @@ -317,30 +421,40 @@ static int64_t dummy_method_to_enforce_bundling(void) { dummy_var ^= ((int64_t) (void*) wire_generate_seed_from_word_count); dummy_var ^= ((int64_t) (void*) wire_generate_seed_from_string); dummy_var ^= ((int64_t) (void*) wire_generate_seed_from_entropy); + dummy_var ^= ((int64_t) (void*) wire_as_sat_per_vb__method__FeeRate); + dummy_var ^= ((int64_t) (void*) new_BdkDescriptor); dummy_var ^= ((int64_t) (void*) new_BlockchainInstance); dummy_var ^= ((int64_t) (void*) new_WalletInstance); + dummy_var ^= ((int64_t) (void*) new_box_autoadd_BdkDescriptor_0); dummy_var ^= ((int64_t) (void*) new_box_autoadd_blockchain_config_0); dummy_var ^= ((int64_t) (void*) new_box_autoadd_database_config_0); dummy_var ^= ((int64_t) (void*) new_box_autoadd_electrum_config_0); dummy_var ^= ((int64_t) (void*) new_box_autoadd_esplora_config_0); dummy_var ^= ((int64_t) (void*) new_box_autoadd_f32_0); + dummy_var ^= ((int64_t) (void*) new_box_autoadd_fee_rate_0); + dummy_var ^= ((int64_t) (void*) new_box_autoadd_rpc_config_0); + dummy_var ^= ((int64_t) (void*) new_box_autoadd_rpc_sync_params_0); dummy_var ^= ((int64_t) (void*) new_box_autoadd_sled_db_configuration_0); dummy_var ^= ((int64_t) (void*) new_box_autoadd_sqlite_db_configuration_0); dummy_var ^= ((int64_t) (void*) new_box_autoadd_u32_0); dummy_var ^= ((int64_t) (void*) new_box_autoadd_u64_0); dummy_var ^= ((int64_t) (void*) new_box_autoadd_u8_0); + dummy_var ^= ((int64_t) (void*) new_box_autoadd_user_pass_0); dummy_var ^= ((int64_t) (void*) new_list_out_point_0); dummy_var ^= ((int64_t) (void*) new_list_script_amount_0); dummy_var ^= ((int64_t) (void*) new_uint_8_list_0); + dummy_var ^= ((int64_t) (void*) drop_opaque_BdkDescriptor); + dummy_var ^= ((int64_t) (void*) share_opaque_BdkDescriptor); dummy_var ^= ((int64_t) (void*) drop_opaque_BlockchainInstance); dummy_var ^= ((int64_t) (void*) share_opaque_BlockchainInstance); dummy_var ^= ((int64_t) (void*) drop_opaque_WalletInstance); dummy_var ^= ((int64_t) (void*) share_opaque_WalletInstance); dummy_var ^= ((int64_t) (void*) inflate_BlockchainConfig_Electrum); dummy_var ^= ((int64_t) (void*) inflate_BlockchainConfig_Esplora); + dummy_var ^= ((int64_t) (void*) inflate_BlockchainConfig_Rpc); dummy_var ^= ((int64_t) (void*) inflate_DatabaseConfig_Sqlite); dummy_var ^= ((int64_t) (void*) inflate_DatabaseConfig_Sled); - dummy_var ^= ((int64_t) (void*) free_WireSyncReturnStruct); + dummy_var ^= ((int64_t) (void*) free_WireSyncReturn); dummy_var ^= ((int64_t) (void*) store_dart_post_cobject); dummy_var ^= ((int64_t) (void*) get_dart_object); dummy_var ^= ((int64_t) (void*) drop_dart_object); diff --git a/ios/bdk_flutter.podspec b/ios/bdk_flutter.podspec index e4b7015c..5a17d0cf 100644 --- a/ios/bdk_flutter.podspec +++ b/ios/bdk_flutter.podspec @@ -4,12 +4,12 @@ # Pod::Spec.new do |s| s.name = 'bdk_flutter' - s.version = '0.2.1' + s.version = '0.3.0' s.summary = 'A Flutter library for the Bitcoin Development Kit (https://bitcoindevkit.org/)' s.description = <<-DESC A new Flutter project. DESC - s.homepage = 'https://github.com/LtbLightning/bdk-flutter' + s.homepage = 'https://github.com/LtbLightning/bdk-flutter' s.license = { :file => '../LICENSE' } s.author = { 'Bitcoin Zavior' => 'BitcoinZavior@GMail.Com' } s.source = { :path => '.' } diff --git a/ios/librust.a b/ios/librust.a index 79cbc913..13cc3f2d 100644 Binary files a/ios/librust.a and b/ios/librust.a differ diff --git a/lib/bdk_flutter.dart b/lib/bdk_flutter.dart index 22e8527e..c0be8a40 100644 --- a/lib/bdk_flutter.dart +++ b/lib/bdk_flutter.dart @@ -1,49 +1,16 @@ ///A Flutter library for the [Bitcoin Development Kit](https://bitcoindevkit.org/). library bdk_flutter; -export './src/generated/bindings.dart' +export './src/generated/bridge_definitions.dart' hide - RustImpl, BlockchainInstance, WalletInstance, - RustPlatform, Rust, BlockchainConfig_Electrum, + BlockchainConfig_Rpc, BlockchainConfig_Esplora, - BlockchainConfigKind, - RustWire, DatabaseConfig_Memory, DatabaseConfig_Sqlite, - DatabaseConfig_Sled, - DatabaseConfigKind, - wire_BlockchainConfig, - wire_DatabaseConfig, - wire_ElectrumConfig, - wire_EsploraConfig, - wire_list_out_point, - wire_list_script_amount, - wire_SledDbConfiguration, - wire_OutPoint, - wire_ScriptAmount, - wire_SqliteDbConfiguration, - wire_BlockchainConfig_Electrum, - wire_BlockchainConfig_Esplora, - wire_BlockchainInstance, - wire_DatabaseConfig_Memory, - wire_DatabaseConfig_Sled, - wire_DatabaseConfig_Sqlite, - wire_WalletInstance, - api2wire_address_index, - api2wire_bool, - api2wire_f32, - api2wire_i32, - api2wire_network, - api2wire_u32, - api2wire_u8, - api2wire_word_count, - DartPostCObjectFnType, - uintptr_t, - DartPort, - wire_uint_8_list; + DatabaseConfig_Sled; export './src/root.dart'; diff --git a/lib/src/generated/bindings.dart b/lib/src/generated/bindings.dart index bd4cf049..96d80634 100644 --- a/lib/src/generated/bindings.dart +++ b/lib/src/generated/bindings.dart @@ -1,563 +1,27 @@ // AUTO GENERATED FILE, DO NOT EDIT. -// Generated by `flutter_rust_bridge`@ 1.54.0. +// Generated by `flutter_rust_bridge`@ 1.60.0. // ignore_for_file: non_constant_identifier_names, unused_element, duplicate_ignore, directives_ordering, curly_braces_in_flow_control_structures, unnecessary_lambdas, slash_for_doc_comments, prefer_const_literals_to_create_immutables, implicit_dynamic_list_literal, duplicate_import, unused_import, prefer_single_quotes, prefer_const_constructors, use_super_parameters, always_use_package_imports, annotate_overrides, invalid_use_of_protected_member, constant_identifier_names, invalid_use_of_internal_member +import "bridge_definitions.dart"; import 'dart:convert'; import 'dart:async'; import 'package:flutter_rust_bridge/flutter_rust_bridge.dart'; -import 'package:freezed_annotation/freezed_annotation.dart' hide protected; import 'package:meta/meta.dart'; +import 'dart:convert'; +import 'dart:async'; +import 'package:flutter_rust_bridge/flutter_rust_bridge.dart'; import 'package:meta/meta.dart'; import 'dart:ffi' as ffi; -part 'bindings.freezed.dart'; - -abstract class Rust { - Future blockchainInit( - {required BlockchainConfig config, dynamic hint}); - - FlutterRustBridgeTaskConstMeta get kBlockchainInitConstMeta; - - Future getBlockchainHeight( - {required BlockchainInstance blockchain, dynamic hint}); - - FlutterRustBridgeTaskConstMeta get kGetBlockchainHeightConstMeta; - - Future getBlockchainHash( - {required int blockchainHeight, - required BlockchainInstance blockchain, - dynamic hint}); - - FlutterRustBridgeTaskConstMeta get kGetBlockchainHashConstMeta; - - Future broadcast( - {required String psbtStr, - required BlockchainInstance blockchain, - dynamic hint}); - - FlutterRustBridgeTaskConstMeta get kBroadcastConstMeta; - - Future psbtToTxid({required String psbtStr, dynamic hint}); - - FlutterRustBridgeTaskConstMeta get kPsbtToTxidConstMeta; - - Future extractTx({required String psbtStr, dynamic hint}); - - FlutterRustBridgeTaskConstMeta get kExtractTxConstMeta; - - Future getFeeRate({required String psbtStr, dynamic hint}); - - FlutterRustBridgeTaskConstMeta get kGetFeeRateConstMeta; - - Future combinePsbt( - {required String psbtStr, required String other, dynamic hint}); - - FlutterRustBridgeTaskConstMeta get kCombinePsbtConstMeta; - - Future txBuilderFinish( - {required WalletInstance wallet, - required List recipients, - required List utxos, - required List unspendable, - required bool manuallySelectedOnly, - required bool onlySpendChange, - required bool doNotSpendChange, - double? feeRate, - int? feeAbsolute, - required bool drainWallet, - String? drainTo, - required bool enableRbf, - int? nSequence, - required Uint8List data, - dynamic hint}); - - FlutterRustBridgeTaskConstMeta get kTxBuilderFinishConstMeta; - - Future bumpFeeTxBuilderFinish( - {required String txid, - required double feeRate, - String? allowShrinking, - required WalletInstance wallet, - required bool enableRbf, - int? nSequence, - dynamic hint}); - - FlutterRustBridgeTaskConstMeta get kBumpFeeTxBuilderFinishConstMeta; - - Future descriptorSecretExtend( - {required String xprv, required String path, dynamic hint}); - - FlutterRustBridgeTaskConstMeta get kDescriptorSecretExtendConstMeta; - - Future descriptorSecretDerive( - {required String xprv, required String path, dynamic hint}); - - FlutterRustBridgeTaskConstMeta get kDescriptorSecretDeriveConstMeta; - - Future descriptorSecretAsSecretBytes( - {String? descriptorSecret, String? xprv, dynamic hint}); - - FlutterRustBridgeTaskConstMeta get kDescriptorSecretAsSecretBytesConstMeta; - - Future descriptorSecretAsPublic( - {String? descriptorSecret, String? xprv, dynamic hint}); - - FlutterRustBridgeTaskConstMeta get kDescriptorSecretAsPublicConstMeta; - - Future createDescriptorSecret( - {required Network network, - required String mnemonic, - String? password, - dynamic hint}); - - FlutterRustBridgeTaskConstMeta get kCreateDescriptorSecretConstMeta; - - Future createDerivationPath({required String path, dynamic hint}); - - FlutterRustBridgeTaskConstMeta get kCreateDerivationPathConstMeta; - - Future createDescriptorPublic( - {String? xpub, required String path, required bool derive, dynamic hint}); - - FlutterRustBridgeTaskConstMeta get kCreateDescriptorPublicConstMeta; - - Future initScript({required Uint8List rawOutputScript, dynamic hint}); - - FlutterRustBridgeTaskConstMeta get kInitScriptConstMeta; - - Future initAddress({required String address, dynamic hint}); - - FlutterRustBridgeTaskConstMeta get kInitAddressConstMeta; - - Future addressToScriptPubkeyHex( - {required String address, dynamic hint}); - - FlutterRustBridgeTaskConstMeta get kAddressToScriptPubkeyHexConstMeta; - - Future walletInit( - {required String descriptor, - String? changeDescriptor, - required Network network, - required DatabaseConfig databaseConfig, - dynamic hint}); - - FlutterRustBridgeTaskConstMeta get kWalletInitConstMeta; - - Future getAddress( - {required WalletInstance wallet, - required AddressIndex addressIndex, - dynamic hint}); - - FlutterRustBridgeTaskConstMeta get kGetAddressConstMeta; - - Future syncWallet( - {required WalletInstance wallet, - required BlockchainInstance blockchain, - dynamic hint}); - - FlutterRustBridgeTaskConstMeta get kSyncWalletConstMeta; - - Future getBalance({required WalletInstance wallet, dynamic hint}); - - FlutterRustBridgeTaskConstMeta get kGetBalanceConstMeta; - - Future> listUnspentOutputs( - {required WalletInstance wallet, dynamic hint}); - - FlutterRustBridgeTaskConstMeta get kListUnspentOutputsConstMeta; - - Future> getTransactions( - {required WalletInstance wallet, dynamic hint}); - - FlutterRustBridgeTaskConstMeta get kGetTransactionsConstMeta; - - Future sign( - {required WalletInstance wallet, - required String psbtStr, - required bool isMultiSig, - dynamic hint}); - - FlutterRustBridgeTaskConstMeta get kSignConstMeta; - - Future getNetwork({required WalletInstance wallet, dynamic hint}); - - FlutterRustBridgeTaskConstMeta get kGetNetworkConstMeta; - - Future> listUnspent( - {required WalletInstance wallet, dynamic hint}); - - FlutterRustBridgeTaskConstMeta get kListUnspentConstMeta; - - Future generateSeedFromWordCount( - {required WordCount wordCount, dynamic hint}); - - FlutterRustBridgeTaskConstMeta get kGenerateSeedFromWordCountConstMeta; - - Future generateSeedFromString( - {required String mnemonic, dynamic hint}); - - FlutterRustBridgeTaskConstMeta get kGenerateSeedFromStringConstMeta; - - Future generateSeedFromEntropy( - {required Uint8List entropy, dynamic hint}); - - FlutterRustBridgeTaskConstMeta get kGenerateSeedFromEntropyConstMeta; - - DropFnType get dropOpaqueBlockchainInstance; - ShareFnType get shareOpaqueBlockchainInstance; - OpaqueTypeFinalizer get BlockchainInstanceFinalizer; - - DropFnType get dropOpaqueWalletInstance; - ShareFnType get shareOpaqueWalletInstance; - OpaqueTypeFinalizer get WalletInstanceFinalizer; -} - -@sealed -class BlockchainInstance extends FrbOpaque { - final Rust bridge; - BlockchainInstance.fromRaw(int ptr, int size, this.bridge) - : super.unsafe(ptr, size); - @override - DropFnType get dropFn => bridge.dropOpaqueBlockchainInstance; - - @override - ShareFnType get shareFn => bridge.shareOpaqueBlockchainInstance; - - @override - OpaqueTypeFinalizer get staticFinalizer => bridge.BlockchainInstanceFinalizer; -} - -@sealed -class WalletInstance extends FrbOpaque { - final Rust bridge; - WalletInstance.fromRaw(int ptr, int size, this.bridge) - : super.unsafe(ptr, size); - @override - DropFnType get dropFn => bridge.dropOpaqueWalletInstance; - - @override - ShareFnType get shareFn => bridge.shareOpaqueWalletInstance; - - @override - OpaqueTypeFinalizer get staticFinalizer => bridge.WalletInstanceFinalizer; -} - -/// The address index selection strategy to use to derived an address from the wallet's external -/// descriptor. -enum AddressIndex { - ///Return a new address after incrementing the current descriptor index. - New, - - ///Return the address for the current descriptor index if it has not been used in a received transaction. Otherwise return a new address as with AddressIndex.New. - ///Use with caution, if the wallet has not yet detected an address has been used it could return an already used address. This function is primarily meant for situations where the caller is untrusted; for example when deriving donation addresses on-demand for a public web page. - LastUnused, -} - -///A derived address and the index it was found at For convenience this automatically derefs to Address -class AddressInfo { - ///Child index of this address - final int index; - - /// Address - final String address; - - AddressInfo({ - required this.index, - required this.address, - }); -} - -/// Local Wallet's Balance -class Balance { - final int immature; - - /// Unconfirmed UTXOs generated by a wallet tx - final int trustedPending; - - /// Unconfirmed UTXOs received from an external wallet - final int untrustedPending; - - /// Confirmed and immediately spendable balance - final int confirmed; - - /// Get sum of trusted_pending and confirmed coins - final int spendable; - - /// Get the whole balance visible to the wallet - final int total; - - Balance({ - required this.immature, - required this.trustedPending, - required this.untrustedPending, - required this.confirmed, - required this.spendable, - required this.total, - }); -} - -///Block height and timestamp of a block -class BlockTime { - ///Confirmation block height - final int height; - - ///Confirmation block timestamp - final int timestamp; - - BlockTime({ - required this.height, - required this.timestamp, - }); -} - -@freezed -class BlockchainConfig with _$BlockchainConfig { - const factory BlockchainConfig.electrum({ - required ElectrumConfig config, - }) = BlockchainConfig_Electrum; - const factory BlockchainConfig.esplora({ - required EsploraConfig config, - }) = BlockchainConfig_Esplora; -} - -@freezed -class DatabaseConfig with _$DatabaseConfig { - const factory DatabaseConfig.memory() = DatabaseConfig_Memory; - - ///Simple key-value embedded database based on sled - const factory DatabaseConfig.sqlite({ - required SqliteDbConfiguration config, - }) = DatabaseConfig_Sqlite; - - ///Sqlite embedded database using rusqlite - const factory DatabaseConfig.sled({ - required SledDbConfiguration config, - }) = DatabaseConfig_Sled; -} - -/// Configuration for an ElectrumBlockchain -class ElectrumConfig { - ///URL of the Electrum server (such as ElectrumX, Esplora, BWT) may start with ssl:// or tcp:// and include a port - ///eg. ssl://electrum.blockstream.info:60002 - final String url; - - ///URL of the socks5 proxy server or a Tor service - final String? socks5; - - ///Request retry count - final int retry; - - ///Request timeout (seconds) - final int? timeout; - - ///Stop searching addresses for transactions after finding an unused gap of this length - final int stopGap; - - ElectrumConfig({ - required this.url, - this.socks5, - required this.retry, - this.timeout, - required this.stopGap, - }); -} - -///Configuration for an EsploraBlockchain -class EsploraConfig { - ///Base URL of the esplora service - ///eg. https://blockstream.info/api/ - final String baseUrl; - - /// Optional URL of the proxy to use to make requests to the Esplora server - /// The string should be formatted as: ://:@host:. - /// Note that the format of this value and the supported protocols change slightly between the sync version of esplora (using ureq) and the async version (using reqwest). - /// For more details check with the documentation of the two crates. Both of them are compiled with the socks feature enabled. - /// The proxy is ignored when targeting wasm32. - final String? proxy; - - ///Number of parallel requests sent to the esplora service (default: 4) - final int? concurrency; - - ///Stop searching addresses for transactions after finding an unused gap of this length. - final int stopGap; - - ///Socket timeout. - final int? timeout; - - EsploraConfig({ - required this.baseUrl, - this.proxy, - this.concurrency, - required this.stopGap, - this.timeout, - }); -} - -/// Unspent outputs of this wallet -class LocalUtxo { - /// Reference to a transaction output - final OutPoint outpoint; - - ///Transaction output - final TxOut txout; - - ///Whether this UTXO is spent or not - final bool isSpent; - - LocalUtxo({ - required this.outpoint, - required this.txout, - required this.isSpent, - }); -} - -///The cryptocurrency to act on -enum Network { - ///Bitcoin’s testnet - Testnet, - - ///Bitcoin’s regtest - Regtest, - - ///Classic Bitcoin - Bitcoin, - - ///Bitcoin’s signet - Signet, -} - -/// A reference to a transaction output. -class OutPoint { - /// The referenced transaction's txid. - final String txid; - - /// The index of the referenced output in its transaction's vout. - final int vout; - - OutPoint({ - required this.txid, - required this.vout, - }); -} - -/// A output script and an amount of satoshis. -class ScriptAmount { - final String script; - final int amount; - - ScriptAmount({ - required this.script, - required this.amount, - }); -} - -///Configuration type for a sled Tree database -class SledDbConfiguration { - ///Main directory of the db - final String path; - - ///Name of the database tree, a separated namespace for the data - final String treeName; - - SledDbConfiguration({ - required this.path, - required this.treeName, - }); -} - -///Configuration type for a SqliteDatabase database -class SqliteDbConfiguration { - ///Main directory of the db - final String path; - - SqliteDbConfiguration({ - required this.path, - }); -} - -///A wallet transaction -class TransactionDetails { - /// Transaction id. - final String txid; - - /// Received value (sats) - /// Sum of owned outputs of this transaction. - final int received; - - /// Sent value (sats) - /// Sum of owned inputs of this transaction. - final int sent; - - /// Fee value (sats) if confirmed. - /// The availability of the fee depends on the backend. It's never None with an Electrum - /// Server backend, but it could be None with a Bitcoin RPC node without txindex that receive - /// funds while offline. - final int? fee; - - /// If the transaction is confirmed, contains height and timestamp of the block containing the - /// transaction, unconfirmed transaction contains `None`. - final BlockTime? confirmationTime; - - TransactionDetails({ - required this.txid, - required this.received, - required this.sent, - this.fee, - this.confirmationTime, - }); -} - -/// The result after calling the TxBuilder finish() function. Contains unsigned PSBT and -/// transaction details. -class TxBuilderResult { - final String psbt; - - ///A wallet transaction - final TransactionDetails transactionDetails; - - TxBuilderResult({ - required this.psbt, - required this.transactionDetails, - }); -} - -///A transaction output, which defines new coins to be created from old ones. -class TxOut { - /// The value of the output, in satoshis. - final int value; - - /// The address of the output. - final String address; - - TxOut({ - required this.value, - required this.address, - }); -} - -///Type describing entropy length (aka word count) in the mnemonic -enum WordCount { - ///12 words mnemonic (128 bits entropy) - Words12, - - ///18 words mnemonic (192 bits entropy) - Words18, - - ///24 words mnemonic (256 bits entropy) - Words24, -} - class RustImpl implements Rust { final RustPlatform _platform; factory RustImpl(ExternalLibrary dylib) => RustImpl.raw(RustPlatform(dylib)); /// Only valid on web/WASM platforms. - factory RustImpl.wasm(FutureOr module) => - RustImpl(module as ExternalLibrary); + factory RustImpl.wasm(FutureOr module) => RustImpl(module as ExternalLibrary); RustImpl.raw(this._platform); - Future blockchainInit( - {required BlockchainConfig config, dynamic hint}) { + Future blockchainInit({required BlockchainConfig config, dynamic hint}) { var arg0 = _platform.api2wire_box_autoadd_blockchain_config(config); return _platform.executeNormal(FlutterRustBridgeTask( callFfi: (port_) => _platform.inner.wire_blockchain_init(port_, arg0), @@ -568,18 +32,15 @@ class RustImpl implements Rust { )); } - FlutterRustBridgeTaskConstMeta get kBlockchainInitConstMeta => - const FlutterRustBridgeTaskConstMeta( + FlutterRustBridgeTaskConstMeta get kBlockchainInitConstMeta => const FlutterRustBridgeTaskConstMeta( debugName: "blockchain_init", argNames: ["config"], ); - Future getBlockchainHeight( - {required BlockchainInstance blockchain, dynamic hint}) { + Future getBlockchainHeight({required BlockchainInstance blockchain, dynamic hint}) { var arg0 = _platform.api2wire_BlockchainInstance(blockchain); return _platform.executeNormal(FlutterRustBridgeTask( - callFfi: (port_) => - _platform.inner.wire_get_blockchain_height(port_, arg0), + callFfi: (port_) => _platform.inner.wire_get_blockchain_height(port_, arg0), parseSuccessData: _wire2api_u32, constMeta: kGetBlockchainHeightConstMeta, argValues: [blockchain], @@ -587,21 +48,17 @@ class RustImpl implements Rust { )); } - FlutterRustBridgeTaskConstMeta get kGetBlockchainHeightConstMeta => - const FlutterRustBridgeTaskConstMeta( + FlutterRustBridgeTaskConstMeta get kGetBlockchainHeightConstMeta => const FlutterRustBridgeTaskConstMeta( debugName: "get_blockchain_height", argNames: ["blockchain"], ); Future getBlockchainHash( - {required int blockchainHeight, - required BlockchainInstance blockchain, - dynamic hint}) { + {required int blockchainHeight, required BlockchainInstance blockchain, dynamic hint}) { var arg0 = api2wire_u32(blockchainHeight); var arg1 = _platform.api2wire_BlockchainInstance(blockchain); return _platform.executeNormal(FlutterRustBridgeTask( - callFfi: (port_) => - _platform.inner.wire_get_blockchain_hash(port_, arg0, arg1), + callFfi: (port_) => _platform.inner.wire_get_blockchain_hash(port_, arg0, arg1), parseSuccessData: _wire2api_String, constMeta: kGetBlockchainHashConstMeta, argValues: [blockchainHeight, blockchain], @@ -609,16 +66,12 @@ class RustImpl implements Rust { )); } - FlutterRustBridgeTaskConstMeta get kGetBlockchainHashConstMeta => - const FlutterRustBridgeTaskConstMeta( + FlutterRustBridgeTaskConstMeta get kGetBlockchainHashConstMeta => const FlutterRustBridgeTaskConstMeta( debugName: "get_blockchain_hash", argNames: ["blockchainHeight", "blockchain"], ); - Future broadcast( - {required String psbtStr, - required BlockchainInstance blockchain, - dynamic hint}) { + Future broadcast({required String psbtStr, required BlockchainInstance blockchain, dynamic hint}) { var arg0 = _platform.api2wire_String(psbtStr); var arg1 = _platform.api2wire_BlockchainInstance(blockchain); return _platform.executeNormal(FlutterRustBridgeTask( @@ -630,8 +83,7 @@ class RustImpl implements Rust { )); } - FlutterRustBridgeTaskConstMeta get kBroadcastConstMeta => - const FlutterRustBridgeTaskConstMeta( + FlutterRustBridgeTaskConstMeta get kBroadcastConstMeta => const FlutterRustBridgeTaskConstMeta( debugName: "broadcast", argNames: ["psbtStr", "blockchain"], ); @@ -647,8 +99,7 @@ class RustImpl implements Rust { )); } - FlutterRustBridgeTaskConstMeta get kPsbtToTxidConstMeta => - const FlutterRustBridgeTaskConstMeta( + FlutterRustBridgeTaskConstMeta get kPsbtToTxidConstMeta => const FlutterRustBridgeTaskConstMeta( debugName: "psbt_to_txid", argNames: ["psbtStr"], ); @@ -664,31 +115,44 @@ class RustImpl implements Rust { )); } - FlutterRustBridgeTaskConstMeta get kExtractTxConstMeta => - const FlutterRustBridgeTaskConstMeta( + FlutterRustBridgeTaskConstMeta get kExtractTxConstMeta => const FlutterRustBridgeTaskConstMeta( debugName: "extract_tx", argNames: ["psbtStr"], ); - Future getFeeRate({required String psbtStr, dynamic hint}) { + Future getFeeRate({required String psbtStr, dynamic hint}) { var arg0 = _platform.api2wire_String(psbtStr); return _platform.executeNormal(FlutterRustBridgeTask( callFfi: (port_) => _platform.inner.wire_get_fee_rate(port_, arg0), - parseSuccessData: _wire2api_f32, + parseSuccessData: _wire2api_opt_box_autoadd_fee_rate, constMeta: kGetFeeRateConstMeta, argValues: [psbtStr], hint: hint, )); } - FlutterRustBridgeTaskConstMeta get kGetFeeRateConstMeta => - const FlutterRustBridgeTaskConstMeta( + FlutterRustBridgeTaskConstMeta get kGetFeeRateConstMeta => const FlutterRustBridgeTaskConstMeta( debugName: "get_fee_rate", argNames: ["psbtStr"], ); - Future combinePsbt( - {required String psbtStr, required String other, dynamic hint}) { + Future getFeeAmount({required String psbtStr, dynamic hint}) { + var arg0 = _platform.api2wire_String(psbtStr); + return _platform.executeNormal(FlutterRustBridgeTask( + callFfi: (port_) => _platform.inner.wire_get_fee_amount(port_, arg0), + parseSuccessData: _wire2api_opt_box_autoadd_u64, + constMeta: kGetFeeAmountConstMeta, + argValues: [psbtStr], + hint: hint, + )); + } + + FlutterRustBridgeTaskConstMeta get kGetFeeAmountConstMeta => const FlutterRustBridgeTaskConstMeta( + debugName: "get_fee_amount", + argNames: ["psbtStr"], + ); + + Future combinePsbt({required String psbtStr, required String other, dynamic hint}) { var arg0 = _platform.api2wire_String(psbtStr); var arg1 = _platform.api2wire_String(other); return _platform.executeNormal(FlutterRustBridgeTask( @@ -700,8 +164,7 @@ class RustImpl implements Rust { )); } - FlutterRustBridgeTaskConstMeta get kCombinePsbtConstMeta => - const FlutterRustBridgeTaskConstMeta( + FlutterRustBridgeTaskConstMeta get kCombinePsbtConstMeta => const FlutterRustBridgeTaskConstMeta( debugName: "combine_psbt", argNames: ["psbtStr", "other"], ); @@ -738,21 +201,7 @@ class RustImpl implements Rust { var arg13 = _platform.api2wire_uint_8_list(data); return _platform.executeNormal(FlutterRustBridgeTask( callFfi: (port_) => _platform.inner.wire_tx_builder_finish( - port_, - arg0, - arg1, - arg2, - arg3, - arg4, - arg5, - arg6, - arg7, - arg8, - arg9, - arg10, - arg11, - arg12, - arg13), + port_, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13), parseSuccessData: _wire2api_tx_builder_result, constMeta: kTxBuilderFinishConstMeta, argValues: [ @@ -775,8 +224,7 @@ class RustImpl implements Rust { )); } - FlutterRustBridgeTaskConstMeta get kTxBuilderFinishConstMeta => - const FlutterRustBridgeTaskConstMeta( + FlutterRustBridgeTaskConstMeta get kTxBuilderFinishConstMeta => const FlutterRustBridgeTaskConstMeta( debugName: "tx_builder_finish", argNames: [ "wallet", @@ -811,8 +259,7 @@ class RustImpl implements Rust { var arg4 = enableRbf; var arg5 = _platform.api2wire_opt_box_autoadd_u32(nSequence); return _platform.executeNormal(FlutterRustBridgeTask( - callFfi: (port_) => _platform.inner.wire_bump_fee_tx_builder_finish( - port_, arg0, arg1, arg2, arg3, arg4, arg5), + callFfi: (port_) => _platform.inner.wire_bump_fee_tx_builder_finish(port_, arg0, arg1, arg2, arg3, arg4, arg5), parseSuccessData: _wire2api_String, constMeta: kBumpFeeTxBuilderFinishConstMeta, argValues: [txid, feeRate, allowShrinking, wallet, enableRbf, nSequence], @@ -820,26 +267,194 @@ class RustImpl implements Rust { )); } - FlutterRustBridgeTaskConstMeta get kBumpFeeTxBuilderFinishConstMeta => - const FlutterRustBridgeTaskConstMeta( + FlutterRustBridgeTaskConstMeta get kBumpFeeTxBuilderFinishConstMeta => const FlutterRustBridgeTaskConstMeta( debugName: "bump_fee_tx_builder_finish", - argNames: [ - "txid", - "feeRate", - "allowShrinking", - "wallet", - "enableRbf", - "nSequence" - ], + argNames: ["txid", "feeRate", "allowShrinking", "wallet", "enableRbf", "nSequence"], + ); + + Future newDescriptor({required String descriptor, required Network network, dynamic hint}) { + var arg0 = _platform.api2wire_String(descriptor); + var arg1 = api2wire_network(network); + return _platform.executeNormal(FlutterRustBridgeTask( + callFfi: (port_) => _platform.inner.wire_new_descriptor(port_, arg0, arg1), + parseSuccessData: _wire2api_BdkDescriptor, + constMeta: kNewDescriptorConstMeta, + argValues: [descriptor, network], + hint: hint, + )); + } + + FlutterRustBridgeTaskConstMeta get kNewDescriptorConstMeta => const FlutterRustBridgeTaskConstMeta( + debugName: "new_descriptor", + argNames: ["descriptor", "network"], + ); + + Future newBip44Descriptor( + {required KeychainKind keyChainKind, required String secretKey, required Network network, dynamic hint}) { + var arg0 = api2wire_keychain_kind(keyChainKind); + var arg1 = _platform.api2wire_String(secretKey); + var arg2 = api2wire_network(network); + return _platform.executeNormal(FlutterRustBridgeTask( + callFfi: (port_) => _platform.inner.wire_new_bip44_descriptor(port_, arg0, arg1, arg2), + parseSuccessData: _wire2api_BdkDescriptor, + constMeta: kNewBip44DescriptorConstMeta, + argValues: [keyChainKind, secretKey, network], + hint: hint, + )); + } + + FlutterRustBridgeTaskConstMeta get kNewBip44DescriptorConstMeta => const FlutterRustBridgeTaskConstMeta( + debugName: "new_bip44_descriptor", + argNames: ["keyChainKind", "secretKey", "network"], + ); + + Future newBip44Public( + {required KeychainKind keyChainKind, + required String publicKey, + required Network network, + required String fingerprint, + dynamic hint}) { + var arg0 = api2wire_keychain_kind(keyChainKind); + var arg1 = _platform.api2wire_String(publicKey); + var arg2 = api2wire_network(network); + var arg3 = _platform.api2wire_String(fingerprint); + return _platform.executeNormal(FlutterRustBridgeTask( + callFfi: (port_) => _platform.inner.wire_new_bip44_public(port_, arg0, arg1, arg2, arg3), + parseSuccessData: _wire2api_BdkDescriptor, + constMeta: kNewBip44PublicConstMeta, + argValues: [keyChainKind, publicKey, network, fingerprint], + hint: hint, + )); + } + + FlutterRustBridgeTaskConstMeta get kNewBip44PublicConstMeta => const FlutterRustBridgeTaskConstMeta( + debugName: "new_bip44_public", + argNames: ["keyChainKind", "publicKey", "network", "fingerprint"], + ); + + Future newBip49Descriptor( + {required KeychainKind keyChainKind, required String secretKey, required Network network, dynamic hint}) { + var arg0 = api2wire_keychain_kind(keyChainKind); + var arg1 = _platform.api2wire_String(secretKey); + var arg2 = api2wire_network(network); + return _platform.executeNormal(FlutterRustBridgeTask( + callFfi: (port_) => _platform.inner.wire_new_bip49_descriptor(port_, arg0, arg1, arg2), + parseSuccessData: _wire2api_BdkDescriptor, + constMeta: kNewBip49DescriptorConstMeta, + argValues: [keyChainKind, secretKey, network], + hint: hint, + )); + } + + FlutterRustBridgeTaskConstMeta get kNewBip49DescriptorConstMeta => const FlutterRustBridgeTaskConstMeta( + debugName: "new_bip49_descriptor", + argNames: ["keyChainKind", "secretKey", "network"], + ); + + Future newBip49Public( + {required KeychainKind keyChainKind, + required String publicKey, + required Network network, + required String fingerprint, + dynamic hint}) { + var arg0 = api2wire_keychain_kind(keyChainKind); + var arg1 = _platform.api2wire_String(publicKey); + var arg2 = api2wire_network(network); + var arg3 = _platform.api2wire_String(fingerprint); + return _platform.executeNormal(FlutterRustBridgeTask( + callFfi: (port_) => _platform.inner.wire_new_bip49_public(port_, arg0, arg1, arg2, arg3), + parseSuccessData: _wire2api_BdkDescriptor, + constMeta: kNewBip49PublicConstMeta, + argValues: [keyChainKind, publicKey, network, fingerprint], + hint: hint, + )); + } + + FlutterRustBridgeTaskConstMeta get kNewBip49PublicConstMeta => const FlutterRustBridgeTaskConstMeta( + debugName: "new_bip49_public", + argNames: ["keyChainKind", "publicKey", "network", "fingerprint"], + ); + + Future newBip84Descriptor( + {required KeychainKind keyChainKind, required String secretKey, required Network network, dynamic hint}) { + var arg0 = api2wire_keychain_kind(keyChainKind); + var arg1 = _platform.api2wire_String(secretKey); + var arg2 = api2wire_network(network); + return _platform.executeNormal(FlutterRustBridgeTask( + callFfi: (port_) => _platform.inner.wire_new_bip84_descriptor(port_, arg0, arg1, arg2), + parseSuccessData: _wire2api_BdkDescriptor, + constMeta: kNewBip84DescriptorConstMeta, + argValues: [keyChainKind, secretKey, network], + hint: hint, + )); + } + + FlutterRustBridgeTaskConstMeta get kNewBip84DescriptorConstMeta => const FlutterRustBridgeTaskConstMeta( + debugName: "new_bip84_descriptor", + argNames: ["keyChainKind", "secretKey", "network"], + ); + + Future newBip84Public( + {required KeychainKind keyChainKind, + required String publicKey, + required Network network, + required String fingerprint, + dynamic hint}) { + var arg0 = api2wire_keychain_kind(keyChainKind); + var arg1 = _platform.api2wire_String(publicKey); + var arg2 = api2wire_network(network); + var arg3 = _platform.api2wire_String(fingerprint); + return _platform.executeNormal(FlutterRustBridgeTask( + callFfi: (port_) => _platform.inner.wire_new_bip84_public(port_, arg0, arg1, arg2, arg3), + parseSuccessData: _wire2api_BdkDescriptor, + constMeta: kNewBip84PublicConstMeta, + argValues: [keyChainKind, publicKey, network, fingerprint], + hint: hint, + )); + } + + FlutterRustBridgeTaskConstMeta get kNewBip84PublicConstMeta => const FlutterRustBridgeTaskConstMeta( + debugName: "new_bip84_public", + argNames: ["keyChainKind", "publicKey", "network", "fingerprint"], + ); + + Future asStringPrivate({required BdkDescriptor descriptor, dynamic hint}) { + var arg0 = _platform.api2wire_BdkDescriptor(descriptor); + return _platform.executeNormal(FlutterRustBridgeTask( + callFfi: (port_) => _platform.inner.wire_as_string_private(port_, arg0), + parseSuccessData: _wire2api_String, + constMeta: kAsStringPrivateConstMeta, + argValues: [descriptor], + hint: hint, + )); + } + + FlutterRustBridgeTaskConstMeta get kAsStringPrivateConstMeta => const FlutterRustBridgeTaskConstMeta( + debugName: "as_string_private", + argNames: ["descriptor"], + ); + + Future asString({required BdkDescriptor descriptor, dynamic hint}) { + var arg0 = _platform.api2wire_BdkDescriptor(descriptor); + return _platform.executeNormal(FlutterRustBridgeTask( + callFfi: (port_) => _platform.inner.wire_as_string(port_, arg0), + parseSuccessData: _wire2api_String, + constMeta: kAsStringConstMeta, + argValues: [descriptor], + hint: hint, + )); + } + + FlutterRustBridgeTaskConstMeta get kAsStringConstMeta => const FlutterRustBridgeTaskConstMeta( + debugName: "as_string", + argNames: ["descriptor"], ); - Future descriptorSecretExtend( - {required String xprv, required String path, dynamic hint}) { + Future descriptorSecretExtend({required String xprv, required String path, dynamic hint}) { var arg0 = _platform.api2wire_String(xprv); var arg1 = _platform.api2wire_String(path); return _platform.executeNormal(FlutterRustBridgeTask( - callFfi: (port_) => - _platform.inner.wire_descriptor_secret_extend(port_, arg0, arg1), + callFfi: (port_) => _platform.inner.wire_descriptor_secret_extend(port_, arg0, arg1), parseSuccessData: _wire2api_String, constMeta: kDescriptorSecretExtendConstMeta, argValues: [xprv, path], @@ -847,19 +462,16 @@ class RustImpl implements Rust { )); } - FlutterRustBridgeTaskConstMeta get kDescriptorSecretExtendConstMeta => - const FlutterRustBridgeTaskConstMeta( + FlutterRustBridgeTaskConstMeta get kDescriptorSecretExtendConstMeta => const FlutterRustBridgeTaskConstMeta( debugName: "descriptor_secret_extend", argNames: ["xprv", "path"], ); - Future descriptorSecretDerive( - {required String xprv, required String path, dynamic hint}) { + Future descriptorSecretDerive({required String xprv, required String path, dynamic hint}) { var arg0 = _platform.api2wire_String(xprv); var arg1 = _platform.api2wire_String(path); return _platform.executeNormal(FlutterRustBridgeTask( - callFfi: (port_) => - _platform.inner.wire_descriptor_secret_derive(port_, arg0, arg1), + callFfi: (port_) => _platform.inner.wire_descriptor_secret_derive(port_, arg0, arg1), parseSuccessData: _wire2api_String, constMeta: kDescriptorSecretDeriveConstMeta, argValues: [xprv, path], @@ -867,19 +479,16 @@ class RustImpl implements Rust { )); } - FlutterRustBridgeTaskConstMeta get kDescriptorSecretDeriveConstMeta => - const FlutterRustBridgeTaskConstMeta( + FlutterRustBridgeTaskConstMeta get kDescriptorSecretDeriveConstMeta => const FlutterRustBridgeTaskConstMeta( debugName: "descriptor_secret_derive", argNames: ["xprv", "path"], ); - Future descriptorSecretAsSecretBytes( - {String? descriptorSecret, String? xprv, dynamic hint}) { + Future descriptorSecretAsSecretBytes({String? descriptorSecret, String? xprv, dynamic hint}) { var arg0 = _platform.api2wire_opt_String(descriptorSecret); var arg1 = _platform.api2wire_opt_String(xprv); return _platform.executeNormal(FlutterRustBridgeTask( - callFfi: (port_) => _platform.inner - .wire_descriptor_secret_as_secret_bytes(port_, arg0, arg1), + callFfi: (port_) => _platform.inner.wire_descriptor_secret_as_secret_bytes(port_, arg0, arg1), parseSuccessData: _wire2api_uint_8_list, constMeta: kDescriptorSecretAsSecretBytesConstMeta, argValues: [descriptorSecret, xprv], @@ -887,19 +496,16 @@ class RustImpl implements Rust { )); } - FlutterRustBridgeTaskConstMeta get kDescriptorSecretAsSecretBytesConstMeta => - const FlutterRustBridgeTaskConstMeta( + FlutterRustBridgeTaskConstMeta get kDescriptorSecretAsSecretBytesConstMeta => const FlutterRustBridgeTaskConstMeta( debugName: "descriptor_secret_as_secret_bytes", argNames: ["descriptorSecret", "xprv"], ); - Future descriptorSecretAsPublic( - {String? descriptorSecret, String? xprv, dynamic hint}) { + Future descriptorSecretAsPublic({String? descriptorSecret, String? xprv, dynamic hint}) { var arg0 = _platform.api2wire_opt_String(descriptorSecret); var arg1 = _platform.api2wire_opt_String(xprv); return _platform.executeNormal(FlutterRustBridgeTask( - callFfi: (port_) => - _platform.inner.wire_descriptor_secret_as_public(port_, arg0, arg1), + callFfi: (port_) => _platform.inner.wire_descriptor_secret_as_public(port_, arg0, arg1), parseSuccessData: _wire2api_String, constMeta: kDescriptorSecretAsPublicConstMeta, argValues: [descriptorSecret, xprv], @@ -907,23 +513,18 @@ class RustImpl implements Rust { )); } - FlutterRustBridgeTaskConstMeta get kDescriptorSecretAsPublicConstMeta => - const FlutterRustBridgeTaskConstMeta( + FlutterRustBridgeTaskConstMeta get kDescriptorSecretAsPublicConstMeta => const FlutterRustBridgeTaskConstMeta( debugName: "descriptor_secret_as_public", argNames: ["descriptorSecret", "xprv"], ); Future createDescriptorSecret( - {required Network network, - required String mnemonic, - String? password, - dynamic hint}) { + {required Network network, required String mnemonic, String? password, dynamic hint}) { var arg0 = api2wire_network(network); var arg1 = _platform.api2wire_String(mnemonic); var arg2 = _platform.api2wire_opt_String(password); return _platform.executeNormal(FlutterRustBridgeTask( - callFfi: (port_) => _platform.inner - .wire_create_descriptor_secret(port_, arg0, arg1, arg2), + callFfi: (port_) => _platform.inner.wire_create_descriptor_secret(port_, arg0, arg1, arg2), parseSuccessData: _wire2api_String, constMeta: kCreateDescriptorSecretConstMeta, argValues: [network, mnemonic, password], @@ -931,8 +532,7 @@ class RustImpl implements Rust { )); } - FlutterRustBridgeTaskConstMeta get kCreateDescriptorSecretConstMeta => - const FlutterRustBridgeTaskConstMeta( + FlutterRustBridgeTaskConstMeta get kCreateDescriptorSecretConstMeta => const FlutterRustBridgeTaskConstMeta( debugName: "create_descriptor_secret", argNames: ["network", "mnemonic", "password"], ); @@ -940,8 +540,7 @@ class RustImpl implements Rust { Future createDerivationPath({required String path, dynamic hint}) { var arg0 = _platform.api2wire_String(path); return _platform.executeNormal(FlutterRustBridgeTask( - callFfi: (port_) => - _platform.inner.wire_create_derivation_path(port_, arg0), + callFfi: (port_) => _platform.inner.wire_create_derivation_path(port_, arg0), parseSuccessData: _wire2api_String, constMeta: kCreateDerivationPathConstMeta, argValues: [path], @@ -949,23 +548,17 @@ class RustImpl implements Rust { )); } - FlutterRustBridgeTaskConstMeta get kCreateDerivationPathConstMeta => - const FlutterRustBridgeTaskConstMeta( + FlutterRustBridgeTaskConstMeta get kCreateDerivationPathConstMeta => const FlutterRustBridgeTaskConstMeta( debugName: "create_derivation_path", argNames: ["path"], ); - Future createDescriptorPublic( - {String? xpub, - required String path, - required bool derive, - dynamic hint}) { + Future createDescriptorPublic({String? xpub, required String path, required bool derive, dynamic hint}) { var arg0 = _platform.api2wire_opt_String(xpub); var arg1 = _platform.api2wire_String(path); var arg2 = derive; return _platform.executeNormal(FlutterRustBridgeTask( - callFfi: (port_) => _platform.inner - .wire_create_descriptor_public(port_, arg0, arg1, arg2), + callFfi: (port_) => _platform.inner.wire_create_descriptor_public(port_, arg0, arg1, arg2), parseSuccessData: _wire2api_String, constMeta: kCreateDescriptorPublicConstMeta, argValues: [xpub, path, derive], @@ -973,14 +566,12 @@ class RustImpl implements Rust { )); } - FlutterRustBridgeTaskConstMeta get kCreateDescriptorPublicConstMeta => - const FlutterRustBridgeTaskConstMeta( + FlutterRustBridgeTaskConstMeta get kCreateDescriptorPublicConstMeta => const FlutterRustBridgeTaskConstMeta( debugName: "create_descriptor_public", argNames: ["xpub", "path", "derive"], ); - Future initScript( - {required Uint8List rawOutputScript, dynamic hint}) { + Future initScript({required Uint8List rawOutputScript, dynamic hint}) { var arg0 = _platform.api2wire_uint_8_list(rawOutputScript); return _platform.executeNormal(FlutterRustBridgeTask( callFfi: (port_) => _platform.inner.wire_init_script(port_, arg0), @@ -991,8 +582,7 @@ class RustImpl implements Rust { )); } - FlutterRustBridgeTaskConstMeta get kInitScriptConstMeta => - const FlutterRustBridgeTaskConstMeta( + FlutterRustBridgeTaskConstMeta get kInitScriptConstMeta => const FlutterRustBridgeTaskConstMeta( debugName: "init_script", argNames: ["rawOutputScript"], ); @@ -1008,18 +598,15 @@ class RustImpl implements Rust { )); } - FlutterRustBridgeTaskConstMeta get kInitAddressConstMeta => - const FlutterRustBridgeTaskConstMeta( + FlutterRustBridgeTaskConstMeta get kInitAddressConstMeta => const FlutterRustBridgeTaskConstMeta( debugName: "init_address", argNames: ["address"], ); - Future addressToScriptPubkeyHex( - {required String address, dynamic hint}) { + Future addressToScriptPubkeyHex({required String address, dynamic hint}) { var arg0 = _platform.api2wire_String(address); return _platform.executeNormal(FlutterRustBridgeTask( - callFfi: (port_) => - _platform.inner.wire_address_to_script_pubkey_hex(port_, arg0), + callFfi: (port_) => _platform.inner.wire_address_to_script_pubkey_hex(port_, arg0), parseSuccessData: _wire2api_String, constMeta: kAddressToScriptPubkeyHexConstMeta, argValues: [address], @@ -1027,25 +614,23 @@ class RustImpl implements Rust { )); } - FlutterRustBridgeTaskConstMeta get kAddressToScriptPubkeyHexConstMeta => - const FlutterRustBridgeTaskConstMeta( + FlutterRustBridgeTaskConstMeta get kAddressToScriptPubkeyHexConstMeta => const FlutterRustBridgeTaskConstMeta( debugName: "address_to_script_pubkey_hex", argNames: ["address"], ); Future walletInit( - {required String descriptor, - String? changeDescriptor, + {required BdkDescriptor descriptor, + BdkDescriptor? changeDescriptor, required Network network, required DatabaseConfig databaseConfig, dynamic hint}) { - var arg0 = _platform.api2wire_String(descriptor); - var arg1 = _platform.api2wire_opt_String(changeDescriptor); + var arg0 = _platform.api2wire_BdkDescriptor(descriptor); + var arg1 = _platform.api2wire_opt_box_autoadd_BdkDescriptor(changeDescriptor); var arg2 = api2wire_network(network); var arg3 = _platform.api2wire_box_autoadd_database_config(databaseConfig); return _platform.executeNormal(FlutterRustBridgeTask( - callFfi: (port_) => - _platform.inner.wire_wallet_init(port_, arg0, arg1, arg2, arg3), + callFfi: (port_) => _platform.inner.wire_wallet_init(port_, arg0, arg1, arg2, arg3), parseSuccessData: _wire2api_WalletInstance, constMeta: kWalletInitConstMeta, argValues: [descriptor, changeDescriptor, network, databaseConfig], @@ -1053,21 +638,12 @@ class RustImpl implements Rust { )); } - FlutterRustBridgeTaskConstMeta get kWalletInitConstMeta => - const FlutterRustBridgeTaskConstMeta( + FlutterRustBridgeTaskConstMeta get kWalletInitConstMeta => const FlutterRustBridgeTaskConstMeta( debugName: "wallet_init", - argNames: [ - "descriptor", - "changeDescriptor", - "network", - "databaseConfig" - ], + argNames: ["descriptor", "changeDescriptor", "network", "databaseConfig"], ); - Future getAddress( - {required WalletInstance wallet, - required AddressIndex addressIndex, - dynamic hint}) { + Future getAddress({required WalletInstance wallet, required AddressIndex addressIndex, dynamic hint}) { var arg0 = _platform.api2wire_WalletInstance(wallet); var arg1 = api2wire_address_index(addressIndex); return _platform.executeNormal(FlutterRustBridgeTask( @@ -1079,16 +655,12 @@ class RustImpl implements Rust { )); } - FlutterRustBridgeTaskConstMeta get kGetAddressConstMeta => - const FlutterRustBridgeTaskConstMeta( + FlutterRustBridgeTaskConstMeta get kGetAddressConstMeta => const FlutterRustBridgeTaskConstMeta( debugName: "get_address", argNames: ["wallet", "addressIndex"], ); - Future syncWallet( - {required WalletInstance wallet, - required BlockchainInstance blockchain, - dynamic hint}) { + Future syncWallet({required WalletInstance wallet, required BlockchainInstance blockchain, dynamic hint}) { var arg0 = _platform.api2wire_WalletInstance(wallet); var arg1 = _platform.api2wire_BlockchainInstance(blockchain); return _platform.executeNormal(FlutterRustBridgeTask( @@ -1100,8 +672,7 @@ class RustImpl implements Rust { )); } - FlutterRustBridgeTaskConstMeta get kSyncWalletConstMeta => - const FlutterRustBridgeTaskConstMeta( + FlutterRustBridgeTaskConstMeta get kSyncWalletConstMeta => const FlutterRustBridgeTaskConstMeta( debugName: "sync_wallet", argNames: ["wallet", "blockchain"], ); @@ -1117,18 +688,15 @@ class RustImpl implements Rust { )); } - FlutterRustBridgeTaskConstMeta get kGetBalanceConstMeta => - const FlutterRustBridgeTaskConstMeta( + FlutterRustBridgeTaskConstMeta get kGetBalanceConstMeta => const FlutterRustBridgeTaskConstMeta( debugName: "get_balance", argNames: ["wallet"], ); - Future> listUnspentOutputs( - {required WalletInstance wallet, dynamic hint}) { + Future> listUnspentOutputs({required WalletInstance wallet, dynamic hint}) { var arg0 = _platform.api2wire_WalletInstance(wallet); return _platform.executeNormal(FlutterRustBridgeTask( - callFfi: (port_) => - _platform.inner.wire_list_unspent_outputs(port_, arg0), + callFfi: (port_) => _platform.inner.wire_list_unspent_outputs(port_, arg0), parseSuccessData: _wire2api_list_local_utxo, constMeta: kListUnspentOutputsConstMeta, argValues: [wallet], @@ -1136,14 +704,12 @@ class RustImpl implements Rust { )); } - FlutterRustBridgeTaskConstMeta get kListUnspentOutputsConstMeta => - const FlutterRustBridgeTaskConstMeta( + FlutterRustBridgeTaskConstMeta get kListUnspentOutputsConstMeta => const FlutterRustBridgeTaskConstMeta( debugName: "list_unspent_outputs", argNames: ["wallet"], ); - Future> getTransactions( - {required WalletInstance wallet, dynamic hint}) { + Future> getTransactions({required WalletInstance wallet, dynamic hint}) { var arg0 = _platform.api2wire_WalletInstance(wallet); return _platform.executeNormal(FlutterRustBridgeTask( callFfi: (port_) => _platform.inner.wire_get_transactions(port_, arg0), @@ -1154,17 +720,13 @@ class RustImpl implements Rust { )); } - FlutterRustBridgeTaskConstMeta get kGetTransactionsConstMeta => - const FlutterRustBridgeTaskConstMeta( + FlutterRustBridgeTaskConstMeta get kGetTransactionsConstMeta => const FlutterRustBridgeTaskConstMeta( debugName: "get_transactions", argNames: ["wallet"], ); Future sign( - {required WalletInstance wallet, - required String psbtStr, - required bool isMultiSig, - dynamic hint}) { + {required WalletInstance wallet, required String psbtStr, required bool isMultiSig, dynamic hint}) { var arg0 = _platform.api2wire_WalletInstance(wallet); var arg1 = _platform.api2wire_String(psbtStr); var arg2 = isMultiSig; @@ -1177,8 +739,7 @@ class RustImpl implements Rust { )); } - FlutterRustBridgeTaskConstMeta get kSignConstMeta => - const FlutterRustBridgeTaskConstMeta( + FlutterRustBridgeTaskConstMeta get kSignConstMeta => const FlutterRustBridgeTaskConstMeta( debugName: "sign", argNames: ["wallet", "psbtStr", "isMultiSig"], ); @@ -1194,14 +755,12 @@ class RustImpl implements Rust { )); } - FlutterRustBridgeTaskConstMeta get kGetNetworkConstMeta => - const FlutterRustBridgeTaskConstMeta( + FlutterRustBridgeTaskConstMeta get kGetNetworkConstMeta => const FlutterRustBridgeTaskConstMeta( debugName: "get_network", argNames: ["wallet"], ); - Future> listUnspent( - {required WalletInstance wallet, dynamic hint}) { + Future> listUnspent({required WalletInstance wallet, dynamic hint}) { var arg0 = _platform.api2wire_WalletInstance(wallet); return _platform.executeNormal(FlutterRustBridgeTask( callFfi: (port_) => _platform.inner.wire_list_unspent(port_, arg0), @@ -1212,18 +771,15 @@ class RustImpl implements Rust { )); } - FlutterRustBridgeTaskConstMeta get kListUnspentConstMeta => - const FlutterRustBridgeTaskConstMeta( + FlutterRustBridgeTaskConstMeta get kListUnspentConstMeta => const FlutterRustBridgeTaskConstMeta( debugName: "list_unspent", argNames: ["wallet"], ); - Future generateSeedFromWordCount( - {required WordCount wordCount, dynamic hint}) { + Future generateSeedFromWordCount({required WordCount wordCount, dynamic hint}) { var arg0 = api2wire_word_count(wordCount); return _platform.executeNormal(FlutterRustBridgeTask( - callFfi: (port_) => - _platform.inner.wire_generate_seed_from_word_count(port_, arg0), + callFfi: (port_) => _platform.inner.wire_generate_seed_from_word_count(port_, arg0), parseSuccessData: _wire2api_String, constMeta: kGenerateSeedFromWordCountConstMeta, argValues: [wordCount], @@ -1231,18 +787,15 @@ class RustImpl implements Rust { )); } - FlutterRustBridgeTaskConstMeta get kGenerateSeedFromWordCountConstMeta => - const FlutterRustBridgeTaskConstMeta( + FlutterRustBridgeTaskConstMeta get kGenerateSeedFromWordCountConstMeta => const FlutterRustBridgeTaskConstMeta( debugName: "generate_seed_from_word_count", argNames: ["wordCount"], ); - Future generateSeedFromString( - {required String mnemonic, dynamic hint}) { + Future generateSeedFromString({required String mnemonic, dynamic hint}) { var arg0 = _platform.api2wire_String(mnemonic); return _platform.executeNormal(FlutterRustBridgeTask( - callFfi: (port_) => - _platform.inner.wire_generate_seed_from_string(port_, arg0), + callFfi: (port_) => _platform.inner.wire_generate_seed_from_string(port_, arg0), parseSuccessData: _wire2api_String, constMeta: kGenerateSeedFromStringConstMeta, argValues: [mnemonic], @@ -1250,18 +803,15 @@ class RustImpl implements Rust { )); } - FlutterRustBridgeTaskConstMeta get kGenerateSeedFromStringConstMeta => - const FlutterRustBridgeTaskConstMeta( + FlutterRustBridgeTaskConstMeta get kGenerateSeedFromStringConstMeta => const FlutterRustBridgeTaskConstMeta( debugName: "generate_seed_from_string", argNames: ["mnemonic"], ); - Future generateSeedFromEntropy( - {required Uint8List entropy, dynamic hint}) { + Future generateSeedFromEntropy({required Uint8List entropy, dynamic hint}) { var arg0 = _platform.api2wire_uint_8_list(entropy); return _platform.executeNormal(FlutterRustBridgeTask( - callFfi: (port_) => - _platform.inner.wire_generate_seed_from_entropy(port_, arg0), + callFfi: (port_) => _platform.inner.wire_generate_seed_from_entropy(port_, arg0), parseSuccessData: _wire2api_String, constMeta: kGenerateSeedFromEntropyConstMeta, argValues: [entropy], @@ -1269,31 +819,48 @@ class RustImpl implements Rust { )); } - FlutterRustBridgeTaskConstMeta get kGenerateSeedFromEntropyConstMeta => - const FlutterRustBridgeTaskConstMeta( + FlutterRustBridgeTaskConstMeta get kGenerateSeedFromEntropyConstMeta => const FlutterRustBridgeTaskConstMeta( debugName: "generate_seed_from_entropy", argNames: ["entropy"], ); - DropFnType get dropOpaqueBlockchainInstance => - _platform.inner.drop_opaque_BlockchainInstance; - ShareFnType get shareOpaqueBlockchainInstance => - _platform.inner.share_opaque_BlockchainInstance; - OpaqueTypeFinalizer get BlockchainInstanceFinalizer => - _platform.BlockchainInstanceFinalizer; + Future asSatPerVbMethodFeeRate({required FeeRate that, dynamic hint}) { + var arg0 = _platform.api2wire_box_autoadd_fee_rate(that); + return _platform.executeNormal(FlutterRustBridgeTask( + callFfi: (port_) => _platform.inner.wire_as_sat_per_vb__method__FeeRate(port_, arg0), + parseSuccessData: _wire2api_f32, + constMeta: kAsSatPerVbMethodFeeRateConstMeta, + argValues: [that], + hint: hint, + )); + } + + FlutterRustBridgeTaskConstMeta get kAsSatPerVbMethodFeeRateConstMeta => const FlutterRustBridgeTaskConstMeta( + debugName: "as_sat_per_vb__method__FeeRate", + argNames: ["that"], + ); + + DropFnType get dropOpaqueBdkDescriptor => _platform.inner.drop_opaque_BdkDescriptor; + ShareFnType get shareOpaqueBdkDescriptor => _platform.inner.share_opaque_BdkDescriptor; + OpaqueTypeFinalizer get BdkDescriptorFinalizer => _platform.BdkDescriptorFinalizer; - DropFnType get dropOpaqueWalletInstance => - _platform.inner.drop_opaque_WalletInstance; - ShareFnType get shareOpaqueWalletInstance => - _platform.inner.share_opaque_WalletInstance; - OpaqueTypeFinalizer get WalletInstanceFinalizer => - _platform.WalletInstanceFinalizer; + DropFnType get dropOpaqueBlockchainInstance => _platform.inner.drop_opaque_BlockchainInstance; + ShareFnType get shareOpaqueBlockchainInstance => _platform.inner.share_opaque_BlockchainInstance; + OpaqueTypeFinalizer get BlockchainInstanceFinalizer => _platform.BlockchainInstanceFinalizer; + + DropFnType get dropOpaqueWalletInstance => _platform.inner.drop_opaque_WalletInstance; + ShareFnType get shareOpaqueWalletInstance => _platform.inner.share_opaque_WalletInstance; + OpaqueTypeFinalizer get WalletInstanceFinalizer => _platform.WalletInstanceFinalizer; void dispose() { _platform.dispose(); } // Section: wire2api + BdkDescriptor _wire2api_BdkDescriptor(dynamic raw) { + return BdkDescriptor.fromRaw(raw[0], raw[1], this); + } + BlockchainInstance _wire2api_BlockchainInstance(dynamic raw) { return BlockchainInstance.fromRaw(raw[0], raw[1], this); } @@ -1308,8 +875,7 @@ class RustImpl implements Rust { AddressInfo _wire2api_address_info(dynamic raw) { final arr = raw as List; - if (arr.length != 2) - throw Exception('unexpected arr length: expect 2 but see ${arr.length}'); + if (arr.length != 2) throw Exception('unexpected arr length: expect 2 but see ${arr.length}'); return AddressInfo( index: _wire2api_u32(arr[0]), address: _wire2api_String(arr[1]), @@ -1318,8 +884,7 @@ class RustImpl implements Rust { Balance _wire2api_balance(dynamic raw) { final arr = raw as List; - if (arr.length != 6) - throw Exception('unexpected arr length: expect 6 but see ${arr.length}'); + if (arr.length != 6) throw Exception('unexpected arr length: expect 6 but see ${arr.length}'); return Balance( immature: _wire2api_u64(arr[0]), trustedPending: _wire2api_u64(arr[1]), @@ -1332,8 +897,7 @@ class RustImpl implements Rust { BlockTime _wire2api_block_time(dynamic raw) { final arr = raw as List; - if (arr.length != 2) - throw Exception('unexpected arr length: expect 2 but see ${arr.length}'); + if (arr.length != 2) throw Exception('unexpected arr length: expect 2 but see ${arr.length}'); return BlockTime( height: _wire2api_u32(arr[0]), timestamp: _wire2api_u64(arr[1]), @@ -1348,6 +912,10 @@ class RustImpl implements Rust { return _wire2api_block_time(raw); } + FeeRate _wire2api_box_autoadd_fee_rate(dynamic raw) { + return _wire2api_fee_rate(raw); + } + int _wire2api_box_autoadd_u64(dynamic raw) { return _wire2api_u64(raw); } @@ -1356,6 +924,15 @@ class RustImpl implements Rust { return raw as double; } + FeeRate _wire2api_fee_rate(dynamic raw) { + final arr = raw as List; + if (arr.length != 1) throw Exception('unexpected arr length: expect 1 but see ${arr.length}'); + return FeeRate( + bridge: this, + field0: _wire2api_f32(arr[0]), + ); + } + int _wire2api_i32(dynamic raw) { return raw as int; } @@ -1370,8 +947,7 @@ class RustImpl implements Rust { LocalUtxo _wire2api_local_utxo(dynamic raw) { final arr = raw as List; - if (arr.length != 3) - throw Exception('unexpected arr length: expect 3 but see ${arr.length}'); + if (arr.length != 3) throw Exception('unexpected arr length: expect 3 but see ${arr.length}'); return LocalUtxo( outpoint: _wire2api_out_point(arr[0]), txout: _wire2api_tx_out(arr[1]), @@ -1391,14 +967,17 @@ class RustImpl implements Rust { return raw == null ? null : _wire2api_box_autoadd_block_time(raw); } + FeeRate? _wire2api_opt_box_autoadd_fee_rate(dynamic raw) { + return raw == null ? null : _wire2api_box_autoadd_fee_rate(raw); + } + int? _wire2api_opt_box_autoadd_u64(dynamic raw) { return raw == null ? null : _wire2api_box_autoadd_u64(raw); } OutPoint _wire2api_out_point(dynamic raw) { final arr = raw as List; - if (arr.length != 2) - throw Exception('unexpected arr length: expect 2 but see ${arr.length}'); + if (arr.length != 2) throw Exception('unexpected arr length: expect 2 but see ${arr.length}'); return OutPoint( txid: _wire2api_String(arr[0]), vout: _wire2api_u32(arr[1]), @@ -1407,8 +986,7 @@ class RustImpl implements Rust { TransactionDetails _wire2api_transaction_details(dynamic raw) { final arr = raw as List; - if (arr.length != 5) - throw Exception('unexpected arr length: expect 5 but see ${arr.length}'); + if (arr.length != 5) throw Exception('unexpected arr length: expect 5 but see ${arr.length}'); return TransactionDetails( txid: _wire2api_String(arr[0]), received: _wire2api_u64(arr[1]), @@ -1420,8 +998,7 @@ class RustImpl implements Rust { TxBuilderResult _wire2api_tx_builder_result(dynamic raw) { final arr = raw as List; - if (arr.length != 2) - throw Exception('unexpected arr length: expect 2 but see ${arr.length}'); + if (arr.length != 2) throw Exception('unexpected arr length: expect 2 but see ${arr.length}'); return TxBuilderResult( psbt: _wire2api_String(arr[0]), transactionDetails: _wire2api_transaction_details(arr[1]), @@ -1430,8 +1007,7 @@ class RustImpl implements Rust { TxOut _wire2api_tx_out(dynamic raw) { final arr = raw as List; - if (arr.length != 2) - throw Exception('unexpected arr length: expect 2 but see ${arr.length}'); + if (arr.length != 2) throw Exception('unexpected arr length: expect 2 but see ${arr.length}'); return TxOut( value: _wire2api_u64(arr[0]), address: _wire2api_String(arr[1]), @@ -1481,6 +1057,11 @@ int api2wire_i32(int raw) { return raw; } +@protected +int api2wire_keychain_kind(KeychainKind raw) { + return api2wire_i32(raw.index); +} + @protected int api2wire_network(Network raw) { return api2wire_i32(raw.index); @@ -1507,6 +1088,13 @@ class RustPlatform extends FlutterRustBridgeBase { // Section: api2wire + @protected + wire_BdkDescriptor api2wire_BdkDescriptor(BdkDescriptor raw) { + final ptr = inner.new_BdkDescriptor(); + _api_fill_to_wire_BdkDescriptor(raw, ptr); + return ptr; + } + @protected wire_BlockchainInstance api2wire_BlockchainInstance(BlockchainInstance raw) { final ptr = inner.new_BlockchainInstance(); @@ -1527,32 +1115,35 @@ class RustPlatform extends FlutterRustBridgeBase { } @protected - ffi.Pointer api2wire_box_autoadd_blockchain_config( - BlockchainConfig raw) { + ffi.Pointer api2wire_box_autoadd_BdkDescriptor(BdkDescriptor raw) { + final ptr = inner.new_box_autoadd_BdkDescriptor_0(); + _api_fill_to_wire_BdkDescriptor(raw, ptr.ref); + return ptr; + } + + @protected + ffi.Pointer api2wire_box_autoadd_blockchain_config(BlockchainConfig raw) { final ptr = inner.new_box_autoadd_blockchain_config_0(); _api_fill_to_wire_blockchain_config(raw, ptr.ref); return ptr; } @protected - ffi.Pointer api2wire_box_autoadd_database_config( - DatabaseConfig raw) { + ffi.Pointer api2wire_box_autoadd_database_config(DatabaseConfig raw) { final ptr = inner.new_box_autoadd_database_config_0(); _api_fill_to_wire_database_config(raw, ptr.ref); return ptr; } @protected - ffi.Pointer api2wire_box_autoadd_electrum_config( - ElectrumConfig raw) { + ffi.Pointer api2wire_box_autoadd_electrum_config(ElectrumConfig raw) { final ptr = inner.new_box_autoadd_electrum_config_0(); _api_fill_to_wire_electrum_config(raw, ptr.ref); return ptr; } @protected - ffi.Pointer api2wire_box_autoadd_esplora_config( - EsploraConfig raw) { + ffi.Pointer api2wire_box_autoadd_esplora_config(EsploraConfig raw) { final ptr = inner.new_box_autoadd_esplora_config_0(); _api_fill_to_wire_esplora_config(raw, ptr.ref); return ptr; @@ -1564,16 +1155,35 @@ class RustPlatform extends FlutterRustBridgeBase { } @protected - ffi.Pointer - api2wire_box_autoadd_sled_db_configuration(SledDbConfiguration raw) { + ffi.Pointer api2wire_box_autoadd_fee_rate(FeeRate raw) { + final ptr = inner.new_box_autoadd_fee_rate_0(); + _api_fill_to_wire_fee_rate(raw, ptr.ref); + return ptr; + } + + @protected + ffi.Pointer api2wire_box_autoadd_rpc_config(RpcConfig raw) { + final ptr = inner.new_box_autoadd_rpc_config_0(); + _api_fill_to_wire_rpc_config(raw, ptr.ref); + return ptr; + } + + @protected + ffi.Pointer api2wire_box_autoadd_rpc_sync_params(RpcSyncParams raw) { + final ptr = inner.new_box_autoadd_rpc_sync_params_0(); + _api_fill_to_wire_rpc_sync_params(raw, ptr.ref); + return ptr; + } + + @protected + ffi.Pointer api2wire_box_autoadd_sled_db_configuration(SledDbConfiguration raw) { final ptr = inner.new_box_autoadd_sled_db_configuration_0(); _api_fill_to_wire_sled_db_configuration(raw, ptr.ref); return ptr; } @protected - ffi.Pointer - api2wire_box_autoadd_sqlite_db_configuration(SqliteDbConfiguration raw) { + ffi.Pointer api2wire_box_autoadd_sqlite_db_configuration(SqliteDbConfiguration raw) { final ptr = inner.new_box_autoadd_sqlite_db_configuration_0(); _api_fill_to_wire_sqlite_db_configuration(raw, ptr.ref); return ptr; @@ -1594,6 +1204,13 @@ class RustPlatform extends FlutterRustBridgeBase { return inner.new_box_autoadd_u8_0(api2wire_u8(raw)); } + @protected + ffi.Pointer api2wire_box_autoadd_user_pass(UserPass raw) { + final ptr = inner.new_box_autoadd_user_pass_0(); + _api_fill_to_wire_user_pass(raw, ptr.ref); + return ptr; + } + @protected ffi.Pointer api2wire_list_out_point(List raw) { final ans = inner.new_list_out_point_0(raw.length); @@ -1604,8 +1221,7 @@ class RustPlatform extends FlutterRustBridgeBase { } @protected - ffi.Pointer api2wire_list_script_amount( - List raw) { + ffi.Pointer api2wire_list_script_amount(List raw) { final ans = inner.new_list_script_amount_0(raw.length); for (var i = 0; i < raw.length; ++i) { _api_fill_to_wire_script_amount(raw[i], ans.ref.ptr[i]); @@ -1618,11 +1234,21 @@ class RustPlatform extends FlutterRustBridgeBase { return raw == null ? ffi.nullptr : api2wire_String(raw); } + @protected + ffi.Pointer api2wire_opt_box_autoadd_BdkDescriptor(BdkDescriptor? raw) { + return raw == null ? ffi.nullptr : api2wire_box_autoadd_BdkDescriptor(raw); + } + @protected ffi.Pointer api2wire_opt_box_autoadd_f32(double? raw) { return raw == null ? ffi.nullptr : api2wire_box_autoadd_f32(raw); } + @protected + ffi.Pointer api2wire_opt_box_autoadd_rpc_sync_params(RpcSyncParams? raw) { + return raw == null ? ffi.nullptr : api2wire_box_autoadd_rpc_sync_params(raw); + } + @protected ffi.Pointer api2wire_opt_box_autoadd_u32(int? raw) { return raw == null ? ffi.nullptr : api2wire_box_autoadd_u32(raw); @@ -1638,6 +1264,11 @@ class RustPlatform extends FlutterRustBridgeBase { return raw == null ? ffi.nullptr : api2wire_box_autoadd_u8(raw); } + @protected + ffi.Pointer api2wire_opt_box_autoadd_user_pass(UserPass? raw) { + return raw == null ? ffi.nullptr : api2wire_box_autoadd_user_pass(raw); + } + @protected int api2wire_u64(int raw) { return raw; @@ -1652,27 +1283,28 @@ class RustPlatform extends FlutterRustBridgeBase { // Section: finalizer + late final OpaqueTypeFinalizer _BdkDescriptorFinalizer = OpaqueTypeFinalizer(inner._drop_opaque_BdkDescriptorPtr); + OpaqueTypeFinalizer get BdkDescriptorFinalizer => _BdkDescriptorFinalizer; late final OpaqueTypeFinalizer _BlockchainInstanceFinalizer = OpaqueTypeFinalizer(inner._drop_opaque_BlockchainInstancePtr); - OpaqueTypeFinalizer get BlockchainInstanceFinalizer => - _BlockchainInstanceFinalizer; - late final OpaqueTypeFinalizer _WalletInstanceFinalizer = - OpaqueTypeFinalizer(inner._drop_opaque_WalletInstancePtr); + OpaqueTypeFinalizer get BlockchainInstanceFinalizer => _BlockchainInstanceFinalizer; + late final OpaqueTypeFinalizer _WalletInstanceFinalizer = OpaqueTypeFinalizer(inner._drop_opaque_WalletInstancePtr); OpaqueTypeFinalizer get WalletInstanceFinalizer => _WalletInstanceFinalizer; // Section: api_fill_to_wire - void _api_fill_to_wire_BlockchainInstance( - BlockchainInstance apiObj, wire_BlockchainInstance wireObj) { + void _api_fill_to_wire_BdkDescriptor(BdkDescriptor apiObj, wire_BdkDescriptor wireObj) { wireObj.ptr = apiObj.shareOrMove(); } - void _api_fill_to_wire_WalletInstance( - WalletInstance apiObj, wire_WalletInstance wireObj) { + void _api_fill_to_wire_BlockchainInstance(BlockchainInstance apiObj, wire_BlockchainInstance wireObj) { wireObj.ptr = apiObj.shareOrMove(); } - void _api_fill_to_wire_blockchain_config( - BlockchainConfig apiObj, wire_BlockchainConfig wireObj) { + void _api_fill_to_wire_WalletInstance(WalletInstance apiObj, wire_WalletInstance wireObj) { + wireObj.ptr = apiObj.shareOrMove(); + } + + void _api_fill_to_wire_blockchain_config(BlockchainConfig apiObj, wire_BlockchainConfig wireObj) { if (apiObj is BlockchainConfig_Electrum) { var pre_config = api2wire_box_autoadd_electrum_config(apiObj.config); wireObj.tag = 0; @@ -1687,6 +1319,17 @@ class RustPlatform extends FlutterRustBridgeBase { wireObj.kind.ref.Esplora.ref.config = pre_config; return; } + if (apiObj is BlockchainConfig_Rpc) { + var pre_config = api2wire_box_autoadd_rpc_config(apiObj.config); + wireObj.tag = 2; + wireObj.kind = inner.inflate_BlockchainConfig_Rpc(); + wireObj.kind.ref.Rpc.ref.config = pre_config; + return; + } + } + + void _api_fill_to_wire_box_autoadd_BdkDescriptor(BdkDescriptor apiObj, ffi.Pointer wireObj) { + _api_fill_to_wire_BdkDescriptor(apiObj, wireObj.ref); } void _api_fill_to_wire_box_autoadd_blockchain_config( @@ -1694,50 +1337,58 @@ class RustPlatform extends FlutterRustBridgeBase { _api_fill_to_wire_blockchain_config(apiObj, wireObj.ref); } - void _api_fill_to_wire_box_autoadd_database_config( - DatabaseConfig apiObj, ffi.Pointer wireObj) { + void _api_fill_to_wire_box_autoadd_database_config(DatabaseConfig apiObj, ffi.Pointer wireObj) { _api_fill_to_wire_database_config(apiObj, wireObj.ref); } - void _api_fill_to_wire_box_autoadd_electrum_config( - ElectrumConfig apiObj, ffi.Pointer wireObj) { + void _api_fill_to_wire_box_autoadd_electrum_config(ElectrumConfig apiObj, ffi.Pointer wireObj) { _api_fill_to_wire_electrum_config(apiObj, wireObj.ref); } - void _api_fill_to_wire_box_autoadd_esplora_config( - EsploraConfig apiObj, ffi.Pointer wireObj) { + void _api_fill_to_wire_box_autoadd_esplora_config(EsploraConfig apiObj, ffi.Pointer wireObj) { _api_fill_to_wire_esplora_config(apiObj, wireObj.ref); } + void _api_fill_to_wire_box_autoadd_fee_rate(FeeRate apiObj, ffi.Pointer wireObj) { + _api_fill_to_wire_fee_rate(apiObj, wireObj.ref); + } + + void _api_fill_to_wire_box_autoadd_rpc_config(RpcConfig apiObj, ffi.Pointer wireObj) { + _api_fill_to_wire_rpc_config(apiObj, wireObj.ref); + } + + void _api_fill_to_wire_box_autoadd_rpc_sync_params(RpcSyncParams apiObj, ffi.Pointer wireObj) { + _api_fill_to_wire_rpc_sync_params(apiObj, wireObj.ref); + } + void _api_fill_to_wire_box_autoadd_sled_db_configuration( - SledDbConfiguration apiObj, - ffi.Pointer wireObj) { + SledDbConfiguration apiObj, ffi.Pointer wireObj) { _api_fill_to_wire_sled_db_configuration(apiObj, wireObj.ref); } void _api_fill_to_wire_box_autoadd_sqlite_db_configuration( - SqliteDbConfiguration apiObj, - ffi.Pointer wireObj) { + SqliteDbConfiguration apiObj, ffi.Pointer wireObj) { _api_fill_to_wire_sqlite_db_configuration(apiObj, wireObj.ref); } - void _api_fill_to_wire_database_config( - DatabaseConfig apiObj, wire_DatabaseConfig wireObj) { + void _api_fill_to_wire_box_autoadd_user_pass(UserPass apiObj, ffi.Pointer wireObj) { + _api_fill_to_wire_user_pass(apiObj, wireObj.ref); + } + + void _api_fill_to_wire_database_config(DatabaseConfig apiObj, wire_DatabaseConfig wireObj) { if (apiObj is DatabaseConfig_Memory) { wireObj.tag = 0; return; } if (apiObj is DatabaseConfig_Sqlite) { - var pre_config = - api2wire_box_autoadd_sqlite_db_configuration(apiObj.config); + var pre_config = api2wire_box_autoadd_sqlite_db_configuration(apiObj.config); wireObj.tag = 1; wireObj.kind = inner.inflate_DatabaseConfig_Sqlite(); wireObj.kind.ref.Sqlite.ref.config = pre_config; return; } if (apiObj is DatabaseConfig_Sled) { - var pre_config = - api2wire_box_autoadd_sled_db_configuration(apiObj.config); + var pre_config = api2wire_box_autoadd_sled_db_configuration(apiObj.config); wireObj.tag = 2; wireObj.kind = inner.inflate_DatabaseConfig_Sled(); wireObj.kind.ref.Sled.ref.config = pre_config; @@ -1745,17 +1396,16 @@ class RustPlatform extends FlutterRustBridgeBase { } } - void _api_fill_to_wire_electrum_config( - ElectrumConfig apiObj, wire_ElectrumConfig wireObj) { + void _api_fill_to_wire_electrum_config(ElectrumConfig apiObj, wire_ElectrumConfig wireObj) { wireObj.url = api2wire_String(apiObj.url); wireObj.socks5 = api2wire_opt_String(apiObj.socks5); wireObj.retry = api2wire_u8(apiObj.retry); wireObj.timeout = api2wire_opt_box_autoadd_u8(apiObj.timeout); wireObj.stop_gap = api2wire_u64(apiObj.stopGap); + wireObj.validate_domain = api2wire_bool(apiObj.validateDomain); } - void _api_fill_to_wire_esplora_config( - EsploraConfig apiObj, wire_EsploraConfig wireObj) { + void _api_fill_to_wire_esplora_config(EsploraConfig apiObj, wire_EsploraConfig wireObj) { wireObj.base_url = api2wire_String(apiObj.baseUrl); wireObj.proxy = api2wire_opt_String(apiObj.proxy); wireObj.concurrency = api2wire_opt_box_autoadd_u8(apiObj.concurrency); @@ -1763,27 +1413,62 @@ class RustPlatform extends FlutterRustBridgeBase { wireObj.timeout = api2wire_opt_box_autoadd_u64(apiObj.timeout); } + void _api_fill_to_wire_fee_rate(FeeRate apiObj, wire_FeeRate wireObj) { + wireObj.field0 = api2wire_f32(apiObj.field0); + } + + void _api_fill_to_wire_opt_box_autoadd_BdkDescriptor(BdkDescriptor? apiObj, ffi.Pointer wireObj) { + if (apiObj != null) _api_fill_to_wire_box_autoadd_BdkDescriptor(apiObj, wireObj); + } + + void _api_fill_to_wire_opt_box_autoadd_rpc_sync_params( + RpcSyncParams? apiObj, ffi.Pointer wireObj) { + if (apiObj != null) _api_fill_to_wire_box_autoadd_rpc_sync_params(apiObj, wireObj); + } + + void _api_fill_to_wire_opt_box_autoadd_user_pass(UserPass? apiObj, ffi.Pointer wireObj) { + if (apiObj != null) _api_fill_to_wire_box_autoadd_user_pass(apiObj, wireObj); + } + void _api_fill_to_wire_out_point(OutPoint apiObj, wire_OutPoint wireObj) { wireObj.txid = api2wire_String(apiObj.txid); wireObj.vout = api2wire_u32(apiObj.vout); } - void _api_fill_to_wire_script_amount( - ScriptAmount apiObj, wire_ScriptAmount wireObj) { + void _api_fill_to_wire_rpc_config(RpcConfig apiObj, wire_RpcConfig wireObj) { + wireObj.url = api2wire_String(apiObj.url); + wireObj.auth_cookie = api2wire_opt_String(apiObj.authCookie); + wireObj.auth_user_pass = api2wire_opt_box_autoadd_user_pass(apiObj.authUserPass); + wireObj.network = api2wire_network(apiObj.network); + wireObj.wallet_name = api2wire_String(apiObj.walletName); + wireObj.sync_params = api2wire_opt_box_autoadd_rpc_sync_params(apiObj.syncParams); + } + + void _api_fill_to_wire_rpc_sync_params(RpcSyncParams apiObj, wire_RpcSyncParams wireObj) { + wireObj.start_script_count = api2wire_u64(apiObj.startScriptCount); + wireObj.start_time = api2wire_u64(apiObj.startTime); + wireObj.force_start_time = api2wire_bool(apiObj.forceStartTime); + wireObj.poll_rate_sec = api2wire_u64(apiObj.pollRateSec); + } + + void _api_fill_to_wire_script_amount(ScriptAmount apiObj, wire_ScriptAmount wireObj) { wireObj.script = api2wire_String(apiObj.script); wireObj.amount = api2wire_u64(apiObj.amount); } - void _api_fill_to_wire_sled_db_configuration( - SledDbConfiguration apiObj, wire_SledDbConfiguration wireObj) { + void _api_fill_to_wire_sled_db_configuration(SledDbConfiguration apiObj, wire_SledDbConfiguration wireObj) { wireObj.path = api2wire_String(apiObj.path); wireObj.tree_name = api2wire_String(apiObj.treeName); } - void _api_fill_to_wire_sqlite_db_configuration( - SqliteDbConfiguration apiObj, wire_SqliteDbConfiguration wireObj) { + void _api_fill_to_wire_sqlite_db_configuration(SqliteDbConfiguration apiObj, wire_SqliteDbConfiguration wireObj) { wireObj.path = api2wire_String(apiObj.path); } + + void _api_fill_to_wire_user_pass(UserPass apiObj, wire_UserPass wireObj) { + wireObj.username = api2wire_String(apiObj.username); + wireObj.password = api2wire_String(apiObj.password); + } } // ignore_for_file: camel_case_types, non_constant_identifier_names, avoid_positional_boolean_parameters, annotate_overrides, constant_identifier_names @@ -1798,17 +1483,13 @@ class RustWire implements FlutterRustBridgeWireBase { late final dartApi = DartApiDl(init_frb_dart_api_dl); /// Holds the symbol lookup function. - final ffi.Pointer Function(String symbolName) - _lookup; + final ffi.Pointer Function(String symbolName) _lookup; /// The symbols are looked up in [dynamicLibrary]. RustWire(ffi.DynamicLibrary dynamicLibrary) : _lookup = dynamicLibrary.lookup; /// The symbols are looked up with [lookup]. - RustWire.fromLookup( - ffi.Pointer Function(String symbolName) - lookup) - : _lookup = lookup; + RustWire.fromLookup(ffi.Pointer Function(String symbolName) lookup) : _lookup = lookup; void store_dart_post_cobject( DartPostCObjectFnType ptr, @@ -1819,10 +1500,8 @@ class RustWire implements FlutterRustBridgeWireBase { } late final _store_dart_post_cobjectPtr = - _lookup>( - 'store_dart_post_cobject'); - late final _store_dart_post_cobject = _store_dart_post_cobjectPtr - .asFunction(); + _lookup>('store_dart_post_cobject'); + late final _store_dart_post_cobject = _store_dart_post_cobjectPtr.asFunction(); Object get_dart_object( int ptr, @@ -1832,11 +1511,8 @@ class RustWire implements FlutterRustBridgeWireBase { ); } - late final _get_dart_objectPtr = - _lookup>( - 'get_dart_object'); - late final _get_dart_object = - _get_dart_objectPtr.asFunction(); + late final _get_dart_objectPtr = _lookup>('get_dart_object'); + late final _get_dart_object = _get_dart_objectPtr.asFunction(); void drop_dart_object( int ptr, @@ -1846,11 +1522,8 @@ class RustWire implements FlutterRustBridgeWireBase { ); } - late final _drop_dart_objectPtr = - _lookup>( - 'drop_dart_object'); - late final _drop_dart_object = - _drop_dart_objectPtr.asFunction(); + late final _drop_dart_objectPtr = _lookup>('drop_dart_object'); + late final _drop_dart_object = _drop_dart_objectPtr.asFunction(); int new_dart_opaque( Object handle, @@ -1860,11 +1533,8 @@ class RustWire implements FlutterRustBridgeWireBase { ); } - late final _new_dart_opaquePtr = - _lookup>( - 'new_dart_opaque'); - late final _new_dart_opaque = - _new_dart_opaquePtr.asFunction(); + late final _new_dart_opaquePtr = _lookup>('new_dart_opaque'); + late final _new_dart_opaque = _new_dart_opaquePtr.asFunction(); int init_frb_dart_api_dl( ffi.Pointer obj, @@ -1875,10 +1545,8 @@ class RustWire implements FlutterRustBridgeWireBase { } late final _init_frb_dart_api_dlPtr = - _lookup)>>( - 'init_frb_dart_api_dl'); - late final _init_frb_dart_api_dl = _init_frb_dart_api_dlPtr - .asFunction)>(); + _lookup)>>('init_frb_dart_api_dl'); + late final _init_frb_dart_api_dl = _init_frb_dart_api_dlPtr.asFunction)>(); void wire_blockchain_init( int port_, @@ -1890,12 +1558,11 @@ class RustWire implements FlutterRustBridgeWireBase { ); } - late final _wire_blockchain_initPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Int64, - ffi.Pointer)>>('wire_blockchain_init'); - late final _wire_blockchain_init = _wire_blockchain_initPtr - .asFunction)>(); + late final _wire_blockchain_initPtr = + _lookup)>>( + 'wire_blockchain_init'); + late final _wire_blockchain_init = + _wire_blockchain_initPtr.asFunction)>(); void wire_get_blockchain_height( int port_, @@ -1907,12 +1574,10 @@ class RustWire implements FlutterRustBridgeWireBase { ); } - late final _wire_get_blockchain_heightPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Int64, - wire_BlockchainInstance)>>('wire_get_blockchain_height'); - late final _wire_get_blockchain_height = _wire_get_blockchain_heightPtr - .asFunction(); + late final _wire_get_blockchain_heightPtr = + _lookup>('wire_get_blockchain_height'); + late final _wire_get_blockchain_height = + _wire_get_blockchain_heightPtr.asFunction(); void wire_get_blockchain_hash( int port_, @@ -1926,12 +1591,11 @@ class RustWire implements FlutterRustBridgeWireBase { ); } - late final _wire_get_blockchain_hashPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Int64, ffi.Uint32, - wire_BlockchainInstance)>>('wire_get_blockchain_hash'); - late final _wire_get_blockchain_hash = _wire_get_blockchain_hashPtr - .asFunction(); + late final _wire_get_blockchain_hashPtr = + _lookup>( + 'wire_get_blockchain_hash'); + late final _wire_get_blockchain_hash = + _wire_get_blockchain_hashPtr.asFunction(); void wire_broadcast( int port_, @@ -1945,13 +1609,11 @@ class RustWire implements FlutterRustBridgeWireBase { ); } - late final _wire_broadcastPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Int64, ffi.Pointer, - wire_BlockchainInstance)>>('wire_broadcast'); - late final _wire_broadcast = _wire_broadcastPtr.asFunction< - void Function( - int, ffi.Pointer, wire_BlockchainInstance)>(); + late final _wire_broadcastPtr = + _lookup, wire_BlockchainInstance)>>( + 'wire_broadcast'); + late final _wire_broadcast = + _wire_broadcastPtr.asFunction, wire_BlockchainInstance)>(); void wire_psbt_to_txid( int port_, @@ -1963,12 +1625,9 @@ class RustWire implements FlutterRustBridgeWireBase { ); } - late final _wire_psbt_to_txidPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Int64, ffi.Pointer)>>('wire_psbt_to_txid'); - late final _wire_psbt_to_txid = _wire_psbt_to_txidPtr - .asFunction)>(); + late final _wire_psbt_to_txidPtr = + _lookup)>>('wire_psbt_to_txid'); + late final _wire_psbt_to_txid = _wire_psbt_to_txidPtr.asFunction)>(); void wire_extract_tx( int port_, @@ -1980,12 +1639,9 @@ class RustWire implements FlutterRustBridgeWireBase { ); } - late final _wire_extract_txPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Int64, ffi.Pointer)>>('wire_extract_tx'); - late final _wire_extract_tx = _wire_extract_txPtr - .asFunction)>(); + late final _wire_extract_txPtr = + _lookup)>>('wire_extract_tx'); + late final _wire_extract_tx = _wire_extract_txPtr.asFunction)>(); void wire_get_fee_rate( int port_, @@ -1997,12 +1653,24 @@ class RustWire implements FlutterRustBridgeWireBase { ); } - late final _wire_get_fee_ratePtr = _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Int64, ffi.Pointer)>>('wire_get_fee_rate'); - late final _wire_get_fee_rate = _wire_get_fee_ratePtr - .asFunction)>(); + late final _wire_get_fee_ratePtr = + _lookup)>>('wire_get_fee_rate'); + late final _wire_get_fee_rate = _wire_get_fee_ratePtr.asFunction)>(); + + void wire_get_fee_amount( + int port_, + ffi.Pointer psbt_str, + ) { + return _wire_get_fee_amount( + port_, + psbt_str, + ); + } + + late final _wire_get_fee_amountPtr = + _lookup)>>('wire_get_fee_amount'); + late final _wire_get_fee_amount = + _wire_get_fee_amountPtr.asFunction)>(); void wire_combine_psbt( int port_, @@ -2018,11 +1686,10 @@ class RustWire implements FlutterRustBridgeWireBase { late final _wire_combine_psbtPtr = _lookup< ffi.NativeFunction< - ffi.Void Function(ffi.Int64, ffi.Pointer, - ffi.Pointer)>>('wire_combine_psbt'); - late final _wire_combine_psbt = _wire_combine_psbtPtr.asFunction< - void Function( - int, ffi.Pointer, ffi.Pointer)>(); + ffi.Void Function( + ffi.Int64, ffi.Pointer, ffi.Pointer)>>('wire_combine_psbt'); + late final _wire_combine_psbt = _wire_combine_psbtPtr + .asFunction, ffi.Pointer)>(); void wire_tx_builder_finish( int port_, @@ -2118,24 +1785,186 @@ class RustWire implements FlutterRustBridgeWireBase { late final _wire_bump_fee_tx_builder_finishPtr = _lookup< ffi.NativeFunction< - ffi.Void Function( - ffi.Int64, - ffi.Pointer, - ffi.Float, - ffi.Pointer, - wire_WalletInstance, - ffi.Bool, - ffi.Pointer)>>('wire_bump_fee_tx_builder_finish'); - late final _wire_bump_fee_tx_builder_finish = - _wire_bump_fee_tx_builder_finishPtr.asFunction< - void Function( - int, - ffi.Pointer, - double, - ffi.Pointer, - wire_WalletInstance, - bool, - ffi.Pointer)>(); + ffi.Void Function(ffi.Int64, ffi.Pointer, ffi.Float, ffi.Pointer, + wire_WalletInstance, ffi.Bool, ffi.Pointer)>>('wire_bump_fee_tx_builder_finish'); + late final _wire_bump_fee_tx_builder_finish = _wire_bump_fee_tx_builder_finishPtr.asFunction< + void Function(int, ffi.Pointer, double, ffi.Pointer, wire_WalletInstance, + bool, ffi.Pointer)>(); + + void wire_new_descriptor( + int port_, + ffi.Pointer descriptor, + int network, + ) { + return _wire_new_descriptor( + port_, + descriptor, + network, + ); + } + + late final _wire_new_descriptorPtr = + _lookup, ffi.Int32)>>( + 'wire_new_descriptor'); + late final _wire_new_descriptor = + _wire_new_descriptorPtr.asFunction, int)>(); + + void wire_new_bip44_descriptor( + int port_, + int key_chain_kind, + ffi.Pointer secret_key, + int network, + ) { + return _wire_new_bip44_descriptor( + port_, + key_chain_kind, + secret_key, + network, + ); + } + + late final _wire_new_bip44_descriptorPtr = + _lookup, ffi.Int32)>>( + 'wire_new_bip44_descriptor'); + late final _wire_new_bip44_descriptor = + _wire_new_bip44_descriptorPtr.asFunction, int)>(); + + void wire_new_bip44_public( + int port_, + int key_chain_kind, + ffi.Pointer public_key, + int network, + ffi.Pointer fingerprint, + ) { + return _wire_new_bip44_public( + port_, + key_chain_kind, + public_key, + network, + fingerprint, + ); + } + + late final _wire_new_bip44_publicPtr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Int64, ffi.Int32, ffi.Pointer, ffi.Int32, + ffi.Pointer)>>('wire_new_bip44_public'); + late final _wire_new_bip44_public = _wire_new_bip44_publicPtr + .asFunction, int, ffi.Pointer)>(); + + void wire_new_bip49_descriptor( + int port_, + int key_chain_kind, + ffi.Pointer secret_key, + int network, + ) { + return _wire_new_bip49_descriptor( + port_, + key_chain_kind, + secret_key, + network, + ); + } + + late final _wire_new_bip49_descriptorPtr = + _lookup, ffi.Int32)>>( + 'wire_new_bip49_descriptor'); + late final _wire_new_bip49_descriptor = + _wire_new_bip49_descriptorPtr.asFunction, int)>(); + + void wire_new_bip49_public( + int port_, + int key_chain_kind, + ffi.Pointer public_key, + int network, + ffi.Pointer fingerprint, + ) { + return _wire_new_bip49_public( + port_, + key_chain_kind, + public_key, + network, + fingerprint, + ); + } + + late final _wire_new_bip49_publicPtr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Int64, ffi.Int32, ffi.Pointer, ffi.Int32, + ffi.Pointer)>>('wire_new_bip49_public'); + late final _wire_new_bip49_public = _wire_new_bip49_publicPtr + .asFunction, int, ffi.Pointer)>(); + + void wire_new_bip84_descriptor( + int port_, + int key_chain_kind, + ffi.Pointer secret_key, + int network, + ) { + return _wire_new_bip84_descriptor( + port_, + key_chain_kind, + secret_key, + network, + ); + } + + late final _wire_new_bip84_descriptorPtr = + _lookup, ffi.Int32)>>( + 'wire_new_bip84_descriptor'); + late final _wire_new_bip84_descriptor = + _wire_new_bip84_descriptorPtr.asFunction, int)>(); + + void wire_new_bip84_public( + int port_, + int key_chain_kind, + ffi.Pointer public_key, + int network, + ffi.Pointer fingerprint, + ) { + return _wire_new_bip84_public( + port_, + key_chain_kind, + public_key, + network, + fingerprint, + ); + } + + late final _wire_new_bip84_publicPtr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Int64, ffi.Int32, ffi.Pointer, ffi.Int32, + ffi.Pointer)>>('wire_new_bip84_public'); + late final _wire_new_bip84_public = _wire_new_bip84_publicPtr + .asFunction, int, ffi.Pointer)>(); + + void wire_as_string_private( + int port_, + wire_BdkDescriptor descriptor, + ) { + return _wire_as_string_private( + port_, + descriptor, + ); + } + + late final _wire_as_string_privatePtr = + _lookup>('wire_as_string_private'); + late final _wire_as_string_private = _wire_as_string_privatePtr.asFunction(); + + void wire_as_string( + int port_, + wire_BdkDescriptor descriptor, + ) { + return _wire_as_string( + port_, + descriptor, + ); + } + + late final _wire_as_stringPtr = + _lookup>('wire_as_string'); + late final _wire_as_string = _wire_as_stringPtr.asFunction(); void wire_descriptor_secret_extend( int port_, @@ -2153,10 +1982,8 @@ class RustWire implements FlutterRustBridgeWireBase { ffi.NativeFunction< ffi.Void Function(ffi.Int64, ffi.Pointer, ffi.Pointer)>>('wire_descriptor_secret_extend'); - late final _wire_descriptor_secret_extend = - _wire_descriptor_secret_extendPtr.asFunction< - void Function(int, ffi.Pointer, - ffi.Pointer)>(); + late final _wire_descriptor_secret_extend = _wire_descriptor_secret_extendPtr + .asFunction, ffi.Pointer)>(); void wire_descriptor_secret_derive( int port_, @@ -2174,10 +2001,8 @@ class RustWire implements FlutterRustBridgeWireBase { ffi.NativeFunction< ffi.Void Function(ffi.Int64, ffi.Pointer, ffi.Pointer)>>('wire_descriptor_secret_derive'); - late final _wire_descriptor_secret_derive = - _wire_descriptor_secret_derivePtr.asFunction< - void Function(int, ffi.Pointer, - ffi.Pointer)>(); + late final _wire_descriptor_secret_derive = _wire_descriptor_secret_derivePtr + .asFunction, ffi.Pointer)>(); void wire_descriptor_secret_as_secret_bytes( int port_, @@ -2192,14 +2017,11 @@ class RustWire implements FlutterRustBridgeWireBase { } late final _wire_descriptor_secret_as_secret_bytesPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Int64, ffi.Pointer, - ffi.Pointer)>>( - 'wire_descriptor_secret_as_secret_bytes'); - late final _wire_descriptor_secret_as_secret_bytes = - _wire_descriptor_secret_as_secret_bytesPtr.asFunction< - void Function(int, ffi.Pointer, - ffi.Pointer)>(); + ffi.NativeFunction< + ffi.Void Function(ffi.Int64, ffi.Pointer, + ffi.Pointer)>>('wire_descriptor_secret_as_secret_bytes'); + late final _wire_descriptor_secret_as_secret_bytes = _wire_descriptor_secret_as_secret_bytesPtr + .asFunction, ffi.Pointer)>(); void wire_descriptor_secret_as_public( int port_, @@ -2214,14 +2036,11 @@ class RustWire implements FlutterRustBridgeWireBase { } late final _wire_descriptor_secret_as_publicPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Int64, ffi.Pointer, - ffi.Pointer)>>( - 'wire_descriptor_secret_as_public'); - late final _wire_descriptor_secret_as_public = - _wire_descriptor_secret_as_publicPtr.asFunction< - void Function(int, ffi.Pointer, - ffi.Pointer)>(); + ffi.NativeFunction< + ffi.Void Function(ffi.Int64, ffi.Pointer, + ffi.Pointer)>>('wire_descriptor_secret_as_public'); + late final _wire_descriptor_secret_as_public = _wire_descriptor_secret_as_publicPtr + .asFunction, ffi.Pointer)>(); void wire_create_descriptor_secret( int port_, @@ -2241,10 +2060,8 @@ class RustWire implements FlutterRustBridgeWireBase { ffi.NativeFunction< ffi.Void Function(ffi.Int64, ffi.Int32, ffi.Pointer, ffi.Pointer)>>('wire_create_descriptor_secret'); - late final _wire_create_descriptor_secret = - _wire_create_descriptor_secretPtr.asFunction< - void Function(int, int, ffi.Pointer, - ffi.Pointer)>(); + late final _wire_create_descriptor_secret = _wire_create_descriptor_secretPtr + .asFunction, ffi.Pointer)>(); void wire_create_derivation_path( int port_, @@ -2256,12 +2073,11 @@ class RustWire implements FlutterRustBridgeWireBase { ); } - late final _wire_create_derivation_pathPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Int64, - ffi.Pointer)>>('wire_create_derivation_path'); - late final _wire_create_derivation_path = _wire_create_derivation_pathPtr - .asFunction)>(); + late final _wire_create_derivation_pathPtr = + _lookup)>>( + 'wire_create_derivation_path'); + late final _wire_create_derivation_path = + _wire_create_derivation_pathPtr.asFunction)>(); void wire_create_descriptor_public( int port_, @@ -2279,15 +2095,10 @@ class RustWire implements FlutterRustBridgeWireBase { late final _wire_create_descriptor_publicPtr = _lookup< ffi.NativeFunction< - ffi.Void Function( - ffi.Int64, - ffi.Pointer, - ffi.Pointer, + ffi.Void Function(ffi.Int64, ffi.Pointer, ffi.Pointer, ffi.Bool)>>('wire_create_descriptor_public'); - late final _wire_create_descriptor_public = - _wire_create_descriptor_publicPtr.asFunction< - void Function(int, ffi.Pointer, - ffi.Pointer, bool)>(); + late final _wire_create_descriptor_public = _wire_create_descriptor_publicPtr + .asFunction, ffi.Pointer, bool)>(); void wire_init_script( int port_, @@ -2299,12 +2110,9 @@ class RustWire implements FlutterRustBridgeWireBase { ); } - late final _wire_init_scriptPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Int64, ffi.Pointer)>>('wire_init_script'); - late final _wire_init_script = _wire_init_scriptPtr - .asFunction)>(); + late final _wire_init_scriptPtr = + _lookup)>>('wire_init_script'); + late final _wire_init_script = _wire_init_scriptPtr.asFunction)>(); void wire_init_address( int port_, @@ -2316,12 +2124,9 @@ class RustWire implements FlutterRustBridgeWireBase { ); } - late final _wire_init_addressPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Int64, ffi.Pointer)>>('wire_init_address'); - late final _wire_init_address = _wire_init_addressPtr - .asFunction)>(); + late final _wire_init_addressPtr = + _lookup)>>('wire_init_address'); + late final _wire_init_address = _wire_init_addressPtr.asFunction)>(); void wire_address_to_script_pubkey_hex( int port_, @@ -2333,18 +2138,16 @@ class RustWire implements FlutterRustBridgeWireBase { ); } - late final _wire_address_to_script_pubkey_hexPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Int64, ffi.Pointer)>>( - 'wire_address_to_script_pubkey_hex'); + late final _wire_address_to_script_pubkey_hexPtr = + _lookup)>>( + 'wire_address_to_script_pubkey_hex'); late final _wire_address_to_script_pubkey_hex = - _wire_address_to_script_pubkey_hexPtr - .asFunction)>(); + _wire_address_to_script_pubkey_hexPtr.asFunction)>(); void wire_wallet_init( int port_, - ffi.Pointer descriptor, - ffi.Pointer change_descriptor, + wire_BdkDescriptor descriptor, + ffi.Pointer change_descriptor, int network, ffi.Pointer database_config, ) { @@ -2359,19 +2162,10 @@ class RustWire implements FlutterRustBridgeWireBase { late final _wire_wallet_initPtr = _lookup< ffi.NativeFunction< - ffi.Void Function( - ffi.Int64, - ffi.Pointer, - ffi.Pointer, - ffi.Int32, + ffi.Void Function(ffi.Int64, wire_BdkDescriptor, ffi.Pointer, ffi.Int32, ffi.Pointer)>>('wire_wallet_init'); late final _wire_wallet_init = _wire_wallet_initPtr.asFunction< - void Function( - int, - ffi.Pointer, - ffi.Pointer, - int, - ffi.Pointer)>(); + void Function(int, wire_BdkDescriptor, ffi.Pointer, int, ffi.Pointer)>(); void wire_get_address( int port_, @@ -2385,12 +2179,9 @@ class RustWire implements FlutterRustBridgeWireBase { ); } - late final _wire_get_addressPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Int64, wire_WalletInstance, ffi.Int32)>>('wire_get_address'); - late final _wire_get_address = _wire_get_addressPtr - .asFunction(); + late final _wire_get_addressPtr = + _lookup>('wire_get_address'); + late final _wire_get_address = _wire_get_addressPtr.asFunction(); void wire_sync_wallet( int port_, @@ -2404,12 +2195,11 @@ class RustWire implements FlutterRustBridgeWireBase { ); } - late final _wire_sync_walletPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Int64, wire_WalletInstance, - wire_BlockchainInstance)>>('wire_sync_wallet'); - late final _wire_sync_wallet = _wire_sync_walletPtr.asFunction< - void Function(int, wire_WalletInstance, wire_BlockchainInstance)>(); + late final _wire_sync_walletPtr = + _lookup>( + 'wire_sync_wallet'); + late final _wire_sync_wallet = + _wire_sync_walletPtr.asFunction(); void wire_get_balance( int port_, @@ -2421,12 +2211,9 @@ class RustWire implements FlutterRustBridgeWireBase { ); } - late final _wire_get_balancePtr = _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Int64, wire_WalletInstance)>>('wire_get_balance'); - late final _wire_get_balance = _wire_get_balancePtr - .asFunction(); + late final _wire_get_balancePtr = + _lookup>('wire_get_balance'); + late final _wire_get_balance = _wire_get_balancePtr.asFunction(); void wire_list_unspent_outputs( int port_, @@ -2438,12 +2225,10 @@ class RustWire implements FlutterRustBridgeWireBase { ); } - late final _wire_list_unspent_outputsPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Int64, wire_WalletInstance)>>('wire_list_unspent_outputs'); - late final _wire_list_unspent_outputs = _wire_list_unspent_outputsPtr - .asFunction(); + late final _wire_list_unspent_outputsPtr = + _lookup>('wire_list_unspent_outputs'); + late final _wire_list_unspent_outputs = + _wire_list_unspent_outputsPtr.asFunction(); void wire_get_transactions( int port_, @@ -2455,12 +2240,9 @@ class RustWire implements FlutterRustBridgeWireBase { ); } - late final _wire_get_transactionsPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Int64, wire_WalletInstance)>>('wire_get_transactions'); - late final _wire_get_transactions = _wire_get_transactionsPtr - .asFunction(); + late final _wire_get_transactionsPtr = + _lookup>('wire_get_transactions'); + late final _wire_get_transactions = _wire_get_transactionsPtr.asFunction(); void wire_sign( int port_, @@ -2478,11 +2260,9 @@ class RustWire implements FlutterRustBridgeWireBase { late final _wire_signPtr = _lookup< ffi.NativeFunction< - ffi.Void Function(ffi.Int64, wire_WalletInstance, - ffi.Pointer, ffi.Bool)>>('wire_sign'); - late final _wire_sign = _wire_signPtr.asFunction< - void Function( - int, wire_WalletInstance, ffi.Pointer, bool)>(); + ffi.Void Function(ffi.Int64, wire_WalletInstance, ffi.Pointer, ffi.Bool)>>('wire_sign'); + late final _wire_sign = + _wire_signPtr.asFunction, bool)>(); void wire_get_network( int port_, @@ -2494,12 +2274,9 @@ class RustWire implements FlutterRustBridgeWireBase { ); } - late final _wire_get_networkPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Int64, wire_WalletInstance)>>('wire_get_network'); - late final _wire_get_network = _wire_get_networkPtr - .asFunction(); + late final _wire_get_networkPtr = + _lookup>('wire_get_network'); + late final _wire_get_network = _wire_get_networkPtr.asFunction(); void wire_list_unspent( int port_, @@ -2511,12 +2288,9 @@ class RustWire implements FlutterRustBridgeWireBase { ); } - late final _wire_list_unspentPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Int64, wire_WalletInstance)>>('wire_list_unspent'); - late final _wire_list_unspent = _wire_list_unspentPtr - .asFunction(); + late final _wire_list_unspentPtr = + _lookup>('wire_list_unspent'); + late final _wire_list_unspent = _wire_list_unspentPtr.asFunction(); void wire_generate_seed_from_word_count( int port_, @@ -2529,11 +2303,9 @@ class RustWire implements FlutterRustBridgeWireBase { } late final _wire_generate_seed_from_word_countPtr = - _lookup>( - 'wire_generate_seed_from_word_count'); + _lookup>('wire_generate_seed_from_word_count'); late final _wire_generate_seed_from_word_count = - _wire_generate_seed_from_word_countPtr - .asFunction(); + _wire_generate_seed_from_word_countPtr.asFunction(); void wire_generate_seed_from_string( int port_, @@ -2545,13 +2317,11 @@ class RustWire implements FlutterRustBridgeWireBase { ); } - late final _wire_generate_seed_from_stringPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Int64, ffi.Pointer)>>( - 'wire_generate_seed_from_string'); + late final _wire_generate_seed_from_stringPtr = + _lookup)>>( + 'wire_generate_seed_from_string'); late final _wire_generate_seed_from_string = - _wire_generate_seed_from_stringPtr - .asFunction)>(); + _wire_generate_seed_from_stringPtr.asFunction)>(); void wire_generate_seed_from_entropy( int port_, @@ -2563,77 +2333,94 @@ class RustWire implements FlutterRustBridgeWireBase { ); } - late final _wire_generate_seed_from_entropyPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Int64, ffi.Pointer)>>( - 'wire_generate_seed_from_entropy'); + late final _wire_generate_seed_from_entropyPtr = + _lookup)>>( + 'wire_generate_seed_from_entropy'); late final _wire_generate_seed_from_entropy = - _wire_generate_seed_from_entropyPtr - .asFunction)>(); + _wire_generate_seed_from_entropyPtr.asFunction)>(); + + void wire_as_sat_per_vb__method__FeeRate( + int port_, + ffi.Pointer that, + ) { + return _wire_as_sat_per_vb__method__FeeRate( + port_, + that, + ); + } + + late final _wire_as_sat_per_vb__method__FeeRatePtr = + _lookup)>>( + 'wire_as_sat_per_vb__method__FeeRate'); + late final _wire_as_sat_per_vb__method__FeeRate = + _wire_as_sat_per_vb__method__FeeRatePtr.asFunction)>(); + + wire_BdkDescriptor new_BdkDescriptor() { + return _new_BdkDescriptor(); + } + + late final _new_BdkDescriptorPtr = _lookup>('new_BdkDescriptor'); + late final _new_BdkDescriptor = _new_BdkDescriptorPtr.asFunction(); wire_BlockchainInstance new_BlockchainInstance() { return _new_BlockchainInstance(); } late final _new_BlockchainInstancePtr = - _lookup>( - 'new_BlockchainInstance'); - late final _new_BlockchainInstance = _new_BlockchainInstancePtr - .asFunction(); + _lookup>('new_BlockchainInstance'); + late final _new_BlockchainInstance = _new_BlockchainInstancePtr.asFunction(); wire_WalletInstance new_WalletInstance() { return _new_WalletInstance(); } - late final _new_WalletInstancePtr = - _lookup>( - 'new_WalletInstance'); - late final _new_WalletInstance = - _new_WalletInstancePtr.asFunction(); + late final _new_WalletInstancePtr = _lookup>('new_WalletInstance'); + late final _new_WalletInstance = _new_WalletInstancePtr.asFunction(); + + ffi.Pointer new_box_autoadd_BdkDescriptor_0() { + return _new_box_autoadd_BdkDescriptor_0(); + } + + late final _new_box_autoadd_BdkDescriptor_0Ptr = + _lookup Function()>>('new_box_autoadd_BdkDescriptor_0'); + late final _new_box_autoadd_BdkDescriptor_0 = + _new_box_autoadd_BdkDescriptor_0Ptr.asFunction Function()>(); ffi.Pointer new_box_autoadd_blockchain_config_0() { return _new_box_autoadd_blockchain_config_0(); } - late final _new_box_autoadd_blockchain_config_0Ptr = _lookup< - ffi.NativeFunction Function()>>( - 'new_box_autoadd_blockchain_config_0'); + late final _new_box_autoadd_blockchain_config_0Ptr = + _lookup Function()>>('new_box_autoadd_blockchain_config_0'); late final _new_box_autoadd_blockchain_config_0 = - _new_box_autoadd_blockchain_config_0Ptr - .asFunction Function()>(); + _new_box_autoadd_blockchain_config_0Ptr.asFunction Function()>(); ffi.Pointer new_box_autoadd_database_config_0() { return _new_box_autoadd_database_config_0(); } late final _new_box_autoadd_database_config_0Ptr = - _lookup Function()>>( - 'new_box_autoadd_database_config_0'); + _lookup Function()>>('new_box_autoadd_database_config_0'); late final _new_box_autoadd_database_config_0 = - _new_box_autoadd_database_config_0Ptr - .asFunction Function()>(); + _new_box_autoadd_database_config_0Ptr.asFunction Function()>(); ffi.Pointer new_box_autoadd_electrum_config_0() { return _new_box_autoadd_electrum_config_0(); } late final _new_box_autoadd_electrum_config_0Ptr = - _lookup Function()>>( - 'new_box_autoadd_electrum_config_0'); + _lookup Function()>>('new_box_autoadd_electrum_config_0'); late final _new_box_autoadd_electrum_config_0 = - _new_box_autoadd_electrum_config_0Ptr - .asFunction Function()>(); + _new_box_autoadd_electrum_config_0Ptr.asFunction Function()>(); ffi.Pointer new_box_autoadd_esplora_config_0() { return _new_box_autoadd_esplora_config_0(); } late final _new_box_autoadd_esplora_config_0Ptr = - _lookup Function()>>( - 'new_box_autoadd_esplora_config_0'); + _lookup Function()>>('new_box_autoadd_esplora_config_0'); late final _new_box_autoadd_esplora_config_0 = - _new_box_autoadd_esplora_config_0Ptr - .asFunction Function()>(); + _new_box_autoadd_esplora_config_0Ptr.asFunction Function()>(); ffi.Pointer new_box_autoadd_f32_0( double value, @@ -2644,35 +2431,55 @@ class RustWire implements FlutterRustBridgeWireBase { } late final _new_box_autoadd_f32_0Ptr = - _lookup Function(ffi.Float)>>( - 'new_box_autoadd_f32_0'); - late final _new_box_autoadd_f32_0 = _new_box_autoadd_f32_0Ptr - .asFunction Function(double)>(); + _lookup Function(ffi.Float)>>('new_box_autoadd_f32_0'); + late final _new_box_autoadd_f32_0 = _new_box_autoadd_f32_0Ptr.asFunction Function(double)>(); + + ffi.Pointer new_box_autoadd_fee_rate_0() { + return _new_box_autoadd_fee_rate_0(); + } + + late final _new_box_autoadd_fee_rate_0Ptr = + _lookup Function()>>('new_box_autoadd_fee_rate_0'); + late final _new_box_autoadd_fee_rate_0 = + _new_box_autoadd_fee_rate_0Ptr.asFunction Function()>(); + + ffi.Pointer new_box_autoadd_rpc_config_0() { + return _new_box_autoadd_rpc_config_0(); + } + + late final _new_box_autoadd_rpc_config_0Ptr = + _lookup Function()>>('new_box_autoadd_rpc_config_0'); + late final _new_box_autoadd_rpc_config_0 = + _new_box_autoadd_rpc_config_0Ptr.asFunction Function()>(); + + ffi.Pointer new_box_autoadd_rpc_sync_params_0() { + return _new_box_autoadd_rpc_sync_params_0(); + } + + late final _new_box_autoadd_rpc_sync_params_0Ptr = + _lookup Function()>>('new_box_autoadd_rpc_sync_params_0'); + late final _new_box_autoadd_rpc_sync_params_0 = + _new_box_autoadd_rpc_sync_params_0Ptr.asFunction Function()>(); - ffi.Pointer - new_box_autoadd_sled_db_configuration_0() { + ffi.Pointer new_box_autoadd_sled_db_configuration_0() { return _new_box_autoadd_sled_db_configuration_0(); } - late final _new_box_autoadd_sled_db_configuration_0Ptr = _lookup< - ffi.NativeFunction Function()>>( - 'new_box_autoadd_sled_db_configuration_0'); + late final _new_box_autoadd_sled_db_configuration_0Ptr = + _lookup Function()>>( + 'new_box_autoadd_sled_db_configuration_0'); late final _new_box_autoadd_sled_db_configuration_0 = - _new_box_autoadd_sled_db_configuration_0Ptr - .asFunction Function()>(); + _new_box_autoadd_sled_db_configuration_0Ptr.asFunction Function()>(); - ffi.Pointer - new_box_autoadd_sqlite_db_configuration_0() { + ffi.Pointer new_box_autoadd_sqlite_db_configuration_0() { return _new_box_autoadd_sqlite_db_configuration_0(); } - late final _new_box_autoadd_sqlite_db_configuration_0Ptr = _lookup< - ffi.NativeFunction< - ffi.Pointer - Function()>>('new_box_autoadd_sqlite_db_configuration_0'); + late final _new_box_autoadd_sqlite_db_configuration_0Ptr = + _lookup Function()>>( + 'new_box_autoadd_sqlite_db_configuration_0'); late final _new_box_autoadd_sqlite_db_configuration_0 = - _new_box_autoadd_sqlite_db_configuration_0Ptr - .asFunction Function()>(); + _new_box_autoadd_sqlite_db_configuration_0Ptr.asFunction Function()>(); ffi.Pointer new_box_autoadd_u32_0( int value, @@ -2683,10 +2490,8 @@ class RustWire implements FlutterRustBridgeWireBase { } late final _new_box_autoadd_u32_0Ptr = - _lookup Function(ffi.Uint32)>>( - 'new_box_autoadd_u32_0'); - late final _new_box_autoadd_u32_0 = _new_box_autoadd_u32_0Ptr - .asFunction Function(int)>(); + _lookup Function(ffi.Uint32)>>('new_box_autoadd_u32_0'); + late final _new_box_autoadd_u32_0 = _new_box_autoadd_u32_0Ptr.asFunction Function(int)>(); ffi.Pointer new_box_autoadd_u64_0( int value, @@ -2697,10 +2502,8 @@ class RustWire implements FlutterRustBridgeWireBase { } late final _new_box_autoadd_u64_0Ptr = - _lookup Function(ffi.Uint64)>>( - 'new_box_autoadd_u64_0'); - late final _new_box_autoadd_u64_0 = _new_box_autoadd_u64_0Ptr - .asFunction Function(int)>(); + _lookup Function(ffi.Uint64)>>('new_box_autoadd_u64_0'); + late final _new_box_autoadd_u64_0 = _new_box_autoadd_u64_0Ptr.asFunction Function(int)>(); ffi.Pointer new_box_autoadd_u8_0( int value, @@ -2711,10 +2514,17 @@ class RustWire implements FlutterRustBridgeWireBase { } late final _new_box_autoadd_u8_0Ptr = - _lookup Function(ffi.Uint8)>>( - 'new_box_autoadd_u8_0'); - late final _new_box_autoadd_u8_0 = _new_box_autoadd_u8_0Ptr - .asFunction Function(int)>(); + _lookup Function(ffi.Uint8)>>('new_box_autoadd_u8_0'); + late final _new_box_autoadd_u8_0 = _new_box_autoadd_u8_0Ptr.asFunction Function(int)>(); + + ffi.Pointer new_box_autoadd_user_pass_0() { + return _new_box_autoadd_user_pass_0(); + } + + late final _new_box_autoadd_user_pass_0Ptr = + _lookup Function()>>('new_box_autoadd_user_pass_0'); + late final _new_box_autoadd_user_pass_0 = + _new_box_autoadd_user_pass_0Ptr.asFunction Function()>(); ffi.Pointer new_list_out_point_0( int len, @@ -2724,12 +2534,10 @@ class RustWire implements FlutterRustBridgeWireBase { ); } - late final _new_list_out_point_0Ptr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Int32)>>('new_list_out_point_0'); - late final _new_list_out_point_0 = _new_list_out_point_0Ptr - .asFunction Function(int)>(); + late final _new_list_out_point_0Ptr = + _lookup Function(ffi.Int32)>>('new_list_out_point_0'); + late final _new_list_out_point_0 = + _new_list_out_point_0Ptr.asFunction Function(int)>(); ffi.Pointer new_list_script_amount_0( int len, @@ -2739,12 +2547,10 @@ class RustWire implements FlutterRustBridgeWireBase { ); } - late final _new_list_script_amount_0Ptr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Int32)>>('new_list_script_amount_0'); - late final _new_list_script_amount_0 = _new_list_script_amount_0Ptr - .asFunction Function(int)>(); + late final _new_list_script_amount_0Ptr = + _lookup Function(ffi.Int32)>>('new_list_script_amount_0'); + late final _new_list_script_amount_0 = + _new_list_script_amount_0Ptr.asFunction Function(int)>(); ffi.Pointer new_uint_8_list_0( int len, @@ -2754,12 +2560,35 @@ class RustWire implements FlutterRustBridgeWireBase { ); } - late final _new_uint_8_list_0Ptr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Int32)>>('new_uint_8_list_0'); - late final _new_uint_8_list_0 = _new_uint_8_list_0Ptr - .asFunction Function(int)>(); + late final _new_uint_8_list_0Ptr = + _lookup Function(ffi.Int32)>>('new_uint_8_list_0'); + late final _new_uint_8_list_0 = _new_uint_8_list_0Ptr.asFunction Function(int)>(); + + void drop_opaque_BdkDescriptor( + ffi.Pointer ptr, + ) { + return _drop_opaque_BdkDescriptor( + ptr, + ); + } + + late final _drop_opaque_BdkDescriptorPtr = + _lookup)>>('drop_opaque_BdkDescriptor'); + late final _drop_opaque_BdkDescriptor = + _drop_opaque_BdkDescriptorPtr.asFunction)>(); + + ffi.Pointer share_opaque_BdkDescriptor( + ffi.Pointer ptr, + ) { + return _share_opaque_BdkDescriptor( + ptr, + ); + } + + late final _share_opaque_BdkDescriptorPtr = + _lookup Function(ffi.Pointer)>>('share_opaque_BdkDescriptor'); + late final _share_opaque_BdkDescriptor = + _share_opaque_BdkDescriptorPtr.asFunction Function(ffi.Pointer)>(); void drop_opaque_BlockchainInstance( ffi.Pointer ptr, @@ -2770,11 +2599,9 @@ class RustWire implements FlutterRustBridgeWireBase { } late final _drop_opaque_BlockchainInstancePtr = - _lookup)>>( - 'drop_opaque_BlockchainInstance'); + _lookup)>>('drop_opaque_BlockchainInstance'); late final _drop_opaque_BlockchainInstance = - _drop_opaque_BlockchainInstancePtr - .asFunction)>(); + _drop_opaque_BlockchainInstancePtr.asFunction)>(); ffi.Pointer share_opaque_BlockchainInstance( ffi.Pointer ptr, @@ -2784,13 +2611,11 @@ class RustWire implements FlutterRustBridgeWireBase { ); } - late final _share_opaque_BlockchainInstancePtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer)>>('share_opaque_BlockchainInstance'); + late final _share_opaque_BlockchainInstancePtr = + _lookup Function(ffi.Pointer)>>( + 'share_opaque_BlockchainInstance'); late final _share_opaque_BlockchainInstance = - _share_opaque_BlockchainInstancePtr - .asFunction Function(ffi.Pointer)>(); + _share_opaque_BlockchainInstancePtr.asFunction Function(ffi.Pointer)>(); void drop_opaque_WalletInstance( ffi.Pointer ptr, @@ -2801,10 +2626,9 @@ class RustWire implements FlutterRustBridgeWireBase { } late final _drop_opaque_WalletInstancePtr = - _lookup)>>( - 'drop_opaque_WalletInstance'); - late final _drop_opaque_WalletInstance = _drop_opaque_WalletInstancePtr - .asFunction)>(); + _lookup)>>('drop_opaque_WalletInstance'); + late final _drop_opaque_WalletInstance = + _drop_opaque_WalletInstancePtr.asFunction)>(); ffi.Pointer share_opaque_WalletInstance( ffi.Pointer ptr, @@ -2814,68 +2638,67 @@ class RustWire implements FlutterRustBridgeWireBase { ); } - late final _share_opaque_WalletInstancePtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer)>>('share_opaque_WalletInstance'); - late final _share_opaque_WalletInstance = _share_opaque_WalletInstancePtr - .asFunction Function(ffi.Pointer)>(); + late final _share_opaque_WalletInstancePtr = + _lookup Function(ffi.Pointer)>>('share_opaque_WalletInstance'); + late final _share_opaque_WalletInstance = + _share_opaque_WalletInstancePtr.asFunction Function(ffi.Pointer)>(); ffi.Pointer inflate_BlockchainConfig_Electrum() { return _inflate_BlockchainConfig_Electrum(); } late final _inflate_BlockchainConfig_ElectrumPtr = - _lookup Function()>>( - 'inflate_BlockchainConfig_Electrum'); + _lookup Function()>>('inflate_BlockchainConfig_Electrum'); late final _inflate_BlockchainConfig_Electrum = - _inflate_BlockchainConfig_ElectrumPtr - .asFunction Function()>(); + _inflate_BlockchainConfig_ElectrumPtr.asFunction Function()>(); ffi.Pointer inflate_BlockchainConfig_Esplora() { return _inflate_BlockchainConfig_Esplora(); } late final _inflate_BlockchainConfig_EsploraPtr = - _lookup Function()>>( - 'inflate_BlockchainConfig_Esplora'); + _lookup Function()>>('inflate_BlockchainConfig_Esplora'); late final _inflate_BlockchainConfig_Esplora = - _inflate_BlockchainConfig_EsploraPtr - .asFunction Function()>(); + _inflate_BlockchainConfig_EsploraPtr.asFunction Function()>(); + + ffi.Pointer inflate_BlockchainConfig_Rpc() { + return _inflate_BlockchainConfig_Rpc(); + } + + late final _inflate_BlockchainConfig_RpcPtr = + _lookup Function()>>('inflate_BlockchainConfig_Rpc'); + late final _inflate_BlockchainConfig_Rpc = + _inflate_BlockchainConfig_RpcPtr.asFunction Function()>(); ffi.Pointer inflate_DatabaseConfig_Sqlite() { return _inflate_DatabaseConfig_Sqlite(); } late final _inflate_DatabaseConfig_SqlitePtr = - _lookup Function()>>( - 'inflate_DatabaseConfig_Sqlite'); - late final _inflate_DatabaseConfig_Sqlite = _inflate_DatabaseConfig_SqlitePtr - .asFunction Function()>(); + _lookup Function()>>('inflate_DatabaseConfig_Sqlite'); + late final _inflate_DatabaseConfig_Sqlite = + _inflate_DatabaseConfig_SqlitePtr.asFunction Function()>(); ffi.Pointer inflate_DatabaseConfig_Sled() { return _inflate_DatabaseConfig_Sled(); } late final _inflate_DatabaseConfig_SledPtr = - _lookup Function()>>( - 'inflate_DatabaseConfig_Sled'); - late final _inflate_DatabaseConfig_Sled = _inflate_DatabaseConfig_SledPtr - .asFunction Function()>(); + _lookup Function()>>('inflate_DatabaseConfig_Sled'); + late final _inflate_DatabaseConfig_Sled = + _inflate_DatabaseConfig_SledPtr.asFunction Function()>(); - void free_WireSyncReturnStruct( - WireSyncReturnStruct val, + void free_WireSyncReturn( + WireSyncReturn ptr, ) { - return _free_WireSyncReturnStruct( - val, + return _free_WireSyncReturn( + ptr, ); } - late final _free_WireSyncReturnStructPtr = - _lookup>( - 'free_WireSyncReturnStruct'); - late final _free_WireSyncReturnStruct = _free_WireSyncReturnStructPtr - .asFunction(); + late final _free_WireSyncReturnPtr = + _lookup>('free_WireSyncReturn'); + late final _free_WireSyncReturn = _free_WireSyncReturnPtr.asFunction(); } class _Dart_Handle extends ffi.Opaque {} @@ -2899,6 +2722,9 @@ class wire_ElectrumConfig extends ffi.Struct { @ffi.Uint64() external int stop_gap; + + @ffi.Bool() + external bool validate_domain; } class wire_BlockchainConfig_Electrum extends ffi.Struct { @@ -2922,10 +2748,51 @@ class wire_BlockchainConfig_Esplora extends ffi.Struct { external ffi.Pointer config; } +class wire_UserPass extends ffi.Struct { + external ffi.Pointer username; + + external ffi.Pointer password; +} + +class wire_RpcSyncParams extends ffi.Struct { + @ffi.Uint64() + external int start_script_count; + + @ffi.Uint64() + external int start_time; + + @ffi.Bool() + external bool force_start_time; + + @ffi.Uint64() + external int poll_rate_sec; +} + +class wire_RpcConfig extends ffi.Struct { + external ffi.Pointer url; + + external ffi.Pointer auth_cookie; + + external ffi.Pointer auth_user_pass; + + @ffi.Int32() + external int network; + + external ffi.Pointer wallet_name; + + external ffi.Pointer sync_params; +} + +class wire_BlockchainConfig_Rpc extends ffi.Struct { + external ffi.Pointer config; +} + class BlockchainConfigKind extends ffi.Union { external ffi.Pointer Electrum; external ffi.Pointer Esplora; + + external ffi.Pointer Rpc; } class wire_BlockchainConfig extends ffi.Struct { @@ -2971,6 +2838,10 @@ class wire_list_out_point extends ffi.Struct { external int len; } +class wire_BdkDescriptor extends ffi.Struct { + external ffi.Pointer ptr; +} + class wire_DatabaseConfig_Memory extends ffi.Opaque {} class wire_SqliteDbConfiguration extends ffi.Struct { @@ -3006,7 +2877,10 @@ class wire_DatabaseConfig extends ffi.Struct { external ffi.Pointer kind; } -typedef DartPostCObjectFnType = ffi.Pointer< - ffi.NativeFunction)>>; +class wire_FeeRate extends ffi.Struct { + @ffi.Float() + external double field0; +} + +typedef DartPostCObjectFnType = ffi.Pointer)>>; typedef DartPort = ffi.Int64; -typedef uintptr_t = ffi.UnsignedLong; diff --git a/lib/src/generated/bridge_definitions.dart b/lib/src/generated/bridge_definitions.dart new file mode 100644 index 00000000..a2d16efd --- /dev/null +++ b/lib/src/generated/bridge_definitions.dart @@ -0,0 +1,694 @@ +// AUTO GENERATED FILE, DO NOT EDIT. +// Generated by `flutter_rust_bridge`@ 1.60.0. +// ignore_for_file: non_constant_identifier_names, unused_element, duplicate_ignore, directives_ordering, curly_braces_in_flow_control_structures, unnecessary_lambdas, slash_for_doc_comments, prefer_const_literals_to_create_immutables, implicit_dynamic_list_literal, duplicate_import, unused_import, prefer_single_quotes, prefer_const_constructors, use_super_parameters, always_use_package_imports, annotate_overrides, invalid_use_of_protected_member, constant_identifier_names, invalid_use_of_internal_member + +import 'dart:convert'; +import 'dart:async'; +import 'package:flutter_rust_bridge/flutter_rust_bridge.dart'; +import 'package:freezed_annotation/freezed_annotation.dart' hide protected; + +part 'bridge_definitions.freezed.dart'; + +abstract class Rust { + Future blockchainInit({required BlockchainConfig config, dynamic hint}); + + FlutterRustBridgeTaskConstMeta get kBlockchainInitConstMeta; + + Future getBlockchainHeight({required BlockchainInstance blockchain, dynamic hint}); + + FlutterRustBridgeTaskConstMeta get kGetBlockchainHeightConstMeta; + + Future getBlockchainHash( + {required int blockchainHeight, required BlockchainInstance blockchain, dynamic hint}); + + FlutterRustBridgeTaskConstMeta get kGetBlockchainHashConstMeta; + + Future broadcast({required String psbtStr, required BlockchainInstance blockchain, dynamic hint}); + + FlutterRustBridgeTaskConstMeta get kBroadcastConstMeta; + + Future psbtToTxid({required String psbtStr, dynamic hint}); + + FlutterRustBridgeTaskConstMeta get kPsbtToTxidConstMeta; + + Future extractTx({required String psbtStr, dynamic hint}); + + FlutterRustBridgeTaskConstMeta get kExtractTxConstMeta; + + Future getFeeRate({required String psbtStr, dynamic hint}); + + FlutterRustBridgeTaskConstMeta get kGetFeeRateConstMeta; + + Future getFeeAmount({required String psbtStr, dynamic hint}); + + FlutterRustBridgeTaskConstMeta get kGetFeeAmountConstMeta; + + Future combinePsbt({required String psbtStr, required String other, dynamic hint}); + + FlutterRustBridgeTaskConstMeta get kCombinePsbtConstMeta; + + Future txBuilderFinish( + {required WalletInstance wallet, + required List recipients, + required List utxos, + required List unspendable, + required bool manuallySelectedOnly, + required bool onlySpendChange, + required bool doNotSpendChange, + double? feeRate, + int? feeAbsolute, + required bool drainWallet, + String? drainTo, + required bool enableRbf, + int? nSequence, + required Uint8List data, + dynamic hint}); + + FlutterRustBridgeTaskConstMeta get kTxBuilderFinishConstMeta; + + Future bumpFeeTxBuilderFinish( + {required String txid, + required double feeRate, + String? allowShrinking, + required WalletInstance wallet, + required bool enableRbf, + int? nSequence, + dynamic hint}); + + FlutterRustBridgeTaskConstMeta get kBumpFeeTxBuilderFinishConstMeta; + + Future newDescriptor({required String descriptor, required Network network, dynamic hint}); + + FlutterRustBridgeTaskConstMeta get kNewDescriptorConstMeta; + + Future newBip44Descriptor( + {required KeychainKind keyChainKind, required String secretKey, required Network network, dynamic hint}); + + FlutterRustBridgeTaskConstMeta get kNewBip44DescriptorConstMeta; + + Future newBip44Public( + {required KeychainKind keyChainKind, + required String publicKey, + required Network network, + required String fingerprint, + dynamic hint}); + + FlutterRustBridgeTaskConstMeta get kNewBip44PublicConstMeta; + + Future newBip49Descriptor( + {required KeychainKind keyChainKind, required String secretKey, required Network network, dynamic hint}); + + FlutterRustBridgeTaskConstMeta get kNewBip49DescriptorConstMeta; + + Future newBip49Public( + {required KeychainKind keyChainKind, + required String publicKey, + required Network network, + required String fingerprint, + dynamic hint}); + + FlutterRustBridgeTaskConstMeta get kNewBip49PublicConstMeta; + + Future newBip84Descriptor( + {required KeychainKind keyChainKind, required String secretKey, required Network network, dynamic hint}); + + FlutterRustBridgeTaskConstMeta get kNewBip84DescriptorConstMeta; + + Future newBip84Public( + {required KeychainKind keyChainKind, + required String publicKey, + required Network network, + required String fingerprint, + dynamic hint}); + + FlutterRustBridgeTaskConstMeta get kNewBip84PublicConstMeta; + + Future asStringPrivate({required BdkDescriptor descriptor, dynamic hint}); + + FlutterRustBridgeTaskConstMeta get kAsStringPrivateConstMeta; + + Future asString({required BdkDescriptor descriptor, dynamic hint}); + + FlutterRustBridgeTaskConstMeta get kAsStringConstMeta; + + Future descriptorSecretExtend({required String xprv, required String path, dynamic hint}); + + FlutterRustBridgeTaskConstMeta get kDescriptorSecretExtendConstMeta; + + Future descriptorSecretDerive({required String xprv, required String path, dynamic hint}); + + FlutterRustBridgeTaskConstMeta get kDescriptorSecretDeriveConstMeta; + + Future descriptorSecretAsSecretBytes({String? descriptorSecret, String? xprv, dynamic hint}); + + FlutterRustBridgeTaskConstMeta get kDescriptorSecretAsSecretBytesConstMeta; + + Future descriptorSecretAsPublic({String? descriptorSecret, String? xprv, dynamic hint}); + + FlutterRustBridgeTaskConstMeta get kDescriptorSecretAsPublicConstMeta; + + Future createDescriptorSecret( + {required Network network, required String mnemonic, String? password, dynamic hint}); + + FlutterRustBridgeTaskConstMeta get kCreateDescriptorSecretConstMeta; + + Future createDerivationPath({required String path, dynamic hint}); + + FlutterRustBridgeTaskConstMeta get kCreateDerivationPathConstMeta; + + Future createDescriptorPublic({String? xpub, required String path, required bool derive, dynamic hint}); + + FlutterRustBridgeTaskConstMeta get kCreateDescriptorPublicConstMeta; + + Future initScript({required Uint8List rawOutputScript, dynamic hint}); + + FlutterRustBridgeTaskConstMeta get kInitScriptConstMeta; + + Future initAddress({required String address, dynamic hint}); + + FlutterRustBridgeTaskConstMeta get kInitAddressConstMeta; + + Future addressToScriptPubkeyHex({required String address, dynamic hint}); + + FlutterRustBridgeTaskConstMeta get kAddressToScriptPubkeyHexConstMeta; + + Future walletInit( + {required BdkDescriptor descriptor, + BdkDescriptor? changeDescriptor, + required Network network, + required DatabaseConfig databaseConfig, + dynamic hint}); + + FlutterRustBridgeTaskConstMeta get kWalletInitConstMeta; + + Future getAddress({required WalletInstance wallet, required AddressIndex addressIndex, dynamic hint}); + + FlutterRustBridgeTaskConstMeta get kGetAddressConstMeta; + + Future syncWallet({required WalletInstance wallet, required BlockchainInstance blockchain, dynamic hint}); + + FlutterRustBridgeTaskConstMeta get kSyncWalletConstMeta; + + Future getBalance({required WalletInstance wallet, dynamic hint}); + + FlutterRustBridgeTaskConstMeta get kGetBalanceConstMeta; + + Future> listUnspentOutputs({required WalletInstance wallet, dynamic hint}); + + FlutterRustBridgeTaskConstMeta get kListUnspentOutputsConstMeta; + + Future> getTransactions({required WalletInstance wallet, dynamic hint}); + + FlutterRustBridgeTaskConstMeta get kGetTransactionsConstMeta; + + Future sign( + {required WalletInstance wallet, required String psbtStr, required bool isMultiSig, dynamic hint}); + + FlutterRustBridgeTaskConstMeta get kSignConstMeta; + + Future getNetwork({required WalletInstance wallet, dynamic hint}); + + FlutterRustBridgeTaskConstMeta get kGetNetworkConstMeta; + + Future> listUnspent({required WalletInstance wallet, dynamic hint}); + + FlutterRustBridgeTaskConstMeta get kListUnspentConstMeta; + + Future generateSeedFromWordCount({required WordCount wordCount, dynamic hint}); + + FlutterRustBridgeTaskConstMeta get kGenerateSeedFromWordCountConstMeta; + + Future generateSeedFromString({required String mnemonic, dynamic hint}); + + FlutterRustBridgeTaskConstMeta get kGenerateSeedFromStringConstMeta; + + Future generateSeedFromEntropy({required Uint8List entropy, dynamic hint}); + + FlutterRustBridgeTaskConstMeta get kGenerateSeedFromEntropyConstMeta; + + Future asSatPerVbMethodFeeRate({required FeeRate that, dynamic hint}); + + FlutterRustBridgeTaskConstMeta get kAsSatPerVbMethodFeeRateConstMeta; + + DropFnType get dropOpaqueBdkDescriptor; + ShareFnType get shareOpaqueBdkDescriptor; + OpaqueTypeFinalizer get BdkDescriptorFinalizer; + + DropFnType get dropOpaqueBlockchainInstance; + ShareFnType get shareOpaqueBlockchainInstance; + OpaqueTypeFinalizer get BlockchainInstanceFinalizer; + + DropFnType get dropOpaqueWalletInstance; + ShareFnType get shareOpaqueWalletInstance; + OpaqueTypeFinalizer get WalletInstanceFinalizer; +} + +@sealed +class BdkDescriptor extends FrbOpaque { + final Rust bridge; + BdkDescriptor.fromRaw(int ptr, int size, this.bridge) : super.unsafe(ptr, size); + @override + DropFnType get dropFn => bridge.dropOpaqueBdkDescriptor; + + @override + ShareFnType get shareFn => bridge.shareOpaqueBdkDescriptor; + + @override + OpaqueTypeFinalizer get staticFinalizer => bridge.BdkDescriptorFinalizer; +} + +@sealed +class BlockchainInstance extends FrbOpaque { + final Rust bridge; + BlockchainInstance.fromRaw(int ptr, int size, this.bridge) : super.unsafe(ptr, size); + @override + DropFnType get dropFn => bridge.dropOpaqueBlockchainInstance; + + @override + ShareFnType get shareFn => bridge.shareOpaqueBlockchainInstance; + + @override + OpaqueTypeFinalizer get staticFinalizer => bridge.BlockchainInstanceFinalizer; +} + +@sealed +class WalletInstance extends FrbOpaque { + final Rust bridge; + WalletInstance.fromRaw(int ptr, int size, this.bridge) : super.unsafe(ptr, size); + @override + DropFnType get dropFn => bridge.dropOpaqueWalletInstance; + + @override + ShareFnType get shareFn => bridge.shareOpaqueWalletInstance; + + @override + OpaqueTypeFinalizer get staticFinalizer => bridge.WalletInstanceFinalizer; +} + +/// The address index selection strategy to use to derived an address from the wallet's external +/// descriptor. +enum AddressIndex { + ///Return a new address after incrementing the current descriptor index. + New, + + ///Return the address for the current descriptor index if it has not been used in a received transaction. Otherwise return a new address as with AddressIndex.New. + ///Use with caution, if the wallet has not yet detected an address has been used it could return an already used address. This function is primarily meant for situations where the caller is untrusted; for example when deriving donation addresses on-demand for a public web page. + LastUnused, +} + +///A derived address and the index it was found at For convenience this automatically derefs to Address +class AddressInfo { + ///Child index of this address + final int index; + + /// Address + final String address; + + AddressInfo({ + required this.index, + required this.address, + }); +} + +/// Local Wallet's Balance +class Balance { + final int immature; + + /// Unconfirmed UTXOs generated by a wallet tx + final int trustedPending; + + /// Unconfirmed UTXOs received from an external wallet + final int untrustedPending; + + /// Confirmed and immediately spendable balance + final int confirmed; + + /// Get sum of trusted_pending and confirmed coins + final int spendable; + + /// Get the whole balance visible to the wallet + final int total; + + Balance({ + required this.immature, + required this.trustedPending, + required this.untrustedPending, + required this.confirmed, + required this.spendable, + required this.total, + }); +} + +///Block height and timestamp of a block +class BlockTime { + ///Confirmation block height + final int height; + + ///Confirmation block timestamp + final int timestamp; + + BlockTime({ + required this.height, + required this.timestamp, + }); +} + +@freezed +class BlockchainConfig with _$BlockchainConfig { + /// Electrum client + const factory BlockchainConfig.electrum({ + required ElectrumConfig config, + }) = BlockchainConfig_Electrum; + + /// Esplora client + const factory BlockchainConfig.esplora({ + required EsploraConfig config, + }) = BlockchainConfig_Esplora; + + /// Bitcoin Core RPC client + const factory BlockchainConfig.rpc({ + required RpcConfig config, + }) = BlockchainConfig_Rpc; +} + +@freezed +class DatabaseConfig with _$DatabaseConfig { + const factory DatabaseConfig.memory() = DatabaseConfig_Memory; + + ///Simple key-value embedded database based on sled + const factory DatabaseConfig.sqlite({ + required SqliteDbConfiguration config, + }) = DatabaseConfig_Sqlite; + + ///Sqlite embedded database using rusqlite + const factory DatabaseConfig.sled({ + required SledDbConfiguration config, + }) = DatabaseConfig_Sled; +} + +/// Configuration for an ElectrumBlockchain +class ElectrumConfig { + ///URL of the Electrum server (such as ElectrumX, Esplora, BWT) may start with ssl:// or tcp:// and include a port + ///eg. ssl://electrum.blockstream.info:60002 + final String url; + + ///URL of the socks5 proxy server or a Tor service + final String? socks5; + + ///Request retry count + final int retry; + + ///Request timeout (seconds) + final int? timeout; + + ///Stop searching addresses for transactions after finding an unused gap of this length + final int stopGap; + + /// Validate the domain when using SSL + final bool validateDomain; + + ElectrumConfig({ + required this.url, + this.socks5, + required this.retry, + this.timeout, + required this.stopGap, + required this.validateDomain, + }); +} + +///Configuration for an EsploraBlockchain +class EsploraConfig { + ///Base URL of the esplora service + ///eg. https://blockstream.info/api/ + final String baseUrl; + + /// Optional URL of the proxy to use to make requests to the Esplora server + /// The string should be formatted as: ://:@host:. + /// Note that the format of this value and the supported protocols change slightly between the sync version of esplora (using ureq) and the async version (using reqwest). + /// For more details check with the documentation of the two crates. Both of them are compiled with the socks feature enabled. + /// The proxy is ignored when targeting wasm32. + final String? proxy; + + ///Number of parallel requests sent to the esplora service (default: 4) + final int? concurrency; + + ///Stop searching addresses for transactions after finding an unused gap of this length. + final int stopGap; + + ///Socket timeout. + final int? timeout; + + EsploraConfig({ + required this.baseUrl, + this.proxy, + this.concurrency, + required this.stopGap, + this.timeout, + }); +} + +class FeeRate { + final Rust bridge; + final double field0; + + FeeRate({ + required this.bridge, + required this.field0, + }); + + Future asSatPerVb({dynamic hint}) => bridge.asSatPerVbMethodFeeRate( + that: this, + ); +} + +///Types of keychains +enum KeychainKind { + External, + + ///Internal, usually used for change outputs + Internal, +} + +/// Unspent outputs of this wallet +class LocalUtxo { + /// Reference to a transaction output + final OutPoint outpoint; + + ///Transaction output + final TxOut txout; + + ///Whether this UTXO is spent or not + final bool isSpent; + + LocalUtxo({ + required this.outpoint, + required this.txout, + required this.isSpent, + }); +} + +///The cryptocurrency to act on +enum Network { + ///Bitcoin’s testnet + Testnet, + + ///Bitcoin’s regtest + Regtest, + + ///Classic Bitcoin + Bitcoin, + + ///Bitcoin’s signet + Signet, +} + +/// A reference to a transaction output. +class OutPoint { + /// The referenced transaction's txid. + final String txid; + + /// The index of the referenced output in its transaction's vout. + final int vout; + + OutPoint({ + required this.txid, + required this.vout, + }); +} + +class RpcConfig { + /// The bitcoin node url + final String url; + + /// The bitcoin node authentication mechanism + final String? authCookie; + final UserPass? authUserPass; + + /// The network we are using (it will be checked the bitcoin node network matches this) + final Network network; + + /// The wallet name in the bitcoin node + final String walletName; + + /// Sync parameters + final RpcSyncParams? syncParams; + + RpcConfig({ + required this.url, + this.authCookie, + this.authUserPass, + required this.network, + required this.walletName, + this.syncParams, + }); +} + +/// Sync parameters for Bitcoin Core RPC. +/// +/// In general, BDK tries to sync `scriptPubKey`s cached in `Database` with +/// `scriptPubKey`s imported in the Bitcoin Core Wallet. These parameters are used for determining +/// how the `importdescriptors` RPC calls are to be made. +/// +class RpcSyncParams { + /// The minimum number of scripts to scan for on initial sync. + final int startScriptCount; + + /// Time in unix seconds in which initial sync will start scanning from (0 to start from genesis). + final int startTime; + + /// Forces every sync to use `start_time` as import timestamp. + final bool forceStartTime; + + /// RPC poll rate (in seconds) to get state updates. + final int pollRateSec; + + RpcSyncParams({ + required this.startScriptCount, + required this.startTime, + required this.forceStartTime, + required this.pollRateSec, + }); +} + +/// A output script and an amount of satoshis. +class ScriptAmount { + final String script; + final int amount; + + ScriptAmount({ + required this.script, + required this.amount, + }); +} + +///Configuration type for a sled Tree database +class SledDbConfiguration { + ///Main directory of the db + final String path; + + ///Name of the database tree, a separated namespace for the data + final String treeName; + + SledDbConfiguration({ + required this.path, + required this.treeName, + }); +} + +///Configuration type for a SqliteDatabase database +class SqliteDbConfiguration { + ///Main directory of the db + final String path; + + SqliteDbConfiguration({ + required this.path, + }); +} + +///A wallet transaction +class TransactionDetails { + /// Transaction id. + final String txid; + + /// Received value (sats) + /// Sum of owned outputs of this transaction. + final int received; + + /// Sent value (sats) + /// Sum of owned inputs of this transaction. + final int sent; + + /// Fee value (sats) if confirmed. + /// The availability of the fee depends on the backend. It's never None with an Electrum + /// Server backend, but it could be None with a Bitcoin RPC node without txindex that receive + /// funds while offline. + final int? fee; + + /// If the transaction is confirmed, contains height and timestamp of the block containing the + /// transaction, unconfirmed transaction contains `None`. + final BlockTime? confirmationTime; + + TransactionDetails({ + required this.txid, + required this.received, + required this.sent, + this.fee, + this.confirmationTime, + }); +} + +/// The result after calling the TxBuilder finish() function. Contains unsigned PSBT and +/// transaction details. +class TxBuilderResult { + final String psbt; + + ///A wallet transaction + final TransactionDetails transactionDetails; + + TxBuilderResult({ + required this.psbt, + required this.transactionDetails, + }); +} + +///A transaction output, which defines new coins to be created from old ones. +class TxOut { + /// The value of the output, in satoshis. + final int value; + + /// The address of the output. + final String address; + + TxOut({ + required this.value, + required this.address, + }); +} + +/// RpcBlockchain configuration options +/// +class UserPass { + /// Username + final String username; + + /// Password + final String password; + + UserPass({ + required this.username, + required this.password, + }); +} + +///Type describing entropy length (aka word count) in the mnemonic +enum WordCount { + ///12 words mnemonic (128 bits entropy) + Words12, + + ///18 words mnemonic (192 bits entropy) + Words18, + + ///24 words mnemonic (256 bits entropy) + Words24, +} diff --git a/lib/src/generated/bindings.freezed.dart b/lib/src/generated/bridge_definitions.freezed.dart similarity index 82% rename from lib/src/generated/bindings.freezed.dart rename to lib/src/generated/bridge_definitions.freezed.dart index accf3fda..ab6e669b 100644 --- a/lib/src/generated/bindings.freezed.dart +++ b/lib/src/generated/bridge_definitions.freezed.dart @@ -3,7 +3,7 @@ // ignore_for_file: type=lint // ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark -part of 'bindings.dart'; +part of 'bridge_definitions.dart'; // ************************************************************************** // FreezedGenerator @@ -21,18 +21,21 @@ mixin _$BlockchainConfig { TResult when({ required TResult Function(ElectrumConfig config) electrum, required TResult Function(EsploraConfig config) esplora, + required TResult Function(RpcConfig config) rpc, }) => throw _privateConstructorUsedError; @optionalTypeArgs TResult? whenOrNull({ TResult? Function(ElectrumConfig config)? electrum, TResult? Function(EsploraConfig config)? esplora, + TResult? Function(RpcConfig config)? rpc, }) => throw _privateConstructorUsedError; @optionalTypeArgs TResult maybeWhen({ TResult Function(ElectrumConfig config)? electrum, TResult Function(EsploraConfig config)? esplora, + TResult Function(RpcConfig config)? rpc, required TResult orElse(), }) => throw _privateConstructorUsedError; @@ -40,18 +43,21 @@ mixin _$BlockchainConfig { TResult map({ required TResult Function(BlockchainConfig_Electrum value) electrum, required TResult Function(BlockchainConfig_Esplora value) esplora, + required TResult Function(BlockchainConfig_Rpc value) rpc, }) => throw _privateConstructorUsedError; @optionalTypeArgs TResult? mapOrNull({ TResult? Function(BlockchainConfig_Electrum value)? electrum, TResult? Function(BlockchainConfig_Esplora value)? esplora, + TResult? Function(BlockchainConfig_Rpc value)? rpc, }) => throw _privateConstructorUsedError; @optionalTypeArgs TResult maybeMap({ TResult Function(BlockchainConfig_Electrum value)? electrum, TResult Function(BlockchainConfig_Esplora value)? esplora, + TResult Function(BlockchainConfig_Rpc value)? rpc, required TResult orElse(), }) => throw _privateConstructorUsedError; @@ -143,6 +149,7 @@ class _$BlockchainConfig_Electrum implements BlockchainConfig_Electrum { TResult when({ required TResult Function(ElectrumConfig config) electrum, required TResult Function(EsploraConfig config) esplora, + required TResult Function(RpcConfig config) rpc, }) { return electrum(config); } @@ -152,6 +159,7 @@ class _$BlockchainConfig_Electrum implements BlockchainConfig_Electrum { TResult? whenOrNull({ TResult? Function(ElectrumConfig config)? electrum, TResult? Function(EsploraConfig config)? esplora, + TResult? Function(RpcConfig config)? rpc, }) { return electrum?.call(config); } @@ -161,6 +169,7 @@ class _$BlockchainConfig_Electrum implements BlockchainConfig_Electrum { TResult maybeWhen({ TResult Function(ElectrumConfig config)? electrum, TResult Function(EsploraConfig config)? esplora, + TResult Function(RpcConfig config)? rpc, required TResult orElse(), }) { if (electrum != null) { @@ -174,6 +183,7 @@ class _$BlockchainConfig_Electrum implements BlockchainConfig_Electrum { TResult map({ required TResult Function(BlockchainConfig_Electrum value) electrum, required TResult Function(BlockchainConfig_Esplora value) esplora, + required TResult Function(BlockchainConfig_Rpc value) rpc, }) { return electrum(this); } @@ -183,6 +193,7 @@ class _$BlockchainConfig_Electrum implements BlockchainConfig_Electrum { TResult? mapOrNull({ TResult? Function(BlockchainConfig_Electrum value)? electrum, TResult? Function(BlockchainConfig_Esplora value)? esplora, + TResult? Function(BlockchainConfig_Rpc value)? rpc, }) { return electrum?.call(this); } @@ -192,6 +203,7 @@ class _$BlockchainConfig_Electrum implements BlockchainConfig_Electrum { TResult maybeMap({ TResult Function(BlockchainConfig_Electrum value)? electrum, TResult Function(BlockchainConfig_Esplora value)? esplora, + TResult Function(BlockchainConfig_Rpc value)? rpc, required TResult orElse(), }) { if (electrum != null) { @@ -280,6 +292,7 @@ class _$BlockchainConfig_Esplora implements BlockchainConfig_Esplora { TResult when({ required TResult Function(ElectrumConfig config) electrum, required TResult Function(EsploraConfig config) esplora, + required TResult Function(RpcConfig config) rpc, }) { return esplora(config); } @@ -289,6 +302,7 @@ class _$BlockchainConfig_Esplora implements BlockchainConfig_Esplora { TResult? whenOrNull({ TResult? Function(ElectrumConfig config)? electrum, TResult? Function(EsploraConfig config)? esplora, + TResult? Function(RpcConfig config)? rpc, }) { return esplora?.call(config); } @@ -298,6 +312,7 @@ class _$BlockchainConfig_Esplora implements BlockchainConfig_Esplora { TResult maybeWhen({ TResult Function(ElectrumConfig config)? electrum, TResult Function(EsploraConfig config)? esplora, + TResult Function(RpcConfig config)? rpc, required TResult orElse(), }) { if (esplora != null) { @@ -311,6 +326,7 @@ class _$BlockchainConfig_Esplora implements BlockchainConfig_Esplora { TResult map({ required TResult Function(BlockchainConfig_Electrum value) electrum, required TResult Function(BlockchainConfig_Esplora value) esplora, + required TResult Function(BlockchainConfig_Rpc value) rpc, }) { return esplora(this); } @@ -320,6 +336,7 @@ class _$BlockchainConfig_Esplora implements BlockchainConfig_Esplora { TResult? mapOrNull({ TResult? Function(BlockchainConfig_Electrum value)? electrum, TResult? Function(BlockchainConfig_Esplora value)? esplora, + TResult? Function(BlockchainConfig_Rpc value)? rpc, }) { return esplora?.call(this); } @@ -329,6 +346,7 @@ class _$BlockchainConfig_Esplora implements BlockchainConfig_Esplora { TResult maybeMap({ TResult Function(BlockchainConfig_Electrum value)? electrum, TResult Function(BlockchainConfig_Esplora value)? esplora, + TResult Function(BlockchainConfig_Rpc value)? rpc, required TResult orElse(), }) { if (esplora != null) { @@ -349,6 +367,148 @@ abstract class BlockchainConfig_Esplora implements BlockchainConfig { get copyWith => throw _privateConstructorUsedError; } +/// @nodoc +abstract class _$$BlockchainConfig_RpcCopyWith<$Res> { + factory _$$BlockchainConfig_RpcCopyWith(_$BlockchainConfig_Rpc value, + $Res Function(_$BlockchainConfig_Rpc) then) = + __$$BlockchainConfig_RpcCopyWithImpl<$Res>; + @useResult + $Res call({RpcConfig config}); +} + +/// @nodoc +class __$$BlockchainConfig_RpcCopyWithImpl<$Res> + extends _$BlockchainConfigCopyWithImpl<$Res, _$BlockchainConfig_Rpc> + implements _$$BlockchainConfig_RpcCopyWith<$Res> { + __$$BlockchainConfig_RpcCopyWithImpl(_$BlockchainConfig_Rpc _value, + $Res Function(_$BlockchainConfig_Rpc) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? config = null, + }) { + return _then(_$BlockchainConfig_Rpc( + config: null == config + ? _value.config + : config // ignore: cast_nullable_to_non_nullable + as RpcConfig, + )); + } +} + +/// @nodoc + +class _$BlockchainConfig_Rpc implements BlockchainConfig_Rpc { + const _$BlockchainConfig_Rpc({required this.config}); + + @override + final RpcConfig config; + + @override + String toString() { + return 'BlockchainConfig.rpc(config: $config)'; + } + + @override + bool operator ==(dynamic other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$BlockchainConfig_Rpc && + (identical(other.config, config) || other.config == config)); + } + + @override + int get hashCode => Object.hash(runtimeType, config); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$BlockchainConfig_RpcCopyWith<_$BlockchainConfig_Rpc> get copyWith => + __$$BlockchainConfig_RpcCopyWithImpl<_$BlockchainConfig_Rpc>( + this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(ElectrumConfig config) electrum, + required TResult Function(EsploraConfig config) esplora, + required TResult Function(RpcConfig config) rpc, + }) { + return rpc(config); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(ElectrumConfig config)? electrum, + TResult? Function(EsploraConfig config)? esplora, + TResult? Function(RpcConfig config)? rpc, + }) { + return rpc?.call(config); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(ElectrumConfig config)? electrum, + TResult Function(EsploraConfig config)? esplora, + TResult Function(RpcConfig config)? rpc, + required TResult orElse(), + }) { + if (rpc != null) { + return rpc(config); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(BlockchainConfig_Electrum value) electrum, + required TResult Function(BlockchainConfig_Esplora value) esplora, + required TResult Function(BlockchainConfig_Rpc value) rpc, + }) { + return rpc(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(BlockchainConfig_Electrum value)? electrum, + TResult? Function(BlockchainConfig_Esplora value)? esplora, + TResult? Function(BlockchainConfig_Rpc value)? rpc, + }) { + return rpc?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(BlockchainConfig_Electrum value)? electrum, + TResult Function(BlockchainConfig_Esplora value)? esplora, + TResult Function(BlockchainConfig_Rpc value)? rpc, + required TResult orElse(), + }) { + if (rpc != null) { + return rpc(this); + } + return orElse(); + } +} + +abstract class BlockchainConfig_Rpc implements BlockchainConfig { + const factory BlockchainConfig_Rpc({required final RpcConfig config}) = + _$BlockchainConfig_Rpc; + + @override + RpcConfig get config; + @JsonKey(ignore: true) + _$$BlockchainConfig_RpcCopyWith<_$BlockchainConfig_Rpc> get copyWith => + throw _privateConstructorUsedError; +} + /// @nodoc mixin _$DatabaseConfig { @optionalTypeArgs diff --git a/lib/src/root.dart b/lib/src/root.dart index 7af1ef7e..6e3b55e8 100644 --- a/lib/src/root.dart +++ b/lib/src/root.dart @@ -1,30 +1,28 @@ import 'dart:typed_data' as typed_data; -import 'package:bdk_flutter/src/utils/exceptions/blockchain_exception.dart'; -import 'package:bdk_flutter/src/utils/exceptions/key_exception.dart'; -import 'package:bdk_flutter/src/utils/exceptions/path_exception.dart'; -import 'package:bdk_flutter/src/utils/exceptions/tx_builder_exception.dart'; -import 'package:bdk_flutter/src/utils/exceptions/wallet_exception.dart'; +import 'package:bdk_flutter/src/utils/exceptions/bdk_exception.dart'; +import 'package:bdk_flutter/src/utils/exceptions/config.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter_rust_bridge/flutter_rust_bridge.dart'; -import 'generated/bindings.dart'; +import 'generated/bridge_definitions.dart'; import 'utils/utils.dart'; /// Blockchain backends module provides the implementation of a few commonly-used backends like Electrum, and Esplora. class Blockchain { BlockchainInstance? _blockchain; Blockchain._(); + Blockchain _setBlockchain(BlockchainInstance blockchain) { + _blockchain = blockchain; + return this; + } /// [Blockchain] constructor static Future create({required BlockchainConfig config}) async { - final blockChain = Blockchain._(); - final res = await blockChain._create(config: config); - return res; - } - - Future _create({required BlockchainConfig config}) async { - final res = await loaderApi.blockchainInit(config: config); - _blockchain = res; - return this; + try{ + final res = await loaderApi.blockchainInit(config: config); + return Blockchain._()._setBlockchain(res); + } on FfiException catch (e){ + throw configException(e.message); + } } /// The function for getting block hash by block height @@ -34,7 +32,7 @@ class Blockchain { blockchainHeight: height, blockchain: _blockchain!); return res; } on FfiException catch (e) { - throw BlockchainException.unexpected(e.message); + throw configException(e.message); } } @@ -44,7 +42,7 @@ class Blockchain { var res = await loaderApi.getBlockchainHeight(blockchain: _blockchain!); return res; } on FfiException catch (e) { - throw BlockchainException.unexpected(e.message); + throw configException(e.message); } } @@ -57,7 +55,154 @@ class Blockchain { print(txid); } } on FfiException catch (e) { - throw BlockchainException.unexpected(e.message); + throw configException(e.message); + } + } +} + +///Script descriptor +class Descriptor { + BdkDescriptor? _descriptorInstance; + Descriptor._(); + Descriptor _setDescriptor(BdkDescriptor? descriptorInstance) { + _descriptorInstance = descriptorInstance; + return this; + } + + /// [Descriptor] constructor + static Future create( + {required String descriptor, required Network network}) async { + try{ final res = await loaderApi.newDescriptor(descriptor: descriptor, network: network); + return Descriptor._()._setDescriptor(res); + } on FfiException catch (e) { + throw configException(e.message); + } + } + + ///BIP44 template. Expands to pkh(key/44'/{0,1}'/0'/{0,1}/*) + /// + /// Since there are hardened derivation steps, this template requires a private derivable key (generally a xprv/tprv). + static Future newBip44( + {required DescriptorSecretKey descriptorSecretKey, + required Network network, + required KeychainKind keyChainKind}) async { + try{ final res = await loaderApi.newBip44Descriptor( + secretKey: descriptorSecretKey.asString(), + network: network, + keyChainKind: keyChainKind); + return Descriptor._()._setDescriptor(res); + } on FfiException catch (e) { + throw configException(e.message); + } + } + + ///BIP44 public template. Expands to pkh(key/{0,1}/*) + /// + /// This assumes that the key used has already been derived with m/44'/0'/0' for Mainnet or m/44'/1'/0' for Testnet. + /// + /// This template requires the parent fingerprint to populate correctly the metadata of PSBTs. + static Future newBip44Public( + {required String publicKey, + String? fingerPrint, + required Network network, + required KeychainKind keyChainKind}) async { + try{ final res = await loaderApi.newBip44Public( + keyChainKind: keyChainKind, + publicKey: publicKey, + network: network, + fingerprint: fingerPrint?? '00000000'); + return Descriptor._()._setDescriptor(res); + } on FfiException catch (e) { + throw configException(e.message); + } + } + + ///BIP49 template. Expands to sh(wpkh(key/49'/{0,1}'/0'/{0,1}/*)) + /// + ///Since there are hardened derivation steps, this template requires a private derivable key (generally a xprv/tprv). + static Future newBip49( + {required String secretKey, + required Network network, + required KeychainKind keyChainKind}) async { + try{ final res = await loaderApi.newBip49Descriptor( + secretKey: secretKey, network: network, keyChainKind: keyChainKind); + return Descriptor._()._setDescriptor(res); + } on FfiException catch (e) { + throw configException(e.message); + } + } + + ///BIP49 public template. Expands to sh(wpkh(key/{0,1}/*)) + /// + /// This assumes that the key used has already been derived with m/49'/0'/0'. + /// + /// This template requires the parent fingerprint to populate correctly the metadata of PSBTs. + static Future newBip49Public( + {required String publicKey, + String? fingerPrint, + required Network network, + required KeychainKind keyChainKind}) async { + try{ final res = await loaderApi.newBip49Public( + keyChainKind: keyChainKind, + publicKey: publicKey, + network: network, + fingerprint: fingerPrint?? '00000000'); + return Descriptor._()._setDescriptor(res); + } on FfiException catch (e) { + throw configException(e.message); + } + } + + ///BIP84 template. Expands to wpkh(key/84'/{0,1}'/0'/{0,1}/*) + /// + ///Since there are hardened derivation steps, this template requires a private derivable key (generally a xprv/tprv). + static Future newBip84( + {required String secretKey, + required Network network, + required KeychainKind keyChainKind}) async { + try{ final res = await loaderApi.newBip84Descriptor( + secretKey: secretKey, network: network, keyChainKind: keyChainKind); + return Descriptor._()._setDescriptor(res); + } on FfiException catch (e) { + throw configException(e.message); + } + } + + ///BIP84 public template. Expands to wpkh(key/{0,1}/*) + /// + /// This assumes that the key used has already been derived with m/84'/0'/0'. + /// + /// This template requires the parent fingerprint to populate correctly the metadata of PSBTs. + static Future newBip84Public( + {required String publicKey, + String? fingerPrint, + required Network network, + required KeychainKind keyChainKind}) async { + try{ final res = await loaderApi.newBip84Public( + keyChainKind: keyChainKind, + publicKey: publicKey, + network: network, + fingerprint: fingerPrint?? '00000000'); + return Descriptor._()._setDescriptor(res); + } on FfiException catch (e) { + throw configException(e.message); + } + } + + Future asPrivateString() async { + try{ final res = + await loaderApi.asStringPrivate(descriptor: _descriptorInstance!); + return res; + } on FfiException catch (e) { + throw configException(e.message); + } + } + + Future asString() async { + try{ final res = await loaderApi.asString(descriptor: _descriptorInstance!); + return res; + } on FfiException catch (e) { + throw configException(e.message); } } } @@ -71,45 +216,35 @@ class Blockchain { /// 2. A Database where it tracks transactions and utxos related to the descriptors. /// /// 3. Signers that can contribute signatures to addresses instantiated from the descriptors. +/// class Wallet { WalletInstance? _wallet; Wallet._(); + Wallet _setWallet(WalletInstance? walletInstance) { + _wallet = walletInstance; + return this; + } /// [Wallet] constructor static Future create({ - required String descriptor, - String? changeDescriptor, + required Descriptor descriptor, + Descriptor? changeDescriptor, required Network network, required DatabaseConfig databaseConfig, }) async { try { - var wallet = Wallet._(); - final res = await wallet._create( - descriptor: descriptor, - changeDescriptor: changeDescriptor, - network: network, - databaseConfig: databaseConfig); - return res; + final res = await loaderApi.walletInit( + descriptor: descriptor._descriptorInstance!, + changeDescriptor: changeDescriptor?._descriptorInstance, + network: network, + databaseConfig: databaseConfig, + ); + return Wallet._()._setWallet(res); } on FfiException catch (e) { - throw WalletException.unexpected(e.message); + throw configException(e.message); } } - Future _create( - {required String descriptor, - String? changeDescriptor, - required Network network, - required DatabaseConfig databaseConfig}) async { - final res = await loaderApi.walletInit( - descriptor: descriptor, - changeDescriptor: changeDescriptor, - network: network, - databaseConfig: databaseConfig, - ); - _wallet = res; - return this; - } - ///Return a derived address using the external descriptor, see [AddressIndex] for available address index selection strategies. /// If none of the keys in the descriptor are derivable (i.e. does not end with /*) then the same address will always be returned for any AddressIndex. Future getAddress({required AddressIndex addressIndex}) async { @@ -118,7 +253,7 @@ class Wallet { wallet: _wallet!, addressIndex: addressIndex); return res; } on FfiException catch (e) { - throw WalletException.unexpected(e.message); + throw configException(e.message); } } @@ -130,7 +265,7 @@ class Wallet { var res = await loaderApi.getBalance(wallet: _wallet!); return res; } on FfiException catch (e) { - throw WalletException.unexpected(e.message); + throw configException(e.message); } } @@ -140,7 +275,7 @@ class Wallet { var res = await loaderApi.getNetwork(wallet: _wallet!); return res; } on FfiException catch (e) { - throw WalletException.unexpected(e.message); + throw configException(e.message); } } @@ -152,7 +287,7 @@ class Wallet { var res = await loaderApi.listUnspentOutputs(wallet: _wallet!); return res; } on FfiException catch (e) { - throw WalletException.unexpected(e.message); + throw configException(e.message); } } @@ -168,7 +303,7 @@ class Wallet { print("Sync complete"); } } on FfiException catch (e) { - throw WalletException.unexpected(e.message); + throw configException(e.message); } } @@ -178,7 +313,7 @@ class Wallet { final res = await loaderApi.getTransactions(wallet: _wallet!); return res; } on FfiException catch (e) { - throw WalletException.unexpected(e.message); + throw configException(e.message); } } @@ -191,11 +326,11 @@ class Wallet { final sbt = await loaderApi.sign( psbtStr: psbt.psbtBase64, wallet: _wallet!, isMultiSig: false); if (sbt == null) { - throw const TxBuilderException.unexpected("Unable to sign transaction"); + throw const BdkException.unExpected("Unable to sign transaction"); } return PartiallySignedTransaction(psbtBase64: sbt); } on FfiException catch (e) { - throw TxBuilderException.unexpected(e.message); + throw configException(e.message); } } } @@ -209,14 +344,22 @@ class PartiallySignedTransaction { /// Returns the [PartiallySignedTransaction] transaction id Future txId() async { - final res = await loaderApi.psbtToTxid(psbtStr: psbtBase64); + try { + final res = await loaderApi.psbtToTxid(psbtStr: psbtBase64); return res; + } on FfiException catch (e) { + throw configException(e.message); + } } /// Return the transaction as bytes. Future> extractTx() async { - final res = await loaderApi.extractTx(psbtStr: psbtBase64); + try{ + final res = await loaderApi.extractTx(psbtStr: psbtBase64); return res; + } on FfiException catch (e) { + throw configException(e.message); + } } /// Combines this [PartiallySignedTransaction] with other PSBT as described by BIP 174. @@ -224,18 +367,44 @@ class PartiallySignedTransaction { /// In accordance with BIP 174 this function is commutative i.e., `A.combine(B) == B.combine(A)` Future combine( PartiallySignedTransaction other) async { - final res = await loaderApi.combinePsbt( + try{ final res = await loaderApi.combinePsbt( psbtStr: psbtBase64, other: other.psbtBase64); return PartiallySignedTransaction(psbtBase64: res); + } on FfiException catch (e) { + throw configException(e.message); + } } /// Return txid as string Future serialize() async { - final res = await loaderApi.psbtToTxid(psbtStr: psbtBase64); + try{ final res = await loaderApi.psbtToTxid(psbtStr: psbtBase64); + return res; + } on FfiException catch (e) { + throw configException(e.message); + } + } + + /// Return Fee Rate + Future feeRate() async { + try{ final res = await loaderApi.getFeeRate(psbtStr: psbtBase64); + if (res == null) return null; + return res; + } on FfiException catch (e) { + throw configException(e.message); + } + } + + /// Return feeAmount + Future feeAmount() async { + try{ final res = await loaderApi.getFeeAmount(psbtStr: psbtBase64); return res; + } on FfiException catch (e) { + throw configException(e.message); + } } } + ///A transaction builder /// /// A TxBuilder is created by calling TxBuilder or BumpFeeTxBuilder on a wallet. @@ -258,7 +427,7 @@ class TxBuilder { ///Add data as an output, using OP_RETURN TxBuilder addData({required List data}) { if (data.isEmpty) { - throw const TxBuilderException.unexpected("List must not be empty"); + throw const BdkException.unExpected("List must not be empty"); } _data = typed_data.Uint8List.fromList(data); return this; @@ -398,7 +567,7 @@ class TxBuilder { /// Returns the BIP174 “PSBT”. Future finish(Wallet wallet) async { if (_recipients.isEmpty) { - throw const TxBuilderException.unexpected("No Recipients Added"); + throw const BdkException.unExpected("No Recipients Added"); } try { final res = await loaderApi.txBuilderFinish( @@ -419,12 +588,7 @@ class TxBuilder { final psbt = PartiallySignedTransaction(psbtBase64: res.psbt); return psbt; } on FfiException catch (e) { - if (e.message.contains("InsufficientFunds")) { - final msg = e.message.split("value:"); - throw TxBuilderException.insufficientBroadcastAmount(msg.last); - } else { - throw TxBuilderException.unexpected(e.message); - } + throw configException(e.message); } } } @@ -481,12 +645,7 @@ class BumpFeeTxBuilder { final psbt = PartiallySignedTransaction(psbtBase64: res); return psbt; } on FfiException catch (e) { - if (e.message.contains("Txid")) { - final msg = e.message.split("value:"); - throw TxBuilderException.invalidTxid(msg.last); - } else { - throw TxBuilderException.unexpected(e.message); - } + throw configException(e.message); } } } @@ -507,15 +666,11 @@ class Script { /// [Script] constructor static Future