diff --git a/CHANGELOG.md b/CHANGELOG.md index 6fc20a9f..d9a7dd53 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,22 @@ -## [0.3.2] +## [0.27.1] +Updated Rust ( Bdk to latest version 0.27.1 ) and Flutter dependencies. + +#### APIs added + - New `Transaction` class that can be created from or serialized to consensus encoded bytes. + - Add estimateFee(int Target) function for `Blockchain` + - Add getInternalAddress() function for `Wallet` + - Add AddressIndex.reset(int index) & AddressIndex.peek(int index) + +#### APIs changed + - partiallySignedTransaction.extractTx() returns a `Transaction` instead of a the transaction bytes. + - blockchain.broadcast() takes a `Transaction` instead of a `PartiallySignedTransaction` +## [0.3.2] ### Fixed -- iOS build issue when using flovors +- iOS build issue when using flavors - Added toString method for all objects -## [0.3.1] +## [0.3.1] ### Fixed - Pub.dev analysis score - Type mismatch for descriptorSecretKey diff --git a/README.md b/README.md index db750407..29174858 100644 --- a/README.md +++ b/README.md @@ -15,18 +15,19 @@ To use the `bdk_flutter` package in your project, add it as a dependency in your ```dart dependencies: - bdk_flutter: ^0.3.2 - + bdk_flutter: ^0.27.1 ``` -`bdk-flutter` can then be imported and used in your Flutter code. For example: +### Examples + +### Create a Wallet & sync the balance of a descriptor ```dart import 'package:bdk_flutter/bdk_flutter.dart'; // .... -final mnemonic = await Mnemonic.create(WordCount.Words12); +final mnemonic = await Mnemonic.create(WordCount.Words12); final descriptorSecretKey = await DescriptorSecretKey.create( network: Network.Testnet, mnemonic: mnemonic ); final externalDescriptor = await Descriptor.newBip44( descriptorSecretKey: descriptorSecretKey, @@ -45,8 +46,26 @@ 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 ); +final _ = await wallet.sync( blockchain ); +``` + +### Create a `public` wallet descriptor + +```dart +import 'package:bdk_flutter/bdk_flutter.dart'; + +// .... + +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, + keychain: KeyChainKind.External ); +final externalPublicDescriptorStr = await externalDescriptor.asString(); +final externalPublicDescriptor = await Descriptor.( descriptor: externalPublicDescriptorStr, + network: Network.Testnet); + ``` ### API Documentation diff --git a/analysis_options.yaml b/analysis_options.yaml index 0923c17f..148f627f 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -2,6 +2,17 @@ include: package:lints/recommended.yaml # Additional information about this file can be found at # https://dart.dev/guides/language/analysis-options +linter: + rules: + prefer_single_quotes: false + avoid_void_async: false + prefer_interpolation_to_compose_strings: false + avoid_print: false + use_build_context_synchronously: false + unnecessary_string_escapes: false + avoid_dynamic_calls: false + non_constant_identifier_names: false + analyzer: exclude: - lib/src/generated/bindings.dart diff --git a/android/src/main/jniLibs/arm64-v8a/librust.so b/android/src/main/jniLibs/arm64-v8a/librust.so index 044418e8..4bb90a81 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 5996ea83..07b0e2a8 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 94a6eb15..d2d1859b 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 b/example/ios/Podfile index 88359b22..70212f20 100644 --- a/example/ios/Podfile +++ b/example/ios/Podfile @@ -1,5 +1,4 @@ -# Uncomment this line to define a global platform for your project -# platform :ios, '11.0' +platform :ios, '12.0' # CocoaPods analytics sends network stats synchronously affecting flutter build latency. ENV['COCOAPODS_DISABLE_STATS'] = 'true' diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index ceea3122..a1cfe1d1 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -1,5 +1,5 @@ PODS: - - bdk_flutter (0.3.0): + - bdk_flutter (0.27.1): - Flutter - Flutter (1.0.0) @@ -14,9 +14,9 @@ EXTERNAL SOURCES: :path: Flutter SPEC CHECKSUMS: - bdk_flutter: e07886d29c53a9c7deba3bec3b20418ce5bd9787 + bdk_flutter: 45bcefee47c051c8c42e507d6a3a708bdd0aadea Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854 -PODFILE CHECKSUM: ef19549a9bc3046e7bb7d2fab4d021637c0c58a3 +PODFILE CHECKSUM: 6998435987a000fdec9b2e1b5b1eef6d54bdba77 COCOAPODS: 1.11.3 diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj index 58cecad1..ad1e3d19 100644 --- a/example/ios/Runner.xcodeproj/project.pbxproj +++ b/example/ios/Runner.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 50; + objectVersion = 54; objects = { /* Begin PBXBuildFile section */ @@ -220,6 +220,7 @@ }; 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; buildActionMask = 2147483647; files = ( ); @@ -234,6 +235,7 @@ }; 9740EEB61CF901F6004384FC /* Run Script */ = { isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; buildActionMask = 2147483647; files = ( ); diff --git a/example/lib/main.dart b/example/lib/main.dart index ae5c3f1b..c9363127 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -14,7 +14,9 @@ class MyApp extends StatefulWidget { } class _MyAppState extends State { - late Wallet aliceWallet; + String displayText = ""; + int balance = 0; + late Wallet bdkWallet; Descriptor? aliceDescriptor; late Descriptor aliceChangeDescriptor; Blockchain? blockchain; @@ -27,6 +29,9 @@ class _MyAppState extends State { generateMnemonicKeys() async { final res = await Mnemonic.create(WordCount.Words12); + setState(() { + displayText = res.toString(); + }); if (kDebugMode) { print(res.asString()); } @@ -34,13 +39,16 @@ class _MyAppState extends State { restoreWallet() async { await createDescriptorSecret(); - aliceWallet = await Wallet.create( + bdkWallet = await Wallet.create( descriptor: aliceDescriptor!, network: Network.Testnet, databaseConfig: const DatabaseConfig.memory()); - if (kDebugMode) { - print("init Complete"); - } + final address = + await bdkWallet.getAddress(addressIndex: const AddressIndex()); + + setState(() { + displayText = "Wallet restored with address: ${address.address} "; + }); } createDescriptorSecret() async { @@ -60,17 +68,14 @@ class _MyAppState extends State { }); } - initElectrumBlockchain(bool isElectrum) async { + initBlockchain(bool isElectrumBlockchain) async { if (blockchain == null) { - if (!isElectrum) { + if (!isElectrumBlockchain) { 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'))); + config: BlockchainConfig.esplora( + config: EsploraConfig( + baseUrl: 'https://blockstream.info/testnet/api', + stopGap: 10))); } else { blockchain = await Blockchain.create( config: BlockchainConfig.electrum( @@ -85,24 +90,33 @@ class _MyAppState extends State { } sync() async { - await initElectrumBlockchain(true); - aliceWallet.sync(blockchain!); + await initBlockchain(true); + bdkWallet.sync(blockchain!); + setState(() { + displayText = "Syncing completed"; + }); } getNewAddress() async { - final alice = await aliceWallet.getAddress(addressIndex: AddressIndex.New); + final res = await bdkWallet.getAddress(addressIndex: const AddressIndex()); if (kDebugMode) { - print(alice.address); - print(alice.index); + print(res.address); } + setState(() { + displayText = "Address: ${res.address} \n Index: ${res.index}"; + }); } getUnConfirmedTransactions() async { List unConfirmed = []; - final res = await aliceWallet.listTransactions(); + final res = await bdkWallet.listTransactions(); + for (var e in res) { if (e.confirmationTime == null) unConfirmed.add(e); } + setState(() { + displayText = "You have ${unConfirmed.length} unConfirmed transactions"; + }); for (var e in unConfirmed) { if (kDebugMode) { print(" txid: ${e.txid}"); @@ -116,10 +130,13 @@ class _MyAppState extends State { getConfirmedTransactions() async { List confirmed = []; - final res = await aliceWallet.listTransactions(); + final res = await bdkWallet.listTransactions(); for (var e in res) { if (e.confirmationTime != null) confirmed.add(e); } + setState(() { + displayText = "You have ${confirmed.length} confirmed transactions"; + }); for (var e in confirmed) { if (kDebugMode) { print(" txid: ${e.txid}"); @@ -134,14 +151,20 @@ class _MyAppState extends State { } getBalance() async { - final res = await aliceWallet.getBalance(); - if (kDebugMode) { - print("alice ${res.total}"); - } + final res = await bdkWallet.getBalance(); + setState(() { + balance = res.total; + displayText = + "Total Balance: ${res.total} \n Immature Balance: ${res.immature}"; + }); } listUnspent() async { - final res = await aliceWallet.listUnspent(); + final res = await bdkWallet.listUnspent(); + setState(() { + displayText = + " OutPoint: { txid:${res.first.outpoint.txid}, vout: ${res.first.outpoint.vout} }"; + }); for (var e in res) { if (kDebugMode) { print("isSpent: ${e.isSpent}"); @@ -158,28 +181,44 @@ class _MyAppState extends State { if (kDebugMode) { print(res); } + setState(() { + displayText = "Height: $res"; + }); return res; } getBlockHash() async { final height = await getBlockHeight(); final blockHash = await blockchain!.getBlockHash(height); + setState(() { + displayText = "BlockHash: $blockHash"; + }); if (kDebugMode) { print(blockHash); } } + Future estimateFeeRate(int blocks) async { + final feeRate = await blockchain!.estimateFee(blocks); + setState(() { + displayText = "feeRate: ${feeRate.asSatPerVb()}"; + }); + return feeRate; + } + sendBit() async { final txBuilder = TxBuilder(); final address = await Address.create(address: "mv4rnyY3Su5gjcDNzbMLKBQkBicCtHUtFB"); final script = await address.scriptPubKey(); + final feeRate = await estimateFeeRate(25); final psbt = await txBuilder .addRecipient(script, 700) - .feeRate(1.1) - .finish(aliceWallet); - final res = await aliceWallet.sign(psbt); - await blockchain!.broadcast(res); + .feeRate(feeRate.asSatPerVb()) + .finish(bdkWallet); + final sbt = await bdkWallet.sign(psbt); + final tx = await sbt.extractTx(); + await blockchain!.broadcast(tx); sync(); } @@ -188,46 +227,161 @@ class _MyAppState extends State { return MaterialApp( debugShowCheckedModeBanner: false, home: Scaffold( - appBar: AppBar( - elevation: 0, - title: const Text( - 'Bdk Flutter', - style: TextStyle( - fontStyle: FontStyle.italic, - fontSize: 20, - fontWeight: FontWeight.w900), + appBar: PreferredSize( + preferredSize: const Size(double.infinity, kToolbarHeight * 1.5), + child: Container( + padding: const EdgeInsets.only(right: 20, left: 20, top: 40), + color: Colors.blue, + child: + Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ + const Text('Bdk Wallet', + style: TextStyle( + fontWeight: FontWeight.w900, + fontSize: 16, + height: 2.5, + color: Colors.white)), + const SizedBox( + height: 5, + ), + Row( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const Text("Response: ", + textAlign: TextAlign.center, + style: TextStyle( + color: Colors.white, + fontSize: 12, + fontWeight: FontWeight.w700)), + Expanded( + child: SelectableText( + displayText, + maxLines: 3, + textAlign: TextAlign.start, + style: const TextStyle( + color: Colors.white, + fontSize: 12, + fontWeight: FontWeight.w700), + ), + ), + ], + ), + ]), ), ), body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + balance.toString(), + style: const TextStyle( + fontWeight: FontWeight.w900, + fontSize: 40, + color: Colors.blue), + ), + const Text( + " sats", + style: TextStyle( + fontWeight: FontWeight.w900, + fontSize: 20, + color: Colors.blue), + ), + ], + ), TextButton( onPressed: () => getNewAddress(), - child: const Text('Press to create new Address')), + child: const Text( + 'Press to create new Address', + style: TextStyle( + color: Colors.indigoAccent, + fontSize: 12, + height: 1.5, + fontWeight: FontWeight.w800), + )), TextButton( - onPressed: () => sendBit(), - child: const Text('Press to send 1200 satoshi')), - TextButton( - onPressed: () => sync(), child: const Text('Press to sync')), + onPressed: () => sync(), + child: const Text( + 'Press to sync', + style: TextStyle( + color: Colors.indigoAccent, + fontSize: 12, + height: 1.5, + fontWeight: FontWeight.w800), + )), TextButton( onPressed: () => getConfirmedTransactions(), - child: const Text('Get ConfirmedTransactions')), + child: const Text( + 'Get ConfirmedTransactions', + style: TextStyle( + color: Colors.indigoAccent, + fontSize: 12, + height: 1.5, + fontWeight: FontWeight.w800), + )), TextButton( onPressed: () => getUnConfirmedTransactions(), - child: const Text('getPendingTransactions')), + child: const Text( + 'getPendingTransactions', + style: TextStyle( + color: Colors.indigoAccent, + fontSize: 12, + height: 1.5, + fontWeight: FontWeight.w800), + )), TextButton( onPressed: () => getBalance(), - child: const Text('get Balance')), + child: const Text( + 'get Balance', + style: TextStyle( + color: Colors.indigoAccent, + fontSize: 12, + height: 1.5, + fontWeight: FontWeight.w800), + )), TextButton( onPressed: () => listUnspent(), - child: const Text('list Unspent')), + child: const Text( + 'list Unspent', + style: TextStyle( + color: Colors.indigoAccent, + fontSize: 12, + height: 1.5, + fontWeight: FontWeight.w800), + )), + TextButton( + onPressed: () => sendBit(), + child: const Text( + 'Press to send 1200 satoshi', + style: TextStyle( + color: Colors.indigoAccent, + fontSize: 12, + height: 1.5, + fontWeight: FontWeight.w800), + )), TextButton( onPressed: () => getBlockHash(), - child: const Text('get BlockHash')), + child: const Text( + 'get BlockHash', + style: TextStyle( + color: Colors.indigoAccent, + fontSize: 12, + height: 1.5, + fontWeight: FontWeight.w800), + )), TextButton( onPressed: () => generateMnemonicKeys(), - child: const Text('generate Mnemonic')), + child: const Text( + 'generate Mnemonic', + style: TextStyle( + color: Colors.indigoAccent, + fontSize: 12, + height: 1.5, + fontWeight: FontWeight.w800), + )), ], ), ), diff --git a/example/pubspec.lock b/example/pubspec.lock index 5c30e92c..99e7c580 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -5,182 +5,207 @@ packages: dependency: transitive description: name: _fe_analyzer_shared - url: "https://pub.dartlang.org" + sha256: "3444216bfd127af50bbe4862d8843ed44db946dd933554f0d7285e89f10e28ac" + url: "https://pub.dev" source: hosted version: "50.0.0" analyzer: dependency: transitive description: name: analyzer - url: "https://pub.dartlang.org" + sha256: "68796c31f510c8455a06fed75fc97d8e5ad04d324a830322ab3efc9feb6201c1" + url: "https://pub.dev" source: hosted version: "5.2.0" archive: dependency: transitive description: name: archive - url: "https://pub.dartlang.org" + sha256: ed7cc591a948744994714375caf9a2ce89e1d82e8243997c8a2994d57181c212 + url: "https://pub.dev" source: hosted - version: "3.3.6" + version: "3.3.5" args: dependency: transitive description: name: args - url: "https://pub.dartlang.org" + sha256: b003c3098049a51720352d219b0bb5f219b60fbfb68e7a4748139a06a5676515 + url: "https://pub.dev" source: hosted - version: "2.3.2" + version: "2.3.1" async: dependency: transitive description: name: async - url: "https://pub.dartlang.org" + sha256: bfe67ef28df125b7dddcea62755991f807aa39a2492a23e1550161692950bbe0 + url: "https://pub.dev" source: hosted - version: "2.9.0" + version: "2.10.0" bdk_flutter: dependency: "direct main" description: path: ".." relative: true source: path - version: "0.3.2" + version: "0.27.1" boolean_selector: dependency: transitive description: name: boolean_selector - url: "https://pub.dartlang.org" + sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.1" build: dependency: transitive description: name: build - url: "https://pub.dartlang.org" + sha256: "3fbda25365741f8251b39f3917fb3c8e286a96fd068a5a242e11c2012d495777" + url: "https://pub.dev" source: hosted version: "2.3.1" build_cli_annotations: dependency: transitive description: name: build_cli_annotations - url: "https://pub.dartlang.org" + sha256: b59d2769769efd6c9ff6d4c4cede0be115a566afc591705c2040b707534b1172 + url: "https://pub.dev" source: hosted version: "2.1.0" build_config: dependency: transitive description: name: build_config - url: "https://pub.dartlang.org" + sha256: "5b7355c14258f5e7df24bad1566f7b991de3e54aeacfb94e1a65e5233d9739c1" + url: "https://pub.dev" source: hosted - version: "1.1.1" + version: "1.1.0" built_collection: dependency: transitive description: name: built_collection - url: "https://pub.dartlang.org" + sha256: "376e3dd27b51ea877c28d525560790aee2e6fbb5f20e2f85d5081027d94e2100" + url: "https://pub.dev" source: hosted version: "5.1.1" built_value: dependency: transitive description: name: built_value - url: "https://pub.dartlang.org" + sha256: d7a9cd57c215bdf8d502772447aa6b52a8ab3f956d25d5fdea6ef1df2d2dad60 + url: "https://pub.dev" source: hosted - version: "8.4.3" + version: "8.4.1" characters: dependency: transitive description: name: characters - url: "https://pub.dartlang.org" + sha256: e6a326c8af69605aec75ed6c187d06b349707a27fbff8222ca9cc2cff167975c + url: "https://pub.dev" source: hosted version: "1.2.1" checked_yaml: dependency: transitive description: name: checked_yaml - url: "https://pub.dartlang.org" + sha256: dd007e4fb8270916820a0d66e24f619266b60773cddd082c6439341645af2659 + url: "https://pub.dev" source: hosted - version: "2.0.2" + version: "2.0.1" clock: dependency: transitive description: name: clock - url: "https://pub.dartlang.org" + sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf + url: "https://pub.dev" source: hosted version: "1.1.1" code_builder: dependency: transitive description: name: code_builder - url: "https://pub.dartlang.org" + sha256: "02ce3596b459c666530f045ad6f96209474e8fee6e4855940a3cee65fb872ec5" + url: "https://pub.dev" source: hosted - version: "4.4.0" + version: "4.3.0" collection: dependency: transitive description: name: collection - url: "https://pub.dartlang.org" + sha256: cfc915e6923fe5ce6e153b0723c753045de46de1b4d63771530504004a45fae0 + url: "https://pub.dev" source: hosted - version: "1.16.0" + version: "1.17.0" colorize: dependency: transitive description: name: colorize - url: "https://pub.dartlang.org" + sha256: "584746cd6ba1cba0633b6720f494fe6f9601c4170f0666c1579d2aa2a61071ba" + url: "https://pub.dev" source: hosted version: "3.0.0" convert: dependency: transitive description: name: convert - url: "https://pub.dartlang.org" + sha256: "196284f26f69444b7f5c50692b55ec25da86d9e500451dc09333bf2e3ad69259" + url: "https://pub.dev" source: hosted - version: "3.1.1" + version: "3.0.2" crypto: dependency: transitive description: name: crypto - url: "https://pub.dartlang.org" + sha256: aa274aa7774f8964e4f4f38cc994db7b6158dd36e9187aaceaddc994b35c6c67 + url: "https://pub.dev" source: hosted version: "3.0.2" cupertino_icons: dependency: "direct main" description: name: cupertino_icons - url: "https://pub.dartlang.org" + sha256: "1989d917fbe8e6b39806207df5a3fdd3d816cbd090fac2ce26fb45e9a71476e5" + url: "https://pub.dev" source: hosted - version: "1.0.5" + version: "1.0.4" dart_style: dependency: transitive description: name: dart_style - url: "https://pub.dartlang.org" + sha256: "7a03456c3490394c8e7665890333e91ae8a49be43542b616e414449ac358acd4" + url: "https://pub.dev" source: hosted version: "2.2.4" fake_async: dependency: transitive description: name: fake_async - url: "https://pub.dartlang.org" + sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" + url: "https://pub.dev" source: hosted version: "1.3.1" ffi: dependency: transitive description: name: ffi - url: "https://pub.dartlang.org" + sha256: a38574032c5f1dd06c4aee541789906c12ccaab8ba01446e800d9c5b79c4a978 + url: "https://pub.dev" source: hosted version: "2.0.1" file: dependency: transitive description: name: file - url: "https://pub.dartlang.org" + sha256: b69516f2c26a5bcac4eee2e32512e1a5205ab312b3536c1c1227b2b942b5f9ad + url: "https://pub.dev" source: hosted - version: "6.1.4" + version: "6.1.2" fixnum: dependency: transitive description: name: fixnum - url: "https://pub.dartlang.org" + sha256: "04be3e934c52e082558cc9ee21f42f5c1cd7a1262f4c63cd0357c08d5bba81ec" + url: "https://pub.dev" source: hosted version: "1.0.1" flutter: @@ -192,14 +217,16 @@ packages: dependency: "direct dev" description: name: flutter_lints - url: "https://pub.dartlang.org" + sha256: aeb0b80a8b3709709c9cc496cdc027c5b3216796bc0af0ce1007eaf24464fd4c + url: "https://pub.dev" source: hosted version: "2.0.1" flutter_rust_bridge: dependency: transitive description: name: flutter_rust_bridge - url: "https://pub.dartlang.org" + sha256: "7660373464f53a8c7b7974ea577d54fa0c1fd04321b10dd444420ae3998b0c42" + url: "https://pub.dev" source: hosted version: "1.60.0" flutter_test: @@ -211,175 +238,200 @@ packages: dependency: transitive description: name: freezed - url: "https://pub.dartlang.org" + sha256: e819441678f1679b719008ff2ff0ef045d66eed9f9ec81166ca0d9b02a187454 + url: "https://pub.dev" source: hosted version: "2.3.2" freezed_annotation: dependency: transitive description: name: freezed_annotation - url: "https://pub.dartlang.org" + sha256: aeac15850ef1b38ee368d4c53ba9a847e900bb2c53a4db3f6881cbb3cb684338 + url: "https://pub.dev" source: hosted version: "2.2.0" glob: dependency: transitive description: name: glob - url: "https://pub.dartlang.org" + sha256: c51b4fdfee4d281f49b8c957f1add91b815473597f76bcf07377987f66a55729 + url: "https://pub.dev" source: hosted - version: "2.1.1" + version: "2.1.0" http: dependency: transitive description: name: http - url: "https://pub.dartlang.org" + sha256: "6aa2946395183537c8b880962d935877325d6a09a2867c3970c05c0fed6ac482" + url: "https://pub.dev" source: hosted version: "0.13.5" http_parser: dependency: transitive description: name: http_parser - url: "https://pub.dartlang.org" + sha256: "2aa08ce0341cc9b354a498388e30986515406668dbcc4f7c950c3e715496693b" + url: "https://pub.dev" source: hosted version: "4.0.2" js: dependency: transitive description: name: js - url: "https://pub.dartlang.org" + sha256: "5528c2f391ededb7775ec1daa69e65a2d61276f7552de2b5f7b8d34ee9fd4ab7" + url: "https://pub.dev" source: hosted version: "0.6.5" json_annotation: dependency: transitive description: name: json_annotation - url: "https://pub.dartlang.org" + sha256: cb314f00b2488de7bc575207e54402cd2f92363f333a7933fd1b0631af226baa + url: "https://pub.dev" source: hosted - version: "4.8.0" + version: "4.6.0" lints: dependency: transitive description: name: lints - url: "https://pub.dartlang.org" + sha256: "5cfd6509652ff5e7fe149b6df4859e687fca9048437857cb2e65c8d780f396e3" + url: "https://pub.dev" source: hosted - version: "2.0.1" + version: "2.0.0" logging: dependency: transitive description: name: logging - url: "https://pub.dartlang.org" + sha256: "293ae2d49fd79d4c04944c3a26dfd313382d5f52e821ec57119230ae16031ad4" + url: "https://pub.dev" source: hosted - version: "1.1.1" + version: "1.0.2" matcher: dependency: transitive description: name: matcher - url: "https://pub.dartlang.org" + sha256: "16db949ceee371e9b99d22f88fa3a73c4e59fd0afed0bd25fc336eb76c198b72" + url: "https://pub.dev" source: hosted - version: "0.12.12" + version: "0.12.13" material_color_utilities: dependency: transitive description: name: material_color_utilities - url: "https://pub.dartlang.org" + sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724 + url: "https://pub.dev" source: hosted - version: "0.1.5" + version: "0.2.0" meta: dependency: transitive description: name: meta - url: "https://pub.dartlang.org" + sha256: "6c268b42ed578a53088d834796959e4a1814b5e9e164f147f580a386e5decf42" + url: "https://pub.dev" source: hosted version: "1.8.0" mime: dependency: transitive description: name: mime - url: "https://pub.dartlang.org" + sha256: "52e38f7e1143ef39daf532117d6b8f8f617bf4bcd6044ed8c29040d20d269630" + url: "https://pub.dev" source: hosted - version: "1.0.4" + version: "1.0.3" mockito: dependency: transitive description: name: mockito - url: "https://pub.dartlang.org" + sha256: "2a8a17b82b1bde04d514e75d90d634a0ac23f6cb4991f6098009dd56836aeafe" + url: "https://pub.dev" source: hosted version: "5.3.2" package_config: dependency: transitive description: name: package_config - url: "https://pub.dartlang.org" + sha256: "1c5b77ccc91e4823a5af61ee74e6b972db1ef98c2ff5a18d3161c982a55448bd" + url: "https://pub.dev" source: hosted version: "2.1.0" path: dependency: transitive description: name: path - url: "https://pub.dartlang.org" + sha256: db9d4f58c908a4ba5953fcee2ae317c94889433e5024c27ce74a37f94267945b + url: "https://pub.dev" source: hosted version: "1.8.2" petitparser: dependency: transitive description: name: petitparser - url: "https://pub.dartlang.org" + sha256: "49392a45ced973e8d94a85fdb21293fbb40ba805fc49f2965101ae748a3683b4" + url: "https://pub.dev" source: hosted version: "5.1.0" pointycastle: dependency: transitive description: name: pointycastle - url: "https://pub.dartlang.org" + sha256: db7306cf0249f838d1a24af52b5a5887c5bf7f31d8bb4e827d071dc0939ad346 + url: "https://pub.dev" source: hosted version: "3.6.2" pool: dependency: transitive description: name: pool - url: "https://pub.dartlang.org" + sha256: "20fe868b6314b322ea036ba325e6fc0711a22948856475e2c2b6306e8ab39c2a" + url: "https://pub.dev" source: hosted version: "1.5.1" pub_semver: dependency: transitive description: name: pub_semver - url: "https://pub.dartlang.org" + sha256: "816c1a640e952d213ddd223b3e7aafae08cd9f8e1f6864eed304cc13b0272b07" + url: "https://pub.dev" source: hosted - version: "2.1.3" + version: "2.1.1" pubspec_parse: dependency: transitive description: name: pubspec_parse - url: "https://pub.dartlang.org" + sha256: "3686efe4a4613a4449b1a4ae08670aadbd3376f2e78d93e3f8f0919db02a7256" + url: "https://pub.dev" source: hosted - version: "1.2.1" + version: "1.2.0" puppeteer: dependency: transitive description: name: puppeteer - url: "https://pub.dartlang.org" + sha256: "8259e98c991bcdf34967cdfb9cec1829e8890cc4ad9b525794e950ce23184cd1" + url: "https://pub.dev" source: hosted - version: "2.22.0" + version: "2.17.0" shelf: dependency: transitive description: name: shelf - url: "https://pub.dartlang.org" + sha256: c24a96135a2ccd62c64b69315a14adc5c3419df63b4d7c05832a346fdb73682c + url: "https://pub.dev" source: hosted version: "1.4.0" shelf_static: dependency: transitive description: name: shelf_static - url: "https://pub.dartlang.org" + sha256: e792b76b96a36d4a41b819da593aff4bdd413576b3ba6150df5d8d9996d2e74c + url: "https://pub.dev" source: hosted version: "1.1.1" shelf_web_socket: dependency: transitive description: name: shelf_web_socket - url: "https://pub.dartlang.org" + sha256: a988c0e8d8ffbdb8a28aa7ec8e449c260f3deb808781fe1284d22c5bba7156e8 + url: "https://pub.dev" source: hosted version: "1.0.3" sky_engine: @@ -391,98 +443,112 @@ packages: dependency: transitive description: name: source_gen - url: "https://pub.dartlang.org" + sha256: "2d79738b6bbf38a43920e2b8d189e9a3ce6cc201f4b8fc76be5e4fe377b1c38d" + url: "https://pub.dev" source: hosted - version: "1.2.7" + version: "1.2.6" source_span: dependency: transitive description: name: source_span - url: "https://pub.dartlang.org" + sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250 + url: "https://pub.dev" source: hosted - version: "1.9.0" + version: "1.9.1" stack_trace: dependency: transitive description: name: stack_trace - url: "https://pub.dartlang.org" + sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5 + url: "https://pub.dev" source: hosted - version: "1.10.0" + version: "1.11.0" stream_channel: dependency: transitive description: name: stream_channel - url: "https://pub.dartlang.org" + sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8" + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.1" string_scanner: dependency: transitive description: name: string_scanner - url: "https://pub.dartlang.org" + sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" + url: "https://pub.dev" source: hosted - version: "1.1.1" + version: "1.2.0" term_glyph: dependency: transitive description: name: term_glyph - url: "https://pub.dartlang.org" + sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 + url: "https://pub.dev" source: hosted version: "1.2.1" test_api: dependency: transitive description: name: test_api - url: "https://pub.dartlang.org" + sha256: ad540f65f92caa91bf21dfc8ffb8c589d6e4dc0c2267818b4cc2792857706206 + url: "https://pub.dev" source: hosted - version: "0.4.12" + version: "0.4.16" tuple: dependency: transitive description: name: tuple - url: "https://pub.dartlang.org" + sha256: "0ea99cd2f9352b2586583ab2ce6489d1f95a5f6de6fb9492faaf97ae2060f0aa" + url: "https://pub.dev" source: hosted version: "2.0.1" typed_data: dependency: transitive description: name: typed_data - url: "https://pub.dartlang.org" + sha256: "26f87ade979c47a150c9eaab93ccd2bebe70a27dc0b4b29517f2904f04eb11a5" + url: "https://pub.dev" source: hosted version: "1.3.1" uuid: dependency: transitive description: name: uuid - url: "https://pub.dartlang.org" + sha256: "648e103079f7c64a36dc7d39369cabb358d377078a051d6ae2ad3aa539519313" + url: "https://pub.dev" source: hosted version: "3.0.7" vector_math: dependency: transitive description: name: vector_math - url: "https://pub.dartlang.org" + sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" + url: "https://pub.dev" source: hosted - version: "2.1.2" + version: "2.1.4" watcher: dependency: transitive description: name: watcher - url: "https://pub.dartlang.org" + sha256: e42dfcc48f67618344da967b10f62de57e04bae01d9d3af4c2596f3712a88c99 + url: "https://pub.dev" source: hosted - version: "1.0.2" + version: "1.0.1" web_socket_channel: dependency: transitive description: name: web_socket_channel - url: "https://pub.dartlang.org" + sha256: "3a969ddcc204a3e34e863d204b29c0752716f78b6f9cc8235083208d268a4ccd" + url: "https://pub.dev" source: hosted - version: "2.3.0" + version: "2.2.0" yaml: dependency: transitive description: name: yaml - url: "https://pub.dartlang.org" + sha256: "23812a9b125b48d4007117254bca50abb6c712352927eece9e155207b1db2370" + url: "https://pub.dev" source: hosted version: "3.1.1" sdks: diff --git a/example/test/widget_test.dart b/example/test/widget_test.dart deleted file mode 100644 index 116e46e9..00000000 --- a/example/test/widget_test.dart +++ /dev/null @@ -1,26 +0,0 @@ -// This is a basic Flutter widget test. -// -// To perform an interaction with a widget in your test, use the WidgetTester -// utility in the flutter_test package. For example, you can send tap and scroll -// gestures. You can also use WidgetTester to find child widgets in the widget -// tree, read text, and verify that the values of widget properties are correct. - -import 'package:bdk_flutter_example/main.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_test/flutter_test.dart'; - -void main() { - testWidgets('Verify Platform version', (WidgetTester tester) async { - // Build our app and trigger a frame. - await tester.pumpWidget(const MyApp()); - - // Verify that platform version is retrieved. - expect( - find.byWidgetPredicate( - (Widget widget) => - widget is Text && widget.data!.startsWith('Running on:'), - ), - findsOneWidget, - ); - }); -} diff --git a/ios/Classes/bindings.h b/ios/Classes/bindings.h index 831a70bf..c0138a6e 100644 --- a/ios/Classes/bindings.h +++ b/ios/Classes/bindings.h @@ -139,9 +139,33 @@ typedef struct wire_DatabaseConfig { union DatabaseConfigKind *kind; } wire_DatabaseConfig; -typedef struct wire_FeeRate { - float field0; -} wire_FeeRate; +typedef struct wire_AddressIndex_New { + +} wire_AddressIndex_New; + +typedef struct wire_AddressIndex_LastUnused { + +} wire_AddressIndex_LastUnused; + +typedef struct wire_AddressIndex_Peek { + uint32_t index; +} wire_AddressIndex_Peek; + +typedef struct wire_AddressIndex_Reset { + uint32_t index; +} wire_AddressIndex_Reset; + +typedef union AddressIndexKind { + struct wire_AddressIndex_New *New; + struct wire_AddressIndex_LastUnused *LastUnused; + struct wire_AddressIndex_Peek *Peek; + struct wire_AddressIndex_Reset *Reset; +} AddressIndexKind; + +typedef struct wire_AddressIndex { + int32_t tag; + union AddressIndexKind *kind; +} wire_AddressIndex; typedef struct DartCObject *WireSyncReturn; @@ -163,15 +187,19 @@ void wire_get_blockchain_hash(int64_t port_, uint32_t blockchain_height, struct wire_BlockchainInstance blockchain); +void wire_estimate_fee(int64_t port_, uint64_t target, struct wire_BlockchainInstance blockchain); + void wire_broadcast(int64_t port_, - struct wire_uint_8_list *psbt_str, + struct wire_uint_8_list *tx, struct wire_BlockchainInstance blockchain); +void wire_new_transaction(int64_t port_, struct wire_uint_8_list *tx); + void wire_psbt_to_txid(int64_t port_, struct wire_uint_8_list *psbt_str); 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_psbt_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); @@ -242,6 +270,13 @@ 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_create_descriptor_secret(int64_t port_, + int32_t network, + struct wire_uint_8_list *mnemonic, + struct wire_uint_8_list *password); + +void wire_descriptor_secret_from_string(int64_t port_, struct wire_uint_8_list *xprv); + void wire_descriptor_secret_extend(int64_t port_, struct wire_uint_8_list *xprv, struct wire_uint_8_list *path); @@ -258,13 +293,10 @@ void wire_descriptor_secret_as_public(int64_t port_, struct wire_uint_8_list *descriptor_secret, struct wire_uint_8_list *xprv); -void wire_create_descriptor_secret(int64_t port_, - int32_t network, - struct wire_uint_8_list *mnemonic, - struct wire_uint_8_list *password); - void wire_create_derivation_path(int64_t port_, struct wire_uint_8_list *path); +void wire_descriptor_public_from_string(int64_t port_, struct wire_uint_8_list *public_key); + void wire_create_descriptor_public(int64_t port_, struct wire_uint_8_list *xpub, struct wire_uint_8_list *path, @@ -282,7 +314,13 @@ void wire_wallet_init(int64_t port_, int32_t network, struct wire_DatabaseConfig *database_config); -void wire_get_address(int64_t port_, struct wire_WalletInstance wallet, int32_t address_index); +void wire_get_address(int64_t port_, + struct wire_WalletInstance wallet, + struct wire_AddressIndex *address_index); + +void wire_get_internalized_address(int64_t port_, + struct wire_WalletInstance wallet, + struct wire_AddressIndex *address_index); void wire_sync_wallet(int64_t port_, struct wire_WalletInstance wallet, @@ -309,8 +347,6 @@ 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); @@ -319,6 +355,8 @@ struct wire_WalletInstance new_WalletInstance(void); struct wire_BdkDescriptor *new_box_autoadd_BdkDescriptor_0(void); +struct wire_AddressIndex *new_box_autoadd_address_index_0(void); + struct wire_BlockchainConfig *new_box_autoadd_blockchain_config_0(void); struct wire_DatabaseConfig *new_box_autoadd_database_config_0(void); @@ -329,8 +367,6 @@ 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); @@ -365,6 +401,10 @@ void drop_opaque_WalletInstance(const void *ptr); const void *share_opaque_WalletInstance(const void *ptr); +union AddressIndexKind *inflate_AddressIndex_Peek(void); + +union AddressIndexKind *inflate_AddressIndex_Reset(void); + union BlockchainConfigKind *inflate_BlockchainConfig_Electrum(void); union BlockchainConfigKind *inflate_BlockchainConfig_Esplora(void); @@ -382,10 +422,12 @@ static int64_t dummy_method_to_enforce_bundling(void) { dummy_var ^= ((int64_t) (void*) wire_blockchain_init); dummy_var ^= ((int64_t) (void*) wire_get_blockchain_height); dummy_var ^= ((int64_t) (void*) wire_get_blockchain_hash); + dummy_var ^= ((int64_t) (void*) wire_estimate_fee); dummy_var ^= ((int64_t) (void*) wire_broadcast); + dummy_var ^= ((int64_t) (void*) wire_new_transaction); 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_psbt_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); @@ -399,18 +441,21 @@ static int64_t dummy_method_to_enforce_bundling(void) { 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_create_descriptor_secret); + dummy_var ^= ((int64_t) (void*) wire_descriptor_secret_from_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); dummy_var ^= ((int64_t) (void*) wire_descriptor_secret_as_public); - dummy_var ^= ((int64_t) (void*) wire_create_descriptor_secret); dummy_var ^= ((int64_t) (void*) wire_create_derivation_path); + dummy_var ^= ((int64_t) (void*) wire_descriptor_public_from_string); dummy_var ^= ((int64_t) (void*) wire_create_descriptor_public); dummy_var ^= ((int64_t) (void*) wire_init_script); dummy_var ^= ((int64_t) (void*) wire_init_address); dummy_var ^= ((int64_t) (void*) wire_address_to_script_pubkey_hex); dummy_var ^= ((int64_t) (void*) wire_wallet_init); dummy_var ^= ((int64_t) (void*) wire_get_address); + dummy_var ^= ((int64_t) (void*) wire_get_internalized_address); dummy_var ^= ((int64_t) (void*) wire_sync_wallet); dummy_var ^= ((int64_t) (void*) wire_get_balance); dummy_var ^= ((int64_t) (void*) wire_list_unspent_outputs); @@ -421,17 +466,16 @@ 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_address_index_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); @@ -449,6 +493,8 @@ static int64_t dummy_method_to_enforce_bundling(void) { 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_AddressIndex_Peek); + dummy_var ^= ((int64_t) (void*) inflate_AddressIndex_Reset); dummy_var ^= ((int64_t) (void*) inflate_BlockchainConfig_Electrum); dummy_var ^= ((int64_t) (void*) inflate_BlockchainConfig_Esplora); dummy_var ^= ((int64_t) (void*) inflate_BlockchainConfig_Rpc); diff --git a/ios/bdk_flutter.podspec b/ios/bdk_flutter.podspec index 5c61f9f3..e3fc2dac 100644 --- a/ios/bdk_flutter.podspec +++ b/ios/bdk_flutter.podspec @@ -4,7 +4,7 @@ # Pod::Spec.new do |s| s.name = 'bdk_flutter' - s.version = '0.3.2' + s.version = '0.27.1' s.summary = 'A Flutter library for the Bitcoin Development Kit (https://bitcoindevkit.org/)' s.description = <<-DESC A new Flutter project. diff --git a/ios/librust.a b/ios/librust.a index 13cc3f2d..c14b38a3 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 c0be8a40..a0c83e5f 100644 --- a/lib/bdk_flutter.dart +++ b/lib/bdk_flutter.dart @@ -11,6 +11,11 @@ export './src/generated/bridge_definitions.dart' BlockchainConfig_Esplora, DatabaseConfig_Memory, DatabaseConfig_Sqlite, + AddressIndex_Reset, + AddressIndex_Peek, + AddressIndex_New, + AddressIndex_LastUnused, + BdkDescriptor, DatabaseConfig_Sled; export './src/root.dart'; diff --git a/lib/src/generated/bindings.dart b/lib/src/generated/bindings.dart index a654fc88..63b0d6b0 100644 --- a/lib/src/generated/bindings.dart +++ b/lib/src/generated/bindings.dart @@ -1,17 +1,18 @@ // 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 +// Generated by `flutter_rust_bridge`@ 1.63.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, unnecessary_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:meta/meta.dart'; import 'package:flutter_rust_bridge/flutter_rust_bridge.dart'; -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 'package:flutter_rust_bridge/flutter_rust_bridge.dart'; + import 'dart:ffi' as ffi; class RustImpl implements Rust { @@ -81,17 +82,38 @@ class RustImpl implements Rust { argNames: ["blockchainHeight", "blockchain"], ); + Future estimateFee( + {required int target, + required BlockchainInstance blockchain, + dynamic hint}) { + var arg0 = _platform.api2wire_u64(target); + var arg1 = _platform.api2wire_BlockchainInstance(blockchain); + return _platform.executeNormal(FlutterRustBridgeTask( + callFfi: (port_) => _platform.inner.wire_estimate_fee(port_, arg0, arg1), + parseSuccessData: _wire2api_f32, + constMeta: kEstimateFeeConstMeta, + argValues: [target, blockchain], + hint: hint, + )); + } + + FlutterRustBridgeTaskConstMeta get kEstimateFeeConstMeta => + const FlutterRustBridgeTaskConstMeta( + debugName: "estimate_fee", + argNames: ["target", "blockchain"], + ); + Future broadcast( - {required String psbtStr, + {required Uint8List tx, required BlockchainInstance blockchain, dynamic hint}) { - var arg0 = _platform.api2wire_String(psbtStr); + var arg0 = _platform.api2wire_uint_8_list(tx); var arg1 = _platform.api2wire_BlockchainInstance(blockchain); return _platform.executeNormal(FlutterRustBridgeTask( callFfi: (port_) => _platform.inner.wire_broadcast(port_, arg0, arg1), parseSuccessData: _wire2api_String, constMeta: kBroadcastConstMeta, - argValues: [psbtStr, blockchain], + argValues: [tx, blockchain], hint: hint, )); } @@ -99,7 +121,24 @@ class RustImpl implements Rust { FlutterRustBridgeTaskConstMeta get kBroadcastConstMeta => const FlutterRustBridgeTaskConstMeta( debugName: "broadcast", - argNames: ["psbtStr", "blockchain"], + argNames: ["tx", "blockchain"], + ); + + Future newTransaction({required Uint8List tx, dynamic hint}) { + var arg0 = _platform.api2wire_uint_8_list(tx); + return _platform.executeNormal(FlutterRustBridgeTask( + callFfi: (port_) => _platform.inner.wire_new_transaction(port_, arg0), + parseSuccessData: _wire2api_uint_8_list, + constMeta: kNewTransactionConstMeta, + argValues: [tx], + hint: hint, + )); + } + + FlutterRustBridgeTaskConstMeta get kNewTransactionConstMeta => + const FlutterRustBridgeTaskConstMeta( + debugName: "new_transaction", + argNames: ["tx"], ); Future psbtToTxid({required String psbtStr, dynamic hint}) { @@ -136,20 +175,20 @@ class RustImpl implements Rust { argNames: ["psbtStr"], ); - Future getFeeRate({required String psbtStr, dynamic hint}) { + Future getPsbtFeeRate({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_opt_box_autoadd_fee_rate, - constMeta: kGetFeeRateConstMeta, + callFfi: (port_) => _platform.inner.wire_get_psbt_fee_rate(port_, arg0), + parseSuccessData: _wire2api_opt_box_autoadd_f32, + constMeta: kGetPsbtFeeRateConstMeta, argValues: [psbtStr], hint: hint, )); } - FlutterRustBridgeTaskConstMeta get kGetFeeRateConstMeta => + FlutterRustBridgeTaskConstMeta get kGetPsbtFeeRateConstMeta => const FlutterRustBridgeTaskConstMeta( - debugName: "get_fee_rate", + debugName: "get_psbt_fee_rate", argNames: ["psbtStr"], ); @@ -521,6 +560,49 @@ class RustImpl implements Rust { argNames: ["descriptor"], ); + Future createDescriptorSecret( + {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), + parseSuccessData: _wire2api_String, + constMeta: kCreateDescriptorSecretConstMeta, + argValues: [network, mnemonic, password], + hint: hint, + )); + } + + FlutterRustBridgeTaskConstMeta get kCreateDescriptorSecretConstMeta => + const FlutterRustBridgeTaskConstMeta( + debugName: "create_descriptor_secret", + argNames: ["network", "mnemonic", "password"], + ); + + Future descriptorSecretFromString( + {required String xprv, dynamic hint}) { + var arg0 = _platform.api2wire_String(xprv); + return _platform.executeNormal(FlutterRustBridgeTask( + callFfi: (port_) => + _platform.inner.wire_descriptor_secret_from_string(port_, arg0), + parseSuccessData: _wire2api_String, + constMeta: kDescriptorSecretFromStringConstMeta, + argValues: [xprv], + hint: hint, + )); + } + + FlutterRustBridgeTaskConstMeta get kDescriptorSecretFromStringConstMeta => + const FlutterRustBridgeTaskConstMeta( + debugName: "descriptor_secret_from_string", + argNames: ["xprv"], + ); + Future descriptorSecretExtend( {required String xprv, required String path, dynamic hint}) { var arg0 = _platform.api2wire_String(xprv); @@ -601,46 +683,41 @@ class RustImpl implements Rust { argNames: ["descriptorSecret", "xprv"], ); - Future createDescriptorSecret( - {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); + Future createDerivationPath({required String path, dynamic hint}) { + var arg0 = _platform.api2wire_String(path); return _platform.executeNormal(FlutterRustBridgeTask( - callFfi: (port_) => _platform.inner - .wire_create_descriptor_secret(port_, arg0, arg1, arg2), + callFfi: (port_) => + _platform.inner.wire_create_derivation_path(port_, arg0), parseSuccessData: _wire2api_String, - constMeta: kCreateDescriptorSecretConstMeta, - argValues: [network, mnemonic, password], + constMeta: kCreateDerivationPathConstMeta, + argValues: [path], hint: hint, )); } - FlutterRustBridgeTaskConstMeta get kCreateDescriptorSecretConstMeta => + FlutterRustBridgeTaskConstMeta get kCreateDerivationPathConstMeta => const FlutterRustBridgeTaskConstMeta( - debugName: "create_descriptor_secret", - argNames: ["network", "mnemonic", "password"], + debugName: "create_derivation_path", + argNames: ["path"], ); - Future createDerivationPath({required String path, dynamic hint}) { - var arg0 = _platform.api2wire_String(path); + Future descriptorPublicFromString( + {required String publicKey, dynamic hint}) { + var arg0 = _platform.api2wire_String(publicKey); return _platform.executeNormal(FlutterRustBridgeTask( callFfi: (port_) => - _platform.inner.wire_create_derivation_path(port_, arg0), + _platform.inner.wire_descriptor_public_from_string(port_, arg0), parseSuccessData: _wire2api_String, - constMeta: kCreateDerivationPathConstMeta, - argValues: [path], + constMeta: kDescriptorPublicFromStringConstMeta, + argValues: [publicKey], hint: hint, )); } - FlutterRustBridgeTaskConstMeta get kCreateDerivationPathConstMeta => + FlutterRustBridgeTaskConstMeta get kDescriptorPublicFromStringConstMeta => const FlutterRustBridgeTaskConstMeta( - debugName: "create_derivation_path", - argNames: ["path"], + debugName: "descriptor_public_from_string", + argNames: ["publicKey"], ); Future createDescriptorPublic( @@ -758,7 +835,7 @@ class RustImpl implements Rust { required AddressIndex addressIndex, dynamic hint}) { var arg0 = _platform.api2wire_WalletInstance(wallet); - var arg1 = api2wire_address_index(addressIndex); + var arg1 = _platform.api2wire_box_autoadd_address_index(addressIndex); return _platform.executeNormal(FlutterRustBridgeTask( callFfi: (port_) => _platform.inner.wire_get_address(port_, arg0, arg1), parseSuccessData: _wire2api_address_info, @@ -774,6 +851,28 @@ class RustImpl implements Rust { argNames: ["wallet", "addressIndex"], ); + Future getInternalizedAddress( + {required WalletInstance wallet, + required AddressIndex addressIndex, + dynamic hint}) { + var arg0 = _platform.api2wire_WalletInstance(wallet); + var arg1 = _platform.api2wire_box_autoadd_address_index(addressIndex); + return _platform.executeNormal(FlutterRustBridgeTask( + callFfi: (port_) => + _platform.inner.wire_get_internalized_address(port_, arg0, arg1), + parseSuccessData: _wire2api_address_info, + constMeta: kGetInternalizedAddressConstMeta, + argValues: [wallet, addressIndex], + hint: hint, + )); + } + + FlutterRustBridgeTaskConstMeta get kGetInternalizedAddressConstMeta => + const FlutterRustBridgeTaskConstMeta( + debugName: "get_internalized_address", + argNames: ["wallet", "addressIndex"], + ); + Future syncWallet( {required WalletInstance wallet, required BlockchainInstance blockchain, @@ -964,25 +1063,6 @@ class RustImpl implements Rust { argNames: ["entropy"], ); - 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 => @@ -1067,8 +1147,8 @@ class RustImpl implements Rust { return _wire2api_block_time(raw); } - FeeRate _wire2api_box_autoadd_fee_rate(dynamic raw) { - return _wire2api_fee_rate(raw); + double _wire2api_box_autoadd_f32(dynamic raw) { + return raw as double; } int _wire2api_box_autoadd_u64(dynamic raw) { @@ -1079,16 +1159,6 @@ 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; } @@ -1124,8 +1194,8 @@ 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); + double? _wire2api_opt_box_autoadd_f32(dynamic raw) { + return raw == null ? null : _wire2api_box_autoadd_f32(raw); } int? _wire2api_opt_box_autoadd_u64(dynamic raw) { @@ -1198,11 +1268,6 @@ class RustImpl implements Rust { // Section: api2wire -@protected -int api2wire_address_index(AddressIndex raw) { - return api2wire_i32(raw.index); -} - @protected bool api2wire_bool(bool raw) { return raw; @@ -1283,6 +1348,14 @@ class RustPlatform extends FlutterRustBridgeBase { return ptr; } + @protected + ffi.Pointer api2wire_box_autoadd_address_index( + AddressIndex raw) { + final ptr = inner.new_box_autoadd_address_index_0(); + _api_fill_to_wire_address_index(raw, ptr.ref); + return ptr; + } + @protected ffi.Pointer api2wire_box_autoadd_blockchain_config( BlockchainConfig raw) { @@ -1320,13 +1393,6 @@ class RustPlatform extends FlutterRustBridgeBase { return inner.new_box_autoadd_f32_0(api2wire_f32(raw)); } - @protected - 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(); @@ -1484,6 +1550,32 @@ class RustPlatform extends FlutterRustBridgeBase { wireObj.ptr = apiObj.shareOrMove(); } + void _api_fill_to_wire_address_index( + AddressIndex apiObj, wire_AddressIndex wireObj) { + if (apiObj is AddressIndex_New) { + wireObj.tag = 0; + return; + } + if (apiObj is AddressIndex_LastUnused) { + wireObj.tag = 1; + return; + } + if (apiObj is AddressIndex_Peek) { + var pre_index = api2wire_u32(apiObj.index); + wireObj.tag = 2; + wireObj.kind = inner.inflate_AddressIndex_Peek(); + wireObj.kind.ref.Peek.ref.index = pre_index; + return; + } + if (apiObj is AddressIndex_Reset) { + var pre_index = api2wire_u32(apiObj.index); + wireObj.tag = 3; + wireObj.kind = inner.inflate_AddressIndex_Reset(); + wireObj.kind.ref.Reset.ref.index = pre_index; + return; + } + } + void _api_fill_to_wire_blockchain_config( BlockchainConfig apiObj, wire_BlockchainConfig wireObj) { if (apiObj is BlockchainConfig_Electrum) { @@ -1514,6 +1606,11 @@ class RustPlatform extends FlutterRustBridgeBase { _api_fill_to_wire_BdkDescriptor(apiObj, wireObj.ref); } + void _api_fill_to_wire_box_autoadd_address_index( + AddressIndex apiObj, ffi.Pointer wireObj) { + _api_fill_to_wire_address_index(apiObj, wireObj.ref); + } + void _api_fill_to_wire_box_autoadd_blockchain_config( BlockchainConfig apiObj, ffi.Pointer wireObj) { _api_fill_to_wire_blockchain_config(apiObj, wireObj.ref); @@ -1534,11 +1631,6 @@ class RustPlatform extends FlutterRustBridgeBase { _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); @@ -1609,10 +1701,6 @@ 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) @@ -1825,14 +1913,33 @@ class RustWire implements FlutterRustBridgeWireBase { late final _wire_get_blockchain_hash = _wire_get_blockchain_hashPtr .asFunction(); + void wire_estimate_fee( + int port_, + int target, + wire_BlockchainInstance blockchain, + ) { + return _wire_estimate_fee( + port_, + target, + blockchain, + ); + } + + late final _wire_estimate_feePtr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Int64, ffi.Uint64, + wire_BlockchainInstance)>>('wire_estimate_fee'); + late final _wire_estimate_fee = _wire_estimate_feePtr + .asFunction(); + void wire_broadcast( int port_, - ffi.Pointer psbt_str, + ffi.Pointer tx, wire_BlockchainInstance blockchain, ) { return _wire_broadcast( port_, - psbt_str, + tx, blockchain, ); } @@ -1845,6 +1952,23 @@ class RustWire implements FlutterRustBridgeWireBase { void Function( int, ffi.Pointer, wire_BlockchainInstance)>(); + void wire_new_transaction( + int port_, + ffi.Pointer tx, + ) { + return _wire_new_transaction( + port_, + tx, + ); + } + + late final _wire_new_transactionPtr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Int64, + ffi.Pointer)>>('wire_new_transaction'); + late final _wire_new_transaction = _wire_new_transactionPtr + .asFunction)>(); + void wire_psbt_to_txid( int port_, ffi.Pointer psbt_str, @@ -1879,21 +2003,21 @@ class RustWire implements FlutterRustBridgeWireBase { late final _wire_extract_tx = _wire_extract_txPtr .asFunction)>(); - void wire_get_fee_rate( + void wire_get_psbt_fee_rate( int port_, ffi.Pointer psbt_str, ) { - return _wire_get_fee_rate( + return _wire_get_psbt_fee_rate( port_, psbt_str, ); } - late final _wire_get_fee_ratePtr = _lookup< + late final _wire_get_psbt_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 + ffi.Void Function(ffi.Int64, + ffi.Pointer)>>('wire_get_psbt_fee_rate'); + late final _wire_get_psbt_fee_rate = _wire_get_psbt_fee_ratePtr .asFunction)>(); void wire_get_fee_amount( @@ -2247,6 +2371,47 @@ class RustWire implements FlutterRustBridgeWireBase { late final _wire_as_string = _wire_as_stringPtr.asFunction(); + void wire_create_descriptor_secret( + int port_, + int network, + ffi.Pointer mnemonic, + ffi.Pointer password, + ) { + return _wire_create_descriptor_secret( + port_, + network, + mnemonic, + password, + ); + } + + late final _wire_create_descriptor_secretPtr = _lookup< + 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)>(); + + void wire_descriptor_secret_from_string( + int port_, + ffi.Pointer xprv, + ) { + return _wire_descriptor_secret_from_string( + port_, + xprv, + ); + } + + late final _wire_descriptor_secret_from_stringPtr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Int64, ffi.Pointer)>>( + 'wire_descriptor_secret_from_string'); + late final _wire_descriptor_secret_from_string = + _wire_descriptor_secret_from_stringPtr + .asFunction)>(); + void wire_descriptor_secret_extend( int port_, ffi.Pointer xprv, @@ -2333,29 +2498,6 @@ class RustWire implements FlutterRustBridgeWireBase { void Function(int, ffi.Pointer, ffi.Pointer)>(); - void wire_create_descriptor_secret( - int port_, - int network, - ffi.Pointer mnemonic, - ffi.Pointer password, - ) { - return _wire_create_descriptor_secret( - port_, - network, - mnemonic, - password, - ); - } - - late final _wire_create_descriptor_secretPtr = _lookup< - 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)>(); - void wire_create_derivation_path( int port_, ffi.Pointer path, @@ -2373,6 +2515,24 @@ class RustWire implements FlutterRustBridgeWireBase { late final _wire_create_derivation_path = _wire_create_derivation_pathPtr .asFunction)>(); + void wire_descriptor_public_from_string( + int port_, + ffi.Pointer public_key, + ) { + return _wire_descriptor_public_from_string( + port_, + public_key, + ); + } + + late final _wire_descriptor_public_from_stringPtr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Int64, ffi.Pointer)>>( + 'wire_descriptor_public_from_string'); + late final _wire_descriptor_public_from_string = + _wire_descriptor_public_from_stringPtr + .asFunction)>(); + void wire_create_descriptor_public( int port_, ffi.Pointer xpub, @@ -2482,7 +2642,7 @@ class RustWire implements FlutterRustBridgeWireBase { void wire_get_address( int port_, wire_WalletInstance wallet, - int address_index, + ffi.Pointer address_index, ) { return _wire_get_address( port_, @@ -2493,10 +2653,33 @@ 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(); + ffi.Void Function(ffi.Int64, wire_WalletInstance, + ffi.Pointer)>>('wire_get_address'); + late final _wire_get_address = _wire_get_addressPtr.asFunction< + void Function( + int, wire_WalletInstance, ffi.Pointer)>(); + + void wire_get_internalized_address( + int port_, + wire_WalletInstance wallet, + ffi.Pointer address_index, + ) { + return _wire_get_internalized_address( + port_, + wallet, + address_index, + ); + } + + late final _wire_get_internalized_addressPtr = _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Int64, wire_WalletInstance, + ffi.Pointer)>>( + 'wire_get_internalized_address'); + late final _wire_get_internalized_address = + _wire_get_internalized_addressPtr.asFunction< + void Function( + int, wire_WalletInstance, ffi.Pointer)>(); void wire_sync_wallet( int port_, @@ -2677,24 +2860,6 @@ class RustWire implements FlutterRustBridgeWireBase { _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< - ffi.NativeFunction< - ffi.Void Function(ffi.Int64, ffi.Pointer)>>( - '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(); } @@ -2736,6 +2901,17 @@ class RustWire implements FlutterRustBridgeWireBase { _new_box_autoadd_BdkDescriptor_0Ptr .asFunction Function()>(); + ffi.Pointer new_box_autoadd_address_index_0() { + return _new_box_autoadd_address_index_0(); + } + + late final _new_box_autoadd_address_index_0Ptr = + _lookup Function()>>( + 'new_box_autoadd_address_index_0'); + late final _new_box_autoadd_address_index_0 = + _new_box_autoadd_address_index_0Ptr + .asFunction Function()>(); + ffi.Pointer new_box_autoadd_blockchain_config_0() { return _new_box_autoadd_blockchain_config_0(); } @@ -2794,16 +2970,6 @@ class RustWire implements FlutterRustBridgeWireBase { 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(); } @@ -3036,6 +3202,26 @@ class RustWire implements FlutterRustBridgeWireBase { late final _share_opaque_WalletInstance = _share_opaque_WalletInstancePtr .asFunction Function(ffi.Pointer)>(); + ffi.Pointer inflate_AddressIndex_Peek() { + return _inflate_AddressIndex_Peek(); + } + + late final _inflate_AddressIndex_PeekPtr = + _lookup Function()>>( + 'inflate_AddressIndex_Peek'); + late final _inflate_AddressIndex_Peek = _inflate_AddressIndex_PeekPtr + .asFunction Function()>(); + + ffi.Pointer inflate_AddressIndex_Reset() { + return _inflate_AddressIndex_Reset(); + } + + late final _inflate_AddressIndex_ResetPtr = + _lookup Function()>>( + 'inflate_AddressIndex_Reset'); + late final _inflate_AddressIndex_Reset = _inflate_AddressIndex_ResetPtr + .asFunction Function()>(); + ffi.Pointer inflate_BlockchainConfig_Electrum() { return _inflate_BlockchainConfig_Electrum(); } @@ -3279,9 +3465,35 @@ class wire_DatabaseConfig extends ffi.Struct { external ffi.Pointer kind; } -class wire_FeeRate extends ffi.Struct { - @ffi.Float() - external double field0; +class wire_AddressIndex_New extends ffi.Opaque {} + +class wire_AddressIndex_LastUnused extends ffi.Opaque {} + +class wire_AddressIndex_Peek extends ffi.Struct { + @ffi.Uint32() + external int index; +} + +class wire_AddressIndex_Reset extends ffi.Struct { + @ffi.Uint32() + external int index; +} + +class AddressIndexKind extends ffi.Union { + external ffi.Pointer New; + + external ffi.Pointer LastUnused; + + external ffi.Pointer Peek; + + external ffi.Pointer Reset; +} + +class wire_AddressIndex extends ffi.Struct { + @ffi.Int32() + external int tag; + + external ffi.Pointer kind; } typedef DartPostCObjectFnType = ffi.Pointer< diff --git a/lib/src/generated/bridge_definitions.dart b/lib/src/generated/bridge_definitions.dart index ae5623f2..3b8b54f9 100644 --- a/lib/src/generated/bridge_definitions.dart +++ b/lib/src/generated/bridge_definitions.dart @@ -1,9 +1,10 @@ // 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 +// Generated by `flutter_rust_bridge`@ 1.63.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, unnecessary_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:meta/meta.dart'; import 'package:flutter_rust_bridge/flutter_rust_bridge.dart'; import 'package:freezed_annotation/freezed_annotation.dart' hide protected; @@ -27,13 +28,24 @@ abstract class Rust { FlutterRustBridgeTaskConstMeta get kGetBlockchainHashConstMeta; + Future estimateFee( + {required int target, + required BlockchainInstance blockchain, + dynamic hint}); + + FlutterRustBridgeTaskConstMeta get kEstimateFeeConstMeta; + Future broadcast( - {required String psbtStr, + {required Uint8List tx, required BlockchainInstance blockchain, dynamic hint}); FlutterRustBridgeTaskConstMeta get kBroadcastConstMeta; + Future newTransaction({required Uint8List tx, dynamic hint}); + + FlutterRustBridgeTaskConstMeta get kNewTransactionConstMeta; + Future psbtToTxid({required String psbtStr, dynamic hint}); FlutterRustBridgeTaskConstMeta get kPsbtToTxidConstMeta; @@ -42,9 +54,9 @@ abstract class Rust { FlutterRustBridgeTaskConstMeta get kExtractTxConstMeta; - Future getFeeRate({required String psbtStr, dynamic hint}); + Future getPsbtFeeRate({required String psbtStr, dynamic hint}); - FlutterRustBridgeTaskConstMeta get kGetFeeRateConstMeta; + FlutterRustBridgeTaskConstMeta get kGetPsbtFeeRateConstMeta; Future getFeeAmount({required String psbtStr, dynamic hint}); @@ -150,6 +162,19 @@ abstract class Rust { FlutterRustBridgeTaskConstMeta get kAsStringConstMeta; + Future createDescriptorSecret( + {required Network network, + required String mnemonic, + String? password, + dynamic hint}); + + FlutterRustBridgeTaskConstMeta get kCreateDescriptorSecretConstMeta; + + Future descriptorSecretFromString( + {required String xprv, dynamic hint}); + + FlutterRustBridgeTaskConstMeta get kDescriptorSecretFromStringConstMeta; + Future descriptorSecretExtend( {required String xprv, required String path, dynamic hint}); @@ -170,18 +195,15 @@ abstract class Rust { 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 descriptorPublicFromString( + {required String publicKey, dynamic hint}); + + FlutterRustBridgeTaskConstMeta get kDescriptorPublicFromStringConstMeta; + Future createDescriptorPublic( {String? xpub, required String path, required bool derive, dynamic hint}); @@ -216,6 +238,13 @@ abstract class Rust { FlutterRustBridgeTaskConstMeta get kGetAddressConstMeta; + Future getInternalizedAddress( + {required WalletInstance wallet, + required AddressIndex addressIndex, + dynamic hint}); + + FlutterRustBridgeTaskConstMeta get kGetInternalizedAddressConstMeta; + Future syncWallet( {required WalletInstance wallet, required BlockchainInstance blockchain, @@ -269,10 +298,6 @@ abstract class Rust { FlutterRustBridgeTaskConstMeta get kGenerateSeedFromEntropyConstMeta; - Future asSatPerVbMethodFeeRate({required FeeRate that, dynamic hint}); - - FlutterRustBridgeTaskConstMeta get kAsSatPerVbMethodFeeRateConstMeta; - DropFnType get dropOpaqueBdkDescriptor; ShareFnType get shareOpaqueBdkDescriptor; OpaqueTypeFinalizer get BdkDescriptorFinalizer; @@ -331,15 +356,33 @@ class WalletInstance extends FrbOpaque { OpaqueTypeFinalizer get staticFinalizer => bridge.WalletInstanceFinalizer; } -/// The address index selection strategy to use to derived an address from the wallet's external -/// descriptor. -enum AddressIndex { +@freezed +class AddressIndex with _$AddressIndex { ///Return a new address after incrementing the current descriptor index. - New, + const factory AddressIndex.new() = AddressIndex_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, + const factory AddressIndex.lastUnused() = AddressIndex_LastUnused; + + /// Return the address for a specific descriptor index. Does not change the current descriptor + /// index used by `AddressIndex` and `AddressIndex.LastUsed`. + /// Use with caution, if an index is given that is less than the current descriptor index + /// then the returned address may have already been used. + const factory AddressIndex.peek({ + required int index, + }) = AddressIndex_Peek; + + /// Return the address for a specific descriptor index and reset the current descriptor index + /// used by `AddressIndex` and `AddressIndex.LastUsed` to this value. + /// Use with caution, if an index is given that is less than the current descriptor index + /// then the returned address and subsequent addresses returned by calls to `AddressIndex` + /// and `AddressIndex.LastUsed` may have already been used. Also if the index is reset to a + /// value earlier than the Blockchain stopGap (default is 20) then a + /// larger stopGap should be used to monitor for all possibly used addresses. + const factory AddressIndex.reset({ + required int index, + }) = AddressIndex_Reset; } ///A derived address and the index it was found at For convenience this automatically derefs to Address @@ -494,20 +537,6 @@ class EsploraConfig { }); } -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, diff --git a/lib/src/generated/bridge_definitions.freezed.dart b/lib/src/generated/bridge_definitions.freezed.dart index ab6e669b..87f2d20f 100644 --- a/lib/src/generated/bridge_definitions.freezed.dart +++ b/lib/src/generated/bridge_definitions.freezed.dart @@ -14,6 +14,600 @@ T _$identity(T value) => value; final _privateConstructorUsedError = UnsupportedError( 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#custom-getters-and-methods'); +/// @nodoc +mixin _$AddressIndex { + @optionalTypeArgs + TResult when( + TResult Function() $default, { + required TResult Function() lastUnused, + required TResult Function(int index) peek, + required TResult Function(int index) reset, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? whenOrNull( + TResult? Function()? $default, { + TResult? Function()? lastUnused, + TResult? Function(int index)? peek, + TResult? Function(int index)? reset, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeWhen( + TResult Function()? $default, { + TResult Function()? lastUnused, + TResult Function(int index)? peek, + TResult Function(int index)? reset, + required TResult orElse(), + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult map( + TResult Function(AddressIndex_New value) $default, { + required TResult Function(AddressIndex_LastUnused value) lastUnused, + required TResult Function(AddressIndex_Peek value) peek, + required TResult Function(AddressIndex_Reset value) reset, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? mapOrNull( + TResult? Function(AddressIndex_New value)? $default, { + TResult? Function(AddressIndex_LastUnused value)? lastUnused, + TResult? Function(AddressIndex_Peek value)? peek, + TResult? Function(AddressIndex_Reset value)? reset, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeMap( + TResult Function(AddressIndex_New value)? $default, { + TResult Function(AddressIndex_LastUnused value)? lastUnused, + TResult Function(AddressIndex_Peek value)? peek, + TResult Function(AddressIndex_Reset value)? reset, + required TResult orElse(), + }) => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $AddressIndexCopyWith<$Res> { + factory $AddressIndexCopyWith( + AddressIndex value, $Res Function(AddressIndex) then) = + _$AddressIndexCopyWithImpl<$Res, AddressIndex>; +} + +/// @nodoc +class _$AddressIndexCopyWithImpl<$Res, $Val extends AddressIndex> + implements $AddressIndexCopyWith<$Res> { + _$AddressIndexCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; +} + +/// @nodoc +abstract class _$$AddressIndex_NewCopyWith<$Res> { + factory _$$AddressIndex_NewCopyWith( + _$AddressIndex_New value, $Res Function(_$AddressIndex_New) then) = + __$$AddressIndex_NewCopyWithImpl<$Res>; +} + +/// @nodoc +class __$$AddressIndex_NewCopyWithImpl<$Res> + extends _$AddressIndexCopyWithImpl<$Res, _$AddressIndex_New> + implements _$$AddressIndex_NewCopyWith<$Res> { + __$$AddressIndex_NewCopyWithImpl( + _$AddressIndex_New _value, $Res Function(_$AddressIndex_New) _then) + : super(_value, _then); +} + +/// @nodoc + +class _$AddressIndex_New implements AddressIndex_New { + const _$AddressIndex_New(); + + @override + String toString() { + return 'AddressIndex()'; + } + + @override + bool operator ==(dynamic other) { + return identical(this, other) || + (other.runtimeType == runtimeType && other is _$AddressIndex_New); + } + + @override + int get hashCode => runtimeType.hashCode; + + @override + @optionalTypeArgs + TResult when( + TResult Function() $default, { + required TResult Function() lastUnused, + required TResult Function(int index) peek, + required TResult Function(int index) reset, + }) { + return $default(); + } + + @override + @optionalTypeArgs + TResult? whenOrNull( + TResult? Function()? $default, { + TResult? Function()? lastUnused, + TResult? Function(int index)? peek, + TResult? Function(int index)? reset, + }) { + return $default?.call(); + } + + @override + @optionalTypeArgs + TResult maybeWhen( + TResult Function()? $default, { + TResult Function()? lastUnused, + TResult Function(int index)? peek, + TResult Function(int index)? reset, + required TResult orElse(), + }) { + if ($default != null) { + return $default(); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map( + TResult Function(AddressIndex_New value) $default, { + required TResult Function(AddressIndex_LastUnused value) lastUnused, + required TResult Function(AddressIndex_Peek value) peek, + required TResult Function(AddressIndex_Reset value) reset, + }) { + return $default(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull( + TResult? Function(AddressIndex_New value)? $default, { + TResult? Function(AddressIndex_LastUnused value)? lastUnused, + TResult? Function(AddressIndex_Peek value)? peek, + TResult? Function(AddressIndex_Reset value)? reset, + }) { + return $default?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap( + TResult Function(AddressIndex_New value)? $default, { + TResult Function(AddressIndex_LastUnused value)? lastUnused, + TResult Function(AddressIndex_Peek value)? peek, + TResult Function(AddressIndex_Reset value)? reset, + required TResult orElse(), + }) { + if ($default != null) { + return $default(this); + } + return orElse(); + } +} + +abstract class AddressIndex_New implements AddressIndex { + const factory AddressIndex_New() = _$AddressIndex_New; +} + +/// @nodoc +abstract class _$$AddressIndex_LastUnusedCopyWith<$Res> { + factory _$$AddressIndex_LastUnusedCopyWith(_$AddressIndex_LastUnused value, + $Res Function(_$AddressIndex_LastUnused) then) = + __$$AddressIndex_LastUnusedCopyWithImpl<$Res>; +} + +/// @nodoc +class __$$AddressIndex_LastUnusedCopyWithImpl<$Res> + extends _$AddressIndexCopyWithImpl<$Res, _$AddressIndex_LastUnused> + implements _$$AddressIndex_LastUnusedCopyWith<$Res> { + __$$AddressIndex_LastUnusedCopyWithImpl(_$AddressIndex_LastUnused _value, + $Res Function(_$AddressIndex_LastUnused) _then) + : super(_value, _then); +} + +/// @nodoc + +class _$AddressIndex_LastUnused implements AddressIndex_LastUnused { + const _$AddressIndex_LastUnused(); + + @override + String toString() { + return 'AddressIndex.lastUnused()'; + } + + @override + bool operator ==(dynamic other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$AddressIndex_LastUnused); + } + + @override + int get hashCode => runtimeType.hashCode; + + @override + @optionalTypeArgs + TResult when( + TResult Function() $default, { + required TResult Function() lastUnused, + required TResult Function(int index) peek, + required TResult Function(int index) reset, + }) { + return lastUnused(); + } + + @override + @optionalTypeArgs + TResult? whenOrNull( + TResult? Function()? $default, { + TResult? Function()? lastUnused, + TResult? Function(int index)? peek, + TResult? Function(int index)? reset, + }) { + return lastUnused?.call(); + } + + @override + @optionalTypeArgs + TResult maybeWhen( + TResult Function()? $default, { + TResult Function()? lastUnused, + TResult Function(int index)? peek, + TResult Function(int index)? reset, + required TResult orElse(), + }) { + if (lastUnused != null) { + return lastUnused(); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map( + TResult Function(AddressIndex_New value) $default, { + required TResult Function(AddressIndex_LastUnused value) lastUnused, + required TResult Function(AddressIndex_Peek value) peek, + required TResult Function(AddressIndex_Reset value) reset, + }) { + return lastUnused(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull( + TResult? Function(AddressIndex_New value)? $default, { + TResult? Function(AddressIndex_LastUnused value)? lastUnused, + TResult? Function(AddressIndex_Peek value)? peek, + TResult? Function(AddressIndex_Reset value)? reset, + }) { + return lastUnused?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap( + TResult Function(AddressIndex_New value)? $default, { + TResult Function(AddressIndex_LastUnused value)? lastUnused, + TResult Function(AddressIndex_Peek value)? peek, + TResult Function(AddressIndex_Reset value)? reset, + required TResult orElse(), + }) { + if (lastUnused != null) { + return lastUnused(this); + } + return orElse(); + } +} + +abstract class AddressIndex_LastUnused implements AddressIndex { + const factory AddressIndex_LastUnused() = _$AddressIndex_LastUnused; +} + +/// @nodoc +abstract class _$$AddressIndex_PeekCopyWith<$Res> { + factory _$$AddressIndex_PeekCopyWith( + _$AddressIndex_Peek value, $Res Function(_$AddressIndex_Peek) then) = + __$$AddressIndex_PeekCopyWithImpl<$Res>; + @useResult + $Res call({int index}); +} + +/// @nodoc +class __$$AddressIndex_PeekCopyWithImpl<$Res> + extends _$AddressIndexCopyWithImpl<$Res, _$AddressIndex_Peek> + implements _$$AddressIndex_PeekCopyWith<$Res> { + __$$AddressIndex_PeekCopyWithImpl( + _$AddressIndex_Peek _value, $Res Function(_$AddressIndex_Peek) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? index = null, + }) { + return _then(_$AddressIndex_Peek( + index: null == index + ? _value.index + : index // ignore: cast_nullable_to_non_nullable + as int, + )); + } +} + +/// @nodoc + +class _$AddressIndex_Peek implements AddressIndex_Peek { + const _$AddressIndex_Peek({required this.index}); + + @override + final int index; + + @override + String toString() { + return 'AddressIndex.peek(index: $index)'; + } + + @override + bool operator ==(dynamic other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$AddressIndex_Peek && + (identical(other.index, index) || other.index == index)); + } + + @override + int get hashCode => Object.hash(runtimeType, index); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$AddressIndex_PeekCopyWith<_$AddressIndex_Peek> get copyWith => + __$$AddressIndex_PeekCopyWithImpl<_$AddressIndex_Peek>(this, _$identity); + + @override + @optionalTypeArgs + TResult when( + TResult Function() $default, { + required TResult Function() lastUnused, + required TResult Function(int index) peek, + required TResult Function(int index) reset, + }) { + return peek(index); + } + + @override + @optionalTypeArgs + TResult? whenOrNull( + TResult? Function()? $default, { + TResult? Function()? lastUnused, + TResult? Function(int index)? peek, + TResult? Function(int index)? reset, + }) { + return peek?.call(index); + } + + @override + @optionalTypeArgs + TResult maybeWhen( + TResult Function()? $default, { + TResult Function()? lastUnused, + TResult Function(int index)? peek, + TResult Function(int index)? reset, + required TResult orElse(), + }) { + if (peek != null) { + return peek(index); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map( + TResult Function(AddressIndex_New value) $default, { + required TResult Function(AddressIndex_LastUnused value) lastUnused, + required TResult Function(AddressIndex_Peek value) peek, + required TResult Function(AddressIndex_Reset value) reset, + }) { + return peek(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull( + TResult? Function(AddressIndex_New value)? $default, { + TResult? Function(AddressIndex_LastUnused value)? lastUnused, + TResult? Function(AddressIndex_Peek value)? peek, + TResult? Function(AddressIndex_Reset value)? reset, + }) { + return peek?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap( + TResult Function(AddressIndex_New value)? $default, { + TResult Function(AddressIndex_LastUnused value)? lastUnused, + TResult Function(AddressIndex_Peek value)? peek, + TResult Function(AddressIndex_Reset value)? reset, + required TResult orElse(), + }) { + if (peek != null) { + return peek(this); + } + return orElse(); + } +} + +abstract class AddressIndex_Peek implements AddressIndex { + const factory AddressIndex_Peek({required final int index}) = + _$AddressIndex_Peek; + + int get index; + @JsonKey(ignore: true) + _$$AddressIndex_PeekCopyWith<_$AddressIndex_Peek> get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$AddressIndex_ResetCopyWith<$Res> { + factory _$$AddressIndex_ResetCopyWith(_$AddressIndex_Reset value, + $Res Function(_$AddressIndex_Reset) then) = + __$$AddressIndex_ResetCopyWithImpl<$Res>; + @useResult + $Res call({int index}); +} + +/// @nodoc +class __$$AddressIndex_ResetCopyWithImpl<$Res> + extends _$AddressIndexCopyWithImpl<$Res, _$AddressIndex_Reset> + implements _$$AddressIndex_ResetCopyWith<$Res> { + __$$AddressIndex_ResetCopyWithImpl( + _$AddressIndex_Reset _value, $Res Function(_$AddressIndex_Reset) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? index = null, + }) { + return _then(_$AddressIndex_Reset( + index: null == index + ? _value.index + : index // ignore: cast_nullable_to_non_nullable + as int, + )); + } +} + +/// @nodoc + +class _$AddressIndex_Reset implements AddressIndex_Reset { + const _$AddressIndex_Reset({required this.index}); + + @override + final int index; + + @override + String toString() { + return 'AddressIndex.reset(index: $index)'; + } + + @override + bool operator ==(dynamic other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$AddressIndex_Reset && + (identical(other.index, index) || other.index == index)); + } + + @override + int get hashCode => Object.hash(runtimeType, index); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$AddressIndex_ResetCopyWith<_$AddressIndex_Reset> get copyWith => + __$$AddressIndex_ResetCopyWithImpl<_$AddressIndex_Reset>( + this, _$identity); + + @override + @optionalTypeArgs + TResult when( + TResult Function() $default, { + required TResult Function() lastUnused, + required TResult Function(int index) peek, + required TResult Function(int index) reset, + }) { + return reset(index); + } + + @override + @optionalTypeArgs + TResult? whenOrNull( + TResult? Function()? $default, { + TResult? Function()? lastUnused, + TResult? Function(int index)? peek, + TResult? Function(int index)? reset, + }) { + return reset?.call(index); + } + + @override + @optionalTypeArgs + TResult maybeWhen( + TResult Function()? $default, { + TResult Function()? lastUnused, + TResult Function(int index)? peek, + TResult Function(int index)? reset, + required TResult orElse(), + }) { + if (reset != null) { + return reset(index); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map( + TResult Function(AddressIndex_New value) $default, { + required TResult Function(AddressIndex_LastUnused value) lastUnused, + required TResult Function(AddressIndex_Peek value) peek, + required TResult Function(AddressIndex_Reset value) reset, + }) { + return reset(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull( + TResult? Function(AddressIndex_New value)? $default, { + TResult? Function(AddressIndex_LastUnused value)? lastUnused, + TResult? Function(AddressIndex_Peek value)? peek, + TResult? Function(AddressIndex_Reset value)? reset, + }) { + return reset?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap( + TResult Function(AddressIndex_New value)? $default, { + TResult Function(AddressIndex_LastUnused value)? lastUnused, + TResult Function(AddressIndex_Peek value)? peek, + TResult Function(AddressIndex_Reset value)? reset, + required TResult orElse(), + }) { + if (reset != null) { + return reset(this); + } + return orElse(); + } +} + +abstract class AddressIndex_Reset implements AddressIndex { + const factory AddressIndex_Reset({required final int index}) = + _$AddressIndex_Reset; + + int get index; + @JsonKey(ignore: true) + _$$AddressIndex_ResetCopyWith<_$AddressIndex_Reset> get copyWith => + throw _privateConstructorUsedError; +} + /// @nodoc mixin _$BlockchainConfig { Object get config => throw _privateConstructorUsedError; diff --git a/lib/src/root.dart b/lib/src/root.dart index 825667e6..9725d643 100644 --- a/lib/src/root.dart +++ b/lib/src/root.dart @@ -6,6 +6,45 @@ import 'package:flutter_rust_bridge/flutter_rust_bridge.dart'; import 'generated/bridge_definitions.dart'; import 'utils/utils.dart'; +///A Bitcoin address. +class Address { + String? _address; + Address._(); + Address _setAddress(String address) { + _address = address; + return this; + } + + /// Creates an instance of [Address] from address given. + /// + /// Throws a [BdkException] if the address is not valid + static Future
create({required String address}) async { + try { + final res = await loaderApi.initAddress(address: address); + return Address._()._setAddress(res); + } on FfiException catch (e) { + throw configException(e.message); + } + } + + /// Returns the script pub key of the [Address] object + Future