diff --git a/.github/workflows/precompile_binaries.yml b/.github/workflows/precompile_binaries.yml index 0804c5b0..a818c74d 100644 --- a/.github/workflows/precompile_binaries.yml +++ b/.github/workflows/precompile_binaries.yml @@ -37,7 +37,7 @@ jobs: uses: android-actions/setup-android@v2 - name: Install Specific NDK if: (matrix.os == 'ubuntu-20.04') - run: sdkmanager --install "ndk;24.0.8215888" + run: sdkmanager --install "ndk;25.1.8937393" - name: Precompile (with iOS) if: (matrix.os == 'macOS-latest') run: dart run build_tool precompile-binaries -v --manifest-dir=../../rust --repository=LtbLightning/bdk-flutter @@ -47,7 +47,7 @@ jobs: PRIVATE_KEY: ${{ secrets.CARGOKIT_PRIVATE_KEY }} - name: Precompile (with Android) if: (matrix.os == 'ubuntu-20.04') - run: dart run build_tool precompile-binaries -v --manifest-dir=../../rust --repository=LtbLightning/bdk-flutter --android-sdk-location=/usr/local/lib/android/sdk --android-ndk-version=24.0.8215888 --android-min-sdk-version=23 + run: dart run build_tool precompile-binaries -v --manifest-dir=../../rust --repository=LtbLightning/bdk-flutter --android-sdk-location=/usr/local/lib/android/sdk --android-ndk-version=25.1.8937393 --android-min-sdk-version=23 working-directory: cargokit/build_tool env: GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 77d8f273..09ada0ef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,11 @@ ## [0.31.3] +#### Upgrades +- Updated `Flutter` dependencies to the latest version. +- Upgraded `Gradle` to version 8.4 and `Java` to version 17. +- Upgraded `android-ndk` to `25.1.8937393`. +#### Fixed +- Removed unnecessary class exports. +- Resolved the `txBuilder.setRecipients` error. ## [0.31.2] Updated `flutter_rust_bridge` to `2.0.0`. diff --git a/android/build.gradle b/android/build.gradle index 6cc0c534..4a79fc4e 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -1,7 +1,6 @@ group 'io.bdk.f.bdk_flutter' -version '1.0-SNAPSHOT' +version '0.31.3' buildscript { - ext.kotlin_version = '1.6.10' repositories { google() mavenCentral() @@ -9,7 +8,6 @@ buildscript { dependencies { classpath 'com.android.tools.build:gradle:7.2.1' - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } @@ -22,33 +20,22 @@ allprojects { } apply plugin: 'com.android.library' -apply plugin: 'kotlin-android' android { - compileSdkVersion 31 - namespace "io.bdk.f.bdk_flutter" - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } - - kotlinOptions { - jvmTarget = '1.8' + if (project.android.hasProperty("namespace")) { + namespace "io.bdk.f.bdk_flutter" } - - sourceSets { - main.java.srcDirs += 'src/main/kotlin' + compileSdkVersion 33 + ndkVersion android.ndkVersion + compileOptions { + sourceCompatibility JavaVersion.VERSION_17 + targetCompatibility JavaVersion.VERSION_17 } defaultConfig { minSdkVersion 23 } } -dependencies { - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" - implementation 'androidx.databinding:databinding-runtime:7.2.1' - testImplementation 'junit:junit:4.13.2' -} apply from: "../cargokit/gradle/plugin.gradle" cargokit { diff --git a/android/gradle/wrapper/gradle-wrapper.jar b/android/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 7454180f..00000000 Binary files a/android/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index 2e6e5897..00000000 --- a/android/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,5 +0,0 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists diff --git a/cargokit/.github/workflows/check_and_lint.yml b/cargokit/.github/workflows/check_and_lint.yml index adec80e1..d8979f0e 100644 --- a/cargokit/.github/workflows/check_and_lint.yml +++ b/cargokit/.github/workflows/check_and_lint.yml @@ -10,8 +10,8 @@ jobs: Flutter: runs-on: ubuntu-latest steps: - - uses: actions/checkout@ee0669bd1cc54295c223e0bb666b733df41de1c5 #v2.7.0 - - uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d #1.6.0 + - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # 4.1.0 + - uses: subosito/flutter-action@44ac965b96f18d999802d4b807e3256d5a3f9fa1 # 2.16.0 - name: Pub Get run: dart pub get --no-precompile working-directory: build_tool @@ -22,5 +22,5 @@ jobs: run: dart analyze working-directory: build_tool - name: Test - run: dart test + run: flutter test working-directory: build_tool diff --git a/cargokit/.github/workflows/test_example_plugin_build.yml b/cargokit/.github/workflows/test_example_plugin_build.yml index bf36e862..698ea7e1 100644 --- a/cargokit/.github/workflows/test_example_plugin_build.yml +++ b/cargokit/.github/workflows/test_example_plugin_build.yml @@ -39,7 +39,7 @@ jobs: git clone -b advanced https://github.com/irondash/hello_rust_ffi_plugin cd hello_rust_ffi_plugin git subtree pull --prefix cargokit https://github.com/${{ github.event.pull_request.head.repo.full_name || github.repository }} ${{ steps.extract_branch.outputs.branch }} --squash - - uses: subosito/flutter-action@cc97e1648fff6ca5cc647fa67f47e70f7895510b # 2.11.0 + - uses: subosito/flutter-action@44ac965b96f18d999802d4b807e3256d5a3f9fa1 # 2.16.0 with: channel: "stable" - name: Install GTK @@ -77,6 +77,10 @@ jobs: shell: bash working-directory: ${{ env.EXAMPLE_DIR }} run: | - export JAVA_HOME=$JAVA_HOME_11_X64 + if [[ $(sysctl hw.optional.arm64) == *"hw.optional.arm64: 1"* ]]; then + export JAVA_HOME=$JAVA_HOME_17_arm64 + else + export JAVA_HOME=$JAVA_HOME_11_X64 + fi flutter build apk --${{ matrix.build_mode }} -v diff --git a/cargokit/gradle/plugin.gradle b/cargokit/gradle/plugin.gradle index 12c49f11..37dd086a 100644 --- a/cargokit/gradle/plugin.gradle +++ b/cargokit/gradle/plugin.gradle @@ -116,8 +116,12 @@ class CargoKitPlugin implements Plugin { } def cargoBuildDir = "${project.buildDir}/build" + + // Determine if the project is an application or library + def isApplication = plugin.project.plugins.hasPlugin('com.android.application') + def variants = isApplication ? plugin.project.android.applicationVariants : plugin.project.android.libraryVariants - plugin.project.android.applicationVariants.all { variant -> + variants.all { variant -> final buildType = variant.buildType.name diff --git a/cargokit/run_build_tool.sh b/cargokit/run_build_tool.sh index 6e594a23..24b0ed89 100755 --- a/cargokit/run_build_tool.sh +++ b/cargokit/run_build_tool.sh @@ -77,6 +77,11 @@ if [ ! -f "$PACKAGE_HASH_FILE" ]; then echo "$PACKAGE_HASH" > "$PACKAGE_HASH_FILE" fi +# Rebuild the tool if it was deleted by Android Studio +if [ ! -f "bin/build_tool_runner.dill" ]; then + "$DART" compile kernel bin/build_tool_runner.dart +fi + set +e "$DART" bin/build_tool_runner.dill "$@" diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index 6036f812..daf08401 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -1,56 +1,35 @@ -def localProperties = new Properties() -def localPropertiesFile = rootProject.file('local.properties') -if (localPropertiesFile.exists()) { - localPropertiesFile.withReader('UTF-8') { reader -> - localProperties.load(reader) - } -} - -def flutterRoot = localProperties.getProperty('flutter.sdk') -if (flutterRoot == null) { - throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") -} - -def flutterVersionCode = localProperties.getProperty('flutter.versionCode') -if (flutterVersionCode == null) { - flutterVersionCode = '1' -} -def flutterVersionName = localProperties.getProperty('flutter.versionName') -if (flutterVersionName == null) { - flutterVersionName = '1.0' +plugins { + id "com.android.application" + id "kotlin-android" + // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins. + id "dev.flutter.flutter-gradle-plugin" } -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" - android { - compileSdkVersion flutter.compileSdkVersion - ndkVersion flutter.ndkVersion + namespace = "io.bdk.f.bdk_flutter_example" + compileSdk = flutter.compileSdkVersion + ndkVersion "25.1.8937393" compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 + sourceCompatibility JavaVersion.VERSION_17 + targetCompatibility JavaVersion.VERSION_17 } - kotlinOptions { - jvmTarget = '1.8' + jvmTarget = JavaVersion.VERSION_17 } - sourceSets { - main.java.srcDirs += 'src/main/kotlin' - } + defaultConfig { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId "io.bdk.f.bdk_flutter_example" // You can update the following values to match your application needs. // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration. - minSdkVersion 23 - targetSdkVersion flutter.targetSdkVersion - versionCode flutterVersionCode.toInteger() - versionName flutterVersionName + minSdk = 23 + targetSdk = flutter.targetSdkVersion + versionCode = flutter.versionCode + versionName = flutter.versionName } buildTypes { @@ -60,13 +39,9 @@ android { signingConfig signingConfigs.debug } } - namespace 'io.bdk.f.bdk_flutter_example' } flutter { source '../..' } -dependencies { - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" -} diff --git a/example/android/build.gradle b/example/android/build.gradle index 5c8d9b8f..8e9de9d8 100644 --- a/example/android/build.gradle +++ b/example/android/build.gradle @@ -1,16 +1,3 @@ -buildscript { - ext.kotlin_version = '1.7.10' - repositories { - google() - mavenCentral() - } - - dependencies { - classpath 'com.android.tools.build:gradle:7.2.1' - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - } -} - allprojects { repositories { google() @@ -18,14 +5,14 @@ allprojects { } } -rootProject.buildDir = '../build' +rootProject.buildDir = "../build" subprojects { project.buildDir = "${rootProject.buildDir}/${project.name}" } subprojects { - project.evaluationDependsOn(':app') + project.evaluationDependsOn(":app") } tasks.register("clean", Delete) { delete rootProject.buildDir -} +} \ No newline at end of file diff --git a/example/android/gradle/wrapper/gradle-wrapper.properties b/example/android/gradle/wrapper/gradle-wrapper.properties index cc5527d7..5e6b5427 100644 --- a/example/android/gradle/wrapper/gradle-wrapper.properties +++ b/example/android/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,5 @@ -#Fri Jun 23 08:50:38 CEST 2017 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-all.zip diff --git a/example/android/settings.gradle b/example/android/settings.gradle index 44e62bcf..814e3704 100644 --- a/example/android/settings.gradle +++ b/example/android/settings.gradle @@ -1,11 +1,24 @@ -include ':app' +pluginManagement { + def flutterSdkPath = { + def properties = new Properties() + file("local.properties").withInputStream { properties.load(it) } + def flutterSdkPath = properties.getProperty("flutter.sdk") + assert flutterSdkPath != null, "flutter.sdk not set in local.properties" + return flutterSdkPath + }() -def localPropertiesFile = new File(rootProject.projectDir, "local.properties") -def properties = new Properties() + includeBuild("$flutterSdkPath/packages/flutter_tools/gradle") -assert localPropertiesFile.exists() -localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } + repositories { + google() + mavenCentral() + gradlePluginPortal() + } +} +plugins { + id "dev.flutter.flutter-plugin-loader" version "1.0.0" + id "com.android.application" version "8.3.1" apply false + id "org.jetbrains.kotlin.android" version "1.8.22" apply false +} -def flutterSdkPath = properties.getProperty("flutter.sdk") -assert flutterSdkPath != null, "flutter.sdk not set in local.properties" -apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" +include ":app" \ No newline at end of file diff --git a/ios/Classes/frb_generated.h b/ios/Classes/frb_generated.h index 5c3e0c91..2430b240 100644 --- a/ios/Classes/frb_generated.h +++ b/ios/Classes/frb_generated.h @@ -906,7 +906,7 @@ typedef struct wire_cst_satisfiable_item { } wire_cst_satisfiable_item; void frbgen_bdk_flutter_wire__crate__api__blockchain__bdk_blockchain_broadcast(int64_t port_, - struct wire_cst_bdk_blockchain *that, + struct wire_cst_bdk_blockchain *ptr, struct wire_cst_bdk_transaction *transaction); void frbgen_bdk_flutter_wire__crate__api__blockchain__bdk_blockchain_create(int64_t port_, @@ -1153,7 +1153,7 @@ void frbgen_bdk_flutter_wire__crate__api__wallet__bdk_wallet_get_psbt_input(int6 bool only_witness_utxo, struct wire_cst_psbt_sig_hash_type *sighash_type); -WireSyncRust2DartDco frbgen_bdk_flutter_wire__crate__api__wallet__bdk_wallet_is_mine(struct wire_cst_bdk_wallet *that, +WireSyncRust2DartDco frbgen_bdk_flutter_wire__crate__api__wallet__bdk_wallet_is_mine(struct wire_cst_bdk_wallet *ptr, struct wire_cst_bdk_script_buf *script); WireSyncRust2DartDco frbgen_bdk_flutter_wire__crate__api__wallet__bdk_wallet_list_transactions(struct wire_cst_bdk_wallet *that, diff --git a/lib/bdk_flutter.dart b/lib/bdk_flutter.dart index 04948352..3f8a0457 100644 --- a/lib/bdk_flutter.dart +++ b/lib/bdk_flutter.dart @@ -2,41 +2,41 @@ library bdk_flutter; export './src/generated/api/blockchain.dart' - hide - BdkBlockchain, - BlockchainConfig_Electrum, - BlockchainConfig_Esplora, - Auth_Cookie, - Auth_UserPass, - Auth_None, - BlockchainConfig_Rpc; -export './src/generated/api/descriptor.dart' hide BdkDescriptor; -export './src/generated/api/key.dart' - hide - BdkDerivationPath, - BdkDescriptorPublicKey, - BdkDescriptorSecretKey, - BdkMnemonic; -export './src/generated/api/psbt.dart' hide BdkPsbt; + show + Auth, + BlockchainConfig, + ElectrumConfig, + EsploraConfig, + RpcConfig, + RpcSyncParams; + export './src/generated/api/types.dart' - hide - BdkScriptBuf, - BdkTransaction, - AddressIndex_Reset, - LockTime_Blocks, - LockTime_Seconds, - BdkAddress, - AddressIndex_Peek, - AddressIndex_Increase, - AddressIndex_LastUnused, - Payload_PubkeyHash, - Payload_ScriptHash, - Payload_WitnessProgram, - DatabaseConfig_Sled, - DatabaseConfig_Memory, - RbfValue_RbfDefault, - RbfValue_Value, - DatabaseConfig_Sqlite; + show + AddressIndex, + Balance, + BlockTime, + ChangeSpendPolicy, + Condition, + DatabaseConfig, + FeeRate, + Input, + KeychainKind, + LocalUtxo, + LockTime, + Network, + OutPoint, + Payload, + PkOrF, + PsbtSigHashType, + RbfValue, + Satisfaction, + SatisfiableItem, + SignOptions, + SledDbConfiguration, + SqliteDbConfiguration, + Variant, + WitnessVersion, + WordCount; export './src/generated/api/wallet.dart' hide BdkWallet, finishBumpFeeTxBuilder, txBuilderFinish; export './src/root.dart'; diff --git a/lib/src/generated/api/blockchain.dart b/lib/src/generated/api/blockchain.dart index f4be0008..469d95ee 100644 --- a/lib/src/generated/api/blockchain.dart +++ b/lib/src/generated/api/blockchain.dart @@ -44,9 +44,10 @@ class BdkBlockchain { required this.ptr, }); - Future broadcast({required BdkTransaction transaction}) => + static Future broadcast( + {required BdkBlockchain ptr, required BdkTransaction transaction}) => core.instance.api.crateApiBlockchainBdkBlockchainBroadcast( - that: this, transaction: transaction); + ptr: ptr, transaction: transaction); static Future create( {required BlockchainConfig blockchainConfig}) => diff --git a/lib/src/generated/api/wallet.dart b/lib/src/generated/api/wallet.dart index f5e19dd4..e3a5ff39 100644 --- a/lib/src/generated/api/wallet.dart +++ b/lib/src/generated/api/wallet.dart @@ -112,8 +112,8 @@ class BdkWallet { onlyWitnessUtxo: onlyWitnessUtxo, sighashType: sighashType); - bool isMine({required BdkScriptBuf script}) => core.instance.api - .crateApiWalletBdkWalletIsMine(that: this, script: script); + static bool isMine({required BdkWallet ptr, required BdkScriptBuf script}) => + core.instance.api.crateApiWalletBdkWalletIsMine(ptr: ptr, script: script); /// Return the list of transactions made and received by the wallet. Note that this method only operate on the internal database, which first needs to be [Wallet.sync] manually. List listTransactions({required bool includeRaw}) => diff --git a/lib/src/generated/frb_generated.dart b/lib/src/generated/frb_generated.dart index 0c5ea9d6..8d2b34e9 100644 --- a/lib/src/generated/frb_generated.dart +++ b/lib/src/generated/frb_generated.dart @@ -74,7 +74,7 @@ class core extends BaseEntrypoint { abstract class coreApi extends BaseApi { Future crateApiBlockchainBdkBlockchainBroadcast( - {required BdkBlockchain that, required BdkTransaction transaction}); + {required BdkBlockchain ptr, required BdkTransaction transaction}); Future crateApiBlockchainBdkBlockchainCreate( {required BlockchainConfig blockchainConfig}); @@ -316,7 +316,7 @@ abstract class coreApi extends BaseApi { PsbtSigHashType? sighashType}); bool crateApiWalletBdkWalletIsMine( - {required BdkWallet that, required BdkScriptBuf script}); + {required BdkWallet ptr, required BdkScriptBuf script}); List crateApiWalletBdkWalletListTransactions( {required BdkWallet that, required bool includeRaw}); @@ -467,10 +467,10 @@ class coreApiImpl extends coreApiImplPlatform implements coreApi { @override Future crateApiBlockchainBdkBlockchainBroadcast( - {required BdkBlockchain that, required BdkTransaction transaction}) { + {required BdkBlockchain ptr, required BdkTransaction transaction}) { return handler.executeNormal(NormalTask( callFfi: (port_) { - var arg0 = cst_encode_box_autoadd_bdk_blockchain(that); + var arg0 = cst_encode_box_autoadd_bdk_blockchain(ptr); var arg1 = cst_encode_box_autoadd_bdk_transaction(transaction); return wire.wire__crate__api__blockchain__bdk_blockchain_broadcast( port_, arg0, arg1); @@ -480,7 +480,7 @@ class coreApiImpl extends coreApiImplPlatform implements coreApi { decodeErrorData: dco_decode_bdk_error, ), constMeta: kCrateApiBlockchainBdkBlockchainBroadcastConstMeta, - argValues: [that, transaction], + argValues: [ptr, transaction], apiImpl: this, )); } @@ -488,7 +488,7 @@ class coreApiImpl extends coreApiImplPlatform implements coreApi { TaskConstMeta get kCrateApiBlockchainBdkBlockchainBroadcastConstMeta => const TaskConstMeta( debugName: "bdk_blockchain_broadcast", - argNames: ["that", "transaction"], + argNames: ["ptr", "transaction"], ); @override @@ -2488,10 +2488,10 @@ class coreApiImpl extends coreApiImplPlatform implements coreApi { @override bool crateApiWalletBdkWalletIsMine( - {required BdkWallet that, required BdkScriptBuf script}) { + {required BdkWallet ptr, required BdkScriptBuf script}) { return handler.executeSync(SyncTask( callFfi: () { - var arg0 = cst_encode_box_autoadd_bdk_wallet(that); + var arg0 = cst_encode_box_autoadd_bdk_wallet(ptr); var arg1 = cst_encode_box_autoadd_bdk_script_buf(script); return wire.wire__crate__api__wallet__bdk_wallet_is_mine(arg0, arg1); }, @@ -2500,7 +2500,7 @@ class coreApiImpl extends coreApiImplPlatform implements coreApi { decodeErrorData: dco_decode_bdk_error, ), constMeta: kCrateApiWalletBdkWalletIsMineConstMeta, - argValues: [that, script], + argValues: [ptr, script], apiImpl: this, )); } @@ -2508,7 +2508,7 @@ class coreApiImpl extends coreApiImplPlatform implements coreApi { TaskConstMeta get kCrateApiWalletBdkWalletIsMineConstMeta => const TaskConstMeta( debugName: "bdk_wallet_is_mine", - argNames: ["that", "script"], + argNames: ["ptr", "script"], ); @override diff --git a/lib/src/generated/frb_generated.io.dart b/lib/src/generated/frb_generated.io.dart index 1fe9f306..2b17a149 100644 --- a/lib/src/generated/frb_generated.io.dart +++ b/lib/src/generated/frb_generated.io.dart @@ -3844,12 +3844,12 @@ class coreWire implements BaseWire { void wire__crate__api__blockchain__bdk_blockchain_broadcast( int port_, - ffi.Pointer that, + ffi.Pointer ptr, ffi.Pointer transaction, ) { return _wire__crate__api__blockchain__bdk_blockchain_broadcast( port_, - that, + ptr, transaction, ); } @@ -5501,11 +5501,11 @@ class coreWire implements BaseWire { ffi.Pointer)>(); WireSyncRust2DartDco wire__crate__api__wallet__bdk_wallet_is_mine( - ffi.Pointer that, + ffi.Pointer ptr, ffi.Pointer script, ) { return _wire__crate__api__wallet__bdk_wallet_is_mine( - that, + ptr, script, ); } diff --git a/lib/src/root.dart b/lib/src/root.dart index e9a856bb..fe73e4f0 100644 --- a/lib/src/root.dart +++ b/lib/src/root.dart @@ -1,6 +1,4 @@ import 'dart:typed_data'; - -import 'package:bdk_flutter/bdk_flutter.dart'; import 'package:bdk_flutter/src/utils/utils.dart'; import 'generated/api/blockchain.dart'; @@ -8,19 +6,20 @@ import 'generated/api/descriptor.dart'; import 'generated/api/error.dart'; import 'generated/api/key.dart'; import 'generated/api/psbt.dart'; -import 'generated/api/types.dart'; +import 'generated/api/types.dart' as types; import 'generated/api/wallet.dart'; ///A Bitcoin address. -class Address extends BdkAddress { +class Address extends types.BdkAddress { Address._({required super.ptr}); /// [Address] constructor static Future
fromScript( - {required ScriptBuf script, required Network network}) async { + {required ScriptBuf script, required types.Network network}) async { try { await Api.initialize(); - final res = await BdkAddress.fromScript(script: script, network: network); + final res = + await types.BdkAddress.fromScript(script: script, network: network); return Address._(ptr: res.ptr); } on BdkError catch (e) { throw mapBdkError(e); @@ -29,10 +28,11 @@ class Address extends BdkAddress { /// [Address] constructor static Future
fromString( - {required String s, required Network network}) async { + {required String s, required types.Network network}) async { try { await Api.initialize(); - final res = await BdkAddress.fromString(address: s, network: network); + final res = + await types.BdkAddress.fromString(address: s, network: network); return Address._(ptr: res.ptr); } on BdkError catch (e) { throw mapBdkError(e); @@ -42,7 +42,7 @@ class Address extends BdkAddress { ///Generates a script pubkey spending to this address ScriptBuf scriptPubkey() { try { - return ScriptBuf(bytes: BdkAddress.script(ptr: this).bytes); + return ScriptBuf(bytes: types.BdkAddress.script(ptr: this).bytes); } on BdkError catch (e) { throw mapBdkError(e); } @@ -66,7 +66,7 @@ class Address extends BdkAddress { ///When parsing, such addresses are always assumed to be testnet addresses (the same is true for bech32 signet addresses). ///So if one wants to check if an address belongs to a certain network a simple comparison is not enough anymore. Instead this function can be used. @override - bool isValidForNetwork({required Network network}) { + bool isValidForNetwork({required types.Network network}) { try { return super.isValidForNetwork(network: network); } on BdkError catch (e) { @@ -76,7 +76,7 @@ class Address extends BdkAddress { ///The network on which this address is usable. @override - Network network() { + types.Network network() { try { return super.network(); } on BdkError catch (e) { @@ -86,7 +86,7 @@ class Address extends BdkAddress { ///The type of the address. @override - Payload payload() { + types.Payload payload() { try { return super.payload(); } on BdkError catch (e) { @@ -146,7 +146,7 @@ class Blockchain extends BdkBlockchain { ///Estimate the fee rate required to confirm a transaction in a given target of blocks @override - Future estimateFee({required BigInt target, hint}) async { + Future estimateFee({required BigInt target, hint}) async { try { return super.estimateFee(target: target); } on BdkError catch (e) { @@ -155,10 +155,9 @@ class Blockchain extends BdkBlockchain { } ///The function for broadcasting a transaction - @override - Future broadcast({required BdkTransaction transaction, hint}) async { + Future broadcast({required Transaction transaction, hint}) async { try { - return super.broadcast(transaction: transaction); + return BdkBlockchain.broadcast(ptr: this, transaction: transaction); } on BdkError catch (e) { throw mapBdkError(e); } @@ -235,7 +234,17 @@ class BumpFeeTxBuilder { wallet: wallet, nSequence: _nSequence, allowShrinking: _allowShrinking); - return (PartiallySignedTransaction._(ptr: res.$1.ptr), res.$2); + return ( + PartiallySignedTransaction._(ptr: res.$1.ptr), + TransactionDetails( + transaction: (res.$2.transaction?.s == null) + ? null + : Transaction._(s: res.$2.transaction!.s), + txid: res.$2.txid, + received: res.$2.received, + sent: res.$2.sent, + confirmationTime: res.$2.confirmationTime) + ); } on BdkError catch (e) { throw mapBdkError(e); } @@ -269,7 +278,7 @@ class Descriptor extends BdkDescriptor { /// [Descriptor] constructor static Future create( - {required String descriptor, required Network network}) async { + {required String descriptor, required types.Network network}) async { try { await Api.initialize(); final res = await BdkDescriptor.newInstance( @@ -286,8 +295,8 @@ class Descriptor extends BdkDescriptor { /// Since there are hardened derivation steps, this template requires a private derivable key (generally a xprv/tprv). static Future newBip44( {required DescriptorSecretKey secretKey, - required Network network, - required KeychainKind keychain}) async { + required types.Network network, + required types.KeychainKind keychain}) async { try { await Api.initialize(); final res = await BdkDescriptor.newBip44( @@ -307,8 +316,8 @@ class Descriptor extends BdkDescriptor { static Future newBip44Public( {required DescriptorPublicKey publicKey, required String fingerPrint, - required Network network, - required KeychainKind keychain}) async { + required types.Network network, + required types.KeychainKind keychain}) async { try { await Api.initialize(); final res = await BdkDescriptor.newBip44Public( @@ -328,8 +337,8 @@ class Descriptor extends BdkDescriptor { ///Since there are hardened derivation steps, this template requires a private derivable key (generally a xprv/tprv). static Future newBip49( {required DescriptorSecretKey secretKey, - required Network network, - required KeychainKind keychain}) async { + required types.Network network, + required types.KeychainKind keychain}) async { try { await Api.initialize(); final res = await BdkDescriptor.newBip49( @@ -349,8 +358,8 @@ class Descriptor extends BdkDescriptor { static Future newBip49Public( {required DescriptorPublicKey publicKey, required String fingerPrint, - required Network network, - required KeychainKind keychain}) async { + required types.Network network, + required types.KeychainKind keychain}) async { try { await Api.initialize(); final res = await BdkDescriptor.newBip49Public( @@ -370,8 +379,8 @@ class Descriptor extends BdkDescriptor { ///Since there are hardened derivation steps, this template requires a private derivable key (generally a xprv/tprv). static Future newBip84( {required DescriptorSecretKey secretKey, - required Network network, - required KeychainKind keychain}) async { + required types.Network network, + required types.KeychainKind keychain}) async { try { await Api.initialize(); final res = await BdkDescriptor.newBip84( @@ -391,8 +400,8 @@ class Descriptor extends BdkDescriptor { static Future newBip84Public( {required DescriptorPublicKey publicKey, required String fingerPrint, - required Network network, - required KeychainKind keychain}) async { + required types.Network network, + required types.KeychainKind keychain}) async { try { await Api.initialize(); final res = await BdkDescriptor.newBip84Public( @@ -412,8 +421,8 @@ class Descriptor extends BdkDescriptor { /// Since there are hardened derivation steps, this template requires a private derivable key (generally a xprv/tprv). static Future newBip86( {required DescriptorSecretKey secretKey, - required Network network, - required KeychainKind keychain}) async { + required types.Network network, + required types.KeychainKind keychain}) async { try { await Api.initialize(); final res = await BdkDescriptor.newBip86( @@ -433,8 +442,8 @@ class Descriptor extends BdkDescriptor { static Future newBip86Public( {required DescriptorPublicKey publicKey, required String fingerPrint, - required Network network, - required KeychainKind keychain}) async { + required types.Network network, + required types.KeychainKind keychain}) async { try { await Api.initialize(); final res = await BdkDescriptor.newBip86Public( @@ -537,7 +546,7 @@ class DescriptorSecretKey extends BdkDescriptorSecretKey { /// [DescriptorSecretKey] constructor static Future create( - {required Network network, + {required types.Network network, required Mnemonic mnemonic, String? password}) async { try { @@ -604,7 +613,7 @@ class Mnemonic extends BdkMnemonic { /// Generates [Mnemonic] with given [WordCount] /// /// [Mnemonic] constructor - static Future create(WordCount wordCount) async { + static Future create(types.WordCount wordCount) async { try { await Api.initialize(); final res = await BdkMnemonic.newInstance(wordCount: wordCount); @@ -678,7 +687,7 @@ class PartiallySignedTransaction extends BdkPsbt { ///Return fee rate @override - FeeRate? feeRate({hint}) { + types.FeeRate? feeRate({hint}) { try { return super.feeRate(); } on BdkError catch (e) { @@ -742,7 +751,7 @@ class PartiallySignedTransaction extends BdkPsbt { } } -class Policy extends BdkPolicy { +class Policy extends types.BdkPolicy { Policy._({required super.ptr}); ///Identifier for this policy node @@ -770,37 +779,43 @@ class Policy extends BdkPolicy { ///Type of this policy node @override - SatisfiableItem item() { + types.SatisfiableItem item() { return super.item().when( - ecdsaSignature: (e) => SatisfiableItem.ecdsaSignature(key: e), - schnorrSignature: (e) => SatisfiableItem.ecdsaSignature(key: e), - sha256Preimage: (e) => SatisfiableItem.sha256Preimage(hash: e), - hash256Preimage: (e) => SatisfiableItem.hash256Preimage(hash: e), - ripemd160Preimage: (e) => SatisfiableItem.ripemd160Preimage(hash: e), - hash160Preimage: (e) => SatisfiableItem.hash160Preimage(hash: e), - absoluteTimelock: (e) => SatisfiableItem.absoluteTimelock(value: e), - relativeTimelock: (e) => SatisfiableItem.relativeTimelock(value: e), - multisig: (e, f) => SatisfiableItem.multisig(keys: e, threshold: f), - thresh: (e, f) => SatisfiableItem.thresh( + ecdsaSignature: (e) => types.SatisfiableItem.ecdsaSignature(key: e), + schnorrSignature: (e) => types.SatisfiableItem.ecdsaSignature(key: e), + sha256Preimage: (e) => types.SatisfiableItem.sha256Preimage(hash: e), + hash256Preimage: (e) => + types.SatisfiableItem.hash256Preimage(hash: e), + ripemd160Preimage: (e) => + types.SatisfiableItem.ripemd160Preimage(hash: e), + hash160Preimage: (e) => + types.SatisfiableItem.hash160Preimage(hash: e), + absoluteTimelock: (e) => + types.SatisfiableItem.absoluteTimelock(value: e), + relativeTimelock: (e) => + types.SatisfiableItem.relativeTimelock(value: e), + multisig: (e, f) => + types.SatisfiableItem.multisig(keys: e, threshold: f), + thresh: (e, f) => types.SatisfiableItem.thresh( items: e.map((e) => Policy._(ptr: e.ptr)).toList(), threshold: f), ); } ///How much a given PSBT already satisfies this policy node in terms of signatures @override - Satisfaction satisfaction() { + types.Satisfaction satisfaction() { return super.satisfaction(); } ///How the wallet's descriptor can satisfy this policy node @override - Satisfaction contribution() { + types.Satisfaction contribution() { return super.contribution(); } } ///Bitcoin script. -class ScriptBuf extends BdkScriptBuf { +class ScriptBuf extends types.BdkScriptBuf { /// [ScriptBuf] constructor ScriptBuf({required super.bytes}); @@ -808,7 +823,7 @@ class ScriptBuf extends BdkScriptBuf { static Future empty() async { try { await Api.initialize(); - return ScriptBuf(bytes: BdkScriptBuf.empty().bytes); + return ScriptBuf(bytes: types.BdkScriptBuf.empty().bytes); } on BdkError catch (e) { throw mapBdkError(e); } @@ -818,7 +833,7 @@ class ScriptBuf extends BdkScriptBuf { static Future withCapacity(BigInt capacity) async { try { await Api.initialize(); - final res = await BdkScriptBuf.withCapacity(capacity: capacity); + final res = await types.BdkScriptBuf.withCapacity(capacity: capacity); return ScriptBuf(bytes: res.bytes); } on BdkError catch (e) { throw mapBdkError(e); @@ -829,7 +844,7 @@ class ScriptBuf extends BdkScriptBuf { static Future fromHex(String s) async { try { await Api.initialize(); - final res = await BdkScriptBuf.fromHex(s: s); + final res = await types.BdkScriptBuf.fromHex(s: s); return ScriptBuf(bytes: res.bytes); } on BdkError catch (e) { throw mapBdkError(e); @@ -843,7 +858,7 @@ class ScriptBuf extends BdkScriptBuf { } ///A bitcoin transaction. -class Transaction extends BdkTransaction { +class Transaction extends types.BdkTransaction { Transaction._({required super.s}); /// [Transaction] constructor @@ -854,8 +869,8 @@ class Transaction extends BdkTransaction { }) async { try { await Api.initialize(); - final res = - await BdkTransaction.fromBytes(transactionBytes: transactionBytes); + final res = await types.BdkTransaction.fromBytes( + transactionBytes: transactionBytes); return Transaction._(s: res.s); } on BdkError catch (e) { throw mapBdkError(e); @@ -873,17 +888,18 @@ class Transaction extends BdkTransaction { /// A TxBuilder is created by calling TxBuilder or BumpFeeTxBuilder on a wallet. /// After assigning it, you set options on it until finally calling finish to consume the builder and generate the transaction. class TxBuilder { - final List _recipients = []; - final List _utxos = []; - final List _unSpendable = []; - (OutPoint, Input, BigInt)? _foreignUtxo; + final List _recipients = []; + final List _utxos = []; + final List _unSpendable = []; + (types.OutPoint, types.Input, BigInt)? _foreignUtxo; bool _manuallySelectedOnly = false; double? _feeRate; - ChangeSpendPolicy _changeSpendPolicy = ChangeSpendPolicy.changeAllowed; + types.ChangeSpendPolicy _changeSpendPolicy = + types.ChangeSpendPolicy.changeAllowed; BigInt? _feeAbsolute; bool _drainWallet = false; ScriptBuf? _drainTo; - RbfValue? _rbfValue; + types.RbfValue? _rbfValue; List _data = []; Map? _internalPolicyPath; Map? _externalPolicyPath; @@ -896,15 +912,15 @@ class TxBuilder { ///Add a recipient to the internal list TxBuilder addRecipient(ScriptBuf script, BigInt amount) { - _recipients.add(ScriptAmount(script: script, amount: amount)); + _recipients.add(types.ScriptAmount(script: script, amount: amount)); return this; } ///Add a utxo to the internal list of unspendable utxos /// - /// It’s important to note that the “must-be-spent” utxos added with TxBuilder().addUtxo have priority over this. + /// It's important to note that the "must-be-spent" utxos added with TxBuilder().addUtxo have priority over this. /// See the docs of the two linked methods for more details. - TxBuilder unSpendable(List outpoints) { + TxBuilder unSpendable(List outpoints) { for (var e in outpoints) { _unSpendable.add(e); } @@ -913,8 +929,8 @@ class TxBuilder { ///Add a utxo to the internal list of utxos that must be spent /// - /// These have priority over the “unspendable” utxos, meaning that if a utxo is present both in the “utxos” and the “unspendable” list, it will be spent. - TxBuilder addUtxo(OutPoint outpoint) { + /// These have priority over the "unspendable" utxos, meaning that if a utxo is present both in the "utxos" and the "unspendable" list, it will be spent. + TxBuilder addUtxo(types.OutPoint outpoint) { _utxos.add(outpoint); return this; } @@ -923,8 +939,8 @@ class TxBuilder { /// ///If an error occurs while adding any of the UTXOs then none of them are added and the error is returned. /// - /// These have priority over the “unspendable” utxos, meaning that if a utxo is present both in the “utxos” and the “unspendable” list, it will be spent. - TxBuilder addUtxos(List outpoints) { + /// These have priority over the "unspendable" utxos, meaning that if a utxo is present both in the "utxos" and the "unspendable" list, it will be spent. + TxBuilder addUtxos(List outpoints) { for (var e in outpoints) { _utxos.add(e); } @@ -937,23 +953,23 @@ class TxBuilder { /// outpoint: To add it to the raw transaction. /// psbt_input: To know the value. /// satisfaction_weight: To know how much weight/vbytes the input will add to the transaction for fee calculation. - /// There are several security concerns about adding foreign UTXOs that application developers should consider. First, how do you know the value of the input is correct? If a non_witness_utxo is provided in the psbt_input then this method implicitly verifies the value by checking it against the transaction. If only a witness_utxo is provided then this method doesn’t verify the value but just takes it as a given – it is up to you to check that whoever sent you the input_psbt was not lying! + /// There are several security concerns about adding foreign UTXOs that application developers should consider. First, how do you know the value of the input is correct? If a non_witness_utxo is provided in the psbt_input then this method implicitly verifies the value by checking it against the transaction. If only a witness_utxo is provided then this method doesn't verify the value but just takes it as a given – it is up to you to check that whoever sent you the input_psbt was not lying! /// /// Secondly, you must somehow provide satisfaction_weight of the input. Depending on your application it may be important that this be known precisely.If not, /// a malicious counterparty may fool you into putting in a value that is too low, giving the transaction a lower than expected feerate. They could also fool /// you into putting a value that is too high causing you to pay a fee that is too high. The party who is broadcasting the transaction can of course check the /// real input weight matches the expected weight prior to broadcasting. - TxBuilder addForeignUtxo( - Input psbtInput, OutPoint outPoint, BigInt satisfactionWeight) { + TxBuilder addForeignUtxo(types.Input psbtInput, types.OutPoint outPoint, + BigInt satisfactionWeight) { _foreignUtxo = (outPoint, psbtInput, satisfactionWeight); return this; } ///Do not spend change outputs /// - /// This effectively adds all the change outputs to the “unspendable” list. See TxBuilder().addUtxos + /// This effectively adds all the change outputs to the "unspendable" list. See TxBuilder().addUtxos TxBuilder doNotSpendChange() { - _changeSpendPolicy = ChangeSpendPolicy.changeForbidden; + _changeSpendPolicy = types.ChangeSpendPolicy.changeForbidden; return this; } @@ -980,11 +996,11 @@ class TxBuilder { ///Enable signaling RBF with a specific nSequence value /// - /// This can cause conflicts if the wallet’s descriptors contain an “older” (OP_CSV) operator and the given nsequence is lower than the CSV value. + /// This can cause conflicts if the wallet's descriptors contain an "older" (OP_CSV) operator and the given nsequence is lower than the CSV value. /// ///If the nsequence is higher than 0xFFFFFFFD an error will be thrown, since it would not be a valid nSequence to signal RBF. TxBuilder enableRbfWithSequence(int nSequence) { - _rbfValue = RbfValue.value(nSequence); + _rbfValue = types.RbfValue.value(nSequence); return this; } @@ -992,7 +1008,7 @@ class TxBuilder { /// /// This will use the default nSequence value of 0xFFFFFFFD. TxBuilder enableRbf() { - _rbfValue = RbfValue.rbfDefault(); + _rbfValue = types.RbfValue.rbfDefault(); return this; } @@ -1009,9 +1025,9 @@ class TxBuilder { } ///Replace the recipients already added with a new list - TxBuilder setRecipients(List recipients) { - for (var e in _recipients) { - _recipients.add(e); + TxBuilder setRecipients(List<(ScriptBuf script, BigInt amount)> recipients) { + for (var (s, a) in recipients) { + _recipients.add(types.ScriptAmount(amount: a, script: s)); } return this; } @@ -1026,21 +1042,22 @@ class TxBuilder { ///Add a utxo to the internal list of unspendable utxos /// - /// It’s important to note that the “must-be-spent” utxos added with TxBuilder().addUtxo + /// It's important to note that the "must-be-spent" utxos added with TxBuilder().addUtxo /// have priority over this. See the docs of the two linked methods for more details. - TxBuilder addUnSpendable(OutPoint unSpendable) { + TxBuilder addUnSpendable(types.OutPoint unSpendable) { _unSpendable.add(unSpendable); return this; } ///Set the policy path to use while creating the transaction for a given keychain. ///This method accepts a map where the key is the policy node id (see policy.id()) and the value is the list of the indexes of the items that are intended to be satisfied from the policy node (see SatisfiableItem.Thresh.items). - TxBuilder policyPath(KeychainKind keychain, Map path) { + TxBuilder policyPath( + types.KeychainKind keychain, Map path) { switch (keychain) { - case KeychainKind.externalChain: + case types.KeychainKind.externalChain: _externalPolicyPath = path; break; - case KeychainKind.internalChain: + case types.KeychainKind.internalChain: _internalPolicyPath = path; break; } @@ -1049,9 +1066,9 @@ class TxBuilder { ///Only spend change outputs /// - /// This effectively adds all the non-change outputs to the “unspendable” list. + /// This effectively adds all the non-change outputs to the "unspendable" list. TxBuilder onlySpendChange() { - _changeSpendPolicy = ChangeSpendPolicy.onlyChange; + _changeSpendPolicy = types.ChangeSpendPolicy.onlyChange; return this; } @@ -1082,7 +1099,17 @@ class TxBuilder { data: _data, changePolicy: _changeSpendPolicy); - return (PartiallySignedTransaction._(ptr: res.$1.ptr), res.$2); + return ( + PartiallySignedTransaction._(ptr: res.$1.ptr), + TransactionDetails( + transaction: (res.$2.transaction?.s == null) + ? null + : Transaction._(s: res.$2.transaction!.s), + txid: res.$2.txid, + received: res.$2.received, + sent: res.$2.sent, + confirmationTime: res.$2.confirmationTime) + ); } on BdkError catch (e) { throw mapBdkError(e); } @@ -1104,8 +1131,8 @@ class Wallet extends BdkWallet { static Future create({ required Descriptor descriptor, Descriptor? changeDescriptor, - required Network network, - required DatabaseConfig databaseConfig, + required types.Network network, + required types.DatabaseConfig databaseConfig, }) async { try { await Api.initialize(); @@ -1124,7 +1151,7 @@ class Wallet extends BdkWallet { /// 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. the descriptor does not end with a * character) /// then the same address will always be returned for any AddressIndex. - AddressInfo getAddress({required AddressIndex addressIndex, hint}) { + AddressInfo getAddress({required types.AddressIndex addressIndex, hint}) { try { final res = BdkWallet.getAddress(ptr: this, addressIndex: addressIndex); return AddressInfo(res.$2, Address._(ptr: res.$1.ptr)); @@ -1136,7 +1163,7 @@ class Wallet extends BdkWallet { /// Return the balance, meaning the sum of this wallet’s unspent outputs’ values. Note that this method only operates /// on the internal database, which first needs to be Wallet.sync manually. @override - Balance getBalance({hint}) { + types.Balance getBalance({hint}) { try { return super.getBalance(); } on BdkError catch (e) { @@ -1146,7 +1173,7 @@ class Wallet extends BdkWallet { ///Returns the descriptor used to create addresses for a particular keychain. Future getDescriptorForKeychain( - {required KeychainKind keychain, hint}) async { + {required types.KeychainKind keychain, hint}) async { try { final res = BdkWallet.getDescriptorForKeychain(ptr: this, keychain: keychain); @@ -1165,7 +1192,8 @@ class Wallet extends BdkWallet { /// in the descriptor are derivable (i.e. does not end with /*) then the same address will always /// be returned for any [AddressIndex]. - AddressInfo getInternalAddress({required AddressIndex addressIndex, hint}) { + AddressInfo getInternalAddress( + {required types.AddressIndex addressIndex, hint}) { try { final res = BdkWallet.getInternalAddress(ptr: this, addressIndex: addressIndex); @@ -1177,10 +1205,10 @@ class Wallet extends BdkWallet { ///get the corresponding PSBT Input for a LocalUtxo @override - Future getPsbtInput( - {required LocalUtxo utxo, + Future getPsbtInput( + {required types.LocalUtxo utxo, required bool onlyWitnessUtxo, - PsbtSigHashType? sighashType, + types.PsbtSigHashType? sighashType, hint}) async { try { return super.getPsbtInput( @@ -1193,10 +1221,9 @@ class Wallet extends BdkWallet { } /// Return whether or not a script is part of this wallet (either internal or external). - @override - bool isMine({required BdkScriptBuf script, hint}) { + bool isMine({required ScriptBuf script}) { try { - return super.isMine(script: script); + return BdkWallet.isMine(ptr: this, script: script); } on BdkError catch (e) { throw mapBdkError(e); } @@ -1206,7 +1233,17 @@ class Wallet extends BdkWallet { @override List listTransactions({required bool includeRaw, hint}) { try { - return super.listTransactions(includeRaw: includeRaw); + return super + .listTransactions(includeRaw: includeRaw) + .map((e) => TransactionDetails( + transaction: (e.transaction?.s == null) + ? null + : Transaction._(s: e.transaction!.s), + txid: e.txid, + received: e.received, + sent: e.sent, + confirmationTime: e.confirmationTime)) + .toList(); } on BdkError catch (e) { throw mapBdkError(e); } @@ -1216,7 +1253,7 @@ class Wallet extends BdkWallet { /// which first needs to be Wallet.sync manually. /// TODO; Update; create custom LocalUtxo @override - List listUnspent({hint}) { + List listUnspent({hint}) { try { return super.listUnspent(); } on BdkError catch (e) { @@ -1226,7 +1263,7 @@ class Wallet extends BdkWallet { /// Get the Bitcoin network the wallet is using. @override - Network network({hint}) { + types.Network network({hint}) { try { return super.network(); } on BdkError catch (e) { @@ -1243,7 +1280,7 @@ class Wallet extends BdkWallet { /// in this library will. Future sign( {required PartiallySignedTransaction psbt, - SignOptions? signOptions, + types.SignOptions? signOptions, hint}) async { try { final res = @@ -1266,7 +1303,7 @@ class Wallet extends BdkWallet { } ///Return the spending policies for the wallet's descriptor - Policy? policies(KeychainKind keychain) { + Policy? policies(types.KeychainKind keychain) { try { final res = BdkWallet.policies(ptr: this, keychain: keychain); if (res == null) return null; @@ -1304,3 +1341,29 @@ class AddressInfo { AddressInfo(this.index, this.address); } + +class TxIn extends types.TxIn { + TxIn( + {required super.previousOutput, + required ScriptBuf scriptSig, + required super.sequence, + required super.witness}) + : super(scriptSig: scriptSig); +} + +///A transaction output, which defines new coins to be created from old ones. +class TxOut extends types.TxOut { + TxOut({required super.value, required ScriptBuf scriptPubkey}) + : super(scriptPubkey: scriptPubkey); +} + +class TransactionDetails extends types.TransactionDetails { + TransactionDetails( + {Transaction? transaction, + required super.txid, + required super.received, + required super.sent, + super.confirmationTime, + super.fee}) + : super(transaction: transaction); +} diff --git a/macos/Classes/frb_generated.h b/macos/Classes/frb_generated.h index 5c3e0c91..2430b240 100644 --- a/macos/Classes/frb_generated.h +++ b/macos/Classes/frb_generated.h @@ -906,7 +906,7 @@ typedef struct wire_cst_satisfiable_item { } wire_cst_satisfiable_item; void frbgen_bdk_flutter_wire__crate__api__blockchain__bdk_blockchain_broadcast(int64_t port_, - struct wire_cst_bdk_blockchain *that, + struct wire_cst_bdk_blockchain *ptr, struct wire_cst_bdk_transaction *transaction); void frbgen_bdk_flutter_wire__crate__api__blockchain__bdk_blockchain_create(int64_t port_, @@ -1153,7 +1153,7 @@ void frbgen_bdk_flutter_wire__crate__api__wallet__bdk_wallet_get_psbt_input(int6 bool only_witness_utxo, struct wire_cst_psbt_sig_hash_type *sighash_type); -WireSyncRust2DartDco frbgen_bdk_flutter_wire__crate__api__wallet__bdk_wallet_is_mine(struct wire_cst_bdk_wallet *that, +WireSyncRust2DartDco frbgen_bdk_flutter_wire__crate__api__wallet__bdk_wallet_is_mine(struct wire_cst_bdk_wallet *ptr, struct wire_cst_bdk_script_buf *script); WireSyncRust2DartDco frbgen_bdk_flutter_wire__crate__api__wallet__bdk_wallet_list_transactions(struct wire_cst_bdk_wallet *that, diff --git a/rust/src/api/blockchain.rs b/rust/src/api/blockchain.rs index ea297051..c27bef2f 100644 --- a/rust/src/api/blockchain.rs +++ b/rust/src/api/blockchain.rs @@ -62,9 +62,9 @@ impl BdkBlockchain { pub(crate) fn get_blockchain(&self) -> RustOpaque { self.ptr.clone() } - pub fn broadcast(&self, transaction: &BdkTransaction) -> Result { + pub fn broadcast(ptr: BdkBlockchain, transaction: &BdkTransaction) -> Result { let tx: Transaction = transaction.try_into()?; - self.get_blockchain().broadcast(&tx)?; + ptr.get_blockchain().broadcast(&tx)?; Ok(tx.txid().to_string()) } diff --git a/rust/src/api/wallet.rs b/rust/src/api/wallet.rs index 46e37649..dcbcf2c5 100644 --- a/rust/src/api/wallet.rs +++ b/rust/src/api/wallet.rs @@ -54,8 +54,8 @@ impl BdkWallet { execute_with_lock(&self.ptr, |w| w.network().into()) } #[frb(sync)] - pub fn is_mine(&self, script: BdkScriptBuf) -> Result { - execute_with_lock(&self.ptr, |w| { + pub fn is_mine(ptr: BdkWallet, script: BdkScriptBuf) -> Result { + execute_with_lock(&ptr.ptr, |w| { w.is_mine(>::into(script).as_script()) .map_err(|e| e.into()) })? diff --git a/rust/src/frb_generated.io.rs b/rust/src/frb_generated.io.rs index 7224d72f..e823f8d2 100644 --- a/rust/src/frb_generated.io.rs +++ b/rust/src/frb_generated.io.rs @@ -2256,10 +2256,10 @@ impl Default for wire_cst_tx_out { #[no_mangle] pub extern "C" fn frbgen_bdk_flutter_wire__crate__api__blockchain__bdk_blockchain_broadcast( port_: i64, - that: *mut wire_cst_bdk_blockchain, + ptr: *mut wire_cst_bdk_blockchain, transaction: *mut wire_cst_bdk_transaction, ) { - wire__crate__api__blockchain__bdk_blockchain_broadcast_impl(port_, that, transaction) + wire__crate__api__blockchain__bdk_blockchain_broadcast_impl(port_, ptr, transaction) } #[no_mangle] @@ -2953,10 +2953,10 @@ pub extern "C" fn frbgen_bdk_flutter_wire__crate__api__wallet__bdk_wallet_get_ps #[no_mangle] pub extern "C" fn frbgen_bdk_flutter_wire__crate__api__wallet__bdk_wallet_is_mine( - that: *mut wire_cst_bdk_wallet, + ptr: *mut wire_cst_bdk_wallet, script: *mut wire_cst_bdk_script_buf, ) -> flutter_rust_bridge::for_generated::WireSyncRust2DartDco { - wire__crate__api__wallet__bdk_wallet_is_mine_impl(that, script) + wire__crate__api__wallet__bdk_wallet_is_mine_impl(ptr, script) } #[no_mangle] diff --git a/rust/src/frb_generated.rs b/rust/src/frb_generated.rs index 65c12a4d..cfe6c5e3 100644 --- a/rust/src/frb_generated.rs +++ b/rust/src/frb_generated.rs @@ -48,7 +48,7 @@ flutter_rust_bridge::frb_generated_default_handler!(); fn wire__crate__api__blockchain__bdk_blockchain_broadcast_impl( port_: flutter_rust_bridge::for_generated::MessagePort, - that: impl CstDecode, + ptr: impl CstDecode, transaction: impl CstDecode, ) { FLUTTER_RUST_BRIDGE_HANDLER.wrap_normal::( @@ -58,12 +58,12 @@ fn wire__crate__api__blockchain__bdk_blockchain_broadcast_impl( mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal, }, move || { - let api_that = that.cst_decode(); + let api_ptr = ptr.cst_decode(); let api_transaction = transaction.cst_decode(); move |context| { transform_result_dco::<_, _, crate::api::error::BdkError>((move || { let output_ok = crate::api::blockchain::BdkBlockchain::broadcast( - &api_that, + api_ptr, &api_transaction, )?; Ok(output_ok) @@ -1809,7 +1809,7 @@ fn wire__crate__api__wallet__bdk_wallet_get_psbt_input_impl( ) } fn wire__crate__api__wallet__bdk_wallet_is_mine_impl( - that: impl CstDecode, + ptr: impl CstDecode, script: impl CstDecode, ) -> flutter_rust_bridge::for_generated::WireSyncRust2DartDco { FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync::( @@ -1819,10 +1819,10 @@ fn wire__crate__api__wallet__bdk_wallet_is_mine_impl( mode: flutter_rust_bridge::for_generated::FfiCallMode::Sync, }, move || { - let api_that = that.cst_decode(); + let api_ptr = ptr.cst_decode(); let api_script = script.cst_decode(); transform_result_dco::<_, _, crate::api::error::BdkError>((move || { - let output_ok = crate::api::wallet::BdkWallet::is_mine(&api_that, api_script)?; + let output_ok = crate::api::wallet::BdkWallet::is_mine(api_ptr, api_script)?; Ok(output_ok) })()) }, diff --git a/test/bdk_flutter_test.mocks.dart b/test/bdk_flutter_test.mocks.dart index 3b01c830..86e43303 100644 --- a/test/bdk_flutter_test.mocks.dart +++ b/test/bdk_flutter_test.mocks.dart @@ -3,12 +3,12 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i4; +import 'dart:async' as _i5; import 'dart:typed_data' as _i7; -import 'package:bdk_flutter/bdk_flutter.dart' as _i3; -import 'package:bdk_flutter/src/generated/api/types.dart' as _i5; +import 'package:bdk_flutter/src/generated/api/types.dart' as _i4; import 'package:bdk_flutter/src/generated/lib.dart' as _i2; +import 'package:bdk_flutter/src/root.dart' as _i3; import 'package:mockito/mockito.dart' as _i1; import 'package:mockito/src/dummies.dart' as _i6; @@ -46,7 +46,7 @@ class _FakeAddressInfo_1 extends _i1.SmartFake implements _i3.AddressInfo { ); } -class _FakeBalance_2 extends _i1.SmartFake implements _i3.Balance { +class _FakeBalance_2 extends _i1.SmartFake implements _i4.Balance { _FakeBalance_2( Object parent, Invocation parentInvocation, @@ -66,7 +66,7 @@ class _FakeDescriptor_3 extends _i1.SmartFake implements _i3.Descriptor { ); } -class _FakeInput_4 extends _i1.SmartFake implements _i3.Input { +class _FakeInput_4 extends _i1.SmartFake implements _i4.Input { _FakeInput_4( Object parent, Invocation parentInvocation, @@ -86,7 +86,7 @@ class _FakeAnyBlockchain_5 extends _i1.SmartFake implements _i2.AnyBlockchain { ); } -class _FakeFeeRate_6 extends _i1.SmartFake implements _i3.FeeRate { +class _FakeFeeRate_6 extends _i1.SmartFake implements _i4.FeeRate { _FakeFeeRate_6( Object parent, Invocation parentInvocation, @@ -235,7 +235,7 @@ class _FakeDerivationPath_19 extends _i1.SmartFake ); } -class _FakeOutPoint_20 extends _i1.SmartFake implements _i3.OutPoint { +class _FakeOutPoint_20 extends _i1.SmartFake implements _i4.OutPoint { _FakeOutPoint_20( Object parent, Invocation parentInvocation, @@ -245,7 +245,7 @@ class _FakeOutPoint_20 extends _i1.SmartFake implements _i3.OutPoint { ); } -class _FakeTxOut_21 extends _i1.SmartFake implements _i3.TxOut { +class _FakeTxOut_21 extends _i1.SmartFake implements _i4.TxOut { _FakeTxOut_21( Object parent, Invocation parentInvocation, @@ -274,7 +274,7 @@ class MockWallet extends _i1.Mock implements _i3.Wallet { @override _i3.AddressInfo getAddress({ - required _i3.AddressIndex? addressIndex, + required _i4.AddressIndex? addressIndex, dynamic hint, }) => (super.noSuchMethod( @@ -311,7 +311,7 @@ class MockWallet extends _i1.Mock implements _i3.Wallet { ) as _i3.AddressInfo); @override - _i3.Balance getBalance({dynamic hint}) => (super.noSuchMethod( + _i4.Balance getBalance({dynamic hint}) => (super.noSuchMethod( Invocation.method( #getBalance, [], @@ -333,11 +333,11 @@ class MockWallet extends _i1.Mock implements _i3.Wallet { {#hint: hint}, ), ), - ) as _i3.Balance); + ) as _i4.Balance); @override - _i4.Future<_i3.Descriptor> getDescriptorForKeychain({ - required _i3.KeychainKind? keychain, + _i5.Future<_i3.Descriptor> getDescriptorForKeychain({ + required _i4.KeychainKind? keychain, dynamic hint, }) => (super.noSuchMethod( @@ -349,7 +349,7 @@ class MockWallet extends _i1.Mock implements _i3.Wallet { #hint: hint, }, ), - returnValue: _i4.Future<_i3.Descriptor>.value(_FakeDescriptor_3( + returnValue: _i5.Future<_i3.Descriptor>.value(_FakeDescriptor_3( this, Invocation.method( #getDescriptorForKeychain, @@ -361,7 +361,7 @@ class MockWallet extends _i1.Mock implements _i3.Wallet { ), )), returnValueForMissingStub: - _i4.Future<_i3.Descriptor>.value(_FakeDescriptor_3( + _i5.Future<_i3.Descriptor>.value(_FakeDescriptor_3( this, Invocation.method( #getDescriptorForKeychain, @@ -372,11 +372,11 @@ class MockWallet extends _i1.Mock implements _i3.Wallet { }, ), )), - ) as _i4.Future<_i3.Descriptor>); + ) as _i5.Future<_i3.Descriptor>); @override _i3.AddressInfo getInternalAddress({ - required _i3.AddressIndex? addressIndex, + required _i4.AddressIndex? addressIndex, dynamic hint, }) => (super.noSuchMethod( @@ -413,10 +413,10 @@ class MockWallet extends _i1.Mock implements _i3.Wallet { ) as _i3.AddressInfo); @override - _i4.Future<_i3.Input> getPsbtInput({ - required _i3.LocalUtxo? utxo, + _i5.Future<_i4.Input> getPsbtInput({ + required _i4.LocalUtxo? utxo, required bool? onlyWitnessUtxo, - _i3.PsbtSigHashType? sighashType, + _i4.PsbtSigHashType? sighashType, dynamic hint, }) => (super.noSuchMethod( @@ -430,7 +430,7 @@ class MockWallet extends _i1.Mock implements _i3.Wallet { #hint: hint, }, ), - returnValue: _i4.Future<_i3.Input>.value(_FakeInput_4( + returnValue: _i5.Future<_i4.Input>.value(_FakeInput_4( this, Invocation.method( #getPsbtInput, @@ -443,7 +443,7 @@ class MockWallet extends _i1.Mock implements _i3.Wallet { }, ), )), - returnValueForMissingStub: _i4.Future<_i3.Input>.value(_FakeInput_4( + returnValueForMissingStub: _i5.Future<_i4.Input>.value(_FakeInput_4( this, Invocation.method( #getPsbtInput, @@ -456,21 +456,14 @@ class MockWallet extends _i1.Mock implements _i3.Wallet { }, ), )), - ) as _i4.Future<_i3.Input>); + ) as _i5.Future<_i4.Input>); @override - bool isMine({ - required _i5.BdkScriptBuf? script, - dynamic hint, - }) => - (super.noSuchMethod( + bool isMine({required _i3.ScriptBuf? script}) => (super.noSuchMethod( Invocation.method( #isMine, [], - { - #script: script, - #hint: hint, - }, + {#script: script}, ), returnValue: false, returnValueForMissingStub: false, @@ -495,31 +488,31 @@ class MockWallet extends _i1.Mock implements _i3.Wallet { ) as List<_i3.TransactionDetails>); @override - List<_i3.LocalUtxo> listUnspent({dynamic hint}) => (super.noSuchMethod( + List<_i4.LocalUtxo> listUnspent({dynamic hint}) => (super.noSuchMethod( Invocation.method( #listUnspent, [], {#hint: hint}, ), - returnValue: <_i3.LocalUtxo>[], - returnValueForMissingStub: <_i3.LocalUtxo>[], - ) as List<_i3.LocalUtxo>); + returnValue: <_i4.LocalUtxo>[], + returnValueForMissingStub: <_i4.LocalUtxo>[], + ) as List<_i4.LocalUtxo>); @override - _i3.Network network({dynamic hint}) => (super.noSuchMethod( + _i4.Network network({dynamic hint}) => (super.noSuchMethod( Invocation.method( #network, [], {#hint: hint}, ), - returnValue: _i3.Network.testnet, - returnValueForMissingStub: _i3.Network.testnet, - ) as _i3.Network); + returnValue: _i4.Network.testnet, + returnValueForMissingStub: _i4.Network.testnet, + ) as _i4.Network); @override - _i4.Future sign({ + _i5.Future sign({ required _i3.PartiallySignedTransaction? psbt, - _i3.SignOptions? signOptions, + _i4.SignOptions? signOptions, dynamic hint, }) => (super.noSuchMethod( @@ -532,12 +525,12 @@ class MockWallet extends _i1.Mock implements _i3.Wallet { #hint: hint, }, ), - returnValue: _i4.Future.value(false), - returnValueForMissingStub: _i4.Future.value(false), - ) as _i4.Future); + returnValue: _i5.Future.value(false), + returnValueForMissingStub: _i5.Future.value(false), + ) as _i5.Future); @override - _i4.Future sync({ + _i5.Future sync({ required _i3.Blockchain? blockchain, dynamic hint, }) => @@ -550,12 +543,12 @@ class MockWallet extends _i1.Mock implements _i3.Wallet { #hint: hint, }, ), - returnValue: _i4.Future.value(), - returnValueForMissingStub: _i4.Future.value(), - ) as _i4.Future); + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) as _i5.Future); @override - _i3.Policy? policies(_i3.KeychainKind? keychain) => (super.noSuchMethod( + _i3.Policy? policies(_i4.KeychainKind? keychain) => (super.noSuchMethod( Invocation.method( #policies, [keychain], @@ -582,54 +575,54 @@ class MockTransaction extends _i1.Mock implements _i3.Transaction { ) as String); @override - _i4.Future> input() => (super.noSuchMethod( + _i5.Future> input() => (super.noSuchMethod( Invocation.method( #input, [], ), - returnValue: _i4.Future>.value(<_i3.TxIn>[]), + returnValue: _i5.Future>.value(<_i4.TxIn>[]), returnValueForMissingStub: - _i4.Future>.value(<_i3.TxIn>[]), - ) as _i4.Future>); + _i5.Future>.value(<_i4.TxIn>[]), + ) as _i5.Future>); @override - _i4.Future isCoinBase() => (super.noSuchMethod( + _i5.Future isCoinBase() => (super.noSuchMethod( Invocation.method( #isCoinBase, [], ), - returnValue: _i4.Future.value(false), - returnValueForMissingStub: _i4.Future.value(false), - ) as _i4.Future); + returnValue: _i5.Future.value(false), + returnValueForMissingStub: _i5.Future.value(false), + ) as _i5.Future); @override - _i4.Future isExplicitlyRbf() => (super.noSuchMethod( + _i5.Future isExplicitlyRbf() => (super.noSuchMethod( Invocation.method( #isExplicitlyRbf, [], ), - returnValue: _i4.Future.value(false), - returnValueForMissingStub: _i4.Future.value(false), - ) as _i4.Future); + returnValue: _i5.Future.value(false), + returnValueForMissingStub: _i5.Future.value(false), + ) as _i5.Future); @override - _i4.Future isLockTimeEnabled() => (super.noSuchMethod( + _i5.Future isLockTimeEnabled() => (super.noSuchMethod( Invocation.method( #isLockTimeEnabled, [], ), - returnValue: _i4.Future.value(false), - returnValueForMissingStub: _i4.Future.value(false), - ) as _i4.Future); + returnValue: _i5.Future.value(false), + returnValueForMissingStub: _i5.Future.value(false), + ) as _i5.Future); @override - _i4.Future<_i3.LockTime> lockTime() => (super.noSuchMethod( + _i5.Future<_i4.LockTime> lockTime() => (super.noSuchMethod( Invocation.method( #lockTime, [], ), returnValue: - _i4.Future<_i3.LockTime>.value(_i6.dummyValue<_i3.LockTime>( + _i5.Future<_i4.LockTime>.value(_i6.dummyValue<_i4.LockTime>( this, Invocation.method( #lockTime, @@ -637,44 +630,44 @@ class MockTransaction extends _i1.Mock implements _i3.Transaction { ), )), returnValueForMissingStub: - _i4.Future<_i3.LockTime>.value(_i6.dummyValue<_i3.LockTime>( + _i5.Future<_i4.LockTime>.value(_i6.dummyValue<_i4.LockTime>( this, Invocation.method( #lockTime, [], ), )), - ) as _i4.Future<_i3.LockTime>); + ) as _i5.Future<_i4.LockTime>); @override - _i4.Future> output() => (super.noSuchMethod( + _i5.Future> output() => (super.noSuchMethod( Invocation.method( #output, [], ), - returnValue: _i4.Future>.value(<_i3.TxOut>[]), + returnValue: _i5.Future>.value(<_i4.TxOut>[]), returnValueForMissingStub: - _i4.Future>.value(<_i3.TxOut>[]), - ) as _i4.Future>); + _i5.Future>.value(<_i4.TxOut>[]), + ) as _i5.Future>); @override - _i4.Future<_i7.Uint8List> serialize() => (super.noSuchMethod( + _i5.Future<_i7.Uint8List> serialize() => (super.noSuchMethod( Invocation.method( #serialize, [], ), - returnValue: _i4.Future<_i7.Uint8List>.value(_i7.Uint8List(0)), + returnValue: _i5.Future<_i7.Uint8List>.value(_i7.Uint8List(0)), returnValueForMissingStub: - _i4.Future<_i7.Uint8List>.value(_i7.Uint8List(0)), - ) as _i4.Future<_i7.Uint8List>); + _i5.Future<_i7.Uint8List>.value(_i7.Uint8List(0)), + ) as _i5.Future<_i7.Uint8List>); @override - _i4.Future size() => (super.noSuchMethod( + _i5.Future size() => (super.noSuchMethod( Invocation.method( #size, [], ), - returnValue: _i4.Future.value(_i6.dummyValue( + returnValue: _i5.Future.value(_i6.dummyValue( this, Invocation.method( #size, @@ -682,22 +675,22 @@ class MockTransaction extends _i1.Mock implements _i3.Transaction { ), )), returnValueForMissingStub: - _i4.Future.value(_i6.dummyValue( + _i5.Future.value(_i6.dummyValue( this, Invocation.method( #size, [], ), )), - ) as _i4.Future); + ) as _i5.Future); @override - _i4.Future txid() => (super.noSuchMethod( + _i5.Future txid() => (super.noSuchMethod( Invocation.method( #txid, [], ), - returnValue: _i4.Future.value(_i6.dummyValue( + returnValue: _i5.Future.value(_i6.dummyValue( this, Invocation.method( #txid, @@ -705,32 +698,32 @@ class MockTransaction extends _i1.Mock implements _i3.Transaction { ), )), returnValueForMissingStub: - _i4.Future.value(_i6.dummyValue( + _i5.Future.value(_i6.dummyValue( this, Invocation.method( #txid, [], ), )), - ) as _i4.Future); + ) as _i5.Future); @override - _i4.Future version() => (super.noSuchMethod( + _i5.Future version() => (super.noSuchMethod( Invocation.method( #version, [], ), - returnValue: _i4.Future.value(0), - returnValueForMissingStub: _i4.Future.value(0), - ) as _i4.Future); + returnValue: _i5.Future.value(0), + returnValueForMissingStub: _i5.Future.value(0), + ) as _i5.Future); @override - _i4.Future vsize() => (super.noSuchMethod( + _i5.Future vsize() => (super.noSuchMethod( Invocation.method( #vsize, [], ), - returnValue: _i4.Future.value(_i6.dummyValue( + returnValue: _i5.Future.value(_i6.dummyValue( this, Invocation.method( #vsize, @@ -738,22 +731,22 @@ class MockTransaction extends _i1.Mock implements _i3.Transaction { ), )), returnValueForMissingStub: - _i4.Future.value(_i6.dummyValue( + _i5.Future.value(_i6.dummyValue( this, Invocation.method( #vsize, [], ), )), - ) as _i4.Future); + ) as _i5.Future); @override - _i4.Future weight() => (super.noSuchMethod( + _i5.Future weight() => (super.noSuchMethod( Invocation.method( #weight, [], ), - returnValue: _i4.Future.value(_i6.dummyValue( + returnValue: _i5.Future.value(_i6.dummyValue( this, Invocation.method( #weight, @@ -761,14 +754,14 @@ class MockTransaction extends _i1.Mock implements _i3.Transaction { ), )), returnValueForMissingStub: - _i4.Future.value(_i6.dummyValue( + _i5.Future.value(_i6.dummyValue( this, Invocation.method( #weight, [], ), )), - ) as _i4.Future); + ) as _i5.Future); } /// A class which mocks [Blockchain]. @@ -789,7 +782,7 @@ class MockBlockchain extends _i1.Mock implements _i3.Blockchain { ) as _i2.AnyBlockchain); @override - _i4.Future<_i3.FeeRate> estimateFee({ + _i5.Future<_i4.FeeRate> estimateFee({ required BigInt? target, dynamic hint, }) => @@ -802,7 +795,7 @@ class MockBlockchain extends _i1.Mock implements _i3.Blockchain { #hint: hint, }, ), - returnValue: _i4.Future<_i3.FeeRate>.value(_FakeFeeRate_6( + returnValue: _i5.Future<_i4.FeeRate>.value(_FakeFeeRate_6( this, Invocation.method( #estimateFee, @@ -813,7 +806,7 @@ class MockBlockchain extends _i1.Mock implements _i3.Blockchain { }, ), )), - returnValueForMissingStub: _i4.Future<_i3.FeeRate>.value(_FakeFeeRate_6( + returnValueForMissingStub: _i5.Future<_i4.FeeRate>.value(_FakeFeeRate_6( this, Invocation.method( #estimateFee, @@ -824,11 +817,11 @@ class MockBlockchain extends _i1.Mock implements _i3.Blockchain { }, ), )), - ) as _i4.Future<_i3.FeeRate>); + ) as _i5.Future<_i4.FeeRate>); @override - _i4.Future broadcast({ - required _i5.BdkTransaction? transaction, + _i5.Future broadcast({ + required _i3.Transaction? transaction, dynamic hint, }) => (super.noSuchMethod( @@ -840,7 +833,7 @@ class MockBlockchain extends _i1.Mock implements _i3.Blockchain { #hint: hint, }, ), - returnValue: _i4.Future.value(_i6.dummyValue( + returnValue: _i5.Future.value(_i6.dummyValue( this, Invocation.method( #broadcast, @@ -852,7 +845,7 @@ class MockBlockchain extends _i1.Mock implements _i3.Blockchain { ), )), returnValueForMissingStub: - _i4.Future.value(_i6.dummyValue( + _i5.Future.value(_i6.dummyValue( this, Invocation.method( #broadcast, @@ -863,10 +856,10 @@ class MockBlockchain extends _i1.Mock implements _i3.Blockchain { }, ), )), - ) as _i4.Future); + ) as _i5.Future); @override - _i4.Future getBlockHash({ + _i5.Future getBlockHash({ required int? height, dynamic hint, }) => @@ -879,7 +872,7 @@ class MockBlockchain extends _i1.Mock implements _i3.Blockchain { #hint: hint, }, ), - returnValue: _i4.Future.value(_i6.dummyValue( + returnValue: _i5.Future.value(_i6.dummyValue( this, Invocation.method( #getBlockHash, @@ -891,7 +884,7 @@ class MockBlockchain extends _i1.Mock implements _i3.Blockchain { ), )), returnValueForMissingStub: - _i4.Future.value(_i6.dummyValue( + _i5.Future.value(_i6.dummyValue( this, Invocation.method( #getBlockHash, @@ -902,18 +895,18 @@ class MockBlockchain extends _i1.Mock implements _i3.Blockchain { }, ), )), - ) as _i4.Future); + ) as _i5.Future); @override - _i4.Future getHeight({dynamic hint}) => (super.noSuchMethod( + _i5.Future getHeight({dynamic hint}) => (super.noSuchMethod( Invocation.method( #getHeight, [], {#hint: hint}, ), - returnValue: _i4.Future.value(0), - returnValueForMissingStub: _i4.Future.value(0), - ) as _i4.Future); + returnValue: _i5.Future.value(0), + returnValueForMissingStub: _i5.Future.value(0), + ) as _i5.Future); } /// A class which mocks [DescriptorSecretKey]. @@ -935,13 +928,13 @@ class MockDescriptorSecretKey extends _i1.Mock ) as _i2.DescriptorSecretKey); @override - _i4.Future<_i3.DescriptorSecretKey> derive(_i3.DerivationPath? path) => + _i5.Future<_i3.DescriptorSecretKey> derive(_i3.DerivationPath? path) => (super.noSuchMethod( Invocation.method( #derive, [path], ), - returnValue: _i4.Future<_i3.DescriptorSecretKey>.value( + returnValue: _i5.Future<_i3.DescriptorSecretKey>.value( _FakeDescriptorSecretKey_8( this, Invocation.method( @@ -949,7 +942,7 @@ class MockDescriptorSecretKey extends _i1.Mock [path], ), )), - returnValueForMissingStub: _i4.Future<_i3.DescriptorSecretKey>.value( + returnValueForMissingStub: _i5.Future<_i3.DescriptorSecretKey>.value( _FakeDescriptorSecretKey_8( this, Invocation.method( @@ -957,16 +950,16 @@ class MockDescriptorSecretKey extends _i1.Mock [path], ), )), - ) as _i4.Future<_i3.DescriptorSecretKey>); + ) as _i5.Future<_i3.DescriptorSecretKey>); @override - _i4.Future<_i3.DescriptorSecretKey> extend(_i3.DerivationPath? path) => + _i5.Future<_i3.DescriptorSecretKey> extend(_i3.DerivationPath? path) => (super.noSuchMethod( Invocation.method( #extend, [path], ), - returnValue: _i4.Future<_i3.DescriptorSecretKey>.value( + returnValue: _i5.Future<_i3.DescriptorSecretKey>.value( _FakeDescriptorSecretKey_8( this, Invocation.method( @@ -974,7 +967,7 @@ class MockDescriptorSecretKey extends _i1.Mock [path], ), )), - returnValueForMissingStub: _i4.Future<_i3.DescriptorSecretKey>.value( + returnValueForMissingStub: _i5.Future<_i3.DescriptorSecretKey>.value( _FakeDescriptorSecretKey_8( this, Invocation.method( @@ -982,7 +975,7 @@ class MockDescriptorSecretKey extends _i1.Mock [path], ), )), - ) as _i4.Future<_i3.DescriptorSecretKey>); + ) as _i5.Future<_i3.DescriptorSecretKey>); @override _i3.DescriptorPublicKey toPublic() => (super.noSuchMethod( @@ -1059,7 +1052,7 @@ class MockDescriptorPublicKey extends _i1.Mock ) as _i2.DescriptorPublicKey); @override - _i4.Future<_i3.DescriptorPublicKey> derive({ + _i5.Future<_i3.DescriptorPublicKey> derive({ required _i3.DerivationPath? path, dynamic hint, }) => @@ -1072,7 +1065,7 @@ class MockDescriptorPublicKey extends _i1.Mock #hint: hint, }, ), - returnValue: _i4.Future<_i3.DescriptorPublicKey>.value( + returnValue: _i5.Future<_i3.DescriptorPublicKey>.value( _FakeDescriptorPublicKey_9( this, Invocation.method( @@ -1084,7 +1077,7 @@ class MockDescriptorPublicKey extends _i1.Mock }, ), )), - returnValueForMissingStub: _i4.Future<_i3.DescriptorPublicKey>.value( + returnValueForMissingStub: _i5.Future<_i3.DescriptorPublicKey>.value( _FakeDescriptorPublicKey_9( this, Invocation.method( @@ -1096,10 +1089,10 @@ class MockDescriptorPublicKey extends _i1.Mock }, ), )), - ) as _i4.Future<_i3.DescriptorPublicKey>); + ) as _i5.Future<_i3.DescriptorPublicKey>); @override - _i4.Future<_i3.DescriptorPublicKey> extend({ + _i5.Future<_i3.DescriptorPublicKey> extend({ required _i3.DerivationPath? path, dynamic hint, }) => @@ -1112,7 +1105,7 @@ class MockDescriptorPublicKey extends _i1.Mock #hint: hint, }, ), - returnValue: _i4.Future<_i3.DescriptorPublicKey>.value( + returnValue: _i5.Future<_i3.DescriptorPublicKey>.value( _FakeDescriptorPublicKey_9( this, Invocation.method( @@ -1124,7 +1117,7 @@ class MockDescriptorPublicKey extends _i1.Mock }, ), )), - returnValueForMissingStub: _i4.Future<_i3.DescriptorPublicKey>.value( + returnValueForMissingStub: _i5.Future<_i3.DescriptorPublicKey>.value( _FakeDescriptorPublicKey_9( this, Invocation.method( @@ -1136,7 +1129,7 @@ class MockDescriptorPublicKey extends _i1.Mock }, ), )), - ) as _i4.Future<_i3.DescriptorPublicKey>); + ) as _i5.Future<_i3.DescriptorPublicKey>); @override String asString() => (super.noSuchMethod( @@ -1238,14 +1231,14 @@ class MockPartiallySignedTransaction extends _i1.Mock ) as _i3.Transaction); @override - _i4.Future<_i3.PartiallySignedTransaction> combine( + _i5.Future<_i3.PartiallySignedTransaction> combine( _i3.PartiallySignedTransaction? other) => (super.noSuchMethod( Invocation.method( #combine, [other], ), - returnValue: _i4.Future<_i3.PartiallySignedTransaction>.value( + returnValue: _i5.Future<_i3.PartiallySignedTransaction>.value( _FakePartiallySignedTransaction_13( this, Invocation.method( @@ -1254,7 +1247,7 @@ class MockPartiallySignedTransaction extends _i1.Mock ), )), returnValueForMissingStub: - _i4.Future<_i3.PartiallySignedTransaction>.value( + _i5.Future<_i3.PartiallySignedTransaction>.value( _FakePartiallySignedTransaction_13( this, Invocation.method( @@ -1262,7 +1255,7 @@ class MockPartiallySignedTransaction extends _i1.Mock [other], ), )), - ) as _i4.Future<_i3.PartiallySignedTransaction>); + ) as _i5.Future<_i3.PartiallySignedTransaction>); @override String txid({dynamic hint}) => (super.noSuchMethod( @@ -1377,7 +1370,7 @@ class MockTxBuilder extends _i1.Mock implements _i3.TxBuilder { ) as _i3.TxBuilder); @override - _i3.TxBuilder unSpendable(List<_i3.OutPoint>? outpoints) => + _i3.TxBuilder unSpendable(List<_i4.OutPoint>? outpoints) => (super.noSuchMethod( Invocation.method( #unSpendable, @@ -1400,7 +1393,7 @@ class MockTxBuilder extends _i1.Mock implements _i3.TxBuilder { ) as _i3.TxBuilder); @override - _i3.TxBuilder addUtxo(_i3.OutPoint? outpoint) => (super.noSuchMethod( + _i3.TxBuilder addUtxo(_i4.OutPoint? outpoint) => (super.noSuchMethod( Invocation.method( #addUtxo, [outpoint], @@ -1422,7 +1415,7 @@ class MockTxBuilder extends _i1.Mock implements _i3.TxBuilder { ) as _i3.TxBuilder); @override - _i3.TxBuilder addUtxos(List<_i3.OutPoint>? outpoints) => (super.noSuchMethod( + _i3.TxBuilder addUtxos(List<_i4.OutPoint>? outpoints) => (super.noSuchMethod( Invocation.method( #addUtxos, [outpoints], @@ -1445,8 +1438,8 @@ class MockTxBuilder extends _i1.Mock implements _i3.TxBuilder { @override _i3.TxBuilder addForeignUtxo( - _i3.Input? psbtInput, - _i3.OutPoint? outPoint, + _i4.Input? psbtInput, + _i4.OutPoint? outPoint, BigInt? satisfactionWeight, ) => (super.noSuchMethod( @@ -1637,7 +1630,7 @@ class MockTxBuilder extends _i1.Mock implements _i3.TxBuilder { ) as _i3.TxBuilder); @override - _i3.TxBuilder setRecipients(List<_i3.ScriptAmount>? recipients) => + _i3.TxBuilder setRecipients(List<(_i3.ScriptBuf, BigInt)>? recipients) => (super.noSuchMethod( Invocation.method( #setRecipients, @@ -1682,7 +1675,7 @@ class MockTxBuilder extends _i1.Mock implements _i3.TxBuilder { ) as _i3.TxBuilder); @override - _i3.TxBuilder addUnSpendable(_i3.OutPoint? unSpendable) => + _i3.TxBuilder addUnSpendable(_i4.OutPoint? unSpendable) => (super.noSuchMethod( Invocation.method( #addUnSpendable, @@ -1706,7 +1699,7 @@ class MockTxBuilder extends _i1.Mock implements _i3.TxBuilder { @override _i3.TxBuilder policyPath( - _i3.KeychainKind? keychain, + _i4.KeychainKind? keychain, Map? path, ) => (super.noSuchMethod( @@ -1762,14 +1755,14 @@ class MockTxBuilder extends _i1.Mock implements _i3.TxBuilder { ) as _i3.TxBuilder); @override - _i4.Future<(_i3.PartiallySignedTransaction, _i3.TransactionDetails)> finish( + _i5.Future<(_i3.PartiallySignedTransaction, _i3.TransactionDetails)> finish( _i3.Wallet? wallet) => (super.noSuchMethod( Invocation.method( #finish, [wallet], ), - returnValue: _i4.Future< + returnValue: _i5.Future< (_i3.PartiallySignedTransaction, _i3.TransactionDetails)>.value(( _FakePartiallySignedTransaction_13( this, @@ -1786,7 +1779,7 @@ class MockTxBuilder extends _i1.Mock implements _i3.TxBuilder { ), ) )), - returnValueForMissingStub: _i4.Future< + returnValueForMissingStub: _i5.Future< (_i3.PartiallySignedTransaction, _i3.TransactionDetails)>.value(( _FakePartiallySignedTransaction_13( this, @@ -1803,7 +1796,7 @@ class MockTxBuilder extends _i1.Mock implements _i3.TxBuilder { ), ) )), - ) as _i4 + ) as _i5 .Future<(_i3.PartiallySignedTransaction, _i3.TransactionDetails)>); } @@ -1900,14 +1893,14 @@ class MockBumpFeeTxBuilder extends _i1.Mock implements _i3.BumpFeeTxBuilder { ) as _i3.BumpFeeTxBuilder); @override - _i4.Future<(_i3.PartiallySignedTransaction, _i3.TransactionDetails)> finish( + _i5.Future<(_i3.PartiallySignedTransaction, _i3.TransactionDetails)> finish( _i3.Wallet? wallet) => (super.noSuchMethod( Invocation.method( #finish, [wallet], ), - returnValue: _i4.Future< + returnValue: _i5.Future< (_i3.PartiallySignedTransaction, _i3.TransactionDetails)>.value(( _FakePartiallySignedTransaction_13( this, @@ -1924,7 +1917,7 @@ class MockBumpFeeTxBuilder extends _i1.Mock implements _i3.BumpFeeTxBuilder { ), ) )), - returnValueForMissingStub: _i4.Future< + returnValueForMissingStub: _i5.Future< (_i3.PartiallySignedTransaction, _i3.TransactionDetails)>.value(( _FakePartiallySignedTransaction_13( this, @@ -1941,7 +1934,7 @@ class MockBumpFeeTxBuilder extends _i1.Mock implements _i3.BumpFeeTxBuilder { ), ) )), - ) as _i4 + ) as _i5 .Future<(_i3.PartiallySignedTransaction, _i3.TransactionDetails)>); } @@ -2041,7 +2034,7 @@ class MockAddress extends _i1.Mock implements _i3.Address { ) as String); @override - bool isValidForNetwork({required _i3.Network? network}) => + bool isValidForNetwork({required _i4.Network? network}) => (super.noSuchMethod( Invocation.method( #isValidForNetwork, @@ -2053,36 +2046,36 @@ class MockAddress extends _i1.Mock implements _i3.Address { ) as bool); @override - _i3.Network network() => (super.noSuchMethod( + _i4.Network network() => (super.noSuchMethod( Invocation.method( #network, [], ), - returnValue: _i3.Network.testnet, - returnValueForMissingStub: _i3.Network.testnet, - ) as _i3.Network); + returnValue: _i4.Network.testnet, + returnValueForMissingStub: _i4.Network.testnet, + ) as _i4.Network); @override - _i3.Payload payload() => (super.noSuchMethod( + _i4.Payload payload() => (super.noSuchMethod( Invocation.method( #payload, [], ), - returnValue: _i6.dummyValue<_i3.Payload>( + returnValue: _i6.dummyValue<_i4.Payload>( this, Invocation.method( #payload, [], ), ), - returnValueForMissingStub: _i6.dummyValue<_i3.Payload>( + returnValueForMissingStub: _i6.dummyValue<_i4.Payload>( this, Invocation.method( #payload, [], ), ), - ) as _i3.Payload); + ) as _i4.Payload); @override String asString() => (super.noSuchMethod( @@ -2150,7 +2143,7 @@ class MockDerivationPath extends _i1.Mock implements _i3.DerivationPath { /// A class which mocks [FeeRate]. /// /// See the documentation for Mockito's code generation for more information. -class MockFeeRate extends _i1.Mock implements _i3.FeeRate { +class MockFeeRate extends _i1.Mock implements _i4.FeeRate { @override double get satPerVb => (super.noSuchMethod( Invocation.getter(#satPerVb), @@ -2162,9 +2155,9 @@ class MockFeeRate extends _i1.Mock implements _i3.FeeRate { /// A class which mocks [LocalUtxo]. /// /// See the documentation for Mockito's code generation for more information. -class MockLocalUtxo extends _i1.Mock implements _i3.LocalUtxo { +class MockLocalUtxo extends _i1.Mock implements _i4.LocalUtxo { @override - _i3.OutPoint get outpoint => (super.noSuchMethod( + _i4.OutPoint get outpoint => (super.noSuchMethod( Invocation.getter(#outpoint), returnValue: _FakeOutPoint_20( this, @@ -2174,10 +2167,10 @@ class MockLocalUtxo extends _i1.Mock implements _i3.LocalUtxo { this, Invocation.getter(#outpoint), ), - ) as _i3.OutPoint); + ) as _i4.OutPoint); @override - _i3.TxOut get txout => (super.noSuchMethod( + _i4.TxOut get txout => (super.noSuchMethod( Invocation.getter(#txout), returnValue: _FakeTxOut_21( this, @@ -2187,14 +2180,14 @@ class MockLocalUtxo extends _i1.Mock implements _i3.LocalUtxo { this, Invocation.getter(#txout), ), - ) as _i3.TxOut); + ) as _i4.TxOut); @override - _i3.KeychainKind get keychain => (super.noSuchMethod( + _i4.KeychainKind get keychain => (super.noSuchMethod( Invocation.getter(#keychain), - returnValue: _i3.KeychainKind.externalChain, - returnValueForMissingStub: _i3.KeychainKind.externalChain, - ) as _i3.KeychainKind); + returnValue: _i4.KeychainKind.externalChain, + returnValueForMissingStub: _i4.KeychainKind.externalChain, + ) as _i4.KeychainKind); @override bool get isSpent => (super.noSuchMethod(