From 10b86b1086275d9fc599f0c3d2125f99b1915779 Mon Sep 17 00:00:00 2001 From: chavic Date: Thu, 18 Sep 2025 14:23:46 +0200 Subject: [PATCH 1/4] feat: add experimental Dart Bindings generation using uniffi-dart --- bdk-dart/.gitignore | 1 + bdk-dart/pubspec.lock | 405 ++++++++++++++++++++++++++ bdk-dart/pubspec.yaml | 12 + bdk-dart/scripts/generate_bindings.sh | 47 +++ bdk-ffi/Cargo.lock | 361 ++++++++++++++++++++--- bdk-ffi/Cargo.toml | 2 + bdk-ffi/rust-toolchain.toml | 2 +- bdk-ffi/uniffi-bindgen.rs | 33 ++- 8 files changed, 819 insertions(+), 44 deletions(-) create mode 100644 bdk-dart/.gitignore create mode 100644 bdk-dart/pubspec.lock create mode 100644 bdk-dart/pubspec.yaml create mode 100755 bdk-dart/scripts/generate_bindings.sh diff --git a/bdk-dart/.gitignore b/bdk-dart/.gitignore new file mode 100644 index 00000000..8d15be0b --- /dev/null +++ b/bdk-dart/.gitignore @@ -0,0 +1 @@ +.dart_tool/ \ No newline at end of file diff --git a/bdk-dart/pubspec.lock b/bdk-dart/pubspec.lock new file mode 100644 index 00000000..b5a0acd8 --- /dev/null +++ b/bdk-dart/pubspec.lock @@ -0,0 +1,405 @@ +# Generated by pub +# See https://dart.dev/tools/pub/glossary#lockfile +packages: + _fe_analyzer_shared: + dependency: transitive + description: + name: _fe_analyzer_shared + sha256: f0bb5d1648339c8308cc0b9838d8456b3cfe5c91f9dc1a735b4d003269e5da9a + url: "https://pub.dev" + source: hosted + version: "88.0.0" + analyzer: + dependency: transitive + description: + name: analyzer + sha256: "0b7b9c329d2879f8f05d6c05b32ee9ec025f39b077864bdb5ac9a7b63418a98f" + url: "https://pub.dev" + source: hosted + version: "8.1.1" + args: + dependency: transitive + description: + name: args + sha256: d0481093c50b1da8910eb0bb301626d4d8eb7284aa739614d2b394ee09e3ea04 + url: "https://pub.dev" + source: hosted + version: "2.7.0" + async: + dependency: transitive + description: + name: async + sha256: "758e6d74e971c3e5aceb4110bfd6698efc7f501675bcfe0c775459a8140750eb" + url: "https://pub.dev" + source: hosted + version: "2.13.0" + boolean_selector: + dependency: transitive + description: + name: boolean_selector + sha256: "8aab1771e1243a5063b8b0ff68042d67334e3feab9e95b9490f9a6ebf73b42ea" + url: "https://pub.dev" + source: hosted + version: "2.1.2" + cli_config: + dependency: transitive + description: + name: cli_config + sha256: ac20a183a07002b700f0c25e61b7ee46b23c309d76ab7b7640a028f18e4d99ec + url: "https://pub.dev" + source: hosted + version: "0.2.0" + collection: + dependency: transitive + description: + name: collection + sha256: "2f5709ae4d3d59dd8f7cd309b4e023046b57d8a6c82130785d2b0e5868084e76" + url: "https://pub.dev" + source: hosted + version: "1.19.1" + convert: + dependency: transitive + description: + name: convert + sha256: b30acd5944035672bc15c6b7a8b47d773e41e2f17de064350988c5d02adb1c68 + url: "https://pub.dev" + source: hosted + version: "3.1.2" + coverage: + dependency: transitive + description: + name: coverage + sha256: "5da775aa218eaf2151c721b16c01c7676fbfdd99cebba2bf64e8b807a28ff94d" + url: "https://pub.dev" + source: hosted + version: "1.15.0" + crypto: + dependency: transitive + description: + name: crypto + sha256: "1e445881f28f22d6140f181e07737b22f1e099a5e1ff94b0af2f9e4a463f4855" + url: "https://pub.dev" + source: hosted + version: "3.0.6" + ffi: + dependency: "direct main" + description: + name: ffi + sha256: "289279317b4b16eb2bb7e271abccd4bf84ec9bdcbe999e278a94b804f5630418" + url: "https://pub.dev" + source: hosted + version: "2.1.4" + file: + dependency: transitive + description: + name: file + sha256: a3b4f84adafef897088c160faf7dfffb7696046cb13ae90b508c2cbc95d3b8d4 + url: "https://pub.dev" + source: hosted + version: "7.0.1" + frontend_server_client: + dependency: transitive + description: + name: frontend_server_client + sha256: f64a0333a82f30b0cca061bc3d143813a486dc086b574bfb233b7c1372427694 + url: "https://pub.dev" + source: hosted + version: "4.0.0" + glob: + dependency: transitive + description: + name: glob + sha256: c3f1ee72c96f8f78935e18aa8cecced9ab132419e8625dc187e1c2408efc20de + url: "https://pub.dev" + source: hosted + version: "2.1.3" + http: + dependency: "direct dev" + description: + name: http + sha256: bb2ce4590bc2667c96f318d68cac1b5a7987ec819351d32b1c987239a815e007 + url: "https://pub.dev" + source: hosted + version: "1.5.0" + http_multi_server: + dependency: transitive + description: + name: http_multi_server + sha256: aa6199f908078bb1c5efb8d8638d4ae191aac11b311132c3ef48ce352fb52ef8 + url: "https://pub.dev" + source: hosted + version: "3.2.2" + http_parser: + dependency: transitive + description: + name: http_parser + sha256: "178d74305e7866013777bab2c3d8726205dc5a4dd935297175b19a23a2e66571" + url: "https://pub.dev" + source: hosted + version: "4.1.2" + io: + dependency: transitive + description: + name: io + sha256: dfd5a80599cf0165756e3181807ed3e77daf6dd4137caaad72d0b7931597650b + url: "https://pub.dev" + source: hosted + version: "1.0.5" + js: + dependency: transitive + description: + name: js + sha256: "53385261521cc4a0c4658fd0ad07a7d14591cf8fc33abbceae306ddb974888dc" + url: "https://pub.dev" + source: hosted + version: "0.7.2" + logging: + dependency: transitive + description: + name: logging + sha256: c8245ada5f1717ed44271ed1c26b8ce85ca3228fd2ffdb75468ab01979309d61 + url: "https://pub.dev" + source: hosted + version: "1.3.0" + matcher: + dependency: transitive + description: + name: matcher + sha256: dc58c723c3c24bf8d3e2d3ad3f2f9d7bd9cf43ec6feaa64181775e60190153f2 + url: "https://pub.dev" + source: hosted + version: "0.12.17" + meta: + dependency: transitive + description: + name: meta + sha256: "23f08335362185a5ea2ad3a4e597f1375e78bce8a040df5c600c8d3552ef2394" + url: "https://pub.dev" + source: hosted + version: "1.17.0" + mime: + dependency: transitive + description: + name: mime + sha256: "41a20518f0cb1256669420fdba0cd90d21561e560ac240f26ef8322e45bb7ed6" + url: "https://pub.dev" + source: hosted + version: "2.0.0" + node_preamble: + dependency: transitive + description: + name: node_preamble + sha256: "6e7eac89047ab8a8d26cf16127b5ed26de65209847630400f9aefd7cd5c730db" + url: "https://pub.dev" + source: hosted + version: "2.0.2" + package_config: + dependency: transitive + description: + name: package_config + sha256: f096c55ebb7deb7e384101542bfba8c52696c1b56fca2eb62827989ef2353bbc + url: "https://pub.dev" + source: hosted + version: "2.2.0" + path: + dependency: transitive + description: + name: path + sha256: "75cca69d1490965be98c73ceaea117e8a04dd21217b37b292c9ddbec0d955bc5" + url: "https://pub.dev" + source: hosted + version: "1.9.1" + pool: + dependency: transitive + description: + name: pool + sha256: "978783255c543aa3586a1b3c21f6e9d720eb315376a915872c61ef8b5c20177d" + url: "https://pub.dev" + source: hosted + version: "1.5.2" + pub_semver: + dependency: transitive + description: + name: pub_semver + sha256: "5bfcf68ca79ef689f8990d1160781b4bad40a3bd5e5218ad4076ddb7f4081585" + url: "https://pub.dev" + source: hosted + version: "2.2.0" + shelf: + dependency: transitive + description: + name: shelf + sha256: e7dd780a7ffb623c57850b33f43309312fc863fb6aa3d276a754bb299839ef12 + url: "https://pub.dev" + source: hosted + version: "1.4.2" + shelf_packages_handler: + dependency: transitive + description: + name: shelf_packages_handler + sha256: "89f967eca29607c933ba9571d838be31d67f53f6e4ee15147d5dc2934fee1b1e" + url: "https://pub.dev" + source: hosted + version: "3.0.2" + shelf_static: + dependency: transitive + description: + name: shelf_static + sha256: c87c3875f91262785dade62d135760c2c69cb217ac759485334c5857ad89f6e3 + url: "https://pub.dev" + source: hosted + version: "1.1.3" + shelf_web_socket: + dependency: transitive + description: + name: shelf_web_socket + sha256: "3632775c8e90d6c9712f883e633716432a27758216dfb61bd86a8321c0580925" + url: "https://pub.dev" + source: hosted + version: "3.0.0" + source_map_stack_trace: + dependency: transitive + description: + name: source_map_stack_trace + sha256: c0713a43e323c3302c2abe2a1cc89aa057a387101ebd280371d6a6c9fa68516b + url: "https://pub.dev" + source: hosted + version: "2.1.2" + source_maps: + dependency: transitive + description: + name: source_maps + sha256: "190222579a448b03896e0ca6eca5998fa810fda630c1d65e2f78b3f638f54812" + url: "https://pub.dev" + source: hosted + version: "0.10.13" + source_span: + dependency: transitive + description: + name: source_span + sha256: "254ee5351d6cb365c859e20ee823c3bb479bf4a293c22d17a9f1bf144ce86f7c" + url: "https://pub.dev" + source: hosted + version: "1.10.1" + stack_trace: + dependency: transitive + description: + name: stack_trace + sha256: "8b27215b45d22309b5cddda1aa2b19bdfec9df0e765f2de506401c071d38d1b1" + url: "https://pub.dev" + source: hosted + version: "1.12.1" + stream_channel: + dependency: transitive + description: + name: stream_channel + sha256: "969e04c80b8bcdf826f8f16579c7b14d780458bd97f56d107d3950fdbeef059d" + url: "https://pub.dev" + source: hosted + version: "2.1.4" + string_scanner: + dependency: transitive + description: + name: string_scanner + sha256: "921cd31725b72fe181906c6a94d987c78e3b98c2e205b397ea399d4054872b43" + url: "https://pub.dev" + source: hosted + version: "1.4.1" + term_glyph: + dependency: transitive + description: + name: term_glyph + sha256: "7f554798625ea768a7518313e58f83891c7f5024f88e46e7182a4558850a4b8e" + url: "https://pub.dev" + source: hosted + version: "1.2.2" + test: + dependency: "direct dev" + description: + name: test + sha256: "75906bf273541b676716d1ca7627a17e4c4070a3a16272b7a3dc7da3b9f3f6b7" + url: "https://pub.dev" + source: hosted + version: "1.26.3" + test_api: + dependency: transitive + description: + name: test_api + sha256: ab2726c1a94d3176a45960b6234466ec367179b87dd74f1611adb1f3b5fb9d55 + url: "https://pub.dev" + source: hosted + version: "0.7.7" + test_core: + dependency: transitive + description: + name: test_core + sha256: "0cc24b5ff94b38d2ae73e1eb43cc302b77964fbf67abad1e296025b78deb53d0" + url: "https://pub.dev" + source: hosted + version: "0.6.12" + typed_data: + dependency: transitive + description: + name: typed_data + sha256: f9049c039ebfeb4cf7a7104a675823cd72dba8297f264b6637062516699fa006 + url: "https://pub.dev" + source: hosted + version: "1.4.0" + vm_service: + dependency: transitive + description: + name: vm_service + sha256: "45caa6c5917fa127b5dbcfbd1fa60b14e583afdc08bfc96dda38886ca252eb60" + url: "https://pub.dev" + source: hosted + version: "15.0.2" + watcher: + dependency: transitive + description: + name: watcher + sha256: "5bf046f41320ac97a469d506261797f35254fa61c641741ef32dacda98b7d39c" + url: "https://pub.dev" + source: hosted + version: "1.1.3" + web: + dependency: transitive + description: + name: web + sha256: "868d88a33d8a87b18ffc05f9f030ba328ffefba92d6c127917a2ba740f9cfe4a" + url: "https://pub.dev" + source: hosted + version: "1.1.1" + web_socket: + dependency: transitive + description: + name: web_socket + sha256: "34d64019aa8e36bf9842ac014bb5d2f5586ca73df5e4d9bf5c936975cae6982c" + url: "https://pub.dev" + source: hosted + version: "1.0.1" + web_socket_channel: + dependency: transitive + description: + name: web_socket_channel + sha256: d645757fb0f4773d602444000a8131ff5d48c9e47adfe9772652dd1a4f2d45c8 + url: "https://pub.dev" + source: hosted + version: "3.0.3" + webkit_inspection_protocol: + dependency: transitive + description: + name: webkit_inspection_protocol + sha256: "87d3f2333bb240704cd3f1c6b5b7acd8a10e7f0bc28c28dcf14e782014f4a572" + url: "https://pub.dev" + source: hosted + version: "1.2.1" + yaml: + dependency: transitive + description: + name: yaml + sha256: b9da305ac7c39faa3f030eccd175340f968459dae4af175130b3fc47e40d76ce + url: "https://pub.dev" + source: hosted + version: "3.1.3" +sdks: + dart: ">=3.7.0 <4.0.0" diff --git a/bdk-dart/pubspec.yaml b/bdk-dart/pubspec.yaml new file mode 100644 index 00000000..1c3f6189 --- /dev/null +++ b/bdk-dart/pubspec.yaml @@ -0,0 +1,12 @@ +name: bdk_dart +description: Dart bindings for bdk-ffi +version: 0.24.0 + +environment: + sdk: '^3.2.0' + +dependencies: + ffi: ^2.1.4 +dev_dependencies: + test: ^1.26.2 + http: ^1.4.0 \ No newline at end of file diff --git a/bdk-dart/scripts/generate_bindings.sh b/bdk-dart/scripts/generate_bindings.sh new file mode 100755 index 00000000..ae51106c --- /dev/null +++ b/bdk-dart/scripts/generate_bindings.sh @@ -0,0 +1,47 @@ +#!/usr/bin/env bash +set -euo pipefail + +OS=$(uname -s) +echo "Running on $OS" + +dart --version +dart pub get + +# Install Rust targets if on macOS +if [[ "$OS" == "Darwin" ]]; then + LIBNAME=libbdkffi.dylib +elif [[ "$OS" == "Linux" ]]; then + LIBNAME=libbdkffi.so +else + echo "Unsupported os: $OS" + exit 1 +fi + +cd ../bdk-ffi/ +echo "Generating bdk-ffi dart..." +cargo build --profile dev +cargo run --profile dev --bin uniffi-bindgen -- --library target/debug/$LIBNAME --language dart --out-dir ../bdk-dart/lib/ + +if [[ "$OS" == "Darwin" ]]; then + echo "Generating native binaries..." + rustup target add aarch64-apple-darwin x86_64-apple-darwin + # This is a test script the actual release should not include the test utils feature + cargo build --profile dev --target aarch64-apple-darwin & + cargo build --profile dev --target x86_64-apple-darwin & + wait + + echo "Building macos fat library" + lipo -create -output ../bdk-dart/$LIBNAME \ + target/aarch64-apple-darwin/debug/$LIBNAME \ + target/x86_64-apple-darwin/debug/$LIBNAME +else + echo "Generating native binaries..." + rustup target add x86_64-unknown-linux-gnu + # This is a test script the actual release should not include the test utils feature + cargo build --profile dev --target x86_64-unknown-linux-gnu + + echo "Copying bdk-ffi binary" + cp target/x86_64-unknown-linux-gnu/debug/$LIBNAME ../bdk-dart/$LIBNAME +fi + +echo "All done!" diff --git a/bdk-ffi/Cargo.lock b/bdk-ffi/Cargo.lock index 49baa2f9..50f859f8 100644 --- a/bdk-ffi/Cargo.lock +++ b/bdk-ffi/Cargo.lock @@ -74,7 +74,7 @@ dependencies = [ "rustc-hash", "serde", "serde_derive", - "syn", + "syn 2.0.106", ] [[package]] @@ -95,6 +95,19 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b34d609dfbaf33d6889b2b7106d3ca345eacad44200913df5ba02bfd31d2ba9" +[[package]] +name = "async-compat" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1ba85bc55464dcbf728b56d97e119d673f4cf9062be330a9a26f3acf504a590" +dependencies = [ + "futures-core", + "futures-io", + "once_cell", + "pin-project-lite", + "tokio", +] + [[package]] name = "autocfg" version = "1.5.0" @@ -158,13 +171,14 @@ dependencies = [ "bdk_wallet", "thiserror 1.0.69", "uniffi", + "uniffi-dart", ] [[package]] name = "bdk_chain" -version = "0.23.1" +version = "0.23.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c361affe46a0120a077e0124e087ce1b4f7eeb9163cb6e5edc43ef21f847b3dc" +checksum = "5b5d691fd092aacec7e05046b7d04897d58d6d65ed3152cb6cf65dababcfabed" dependencies = [ "bdk_core", "bitcoin", @@ -175,9 +189,9 @@ dependencies = [ [[package]] name = "bdk_core" -version = "0.6.1" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f549541116c9f100cd7aa06b5e551e49bcc1f8dda1d0583e014de891aa943329" +checksum = "0dbbe4aad0c898bfeb5253c222be3ea3dccfb380a07e72c87e3e4ed6664a6753" dependencies = [ "bitcoin", "hashbrown 0.14.5", @@ -186,9 +200,9 @@ dependencies = [ [[package]] name = "bdk_electrum" -version = "0.23.1" +version = "0.23.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e36909a0f4b32146c0885cc553890489fd47e9141dbef260fccdf09a2c582e33" +checksum = "b59a3f7fbe678874fa34354097644a171276e02a49934c13b3d61c54610ddf39" dependencies = [ "bdk_core", "electrum-client", @@ -375,11 +389,11 @@ checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a" [[package]] name = "camino" -version = "1.1.12" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd0b03af37dad7a14518b7691d81acb0f8222604ad3d1b02f6b4bed5188c0cd5" +checksum = "e1de8bc0aa9e9385ceb3bf0c152e3a9b9544f6c4a912c8ae504e80c1f0368603" dependencies = [ - "serde", + "serde_core", ] [[package]] @@ -407,9 +421,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.2.36" +version = "1.2.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5252b3d2648e5eedbc1a6f501e3c795e07025c1e93bbf8bbdd6eef7f447a6d54" +checksum = "65193589c6404eb80b450d618eaf9a2cafaaafd57ecce47370519ef674a7bd44" dependencies = [ "find-msvc-tools", "shlex", @@ -457,7 +471,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn", + "syn 2.0.106", ] [[package]] @@ -545,6 +559,117 @@ dependencies = [ "autocfg", ] +[[package]] +name = "futures" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65bc07b1a8bc7c85c5f2e110c476c7389b4554ba72af57d8445ea63a576b0876" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" + +[[package]] +name = "futures-executor" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e28d1d997f585e54aebc3f97d39e72338912123a67330d723fdbb564d646c9f" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-io" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" + +[[package]] +name = "futures-macro" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.106", +] + +[[package]] +name = "futures-sink" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7" + +[[package]] +name = "futures-task" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" + +[[package]] +name = "futures-util" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "pin-utils", + "slab", +] + +[[package]] +name = "genco" +version = "0.17.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a35958104272e516c2a5f66a9d82fba4784d2b585fc1e2358b8f96e15d342995" +dependencies = [ + "genco-macros", + "relative-path", + "smallvec", +] + +[[package]] +name = "genco-macros" +version = "0.17.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43eaff6bbc0b3a878361aced5ec6a2818ee7c541c5b33b5880dfa9a86c23e9e7" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.106", +] + [[package]] name = "getrandom" version = "0.2.16" @@ -565,7 +690,7 @@ dependencies = [ "cfg-if", "libc", "r-efi", - "wasi 0.14.5+wasi-0.2.4", + "wasi 0.14.7+wasi-0.2.4", ] [[package]] @@ -654,9 +779,9 @@ checksum = "3011d1213f159867b13cfd6ac92d2cd5f1345762c63be3554e84092d85a50bbd" [[package]] name = "indexmap" -version = "2.11.1" +version = "2.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "206a8042aec68fa4a62e8d3f7aa4ceb508177d9324faf261e1959e495b7a1921" +checksum = "92119844f513ffa41556430369ab02c295a3578af21cf945caa3e9e0c2481ac3" dependencies = [ "equivalent", "hashbrown 0.15.5", @@ -691,6 +816,12 @@ dependencies = [ "tokio", ] +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" + [[package]] name = "libc" version = "0.2.175" @@ -714,6 +845,16 @@ version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df1d3c3b53da64cf5760482273a98e575c651a67eec7f77df96b5b642de8f039" +[[package]] +name = "lock_api" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96936507f153605bddfcda068dd804796c84324ed2510809e5b2a624c81da765" +dependencies = [ + "autocfg", + "scopeguard", +] + [[package]] name = "log" version = "0.4.28" @@ -802,6 +943,35 @@ version = "1.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" +[[package]] +name = "parking_lot" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70d58bf43669b5795d1576d0641cfb6fbb2057bf629506267a92807158584a13" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc838d2a56b5b1a6c25f55575dfc605fabb63bb2365f6c2353ef9159aa69e4a5" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-targets", +] + +[[package]] +name = "paste" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" + [[package]] name = "percent-encoding" version = "2.3.2" @@ -814,6 +984,12 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + [[package]] name = "pkg-config" version = "0.3.32" @@ -889,6 +1065,21 @@ dependencies = [ "getrandom 0.2.16", ] +[[package]] +name = "redox_syscall" +version = "0.5.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5407465600fb0548f1442edf71dd20683c6ed326200ace4b1ef0763521bb3b77" +dependencies = [ + "bitflags", +] + +[[package]] +name = "relative-path" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba39f3699c378cd8970968dcbff9c43159ea4cfbd88d43c00b22f2ef10a435d2" + [[package]] name = "ring" version = "0.17.14" @@ -964,7 +1155,7 @@ dependencies = [ "once_cell", "ring", "rustls-pki-types", - "rustls-webpki 0.103.5", + "rustls-webpki 0.103.6", "subtle", "zeroize", ] @@ -990,9 +1181,9 @@ dependencies = [ [[package]] name = "rustls-webpki" -version = "0.103.5" +version = "0.103.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5a37813727b78798e53c2bec3f5e8fe12a6d6f8389bf9ca7802add4c9905ad8" +checksum = "8572f3c2cb9934231157b45499fc41e1f58c589fdfb81a844ba873265e80f8eb" dependencies = [ "ring", "rustls-pki-types", @@ -1005,6 +1196,12 @@ version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + [[package]] name = "scroll" version = "0.12.0" @@ -1022,7 +1219,7 @@ checksum = "1783eabc414609e28a5ba76aee5ddd52199f7107a0b24c2e9746a1ecc34a683d" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.106", ] [[package]] @@ -1058,43 +1255,55 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.26" +version = "1.0.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56e6fa9c48d24d85fb3de5ad847117517440f6beceb7798af16b4a87d616b8d0" +checksum = "d767eb0aabc880b29956c35734170f26ed551a859dbd361d140cdbeca61ab1e2" dependencies = [ "serde", + "serde_core", ] [[package]] name = "serde" -version = "1.0.219" +version = "1.0.225" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd6c24dee235d0da097043389623fb913daddf92c76e9f5a1db88607a0bcbd1d" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde_core" +version = "1.0.225" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" +checksum = "659356f9a0cb1e529b24c01e43ad2bdf520ec4ceaf83047b83ddcc2251f96383" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.219" +version = "1.0.225" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" +checksum = "0ea936adf78b1f766949a4977b91d2f5595825bd6ec079aa9543ad2685fc4516" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.106", ] [[package]] name = "serde_json" -version = "1.0.143" +version = "1.0.145" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d401abef1d108fbd9cbaebc3e46611f4b1021f714a0597a71f41ee463f5f4a5a" +checksum = "402a6f66d8c709116cf22f558eab210f5a50187f702eb4d7e5ef38d9a7f1c79c" dependencies = [ "itoa", "memchr", "ryu", "serde", + "serde_core", ] [[package]] @@ -1103,6 +1312,15 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" +[[package]] +name = "signal-hook-registry" +version = "1.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2a4719bff48cee6b39d12c020eeb490953ad2443b7055bd0b21fca26bd8c28b" +dependencies = [ + "libc", +] + [[package]] name = "siphasher" version = "0.3.11" @@ -1143,6 +1361,18 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" +[[package]] +name = "stringcase" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04028eeb851ed08af6aba5caa29f2d59a13ed168cee4d6bd753aeefcf1d636b0" + +[[package]] +name = "stringcase" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72abeda133c49d7bddece6c154728f83eec8172380c80ab7096da9487e20d27c" + [[package]] name = "strsim" version = "0.11.1" @@ -1155,6 +1385,17 @@ version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + [[package]] name = "syn" version = "2.0.106" @@ -1214,7 +1455,7 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.106", ] [[package]] @@ -1225,7 +1466,7 @@ checksum = "6c5e1be1c48b9172ee610da68fd9cd2770e7a4056cb3fc98710ee6906f0c7960" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.106", ] [[package]] @@ -1254,7 +1495,9 @@ dependencies = [ "io-uring", "libc", "mio", + "parking_lot", "pin-project-lite", + "signal-hook-registry", "slab", "socket2", "tokio-macros", @@ -1269,7 +1512,7 @@ checksum = "6e06d43f1345a3bcd39f6a56dbb7dcab2ba47e68e8ac134855e7e2bdbaf8cab8" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.106", ] [[package]] @@ -1313,6 +1556,27 @@ dependencies = [ "uniffi_pipeline", ] +[[package]] +name = "uniffi-dart" +version = "0.1.0" +source = "git+https://github.com/chavic/uniffi-dart.git?branch=chavic%2Fmap-types-fix#a0a8fb56dc699dfbb9f0915112e1bc3461c5f7ca" +dependencies = [ + "anyhow", + "camino", + "genco", + "heck", + "lazy_static", + "paste", + "proc-macro2", + "serde", + "stringcase 0.4.0", + "toml", + "uniffi", + "uniffi_bindgen", + "uniffi_build", + "uniffi_dart_macro", +] + [[package]] name = "uniffi_bindgen" version = "0.29.4" @@ -1358,11 +1622,26 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2d990b553d6b9a7ee9c3ae71134674739913d52350b56152b0e613595bb5a6f" dependencies = [ "anyhow", + "async-compat", "bytes", "once_cell", "static_assertions", ] +[[package]] +name = "uniffi_dart_macro" +version = "0.1.0" +source = "git+https://github.com/chavic/uniffi-dart.git?branch=chavic%2Fmap-types-fix#a0a8fb56dc699dfbb9f0915112e1bc3461c5f7ca" +dependencies = [ + "futures", + "proc-macro2", + "quote", + "stringcase 0.3.0", + "syn 1.0.109", + "tokio", + "uniffi", +] + [[package]] name = "uniffi_internal_macros" version = "0.29.4" @@ -1373,7 +1652,7 @@ dependencies = [ "indexmap", "proc-macro2", "quote", - "syn", + "syn 2.0.106", ] [[package]] @@ -1388,7 +1667,7 @@ dependencies = [ "proc-macro2", "quote", "serde", - "syn", + "syn 2.0.106", "toml", "uniffi_meta", ] @@ -1469,18 +1748,18 @@ checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" [[package]] name = "wasi" -version = "0.14.5+wasi-0.2.4" +version = "0.14.7+wasi-0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4494f6290a82f5fe584817a676a34b9d6763e8d9d18204009fb31dceca98fd4" +checksum = "883478de20367e224c0090af9cf5f9fa85bed63a95c1abf3afc5c083ebc06e8c" dependencies = [ "wasip2", ] [[package]] name = "wasip2" -version = "1.0.0+wasi-0.2.4" +version = "1.0.1+wasi-0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03fa2761397e5bd52002cd7e73110c71af2109aca4e521a9f40473fe685b0a24" +checksum = "0562428422c63773dad2c345a1882263bbf4d65cf3f42e90921f787ef5ad58e7" dependencies = [ "wit-bindgen", ] @@ -1630,9 +1909,9 @@ dependencies = [ [[package]] name = "wit-bindgen" -version = "0.45.1" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c573471f125075647d03df72e026074b7203790d41351cd6edc96f46bcccd36" +checksum = "f17a85883d4e6d00e8a97c586de764dabcc06133f7f1d55dce5cdc070ad7fe59" [[package]] name = "zerocopy" @@ -1651,7 +1930,7 @@ checksum = "88d2b8d9c68ad2b9e4340d7832716a4d21a22a1154777ad56ea55c51a9cf3831" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.106", ] [[package]] diff --git a/bdk-ffi/Cargo.toml b/bdk-ffi/Cargo.toml index 73dcf03f..f4455191 100644 --- a/bdk-ffi/Cargo.toml +++ b/bdk-ffi/Cargo.toml @@ -21,10 +21,12 @@ bdk_electrum = { version = "0.23.1", default-features = false, features = ["use- bdk_kyoto = { version = "0.14.0" } uniffi = { version = "=0.29.4", features = ["cli"]} +uniffi-dart = { git = "https://github.com/chavic/uniffi-dart.git", branch = "chavic/map-types-fix" } thiserror = "1.0.58" [build-dependencies] uniffi = { version = "=0.29.4", features = ["build"] } +uniffi-dart = { git = "https://github.com/chavic/uniffi-dart.git", branch = "chavic/map-types-fix", features = ["build"] } [dev-dependencies] uniffi = { version = "=0.29.4", features = ["bindgen-tests"] } diff --git a/bdk-ffi/rust-toolchain.toml b/bdk-ffi/rust-toolchain.toml index 35e9b966..c05dd699 100644 --- a/bdk-ffi/rust-toolchain.toml +++ b/bdk-ffi/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "1.85.1" +channel = "1.86" components = ["clippy", "rustfmt"] diff --git a/bdk-ffi/uniffi-bindgen.rs b/bdk-ffi/uniffi-bindgen.rs index f6cff6cf..3de84c40 100644 --- a/bdk-ffi/uniffi-bindgen.rs +++ b/bdk-ffi/uniffi-bindgen.rs @@ -1,3 +1,32 @@ -fn main() { - uniffi::uniffi_bindgen_main() +fn main() { uniffi_bindgen() } + +fn uniffi_bindgen() { + // uniffi_bindgen_main parses command line arguments for officially supported languages, + // but we need to parse them manually first to decide whether to use the uniffi_dart plugin. + let args: Vec = std::env::args().collect(); + let language = + args.iter().position(|arg| arg == "--language").and_then(|idx| args.get(idx + 1)); + let library_path = args + .iter() + .position(|arg| arg == "--library") + .and_then(|idx| args.get(idx + 1)) + .expect("specify the library path with --library"); + let output_dir = args + .iter() + .position(|arg| arg == "--out-dir") + .and_then(|idx| args.get(idx + 1)) + .expect("--out-dir is required when using --library"); + match language { + Some(lang) if lang == "dart" => { + uniffi_dart::gen::generate_dart_bindings( + "src/bdk-ffi.udl".into(), + None, + Some(output_dir.as_str().into()), + library_path.as_str().into(), + true, + ) + .expect("Failed to generate dart bindings"); + } + _ => uniffi::uniffi_bindgen_main(), + } } From 15c03b725b7f5ec5c3d994dea4f9091e84bfc6b2 Mon Sep 17 00:00:00 2001 From: chavic Date: Mon, 22 Sep 2025 11:45:37 +0200 Subject: [PATCH 2/4] test: added equivalent tests from android and swift to dart --- ...re_existing_wallet_persistence_test.sqlite | Bin 0 -> 53248 bytes bdk-dart/test/descriptor_test.dart | 102 ++++++++++++++++++ bdk-dart/test/mnemonic_test.dart | 31 ++++++ bdk-dart/test/offline_persistence_test.dart | 63 +++++++++++ bdk-dart/test/offline_wallet_test.dart | 54 ++++++++++ bdk-dart/test/test_constants.dart | 77 +++++++++++++ bdk-dart/test/wallet_behavior_test.dart | 53 +++++++++ bdk-dart/test/wallet_creation_test.dart | 102 ++++++++++++++++++ 8 files changed, 482 insertions(+) create mode 100644 bdk-dart/test/data/pre_existing_wallet_persistence_test.sqlite create mode 100644 bdk-dart/test/descriptor_test.dart create mode 100644 bdk-dart/test/mnemonic_test.dart create mode 100644 bdk-dart/test/offline_persistence_test.dart create mode 100644 bdk-dart/test/offline_wallet_test.dart create mode 100644 bdk-dart/test/test_constants.dart create mode 100644 bdk-dart/test/wallet_behavior_test.dart create mode 100644 bdk-dart/test/wallet_creation_test.dart diff --git a/bdk-dart/test/data/pre_existing_wallet_persistence_test.sqlite b/bdk-dart/test/data/pre_existing_wallet_persistence_test.sqlite new file mode 100644 index 0000000000000000000000000000000000000000..18b69e7e358260b51a87195539a085d5016073d0 GIT binary patch literal 53248 zcmeI*U2ob}7zc1WP{wHR(jTNSNp_HgCSDG(x;43r$l(*QV2iY;z0@0u(!h z0g_SS6LaR!{O-qI)9n=rR+iH)OMiU(&B`Z+dh>kPWo)^ zDF}V7bxNnSyIuBg5RA5aovyqXiauPQm9874o2^@3I=>T+-n+*S_ip6sC2EDHWXX>3 zjh-;QtM|0Cial`R_xim>Y1>b9+|}=gLec!a+3{NAV6E^l9CQxL@YoO4>10l{Zt2cM zz-~K>d1`;09=^BeMBnuL)i4%tJIMQfBxhQyMeWf@a!bL9NZfW72^&S@(LZhfq_C?N z_Q@7o>;VzkNVjKy!JM=&pN%PJD|qMU-HhV9~S&jEu&6PG)K)V zE=&aL&DbJs?S#4;oE9tV*|cXhI@iZ`JdS;<^uk|_L2qB~f%Yl^_D-@mdN&!J;0J|o zIpLM?tMC&mV1fVyAOHafKmY;|fB*y_009Ub(I=}nkK!36S;-c5@9PBFl`4a8sa((s4$UGX9 zUgo>0;t4%8BuXDX&pdxR*fy&5{7KWUKP&INJg*&INN2_T`R=oZwIeA?v03eXk*2ld zOhQb25Zk!uYFhiEb~-mvB}Y-UQ^x68-8i=zHTHo9=loyzj$;o@5P$##AOHafKmY;| zfB*y_009Whoxl$JGQMF%bf;V{spPUURit!El8mHjil(BNS;J6tU6*7@Gc&R#X0uu< zCu(v=mUT*#)XX?v@OO9al0!fcfB*y_009U<00Izz00bZa0SNqy0;A9WvoHO}1OW&@ z00Izz00bZa0SG_<0uX?}Ef&E2|66=;ks1Ub009U<00Izz00bZa0SG|A6Ttm{bOi`N z00Izz00bZa0SG_<0uX?}?H9oP|J#3zks$;i009U<00Izz00bZa0SG_<_y5rcAOHaf zKmY;|fB*y_009U<00OsP!2SP!SDbKl`*THx5P$##AOHafKmY;|fB*y_0D=FVfXWAl z5k9M#O1f$oX_L~FoXhAmXNp-W>57>)B{?f6MOl)}j3Mf}Sxp&AN}?&TDjK?+tV(7z tG`j!K3*U3>fe8W-fB*y_009U<00Izz00bZaf%y~IVHW_F{^ buildBip84Descriptor(Network.regtest), + returnsNormally, + ); + expect( + () => buildBip84Descriptor(Network.testnet), + returnsNormally, + ); + expect( + () => buildBip84Descriptor(Network.testnet4), + returnsNormally, + ); + expect( + () => buildBip84Descriptor(Network.signet), + returnsNormally, + ); + expect( + () => buildMainnetBip84Descriptor(), + returnsNormally, + ); + }); + + test('creates extended TR descriptors across networks', () { + expect( + () => buildBip86Descriptor(Network.regtest), + returnsNormally, + ); + expect( + () => buildBip86Descriptor(Network.testnet), + returnsNormally, + ); + expect( + () => buildBip86Descriptor(Network.testnet4), + returnsNormally, + ); + expect( + () => buildBip86Descriptor(Network.signet), + returnsNormally, + ); + expect( + () => buildMainnetBip86Descriptor(), + returnsNormally, + ); + }); + + test('creates non-extended descriptors for all networks', () { + expect( + () => Descriptor( + "tr($testExtendedPrivKey/$bip86TestReceivePath/0)", + Network.regtest, + ), + returnsNormally, + ); + expect( + () => Descriptor( + "tr($testExtendedPrivKey/$bip86TestReceivePath/0)", + Network.testnet, + ), + returnsNormally, + ); + expect( + () => Descriptor( + "tr($testExtendedPrivKey/$bip86TestReceivePath/0)", + Network.testnet4, + ), + returnsNormally, + ); + expect( + () => Descriptor( + "tr($testExtendedPrivKey/$bip86TestReceivePath/0)", + Network.signet, + ), + returnsNormally, + ); + expect( + () => Descriptor( + "tr($mainnetExtendedPrivKey/$bip86MainnetReceivePath/0)", + Network.bitcoin, + ), + returnsNormally, + ); + }); + + test('fails to create addr() descriptor', () { + expect( + () => Descriptor( + "addr(tb1qhjys9wxlfykmte7ftryptx975uqgd6kcm6a7z4)", + Network.testnet, + ), + throwsA(isA()), + ); + }); + }); +} diff --git a/bdk-dart/test/mnemonic_test.dart b/bdk-dart/test/mnemonic_test.dart new file mode 100644 index 00000000..30732fda --- /dev/null +++ b/bdk-dart/test/mnemonic_test.dart @@ -0,0 +1,31 @@ +import 'package:bdk_dart/bdk.dart'; +import 'package:test/test.dart'; + +import 'test_constants.dart'; + +void main() { + group('Mnemonic', () { + test('produces expected BIP86 descriptor', () { + final mnemonic = Mnemonic.fromString( + "space echo position wrist orient erupt relief museum myself grain wisdom tumble", + ); + final descriptorSecretKey = DescriptorSecretKey( + Network.testnet, + mnemonic, + null, + ); + final descriptor = Descriptor.newBip86( + descriptorSecretKey, + KeychainKind.external_, + Network.testnet, + ); + + expect( + descriptor.toString(), + equals( + "tr([be1eec8f/86'/1'/0']tpubDCTtszwSxPx3tATqDrsSyqScPNnUChwQAVAkanuDUCJQESGBbkt68nXXKRDifYSDbeMa2Xg2euKbXaU3YphvGWftDE7ozRKPriT6vAo3xsc/0/*)#m7puekcx", + ), + ); + }); + }); +} diff --git a/bdk-dart/test/offline_persistence_test.dart b/bdk-dart/test/offline_persistence_test.dart new file mode 100644 index 00000000..88787a3a --- /dev/null +++ b/bdk-dart/test/offline_persistence_test.dart @@ -0,0 +1,63 @@ +import 'dart:io'; + +import 'package:bdk_dart/bdk.dart'; +import 'package:test/test.dart'; + +import 'test_constants.dart'; + +const _fixtureName = 'pre_existing_wallet_persistence_test.sqlite'; + +String _copyFixtureToTempDir() { + final source = File('test/data/$_fixtureName'); + final tempDir = Directory.systemTemp.createTempSync('bdk_dart_persistence_'); + addTearDown(() => tempDir.delete(recursive: true)); + final destination = File('${tempDir.path}/$_fixtureName'); + destination.writeAsBytesSync(source.readAsBytesSync(), flush: true); + return destination.path; +} + +void main() { + group('Offline persistence', () { + test('loads sqlite wallet with private descriptors', () { + final dbPath = _copyFixtureToTempDir(); + final persister = Persister.newSqlite(dbPath); + final wallet = Wallet.load( + buildDescriptor(persistenceDescriptorString, Network.signet), + buildDescriptor(persistenceChangeDescriptorString, Network.signet), + persister, + defaultLookahead, + ); + + final addressInfo = + wallet.revealNextAddress(KeychainKind.external_); + final expectedAddress = Address(expectedPersistedAddress, Network.signet); + + expect(addressInfo.index, equals(7)); + expect( + addressInfo.address.scriptPubkey().toBytes(), + orderedEquals(expectedAddress.scriptPubkey().toBytes()), + ); + }); + + test('loads sqlite wallet with public descriptors', () { + final dbPath = _copyFixtureToTempDir(); + final persister = Persister.newSqlite(dbPath); + final wallet = Wallet.load( + buildDescriptor(persistencePublicDescriptorString, Network.signet), + buildDescriptor(persistencePublicChangeDescriptorString, Network.signet), + persister, + defaultLookahead, + ); + + final addressInfo = + wallet.revealNextAddress(KeychainKind.external_); + + expect(addressInfo.index, equals(7)); + final expectedAddress = Address(expectedPersistedAddress, Network.signet); + expect( + addressInfo.address.scriptPubkey().toBytes(), + orderedEquals(expectedAddress.scriptPubkey().toBytes()), + ); + }); + }); +} diff --git a/bdk-dart/test/offline_wallet_test.dart b/bdk-dart/test/offline_wallet_test.dart new file mode 100644 index 00000000..dcadeae6 --- /dev/null +++ b/bdk-dart/test/offline_wallet_test.dart @@ -0,0 +1,54 @@ +import 'package:bdk_dart/bdk.dart'; +import 'package:test/test.dart'; + +import 'test_constants.dart'; + +void main() { + group('Offline wallet', () { + test('revealNextAddress yields expected address on multiple networks', () { + final descriptor = + buildDescriptor(offlineDescriptorString, Network.signet); + final changeDescriptor = + buildDescriptor(offlineChangeDescriptorString, Network.signet); + final persister = Persister.newInMemory(); + final wallet = Wallet( + descriptor, + changeDescriptor, + Network.signet, + persister, + defaultLookahead, + ); + + final addressInfo = + wallet.revealNextAddress(KeychainKind.external_); + final expectedAddress = Address(expectedOfflineAddress, Network.signet); + + expect(addressInfo.address.isValidForNetwork(Network.testnet), isTrue); + expect(addressInfo.address.isValidForNetwork(Network.testnet4), isTrue); + expect(addressInfo.address.isValidForNetwork(Network.signet), isTrue); + expect(addressInfo.address.isValidForNetwork(Network.regtest), isFalse); + expect(addressInfo.address.isValidForNetwork(Network.bitcoin), isFalse); + expect( + addressInfo.address.scriptPubkey().toBytes(), + orderedEquals(expectedAddress.scriptPubkey().toBytes()), + ); + }); + + test('new wallet starts with zero balance', () { + final descriptor = + buildDescriptor(offlineDescriptorString, Network.signet); + final changeDescriptor = + buildDescriptor(offlineChangeDescriptorString, Network.signet); + final persister = Persister.newInMemory(); + final wallet = Wallet( + descriptor, + changeDescriptor, + Network.signet, + persister, + defaultLookahead, + ); + + expect(wallet.balance().total.toSat(), equals(0)); + }); + }); +} diff --git a/bdk-dart/test/test_constants.dart b/bdk-dart/test/test_constants.dart new file mode 100644 index 00000000..b3e00a90 --- /dev/null +++ b/bdk-dart/test/test_constants.dart @@ -0,0 +1,77 @@ +import 'package:bdk_dart/bdk.dart'; + +const testExtendedPrivKey = + "tprv8ZgxMBicQKsPf2qfrEygW6fdYseJDDrVnDv26PH5BHdvSuG6ecCbHqLVof9yZcMoM31z9ur3tTYbSnr1WBqbGX97CbXcmp5H6qeMpyvx35B"; +const bip84TestReceivePath = "84h/1h/0h/0"; +const bip84TestChangePath = "84h/1h/0h/1"; +const bip86TestReceivePath = "86h/1h/0h/0"; +const bip86TestChangePath = "86h/1h/0h/1"; + +const mainnetExtendedPrivKey = + "xprv9s21ZrQH143K3LRcTnWpaCSYb75ic2rGuSgicmJhSVQSbfaKgPXfa8PhnYszgdcyWLoc8n1E2iHUnskjgGTAyCEpJYv7fqKxUcRNaVngA1V"; +const bip84MainnetReceivePath = "84h/0h/0h/1"; +const bip86MainnetReceivePath = "86h/0h/0h/1"; + +const offlineDescriptorString = + "wpkh(tprv8ZgxMBicQKsPf2qfrEygW6fdYseJDDrVnDv26PH5BHdvSuG6ecCbHqLVof9yZcMoM31z9ur3tTYbSnr1WBqbGX97CbXcmp5H6qeMpyvx35B/84h/1h/1h/0/*)"; +const offlineChangeDescriptorString = + "wpkh(tprv8ZgxMBicQKsPf2qfrEygW6fdYseJDDrVnDv26PH5BHdvSuG6ecCbHqLVof9yZcMoM31z9ur3tTYbSnr1WBqbGX97CbXcmp5H6qeMpyvx35B/84h/1h/1h/1/*)"; + +const persistenceDescriptorString = + "wpkh(tprv8ZgxMBicQKsPf2qfrEygW6fdYseJDDrVnDv26PH5BHdvSuG6ecCbHqLVof9yZcMoM31z9ur3tTYbSnr1WBqbGX97CbXcmp5H6qeMpyvx35B/84h/1h/0h/0/*)"; +const persistenceChangeDescriptorString = + "wpkh(tprv8ZgxMBicQKsPf2qfrEygW6fdYseJDDrVnDv26PH5BHdvSuG6ecCbHqLVof9yZcMoM31z9ur3tTYbSnr1WBqbGX97CbXcmp5H6qeMpyvx35B/84h/1h/0h/1/*)"; +const persistencePublicDescriptorString = + "wpkh([9122d9e0/84'/1'/0']tpubDCYVtmaSaDzTxcgvoP5AHZNbZKZzrvoNH9KARep88vESc6MxRqAp4LmePc2eeGX6XUxBcdhAmkthWTDqygPz2wLAyHWisD299Lkdrj5egY6/0/*)#zpaanzgu"; +const persistencePublicChangeDescriptorString = + "wpkh([9122d9e0/84'/1'/0']tpubDCYVtmaSaDzTxcgvoP5AHZNbZKZzrvoNH9KARep88vESc6MxRqAp4LmePc2eeGX6XUxBcdhAmkthWTDqygPz2wLAyHWisD299Lkdrj5egY6/1/*)#n4cuwhcy"; + +const multipathDescriptorString = + "wpkh([9a6a2580/84'/0'/0']xpub6DEzNop46vmxR49zYWFnMwmEfawSNmAMf6dLH5YKDY463twtvw1XD7ihwJRLPRGZJz799VPFzXHpZu6WdhT29WnaeuChS6aZHZPFmqczR5K/<0;1>/*)"; +const privateMultipathDescriptorString = + "tprv8ZgxMBicQKsPf2qfrEygW6fdYseJDDrVnDv26PH5BHdvSuG6ecCbHqLVof9yZcMoM31z9ur3tTYbSnr1WBqbGX97CbXcmp5H6qeMpyvx35B/<0;1>/*)"; + +const expectedOfflineAddress = + "tb1qhjys9wxlfykmte7ftryptx975uqgd6kcm6a7z4"; +const expectedPersistedAddress = + "tb1qan3lldunh37ma6c0afeywgjyjgnyc8uz975zl2"; + +Descriptor buildDescriptor(String descriptor, Network network) => + Descriptor(descriptor, network); + +Descriptor buildBip84Descriptor(Network network) => Descriptor( + "wpkh($testExtendedPrivKey/$bip84TestReceivePath/*)", + network, + ); + +Descriptor buildBip84ChangeDescriptor(Network network) => Descriptor( + "wpkh($testExtendedPrivKey/$bip84TestChangePath/*)", + network, + ); + +Descriptor buildBip86Descriptor(Network network) => Descriptor( + "tr($testExtendedPrivKey/$bip86TestReceivePath/*)", + network, + ); + +Descriptor buildBip86ChangeDescriptor(Network network) => Descriptor( + "tr($testExtendedPrivKey/$bip86TestChangePath/*)", + network, + ); + +Descriptor buildMainnetBip84Descriptor() => Descriptor( + "wpkh($mainnetExtendedPrivKey/$bip84MainnetReceivePath/*)", + Network.bitcoin, + ); + +Descriptor buildMainnetBip86Descriptor() => Descriptor( + "tr($mainnetExtendedPrivKey/$bip86MainnetReceivePath/*)", + Network.bitcoin, + ); + +Descriptor buildNonExtendedDescriptor(int index) => Descriptor( + "wpkh($testExtendedPrivKey/$bip84TestReceivePath/$index)", + Network.testnet, + ); + +const defaultLookahead = 25; diff --git a/bdk-dart/test/wallet_behavior_test.dart b/bdk-dart/test/wallet_behavior_test.dart new file mode 100644 index 00000000..cf6ea9a7 --- /dev/null +++ b/bdk-dart/test/wallet_behavior_test.dart @@ -0,0 +1,53 @@ +import 'package:bdk_dart/bdk.dart'; +import 'package:test/test.dart'; + +import 'test_constants.dart'; + +Wallet _buildTestWallet() { + final persister = Persister.newInMemory(); + return Wallet( + buildBip84Descriptor(Network.testnet), + buildBip84ChangeDescriptor(Network.testnet), + Network.testnet, + persister, + defaultLookahead, + ); +} + +void main() { + group('Wallet behaviour', () { + test('produces addresses valid for expected networks', () { + final wallet = _buildTestWallet(); + final addressInfo = wallet.revealNextAddress(KeychainKind.external_); + + expect(addressInfo.address.isValidForNetwork(Network.testnet), isTrue); + expect(addressInfo.address.isValidForNetwork(Network.testnet4), isTrue); + expect(addressInfo.address.isValidForNetwork(Network.signet), isTrue); + expect(addressInfo.address.isValidForNetwork(Network.regtest), isFalse); + expect(addressInfo.address.isValidForNetwork(Network.bitcoin), isFalse); + }); + + test('starts with zero balance before sync', () { + final wallet = _buildTestWallet(); + expect(wallet.balance().total.toSat(), equals(0)); + }); + + test('single-descriptor wallet returns identical external/internal addresses', () { + final persister = Persister.newInMemory(); + final wallet = Wallet.createSingle( + buildBip84Descriptor(Network.testnet), + Network.testnet, + persister, + defaultLookahead, + ); + + final externalAddress = wallet.peekAddress(KeychainKind.external_, 0); + final internalAddress = wallet.peekAddress(KeychainKind.internal, 0); + + expect( + externalAddress.address.scriptPubkey().toBytes(), + orderedEquals(internalAddress.address.scriptPubkey().toBytes()), + ); + }); + }); +} diff --git a/bdk-dart/test/wallet_creation_test.dart b/bdk-dart/test/wallet_creation_test.dart new file mode 100644 index 00000000..de40f2aa --- /dev/null +++ b/bdk-dart/test/wallet_creation_test.dart @@ -0,0 +1,102 @@ +import 'package:bdk_dart/bdk.dart'; +import 'package:test/test.dart'; + +import 'test_constants.dart'; + +Wallet _createWallet( + Descriptor descriptor, + Descriptor changeDescriptor, +) { + final persister = Persister.newInMemory(); + return Wallet( + descriptor, + changeDescriptor, + Network.testnet, + persister, + defaultLookahead, + ); +} + +void main() { + group('Wallet construction', () { + test('creates WPKH wallet', () { + expect( + () => _createWallet( + buildBip84Descriptor(Network.testnet), + buildBip84ChangeDescriptor(Network.testnet), + ), + returnsNormally, + ); + }); + + test('creates TR wallet', () { + expect( + () => _createWallet( + buildBip86Descriptor(Network.testnet), + buildBip86ChangeDescriptor(Network.testnet), + ), + returnsNormally, + ); + }); + + test('creates wallet with non-extended descriptors', () { + expect( + () => _createWallet( + buildNonExtendedDescriptor(0), + buildNonExtendedDescriptor(1), + ), + returnsNormally, + ); + }); + + test('creates single-descriptor wallet', () { + final persister = Persister.newInMemory(); + expect( + () => Wallet.createSingle( + buildBip86Descriptor(Network.testnet), + Network.testnet, + persister, + defaultLookahead, + ), + returnsNormally, + ); + }); + + test('creates wallet from public multipath descriptor', () { + final persister = Persister.newInMemory(); + expect( + () => Wallet.createFromTwoPathDescriptor( + buildDescriptor(multipathDescriptorString, Network.bitcoin), + Network.bitcoin, + persister, + defaultLookahead, + ), + returnsNormally, + ); + }); + + test('fails for private multipath descriptor', () { + expect( + () => buildDescriptor( + privateMultipathDescriptorString, + Network.testnet, + ), + throwsA(isA()), + ); + }); + + test('fails when descriptors do not match network', () { + final persister = Persister.newInMemory(); + expect( + () => Wallet( + buildNonExtendedDescriptor(0), + buildNonExtendedDescriptor(1), + Network.bitcoin, + persister, + defaultLookahead, + ), + throwsA(isA()), + ); + }); + }); +} From 401529bc0773ffe94c164932076eb417c7c46706 Mon Sep 17 00:00:00 2001 From: chavic Date: Mon, 22 Sep 2025 12:09:50 +0200 Subject: [PATCH 3/4] feat: generate dart bindings --- bdk-dart/lib/bdk.dart | 27520 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 27520 insertions(+) create mode 100644 bdk-dart/lib/bdk.dart diff --git a/bdk-dart/lib/bdk.dart b/bdk-dart/lib/bdk.dart new file mode 100644 index 00000000..0e045dee --- /dev/null +++ b/bdk-dart/lib/bdk.dart @@ -0,0 +1,27520 @@ +library uniffi; + +import "dart:async"; +import "dart:convert"; +import "dart:ffi"; +import "dart:io" show Platform, File, Directory; +import "dart:isolate"; +import "dart:typed_data"; +import "package:ffi/ffi.dart"; + +class AddressInfo { + final int index; + final Address address; + final KeychainKind keychain; + AddressInfo( + this.index, + this.address, + this.keychain, + ); +} + +class FfiConverterAddressInfo { + static AddressInfo lift(RustBuffer buf) { + return FfiConverterAddressInfo.read(buf.asUint8List()).value; + } + + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final index_lifted = + FfiConverterUInt32.read(Uint8List.view(buf.buffer, new_offset)); + final index = index_lifted.value; + new_offset += index_lifted.bytesRead; + final address_lifted = Address.read(Uint8List.view(buf.buffer, new_offset)); + final address = address_lifted.value; + new_offset += address_lifted.bytesRead; + final keychain_lifted = + FfiConverterKeychainKind.read(Uint8List.view(buf.buffer, new_offset)); + final keychain = keychain_lifted.value; + new_offset += keychain_lifted.bytesRead; + return LiftRetVal( + AddressInfo( + index, + address, + keychain, + ), + new_offset - buf.offsetInBytes); + } + + static RustBuffer lower(AddressInfo value) { + final total_length = FfiConverterUInt32.allocationSize(value.index) + + Address.allocationSize(value.address) + + FfiConverterKeychainKind.allocationSize(value.keychain) + + 0; + final buf = Uint8List(total_length); + write(value, buf); + return toRustBuffer(buf); + } + + static int write(AddressInfo value, Uint8List buf) { + int new_offset = buf.offsetInBytes; + new_offset += FfiConverterUInt32.write( + value.index, Uint8List.view(buf.buffer, new_offset)); + new_offset += + Address.write(value.address, Uint8List.view(buf.buffer, new_offset)); + new_offset += FfiConverterKeychainKind.write( + value.keychain, Uint8List.view(buf.buffer, new_offset)); + return new_offset - buf.offsetInBytes; + } + + static int allocationSize(AddressInfo value) { + return FfiConverterUInt32.allocationSize(value.index) + + Address.allocationSize(value.address) + + FfiConverterKeychainKind.allocationSize(value.keychain) + + 0; + } +} + +class Anchor { + final ConfirmationBlockTime confirmationBlockTime; + final Txid txid; + Anchor( + this.confirmationBlockTime, + this.txid, + ); +} + +class FfiConverterAnchor { + static Anchor lift(RustBuffer buf) { + return FfiConverterAnchor.read(buf.asUint8List()).value; + } + + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final confirmationBlockTime_lifted = FfiConverterConfirmationBlockTime.read( + Uint8List.view(buf.buffer, new_offset)); + final confirmationBlockTime = confirmationBlockTime_lifted.value; + new_offset += confirmationBlockTime_lifted.bytesRead; + final txid_lifted = Txid.read(Uint8List.view(buf.buffer, new_offset)); + final txid = txid_lifted.value; + new_offset += txid_lifted.bytesRead; + return LiftRetVal( + Anchor( + confirmationBlockTime, + txid, + ), + new_offset - buf.offsetInBytes); + } + + static RustBuffer lower(Anchor value) { + final total_length = FfiConverterConfirmationBlockTime.allocationSize( + value.confirmationBlockTime) + + Txid.allocationSize(value.txid) + + 0; + final buf = Uint8List(total_length); + write(value, buf); + return toRustBuffer(buf); + } + + static int write(Anchor value, Uint8List buf) { + int new_offset = buf.offsetInBytes; + new_offset += FfiConverterConfirmationBlockTime.write( + value.confirmationBlockTime, Uint8List.view(buf.buffer, new_offset)); + new_offset += + Txid.write(value.txid, Uint8List.view(buf.buffer, new_offset)); + return new_offset - buf.offsetInBytes; + } + + static int allocationSize(Anchor value) { + return FfiConverterConfirmationBlockTime.allocationSize( + value.confirmationBlockTime) + + Txid.allocationSize(value.txid) + + 0; + } +} + +class Balance { + final Amount immature; + final Amount trustedPending; + final Amount untrustedPending; + final Amount confirmed; + final Amount trustedSpendable; + final Amount total; + Balance( + this.immature, + this.trustedPending, + this.untrustedPending, + this.confirmed, + this.trustedSpendable, + this.total, + ); +} + +class FfiConverterBalance { + static Balance lift(RustBuffer buf) { + return FfiConverterBalance.read(buf.asUint8List()).value; + } + + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final immature_lifted = Amount.read(Uint8List.view(buf.buffer, new_offset)); + final immature = immature_lifted.value; + new_offset += immature_lifted.bytesRead; + final trustedPending_lifted = + Amount.read(Uint8List.view(buf.buffer, new_offset)); + final trustedPending = trustedPending_lifted.value; + new_offset += trustedPending_lifted.bytesRead; + final untrustedPending_lifted = + Amount.read(Uint8List.view(buf.buffer, new_offset)); + final untrustedPending = untrustedPending_lifted.value; + new_offset += untrustedPending_lifted.bytesRead; + final confirmed_lifted = + Amount.read(Uint8List.view(buf.buffer, new_offset)); + final confirmed = confirmed_lifted.value; + new_offset += confirmed_lifted.bytesRead; + final trustedSpendable_lifted = + Amount.read(Uint8List.view(buf.buffer, new_offset)); + final trustedSpendable = trustedSpendable_lifted.value; + new_offset += trustedSpendable_lifted.bytesRead; + final total_lifted = Amount.read(Uint8List.view(buf.buffer, new_offset)); + final total = total_lifted.value; + new_offset += total_lifted.bytesRead; + return LiftRetVal( + Balance( + immature, + trustedPending, + untrustedPending, + confirmed, + trustedSpendable, + total, + ), + new_offset - buf.offsetInBytes); + } + + static RustBuffer lower(Balance value) { + final total_length = Amount.allocationSize(value.immature) + + Amount.allocationSize(value.trustedPending) + + Amount.allocationSize(value.untrustedPending) + + Amount.allocationSize(value.confirmed) + + Amount.allocationSize(value.trustedSpendable) + + Amount.allocationSize(value.total) + + 0; + final buf = Uint8List(total_length); + write(value, buf); + return toRustBuffer(buf); + } + + static int write(Balance value, Uint8List buf) { + int new_offset = buf.offsetInBytes; + new_offset += + Amount.write(value.immature, Uint8List.view(buf.buffer, new_offset)); + new_offset += Amount.write( + value.trustedPending, Uint8List.view(buf.buffer, new_offset)); + new_offset += Amount.write( + value.untrustedPending, Uint8List.view(buf.buffer, new_offset)); + new_offset += + Amount.write(value.confirmed, Uint8List.view(buf.buffer, new_offset)); + new_offset += Amount.write( + value.trustedSpendable, Uint8List.view(buf.buffer, new_offset)); + new_offset += + Amount.write(value.total, Uint8List.view(buf.buffer, new_offset)); + return new_offset - buf.offsetInBytes; + } + + static int allocationSize(Balance value) { + return Amount.allocationSize(value.immature) + + Amount.allocationSize(value.trustedPending) + + Amount.allocationSize(value.untrustedPending) + + Amount.allocationSize(value.confirmed) + + Amount.allocationSize(value.trustedSpendable) + + Amount.allocationSize(value.total) + + 0; + } +} + +class BlockId { + final int height; + final BlockHash hash; + BlockId( + this.height, + this.hash, + ); +} + +class FfiConverterBlockId { + static BlockId lift(RustBuffer buf) { + return FfiConverterBlockId.read(buf.asUint8List()).value; + } + + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final height_lifted = + FfiConverterUInt32.read(Uint8List.view(buf.buffer, new_offset)); + final height = height_lifted.value; + new_offset += height_lifted.bytesRead; + final hash_lifted = BlockHash.read(Uint8List.view(buf.buffer, new_offset)); + final hash = hash_lifted.value; + new_offset += hash_lifted.bytesRead; + return LiftRetVal( + BlockId( + height, + hash, + ), + new_offset - buf.offsetInBytes); + } + + static RustBuffer lower(BlockId value) { + final total_length = FfiConverterUInt32.allocationSize(value.height) + + BlockHash.allocationSize(value.hash) + + 0; + final buf = Uint8List(total_length); + write(value, buf); + return toRustBuffer(buf); + } + + static int write(BlockId value, Uint8List buf) { + int new_offset = buf.offsetInBytes; + new_offset += FfiConverterUInt32.write( + value.height, Uint8List.view(buf.buffer, new_offset)); + new_offset += + BlockHash.write(value.hash, Uint8List.view(buf.buffer, new_offset)); + return new_offset - buf.offsetInBytes; + } + + static int allocationSize(BlockId value) { + return FfiConverterUInt32.allocationSize(value.height) + + BlockHash.allocationSize(value.hash) + + 0; + } +} + +class CanonicalTx { + final Transaction transaction; + final ChainPosition chainPosition; + CanonicalTx( + this.transaction, + this.chainPosition, + ); +} + +class FfiConverterCanonicalTx { + static CanonicalTx lift(RustBuffer buf) { + return FfiConverterCanonicalTx.read(buf.asUint8List()).value; + } + + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final transaction_lifted = + Transaction.read(Uint8List.view(buf.buffer, new_offset)); + final transaction = transaction_lifted.value; + new_offset += transaction_lifted.bytesRead; + final chainPosition_lifted = + FfiConverterChainPosition.read(Uint8List.view(buf.buffer, new_offset)); + final chainPosition = chainPosition_lifted.value; + new_offset += chainPosition_lifted.bytesRead; + return LiftRetVal( + CanonicalTx( + transaction, + chainPosition, + ), + new_offset - buf.offsetInBytes); + } + + static RustBuffer lower(CanonicalTx value) { + final total_length = Transaction.allocationSize(value.transaction) + + FfiConverterChainPosition.allocationSize(value.chainPosition) + + 0; + final buf = Uint8List(total_length); + write(value, buf); + return toRustBuffer(buf); + } + + static int write(CanonicalTx value, Uint8List buf) { + int new_offset = buf.offsetInBytes; + new_offset += Transaction.write( + value.transaction, Uint8List.view(buf.buffer, new_offset)); + new_offset += FfiConverterChainPosition.write( + value.chainPosition, Uint8List.view(buf.buffer, new_offset)); + return new_offset - buf.offsetInBytes; + } + + static int allocationSize(CanonicalTx value) { + return Transaction.allocationSize(value.transaction) + + FfiConverterChainPosition.allocationSize(value.chainPosition) + + 0; + } +} + +class CbfComponents { + final CbfClient client; + final CbfNode node; + CbfComponents( + this.client, + this.node, + ); +} + +class FfiConverterCbfComponents { + static CbfComponents lift(RustBuffer buf) { + return FfiConverterCbfComponents.read(buf.asUint8List()).value; + } + + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final client_lifted = + CbfClient.read(Uint8List.view(buf.buffer, new_offset)); + final client = client_lifted.value; + new_offset += client_lifted.bytesRead; + final node_lifted = CbfNode.read(Uint8List.view(buf.buffer, new_offset)); + final node = node_lifted.value; + new_offset += node_lifted.bytesRead; + return LiftRetVal( + CbfComponents( + client, + node, + ), + new_offset - buf.offsetInBytes); + } + + static RustBuffer lower(CbfComponents value) { + final total_length = CbfClient.allocationSize(value.client) + + CbfNode.allocationSize(value.node) + + 0; + final buf = Uint8List(total_length); + write(value, buf); + return toRustBuffer(buf); + } + + static int write(CbfComponents value, Uint8List buf) { + int new_offset = buf.offsetInBytes; + new_offset += + CbfClient.write(value.client, Uint8List.view(buf.buffer, new_offset)); + new_offset += + CbfNode.write(value.node, Uint8List.view(buf.buffer, new_offset)); + return new_offset - buf.offsetInBytes; + } + + static int allocationSize(CbfComponents value) { + return CbfClient.allocationSize(value.client) + + CbfNode.allocationSize(value.node) + + 0; + } +} + +class ChainChange { + final int height; + final BlockHash? hash; + ChainChange( + this.height, + this.hash, + ); +} + +class FfiConverterChainChange { + static ChainChange lift(RustBuffer buf) { + return FfiConverterChainChange.read(buf.asUint8List()).value; + } + + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final height_lifted = + FfiConverterUInt32.read(Uint8List.view(buf.buffer, new_offset)); + final height = height_lifted.value; + new_offset += height_lifted.bytesRead; + final hash_lifted = FfiConverterOptionalBlockHash.read( + Uint8List.view(buf.buffer, new_offset)); + final hash = hash_lifted.value; + new_offset += hash_lifted.bytesRead; + return LiftRetVal( + ChainChange( + height, + hash, + ), + new_offset - buf.offsetInBytes); + } + + static RustBuffer lower(ChainChange value) { + final total_length = FfiConverterUInt32.allocationSize(value.height) + + FfiConverterOptionalBlockHash.allocationSize(value.hash) + + 0; + final buf = Uint8List(total_length); + write(value, buf); + return toRustBuffer(buf); + } + + static int write(ChainChange value, Uint8List buf) { + int new_offset = buf.offsetInBytes; + new_offset += FfiConverterUInt32.write( + value.height, Uint8List.view(buf.buffer, new_offset)); + new_offset += FfiConverterOptionalBlockHash.write( + value.hash, Uint8List.view(buf.buffer, new_offset)); + return new_offset - buf.offsetInBytes; + } + + static int allocationSize(ChainChange value) { + return FfiConverterUInt32.allocationSize(value.height) + + FfiConverterOptionalBlockHash.allocationSize(value.hash) + + 0; + } +} + +class Condition { + final int? csv; + final LockTime? timelock; + Condition( + this.csv, + this.timelock, + ); +} + +class FfiConverterCondition { + static Condition lift(RustBuffer buf) { + return FfiConverterCondition.read(buf.asUint8List()).value; + } + + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final csv_lifted = + FfiConverterOptionalUInt32.read(Uint8List.view(buf.buffer, new_offset)); + final csv = csv_lifted.value; + new_offset += csv_lifted.bytesRead; + final timelock_lifted = FfiConverterOptionalLockTime.read( + Uint8List.view(buf.buffer, new_offset)); + final timelock = timelock_lifted.value; + new_offset += timelock_lifted.bytesRead; + return LiftRetVal( + Condition( + csv, + timelock, + ), + new_offset - buf.offsetInBytes); + } + + static RustBuffer lower(Condition value) { + final total_length = FfiConverterOptionalUInt32.allocationSize(value.csv) + + FfiConverterOptionalLockTime.allocationSize(value.timelock) + + 0; + final buf = Uint8List(total_length); + write(value, buf); + return toRustBuffer(buf); + } + + static int write(Condition value, Uint8List buf) { + int new_offset = buf.offsetInBytes; + new_offset += FfiConverterOptionalUInt32.write( + value.csv, Uint8List.view(buf.buffer, new_offset)); + new_offset += FfiConverterOptionalLockTime.write( + value.timelock, Uint8List.view(buf.buffer, new_offset)); + return new_offset - buf.offsetInBytes; + } + + static int allocationSize(Condition value) { + return FfiConverterOptionalUInt32.allocationSize(value.csv) + + FfiConverterOptionalLockTime.allocationSize(value.timelock) + + 0; + } +} + +class ConfirmationBlockTime { + final BlockId blockId; + final int confirmationTime; + ConfirmationBlockTime( + this.blockId, + this.confirmationTime, + ); +} + +class FfiConverterConfirmationBlockTime { + static ConfirmationBlockTime lift(RustBuffer buf) { + return FfiConverterConfirmationBlockTime.read(buf.asUint8List()).value; + } + + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final blockId_lifted = + FfiConverterBlockId.read(Uint8List.view(buf.buffer, new_offset)); + final blockId = blockId_lifted.value; + new_offset += blockId_lifted.bytesRead; + final confirmationTime_lifted = + FfiConverterUInt64.read(Uint8List.view(buf.buffer, new_offset)); + final confirmationTime = confirmationTime_lifted.value; + new_offset += confirmationTime_lifted.bytesRead; + return LiftRetVal( + ConfirmationBlockTime( + blockId, + confirmationTime, + ), + new_offset - buf.offsetInBytes); + } + + static RustBuffer lower(ConfirmationBlockTime value) { + final total_length = FfiConverterBlockId.allocationSize(value.blockId) + + FfiConverterUInt64.allocationSize(value.confirmationTime) + + 0; + final buf = Uint8List(total_length); + write(value, buf); + return toRustBuffer(buf); + } + + static int write(ConfirmationBlockTime value, Uint8List buf) { + int new_offset = buf.offsetInBytes; + new_offset += FfiConverterBlockId.write( + value.blockId, Uint8List.view(buf.buffer, new_offset)); + new_offset += FfiConverterUInt64.write( + value.confirmationTime, Uint8List.view(buf.buffer, new_offset)); + return new_offset - buf.offsetInBytes; + } + + static int allocationSize(ConfirmationBlockTime value) { + return FfiConverterBlockId.allocationSize(value.blockId) + + FfiConverterUInt64.allocationSize(value.confirmationTime) + + 0; + } +} + +class EvictedTx { + final Txid txid; + final int evictedAt; + EvictedTx( + this.txid, + this.evictedAt, + ); +} + +class FfiConverterEvictedTx { + static EvictedTx lift(RustBuffer buf) { + return FfiConverterEvictedTx.read(buf.asUint8List()).value; + } + + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final txid_lifted = Txid.read(Uint8List.view(buf.buffer, new_offset)); + final txid = txid_lifted.value; + new_offset += txid_lifted.bytesRead; + final evictedAt_lifted = + FfiConverterUInt64.read(Uint8List.view(buf.buffer, new_offset)); + final evictedAt = evictedAt_lifted.value; + new_offset += evictedAt_lifted.bytesRead; + return LiftRetVal( + EvictedTx( + txid, + evictedAt, + ), + new_offset - buf.offsetInBytes); + } + + static RustBuffer lower(EvictedTx value) { + final total_length = Txid.allocationSize(value.txid) + + FfiConverterUInt64.allocationSize(value.evictedAt) + + 0; + final buf = Uint8List(total_length); + write(value, buf); + return toRustBuffer(buf); + } + + static int write(EvictedTx value, Uint8List buf) { + int new_offset = buf.offsetInBytes; + new_offset += + Txid.write(value.txid, Uint8List.view(buf.buffer, new_offset)); + new_offset += FfiConverterUInt64.write( + value.evictedAt, Uint8List.view(buf.buffer, new_offset)); + return new_offset - buf.offsetInBytes; + } + + static int allocationSize(EvictedTx value) { + return Txid.allocationSize(value.txid) + + FfiConverterUInt64.allocationSize(value.evictedAt) + + 0; + } +} + +class FinalizedPsbtResult { + final Psbt psbt; + final bool couldFinalize; + final List? errors; + FinalizedPsbtResult( + this.psbt, + this.couldFinalize, + this.errors, + ); +} + +class FfiConverterFinalizedPsbtResult { + static FinalizedPsbtResult lift(RustBuffer buf) { + return FfiConverterFinalizedPsbtResult.read(buf.asUint8List()).value; + } + + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final psbt_lifted = Psbt.read(Uint8List.view(buf.buffer, new_offset)); + final psbt = psbt_lifted.value; + new_offset += psbt_lifted.bytesRead; + final couldFinalize_lifted = + FfiConverterBool.read(Uint8List.view(buf.buffer, new_offset)); + final couldFinalize = couldFinalize_lifted.value; + new_offset += couldFinalize_lifted.bytesRead; + final errors_lifted = FfiConverterOptionalSequencePsbtFinalizeError.read( + Uint8List.view(buf.buffer, new_offset)); + final errors = errors_lifted.value; + new_offset += errors_lifted.bytesRead; + return LiftRetVal( + FinalizedPsbtResult( + psbt, + couldFinalize, + errors, + ), + new_offset - buf.offsetInBytes); + } + + static RustBuffer lower(FinalizedPsbtResult value) { + final total_length = Psbt.allocationSize(value.psbt) + + FfiConverterBool.allocationSize(value.couldFinalize) + + FfiConverterOptionalSequencePsbtFinalizeError.allocationSize( + value.errors) + + 0; + final buf = Uint8List(total_length); + write(value, buf); + return toRustBuffer(buf); + } + + static int write(FinalizedPsbtResult value, Uint8List buf) { + int new_offset = buf.offsetInBytes; + new_offset += + Psbt.write(value.psbt, Uint8List.view(buf.buffer, new_offset)); + new_offset += FfiConverterBool.write( + value.couldFinalize, Uint8List.view(buf.buffer, new_offset)); + new_offset += FfiConverterOptionalSequencePsbtFinalizeError.write( + value.errors, Uint8List.view(buf.buffer, new_offset)); + return new_offset - buf.offsetInBytes; + } + + static int allocationSize(FinalizedPsbtResult value) { + return Psbt.allocationSize(value.psbt) + + FfiConverterBool.allocationSize(value.couldFinalize) + + FfiConverterOptionalSequencePsbtFinalizeError.allocationSize( + value.errors) + + 0; + } +} + +class Header { + final int version; + final BlockHash prevBlockhash; + final TxMerkleNode merkleRoot; + final int time; + final int bits; + final int nonce; + Header( + this.version, + this.prevBlockhash, + this.merkleRoot, + this.time, + this.bits, + this.nonce, + ); +} + +class FfiConverterHeader { + static Header lift(RustBuffer buf) { + return FfiConverterHeader.read(buf.asUint8List()).value; + } + + static LiftRetVal
read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final version_lifted = + FfiConverterInt32.read(Uint8List.view(buf.buffer, new_offset)); + final version = version_lifted.value; + new_offset += version_lifted.bytesRead; + final prevBlockhash_lifted = + BlockHash.read(Uint8List.view(buf.buffer, new_offset)); + final prevBlockhash = prevBlockhash_lifted.value; + new_offset += prevBlockhash_lifted.bytesRead; + final merkleRoot_lifted = + TxMerkleNode.read(Uint8List.view(buf.buffer, new_offset)); + final merkleRoot = merkleRoot_lifted.value; + new_offset += merkleRoot_lifted.bytesRead; + final time_lifted = + FfiConverterUInt32.read(Uint8List.view(buf.buffer, new_offset)); + final time = time_lifted.value; + new_offset += time_lifted.bytesRead; + final bits_lifted = + FfiConverterUInt32.read(Uint8List.view(buf.buffer, new_offset)); + final bits = bits_lifted.value; + new_offset += bits_lifted.bytesRead; + final nonce_lifted = + FfiConverterUInt32.read(Uint8List.view(buf.buffer, new_offset)); + final nonce = nonce_lifted.value; + new_offset += nonce_lifted.bytesRead; + return LiftRetVal( + Header( + version, + prevBlockhash, + merkleRoot, + time, + bits, + nonce, + ), + new_offset - buf.offsetInBytes); + } + + static RustBuffer lower(Header value) { + final total_length = FfiConverterInt32.allocationSize(value.version) + + BlockHash.allocationSize(value.prevBlockhash) + + TxMerkleNode.allocationSize(value.merkleRoot) + + FfiConverterUInt32.allocationSize(value.time) + + FfiConverterUInt32.allocationSize(value.bits) + + FfiConverterUInt32.allocationSize(value.nonce) + + 0; + final buf = Uint8List(total_length); + write(value, buf); + return toRustBuffer(buf); + } + + static int write(Header value, Uint8List buf) { + int new_offset = buf.offsetInBytes; + new_offset += FfiConverterInt32.write( + value.version, Uint8List.view(buf.buffer, new_offset)); + new_offset += BlockHash.write( + value.prevBlockhash, Uint8List.view(buf.buffer, new_offset)); + new_offset += TxMerkleNode.write( + value.merkleRoot, Uint8List.view(buf.buffer, new_offset)); + new_offset += FfiConverterUInt32.write( + value.time, Uint8List.view(buf.buffer, new_offset)); + new_offset += FfiConverterUInt32.write( + value.bits, Uint8List.view(buf.buffer, new_offset)); + new_offset += FfiConverterUInt32.write( + value.nonce, Uint8List.view(buf.buffer, new_offset)); + return new_offset - buf.offsetInBytes; + } + + static int allocationSize(Header value) { + return FfiConverterInt32.allocationSize(value.version) + + BlockHash.allocationSize(value.prevBlockhash) + + TxMerkleNode.allocationSize(value.merkleRoot) + + FfiConverterUInt32.allocationSize(value.time) + + FfiConverterUInt32.allocationSize(value.bits) + + FfiConverterUInt32.allocationSize(value.nonce) + + 0; + } +} + +class HeaderNotification { + final int height; + final Header header; + HeaderNotification( + this.height, + this.header, + ); +} + +class FfiConverterHeaderNotification { + static HeaderNotification lift(RustBuffer buf) { + return FfiConverterHeaderNotification.read(buf.asUint8List()).value; + } + + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final height_lifted = + FfiConverterUInt64.read(Uint8List.view(buf.buffer, new_offset)); + final height = height_lifted.value; + new_offset += height_lifted.bytesRead; + final header_lifted = + FfiConverterHeader.read(Uint8List.view(buf.buffer, new_offset)); + final header = header_lifted.value; + new_offset += header_lifted.bytesRead; + return LiftRetVal( + HeaderNotification( + height, + header, + ), + new_offset - buf.offsetInBytes); + } + + static RustBuffer lower(HeaderNotification value) { + final total_length = FfiConverterUInt64.allocationSize(value.height) + + FfiConverterHeader.allocationSize(value.header) + + 0; + final buf = Uint8List(total_length); + write(value, buf); + return toRustBuffer(buf); + } + + static int write(HeaderNotification value, Uint8List buf) { + int new_offset = buf.offsetInBytes; + new_offset += FfiConverterUInt64.write( + value.height, Uint8List.view(buf.buffer, new_offset)); + new_offset += FfiConverterHeader.write( + value.header, Uint8List.view(buf.buffer, new_offset)); + return new_offset - buf.offsetInBytes; + } + + static int allocationSize(HeaderNotification value) { + return FfiConverterUInt64.allocationSize(value.height) + + FfiConverterHeader.allocationSize(value.header) + + 0; + } +} + +class IndexerChangeSet { + final Map lastRevealed; + IndexerChangeSet( + this.lastRevealed, + ); +} + +class FfiConverterIndexerChangeSet { + static IndexerChangeSet lift(RustBuffer buf) { + return FfiConverterIndexerChangeSet.read(buf.asUint8List()).value; + } + + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final lastRevealed_lifted = FfiConverterMapDescriptorIdToUInt32.read( + Uint8List.view(buf.buffer, new_offset)); + final lastRevealed = lastRevealed_lifted.value; + new_offset += lastRevealed_lifted.bytesRead; + return LiftRetVal( + IndexerChangeSet( + lastRevealed, + ), + new_offset - buf.offsetInBytes); + } + + static RustBuffer lower(IndexerChangeSet value) { + final total_length = + FfiConverterMapDescriptorIdToUInt32.allocationSize(value.lastRevealed) + + 0; + final buf = Uint8List(total_length); + write(value, buf); + return toRustBuffer(buf); + } + + static int write(IndexerChangeSet value, Uint8List buf) { + int new_offset = buf.offsetInBytes; + new_offset += FfiConverterMapDescriptorIdToUInt32.write( + value.lastRevealed, Uint8List.view(buf.buffer, new_offset)); + return new_offset - buf.offsetInBytes; + } + + static int allocationSize(IndexerChangeSet value) { + return FfiConverterMapDescriptorIdToUInt32.allocationSize( + value.lastRevealed) + + 0; + } +} + +class KeychainAndIndex { + final KeychainKind keychain; + final int index; + KeychainAndIndex( + this.keychain, + this.index, + ); +} + +class FfiConverterKeychainAndIndex { + static KeychainAndIndex lift(RustBuffer buf) { + return FfiConverterKeychainAndIndex.read(buf.asUint8List()).value; + } + + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final keychain_lifted = + FfiConverterKeychainKind.read(Uint8List.view(buf.buffer, new_offset)); + final keychain = keychain_lifted.value; + new_offset += keychain_lifted.bytesRead; + final index_lifted = + FfiConverterUInt32.read(Uint8List.view(buf.buffer, new_offset)); + final index = index_lifted.value; + new_offset += index_lifted.bytesRead; + return LiftRetVal( + KeychainAndIndex( + keychain, + index, + ), + new_offset - buf.offsetInBytes); + } + + static RustBuffer lower(KeychainAndIndex value) { + final total_length = + FfiConverterKeychainKind.allocationSize(value.keychain) + + FfiConverterUInt32.allocationSize(value.index) + + 0; + final buf = Uint8List(total_length); + write(value, buf); + return toRustBuffer(buf); + } + + static int write(KeychainAndIndex value, Uint8List buf) { + int new_offset = buf.offsetInBytes; + new_offset += FfiConverterKeychainKind.write( + value.keychain, Uint8List.view(buf.buffer, new_offset)); + new_offset += FfiConverterUInt32.write( + value.index, Uint8List.view(buf.buffer, new_offset)); + return new_offset - buf.offsetInBytes; + } + + static int allocationSize(KeychainAndIndex value) { + return FfiConverterKeychainKind.allocationSize(value.keychain) + + FfiConverterUInt32.allocationSize(value.index) + + 0; + } +} + +class LocalChainChangeSet { + final List changes; + LocalChainChangeSet( + this.changes, + ); +} + +class FfiConverterLocalChainChangeSet { + static LocalChainChangeSet lift(RustBuffer buf) { + return FfiConverterLocalChainChangeSet.read(buf.asUint8List()).value; + } + + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final changes_lifted = FfiConverterSequenceChainChange.read( + Uint8List.view(buf.buffer, new_offset)); + final changes = changes_lifted.value; + new_offset += changes_lifted.bytesRead; + return LiftRetVal( + LocalChainChangeSet( + changes, + ), + new_offset - buf.offsetInBytes); + } + + static RustBuffer lower(LocalChainChangeSet value) { + final total_length = + FfiConverterSequenceChainChange.allocationSize(value.changes) + 0; + final buf = Uint8List(total_length); + write(value, buf); + return toRustBuffer(buf); + } + + static int write(LocalChainChangeSet value, Uint8List buf) { + int new_offset = buf.offsetInBytes; + new_offset += FfiConverterSequenceChainChange.write( + value.changes, Uint8List.view(buf.buffer, new_offset)); + return new_offset - buf.offsetInBytes; + } + + static int allocationSize(LocalChainChangeSet value) { + return FfiConverterSequenceChainChange.allocationSize(value.changes) + 0; + } +} + +class LocalOutput { + final OutPoint outpoint; + final TxOut txout; + final KeychainKind keychain; + final bool isSpent; + final int derivationIndex; + final ChainPosition chainPosition; + LocalOutput( + this.outpoint, + this.txout, + this.keychain, + this.isSpent, + this.derivationIndex, + this.chainPosition, + ); +} + +class FfiConverterLocalOutput { + static LocalOutput lift(RustBuffer buf) { + return FfiConverterLocalOutput.read(buf.asUint8List()).value; + } + + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final outpoint_lifted = + FfiConverterOutPoint.read(Uint8List.view(buf.buffer, new_offset)); + final outpoint = outpoint_lifted.value; + new_offset += outpoint_lifted.bytesRead; + final txout_lifted = + FfiConverterTxOut.read(Uint8List.view(buf.buffer, new_offset)); + final txout = txout_lifted.value; + new_offset += txout_lifted.bytesRead; + final keychain_lifted = + FfiConverterKeychainKind.read(Uint8List.view(buf.buffer, new_offset)); + final keychain = keychain_lifted.value; + new_offset += keychain_lifted.bytesRead; + final isSpent_lifted = + FfiConverterBool.read(Uint8List.view(buf.buffer, new_offset)); + final isSpent = isSpent_lifted.value; + new_offset += isSpent_lifted.bytesRead; + final derivationIndex_lifted = + FfiConverterUInt32.read(Uint8List.view(buf.buffer, new_offset)); + final derivationIndex = derivationIndex_lifted.value; + new_offset += derivationIndex_lifted.bytesRead; + final chainPosition_lifted = + FfiConverterChainPosition.read(Uint8List.view(buf.buffer, new_offset)); + final chainPosition = chainPosition_lifted.value; + new_offset += chainPosition_lifted.bytesRead; + return LiftRetVal( + LocalOutput( + outpoint, + txout, + keychain, + isSpent, + derivationIndex, + chainPosition, + ), + new_offset - buf.offsetInBytes); + } + + static RustBuffer lower(LocalOutput value) { + final total_length = FfiConverterOutPoint.allocationSize(value.outpoint) + + FfiConverterTxOut.allocationSize(value.txout) + + FfiConverterKeychainKind.allocationSize(value.keychain) + + FfiConverterBool.allocationSize(value.isSpent) + + FfiConverterUInt32.allocationSize(value.derivationIndex) + + FfiConverterChainPosition.allocationSize(value.chainPosition) + + 0; + final buf = Uint8List(total_length); + write(value, buf); + return toRustBuffer(buf); + } + + static int write(LocalOutput value, Uint8List buf) { + int new_offset = buf.offsetInBytes; + new_offset += FfiConverterOutPoint.write( + value.outpoint, Uint8List.view(buf.buffer, new_offset)); + new_offset += FfiConverterTxOut.write( + value.txout, Uint8List.view(buf.buffer, new_offset)); + new_offset += FfiConverterKeychainKind.write( + value.keychain, Uint8List.view(buf.buffer, new_offset)); + new_offset += FfiConverterBool.write( + value.isSpent, Uint8List.view(buf.buffer, new_offset)); + new_offset += FfiConverterUInt32.write( + value.derivationIndex, Uint8List.view(buf.buffer, new_offset)); + new_offset += FfiConverterChainPosition.write( + value.chainPosition, Uint8List.view(buf.buffer, new_offset)); + return new_offset - buf.offsetInBytes; + } + + static int allocationSize(LocalOutput value) { + return FfiConverterOutPoint.allocationSize(value.outpoint) + + FfiConverterTxOut.allocationSize(value.txout) + + FfiConverterKeychainKind.allocationSize(value.keychain) + + FfiConverterBool.allocationSize(value.isSpent) + + FfiConverterUInt32.allocationSize(value.derivationIndex) + + FfiConverterChainPosition.allocationSize(value.chainPosition) + + 0; + } +} + +class OutPoint { + final Txid txid; + final int vout; + OutPoint( + this.txid, + this.vout, + ); +} + +class FfiConverterOutPoint { + static OutPoint lift(RustBuffer buf) { + return FfiConverterOutPoint.read(buf.asUint8List()).value; + } + + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final txid_lifted = Txid.read(Uint8List.view(buf.buffer, new_offset)); + final txid = txid_lifted.value; + new_offset += txid_lifted.bytesRead; + final vout_lifted = + FfiConverterUInt32.read(Uint8List.view(buf.buffer, new_offset)); + final vout = vout_lifted.value; + new_offset += vout_lifted.bytesRead; + return LiftRetVal( + OutPoint( + txid, + vout, + ), + new_offset - buf.offsetInBytes); + } + + static RustBuffer lower(OutPoint value) { + final total_length = Txid.allocationSize(value.txid) + + FfiConverterUInt32.allocationSize(value.vout) + + 0; + final buf = Uint8List(total_length); + write(value, buf); + return toRustBuffer(buf); + } + + static int write(OutPoint value, Uint8List buf) { + int new_offset = buf.offsetInBytes; + new_offset += + Txid.write(value.txid, Uint8List.view(buf.buffer, new_offset)); + new_offset += FfiConverterUInt32.write( + value.vout, Uint8List.view(buf.buffer, new_offset)); + return new_offset - buf.offsetInBytes; + } + + static int allocationSize(OutPoint value) { + return Txid.allocationSize(value.txid) + + FfiConverterUInt32.allocationSize(value.vout) + + 0; + } +} + +class Peer { + final IpAddress address; + final int? port; + final bool v2Transport; + Peer( + this.address, + this.port, + this.v2Transport, + ); +} + +class FfiConverterPeer { + static Peer lift(RustBuffer buf) { + return FfiConverterPeer.read(buf.asUint8List()).value; + } + + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final address_lifted = + IpAddress.read(Uint8List.view(buf.buffer, new_offset)); + final address = address_lifted.value; + new_offset += address_lifted.bytesRead; + final port_lifted = + FfiConverterOptionalUInt16.read(Uint8List.view(buf.buffer, new_offset)); + final port = port_lifted.value; + new_offset += port_lifted.bytesRead; + final v2Transport_lifted = + FfiConverterBool.read(Uint8List.view(buf.buffer, new_offset)); + final v2Transport = v2Transport_lifted.value; + new_offset += v2Transport_lifted.bytesRead; + return LiftRetVal( + Peer( + address, + port, + v2Transport, + ), + new_offset - buf.offsetInBytes); + } + + static RustBuffer lower(Peer value) { + final total_length = IpAddress.allocationSize(value.address) + + FfiConverterOptionalUInt16.allocationSize(value.port) + + FfiConverterBool.allocationSize(value.v2Transport) + + 0; + final buf = Uint8List(total_length); + write(value, buf); + return toRustBuffer(buf); + } + + static int write(Peer value, Uint8List buf) { + int new_offset = buf.offsetInBytes; + new_offset += + IpAddress.write(value.address, Uint8List.view(buf.buffer, new_offset)); + new_offset += FfiConverterOptionalUInt16.write( + value.port, Uint8List.view(buf.buffer, new_offset)); + new_offset += FfiConverterBool.write( + value.v2Transport, Uint8List.view(buf.buffer, new_offset)); + return new_offset - buf.offsetInBytes; + } + + static int allocationSize(Peer value) { + return IpAddress.allocationSize(value.address) + + FfiConverterOptionalUInt16.allocationSize(value.port) + + FfiConverterBool.allocationSize(value.v2Transport) + + 0; + } +} + +class ScriptAmount { + final Script script; + final Amount amount; + ScriptAmount( + this.script, + this.amount, + ); +} + +class FfiConverterScriptAmount { + static ScriptAmount lift(RustBuffer buf) { + return FfiConverterScriptAmount.read(buf.asUint8List()).value; + } + + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final script_lifted = Script.read(Uint8List.view(buf.buffer, new_offset)); + final script = script_lifted.value; + new_offset += script_lifted.bytesRead; + final amount_lifted = Amount.read(Uint8List.view(buf.buffer, new_offset)); + final amount = amount_lifted.value; + new_offset += amount_lifted.bytesRead; + return LiftRetVal( + ScriptAmount( + script, + amount, + ), + new_offset - buf.offsetInBytes); + } + + static RustBuffer lower(ScriptAmount value) { + final total_length = Script.allocationSize(value.script) + + Amount.allocationSize(value.amount) + + 0; + final buf = Uint8List(total_length); + write(value, buf); + return toRustBuffer(buf); + } + + static int write(ScriptAmount value, Uint8List buf) { + int new_offset = buf.offsetInBytes; + new_offset += + Script.write(value.script, Uint8List.view(buf.buffer, new_offset)); + new_offset += + Amount.write(value.amount, Uint8List.view(buf.buffer, new_offset)); + return new_offset - buf.offsetInBytes; + } + + static int allocationSize(ScriptAmount value) { + return Script.allocationSize(value.script) + + Amount.allocationSize(value.amount) + + 0; + } +} + +class SentAndReceivedValues { + final Amount sent; + final Amount received; + SentAndReceivedValues( + this.sent, + this.received, + ); +} + +class FfiConverterSentAndReceivedValues { + static SentAndReceivedValues lift(RustBuffer buf) { + return FfiConverterSentAndReceivedValues.read(buf.asUint8List()).value; + } + + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final sent_lifted = Amount.read(Uint8List.view(buf.buffer, new_offset)); + final sent = sent_lifted.value; + new_offset += sent_lifted.bytesRead; + final received_lifted = Amount.read(Uint8List.view(buf.buffer, new_offset)); + final received = received_lifted.value; + new_offset += received_lifted.bytesRead; + return LiftRetVal( + SentAndReceivedValues( + sent, + received, + ), + new_offset - buf.offsetInBytes); + } + + static RustBuffer lower(SentAndReceivedValues value) { + final total_length = Amount.allocationSize(value.sent) + + Amount.allocationSize(value.received) + + 0; + final buf = Uint8List(total_length); + write(value, buf); + return toRustBuffer(buf); + } + + static int write(SentAndReceivedValues value, Uint8List buf) { + int new_offset = buf.offsetInBytes; + new_offset += + Amount.write(value.sent, Uint8List.view(buf.buffer, new_offset)); + new_offset += + Amount.write(value.received, Uint8List.view(buf.buffer, new_offset)); + return new_offset - buf.offsetInBytes; + } + + static int allocationSize(SentAndReceivedValues value) { + return Amount.allocationSize(value.sent) + + Amount.allocationSize(value.received) + + 0; + } +} + +class ServerFeaturesRes { + final String serverVersion; + final BlockHash genesisHash; + final String protocolMin; + final String protocolMax; + final String? hashFunction; + final int? pruning; + ServerFeaturesRes( + this.serverVersion, + this.genesisHash, + this.protocolMin, + this.protocolMax, + this.hashFunction, + this.pruning, + ); +} + +class FfiConverterServerFeaturesRes { + static ServerFeaturesRes lift(RustBuffer buf) { + return FfiConverterServerFeaturesRes.read(buf.asUint8List()).value; + } + + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final serverVersion_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final serverVersion = serverVersion_lifted.value; + new_offset += serverVersion_lifted.bytesRead; + final genesisHash_lifted = + BlockHash.read(Uint8List.view(buf.buffer, new_offset)); + final genesisHash = genesisHash_lifted.value; + new_offset += genesisHash_lifted.bytesRead; + final protocolMin_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final protocolMin = protocolMin_lifted.value; + new_offset += protocolMin_lifted.bytesRead; + final protocolMax_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final protocolMax = protocolMax_lifted.value; + new_offset += protocolMax_lifted.bytesRead; + final hashFunction_lifted = + FfiConverterOptionalString.read(Uint8List.view(buf.buffer, new_offset)); + final hashFunction = hashFunction_lifted.value; + new_offset += hashFunction_lifted.bytesRead; + final pruning_lifted = + FfiConverterOptionalInt64.read(Uint8List.view(buf.buffer, new_offset)); + final pruning = pruning_lifted.value; + new_offset += pruning_lifted.bytesRead; + return LiftRetVal( + ServerFeaturesRes( + serverVersion, + genesisHash, + protocolMin, + protocolMax, + hashFunction, + pruning, + ), + new_offset - buf.offsetInBytes); + } + + static RustBuffer lower(ServerFeaturesRes value) { + final total_length = + FfiConverterString.allocationSize(value.serverVersion) + + BlockHash.allocationSize(value.genesisHash) + + FfiConverterString.allocationSize(value.protocolMin) + + FfiConverterString.allocationSize(value.protocolMax) + + FfiConverterOptionalString.allocationSize(value.hashFunction) + + FfiConverterOptionalInt64.allocationSize(value.pruning) + + 0; + final buf = Uint8List(total_length); + write(value, buf); + return toRustBuffer(buf); + } + + static int write(ServerFeaturesRes value, Uint8List buf) { + int new_offset = buf.offsetInBytes; + new_offset += FfiConverterString.write( + value.serverVersion, Uint8List.view(buf.buffer, new_offset)); + new_offset += BlockHash.write( + value.genesisHash, Uint8List.view(buf.buffer, new_offset)); + new_offset += FfiConverterString.write( + value.protocolMin, Uint8List.view(buf.buffer, new_offset)); + new_offset += FfiConverterString.write( + value.protocolMax, Uint8List.view(buf.buffer, new_offset)); + new_offset += FfiConverterOptionalString.write( + value.hashFunction, Uint8List.view(buf.buffer, new_offset)); + new_offset += FfiConverterOptionalInt64.write( + value.pruning, Uint8List.view(buf.buffer, new_offset)); + return new_offset - buf.offsetInBytes; + } + + static int allocationSize(ServerFeaturesRes value) { + return FfiConverterString.allocationSize(value.serverVersion) + + BlockHash.allocationSize(value.genesisHash) + + FfiConverterString.allocationSize(value.protocolMin) + + FfiConverterString.allocationSize(value.protocolMax) + + FfiConverterOptionalString.allocationSize(value.hashFunction) + + FfiConverterOptionalInt64.allocationSize(value.pruning) + + 0; + } +} + +class SignOptions { + final bool trustWitnessUtxo; + final int? assumeHeight; + final bool allowAllSighashes; + final bool tryFinalize; + final bool signWithTapInternalKey; + final bool allowGrinding; + SignOptions( + this.trustWitnessUtxo, + this.assumeHeight, + this.allowAllSighashes, + this.tryFinalize, + this.signWithTapInternalKey, + this.allowGrinding, + ); +} + +class FfiConverterSignOptions { + static SignOptions lift(RustBuffer buf) { + return FfiConverterSignOptions.read(buf.asUint8List()).value; + } + + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final trustWitnessUtxo_lifted = + FfiConverterBool.read(Uint8List.view(buf.buffer, new_offset)); + final trustWitnessUtxo = trustWitnessUtxo_lifted.value; + new_offset += trustWitnessUtxo_lifted.bytesRead; + final assumeHeight_lifted = + FfiConverterOptionalUInt32.read(Uint8List.view(buf.buffer, new_offset)); + final assumeHeight = assumeHeight_lifted.value; + new_offset += assumeHeight_lifted.bytesRead; + final allowAllSighashes_lifted = + FfiConverterBool.read(Uint8List.view(buf.buffer, new_offset)); + final allowAllSighashes = allowAllSighashes_lifted.value; + new_offset += allowAllSighashes_lifted.bytesRead; + final tryFinalize_lifted = + FfiConverterBool.read(Uint8List.view(buf.buffer, new_offset)); + final tryFinalize = tryFinalize_lifted.value; + new_offset += tryFinalize_lifted.bytesRead; + final signWithTapInternalKey_lifted = + FfiConverterBool.read(Uint8List.view(buf.buffer, new_offset)); + final signWithTapInternalKey = signWithTapInternalKey_lifted.value; + new_offset += signWithTapInternalKey_lifted.bytesRead; + final allowGrinding_lifted = + FfiConverterBool.read(Uint8List.view(buf.buffer, new_offset)); + final allowGrinding = allowGrinding_lifted.value; + new_offset += allowGrinding_lifted.bytesRead; + return LiftRetVal( + SignOptions( + trustWitnessUtxo, + assumeHeight, + allowAllSighashes, + tryFinalize, + signWithTapInternalKey, + allowGrinding, + ), + new_offset - buf.offsetInBytes); + } + + static RustBuffer lower(SignOptions value) { + final total_length = + FfiConverterBool.allocationSize(value.trustWitnessUtxo) + + FfiConverterOptionalUInt32.allocationSize(value.assumeHeight) + + FfiConverterBool.allocationSize(value.allowAllSighashes) + + FfiConverterBool.allocationSize(value.tryFinalize) + + FfiConverterBool.allocationSize(value.signWithTapInternalKey) + + FfiConverterBool.allocationSize(value.allowGrinding) + + 0; + final buf = Uint8List(total_length); + write(value, buf); + return toRustBuffer(buf); + } + + static int write(SignOptions value, Uint8List buf) { + int new_offset = buf.offsetInBytes; + new_offset += FfiConverterBool.write( + value.trustWitnessUtxo, Uint8List.view(buf.buffer, new_offset)); + new_offset += FfiConverterOptionalUInt32.write( + value.assumeHeight, Uint8List.view(buf.buffer, new_offset)); + new_offset += FfiConverterBool.write( + value.allowAllSighashes, Uint8List.view(buf.buffer, new_offset)); + new_offset += FfiConverterBool.write( + value.tryFinalize, Uint8List.view(buf.buffer, new_offset)); + new_offset += FfiConverterBool.write( + value.signWithTapInternalKey, Uint8List.view(buf.buffer, new_offset)); + new_offset += FfiConverterBool.write( + value.allowGrinding, Uint8List.view(buf.buffer, new_offset)); + return new_offset - buf.offsetInBytes; + } + + static int allocationSize(SignOptions value) { + return FfiConverterBool.allocationSize(value.trustWitnessUtxo) + + FfiConverterOptionalUInt32.allocationSize(value.assumeHeight) + + FfiConverterBool.allocationSize(value.allowAllSighashes) + + FfiConverterBool.allocationSize(value.tryFinalize) + + FfiConverterBool.allocationSize(value.signWithTapInternalKey) + + FfiConverterBool.allocationSize(value.allowGrinding) + + 0; + } +} + +class Socks5Proxy { + final IpAddress address; + final int port; + Socks5Proxy( + this.address, + this.port, + ); +} + +class FfiConverterSocks5Proxy { + static Socks5Proxy lift(RustBuffer buf) { + return FfiConverterSocks5Proxy.read(buf.asUint8List()).value; + } + + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final address_lifted = + IpAddress.read(Uint8List.view(buf.buffer, new_offset)); + final address = address_lifted.value; + new_offset += address_lifted.bytesRead; + final port_lifted = + FfiConverterUInt16.read(Uint8List.view(buf.buffer, new_offset)); + final port = port_lifted.value; + new_offset += port_lifted.bytesRead; + return LiftRetVal( + Socks5Proxy( + address, + port, + ), + new_offset - buf.offsetInBytes); + } + + static RustBuffer lower(Socks5Proxy value) { + final total_length = IpAddress.allocationSize(value.address) + + FfiConverterUInt16.allocationSize(value.port) + + 0; + final buf = Uint8List(total_length); + write(value, buf); + return toRustBuffer(buf); + } + + static int write(Socks5Proxy value, Uint8List buf) { + int new_offset = buf.offsetInBytes; + new_offset += + IpAddress.write(value.address, Uint8List.view(buf.buffer, new_offset)); + new_offset += FfiConverterUInt16.write( + value.port, Uint8List.view(buf.buffer, new_offset)); + return new_offset - buf.offsetInBytes; + } + + static int allocationSize(Socks5Proxy value) { + return IpAddress.allocationSize(value.address) + + FfiConverterUInt16.allocationSize(value.port) + + 0; + } +} + +class Tx { + final Txid txid; + final int version; + final int locktime; + final int size; + final int weight; + final int fee; + final TxStatus status; + Tx( + this.txid, + this.version, + this.locktime, + this.size, + this.weight, + this.fee, + this.status, + ); +} + +class FfiConverterTx { + static Tx lift(RustBuffer buf) { + return FfiConverterTx.read(buf.asUint8List()).value; + } + + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final txid_lifted = Txid.read(Uint8List.view(buf.buffer, new_offset)); + final txid = txid_lifted.value; + new_offset += txid_lifted.bytesRead; + final version_lifted = + FfiConverterInt32.read(Uint8List.view(buf.buffer, new_offset)); + final version = version_lifted.value; + new_offset += version_lifted.bytesRead; + final locktime_lifted = + FfiConverterUInt32.read(Uint8List.view(buf.buffer, new_offset)); + final locktime = locktime_lifted.value; + new_offset += locktime_lifted.bytesRead; + final size_lifted = + FfiConverterUInt64.read(Uint8List.view(buf.buffer, new_offset)); + final size = size_lifted.value; + new_offset += size_lifted.bytesRead; + final weight_lifted = + FfiConverterUInt64.read(Uint8List.view(buf.buffer, new_offset)); + final weight = weight_lifted.value; + new_offset += weight_lifted.bytesRead; + final fee_lifted = + FfiConverterUInt64.read(Uint8List.view(buf.buffer, new_offset)); + final fee = fee_lifted.value; + new_offset += fee_lifted.bytesRead; + final status_lifted = + FfiConverterTxStatus.read(Uint8List.view(buf.buffer, new_offset)); + final status = status_lifted.value; + new_offset += status_lifted.bytesRead; + return LiftRetVal( + Tx( + txid, + version, + locktime, + size, + weight, + fee, + status, + ), + new_offset - buf.offsetInBytes); + } + + static RustBuffer lower(Tx value) { + final total_length = Txid.allocationSize(value.txid) + + FfiConverterInt32.allocationSize(value.version) + + FfiConverterUInt32.allocationSize(value.locktime) + + FfiConverterUInt64.allocationSize(value.size) + + FfiConverterUInt64.allocationSize(value.weight) + + FfiConverterUInt64.allocationSize(value.fee) + + FfiConverterTxStatus.allocationSize(value.status) + + 0; + final buf = Uint8List(total_length); + write(value, buf); + return toRustBuffer(buf); + } + + static int write(Tx value, Uint8List buf) { + int new_offset = buf.offsetInBytes; + new_offset += + Txid.write(value.txid, Uint8List.view(buf.buffer, new_offset)); + new_offset += FfiConverterInt32.write( + value.version, Uint8List.view(buf.buffer, new_offset)); + new_offset += FfiConverterUInt32.write( + value.locktime, Uint8List.view(buf.buffer, new_offset)); + new_offset += FfiConverterUInt64.write( + value.size, Uint8List.view(buf.buffer, new_offset)); + new_offset += FfiConverterUInt64.write( + value.weight, Uint8List.view(buf.buffer, new_offset)); + new_offset += FfiConverterUInt64.write( + value.fee, Uint8List.view(buf.buffer, new_offset)); + new_offset += FfiConverterTxStatus.write( + value.status, Uint8List.view(buf.buffer, new_offset)); + return new_offset - buf.offsetInBytes; + } + + static int allocationSize(Tx value) { + return Txid.allocationSize(value.txid) + + FfiConverterInt32.allocationSize(value.version) + + FfiConverterUInt32.allocationSize(value.locktime) + + FfiConverterUInt64.allocationSize(value.size) + + FfiConverterUInt64.allocationSize(value.weight) + + FfiConverterUInt64.allocationSize(value.fee) + + FfiConverterTxStatus.allocationSize(value.status) + + 0; + } +} + +class TxDetails { + final Txid txid; + final Amount sent; + final Amount received; + final Amount? fee; + final double? feeRate; + final int balanceDelta; + final ChainPosition chainPosition; + final Transaction tx; + TxDetails( + this.txid, + this.sent, + this.received, + this.fee, + this.feeRate, + this.balanceDelta, + this.chainPosition, + this.tx, + ); +} + +class FfiConverterTxDetails { + static TxDetails lift(RustBuffer buf) { + return FfiConverterTxDetails.read(buf.asUint8List()).value; + } + + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final txid_lifted = Txid.read(Uint8List.view(buf.buffer, new_offset)); + final txid = txid_lifted.value; + new_offset += txid_lifted.bytesRead; + final sent_lifted = Amount.read(Uint8List.view(buf.buffer, new_offset)); + final sent = sent_lifted.value; + new_offset += sent_lifted.bytesRead; + final received_lifted = Amount.read(Uint8List.view(buf.buffer, new_offset)); + final received = received_lifted.value; + new_offset += received_lifted.bytesRead; + final fee_lifted = + FfiConverterOptionalAmount.read(Uint8List.view(buf.buffer, new_offset)); + final fee = fee_lifted.value; + new_offset += fee_lifted.bytesRead; + final feeRate_lifted = FfiConverterOptionalDouble32.read( + Uint8List.view(buf.buffer, new_offset)); + final feeRate = feeRate_lifted.value; + new_offset += feeRate_lifted.bytesRead; + final balanceDelta_lifted = + FfiConverterInt64.read(Uint8List.view(buf.buffer, new_offset)); + final balanceDelta = balanceDelta_lifted.value; + new_offset += balanceDelta_lifted.bytesRead; + final chainPosition_lifted = + FfiConverterChainPosition.read(Uint8List.view(buf.buffer, new_offset)); + final chainPosition = chainPosition_lifted.value; + new_offset += chainPosition_lifted.bytesRead; + final tx_lifted = Transaction.read(Uint8List.view(buf.buffer, new_offset)); + final tx = tx_lifted.value; + new_offset += tx_lifted.bytesRead; + return LiftRetVal( + TxDetails( + txid, + sent, + received, + fee, + feeRate, + balanceDelta, + chainPosition, + tx, + ), + new_offset - buf.offsetInBytes); + } + + static RustBuffer lower(TxDetails value) { + final total_length = Txid.allocationSize(value.txid) + + Amount.allocationSize(value.sent) + + Amount.allocationSize(value.received) + + FfiConverterOptionalAmount.allocationSize(value.fee) + + FfiConverterOptionalDouble32.allocationSize(value.feeRate) + + FfiConverterInt64.allocationSize(value.balanceDelta) + + FfiConverterChainPosition.allocationSize(value.chainPosition) + + Transaction.allocationSize(value.tx) + + 0; + final buf = Uint8List(total_length); + write(value, buf); + return toRustBuffer(buf); + } + + static int write(TxDetails value, Uint8List buf) { + int new_offset = buf.offsetInBytes; + new_offset += + Txid.write(value.txid, Uint8List.view(buf.buffer, new_offset)); + new_offset += + Amount.write(value.sent, Uint8List.view(buf.buffer, new_offset)); + new_offset += + Amount.write(value.received, Uint8List.view(buf.buffer, new_offset)); + new_offset += FfiConverterOptionalAmount.write( + value.fee, Uint8List.view(buf.buffer, new_offset)); + new_offset += FfiConverterOptionalDouble32.write( + value.feeRate, Uint8List.view(buf.buffer, new_offset)); + new_offset += FfiConverterInt64.write( + value.balanceDelta, Uint8List.view(buf.buffer, new_offset)); + new_offset += FfiConverterChainPosition.write( + value.chainPosition, Uint8List.view(buf.buffer, new_offset)); + new_offset += + Transaction.write(value.tx, Uint8List.view(buf.buffer, new_offset)); + return new_offset - buf.offsetInBytes; + } + + static int allocationSize(TxDetails value) { + return Txid.allocationSize(value.txid) + + Amount.allocationSize(value.sent) + + Amount.allocationSize(value.received) + + FfiConverterOptionalAmount.allocationSize(value.fee) + + FfiConverterOptionalDouble32.allocationSize(value.feeRate) + + FfiConverterInt64.allocationSize(value.balanceDelta) + + FfiConverterChainPosition.allocationSize(value.chainPosition) + + Transaction.allocationSize(value.tx) + + 0; + } +} + +class TxGraphChangeSet { + final List txs; + final Map txouts; + final List anchors; + final Map lastSeen; + final Map firstSeen; + final Map lastEvicted; + TxGraphChangeSet( + this.txs, + this.txouts, + this.anchors, + this.lastSeen, + this.firstSeen, + this.lastEvicted, + ); +} + +class FfiConverterTxGraphChangeSet { + static TxGraphChangeSet lift(RustBuffer buf) { + return FfiConverterTxGraphChangeSet.read(buf.asUint8List()).value; + } + + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final txs_lifted = FfiConverterSequenceTransaction.read( + Uint8List.view(buf.buffer, new_offset)); + final txs = txs_lifted.value; + new_offset += txs_lifted.bytesRead; + final txouts_lifted = FfiConverterMapHashableOutPointToTxOut.read( + Uint8List.view(buf.buffer, new_offset)); + final txouts = txouts_lifted.value; + new_offset += txouts_lifted.bytesRead; + final anchors_lifted = + FfiConverterSequenceAnchor.read(Uint8List.view(buf.buffer, new_offset)); + final anchors = anchors_lifted.value; + new_offset += anchors_lifted.bytesRead; + final lastSeen_lifted = FfiConverterMapTxidToUInt64.read( + Uint8List.view(buf.buffer, new_offset)); + final lastSeen = lastSeen_lifted.value; + new_offset += lastSeen_lifted.bytesRead; + final firstSeen_lifted = FfiConverterMapTxidToUInt64.read( + Uint8List.view(buf.buffer, new_offset)); + final firstSeen = firstSeen_lifted.value; + new_offset += firstSeen_lifted.bytesRead; + final lastEvicted_lifted = FfiConverterMapTxidToUInt64.read( + Uint8List.view(buf.buffer, new_offset)); + final lastEvicted = lastEvicted_lifted.value; + new_offset += lastEvicted_lifted.bytesRead; + return LiftRetVal( + TxGraphChangeSet( + txs, + txouts, + anchors, + lastSeen, + firstSeen, + lastEvicted, + ), + new_offset - buf.offsetInBytes); + } + + static RustBuffer lower(TxGraphChangeSet value) { + final total_length = FfiConverterSequenceTransaction.allocationSize( + value.txs) + + FfiConverterMapHashableOutPointToTxOut.allocationSize(value.txouts) + + FfiConverterSequenceAnchor.allocationSize(value.anchors) + + FfiConverterMapTxidToUInt64.allocationSize(value.lastSeen) + + FfiConverterMapTxidToUInt64.allocationSize(value.firstSeen) + + FfiConverterMapTxidToUInt64.allocationSize(value.lastEvicted) + + 0; + final buf = Uint8List(total_length); + write(value, buf); + return toRustBuffer(buf); + } + + static int write(TxGraphChangeSet value, Uint8List buf) { + int new_offset = buf.offsetInBytes; + new_offset += FfiConverterSequenceTransaction.write( + value.txs, Uint8List.view(buf.buffer, new_offset)); + new_offset += FfiConverterMapHashableOutPointToTxOut.write( + value.txouts, Uint8List.view(buf.buffer, new_offset)); + new_offset += FfiConverterSequenceAnchor.write( + value.anchors, Uint8List.view(buf.buffer, new_offset)); + new_offset += FfiConverterMapTxidToUInt64.write( + value.lastSeen, Uint8List.view(buf.buffer, new_offset)); + new_offset += FfiConverterMapTxidToUInt64.write( + value.firstSeen, Uint8List.view(buf.buffer, new_offset)); + new_offset += FfiConverterMapTxidToUInt64.write( + value.lastEvicted, Uint8List.view(buf.buffer, new_offset)); + return new_offset - buf.offsetInBytes; + } + + static int allocationSize(TxGraphChangeSet value) { + return FfiConverterSequenceTransaction.allocationSize(value.txs) + + FfiConverterMapHashableOutPointToTxOut.allocationSize(value.txouts) + + FfiConverterSequenceAnchor.allocationSize(value.anchors) + + FfiConverterMapTxidToUInt64.allocationSize(value.lastSeen) + + FfiConverterMapTxidToUInt64.allocationSize(value.firstSeen) + + FfiConverterMapTxidToUInt64.allocationSize(value.lastEvicted) + + 0; + } +} + +class TxIn { + final OutPoint previousOutput; + final Script scriptSig; + final int sequence; + final List witness; + TxIn( + this.previousOutput, + this.scriptSig, + this.sequence, + this.witness, + ); +} + +class FfiConverterTxIn { + static TxIn lift(RustBuffer buf) { + return FfiConverterTxIn.read(buf.asUint8List()).value; + } + + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final previousOutput_lifted = + FfiConverterOutPoint.read(Uint8List.view(buf.buffer, new_offset)); + final previousOutput = previousOutput_lifted.value; + new_offset += previousOutput_lifted.bytesRead; + final scriptSig_lifted = + Script.read(Uint8List.view(buf.buffer, new_offset)); + final scriptSig = scriptSig_lifted.value; + new_offset += scriptSig_lifted.bytesRead; + final sequence_lifted = + FfiConverterUInt32.read(Uint8List.view(buf.buffer, new_offset)); + final sequence = sequence_lifted.value; + new_offset += sequence_lifted.bytesRead; + final witness_lifted = FfiConverterSequenceUint8List.read( + Uint8List.view(buf.buffer, new_offset)); + final witness = witness_lifted.value; + new_offset += witness_lifted.bytesRead; + return LiftRetVal( + TxIn( + previousOutput, + scriptSig, + sequence, + witness, + ), + new_offset - buf.offsetInBytes); + } + + static RustBuffer lower(TxIn value) { + final total_length = + FfiConverterOutPoint.allocationSize(value.previousOutput) + + Script.allocationSize(value.scriptSig) + + FfiConverterUInt32.allocationSize(value.sequence) + + FfiConverterSequenceUint8List.allocationSize(value.witness) + + 0; + final buf = Uint8List(total_length); + write(value, buf); + return toRustBuffer(buf); + } + + static int write(TxIn value, Uint8List buf) { + int new_offset = buf.offsetInBytes; + new_offset += FfiConverterOutPoint.write( + value.previousOutput, Uint8List.view(buf.buffer, new_offset)); + new_offset += + Script.write(value.scriptSig, Uint8List.view(buf.buffer, new_offset)); + new_offset += FfiConverterUInt32.write( + value.sequence, Uint8List.view(buf.buffer, new_offset)); + new_offset += FfiConverterSequenceUint8List.write( + value.witness, Uint8List.view(buf.buffer, new_offset)); + return new_offset - buf.offsetInBytes; + } + + static int allocationSize(TxIn value) { + return FfiConverterOutPoint.allocationSize(value.previousOutput) + + Script.allocationSize(value.scriptSig) + + FfiConverterUInt32.allocationSize(value.sequence) + + FfiConverterSequenceUint8List.allocationSize(value.witness) + + 0; + } +} + +class TxOut { + final Amount value; + final Script scriptPubkey; + TxOut( + this.value, + this.scriptPubkey, + ); +} + +class FfiConverterTxOut { + static TxOut lift(RustBuffer buf) { + return FfiConverterTxOut.read(buf.asUint8List()).value; + } + + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final value_lifted = Amount.read(Uint8List.view(buf.buffer, new_offset)); + final value = value_lifted.value; + new_offset += value_lifted.bytesRead; + final scriptPubkey_lifted = + Script.read(Uint8List.view(buf.buffer, new_offset)); + final scriptPubkey = scriptPubkey_lifted.value; + new_offset += scriptPubkey_lifted.bytesRead; + return LiftRetVal( + TxOut( + value, + scriptPubkey, + ), + new_offset - buf.offsetInBytes); + } + + static RustBuffer lower(TxOut value) { + final total_length = Amount.allocationSize(value.value) + + Script.allocationSize(value.scriptPubkey) + + 0; + final buf = Uint8List(total_length); + write(value, buf); + return toRustBuffer(buf); + } + + static int write(TxOut value, Uint8List buf) { + int new_offset = buf.offsetInBytes; + new_offset += + Amount.write(value.value, Uint8List.view(buf.buffer, new_offset)); + new_offset += Script.write( + value.scriptPubkey, Uint8List.view(buf.buffer, new_offset)); + return new_offset - buf.offsetInBytes; + } + + static int allocationSize(TxOut value) { + return Amount.allocationSize(value.value) + + Script.allocationSize(value.scriptPubkey) + + 0; + } +} + +class TxStatus { + final bool confirmed; + final int? blockHeight; + final BlockHash? blockHash; + final int? blockTime; + TxStatus( + this.confirmed, + this.blockHeight, + this.blockHash, + this.blockTime, + ); +} + +class FfiConverterTxStatus { + static TxStatus lift(RustBuffer buf) { + return FfiConverterTxStatus.read(buf.asUint8List()).value; + } + + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final confirmed_lifted = + FfiConverterBool.read(Uint8List.view(buf.buffer, new_offset)); + final confirmed = confirmed_lifted.value; + new_offset += confirmed_lifted.bytesRead; + final blockHeight_lifted = + FfiConverterOptionalUInt32.read(Uint8List.view(buf.buffer, new_offset)); + final blockHeight = blockHeight_lifted.value; + new_offset += blockHeight_lifted.bytesRead; + final blockHash_lifted = FfiConverterOptionalBlockHash.read( + Uint8List.view(buf.buffer, new_offset)); + final blockHash = blockHash_lifted.value; + new_offset += blockHash_lifted.bytesRead; + final blockTime_lifted = + FfiConverterOptionalUInt64.read(Uint8List.view(buf.buffer, new_offset)); + final blockTime = blockTime_lifted.value; + new_offset += blockTime_lifted.bytesRead; + return LiftRetVal( + TxStatus( + confirmed, + blockHeight, + blockHash, + blockTime, + ), + new_offset - buf.offsetInBytes); + } + + static RustBuffer lower(TxStatus value) { + final total_length = FfiConverterBool.allocationSize(value.confirmed) + + FfiConverterOptionalUInt32.allocationSize(value.blockHeight) + + FfiConverterOptionalBlockHash.allocationSize(value.blockHash) + + FfiConverterOptionalUInt64.allocationSize(value.blockTime) + + 0; + final buf = Uint8List(total_length); + write(value, buf); + return toRustBuffer(buf); + } + + static int write(TxStatus value, Uint8List buf) { + int new_offset = buf.offsetInBytes; + new_offset += FfiConverterBool.write( + value.confirmed, Uint8List.view(buf.buffer, new_offset)); + new_offset += FfiConverterOptionalUInt32.write( + value.blockHeight, Uint8List.view(buf.buffer, new_offset)); + new_offset += FfiConverterOptionalBlockHash.write( + value.blockHash, Uint8List.view(buf.buffer, new_offset)); + new_offset += FfiConverterOptionalUInt64.write( + value.blockTime, Uint8List.view(buf.buffer, new_offset)); + return new_offset - buf.offsetInBytes; + } + + static int allocationSize(TxStatus value) { + return FfiConverterBool.allocationSize(value.confirmed) + + FfiConverterOptionalUInt32.allocationSize(value.blockHeight) + + FfiConverterOptionalBlockHash.allocationSize(value.blockHash) + + FfiConverterOptionalUInt64.allocationSize(value.blockTime) + + 0; + } +} + +class UnconfirmedTx { + final Transaction tx; + final int lastSeen; + UnconfirmedTx( + this.tx, + this.lastSeen, + ); +} + +class FfiConverterUnconfirmedTx { + static UnconfirmedTx lift(RustBuffer buf) { + return FfiConverterUnconfirmedTx.read(buf.asUint8List()).value; + } + + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final tx_lifted = Transaction.read(Uint8List.view(buf.buffer, new_offset)); + final tx = tx_lifted.value; + new_offset += tx_lifted.bytesRead; + final lastSeen_lifted = + FfiConverterUInt64.read(Uint8List.view(buf.buffer, new_offset)); + final lastSeen = lastSeen_lifted.value; + new_offset += lastSeen_lifted.bytesRead; + return LiftRetVal( + UnconfirmedTx( + tx, + lastSeen, + ), + new_offset - buf.offsetInBytes); + } + + static RustBuffer lower(UnconfirmedTx value) { + final total_length = Transaction.allocationSize(value.tx) + + FfiConverterUInt64.allocationSize(value.lastSeen) + + 0; + final buf = Uint8List(total_length); + write(value, buf); + return toRustBuffer(buf); + } + + static int write(UnconfirmedTx value, Uint8List buf) { + int new_offset = buf.offsetInBytes; + new_offset += + Transaction.write(value.tx, Uint8List.view(buf.buffer, new_offset)); + new_offset += FfiConverterUInt64.write( + value.lastSeen, Uint8List.view(buf.buffer, new_offset)); + return new_offset - buf.offsetInBytes; + } + + static int allocationSize(UnconfirmedTx value) { + return Transaction.allocationSize(value.tx) + + FfiConverterUInt64.allocationSize(value.lastSeen) + + 0; + } +} + +class WitnessProgram { + final int version; + final Uint8List program; + WitnessProgram( + this.version, + this.program, + ); +} + +class FfiConverterWitnessProgram { + static WitnessProgram lift(RustBuffer buf) { + return FfiConverterWitnessProgram.read(buf.asUint8List()).value; + } + + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final version_lifted = + FfiConverterUInt8.read(Uint8List.view(buf.buffer, new_offset)); + final version = version_lifted.value; + new_offset += version_lifted.bytesRead; + final program_lifted = + FfiConverterUint8List.read(Uint8List.view(buf.buffer, new_offset)); + final program = program_lifted.value; + new_offset += program_lifted.bytesRead; + return LiftRetVal( + WitnessProgram( + version, + program, + ), + new_offset - buf.offsetInBytes); + } + + static RustBuffer lower(WitnessProgram value) { + final total_length = FfiConverterUInt8.allocationSize(value.version) + + FfiConverterUint8List.allocationSize(value.program) + + 0; + final buf = Uint8List(total_length); + write(value, buf); + return toRustBuffer(buf); + } + + static int write(WitnessProgram value, Uint8List buf) { + int new_offset = buf.offsetInBytes; + new_offset += FfiConverterUInt8.write( + value.version, Uint8List.view(buf.buffer, new_offset)); + new_offset += FfiConverterUint8List.write( + value.program, Uint8List.view(buf.buffer, new_offset)); + return new_offset - buf.offsetInBytes; + } + + static int allocationSize(WitnessProgram value) { + return FfiConverterUInt8.allocationSize(value.version) + + FfiConverterUint8List.allocationSize(value.program) + + 0; + } +} + +abstract class AddressData { + RustBuffer lower(); + int allocationSize(); + int write(Uint8List buf); +} + +class FfiConverterAddressData { + static AddressData lift(RustBuffer buffer) { + return FfiConverterAddressData.read(buffer.asUint8List()).value; + } + + static LiftRetVal read(Uint8List buf) { + final index = buf.buffer.asByteData(buf.offsetInBytes).getInt32(0); + final subview = Uint8List.view(buf.buffer, buf.offsetInBytes + 4); + switch (index) { + case 1: + return P2pkhAddressData.read(subview); + case 2: + return P2shAddressData.read(subview); + case 3: + return SegwitAddressData.read(subview); + default: + throw UniffiInternalError(UniffiInternalError.unexpectedEnumCase, + "Unable to determine enum variant"); + } + } + + static RustBuffer lower(AddressData value) { + return value.lower(); + } + + static int allocationSize(AddressData value) { + return value.allocationSize(); + } + + static int write(AddressData value, Uint8List buf) { + return value.write(buf); + } +} + +class P2pkhAddressData extends AddressData { + final String pubkeyHash; + P2pkhAddressData( + String this.pubkeyHash, + ); + P2pkhAddressData._( + String this.pubkeyHash, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final pubkeyHash_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final pubkeyHash = pubkeyHash_lifted.value; + new_offset += pubkeyHash_lifted.bytesRead; + return LiftRetVal( + P2pkhAddressData._( + pubkeyHash, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(pubkeyHash) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 1); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterString.write( + pubkeyHash, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } +} + +class P2shAddressData extends AddressData { + final String scriptHash; + P2shAddressData( + String this.scriptHash, + ); + P2shAddressData._( + String this.scriptHash, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final scriptHash_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final scriptHash = scriptHash_lifted.value; + new_offset += scriptHash_lifted.bytesRead; + return LiftRetVal( + P2shAddressData._( + scriptHash, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(scriptHash) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 2); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterString.write( + scriptHash, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } +} + +class SegwitAddressData extends AddressData { + final WitnessProgram witnessProgram; + SegwitAddressData( + WitnessProgram this.witnessProgram, + ); + SegwitAddressData._( + WitnessProgram this.witnessProgram, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final witnessProgram_lifted = + FfiConverterWitnessProgram.read(Uint8List.view(buf.buffer, new_offset)); + final witnessProgram = witnessProgram_lifted.value; + new_offset += witnessProgram_lifted.bytesRead; + return LiftRetVal( + SegwitAddressData._( + witnessProgram, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterWitnessProgram.allocationSize(witnessProgram) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 3); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterWitnessProgram.write( + witnessProgram, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } +} + +abstract class AddressParseException implements Exception { + RustBuffer lower(); + int allocationSize(); + int write(Uint8List buf); +} + +class FfiConverterAddressParseException { + static AddressParseException lift(RustBuffer buffer) { + return FfiConverterAddressParseException.read(buffer.asUint8List()).value; + } + + static LiftRetVal read(Uint8List buf) { + final index = buf.buffer.asByteData(buf.offsetInBytes).getInt32(0); + final subview = Uint8List.view(buf.buffer, buf.offsetInBytes + 4); + switch (index) { + case 1: + return Base58AddressParseException.read(subview); + case 2: + return Bech32AddressParseException.read(subview); + case 3: + return WitnessVersionAddressParseException.read(subview); + case 4: + return WitnessProgramAddressParseException.read(subview); + case 5: + return UnknownHrpAddressParseException.read(subview); + case 6: + return LegacyAddressTooLongAddressParseException.read(subview); + case 7: + return InvalidBase58PayloadLengthAddressParseException.read(subview); + case 8: + return InvalidLegacyPrefixAddressParseException.read(subview); + case 9: + return NetworkValidationAddressParseException.read(subview); + case 10: + return OtherAddressParseErrAddressParseException.read(subview); + default: + throw UniffiInternalError(UniffiInternalError.unexpectedEnumCase, + "Unable to determine enum variant"); + } + } + + static RustBuffer lower(AddressParseException value) { + return value.lower(); + } + + static int allocationSize(AddressParseException value) { + return value.allocationSize(); + } + + static int write(AddressParseException value, Uint8List buf) { + return value.write(buf); + } +} + +class Base58AddressParseException extends AddressParseException { + Base58AddressParseException(); + Base58AddressParseException._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(Base58AddressParseException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 1); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "Base58AddressParseException"; + } +} + +class Bech32AddressParseException extends AddressParseException { + Bech32AddressParseException(); + Bech32AddressParseException._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(Bech32AddressParseException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 2); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "Bech32AddressParseException"; + } +} + +class WitnessVersionAddressParseException extends AddressParseException { + final String errorMessage; + WitnessVersionAddressParseException( + String this.errorMessage, + ); + WitnessVersionAddressParseException._( + String this.errorMessage, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final errorMessage_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final errorMessage = errorMessage_lifted.value; + new_offset += errorMessage_lifted.bytesRead; + return LiftRetVal( + WitnessVersionAddressParseException._( + errorMessage, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(errorMessage) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 3); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterString.write( + errorMessage, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "WitnessVersionAddressParseException($errorMessage)"; + } +} + +class WitnessProgramAddressParseException extends AddressParseException { + final String errorMessage; + WitnessProgramAddressParseException( + String this.errorMessage, + ); + WitnessProgramAddressParseException._( + String this.errorMessage, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final errorMessage_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final errorMessage = errorMessage_lifted.value; + new_offset += errorMessage_lifted.bytesRead; + return LiftRetVal( + WitnessProgramAddressParseException._( + errorMessage, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(errorMessage) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 4); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterString.write( + errorMessage, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "WitnessProgramAddressParseException($errorMessage)"; + } +} + +class UnknownHrpAddressParseException extends AddressParseException { + UnknownHrpAddressParseException(); + UnknownHrpAddressParseException._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(UnknownHrpAddressParseException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 5); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "UnknownHrpAddressParseException"; + } +} + +class LegacyAddressTooLongAddressParseException extends AddressParseException { + LegacyAddressTooLongAddressParseException(); + LegacyAddressTooLongAddressParseException._(); + static LiftRetVal read( + Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal( + LegacyAddressTooLongAddressParseException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 6); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "LegacyAddressTooLongAddressParseException"; + } +} + +class InvalidBase58PayloadLengthAddressParseException + extends AddressParseException { + InvalidBase58PayloadLengthAddressParseException(); + InvalidBase58PayloadLengthAddressParseException._(); + static LiftRetVal read( + Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal( + InvalidBase58PayloadLengthAddressParseException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 7); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "InvalidBase58PayloadLengthAddressParseException"; + } +} + +class InvalidLegacyPrefixAddressParseException extends AddressParseException { + InvalidLegacyPrefixAddressParseException(); + InvalidLegacyPrefixAddressParseException._(); + static LiftRetVal read( + Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(InvalidLegacyPrefixAddressParseException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 8); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "InvalidLegacyPrefixAddressParseException"; + } +} + +class NetworkValidationAddressParseException extends AddressParseException { + NetworkValidationAddressParseException(); + NetworkValidationAddressParseException._(); + static LiftRetVal read( + Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(NetworkValidationAddressParseException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 9); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "NetworkValidationAddressParseException"; + } +} + +class OtherAddressParseErrAddressParseException extends AddressParseException { + OtherAddressParseErrAddressParseException(); + OtherAddressParseErrAddressParseException._(); + static LiftRetVal read( + Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal( + OtherAddressParseErrAddressParseException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 10); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "OtherAddressParseErrAddressParseException"; + } +} + +class AddressParseExceptionErrorHandler + extends UniffiRustCallStatusErrorHandler { + @override + Exception lift(RustBuffer errorBuf) { + return FfiConverterAddressParseException.lift(errorBuf); + } +} + +final AddressParseExceptionErrorHandler addressParseExceptionErrorHandler = + AddressParseExceptionErrorHandler(); + +abstract class Bip32Exception implements Exception { + RustBuffer lower(); + int allocationSize(); + int write(Uint8List buf); +} + +class FfiConverterBip32Exception { + static Bip32Exception lift(RustBuffer buffer) { + return FfiConverterBip32Exception.read(buffer.asUint8List()).value; + } + + static LiftRetVal read(Uint8List buf) { + final index = buf.buffer.asByteData(buf.offsetInBytes).getInt32(0); + final subview = Uint8List.view(buf.buffer, buf.offsetInBytes + 4); + switch (index) { + case 1: + return CannotDeriveFromHardenedKeyBip32Exception.read(subview); + case 2: + return Secp256k1Bip32Exception.read(subview); + case 3: + return InvalidChildNumberBip32Exception.read(subview); + case 4: + return InvalidChildNumberFormatBip32Exception.read(subview); + case 5: + return InvalidDerivationPathFormatBip32Exception.read(subview); + case 6: + return UnknownVersionBip32Exception.read(subview); + case 7: + return WrongExtendedKeyLengthBip32Exception.read(subview); + case 8: + return Base58Bip32Exception.read(subview); + case 9: + return HexBip32Exception.read(subview); + case 10: + return InvalidPublicKeyHexLengthBip32Exception.read(subview); + case 11: + return UnknownExceptionBip32Exception.read(subview); + default: + throw UniffiInternalError(UniffiInternalError.unexpectedEnumCase, + "Unable to determine enum variant"); + } + } + + static RustBuffer lower(Bip32Exception value) { + return value.lower(); + } + + static int allocationSize(Bip32Exception value) { + return value.allocationSize(); + } + + static int write(Bip32Exception value, Uint8List buf) { + return value.write(buf); + } +} + +class CannotDeriveFromHardenedKeyBip32Exception extends Bip32Exception { + CannotDeriveFromHardenedKeyBip32Exception(); + CannotDeriveFromHardenedKeyBip32Exception._(); + static LiftRetVal read( + Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal( + CannotDeriveFromHardenedKeyBip32Exception._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 1); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "CannotDeriveFromHardenedKeyBip32Exception"; + } +} + +class Secp256k1Bip32Exception extends Bip32Exception { + final String errorMessage; + Secp256k1Bip32Exception( + String this.errorMessage, + ); + Secp256k1Bip32Exception._( + String this.errorMessage, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final errorMessage_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final errorMessage = errorMessage_lifted.value; + new_offset += errorMessage_lifted.bytesRead; + return LiftRetVal( + Secp256k1Bip32Exception._( + errorMessage, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(errorMessage) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 2); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterString.write( + errorMessage, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "Secp256k1Bip32Exception($errorMessage)"; + } +} + +class InvalidChildNumberBip32Exception extends Bip32Exception { + final int childNumber; + InvalidChildNumberBip32Exception( + int this.childNumber, + ); + InvalidChildNumberBip32Exception._( + int this.childNumber, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final childNumber_lifted = + FfiConverterUInt32.read(Uint8List.view(buf.buffer, new_offset)); + final childNumber = childNumber_lifted.value; + new_offset += childNumber_lifted.bytesRead; + return LiftRetVal( + InvalidChildNumberBip32Exception._( + childNumber, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterUInt32.allocationSize(childNumber) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 3); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterUInt32.write( + childNumber, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "InvalidChildNumberBip32Exception($childNumber)"; + } +} + +class InvalidChildNumberFormatBip32Exception extends Bip32Exception { + InvalidChildNumberFormatBip32Exception(); + InvalidChildNumberFormatBip32Exception._(); + static LiftRetVal read( + Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(InvalidChildNumberFormatBip32Exception._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 4); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "InvalidChildNumberFormatBip32Exception"; + } +} + +class InvalidDerivationPathFormatBip32Exception extends Bip32Exception { + InvalidDerivationPathFormatBip32Exception(); + InvalidDerivationPathFormatBip32Exception._(); + static LiftRetVal read( + Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal( + InvalidDerivationPathFormatBip32Exception._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 5); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "InvalidDerivationPathFormatBip32Exception"; + } +} + +class UnknownVersionBip32Exception extends Bip32Exception { + final String version; + UnknownVersionBip32Exception( + String this.version, + ); + UnknownVersionBip32Exception._( + String this.version, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final version_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final version = version_lifted.value; + new_offset += version_lifted.bytesRead; + return LiftRetVal( + UnknownVersionBip32Exception._( + version, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(version) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 6); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterString.write( + version, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "UnknownVersionBip32Exception($version)"; + } +} + +class WrongExtendedKeyLengthBip32Exception extends Bip32Exception { + final int length; + WrongExtendedKeyLengthBip32Exception( + int this.length, + ); + WrongExtendedKeyLengthBip32Exception._( + int this.length, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final length_lifted = + FfiConverterUInt32.read(Uint8List.view(buf.buffer, new_offset)); + final length = length_lifted.value; + new_offset += length_lifted.bytesRead; + return LiftRetVal( + WrongExtendedKeyLengthBip32Exception._( + length, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterUInt32.allocationSize(length) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 7); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterUInt32.write( + length, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "WrongExtendedKeyLengthBip32Exception($length)"; + } +} + +class Base58Bip32Exception extends Bip32Exception { + final String errorMessage; + Base58Bip32Exception( + String this.errorMessage, + ); + Base58Bip32Exception._( + String this.errorMessage, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final errorMessage_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final errorMessage = errorMessage_lifted.value; + new_offset += errorMessage_lifted.bytesRead; + return LiftRetVal( + Base58Bip32Exception._( + errorMessage, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(errorMessage) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 8); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterString.write( + errorMessage, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "Base58Bip32Exception($errorMessage)"; + } +} + +class HexBip32Exception extends Bip32Exception { + final String errorMessage; + HexBip32Exception( + String this.errorMessage, + ); + HexBip32Exception._( + String this.errorMessage, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final errorMessage_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final errorMessage = errorMessage_lifted.value; + new_offset += errorMessage_lifted.bytesRead; + return LiftRetVal( + HexBip32Exception._( + errorMessage, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(errorMessage) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 9); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterString.write( + errorMessage, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "HexBip32Exception($errorMessage)"; + } +} + +class InvalidPublicKeyHexLengthBip32Exception extends Bip32Exception { + final int length; + InvalidPublicKeyHexLengthBip32Exception( + int this.length, + ); + InvalidPublicKeyHexLengthBip32Exception._( + int this.length, + ); + static LiftRetVal read( + Uint8List buf) { + int new_offset = buf.offsetInBytes; + final length_lifted = + FfiConverterUInt32.read(Uint8List.view(buf.buffer, new_offset)); + final length = length_lifted.value; + new_offset += length_lifted.bytesRead; + return LiftRetVal( + InvalidPublicKeyHexLengthBip32Exception._( + length, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterUInt32.allocationSize(length) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 10); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterUInt32.write( + length, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "InvalidPublicKeyHexLengthBip32Exception($length)"; + } +} + +class UnknownExceptionBip32Exception extends Bip32Exception { + final String errorMessage; + UnknownExceptionBip32Exception( + String this.errorMessage, + ); + UnknownExceptionBip32Exception._( + String this.errorMessage, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final errorMessage_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final errorMessage = errorMessage_lifted.value; + new_offset += errorMessage_lifted.bytesRead; + return LiftRetVal( + UnknownExceptionBip32Exception._( + errorMessage, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(errorMessage) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 11); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterString.write( + errorMessage, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "UnknownExceptionBip32Exception($errorMessage)"; + } +} + +class Bip32ExceptionErrorHandler extends UniffiRustCallStatusErrorHandler { + @override + Exception lift(RustBuffer errorBuf) { + return FfiConverterBip32Exception.lift(errorBuf); + } +} + +final Bip32ExceptionErrorHandler bip32ExceptionErrorHandler = + Bip32ExceptionErrorHandler(); + +abstract class Bip39Exception implements Exception { + RustBuffer lower(); + int allocationSize(); + int write(Uint8List buf); +} + +class FfiConverterBip39Exception { + static Bip39Exception lift(RustBuffer buffer) { + return FfiConverterBip39Exception.read(buffer.asUint8List()).value; + } + + static LiftRetVal read(Uint8List buf) { + final index = buf.buffer.asByteData(buf.offsetInBytes).getInt32(0); + final subview = Uint8List.view(buf.buffer, buf.offsetInBytes + 4); + switch (index) { + case 1: + return BadWordCountBip39Exception.read(subview); + case 2: + return UnknownWordBip39Exception.read(subview); + case 3: + return BadEntropyBitCountBip39Exception.read(subview); + case 4: + return InvalidChecksumBip39Exception.read(subview); + case 5: + return AmbiguousLanguagesBip39Exception.read(subview); + default: + throw UniffiInternalError(UniffiInternalError.unexpectedEnumCase, + "Unable to determine enum variant"); + } + } + + static RustBuffer lower(Bip39Exception value) { + return value.lower(); + } + + static int allocationSize(Bip39Exception value) { + return value.allocationSize(); + } + + static int write(Bip39Exception value, Uint8List buf) { + return value.write(buf); + } +} + +class BadWordCountBip39Exception extends Bip39Exception { + final int wordCount; + BadWordCountBip39Exception( + int this.wordCount, + ); + BadWordCountBip39Exception._( + int this.wordCount, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final wordCount_lifted = + FfiConverterUInt64.read(Uint8List.view(buf.buffer, new_offset)); + final wordCount = wordCount_lifted.value; + new_offset += wordCount_lifted.bytesRead; + return LiftRetVal( + BadWordCountBip39Exception._( + wordCount, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterUInt64.allocationSize(wordCount) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 1); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterUInt64.write( + wordCount, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "BadWordCountBip39Exception($wordCount)"; + } +} + +class UnknownWordBip39Exception extends Bip39Exception { + final int index; + UnknownWordBip39Exception( + int this.index, + ); + UnknownWordBip39Exception._( + int this.index, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final index_lifted = + FfiConverterUInt64.read(Uint8List.view(buf.buffer, new_offset)); + final index = index_lifted.value; + new_offset += index_lifted.bytesRead; + return LiftRetVal( + UnknownWordBip39Exception._( + index, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterUInt64.allocationSize(index) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 2); + int new_offset = buf.offsetInBytes + 4; + new_offset += + FfiConverterUInt64.write(index, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "UnknownWordBip39Exception($index)"; + } +} + +class BadEntropyBitCountBip39Exception extends Bip39Exception { + final int bitCount; + BadEntropyBitCountBip39Exception( + int this.bitCount, + ); + BadEntropyBitCountBip39Exception._( + int this.bitCount, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final bitCount_lifted = + FfiConverterUInt64.read(Uint8List.view(buf.buffer, new_offset)); + final bitCount = bitCount_lifted.value; + new_offset += bitCount_lifted.bytesRead; + return LiftRetVal( + BadEntropyBitCountBip39Exception._( + bitCount, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterUInt64.allocationSize(bitCount) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 3); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterUInt64.write( + bitCount, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "BadEntropyBitCountBip39Exception($bitCount)"; + } +} + +class InvalidChecksumBip39Exception extends Bip39Exception { + InvalidChecksumBip39Exception(); + InvalidChecksumBip39Exception._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(InvalidChecksumBip39Exception._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 4); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "InvalidChecksumBip39Exception"; + } +} + +class AmbiguousLanguagesBip39Exception extends Bip39Exception { + final String languages; + AmbiguousLanguagesBip39Exception( + String this.languages, + ); + AmbiguousLanguagesBip39Exception._( + String this.languages, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final languages_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final languages = languages_lifted.value; + new_offset += languages_lifted.bytesRead; + return LiftRetVal( + AmbiguousLanguagesBip39Exception._( + languages, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(languages) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 5); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterString.write( + languages, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "AmbiguousLanguagesBip39Exception($languages)"; + } +} + +class Bip39ExceptionErrorHandler extends UniffiRustCallStatusErrorHandler { + @override + Exception lift(RustBuffer errorBuf) { + return FfiConverterBip39Exception.lift(errorBuf); + } +} + +final Bip39ExceptionErrorHandler bip39ExceptionErrorHandler = + Bip39ExceptionErrorHandler(); + +abstract class CalculateFeeException implements Exception { + RustBuffer lower(); + int allocationSize(); + int write(Uint8List buf); +} + +class FfiConverterCalculateFeeException { + static CalculateFeeException lift(RustBuffer buffer) { + return FfiConverterCalculateFeeException.read(buffer.asUint8List()).value; + } + + static LiftRetVal read(Uint8List buf) { + final index = buf.buffer.asByteData(buf.offsetInBytes).getInt32(0); + final subview = Uint8List.view(buf.buffer, buf.offsetInBytes + 4); + switch (index) { + case 1: + return MissingTxOutCalculateFeeException.read(subview); + case 2: + return NegativeFeeCalculateFeeException.read(subview); + default: + throw UniffiInternalError(UniffiInternalError.unexpectedEnumCase, + "Unable to determine enum variant"); + } + } + + static RustBuffer lower(CalculateFeeException value) { + return value.lower(); + } + + static int allocationSize(CalculateFeeException value) { + return value.allocationSize(); + } + + static int write(CalculateFeeException value, Uint8List buf) { + return value.write(buf); + } +} + +class MissingTxOutCalculateFeeException extends CalculateFeeException { + final List outPoints; + MissingTxOutCalculateFeeException( + List this.outPoints, + ); + MissingTxOutCalculateFeeException._( + List this.outPoints, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final outPoints_lifted = FfiConverterSequenceOutPoint.read( + Uint8List.view(buf.buffer, new_offset)); + final outPoints = outPoints_lifted.value; + new_offset += outPoints_lifted.bytesRead; + return LiftRetVal( + MissingTxOutCalculateFeeException._( + outPoints, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterSequenceOutPoint.allocationSize(outPoints) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 1); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterSequenceOutPoint.write( + outPoints, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "MissingTxOutCalculateFeeException($outPoints)"; + } +} + +class NegativeFeeCalculateFeeException extends CalculateFeeException { + final String amount; + NegativeFeeCalculateFeeException( + String this.amount, + ); + NegativeFeeCalculateFeeException._( + String this.amount, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final amount_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final amount = amount_lifted.value; + new_offset += amount_lifted.bytesRead; + return LiftRetVal( + NegativeFeeCalculateFeeException._( + amount, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(amount) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 2); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterString.write( + amount, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "NegativeFeeCalculateFeeException($amount)"; + } +} + +class CalculateFeeExceptionErrorHandler + extends UniffiRustCallStatusErrorHandler { + @override + Exception lift(RustBuffer errorBuf) { + return FfiConverterCalculateFeeException.lift(errorBuf); + } +} + +final CalculateFeeExceptionErrorHandler calculateFeeExceptionErrorHandler = + CalculateFeeExceptionErrorHandler(); + +abstract class CannotConnectException implements Exception { + RustBuffer lower(); + int allocationSize(); + int write(Uint8List buf); +} + +class FfiConverterCannotConnectException { + static CannotConnectException lift(RustBuffer buffer) { + return FfiConverterCannotConnectException.read(buffer.asUint8List()).value; + } + + static LiftRetVal read(Uint8List buf) { + final index = buf.buffer.asByteData(buf.offsetInBytes).getInt32(0); + final subview = Uint8List.view(buf.buffer, buf.offsetInBytes + 4); + switch (index) { + case 1: + return IncludeCannotConnectException.read(subview); + default: + throw UniffiInternalError(UniffiInternalError.unexpectedEnumCase, + "Unable to determine enum variant"); + } + } + + static RustBuffer lower(CannotConnectException value) { + return value.lower(); + } + + static int allocationSize(CannotConnectException value) { + return value.allocationSize(); + } + + static int write(CannotConnectException value, Uint8List buf) { + return value.write(buf); + } +} + +class IncludeCannotConnectException extends CannotConnectException { + final int height; + IncludeCannotConnectException( + int this.height, + ); + IncludeCannotConnectException._( + int this.height, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final height_lifted = + FfiConverterUInt32.read(Uint8List.view(buf.buffer, new_offset)); + final height = height_lifted.value; + new_offset += height_lifted.bytesRead; + return LiftRetVal( + IncludeCannotConnectException._( + height, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterUInt32.allocationSize(height) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 1); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterUInt32.write( + height, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "IncludeCannotConnectException($height)"; + } +} + +class CannotConnectExceptionErrorHandler + extends UniffiRustCallStatusErrorHandler { + @override + Exception lift(RustBuffer errorBuf) { + return FfiConverterCannotConnectException.lift(errorBuf); + } +} + +final CannotConnectExceptionErrorHandler cannotConnectExceptionErrorHandler = + CannotConnectExceptionErrorHandler(); + +abstract class CbfBuilderException implements Exception { + RustBuffer lower(); + int allocationSize(); + int write(Uint8List buf); +} + +class FfiConverterCbfBuilderException { + static CbfBuilderException lift(RustBuffer buffer) { + return FfiConverterCbfBuilderException.read(buffer.asUint8List()).value; + } + + static LiftRetVal read(Uint8List buf) { + final index = buf.buffer.asByteData(buf.offsetInBytes).getInt32(0); + final subview = Uint8List.view(buf.buffer, buf.offsetInBytes + 4); + switch (index) { + case 1: + return DatabaseExceptionCbfBuilderException.read(subview); + default: + throw UniffiInternalError(UniffiInternalError.unexpectedEnumCase, + "Unable to determine enum variant"); + } + } + + static RustBuffer lower(CbfBuilderException value) { + return value.lower(); + } + + static int allocationSize(CbfBuilderException value) { + return value.allocationSize(); + } + + static int write(CbfBuilderException value, Uint8List buf) { + return value.write(buf); + } +} + +class DatabaseExceptionCbfBuilderException extends CbfBuilderException { + final String reason; + DatabaseExceptionCbfBuilderException( + String this.reason, + ); + DatabaseExceptionCbfBuilderException._( + String this.reason, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final reason_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final reason = reason_lifted.value; + new_offset += reason_lifted.bytesRead; + return LiftRetVal( + DatabaseExceptionCbfBuilderException._( + reason, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(reason) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 1); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterString.write( + reason, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "DatabaseExceptionCbfBuilderException($reason)"; + } +} + +class CbfBuilderExceptionErrorHandler extends UniffiRustCallStatusErrorHandler { + @override + Exception lift(RustBuffer errorBuf) { + return FfiConverterCbfBuilderException.lift(errorBuf); + } +} + +final CbfBuilderExceptionErrorHandler cbfBuilderExceptionErrorHandler = + CbfBuilderExceptionErrorHandler(); + +abstract class CbfException implements Exception { + RustBuffer lower(); + int allocationSize(); + int write(Uint8List buf); +} + +class FfiConverterCbfException { + static CbfException lift(RustBuffer buffer) { + return FfiConverterCbfException.read(buffer.asUint8List()).value; + } + + static LiftRetVal read(Uint8List buf) { + final index = buf.buffer.asByteData(buf.offsetInBytes).getInt32(0); + final subview = Uint8List.view(buf.buffer, buf.offsetInBytes + 4); + switch (index) { + case 1: + return NodeStoppedCbfException.read(subview); + default: + throw UniffiInternalError(UniffiInternalError.unexpectedEnumCase, + "Unable to determine enum variant"); + } + } + + static RustBuffer lower(CbfException value) { + return value.lower(); + } + + static int allocationSize(CbfException value) { + return value.allocationSize(); + } + + static int write(CbfException value, Uint8List buf) { + return value.write(buf); + } +} + +class NodeStoppedCbfException extends CbfException { + NodeStoppedCbfException(); + NodeStoppedCbfException._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(NodeStoppedCbfException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 1); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "NodeStoppedCbfException"; + } +} + +class CbfExceptionErrorHandler extends UniffiRustCallStatusErrorHandler { + @override + Exception lift(RustBuffer errorBuf) { + return FfiConverterCbfException.lift(errorBuf); + } +} + +final CbfExceptionErrorHandler cbfExceptionErrorHandler = + CbfExceptionErrorHandler(); + +abstract class ChainPosition { + RustBuffer lower(); + int allocationSize(); + int write(Uint8List buf); +} + +class FfiConverterChainPosition { + static ChainPosition lift(RustBuffer buffer) { + return FfiConverterChainPosition.read(buffer.asUint8List()).value; + } + + static LiftRetVal read(Uint8List buf) { + final index = buf.buffer.asByteData(buf.offsetInBytes).getInt32(0); + final subview = Uint8List.view(buf.buffer, buf.offsetInBytes + 4); + switch (index) { + case 1: + return ConfirmedChainPosition.read(subview); + case 2: + return UnconfirmedChainPosition.read(subview); + default: + throw UniffiInternalError(UniffiInternalError.unexpectedEnumCase, + "Unable to determine enum variant"); + } + } + + static RustBuffer lower(ChainPosition value) { + return value.lower(); + } + + static int allocationSize(ChainPosition value) { + return value.allocationSize(); + } + + static int write(ChainPosition value, Uint8List buf) { + return value.write(buf); + } +} + +class ConfirmedChainPosition extends ChainPosition { + final ConfirmationBlockTime confirmationBlockTime; + final Txid? transitively; + ConfirmedChainPosition({ + required ConfirmationBlockTime this.confirmationBlockTime, + required Txid? this.transitively, + }); + ConfirmedChainPosition._( + ConfirmationBlockTime this.confirmationBlockTime, + Txid? this.transitively, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final confirmationBlockTime_lifted = FfiConverterConfirmationBlockTime.read( + Uint8List.view(buf.buffer, new_offset)); + final confirmationBlockTime = confirmationBlockTime_lifted.value; + new_offset += confirmationBlockTime_lifted.bytesRead; + final transitively_lifted = + FfiConverterOptionalTxid.read(Uint8List.view(buf.buffer, new_offset)); + final transitively = transitively_lifted.value; + new_offset += transitively_lifted.bytesRead; + return LiftRetVal( + ConfirmedChainPosition._( + confirmationBlockTime, + transitively, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterConfirmationBlockTime.allocationSize( + confirmationBlockTime) + + FfiConverterOptionalTxid.allocationSize(transitively) + + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 1); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterConfirmationBlockTime.write( + confirmationBlockTime, Uint8List.view(buf.buffer, new_offset)); + new_offset += FfiConverterOptionalTxid.write( + transitively, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } +} + +class UnconfirmedChainPosition extends ChainPosition { + final int? timestamp; + UnconfirmedChainPosition( + int? this.timestamp, + ); + UnconfirmedChainPosition._( + int? this.timestamp, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final timestamp_lifted = + FfiConverterOptionalUInt64.read(Uint8List.view(buf.buffer, new_offset)); + final timestamp = timestamp_lifted.value; + new_offset += timestamp_lifted.bytesRead; + return LiftRetVal( + UnconfirmedChainPosition._( + timestamp, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterOptionalUInt64.allocationSize(timestamp) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 2); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterOptionalUInt64.write( + timestamp, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } +} + +enum ChangeSpendPolicy { + changeAllowed, + onlyChange, + changeForbidden, + ; +} + +class FfiConverterChangeSpendPolicy { + static ChangeSpendPolicy lift(RustBuffer buffer) { + final index = buffer.asUint8List().buffer.asByteData().getInt32(0); + switch (index) { + case 1: + return ChangeSpendPolicy.changeAllowed; + case 2: + return ChangeSpendPolicy.onlyChange; + case 3: + return ChangeSpendPolicy.changeForbidden; + default: + throw UniffiInternalError(UniffiInternalError.unexpectedEnumCase, + "Unable to determine enum variant"); + } + } + + static RustBuffer lower(ChangeSpendPolicy input) { + return toRustBuffer(createUint8ListFromInt(input.index + 1)); + } +} + +abstract class CreateTxException implements Exception { + RustBuffer lower(); + int allocationSize(); + int write(Uint8List buf); +} + +class FfiConverterCreateTxException { + static CreateTxException lift(RustBuffer buffer) { + return FfiConverterCreateTxException.read(buffer.asUint8List()).value; + } + + static LiftRetVal read(Uint8List buf) { + final index = buf.buffer.asByteData(buf.offsetInBytes).getInt32(0); + final subview = Uint8List.view(buf.buffer, buf.offsetInBytes + 4); + switch (index) { + case 1: + return DescriptorCreateTxException.read(subview); + case 2: + return PolicyCreateTxException.read(subview); + case 3: + return SpendingPolicyRequiredCreateTxException.read(subview); + case 4: + return Version0CreateTxException.read(subview); + case 5: + return Version1CsvCreateTxException.read(subview); + case 6: + return LockTimeCreateTxException.read(subview); + case 7: + return RbfSequenceCsvCreateTxException.read(subview); + case 8: + return FeeTooLowCreateTxException.read(subview); + case 9: + return FeeRateTooLowCreateTxException.read(subview); + case 10: + return NoUtxosSelectedCreateTxException.read(subview); + case 11: + return OutputBelowDustLimitCreateTxException.read(subview); + case 12: + return ChangePolicyDescriptorCreateTxException.read(subview); + case 13: + return CoinSelectionCreateTxException.read(subview); + case 14: + return InsufficientFundsCreateTxException.read(subview); + case 15: + return NoRecipientsCreateTxException.read(subview); + case 16: + return PsbtCreateTxException.read(subview); + case 17: + return MissingKeyOriginCreateTxException.read(subview); + case 18: + return UnknownUtxoCreateTxException.read(subview); + case 19: + return MissingNonWitnessUtxoCreateTxException.read(subview); + case 20: + return MiniscriptPsbtCreateTxException.read(subview); + case 21: + return PushBytesExceptionCreateTxException.read(subview); + case 22: + return LockTimeConversionExceptionCreateTxException.read(subview); + default: + throw UniffiInternalError(UniffiInternalError.unexpectedEnumCase, + "Unable to determine enum variant"); + } + } + + static RustBuffer lower(CreateTxException value) { + return value.lower(); + } + + static int allocationSize(CreateTxException value) { + return value.allocationSize(); + } + + static int write(CreateTxException value, Uint8List buf) { + return value.write(buf); + } +} + +class DescriptorCreateTxException extends CreateTxException { + final String errorMessage; + DescriptorCreateTxException( + String this.errorMessage, + ); + DescriptorCreateTxException._( + String this.errorMessage, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final errorMessage_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final errorMessage = errorMessage_lifted.value; + new_offset += errorMessage_lifted.bytesRead; + return LiftRetVal( + DescriptorCreateTxException._( + errorMessage, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(errorMessage) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 1); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterString.write( + errorMessage, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "DescriptorCreateTxException($errorMessage)"; + } +} + +class PolicyCreateTxException extends CreateTxException { + final String errorMessage; + PolicyCreateTxException( + String this.errorMessage, + ); + PolicyCreateTxException._( + String this.errorMessage, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final errorMessage_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final errorMessage = errorMessage_lifted.value; + new_offset += errorMessage_lifted.bytesRead; + return LiftRetVal( + PolicyCreateTxException._( + errorMessage, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(errorMessage) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 2); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterString.write( + errorMessage, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "PolicyCreateTxException($errorMessage)"; + } +} + +class SpendingPolicyRequiredCreateTxException extends CreateTxException { + final String kind; + SpendingPolicyRequiredCreateTxException( + String this.kind, + ); + SpendingPolicyRequiredCreateTxException._( + String this.kind, + ); + static LiftRetVal read( + Uint8List buf) { + int new_offset = buf.offsetInBytes; + final kind_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final kind = kind_lifted.value; + new_offset += kind_lifted.bytesRead; + return LiftRetVal( + SpendingPolicyRequiredCreateTxException._( + kind, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(kind) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 3); + int new_offset = buf.offsetInBytes + 4; + new_offset += + FfiConverterString.write(kind, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "SpendingPolicyRequiredCreateTxException($kind)"; + } +} + +class Version0CreateTxException extends CreateTxException { + Version0CreateTxException(); + Version0CreateTxException._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(Version0CreateTxException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 4); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "Version0CreateTxException"; + } +} + +class Version1CsvCreateTxException extends CreateTxException { + Version1CsvCreateTxException(); + Version1CsvCreateTxException._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(Version1CsvCreateTxException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 5); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "Version1CsvCreateTxException"; + } +} + +class LockTimeCreateTxException extends CreateTxException { + final String requested; + final String required_; + LockTimeCreateTxException({ + required String this.requested, + required String this.required_, + }); + LockTimeCreateTxException._( + String this.requested, + String this.required_, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final requested_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final requested = requested_lifted.value; + new_offset += requested_lifted.bytesRead; + final required__lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final required_ = required__lifted.value; + new_offset += required__lifted.bytesRead; + return LiftRetVal( + LockTimeCreateTxException._( + requested, + required_, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(requested) + + FfiConverterString.allocationSize(required_) + + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 6); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterString.write( + requested, Uint8List.view(buf.buffer, new_offset)); + new_offset += FfiConverterString.write( + required_, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "LockTimeCreateTxException($requested, $required_)"; + } +} + +class RbfSequenceCsvCreateTxException extends CreateTxException { + final String sequence; + final String csv; + RbfSequenceCsvCreateTxException({ + required String this.sequence, + required String this.csv, + }); + RbfSequenceCsvCreateTxException._( + String this.sequence, + String this.csv, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final sequence_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final sequence = sequence_lifted.value; + new_offset += sequence_lifted.bytesRead; + final csv_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final csv = csv_lifted.value; + new_offset += csv_lifted.bytesRead; + return LiftRetVal( + RbfSequenceCsvCreateTxException._( + sequence, + csv, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(sequence) + + FfiConverterString.allocationSize(csv) + + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 7); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterString.write( + sequence, Uint8List.view(buf.buffer, new_offset)); + new_offset += + FfiConverterString.write(csv, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "RbfSequenceCsvCreateTxException($sequence, $csv)"; + } +} + +class FeeTooLowCreateTxException extends CreateTxException { + final String required_; + FeeTooLowCreateTxException( + String this.required_, + ); + FeeTooLowCreateTxException._( + String this.required_, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final required__lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final required_ = required__lifted.value; + new_offset += required__lifted.bytesRead; + return LiftRetVal( + FeeTooLowCreateTxException._( + required_, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(required_) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 8); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterString.write( + required_, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "FeeTooLowCreateTxException($required_)"; + } +} + +class FeeRateTooLowCreateTxException extends CreateTxException { + final String required_; + FeeRateTooLowCreateTxException( + String this.required_, + ); + FeeRateTooLowCreateTxException._( + String this.required_, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final required__lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final required_ = required__lifted.value; + new_offset += required__lifted.bytesRead; + return LiftRetVal( + FeeRateTooLowCreateTxException._( + required_, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(required_) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 9); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterString.write( + required_, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "FeeRateTooLowCreateTxException($required_)"; + } +} + +class NoUtxosSelectedCreateTxException extends CreateTxException { + NoUtxosSelectedCreateTxException(); + NoUtxosSelectedCreateTxException._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(NoUtxosSelectedCreateTxException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 10); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "NoUtxosSelectedCreateTxException"; + } +} + +class OutputBelowDustLimitCreateTxException extends CreateTxException { + final int index; + OutputBelowDustLimitCreateTxException( + int this.index, + ); + OutputBelowDustLimitCreateTxException._( + int this.index, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final index_lifted = + FfiConverterUInt64.read(Uint8List.view(buf.buffer, new_offset)); + final index = index_lifted.value; + new_offset += index_lifted.bytesRead; + return LiftRetVal( + OutputBelowDustLimitCreateTxException._( + index, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterUInt64.allocationSize(index) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 11); + int new_offset = buf.offsetInBytes + 4; + new_offset += + FfiConverterUInt64.write(index, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "OutputBelowDustLimitCreateTxException($index)"; + } +} + +class ChangePolicyDescriptorCreateTxException extends CreateTxException { + ChangePolicyDescriptorCreateTxException(); + ChangePolicyDescriptorCreateTxException._(); + static LiftRetVal read( + Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(ChangePolicyDescriptorCreateTxException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 12); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "ChangePolicyDescriptorCreateTxException"; + } +} + +class CoinSelectionCreateTxException extends CreateTxException { + final String errorMessage; + CoinSelectionCreateTxException( + String this.errorMessage, + ); + CoinSelectionCreateTxException._( + String this.errorMessage, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final errorMessage_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final errorMessage = errorMessage_lifted.value; + new_offset += errorMessage_lifted.bytesRead; + return LiftRetVal( + CoinSelectionCreateTxException._( + errorMessage, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(errorMessage) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 13); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterString.write( + errorMessage, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "CoinSelectionCreateTxException($errorMessage)"; + } +} + +class InsufficientFundsCreateTxException extends CreateTxException { + final int needed; + final int available; + InsufficientFundsCreateTxException({ + required int this.needed, + required int this.available, + }); + InsufficientFundsCreateTxException._( + int this.needed, + int this.available, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final needed_lifted = + FfiConverterUInt64.read(Uint8List.view(buf.buffer, new_offset)); + final needed = needed_lifted.value; + new_offset += needed_lifted.bytesRead; + final available_lifted = + FfiConverterUInt64.read(Uint8List.view(buf.buffer, new_offset)); + final available = available_lifted.value; + new_offset += available_lifted.bytesRead; + return LiftRetVal( + InsufficientFundsCreateTxException._( + needed, + available, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterUInt64.allocationSize(needed) + + FfiConverterUInt64.allocationSize(available) + + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 14); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterUInt64.write( + needed, Uint8List.view(buf.buffer, new_offset)); + new_offset += FfiConverterUInt64.write( + available, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "InsufficientFundsCreateTxException($needed, $available)"; + } +} + +class NoRecipientsCreateTxException extends CreateTxException { + NoRecipientsCreateTxException(); + NoRecipientsCreateTxException._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(NoRecipientsCreateTxException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 15); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "NoRecipientsCreateTxException"; + } +} + +class PsbtCreateTxException extends CreateTxException { + final String errorMessage; + PsbtCreateTxException( + String this.errorMessage, + ); + PsbtCreateTxException._( + String this.errorMessage, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final errorMessage_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final errorMessage = errorMessage_lifted.value; + new_offset += errorMessage_lifted.bytesRead; + return LiftRetVal( + PsbtCreateTxException._( + errorMessage, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(errorMessage) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 16); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterString.write( + errorMessage, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "PsbtCreateTxException($errorMessage)"; + } +} + +class MissingKeyOriginCreateTxException extends CreateTxException { + final String key; + MissingKeyOriginCreateTxException( + String this.key, + ); + MissingKeyOriginCreateTxException._( + String this.key, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final key_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final key = key_lifted.value; + new_offset += key_lifted.bytesRead; + return LiftRetVal( + MissingKeyOriginCreateTxException._( + key, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(key) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 17); + int new_offset = buf.offsetInBytes + 4; + new_offset += + FfiConverterString.write(key, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "MissingKeyOriginCreateTxException($key)"; + } +} + +class UnknownUtxoCreateTxException extends CreateTxException { + final String outpoint; + UnknownUtxoCreateTxException( + String this.outpoint, + ); + UnknownUtxoCreateTxException._( + String this.outpoint, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final outpoint_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final outpoint = outpoint_lifted.value; + new_offset += outpoint_lifted.bytesRead; + return LiftRetVal( + UnknownUtxoCreateTxException._( + outpoint, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(outpoint) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 18); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterString.write( + outpoint, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "UnknownUtxoCreateTxException($outpoint)"; + } +} + +class MissingNonWitnessUtxoCreateTxException extends CreateTxException { + final String outpoint; + MissingNonWitnessUtxoCreateTxException( + String this.outpoint, + ); + MissingNonWitnessUtxoCreateTxException._( + String this.outpoint, + ); + static LiftRetVal read( + Uint8List buf) { + int new_offset = buf.offsetInBytes; + final outpoint_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final outpoint = outpoint_lifted.value; + new_offset += outpoint_lifted.bytesRead; + return LiftRetVal( + MissingNonWitnessUtxoCreateTxException._( + outpoint, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(outpoint) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 19); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterString.write( + outpoint, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "MissingNonWitnessUtxoCreateTxException($outpoint)"; + } +} + +class MiniscriptPsbtCreateTxException extends CreateTxException { + final String errorMessage; + MiniscriptPsbtCreateTxException( + String this.errorMessage, + ); + MiniscriptPsbtCreateTxException._( + String this.errorMessage, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final errorMessage_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final errorMessage = errorMessage_lifted.value; + new_offset += errorMessage_lifted.bytesRead; + return LiftRetVal( + MiniscriptPsbtCreateTxException._( + errorMessage, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(errorMessage) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 20); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterString.write( + errorMessage, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "MiniscriptPsbtCreateTxException($errorMessage)"; + } +} + +class PushBytesExceptionCreateTxException extends CreateTxException { + PushBytesExceptionCreateTxException(); + PushBytesExceptionCreateTxException._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(PushBytesExceptionCreateTxException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 21); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "PushBytesExceptionCreateTxException"; + } +} + +class LockTimeConversionExceptionCreateTxException extends CreateTxException { + LockTimeConversionExceptionCreateTxException(); + LockTimeConversionExceptionCreateTxException._(); + static LiftRetVal read( + Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal( + LockTimeConversionExceptionCreateTxException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 22); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "LockTimeConversionExceptionCreateTxException"; + } +} + +class CreateTxExceptionErrorHandler extends UniffiRustCallStatusErrorHandler { + @override + Exception lift(RustBuffer errorBuf) { + return FfiConverterCreateTxException.lift(errorBuf); + } +} + +final CreateTxExceptionErrorHandler createTxExceptionErrorHandler = + CreateTxExceptionErrorHandler(); + +abstract class CreateWithPersistException implements Exception { + RustBuffer lower(); + int allocationSize(); + int write(Uint8List buf); +} + +class FfiConverterCreateWithPersistException { + static CreateWithPersistException lift(RustBuffer buffer) { + return FfiConverterCreateWithPersistException.read(buffer.asUint8List()) + .value; + } + + static LiftRetVal read(Uint8List buf) { + final index = buf.buffer.asByteData(buf.offsetInBytes).getInt32(0); + final subview = Uint8List.view(buf.buffer, buf.offsetInBytes + 4); + switch (index) { + case 1: + return PersistCreateWithPersistException.read(subview); + case 2: + return DataAlreadyExistsCreateWithPersistException.read(subview); + case 3: + return DescriptorCreateWithPersistException.read(subview); + default: + throw UniffiInternalError(UniffiInternalError.unexpectedEnumCase, + "Unable to determine enum variant"); + } + } + + static RustBuffer lower(CreateWithPersistException value) { + return value.lower(); + } + + static int allocationSize(CreateWithPersistException value) { + return value.allocationSize(); + } + + static int write(CreateWithPersistException value, Uint8List buf) { + return value.write(buf); + } +} + +class PersistCreateWithPersistException extends CreateWithPersistException { + final String errorMessage; + PersistCreateWithPersistException( + String this.errorMessage, + ); + PersistCreateWithPersistException._( + String this.errorMessage, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final errorMessage_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final errorMessage = errorMessage_lifted.value; + new_offset += errorMessage_lifted.bytesRead; + return LiftRetVal( + PersistCreateWithPersistException._( + errorMessage, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(errorMessage) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 1); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterString.write( + errorMessage, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "PersistCreateWithPersistException($errorMessage)"; + } +} + +class DataAlreadyExistsCreateWithPersistException + extends CreateWithPersistException { + DataAlreadyExistsCreateWithPersistException(); + DataAlreadyExistsCreateWithPersistException._(); + static LiftRetVal read( + Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal( + DataAlreadyExistsCreateWithPersistException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 2); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "DataAlreadyExistsCreateWithPersistException"; + } +} + +class DescriptorCreateWithPersistException extends CreateWithPersistException { + final String errorMessage; + DescriptorCreateWithPersistException( + String this.errorMessage, + ); + DescriptorCreateWithPersistException._( + String this.errorMessage, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final errorMessage_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final errorMessage = errorMessage_lifted.value; + new_offset += errorMessage_lifted.bytesRead; + return LiftRetVal( + DescriptorCreateWithPersistException._( + errorMessage, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(errorMessage) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 3); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterString.write( + errorMessage, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "DescriptorCreateWithPersistException($errorMessage)"; + } +} + +class CreateWithPersistExceptionErrorHandler + extends UniffiRustCallStatusErrorHandler { + @override + Exception lift(RustBuffer errorBuf) { + return FfiConverterCreateWithPersistException.lift(errorBuf); + } +} + +final CreateWithPersistExceptionErrorHandler + createWithPersistExceptionErrorHandler = + CreateWithPersistExceptionErrorHandler(); + +abstract class DescriptorException implements Exception { + RustBuffer lower(); + int allocationSize(); + int write(Uint8List buf); +} + +class FfiConverterDescriptorException { + static DescriptorException lift(RustBuffer buffer) { + return FfiConverterDescriptorException.read(buffer.asUint8List()).value; + } + + static LiftRetVal read(Uint8List buf) { + final index = buf.buffer.asByteData(buf.offsetInBytes).getInt32(0); + final subview = Uint8List.view(buf.buffer, buf.offsetInBytes + 4); + switch (index) { + case 1: + return InvalidHdKeyPathDescriptorException.read(subview); + case 2: + return InvalidDescriptorChecksumDescriptorException.read(subview); + case 3: + return HardenedDerivationXpubDescriptorException.read(subview); + case 4: + return MultiPathDescriptorException.read(subview); + case 5: + return KeyDescriptorException.read(subview); + case 6: + return PolicyDescriptorException.read(subview); + case 7: + return InvalidDescriptorCharacterDescriptorException.read(subview); + case 8: + return Bip32DescriptorException.read(subview); + case 9: + return Base58DescriptorException.read(subview); + case 10: + return PkDescriptorException.read(subview); + case 11: + return MiniscriptDescriptorException.read(subview); + case 12: + return HexDescriptorException.read(subview); + case 13: + return ExternalAndInternalAreTheSameDescriptorException.read(subview); + default: + throw UniffiInternalError(UniffiInternalError.unexpectedEnumCase, + "Unable to determine enum variant"); + } + } + + static RustBuffer lower(DescriptorException value) { + return value.lower(); + } + + static int allocationSize(DescriptorException value) { + return value.allocationSize(); + } + + static int write(DescriptorException value, Uint8List buf) { + return value.write(buf); + } +} + +class InvalidHdKeyPathDescriptorException extends DescriptorException { + InvalidHdKeyPathDescriptorException(); + InvalidHdKeyPathDescriptorException._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(InvalidHdKeyPathDescriptorException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 1); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "InvalidHdKeyPathDescriptorException"; + } +} + +class InvalidDescriptorChecksumDescriptorException extends DescriptorException { + InvalidDescriptorChecksumDescriptorException(); + InvalidDescriptorChecksumDescriptorException._(); + static LiftRetVal read( + Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal( + InvalidDescriptorChecksumDescriptorException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 2); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "InvalidDescriptorChecksumDescriptorException"; + } +} + +class HardenedDerivationXpubDescriptorException extends DescriptorException { + HardenedDerivationXpubDescriptorException(); + HardenedDerivationXpubDescriptorException._(); + static LiftRetVal read( + Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal( + HardenedDerivationXpubDescriptorException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 3); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "HardenedDerivationXpubDescriptorException"; + } +} + +class MultiPathDescriptorException extends DescriptorException { + MultiPathDescriptorException(); + MultiPathDescriptorException._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(MultiPathDescriptorException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 4); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "MultiPathDescriptorException"; + } +} + +class KeyDescriptorException extends DescriptorException { + final String errorMessage; + KeyDescriptorException( + String this.errorMessage, + ); + KeyDescriptorException._( + String this.errorMessage, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final errorMessage_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final errorMessage = errorMessage_lifted.value; + new_offset += errorMessage_lifted.bytesRead; + return LiftRetVal( + KeyDescriptorException._( + errorMessage, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(errorMessage) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 5); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterString.write( + errorMessage, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "KeyDescriptorException($errorMessage)"; + } +} + +class PolicyDescriptorException extends DescriptorException { + final String errorMessage; + PolicyDescriptorException( + String this.errorMessage, + ); + PolicyDescriptorException._( + String this.errorMessage, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final errorMessage_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final errorMessage = errorMessage_lifted.value; + new_offset += errorMessage_lifted.bytesRead; + return LiftRetVal( + PolicyDescriptorException._( + errorMessage, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(errorMessage) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 6); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterString.write( + errorMessage, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "PolicyDescriptorException($errorMessage)"; + } +} + +class InvalidDescriptorCharacterDescriptorException + extends DescriptorException { + final String char; + InvalidDescriptorCharacterDescriptorException( + String this.char, + ); + InvalidDescriptorCharacterDescriptorException._( + String this.char, + ); + static LiftRetVal read( + Uint8List buf) { + int new_offset = buf.offsetInBytes; + final char_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final char = char_lifted.value; + new_offset += char_lifted.bytesRead; + return LiftRetVal( + InvalidDescriptorCharacterDescriptorException._( + char, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(char) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 7); + int new_offset = buf.offsetInBytes + 4; + new_offset += + FfiConverterString.write(char, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "InvalidDescriptorCharacterDescriptorException($char)"; + } +} + +class Bip32DescriptorException extends DescriptorException { + final String errorMessage; + Bip32DescriptorException( + String this.errorMessage, + ); + Bip32DescriptorException._( + String this.errorMessage, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final errorMessage_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final errorMessage = errorMessage_lifted.value; + new_offset += errorMessage_lifted.bytesRead; + return LiftRetVal( + Bip32DescriptorException._( + errorMessage, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(errorMessage) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 8); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterString.write( + errorMessage, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "Bip32DescriptorException($errorMessage)"; + } +} + +class Base58DescriptorException extends DescriptorException { + final String errorMessage; + Base58DescriptorException( + String this.errorMessage, + ); + Base58DescriptorException._( + String this.errorMessage, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final errorMessage_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final errorMessage = errorMessage_lifted.value; + new_offset += errorMessage_lifted.bytesRead; + return LiftRetVal( + Base58DescriptorException._( + errorMessage, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(errorMessage) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 9); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterString.write( + errorMessage, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "Base58DescriptorException($errorMessage)"; + } +} + +class PkDescriptorException extends DescriptorException { + final String errorMessage; + PkDescriptorException( + String this.errorMessage, + ); + PkDescriptorException._( + String this.errorMessage, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final errorMessage_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final errorMessage = errorMessage_lifted.value; + new_offset += errorMessage_lifted.bytesRead; + return LiftRetVal( + PkDescriptorException._( + errorMessage, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(errorMessage) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 10); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterString.write( + errorMessage, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "PkDescriptorException($errorMessage)"; + } +} + +class MiniscriptDescriptorException extends DescriptorException { + final String errorMessage; + MiniscriptDescriptorException( + String this.errorMessage, + ); + MiniscriptDescriptorException._( + String this.errorMessage, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final errorMessage_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final errorMessage = errorMessage_lifted.value; + new_offset += errorMessage_lifted.bytesRead; + return LiftRetVal( + MiniscriptDescriptorException._( + errorMessage, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(errorMessage) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 11); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterString.write( + errorMessage, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "MiniscriptDescriptorException($errorMessage)"; + } +} + +class HexDescriptorException extends DescriptorException { + final String errorMessage; + HexDescriptorException( + String this.errorMessage, + ); + HexDescriptorException._( + String this.errorMessage, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final errorMessage_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final errorMessage = errorMessage_lifted.value; + new_offset += errorMessage_lifted.bytesRead; + return LiftRetVal( + HexDescriptorException._( + errorMessage, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(errorMessage) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 12); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterString.write( + errorMessage, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "HexDescriptorException($errorMessage)"; + } +} + +class ExternalAndInternalAreTheSameDescriptorException + extends DescriptorException { + ExternalAndInternalAreTheSameDescriptorException(); + ExternalAndInternalAreTheSameDescriptorException._(); + static LiftRetVal read( + Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal( + ExternalAndInternalAreTheSameDescriptorException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 13); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "ExternalAndInternalAreTheSameDescriptorException"; + } +} + +class DescriptorExceptionErrorHandler extends UniffiRustCallStatusErrorHandler { + @override + Exception lift(RustBuffer errorBuf) { + return FfiConverterDescriptorException.lift(errorBuf); + } +} + +final DescriptorExceptionErrorHandler descriptorExceptionErrorHandler = + DescriptorExceptionErrorHandler(); + +abstract class DescriptorKeyException implements Exception { + RustBuffer lower(); + int allocationSize(); + int write(Uint8List buf); +} + +class FfiConverterDescriptorKeyException { + static DescriptorKeyException lift(RustBuffer buffer) { + return FfiConverterDescriptorKeyException.read(buffer.asUint8List()).value; + } + + static LiftRetVal read(Uint8List buf) { + final index = buf.buffer.asByteData(buf.offsetInBytes).getInt32(0); + final subview = Uint8List.view(buf.buffer, buf.offsetInBytes + 4); + switch (index) { + case 1: + return ParseDescriptorKeyException.read(subview); + case 2: + return InvalidKeyTypeDescriptorKeyException.read(subview); + case 3: + return Bip32DescriptorKeyException.read(subview); + default: + throw UniffiInternalError(UniffiInternalError.unexpectedEnumCase, + "Unable to determine enum variant"); + } + } + + static RustBuffer lower(DescriptorKeyException value) { + return value.lower(); + } + + static int allocationSize(DescriptorKeyException value) { + return value.allocationSize(); + } + + static int write(DescriptorKeyException value, Uint8List buf) { + return value.write(buf); + } +} + +class ParseDescriptorKeyException extends DescriptorKeyException { + final String errorMessage; + ParseDescriptorKeyException( + String this.errorMessage, + ); + ParseDescriptorKeyException._( + String this.errorMessage, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final errorMessage_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final errorMessage = errorMessage_lifted.value; + new_offset += errorMessage_lifted.bytesRead; + return LiftRetVal( + ParseDescriptorKeyException._( + errorMessage, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(errorMessage) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 1); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterString.write( + errorMessage, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "ParseDescriptorKeyException($errorMessage)"; + } +} + +class InvalidKeyTypeDescriptorKeyException extends DescriptorKeyException { + InvalidKeyTypeDescriptorKeyException(); + InvalidKeyTypeDescriptorKeyException._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(InvalidKeyTypeDescriptorKeyException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 2); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "InvalidKeyTypeDescriptorKeyException"; + } +} + +class Bip32DescriptorKeyException extends DescriptorKeyException { + final String errorMessage; + Bip32DescriptorKeyException( + String this.errorMessage, + ); + Bip32DescriptorKeyException._( + String this.errorMessage, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final errorMessage_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final errorMessage = errorMessage_lifted.value; + new_offset += errorMessage_lifted.bytesRead; + return LiftRetVal( + Bip32DescriptorKeyException._( + errorMessage, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(errorMessage) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 3); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterString.write( + errorMessage, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "Bip32DescriptorKeyException($errorMessage)"; + } +} + +class DescriptorKeyExceptionErrorHandler + extends UniffiRustCallStatusErrorHandler { + @override + Exception lift(RustBuffer errorBuf) { + return FfiConverterDescriptorKeyException.lift(errorBuf); + } +} + +final DescriptorKeyExceptionErrorHandler descriptorKeyExceptionErrorHandler = + DescriptorKeyExceptionErrorHandler(); + +enum DescriptorType { + bare, + sh, + pkh, + wpkh, + wsh, + shWsh, + shWpkh, + shSortedMulti, + wshSortedMulti, + shWshSortedMulti, + tr, + ; +} + +class FfiConverterDescriptorType { + static DescriptorType lift(RustBuffer buffer) { + final index = buffer.asUint8List().buffer.asByteData().getInt32(0); + switch (index) { + case 1: + return DescriptorType.bare; + case 2: + return DescriptorType.sh; + case 3: + return DescriptorType.pkh; + case 4: + return DescriptorType.wpkh; + case 5: + return DescriptorType.wsh; + case 6: + return DescriptorType.shWsh; + case 7: + return DescriptorType.shWpkh; + case 8: + return DescriptorType.shSortedMulti; + case 9: + return DescriptorType.wshSortedMulti; + case 10: + return DescriptorType.shWshSortedMulti; + case 11: + return DescriptorType.tr; + default: + throw UniffiInternalError(UniffiInternalError.unexpectedEnumCase, + "Unable to determine enum variant"); + } + } + + static RustBuffer lower(DescriptorType input) { + return toRustBuffer(createUint8ListFromInt(input.index + 1)); + } +} + +abstract class ElectrumException implements Exception { + RustBuffer lower(); + int allocationSize(); + int write(Uint8List buf); +} + +class FfiConverterElectrumException { + static ElectrumException lift(RustBuffer buffer) { + return FfiConverterElectrumException.read(buffer.asUint8List()).value; + } + + static LiftRetVal read(Uint8List buf) { + final index = buf.buffer.asByteData(buf.offsetInBytes).getInt32(0); + final subview = Uint8List.view(buf.buffer, buf.offsetInBytes + 4); + switch (index) { + case 1: + return IoExceptionElectrumException.read(subview); + case 2: + return JsonElectrumException.read(subview); + case 3: + return HexElectrumException.read(subview); + case 4: + return ProtocolElectrumException.read(subview); + case 5: + return BitcoinElectrumException.read(subview); + case 6: + return AlreadySubscribedElectrumException.read(subview); + case 7: + return NotSubscribedElectrumException.read(subview); + case 8: + return InvalidResponseElectrumException.read(subview); + case 9: + return MessageElectrumException.read(subview); + case 10: + return InvalidDnsNameExceptionElectrumException.read(subview); + case 11: + return MissingDomainElectrumException.read(subview); + case 12: + return AllAttemptsErroredElectrumException.read(subview); + case 13: + return SharedIoExceptionElectrumException.read(subview); + case 14: + return CouldntLockReaderElectrumException.read(subview); + case 15: + return MpscElectrumException.read(subview); + case 16: + return CouldNotCreateConnectionElectrumException.read(subview); + case 17: + return RequestAlreadyConsumedElectrumException.read(subview); + default: + throw UniffiInternalError(UniffiInternalError.unexpectedEnumCase, + "Unable to determine enum variant"); + } + } + + static RustBuffer lower(ElectrumException value) { + return value.lower(); + } + + static int allocationSize(ElectrumException value) { + return value.allocationSize(); + } + + static int write(ElectrumException value, Uint8List buf) { + return value.write(buf); + } +} + +class IoExceptionElectrumException extends ElectrumException { + final String errorMessage; + IoExceptionElectrumException( + String this.errorMessage, + ); + IoExceptionElectrumException._( + String this.errorMessage, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final errorMessage_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final errorMessage = errorMessage_lifted.value; + new_offset += errorMessage_lifted.bytesRead; + return LiftRetVal( + IoExceptionElectrumException._( + errorMessage, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(errorMessage) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 1); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterString.write( + errorMessage, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "IoExceptionElectrumException($errorMessage)"; + } +} + +class JsonElectrumException extends ElectrumException { + final String errorMessage; + JsonElectrumException( + String this.errorMessage, + ); + JsonElectrumException._( + String this.errorMessage, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final errorMessage_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final errorMessage = errorMessage_lifted.value; + new_offset += errorMessage_lifted.bytesRead; + return LiftRetVal( + JsonElectrumException._( + errorMessage, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(errorMessage) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 2); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterString.write( + errorMessage, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "JsonElectrumException($errorMessage)"; + } +} + +class HexElectrumException extends ElectrumException { + final String errorMessage; + HexElectrumException( + String this.errorMessage, + ); + HexElectrumException._( + String this.errorMessage, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final errorMessage_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final errorMessage = errorMessage_lifted.value; + new_offset += errorMessage_lifted.bytesRead; + return LiftRetVal( + HexElectrumException._( + errorMessage, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(errorMessage) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 3); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterString.write( + errorMessage, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "HexElectrumException($errorMessage)"; + } +} + +class ProtocolElectrumException extends ElectrumException { + final String errorMessage; + ProtocolElectrumException( + String this.errorMessage, + ); + ProtocolElectrumException._( + String this.errorMessage, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final errorMessage_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final errorMessage = errorMessage_lifted.value; + new_offset += errorMessage_lifted.bytesRead; + return LiftRetVal( + ProtocolElectrumException._( + errorMessage, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(errorMessage) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 4); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterString.write( + errorMessage, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "ProtocolElectrumException($errorMessage)"; + } +} + +class BitcoinElectrumException extends ElectrumException { + final String errorMessage; + BitcoinElectrumException( + String this.errorMessage, + ); + BitcoinElectrumException._( + String this.errorMessage, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final errorMessage_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final errorMessage = errorMessage_lifted.value; + new_offset += errorMessage_lifted.bytesRead; + return LiftRetVal( + BitcoinElectrumException._( + errorMessage, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(errorMessage) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 5); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterString.write( + errorMessage, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "BitcoinElectrumException($errorMessage)"; + } +} + +class AlreadySubscribedElectrumException extends ElectrumException { + AlreadySubscribedElectrumException(); + AlreadySubscribedElectrumException._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(AlreadySubscribedElectrumException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 6); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "AlreadySubscribedElectrumException"; + } +} + +class NotSubscribedElectrumException extends ElectrumException { + NotSubscribedElectrumException(); + NotSubscribedElectrumException._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(NotSubscribedElectrumException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 7); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "NotSubscribedElectrumException"; + } +} + +class InvalidResponseElectrumException extends ElectrumException { + final String errorMessage; + InvalidResponseElectrumException( + String this.errorMessage, + ); + InvalidResponseElectrumException._( + String this.errorMessage, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final errorMessage_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final errorMessage = errorMessage_lifted.value; + new_offset += errorMessage_lifted.bytesRead; + return LiftRetVal( + InvalidResponseElectrumException._( + errorMessage, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(errorMessage) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 8); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterString.write( + errorMessage, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "InvalidResponseElectrumException($errorMessage)"; + } +} + +class MessageElectrumException extends ElectrumException { + final String errorMessage; + MessageElectrumException( + String this.errorMessage, + ); + MessageElectrumException._( + String this.errorMessage, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final errorMessage_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final errorMessage = errorMessage_lifted.value; + new_offset += errorMessage_lifted.bytesRead; + return LiftRetVal( + MessageElectrumException._( + errorMessage, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(errorMessage) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 9); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterString.write( + errorMessage, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "MessageElectrumException($errorMessage)"; + } +} + +class InvalidDnsNameExceptionElectrumException extends ElectrumException { + final String domain; + InvalidDnsNameExceptionElectrumException( + String this.domain, + ); + InvalidDnsNameExceptionElectrumException._( + String this.domain, + ); + static LiftRetVal read( + Uint8List buf) { + int new_offset = buf.offsetInBytes; + final domain_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final domain = domain_lifted.value; + new_offset += domain_lifted.bytesRead; + return LiftRetVal( + InvalidDnsNameExceptionElectrumException._( + domain, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(domain) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 10); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterString.write( + domain, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "InvalidDnsNameExceptionElectrumException($domain)"; + } +} + +class MissingDomainElectrumException extends ElectrumException { + MissingDomainElectrumException(); + MissingDomainElectrumException._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(MissingDomainElectrumException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 11); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "MissingDomainElectrumException"; + } +} + +class AllAttemptsErroredElectrumException extends ElectrumException { + AllAttemptsErroredElectrumException(); + AllAttemptsErroredElectrumException._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(AllAttemptsErroredElectrumException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 12); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "AllAttemptsErroredElectrumException"; + } +} + +class SharedIoExceptionElectrumException extends ElectrumException { + final String errorMessage; + SharedIoExceptionElectrumException( + String this.errorMessage, + ); + SharedIoExceptionElectrumException._( + String this.errorMessage, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final errorMessage_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final errorMessage = errorMessage_lifted.value; + new_offset += errorMessage_lifted.bytesRead; + return LiftRetVal( + SharedIoExceptionElectrumException._( + errorMessage, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(errorMessage) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 13); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterString.write( + errorMessage, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "SharedIoExceptionElectrumException($errorMessage)"; + } +} + +class CouldntLockReaderElectrumException extends ElectrumException { + CouldntLockReaderElectrumException(); + CouldntLockReaderElectrumException._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(CouldntLockReaderElectrumException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 14); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "CouldntLockReaderElectrumException"; + } +} + +class MpscElectrumException extends ElectrumException { + MpscElectrumException(); + MpscElectrumException._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(MpscElectrumException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 15); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "MpscElectrumException"; + } +} + +class CouldNotCreateConnectionElectrumException extends ElectrumException { + final String errorMessage; + CouldNotCreateConnectionElectrumException( + String this.errorMessage, + ); + CouldNotCreateConnectionElectrumException._( + String this.errorMessage, + ); + static LiftRetVal read( + Uint8List buf) { + int new_offset = buf.offsetInBytes; + final errorMessage_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final errorMessage = errorMessage_lifted.value; + new_offset += errorMessage_lifted.bytesRead; + return LiftRetVal( + CouldNotCreateConnectionElectrumException._( + errorMessage, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(errorMessage) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 16); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterString.write( + errorMessage, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "CouldNotCreateConnectionElectrumException($errorMessage)"; + } +} + +class RequestAlreadyConsumedElectrumException extends ElectrumException { + RequestAlreadyConsumedElectrumException(); + RequestAlreadyConsumedElectrumException._(); + static LiftRetVal read( + Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(RequestAlreadyConsumedElectrumException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 17); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "RequestAlreadyConsumedElectrumException"; + } +} + +class ElectrumExceptionErrorHandler extends UniffiRustCallStatusErrorHandler { + @override + Exception lift(RustBuffer errorBuf) { + return FfiConverterElectrumException.lift(errorBuf); + } +} + +final ElectrumExceptionErrorHandler electrumExceptionErrorHandler = + ElectrumExceptionErrorHandler(); + +abstract class EsploraException implements Exception { + RustBuffer lower(); + int allocationSize(); + int write(Uint8List buf); +} + +class FfiConverterEsploraException { + static EsploraException lift(RustBuffer buffer) { + return FfiConverterEsploraException.read(buffer.asUint8List()).value; + } + + static LiftRetVal read(Uint8List buf) { + final index = buf.buffer.asByteData(buf.offsetInBytes).getInt32(0); + final subview = Uint8List.view(buf.buffer, buf.offsetInBytes + 4); + switch (index) { + case 1: + return MinreqEsploraException.read(subview); + case 2: + return HttpResponseEsploraException.read(subview); + case 3: + return ParsingEsploraException.read(subview); + case 4: + return StatusCodeEsploraException.read(subview); + case 5: + return BitcoinEncodingEsploraException.read(subview); + case 6: + return HexToArrayEsploraException.read(subview); + case 7: + return HexToBytesEsploraException.read(subview); + case 8: + return TransactionNotFoundEsploraException.read(subview); + case 9: + return HeaderHeightNotFoundEsploraException.read(subview); + case 10: + return HeaderHashNotFoundEsploraException.read(subview); + case 11: + return InvalidHttpHeaderNameEsploraException.read(subview); + case 12: + return InvalidHttpHeaderValueEsploraException.read(subview); + case 13: + return RequestAlreadyConsumedEsploraException.read(subview); + case 14: + return InvalidResponseEsploraException.read(subview); + default: + throw UniffiInternalError(UniffiInternalError.unexpectedEnumCase, + "Unable to determine enum variant"); + } + } + + static RustBuffer lower(EsploraException value) { + return value.lower(); + } + + static int allocationSize(EsploraException value) { + return value.allocationSize(); + } + + static int write(EsploraException value, Uint8List buf) { + return value.write(buf); + } +} + +class MinreqEsploraException extends EsploraException { + final String errorMessage; + MinreqEsploraException( + String this.errorMessage, + ); + MinreqEsploraException._( + String this.errorMessage, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final errorMessage_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final errorMessage = errorMessage_lifted.value; + new_offset += errorMessage_lifted.bytesRead; + return LiftRetVal( + MinreqEsploraException._( + errorMessage, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(errorMessage) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 1); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterString.write( + errorMessage, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "MinreqEsploraException($errorMessage)"; + } +} + +class HttpResponseEsploraException extends EsploraException { + final int status; + final String errorMessage; + HttpResponseEsploraException({ + required int this.status, + required String this.errorMessage, + }); + HttpResponseEsploraException._( + int this.status, + String this.errorMessage, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final status_lifted = + FfiConverterUInt16.read(Uint8List.view(buf.buffer, new_offset)); + final status = status_lifted.value; + new_offset += status_lifted.bytesRead; + final errorMessage_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final errorMessage = errorMessage_lifted.value; + new_offset += errorMessage_lifted.bytesRead; + return LiftRetVal( + HttpResponseEsploraException._( + status, + errorMessage, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterUInt16.allocationSize(status) + + FfiConverterString.allocationSize(errorMessage) + + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 2); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterUInt16.write( + status, Uint8List.view(buf.buffer, new_offset)); + new_offset += FfiConverterString.write( + errorMessage, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "HttpResponseEsploraException($status, $errorMessage)"; + } +} + +class ParsingEsploraException extends EsploraException { + final String errorMessage; + ParsingEsploraException( + String this.errorMessage, + ); + ParsingEsploraException._( + String this.errorMessage, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final errorMessage_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final errorMessage = errorMessage_lifted.value; + new_offset += errorMessage_lifted.bytesRead; + return LiftRetVal( + ParsingEsploraException._( + errorMessage, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(errorMessage) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 3); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterString.write( + errorMessage, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "ParsingEsploraException($errorMessage)"; + } +} + +class StatusCodeEsploraException extends EsploraException { + final String errorMessage; + StatusCodeEsploraException( + String this.errorMessage, + ); + StatusCodeEsploraException._( + String this.errorMessage, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final errorMessage_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final errorMessage = errorMessage_lifted.value; + new_offset += errorMessage_lifted.bytesRead; + return LiftRetVal( + StatusCodeEsploraException._( + errorMessage, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(errorMessage) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 4); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterString.write( + errorMessage, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "StatusCodeEsploraException($errorMessage)"; + } +} + +class BitcoinEncodingEsploraException extends EsploraException { + final String errorMessage; + BitcoinEncodingEsploraException( + String this.errorMessage, + ); + BitcoinEncodingEsploraException._( + String this.errorMessage, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final errorMessage_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final errorMessage = errorMessage_lifted.value; + new_offset += errorMessage_lifted.bytesRead; + return LiftRetVal( + BitcoinEncodingEsploraException._( + errorMessage, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(errorMessage) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 5); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterString.write( + errorMessage, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "BitcoinEncodingEsploraException($errorMessage)"; + } +} + +class HexToArrayEsploraException extends EsploraException { + final String errorMessage; + HexToArrayEsploraException( + String this.errorMessage, + ); + HexToArrayEsploraException._( + String this.errorMessage, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final errorMessage_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final errorMessage = errorMessage_lifted.value; + new_offset += errorMessage_lifted.bytesRead; + return LiftRetVal( + HexToArrayEsploraException._( + errorMessage, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(errorMessage) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 6); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterString.write( + errorMessage, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "HexToArrayEsploraException($errorMessage)"; + } +} + +class HexToBytesEsploraException extends EsploraException { + final String errorMessage; + HexToBytesEsploraException( + String this.errorMessage, + ); + HexToBytesEsploraException._( + String this.errorMessage, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final errorMessage_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final errorMessage = errorMessage_lifted.value; + new_offset += errorMessage_lifted.bytesRead; + return LiftRetVal( + HexToBytesEsploraException._( + errorMessage, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(errorMessage) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 7); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterString.write( + errorMessage, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "HexToBytesEsploraException($errorMessage)"; + } +} + +class TransactionNotFoundEsploraException extends EsploraException { + TransactionNotFoundEsploraException(); + TransactionNotFoundEsploraException._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(TransactionNotFoundEsploraException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 8); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "TransactionNotFoundEsploraException"; + } +} + +class HeaderHeightNotFoundEsploraException extends EsploraException { + final int height; + HeaderHeightNotFoundEsploraException( + int this.height, + ); + HeaderHeightNotFoundEsploraException._( + int this.height, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final height_lifted = + FfiConverterUInt32.read(Uint8List.view(buf.buffer, new_offset)); + final height = height_lifted.value; + new_offset += height_lifted.bytesRead; + return LiftRetVal( + HeaderHeightNotFoundEsploraException._( + height, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterUInt32.allocationSize(height) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 9); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterUInt32.write( + height, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "HeaderHeightNotFoundEsploraException($height)"; + } +} + +class HeaderHashNotFoundEsploraException extends EsploraException { + HeaderHashNotFoundEsploraException(); + HeaderHashNotFoundEsploraException._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(HeaderHashNotFoundEsploraException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 10); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "HeaderHashNotFoundEsploraException"; + } +} + +class InvalidHttpHeaderNameEsploraException extends EsploraException { + final String name; + InvalidHttpHeaderNameEsploraException( + String this.name, + ); + InvalidHttpHeaderNameEsploraException._( + String this.name, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final name_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final name = name_lifted.value; + new_offset += name_lifted.bytesRead; + return LiftRetVal( + InvalidHttpHeaderNameEsploraException._( + name, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(name) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 11); + int new_offset = buf.offsetInBytes + 4; + new_offset += + FfiConverterString.write(name, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "InvalidHttpHeaderNameEsploraException($name)"; + } +} + +class InvalidHttpHeaderValueEsploraException extends EsploraException { + final String value; + InvalidHttpHeaderValueEsploraException( + String this.value, + ); + InvalidHttpHeaderValueEsploraException._( + String this.value, + ); + static LiftRetVal read( + Uint8List buf) { + int new_offset = buf.offsetInBytes; + final value_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final value = value_lifted.value; + new_offset += value_lifted.bytesRead; + return LiftRetVal( + InvalidHttpHeaderValueEsploraException._( + value, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(value) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 12); + int new_offset = buf.offsetInBytes + 4; + new_offset += + FfiConverterString.write(value, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "InvalidHttpHeaderValueEsploraException($value)"; + } +} + +class RequestAlreadyConsumedEsploraException extends EsploraException { + RequestAlreadyConsumedEsploraException(); + RequestAlreadyConsumedEsploraException._(); + static LiftRetVal read( + Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(RequestAlreadyConsumedEsploraException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 13); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "RequestAlreadyConsumedEsploraException"; + } +} + +class InvalidResponseEsploraException extends EsploraException { + InvalidResponseEsploraException(); + InvalidResponseEsploraException._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(InvalidResponseEsploraException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 14); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "InvalidResponseEsploraException"; + } +} + +class EsploraExceptionErrorHandler extends UniffiRustCallStatusErrorHandler { + @override + Exception lift(RustBuffer errorBuf) { + return FfiConverterEsploraException.lift(errorBuf); + } +} + +final EsploraExceptionErrorHandler esploraExceptionErrorHandler = + EsploraExceptionErrorHandler(); + +abstract class ExtractTxException implements Exception { + RustBuffer lower(); + int allocationSize(); + int write(Uint8List buf); +} + +class FfiConverterExtractTxException { + static ExtractTxException lift(RustBuffer buffer) { + return FfiConverterExtractTxException.read(buffer.asUint8List()).value; + } + + static LiftRetVal read(Uint8List buf) { + final index = buf.buffer.asByteData(buf.offsetInBytes).getInt32(0); + final subview = Uint8List.view(buf.buffer, buf.offsetInBytes + 4); + switch (index) { + case 1: + return AbsurdFeeRateExtractTxException.read(subview); + case 2: + return MissingInputValueExtractTxException.read(subview); + case 3: + return SendingTooMuchExtractTxException.read(subview); + case 4: + return OtherExtractTxErrExtractTxException.read(subview); + default: + throw UniffiInternalError(UniffiInternalError.unexpectedEnumCase, + "Unable to determine enum variant"); + } + } + + static RustBuffer lower(ExtractTxException value) { + return value.lower(); + } + + static int allocationSize(ExtractTxException value) { + return value.allocationSize(); + } + + static int write(ExtractTxException value, Uint8List buf) { + return value.write(buf); + } +} + +class AbsurdFeeRateExtractTxException extends ExtractTxException { + final int feeRate; + AbsurdFeeRateExtractTxException( + int this.feeRate, + ); + AbsurdFeeRateExtractTxException._( + int this.feeRate, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final feeRate_lifted = + FfiConverterUInt64.read(Uint8List.view(buf.buffer, new_offset)); + final feeRate = feeRate_lifted.value; + new_offset += feeRate_lifted.bytesRead; + return LiftRetVal( + AbsurdFeeRateExtractTxException._( + feeRate, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterUInt64.allocationSize(feeRate) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 1); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterUInt64.write( + feeRate, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "AbsurdFeeRateExtractTxException($feeRate)"; + } +} + +class MissingInputValueExtractTxException extends ExtractTxException { + MissingInputValueExtractTxException(); + MissingInputValueExtractTxException._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(MissingInputValueExtractTxException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 2); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "MissingInputValueExtractTxException"; + } +} + +class SendingTooMuchExtractTxException extends ExtractTxException { + SendingTooMuchExtractTxException(); + SendingTooMuchExtractTxException._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(SendingTooMuchExtractTxException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 3); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "SendingTooMuchExtractTxException"; + } +} + +class OtherExtractTxErrExtractTxException extends ExtractTxException { + OtherExtractTxErrExtractTxException(); + OtherExtractTxErrExtractTxException._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(OtherExtractTxErrExtractTxException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 4); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "OtherExtractTxErrExtractTxException"; + } +} + +class ExtractTxExceptionErrorHandler extends UniffiRustCallStatusErrorHandler { + @override + Exception lift(RustBuffer errorBuf) { + return FfiConverterExtractTxException.lift(errorBuf); + } +} + +final ExtractTxExceptionErrorHandler extractTxExceptionErrorHandler = + ExtractTxExceptionErrorHandler(); + +abstract class FeeRateException implements Exception { + RustBuffer lower(); + int allocationSize(); + int write(Uint8List buf); +} + +class FfiConverterFeeRateException { + static FeeRateException lift(RustBuffer buffer) { + return FfiConverterFeeRateException.read(buffer.asUint8List()).value; + } + + static LiftRetVal read(Uint8List buf) { + final index = buf.buffer.asByteData(buf.offsetInBytes).getInt32(0); + final subview = Uint8List.view(buf.buffer, buf.offsetInBytes + 4); + switch (index) { + case 1: + return ArithmeticOverflowFeeRateException.read(subview); + default: + throw UniffiInternalError(UniffiInternalError.unexpectedEnumCase, + "Unable to determine enum variant"); + } + } + + static RustBuffer lower(FeeRateException value) { + return value.lower(); + } + + static int allocationSize(FeeRateException value) { + return value.allocationSize(); + } + + static int write(FeeRateException value, Uint8List buf) { + return value.write(buf); + } +} + +class ArithmeticOverflowFeeRateException extends FeeRateException { + ArithmeticOverflowFeeRateException(); + ArithmeticOverflowFeeRateException._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(ArithmeticOverflowFeeRateException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 1); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "ArithmeticOverflowFeeRateException"; + } +} + +class FeeRateExceptionErrorHandler extends UniffiRustCallStatusErrorHandler { + @override + Exception lift(RustBuffer errorBuf) { + return FfiConverterFeeRateException.lift(errorBuf); + } +} + +final FeeRateExceptionErrorHandler feeRateExceptionErrorHandler = + FeeRateExceptionErrorHandler(); + +abstract class FromScriptException implements Exception { + RustBuffer lower(); + int allocationSize(); + int write(Uint8List buf); +} + +class FfiConverterFromScriptException { + static FromScriptException lift(RustBuffer buffer) { + return FfiConverterFromScriptException.read(buffer.asUint8List()).value; + } + + static LiftRetVal read(Uint8List buf) { + final index = buf.buffer.asByteData(buf.offsetInBytes).getInt32(0); + final subview = Uint8List.view(buf.buffer, buf.offsetInBytes + 4); + switch (index) { + case 1: + return UnrecognizedScriptFromScriptException.read(subview); + case 2: + return WitnessProgramFromScriptException.read(subview); + case 3: + return WitnessVersionFromScriptException.read(subview); + case 4: + return OtherFromScriptErrFromScriptException.read(subview); + default: + throw UniffiInternalError(UniffiInternalError.unexpectedEnumCase, + "Unable to determine enum variant"); + } + } + + static RustBuffer lower(FromScriptException value) { + return value.lower(); + } + + static int allocationSize(FromScriptException value) { + return value.allocationSize(); + } + + static int write(FromScriptException value, Uint8List buf) { + return value.write(buf); + } +} + +class UnrecognizedScriptFromScriptException extends FromScriptException { + UnrecognizedScriptFromScriptException(); + UnrecognizedScriptFromScriptException._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(UnrecognizedScriptFromScriptException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 1); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "UnrecognizedScriptFromScriptException"; + } +} + +class WitnessProgramFromScriptException extends FromScriptException { + final String errorMessage; + WitnessProgramFromScriptException( + String this.errorMessage, + ); + WitnessProgramFromScriptException._( + String this.errorMessage, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final errorMessage_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final errorMessage = errorMessage_lifted.value; + new_offset += errorMessage_lifted.bytesRead; + return LiftRetVal( + WitnessProgramFromScriptException._( + errorMessage, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(errorMessage) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 2); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterString.write( + errorMessage, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "WitnessProgramFromScriptException($errorMessage)"; + } +} + +class WitnessVersionFromScriptException extends FromScriptException { + final String errorMessage; + WitnessVersionFromScriptException( + String this.errorMessage, + ); + WitnessVersionFromScriptException._( + String this.errorMessage, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final errorMessage_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final errorMessage = errorMessage_lifted.value; + new_offset += errorMessage_lifted.bytesRead; + return LiftRetVal( + WitnessVersionFromScriptException._( + errorMessage, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(errorMessage) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 3); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterString.write( + errorMessage, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "WitnessVersionFromScriptException($errorMessage)"; + } +} + +class OtherFromScriptErrFromScriptException extends FromScriptException { + OtherFromScriptErrFromScriptException(); + OtherFromScriptErrFromScriptException._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(OtherFromScriptErrFromScriptException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 4); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "OtherFromScriptErrFromScriptException"; + } +} + +class FromScriptExceptionErrorHandler extends UniffiRustCallStatusErrorHandler { + @override + Exception lift(RustBuffer errorBuf) { + return FfiConverterFromScriptException.lift(errorBuf); + } +} + +final FromScriptExceptionErrorHandler fromScriptExceptionErrorHandler = + FromScriptExceptionErrorHandler(); + +abstract class HashParseException implements Exception { + RustBuffer lower(); + int allocationSize(); + int write(Uint8List buf); +} + +class FfiConverterHashParseException { + static HashParseException lift(RustBuffer buffer) { + return FfiConverterHashParseException.read(buffer.asUint8List()).value; + } + + static LiftRetVal read(Uint8List buf) { + final index = buf.buffer.asByteData(buf.offsetInBytes).getInt32(0); + final subview = Uint8List.view(buf.buffer, buf.offsetInBytes + 4); + switch (index) { + case 1: + return InvalidHashHashParseException.read(subview); + case 2: + return InvalidHexStringHashParseException.read(subview); + default: + throw UniffiInternalError(UniffiInternalError.unexpectedEnumCase, + "Unable to determine enum variant"); + } + } + + static RustBuffer lower(HashParseException value) { + return value.lower(); + } + + static int allocationSize(HashParseException value) { + return value.allocationSize(); + } + + static int write(HashParseException value, Uint8List buf) { + return value.write(buf); + } +} + +class InvalidHashHashParseException extends HashParseException { + final int len; + InvalidHashHashParseException( + int this.len, + ); + InvalidHashHashParseException._( + int this.len, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final len_lifted = + FfiConverterUInt32.read(Uint8List.view(buf.buffer, new_offset)); + final len = len_lifted.value; + new_offset += len_lifted.bytesRead; + return LiftRetVal( + InvalidHashHashParseException._( + len, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterUInt32.allocationSize(len) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 1); + int new_offset = buf.offsetInBytes + 4; + new_offset += + FfiConverterUInt32.write(len, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "InvalidHashHashParseException($len)"; + } +} + +class InvalidHexStringHashParseException extends HashParseException { + final String hex; + InvalidHexStringHashParseException( + String this.hex, + ); + InvalidHexStringHashParseException._( + String this.hex, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final hex_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final hex = hex_lifted.value; + new_offset += hex_lifted.bytesRead; + return LiftRetVal( + InvalidHexStringHashParseException._( + hex, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(hex) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 2); + int new_offset = buf.offsetInBytes + 4; + new_offset += + FfiConverterString.write(hex, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "InvalidHexStringHashParseException($hex)"; + } +} + +class HashParseExceptionErrorHandler extends UniffiRustCallStatusErrorHandler { + @override + Exception lift(RustBuffer errorBuf) { + return FfiConverterHashParseException.lift(errorBuf); + } +} + +final HashParseExceptionErrorHandler hashParseExceptionErrorHandler = + HashParseExceptionErrorHandler(); + +abstract class Info { + RustBuffer lower(); + int allocationSize(); + int write(Uint8List buf); +} + +class FfiConverterInfo { + static Info lift(RustBuffer buffer) { + return FfiConverterInfo.read(buffer.asUint8List()).value; + } + + static LiftRetVal read(Uint8List buf) { + final index = buf.buffer.asByteData(buf.offsetInBytes).getInt32(0); + final subview = Uint8List.view(buf.buffer, buf.offsetInBytes + 4); + switch (index) { + case 1: + return ConnectionsMetInfo.read(subview); + case 2: + return SuccessfulHandshakeInfo.read(subview); + case 3: + return NewChainHeightInfo.read(subview); + case 4: + return NewForkInfo.read(subview); + case 5: + return ProgressInfo.read(subview); + case 6: + return StateUpdateInfo.read(subview); + case 7: + return TxGossipedInfo.read(subview); + default: + throw UniffiInternalError(UniffiInternalError.unexpectedEnumCase, + "Unable to determine enum variant"); + } + } + + static RustBuffer lower(Info value) { + return value.lower(); + } + + static int allocationSize(Info value) { + return value.allocationSize(); + } + + static int write(Info value, Uint8List buf) { + return value.write(buf); + } +} + +class ConnectionsMetInfo extends Info { + ConnectionsMetInfo(); + ConnectionsMetInfo._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(ConnectionsMetInfo._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 1); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } +} + +class SuccessfulHandshakeInfo extends Info { + SuccessfulHandshakeInfo(); + SuccessfulHandshakeInfo._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(SuccessfulHandshakeInfo._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 2); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } +} + +class NewChainHeightInfo extends Info { + final int height; + NewChainHeightInfo( + int this.height, + ); + NewChainHeightInfo._( + int this.height, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final height_lifted = + FfiConverterUInt32.read(Uint8List.view(buf.buffer, new_offset)); + final height = height_lifted.value; + new_offset += height_lifted.bytesRead; + return LiftRetVal( + NewChainHeightInfo._( + height, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterUInt32.allocationSize(height) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 3); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterUInt32.write( + height, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } +} + +class NewForkInfo extends Info { + final int height; + NewForkInfo( + int this.height, + ); + NewForkInfo._( + int this.height, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final height_lifted = + FfiConverterUInt32.read(Uint8List.view(buf.buffer, new_offset)); + final height = height_lifted.value; + new_offset += height_lifted.bytesRead; + return LiftRetVal( + NewForkInfo._( + height, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterUInt32.allocationSize(height) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 4); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterUInt32.write( + height, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } +} + +class ProgressInfo extends Info { + final double progress; + ProgressInfo( + double this.progress, + ); + ProgressInfo._( + double this.progress, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final progress_lifted = + FfiConverterDouble32.read(Uint8List.view(buf.buffer, new_offset)); + final progress = progress_lifted.value; + new_offset += progress_lifted.bytesRead; + return LiftRetVal( + ProgressInfo._( + progress, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterDouble32.allocationSize(progress) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 5); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterDouble32.write( + progress, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } +} + +class StateUpdateInfo extends Info { + final NodeState nodeState; + StateUpdateInfo( + NodeState this.nodeState, + ); + StateUpdateInfo._( + NodeState this.nodeState, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final nodeState_int = buf.buffer.asByteData(new_offset).getInt32(0); + final nodeState = FfiConverterNodeState.lift( + toRustBuffer(createUint8ListFromInt(nodeState_int))); + new_offset += 4; + return LiftRetVal( + StateUpdateInfo._( + nodeState, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4 + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 6); + int new_offset = buf.offsetInBytes + 4; + final nodeState_buffer = FfiConverterNodeState.lower(nodeState); + final nodeState_int = + nodeState_buffer.asUint8List().buffer.asByteData().getInt32(0); + buf.buffer.asByteData(new_offset).setInt32(0, nodeState_int); + new_offset += 4; + return new_offset; + } +} + +class TxGossipedInfo extends Info { + final String wtxid; + TxGossipedInfo( + String this.wtxid, + ); + TxGossipedInfo._( + String this.wtxid, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final wtxid_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final wtxid = wtxid_lifted.value; + new_offset += wtxid_lifted.bytesRead; + return LiftRetVal( + TxGossipedInfo._( + wtxid, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(wtxid) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 7); + int new_offset = buf.offsetInBytes + 4; + new_offset += + FfiConverterString.write(wtxid, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } +} + +enum KeychainKind { + external_, + internal, + ; +} + +class FfiConverterKeychainKind { + static KeychainKind lift(RustBuffer buffer) { + final index = buffer.asUint8List().buffer.asByteData().getInt32(0); + switch (index) { + case 1: + return KeychainKind.external_; + case 2: + return KeychainKind.internal; + default: + throw UniffiInternalError(UniffiInternalError.unexpectedEnumCase, + "Unable to determine enum variant"); + } + } + + static RustBuffer lower(KeychainKind input) { + return toRustBuffer(createUint8ListFromInt(input.index + 1)); + } +} + +abstract class LoadWithPersistException implements Exception { + RustBuffer lower(); + int allocationSize(); + int write(Uint8List buf); +} + +class FfiConverterLoadWithPersistException { + static LoadWithPersistException lift(RustBuffer buffer) { + return FfiConverterLoadWithPersistException.read(buffer.asUint8List()) + .value; + } + + static LiftRetVal read(Uint8List buf) { + final index = buf.buffer.asByteData(buf.offsetInBytes).getInt32(0); + final subview = Uint8List.view(buf.buffer, buf.offsetInBytes + 4); + switch (index) { + case 1: + return PersistLoadWithPersistException.read(subview); + case 2: + return InvalidChangeSetLoadWithPersistException.read(subview); + case 3: + return CouldNotLoadLoadWithPersistException.read(subview); + default: + throw UniffiInternalError(UniffiInternalError.unexpectedEnumCase, + "Unable to determine enum variant"); + } + } + + static RustBuffer lower(LoadWithPersistException value) { + return value.lower(); + } + + static int allocationSize(LoadWithPersistException value) { + return value.allocationSize(); + } + + static int write(LoadWithPersistException value, Uint8List buf) { + return value.write(buf); + } +} + +class PersistLoadWithPersistException extends LoadWithPersistException { + final String errorMessage; + PersistLoadWithPersistException( + String this.errorMessage, + ); + PersistLoadWithPersistException._( + String this.errorMessage, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final errorMessage_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final errorMessage = errorMessage_lifted.value; + new_offset += errorMessage_lifted.bytesRead; + return LiftRetVal( + PersistLoadWithPersistException._( + errorMessage, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(errorMessage) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 1); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterString.write( + errorMessage, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "PersistLoadWithPersistException($errorMessage)"; + } +} + +class InvalidChangeSetLoadWithPersistException + extends LoadWithPersistException { + final String errorMessage; + InvalidChangeSetLoadWithPersistException( + String this.errorMessage, + ); + InvalidChangeSetLoadWithPersistException._( + String this.errorMessage, + ); + static LiftRetVal read( + Uint8List buf) { + int new_offset = buf.offsetInBytes; + final errorMessage_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final errorMessage = errorMessage_lifted.value; + new_offset += errorMessage_lifted.bytesRead; + return LiftRetVal( + InvalidChangeSetLoadWithPersistException._( + errorMessage, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(errorMessage) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 2); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterString.write( + errorMessage, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "InvalidChangeSetLoadWithPersistException($errorMessage)"; + } +} + +class CouldNotLoadLoadWithPersistException extends LoadWithPersistException { + CouldNotLoadLoadWithPersistException(); + CouldNotLoadLoadWithPersistException._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(CouldNotLoadLoadWithPersistException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 3); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "CouldNotLoadLoadWithPersistException"; + } +} + +class LoadWithPersistExceptionErrorHandler + extends UniffiRustCallStatusErrorHandler { + @override + Exception lift(RustBuffer errorBuf) { + return FfiConverterLoadWithPersistException.lift(errorBuf); + } +} + +final LoadWithPersistExceptionErrorHandler + loadWithPersistExceptionErrorHandler = + LoadWithPersistExceptionErrorHandler(); + +abstract class LockTime { + RustBuffer lower(); + int allocationSize(); + int write(Uint8List buf); +} + +class FfiConverterLockTime { + static LockTime lift(RustBuffer buffer) { + return FfiConverterLockTime.read(buffer.asUint8List()).value; + } + + static LiftRetVal read(Uint8List buf) { + final index = buf.buffer.asByteData(buf.offsetInBytes).getInt32(0); + final subview = Uint8List.view(buf.buffer, buf.offsetInBytes + 4); + switch (index) { + case 1: + return BlocksLockTime.read(subview); + case 2: + return SecondsLockTime.read(subview); + default: + throw UniffiInternalError(UniffiInternalError.unexpectedEnumCase, + "Unable to determine enum variant"); + } + } + + static RustBuffer lower(LockTime value) { + return value.lower(); + } + + static int allocationSize(LockTime value) { + return value.allocationSize(); + } + + static int write(LockTime value, Uint8List buf) { + return value.write(buf); + } +} + +class BlocksLockTime extends LockTime { + final int height; + BlocksLockTime( + int this.height, + ); + BlocksLockTime._( + int this.height, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final height_lifted = + FfiConverterUInt32.read(Uint8List.view(buf.buffer, new_offset)); + final height = height_lifted.value; + new_offset += height_lifted.bytesRead; + return LiftRetVal( + BlocksLockTime._( + height, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterUInt32.allocationSize(height) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 1); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterUInt32.write( + height, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } +} + +class SecondsLockTime extends LockTime { + final int consensusTime; + SecondsLockTime( + int this.consensusTime, + ); + SecondsLockTime._( + int this.consensusTime, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final consensusTime_lifted = + FfiConverterUInt32.read(Uint8List.view(buf.buffer, new_offset)); + final consensusTime = consensusTime_lifted.value; + new_offset += consensusTime_lifted.bytesRead; + return LiftRetVal( + SecondsLockTime._( + consensusTime, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterUInt32.allocationSize(consensusTime) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 2); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterUInt32.write( + consensusTime, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } +} + +abstract class MiniscriptException implements Exception { + RustBuffer lower(); + int allocationSize(); + int write(Uint8List buf); +} + +class FfiConverterMiniscriptException { + static MiniscriptException lift(RustBuffer buffer) { + return FfiConverterMiniscriptException.read(buffer.asUint8List()).value; + } + + static LiftRetVal read(Uint8List buf) { + final index = buf.buffer.asByteData(buf.offsetInBytes).getInt32(0); + final subview = Uint8List.view(buf.buffer, buf.offsetInBytes + 4); + switch (index) { + case 1: + return AbsoluteLockTimeMiniscriptException.read(subview); + case 2: + return AddrExceptionMiniscriptException.read(subview); + case 3: + return AddrP2shExceptionMiniscriptException.read(subview); + case 4: + return AnalysisExceptionMiniscriptException.read(subview); + case 5: + return AtOutsideOrMiniscriptException.read(subview); + case 6: + return BadDescriptorMiniscriptException.read(subview); + case 7: + return BareDescriptorAddrMiniscriptException.read(subview); + case 8: + return CmsTooManyKeysMiniscriptException.read(subview); + case 9: + return ContextExceptionMiniscriptException.read(subview); + case 10: + return CouldNotSatisfyMiniscriptException.read(subview); + case 11: + return ExpectedCharMiniscriptException.read(subview); + case 12: + return ImpossibleSatisfactionMiniscriptException.read(subview); + case 13: + return InvalidOpcodeMiniscriptException.read(subview); + case 14: + return InvalidPushMiniscriptException.read(subview); + case 15: + return LiftExceptionMiniscriptException.read(subview); + case 16: + return MaxRecursiveDepthExceededMiniscriptException.read(subview); + case 17: + return MissingSigMiniscriptException.read(subview); + case 18: + return MultiATooManyKeysMiniscriptException.read(subview); + case 19: + return MultiColonMiniscriptException.read(subview); + case 20: + return MultipathDescLenMismatchMiniscriptException.read(subview); + case 21: + return NonMinimalVerifyMiniscriptException.read(subview); + case 22: + return NonStandardBareScriptMiniscriptException.read(subview); + case 23: + return NonTopLevelMiniscriptException.read(subview); + case 24: + return ParseThresholdMiniscriptException.read(subview); + case 25: + return PolicyExceptionMiniscriptException.read(subview); + case 26: + return PubKeyCtxExceptionMiniscriptException.read(subview); + case 27: + return RelativeLockTimeMiniscriptException.read(subview); + case 28: + return ScriptMiniscriptException.read(subview); + case 29: + return SecpMiniscriptException.read(subview); + case 30: + return ThresholdMiniscriptException.read(subview); + case 31: + return TrNoScriptCodeMiniscriptException.read(subview); + case 32: + return TrailingMiniscriptException.read(subview); + case 33: + return TypeCheckMiniscriptException.read(subview); + case 34: + return UnexpectedMiniscriptException.read(subview); + case 35: + return UnexpectedStartMiniscriptException.read(subview); + case 36: + return UnknownWrapperMiniscriptException.read(subview); + case 37: + return UnprintableMiniscriptException.read(subview); + default: + throw UniffiInternalError(UniffiInternalError.unexpectedEnumCase, + "Unable to determine enum variant"); + } + } + + static RustBuffer lower(MiniscriptException value) { + return value.lower(); + } + + static int allocationSize(MiniscriptException value) { + return value.allocationSize(); + } + + static int write(MiniscriptException value, Uint8List buf) { + return value.write(buf); + } +} + +class AbsoluteLockTimeMiniscriptException extends MiniscriptException { + AbsoluteLockTimeMiniscriptException(); + AbsoluteLockTimeMiniscriptException._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(AbsoluteLockTimeMiniscriptException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 1); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "AbsoluteLockTimeMiniscriptException"; + } +} + +class AddrExceptionMiniscriptException extends MiniscriptException { + final String errorMessage; + AddrExceptionMiniscriptException( + String this.errorMessage, + ); + AddrExceptionMiniscriptException._( + String this.errorMessage, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final errorMessage_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final errorMessage = errorMessage_lifted.value; + new_offset += errorMessage_lifted.bytesRead; + return LiftRetVal( + AddrExceptionMiniscriptException._( + errorMessage, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(errorMessage) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 2); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterString.write( + errorMessage, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "AddrExceptionMiniscriptException($errorMessage)"; + } +} + +class AddrP2shExceptionMiniscriptException extends MiniscriptException { + final String errorMessage; + AddrP2shExceptionMiniscriptException( + String this.errorMessage, + ); + AddrP2shExceptionMiniscriptException._( + String this.errorMessage, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final errorMessage_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final errorMessage = errorMessage_lifted.value; + new_offset += errorMessage_lifted.bytesRead; + return LiftRetVal( + AddrP2shExceptionMiniscriptException._( + errorMessage, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(errorMessage) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 3); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterString.write( + errorMessage, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "AddrP2shExceptionMiniscriptException($errorMessage)"; + } +} + +class AnalysisExceptionMiniscriptException extends MiniscriptException { + final String errorMessage; + AnalysisExceptionMiniscriptException( + String this.errorMessage, + ); + AnalysisExceptionMiniscriptException._( + String this.errorMessage, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final errorMessage_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final errorMessage = errorMessage_lifted.value; + new_offset += errorMessage_lifted.bytesRead; + return LiftRetVal( + AnalysisExceptionMiniscriptException._( + errorMessage, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(errorMessage) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 4); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterString.write( + errorMessage, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "AnalysisExceptionMiniscriptException($errorMessage)"; + } +} + +class AtOutsideOrMiniscriptException extends MiniscriptException { + AtOutsideOrMiniscriptException(); + AtOutsideOrMiniscriptException._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(AtOutsideOrMiniscriptException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 5); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "AtOutsideOrMiniscriptException"; + } +} + +class BadDescriptorMiniscriptException extends MiniscriptException { + final String errorMessage; + BadDescriptorMiniscriptException( + String this.errorMessage, + ); + BadDescriptorMiniscriptException._( + String this.errorMessage, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final errorMessage_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final errorMessage = errorMessage_lifted.value; + new_offset += errorMessage_lifted.bytesRead; + return LiftRetVal( + BadDescriptorMiniscriptException._( + errorMessage, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(errorMessage) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 6); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterString.write( + errorMessage, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "BadDescriptorMiniscriptException($errorMessage)"; + } +} + +class BareDescriptorAddrMiniscriptException extends MiniscriptException { + BareDescriptorAddrMiniscriptException(); + BareDescriptorAddrMiniscriptException._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(BareDescriptorAddrMiniscriptException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 7); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "BareDescriptorAddrMiniscriptException"; + } +} + +class CmsTooManyKeysMiniscriptException extends MiniscriptException { + final int keys; + CmsTooManyKeysMiniscriptException( + int this.keys, + ); + CmsTooManyKeysMiniscriptException._( + int this.keys, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final keys_lifted = + FfiConverterUInt32.read(Uint8List.view(buf.buffer, new_offset)); + final keys = keys_lifted.value; + new_offset += keys_lifted.bytesRead; + return LiftRetVal( + CmsTooManyKeysMiniscriptException._( + keys, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterUInt32.allocationSize(keys) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 8); + int new_offset = buf.offsetInBytes + 4; + new_offset += + FfiConverterUInt32.write(keys, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "CmsTooManyKeysMiniscriptException($keys)"; + } +} + +class ContextExceptionMiniscriptException extends MiniscriptException { + final String errorMessage; + ContextExceptionMiniscriptException( + String this.errorMessage, + ); + ContextExceptionMiniscriptException._( + String this.errorMessage, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final errorMessage_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final errorMessage = errorMessage_lifted.value; + new_offset += errorMessage_lifted.bytesRead; + return LiftRetVal( + ContextExceptionMiniscriptException._( + errorMessage, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(errorMessage) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 9); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterString.write( + errorMessage, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "ContextExceptionMiniscriptException($errorMessage)"; + } +} + +class CouldNotSatisfyMiniscriptException extends MiniscriptException { + CouldNotSatisfyMiniscriptException(); + CouldNotSatisfyMiniscriptException._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(CouldNotSatisfyMiniscriptException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 10); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "CouldNotSatisfyMiniscriptException"; + } +} + +class ExpectedCharMiniscriptException extends MiniscriptException { + final String char; + ExpectedCharMiniscriptException( + String this.char, + ); + ExpectedCharMiniscriptException._( + String this.char, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final char_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final char = char_lifted.value; + new_offset += char_lifted.bytesRead; + return LiftRetVal( + ExpectedCharMiniscriptException._( + char, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(char) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 11); + int new_offset = buf.offsetInBytes + 4; + new_offset += + FfiConverterString.write(char, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "ExpectedCharMiniscriptException($char)"; + } +} + +class ImpossibleSatisfactionMiniscriptException extends MiniscriptException { + ImpossibleSatisfactionMiniscriptException(); + ImpossibleSatisfactionMiniscriptException._(); + static LiftRetVal read( + Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal( + ImpossibleSatisfactionMiniscriptException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 12); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "ImpossibleSatisfactionMiniscriptException"; + } +} + +class InvalidOpcodeMiniscriptException extends MiniscriptException { + InvalidOpcodeMiniscriptException(); + InvalidOpcodeMiniscriptException._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(InvalidOpcodeMiniscriptException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 13); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "InvalidOpcodeMiniscriptException"; + } +} + +class InvalidPushMiniscriptException extends MiniscriptException { + InvalidPushMiniscriptException(); + InvalidPushMiniscriptException._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(InvalidPushMiniscriptException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 14); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "InvalidPushMiniscriptException"; + } +} + +class LiftExceptionMiniscriptException extends MiniscriptException { + final String errorMessage; + LiftExceptionMiniscriptException( + String this.errorMessage, + ); + LiftExceptionMiniscriptException._( + String this.errorMessage, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final errorMessage_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final errorMessage = errorMessage_lifted.value; + new_offset += errorMessage_lifted.bytesRead; + return LiftRetVal( + LiftExceptionMiniscriptException._( + errorMessage, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(errorMessage) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 15); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterString.write( + errorMessage, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "LiftExceptionMiniscriptException($errorMessage)"; + } +} + +class MaxRecursiveDepthExceededMiniscriptException extends MiniscriptException { + MaxRecursiveDepthExceededMiniscriptException(); + MaxRecursiveDepthExceededMiniscriptException._(); + static LiftRetVal read( + Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal( + MaxRecursiveDepthExceededMiniscriptException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 16); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "MaxRecursiveDepthExceededMiniscriptException"; + } +} + +class MissingSigMiniscriptException extends MiniscriptException { + MissingSigMiniscriptException(); + MissingSigMiniscriptException._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(MissingSigMiniscriptException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 17); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "MissingSigMiniscriptException"; + } +} + +class MultiATooManyKeysMiniscriptException extends MiniscriptException { + final int keys; + MultiATooManyKeysMiniscriptException( + int this.keys, + ); + MultiATooManyKeysMiniscriptException._( + int this.keys, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final keys_lifted = + FfiConverterUInt64.read(Uint8List.view(buf.buffer, new_offset)); + final keys = keys_lifted.value; + new_offset += keys_lifted.bytesRead; + return LiftRetVal( + MultiATooManyKeysMiniscriptException._( + keys, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterUInt64.allocationSize(keys) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 18); + int new_offset = buf.offsetInBytes + 4; + new_offset += + FfiConverterUInt64.write(keys, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "MultiATooManyKeysMiniscriptException($keys)"; + } +} + +class MultiColonMiniscriptException extends MiniscriptException { + MultiColonMiniscriptException(); + MultiColonMiniscriptException._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(MultiColonMiniscriptException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 19); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "MultiColonMiniscriptException"; + } +} + +class MultipathDescLenMismatchMiniscriptException extends MiniscriptException { + MultipathDescLenMismatchMiniscriptException(); + MultipathDescLenMismatchMiniscriptException._(); + static LiftRetVal read( + Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal( + MultipathDescLenMismatchMiniscriptException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 20); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "MultipathDescLenMismatchMiniscriptException"; + } +} + +class NonMinimalVerifyMiniscriptException extends MiniscriptException { + final String errorMessage; + NonMinimalVerifyMiniscriptException( + String this.errorMessage, + ); + NonMinimalVerifyMiniscriptException._( + String this.errorMessage, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final errorMessage_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final errorMessage = errorMessage_lifted.value; + new_offset += errorMessage_lifted.bytesRead; + return LiftRetVal( + NonMinimalVerifyMiniscriptException._( + errorMessage, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(errorMessage) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 21); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterString.write( + errorMessage, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "NonMinimalVerifyMiniscriptException($errorMessage)"; + } +} + +class NonStandardBareScriptMiniscriptException extends MiniscriptException { + NonStandardBareScriptMiniscriptException(); + NonStandardBareScriptMiniscriptException._(); + static LiftRetVal read( + Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(NonStandardBareScriptMiniscriptException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 22); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "NonStandardBareScriptMiniscriptException"; + } +} + +class NonTopLevelMiniscriptException extends MiniscriptException { + final String errorMessage; + NonTopLevelMiniscriptException( + String this.errorMessage, + ); + NonTopLevelMiniscriptException._( + String this.errorMessage, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final errorMessage_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final errorMessage = errorMessage_lifted.value; + new_offset += errorMessage_lifted.bytesRead; + return LiftRetVal( + NonTopLevelMiniscriptException._( + errorMessage, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(errorMessage) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 23); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterString.write( + errorMessage, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "NonTopLevelMiniscriptException($errorMessage)"; + } +} + +class ParseThresholdMiniscriptException extends MiniscriptException { + ParseThresholdMiniscriptException(); + ParseThresholdMiniscriptException._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(ParseThresholdMiniscriptException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 24); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "ParseThresholdMiniscriptException"; + } +} + +class PolicyExceptionMiniscriptException extends MiniscriptException { + final String errorMessage; + PolicyExceptionMiniscriptException( + String this.errorMessage, + ); + PolicyExceptionMiniscriptException._( + String this.errorMessage, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final errorMessage_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final errorMessage = errorMessage_lifted.value; + new_offset += errorMessage_lifted.bytesRead; + return LiftRetVal( + PolicyExceptionMiniscriptException._( + errorMessage, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(errorMessage) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 25); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterString.write( + errorMessage, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "PolicyExceptionMiniscriptException($errorMessage)"; + } +} + +class PubKeyCtxExceptionMiniscriptException extends MiniscriptException { + PubKeyCtxExceptionMiniscriptException(); + PubKeyCtxExceptionMiniscriptException._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(PubKeyCtxExceptionMiniscriptException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 26); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "PubKeyCtxExceptionMiniscriptException"; + } +} + +class RelativeLockTimeMiniscriptException extends MiniscriptException { + RelativeLockTimeMiniscriptException(); + RelativeLockTimeMiniscriptException._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(RelativeLockTimeMiniscriptException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 27); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "RelativeLockTimeMiniscriptException"; + } +} + +class ScriptMiniscriptException extends MiniscriptException { + final String errorMessage; + ScriptMiniscriptException( + String this.errorMessage, + ); + ScriptMiniscriptException._( + String this.errorMessage, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final errorMessage_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final errorMessage = errorMessage_lifted.value; + new_offset += errorMessage_lifted.bytesRead; + return LiftRetVal( + ScriptMiniscriptException._( + errorMessage, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(errorMessage) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 28); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterString.write( + errorMessage, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "ScriptMiniscriptException($errorMessage)"; + } +} + +class SecpMiniscriptException extends MiniscriptException { + final String errorMessage; + SecpMiniscriptException( + String this.errorMessage, + ); + SecpMiniscriptException._( + String this.errorMessage, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final errorMessage_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final errorMessage = errorMessage_lifted.value; + new_offset += errorMessage_lifted.bytesRead; + return LiftRetVal( + SecpMiniscriptException._( + errorMessage, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(errorMessage) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 29); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterString.write( + errorMessage, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "SecpMiniscriptException($errorMessage)"; + } +} + +class ThresholdMiniscriptException extends MiniscriptException { + ThresholdMiniscriptException(); + ThresholdMiniscriptException._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(ThresholdMiniscriptException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 30); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "ThresholdMiniscriptException"; + } +} + +class TrNoScriptCodeMiniscriptException extends MiniscriptException { + TrNoScriptCodeMiniscriptException(); + TrNoScriptCodeMiniscriptException._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(TrNoScriptCodeMiniscriptException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 31); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "TrNoScriptCodeMiniscriptException"; + } +} + +class TrailingMiniscriptException extends MiniscriptException { + final String errorMessage; + TrailingMiniscriptException( + String this.errorMessage, + ); + TrailingMiniscriptException._( + String this.errorMessage, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final errorMessage_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final errorMessage = errorMessage_lifted.value; + new_offset += errorMessage_lifted.bytesRead; + return LiftRetVal( + TrailingMiniscriptException._( + errorMessage, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(errorMessage) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 32); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterString.write( + errorMessage, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "TrailingMiniscriptException($errorMessage)"; + } +} + +class TypeCheckMiniscriptException extends MiniscriptException { + final String errorMessage; + TypeCheckMiniscriptException( + String this.errorMessage, + ); + TypeCheckMiniscriptException._( + String this.errorMessage, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final errorMessage_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final errorMessage = errorMessage_lifted.value; + new_offset += errorMessage_lifted.bytesRead; + return LiftRetVal( + TypeCheckMiniscriptException._( + errorMessage, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(errorMessage) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 33); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterString.write( + errorMessage, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "TypeCheckMiniscriptException($errorMessage)"; + } +} + +class UnexpectedMiniscriptException extends MiniscriptException { + final String errorMessage; + UnexpectedMiniscriptException( + String this.errorMessage, + ); + UnexpectedMiniscriptException._( + String this.errorMessage, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final errorMessage_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final errorMessage = errorMessage_lifted.value; + new_offset += errorMessage_lifted.bytesRead; + return LiftRetVal( + UnexpectedMiniscriptException._( + errorMessage, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(errorMessage) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 34); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterString.write( + errorMessage, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "UnexpectedMiniscriptException($errorMessage)"; + } +} + +class UnexpectedStartMiniscriptException extends MiniscriptException { + UnexpectedStartMiniscriptException(); + UnexpectedStartMiniscriptException._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(UnexpectedStartMiniscriptException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 35); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "UnexpectedStartMiniscriptException"; + } +} + +class UnknownWrapperMiniscriptException extends MiniscriptException { + final String char; + UnknownWrapperMiniscriptException( + String this.char, + ); + UnknownWrapperMiniscriptException._( + String this.char, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final char_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final char = char_lifted.value; + new_offset += char_lifted.bytesRead; + return LiftRetVal( + UnknownWrapperMiniscriptException._( + char, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(char) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 36); + int new_offset = buf.offsetInBytes + 4; + new_offset += + FfiConverterString.write(char, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "UnknownWrapperMiniscriptException($char)"; + } +} + +class UnprintableMiniscriptException extends MiniscriptException { + final int byte; + UnprintableMiniscriptException( + int this.byte, + ); + UnprintableMiniscriptException._( + int this.byte, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final byte_lifted = + FfiConverterUInt8.read(Uint8List.view(buf.buffer, new_offset)); + final byte = byte_lifted.value; + new_offset += byte_lifted.bytesRead; + return LiftRetVal( + UnprintableMiniscriptException._( + byte, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterUInt8.allocationSize(byte) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 37); + int new_offset = buf.offsetInBytes + 4; + new_offset += + FfiConverterUInt8.write(byte, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "UnprintableMiniscriptException($byte)"; + } +} + +class MiniscriptExceptionErrorHandler extends UniffiRustCallStatusErrorHandler { + @override + Exception lift(RustBuffer errorBuf) { + return FfiConverterMiniscriptException.lift(errorBuf); + } +} + +final MiniscriptExceptionErrorHandler miniscriptExceptionErrorHandler = + MiniscriptExceptionErrorHandler(); + +enum Network { + bitcoin, + testnet, + testnet4, + signet, + regtest, + ; +} + +class FfiConverterNetwork { + static Network lift(RustBuffer buffer) { + final index = buffer.asUint8List().buffer.asByteData().getInt32(0); + switch (index) { + case 1: + return Network.bitcoin; + case 2: + return Network.testnet; + case 3: + return Network.testnet4; + case 4: + return Network.signet; + case 5: + return Network.regtest; + default: + throw UniffiInternalError(UniffiInternalError.unexpectedEnumCase, + "Unable to determine enum variant"); + } + } + + static RustBuffer lower(Network input) { + return toRustBuffer(createUint8ListFromInt(input.index + 1)); + } +} + +enum NodeState { + behind, + headersSynced, + filterHeadersSynced, + filtersSynced, + transactionsSynced, + ; +} + +class FfiConverterNodeState { + static NodeState lift(RustBuffer buffer) { + final index = buffer.asUint8List().buffer.asByteData().getInt32(0); + switch (index) { + case 1: + return NodeState.behind; + case 2: + return NodeState.headersSynced; + case 3: + return NodeState.filterHeadersSynced; + case 4: + return NodeState.filtersSynced; + case 5: + return NodeState.transactionsSynced; + default: + throw UniffiInternalError(UniffiInternalError.unexpectedEnumCase, + "Unable to determine enum variant"); + } + } + + static RustBuffer lower(NodeState input) { + return toRustBuffer(createUint8ListFromInt(input.index + 1)); + } +} + +abstract class ParseAmountException implements Exception { + RustBuffer lower(); + int allocationSize(); + int write(Uint8List buf); +} + +class FfiConverterParseAmountException { + static ParseAmountException lift(RustBuffer buffer) { + return FfiConverterParseAmountException.read(buffer.asUint8List()).value; + } + + static LiftRetVal read(Uint8List buf) { + final index = buf.buffer.asByteData(buf.offsetInBytes).getInt32(0); + final subview = Uint8List.view(buf.buffer, buf.offsetInBytes + 4); + switch (index) { + case 1: + return OutOfRangeParseAmountException.read(subview); + case 2: + return TooPreciseParseAmountException.read(subview); + case 3: + return MissingDigitsParseAmountException.read(subview); + case 4: + return InputTooLargeParseAmountException.read(subview); + case 5: + return InvalidCharacterParseAmountException.read(subview); + case 6: + return OtherParseAmountErrParseAmountException.read(subview); + default: + throw UniffiInternalError(UniffiInternalError.unexpectedEnumCase, + "Unable to determine enum variant"); + } + } + + static RustBuffer lower(ParseAmountException value) { + return value.lower(); + } + + static int allocationSize(ParseAmountException value) { + return value.allocationSize(); + } + + static int write(ParseAmountException value, Uint8List buf) { + return value.write(buf); + } +} + +class OutOfRangeParseAmountException extends ParseAmountException { + OutOfRangeParseAmountException(); + OutOfRangeParseAmountException._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(OutOfRangeParseAmountException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 1); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "OutOfRangeParseAmountException"; + } +} + +class TooPreciseParseAmountException extends ParseAmountException { + TooPreciseParseAmountException(); + TooPreciseParseAmountException._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(TooPreciseParseAmountException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 2); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "TooPreciseParseAmountException"; + } +} + +class MissingDigitsParseAmountException extends ParseAmountException { + MissingDigitsParseAmountException(); + MissingDigitsParseAmountException._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(MissingDigitsParseAmountException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 3); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "MissingDigitsParseAmountException"; + } +} + +class InputTooLargeParseAmountException extends ParseAmountException { + InputTooLargeParseAmountException(); + InputTooLargeParseAmountException._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(InputTooLargeParseAmountException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 4); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "InputTooLargeParseAmountException"; + } +} + +class InvalidCharacterParseAmountException extends ParseAmountException { + final String errorMessage; + InvalidCharacterParseAmountException( + String this.errorMessage, + ); + InvalidCharacterParseAmountException._( + String this.errorMessage, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final errorMessage_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final errorMessage = errorMessage_lifted.value; + new_offset += errorMessage_lifted.bytesRead; + return LiftRetVal( + InvalidCharacterParseAmountException._( + errorMessage, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(errorMessage) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 5); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterString.write( + errorMessage, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "InvalidCharacterParseAmountException($errorMessage)"; + } +} + +class OtherParseAmountErrParseAmountException extends ParseAmountException { + OtherParseAmountErrParseAmountException(); + OtherParseAmountErrParseAmountException._(); + static LiftRetVal read( + Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(OtherParseAmountErrParseAmountException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 6); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "OtherParseAmountErrParseAmountException"; + } +} + +class ParseAmountExceptionErrorHandler + extends UniffiRustCallStatusErrorHandler { + @override + Exception lift(RustBuffer errorBuf) { + return FfiConverterParseAmountException.lift(errorBuf); + } +} + +final ParseAmountExceptionErrorHandler parseAmountExceptionErrorHandler = + ParseAmountExceptionErrorHandler(); + +abstract class PersistenceException implements Exception { + RustBuffer lower(); + int allocationSize(); + int write(Uint8List buf); +} + +class FfiConverterPersistenceException { + static PersistenceException lift(RustBuffer buffer) { + return FfiConverterPersistenceException.read(buffer.asUint8List()).value; + } + + static LiftRetVal read(Uint8List buf) { + final index = buf.buffer.asByteData(buf.offsetInBytes).getInt32(0); + final subview = Uint8List.view(buf.buffer, buf.offsetInBytes + 4); + switch (index) { + case 1: + return ReasonPersistenceException.read(subview); + default: + throw UniffiInternalError(UniffiInternalError.unexpectedEnumCase, + "Unable to determine enum variant"); + } + } + + static RustBuffer lower(PersistenceException value) { + return value.lower(); + } + + static int allocationSize(PersistenceException value) { + return value.allocationSize(); + } + + static int write(PersistenceException value, Uint8List buf) { + return value.write(buf); + } +} + +class ReasonPersistenceException extends PersistenceException { + final String errorMessage; + ReasonPersistenceException( + String this.errorMessage, + ); + ReasonPersistenceException._( + String this.errorMessage, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final errorMessage_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final errorMessage = errorMessage_lifted.value; + new_offset += errorMessage_lifted.bytesRead; + return LiftRetVal( + ReasonPersistenceException._( + errorMessage, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(errorMessage) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 1); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterString.write( + errorMessage, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "ReasonPersistenceException($errorMessage)"; + } +} + +class PersistenceExceptionErrorHandler + extends UniffiRustCallStatusErrorHandler { + @override + Exception lift(RustBuffer errorBuf) { + return FfiConverterPersistenceException.lift(errorBuf); + } +} + +final PersistenceExceptionErrorHandler persistenceExceptionErrorHandler = + PersistenceExceptionErrorHandler(); + +abstract class PkOrF { + RustBuffer lower(); + int allocationSize(); + int write(Uint8List buf); +} + +class FfiConverterPkOrF { + static PkOrF lift(RustBuffer buffer) { + return FfiConverterPkOrF.read(buffer.asUint8List()).value; + } + + static LiftRetVal read(Uint8List buf) { + final index = buf.buffer.asByteData(buf.offsetInBytes).getInt32(0); + final subview = Uint8List.view(buf.buffer, buf.offsetInBytes + 4); + switch (index) { + case 1: + return PubkeyPkOrF.read(subview); + case 2: + return XOnlyPubkeyPkOrF.read(subview); + case 3: + return FingerprintPkOrF.read(subview); + default: + throw UniffiInternalError(UniffiInternalError.unexpectedEnumCase, + "Unable to determine enum variant"); + } + } + + static RustBuffer lower(PkOrF value) { + return value.lower(); + } + + static int allocationSize(PkOrF value) { + return value.allocationSize(); + } + + static int write(PkOrF value, Uint8List buf) { + return value.write(buf); + } +} + +class PubkeyPkOrF extends PkOrF { + final String value; + PubkeyPkOrF( + String this.value, + ); + PubkeyPkOrF._( + String this.value, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final value_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final value = value_lifted.value; + new_offset += value_lifted.bytesRead; + return LiftRetVal( + PubkeyPkOrF._( + value, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(value) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 1); + int new_offset = buf.offsetInBytes + 4; + new_offset += + FfiConverterString.write(value, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } +} + +class XOnlyPubkeyPkOrF extends PkOrF { + final String value; + XOnlyPubkeyPkOrF( + String this.value, + ); + XOnlyPubkeyPkOrF._( + String this.value, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final value_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final value = value_lifted.value; + new_offset += value_lifted.bytesRead; + return LiftRetVal( + XOnlyPubkeyPkOrF._( + value, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(value) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 2); + int new_offset = buf.offsetInBytes + 4; + new_offset += + FfiConverterString.write(value, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } +} + +class FingerprintPkOrF extends PkOrF { + final String value; + FingerprintPkOrF( + String this.value, + ); + FingerprintPkOrF._( + String this.value, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final value_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final value = value_lifted.value; + new_offset += value_lifted.bytesRead; + return LiftRetVal( + FingerprintPkOrF._( + value, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(value) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 3); + int new_offset = buf.offsetInBytes + 4; + new_offset += + FfiConverterString.write(value, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } +} + +abstract class PsbtException implements Exception { + RustBuffer lower(); + int allocationSize(); + int write(Uint8List buf); +} + +class FfiConverterPsbtException { + static PsbtException lift(RustBuffer buffer) { + return FfiConverterPsbtException.read(buffer.asUint8List()).value; + } + + static LiftRetVal read(Uint8List buf) { + final index = buf.buffer.asByteData(buf.offsetInBytes).getInt32(0); + final subview = Uint8List.view(buf.buffer, buf.offsetInBytes + 4); + switch (index) { + case 1: + return InvalidMagicPsbtException.read(subview); + case 2: + return MissingUtxoPsbtException.read(subview); + case 3: + return InvalidSeparatorPsbtException.read(subview); + case 4: + return PsbtUtxoOutOfBoundsPsbtException.read(subview); + case 5: + return InvalidKeyPsbtException.read(subview); + case 6: + return InvalidProprietaryKeyPsbtException.read(subview); + case 7: + return DuplicateKeyPsbtException.read(subview); + case 8: + return UnsignedTxHasScriptSigsPsbtException.read(subview); + case 9: + return UnsignedTxHasScriptWitnessesPsbtException.read(subview); + case 10: + return MustHaveUnsignedTxPsbtException.read(subview); + case 11: + return NoMorePairsPsbtException.read(subview); + case 12: + return UnexpectedUnsignedTxPsbtException.read(subview); + case 13: + return NonStandardSighashTypePsbtException.read(subview); + case 14: + return InvalidHashPsbtException.read(subview); + case 15: + return InvalidPreimageHashPairPsbtException.read(subview); + case 16: + return CombineInconsistentKeySourcesPsbtException.read(subview); + case 17: + return ConsensusEncodingPsbtException.read(subview); + case 18: + return NegativeFeePsbtException.read(subview); + case 19: + return FeeOverflowPsbtException.read(subview); + case 20: + return InvalidPublicKeyPsbtException.read(subview); + case 21: + return InvalidSecp256k1PublicKeyPsbtException.read(subview); + case 22: + return InvalidXOnlyPublicKeyPsbtException.read(subview); + case 23: + return InvalidEcdsaSignaturePsbtException.read(subview); + case 24: + return InvalidTaprootSignaturePsbtException.read(subview); + case 25: + return InvalidControlBlockPsbtException.read(subview); + case 26: + return InvalidLeafVersionPsbtException.read(subview); + case 27: + return TaprootPsbtException.read(subview); + case 28: + return TapTreePsbtException.read(subview); + case 29: + return XPubKeyPsbtException.read(subview); + case 30: + return VersionPsbtException.read(subview); + case 31: + return PartialDataConsumptionPsbtException.read(subview); + case 32: + return IoPsbtException.read(subview); + case 33: + return OtherPsbtErrPsbtException.read(subview); + default: + throw UniffiInternalError(UniffiInternalError.unexpectedEnumCase, + "Unable to determine enum variant"); + } + } + + static RustBuffer lower(PsbtException value) { + return value.lower(); + } + + static int allocationSize(PsbtException value) { + return value.allocationSize(); + } + + static int write(PsbtException value, Uint8List buf) { + return value.write(buf); + } +} + +class InvalidMagicPsbtException extends PsbtException { + InvalidMagicPsbtException(); + InvalidMagicPsbtException._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(InvalidMagicPsbtException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 1); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "InvalidMagicPsbtException"; + } +} + +class MissingUtxoPsbtException extends PsbtException { + MissingUtxoPsbtException(); + MissingUtxoPsbtException._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(MissingUtxoPsbtException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 2); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "MissingUtxoPsbtException"; + } +} + +class InvalidSeparatorPsbtException extends PsbtException { + InvalidSeparatorPsbtException(); + InvalidSeparatorPsbtException._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(InvalidSeparatorPsbtException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 3); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "InvalidSeparatorPsbtException"; + } +} + +class PsbtUtxoOutOfBoundsPsbtException extends PsbtException { + PsbtUtxoOutOfBoundsPsbtException(); + PsbtUtxoOutOfBoundsPsbtException._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(PsbtUtxoOutOfBoundsPsbtException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 4); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "PsbtUtxoOutOfBoundsPsbtException"; + } +} + +class InvalidKeyPsbtException extends PsbtException { + final String key; + InvalidKeyPsbtException( + String this.key, + ); + InvalidKeyPsbtException._( + String this.key, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final key_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final key = key_lifted.value; + new_offset += key_lifted.bytesRead; + return LiftRetVal( + InvalidKeyPsbtException._( + key, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(key) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 5); + int new_offset = buf.offsetInBytes + 4; + new_offset += + FfiConverterString.write(key, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "InvalidKeyPsbtException($key)"; + } +} + +class InvalidProprietaryKeyPsbtException extends PsbtException { + InvalidProprietaryKeyPsbtException(); + InvalidProprietaryKeyPsbtException._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(InvalidProprietaryKeyPsbtException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 6); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "InvalidProprietaryKeyPsbtException"; + } +} + +class DuplicateKeyPsbtException extends PsbtException { + final String key; + DuplicateKeyPsbtException( + String this.key, + ); + DuplicateKeyPsbtException._( + String this.key, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final key_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final key = key_lifted.value; + new_offset += key_lifted.bytesRead; + return LiftRetVal( + DuplicateKeyPsbtException._( + key, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(key) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 7); + int new_offset = buf.offsetInBytes + 4; + new_offset += + FfiConverterString.write(key, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "DuplicateKeyPsbtException($key)"; + } +} + +class UnsignedTxHasScriptSigsPsbtException extends PsbtException { + UnsignedTxHasScriptSigsPsbtException(); + UnsignedTxHasScriptSigsPsbtException._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(UnsignedTxHasScriptSigsPsbtException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 8); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "UnsignedTxHasScriptSigsPsbtException"; + } +} + +class UnsignedTxHasScriptWitnessesPsbtException extends PsbtException { + UnsignedTxHasScriptWitnessesPsbtException(); + UnsignedTxHasScriptWitnessesPsbtException._(); + static LiftRetVal read( + Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal( + UnsignedTxHasScriptWitnessesPsbtException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 9); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "UnsignedTxHasScriptWitnessesPsbtException"; + } +} + +class MustHaveUnsignedTxPsbtException extends PsbtException { + MustHaveUnsignedTxPsbtException(); + MustHaveUnsignedTxPsbtException._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(MustHaveUnsignedTxPsbtException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 10); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "MustHaveUnsignedTxPsbtException"; + } +} + +class NoMorePairsPsbtException extends PsbtException { + NoMorePairsPsbtException(); + NoMorePairsPsbtException._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(NoMorePairsPsbtException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 11); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "NoMorePairsPsbtException"; + } +} + +class UnexpectedUnsignedTxPsbtException extends PsbtException { + UnexpectedUnsignedTxPsbtException(); + UnexpectedUnsignedTxPsbtException._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(UnexpectedUnsignedTxPsbtException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 12); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "UnexpectedUnsignedTxPsbtException"; + } +} + +class NonStandardSighashTypePsbtException extends PsbtException { + final int sighash; + NonStandardSighashTypePsbtException( + int this.sighash, + ); + NonStandardSighashTypePsbtException._( + int this.sighash, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final sighash_lifted = + FfiConverterUInt32.read(Uint8List.view(buf.buffer, new_offset)); + final sighash = sighash_lifted.value; + new_offset += sighash_lifted.bytesRead; + return LiftRetVal( + NonStandardSighashTypePsbtException._( + sighash, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterUInt32.allocationSize(sighash) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 13); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterUInt32.write( + sighash, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "NonStandardSighashTypePsbtException($sighash)"; + } +} + +class InvalidHashPsbtException extends PsbtException { + final String hash; + InvalidHashPsbtException( + String this.hash, + ); + InvalidHashPsbtException._( + String this.hash, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final hash_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final hash = hash_lifted.value; + new_offset += hash_lifted.bytesRead; + return LiftRetVal( + InvalidHashPsbtException._( + hash, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(hash) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 14); + int new_offset = buf.offsetInBytes + 4; + new_offset += + FfiConverterString.write(hash, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "InvalidHashPsbtException($hash)"; + } +} + +class InvalidPreimageHashPairPsbtException extends PsbtException { + InvalidPreimageHashPairPsbtException(); + InvalidPreimageHashPairPsbtException._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(InvalidPreimageHashPairPsbtException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 15); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "InvalidPreimageHashPairPsbtException"; + } +} + +class CombineInconsistentKeySourcesPsbtException extends PsbtException { + final String xpub; + CombineInconsistentKeySourcesPsbtException( + String this.xpub, + ); + CombineInconsistentKeySourcesPsbtException._( + String this.xpub, + ); + static LiftRetVal read( + Uint8List buf) { + int new_offset = buf.offsetInBytes; + final xpub_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final xpub = xpub_lifted.value; + new_offset += xpub_lifted.bytesRead; + return LiftRetVal( + CombineInconsistentKeySourcesPsbtException._( + xpub, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(xpub) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 16); + int new_offset = buf.offsetInBytes + 4; + new_offset += + FfiConverterString.write(xpub, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "CombineInconsistentKeySourcesPsbtException($xpub)"; + } +} + +class ConsensusEncodingPsbtException extends PsbtException { + final String encodingError; + ConsensusEncodingPsbtException( + String this.encodingError, + ); + ConsensusEncodingPsbtException._( + String this.encodingError, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final encodingError_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final encodingError = encodingError_lifted.value; + new_offset += encodingError_lifted.bytesRead; + return LiftRetVal( + ConsensusEncodingPsbtException._( + encodingError, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(encodingError) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 17); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterString.write( + encodingError, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "ConsensusEncodingPsbtException($encodingError)"; + } +} + +class NegativeFeePsbtException extends PsbtException { + NegativeFeePsbtException(); + NegativeFeePsbtException._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(NegativeFeePsbtException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 18); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "NegativeFeePsbtException"; + } +} + +class FeeOverflowPsbtException extends PsbtException { + FeeOverflowPsbtException(); + FeeOverflowPsbtException._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(FeeOverflowPsbtException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 19); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "FeeOverflowPsbtException"; + } +} + +class InvalidPublicKeyPsbtException extends PsbtException { + final String errorMessage; + InvalidPublicKeyPsbtException( + String this.errorMessage, + ); + InvalidPublicKeyPsbtException._( + String this.errorMessage, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final errorMessage_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final errorMessage = errorMessage_lifted.value; + new_offset += errorMessage_lifted.bytesRead; + return LiftRetVal( + InvalidPublicKeyPsbtException._( + errorMessage, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(errorMessage) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 20); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterString.write( + errorMessage, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "InvalidPublicKeyPsbtException($errorMessage)"; + } +} + +class InvalidSecp256k1PublicKeyPsbtException extends PsbtException { + final String secp256k1Error; + InvalidSecp256k1PublicKeyPsbtException( + String this.secp256k1Error, + ); + InvalidSecp256k1PublicKeyPsbtException._( + String this.secp256k1Error, + ); + static LiftRetVal read( + Uint8List buf) { + int new_offset = buf.offsetInBytes; + final secp256k1Error_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final secp256k1Error = secp256k1Error_lifted.value; + new_offset += secp256k1Error_lifted.bytesRead; + return LiftRetVal( + InvalidSecp256k1PublicKeyPsbtException._( + secp256k1Error, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(secp256k1Error) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 21); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterString.write( + secp256k1Error, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "InvalidSecp256k1PublicKeyPsbtException($secp256k1Error)"; + } +} + +class InvalidXOnlyPublicKeyPsbtException extends PsbtException { + InvalidXOnlyPublicKeyPsbtException(); + InvalidXOnlyPublicKeyPsbtException._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(InvalidXOnlyPublicKeyPsbtException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 22); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "InvalidXOnlyPublicKeyPsbtException"; + } +} + +class InvalidEcdsaSignaturePsbtException extends PsbtException { + final String errorMessage; + InvalidEcdsaSignaturePsbtException( + String this.errorMessage, + ); + InvalidEcdsaSignaturePsbtException._( + String this.errorMessage, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final errorMessage_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final errorMessage = errorMessage_lifted.value; + new_offset += errorMessage_lifted.bytesRead; + return LiftRetVal( + InvalidEcdsaSignaturePsbtException._( + errorMessage, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(errorMessage) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 23); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterString.write( + errorMessage, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "InvalidEcdsaSignaturePsbtException($errorMessage)"; + } +} + +class InvalidTaprootSignaturePsbtException extends PsbtException { + final String errorMessage; + InvalidTaprootSignaturePsbtException( + String this.errorMessage, + ); + InvalidTaprootSignaturePsbtException._( + String this.errorMessage, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final errorMessage_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final errorMessage = errorMessage_lifted.value; + new_offset += errorMessage_lifted.bytesRead; + return LiftRetVal( + InvalidTaprootSignaturePsbtException._( + errorMessage, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(errorMessage) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 24); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterString.write( + errorMessage, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "InvalidTaprootSignaturePsbtException($errorMessage)"; + } +} + +class InvalidControlBlockPsbtException extends PsbtException { + InvalidControlBlockPsbtException(); + InvalidControlBlockPsbtException._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(InvalidControlBlockPsbtException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 25); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "InvalidControlBlockPsbtException"; + } +} + +class InvalidLeafVersionPsbtException extends PsbtException { + InvalidLeafVersionPsbtException(); + InvalidLeafVersionPsbtException._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(InvalidLeafVersionPsbtException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 26); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "InvalidLeafVersionPsbtException"; + } +} + +class TaprootPsbtException extends PsbtException { + TaprootPsbtException(); + TaprootPsbtException._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(TaprootPsbtException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 27); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "TaprootPsbtException"; + } +} + +class TapTreePsbtException extends PsbtException { + final String errorMessage; + TapTreePsbtException( + String this.errorMessage, + ); + TapTreePsbtException._( + String this.errorMessage, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final errorMessage_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final errorMessage = errorMessage_lifted.value; + new_offset += errorMessage_lifted.bytesRead; + return LiftRetVal( + TapTreePsbtException._( + errorMessage, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(errorMessage) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 28); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterString.write( + errorMessage, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "TapTreePsbtException($errorMessage)"; + } +} + +class XPubKeyPsbtException extends PsbtException { + XPubKeyPsbtException(); + XPubKeyPsbtException._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(XPubKeyPsbtException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 29); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "XPubKeyPsbtException"; + } +} + +class VersionPsbtException extends PsbtException { + final String errorMessage; + VersionPsbtException( + String this.errorMessage, + ); + VersionPsbtException._( + String this.errorMessage, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final errorMessage_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final errorMessage = errorMessage_lifted.value; + new_offset += errorMessage_lifted.bytesRead; + return LiftRetVal( + VersionPsbtException._( + errorMessage, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(errorMessage) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 30); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterString.write( + errorMessage, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "VersionPsbtException($errorMessage)"; + } +} + +class PartialDataConsumptionPsbtException extends PsbtException { + PartialDataConsumptionPsbtException(); + PartialDataConsumptionPsbtException._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(PartialDataConsumptionPsbtException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 31); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "PartialDataConsumptionPsbtException"; + } +} + +class IoPsbtException extends PsbtException { + final String errorMessage; + IoPsbtException( + String this.errorMessage, + ); + IoPsbtException._( + String this.errorMessage, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final errorMessage_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final errorMessage = errorMessage_lifted.value; + new_offset += errorMessage_lifted.bytesRead; + return LiftRetVal( + IoPsbtException._( + errorMessage, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(errorMessage) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 32); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterString.write( + errorMessage, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "IoPsbtException($errorMessage)"; + } +} + +class OtherPsbtErrPsbtException extends PsbtException { + OtherPsbtErrPsbtException(); + OtherPsbtErrPsbtException._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(OtherPsbtErrPsbtException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 33); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "OtherPsbtErrPsbtException"; + } +} + +class PsbtExceptionErrorHandler extends UniffiRustCallStatusErrorHandler { + @override + Exception lift(RustBuffer errorBuf) { + return FfiConverterPsbtException.lift(errorBuf); + } +} + +final PsbtExceptionErrorHandler psbtExceptionErrorHandler = + PsbtExceptionErrorHandler(); + +abstract class PsbtFinalizeException implements Exception { + RustBuffer lower(); + int allocationSize(); + int write(Uint8List buf); +} + +class FfiConverterPsbtFinalizeException { + static PsbtFinalizeException lift(RustBuffer buffer) { + return FfiConverterPsbtFinalizeException.read(buffer.asUint8List()).value; + } + + static LiftRetVal read(Uint8List buf) { + final index = buf.buffer.asByteData(buf.offsetInBytes).getInt32(0); + final subview = Uint8List.view(buf.buffer, buf.offsetInBytes + 4); + switch (index) { + case 1: + return InputExceptionPsbtFinalizeException.read(subview); + case 2: + return WrongInputCountPsbtFinalizeException.read(subview); + case 3: + return InputIdxOutofBoundsPsbtFinalizeException.read(subview); + default: + throw UniffiInternalError(UniffiInternalError.unexpectedEnumCase, + "Unable to determine enum variant"); + } + } + + static RustBuffer lower(PsbtFinalizeException value) { + return value.lower(); + } + + static int allocationSize(PsbtFinalizeException value) { + return value.allocationSize(); + } + + static int write(PsbtFinalizeException value, Uint8List buf) { + return value.write(buf); + } +} + +class InputExceptionPsbtFinalizeException extends PsbtFinalizeException { + final String reason; + final int index; + InputExceptionPsbtFinalizeException({ + required String this.reason, + required int this.index, + }); + InputExceptionPsbtFinalizeException._( + String this.reason, + int this.index, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final reason_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final reason = reason_lifted.value; + new_offset += reason_lifted.bytesRead; + final index_lifted = + FfiConverterUInt32.read(Uint8List.view(buf.buffer, new_offset)); + final index = index_lifted.value; + new_offset += index_lifted.bytesRead; + return LiftRetVal( + InputExceptionPsbtFinalizeException._( + reason, + index, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(reason) + + FfiConverterUInt32.allocationSize(index) + + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 1); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterString.write( + reason, Uint8List.view(buf.buffer, new_offset)); + new_offset += + FfiConverterUInt32.write(index, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "InputExceptionPsbtFinalizeException($reason, $index)"; + } +} + +class WrongInputCountPsbtFinalizeException extends PsbtFinalizeException { + final int inTx; + final int inMap; + WrongInputCountPsbtFinalizeException({ + required int this.inTx, + required int this.inMap, + }); + WrongInputCountPsbtFinalizeException._( + int this.inTx, + int this.inMap, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final inTx_lifted = + FfiConverterUInt32.read(Uint8List.view(buf.buffer, new_offset)); + final inTx = inTx_lifted.value; + new_offset += inTx_lifted.bytesRead; + final inMap_lifted = + FfiConverterUInt32.read(Uint8List.view(buf.buffer, new_offset)); + final inMap = inMap_lifted.value; + new_offset += inMap_lifted.bytesRead; + return LiftRetVal( + WrongInputCountPsbtFinalizeException._( + inTx, + inMap, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterUInt32.allocationSize(inTx) + + FfiConverterUInt32.allocationSize(inMap) + + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 2); + int new_offset = buf.offsetInBytes + 4; + new_offset += + FfiConverterUInt32.write(inTx, Uint8List.view(buf.buffer, new_offset)); + new_offset += + FfiConverterUInt32.write(inMap, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "WrongInputCountPsbtFinalizeException($inTx, $inMap)"; + } +} + +class InputIdxOutofBoundsPsbtFinalizeException extends PsbtFinalizeException { + final int psbtInp; + final int requested; + InputIdxOutofBoundsPsbtFinalizeException({ + required int this.psbtInp, + required int this.requested, + }); + InputIdxOutofBoundsPsbtFinalizeException._( + int this.psbtInp, + int this.requested, + ); + static LiftRetVal read( + Uint8List buf) { + int new_offset = buf.offsetInBytes; + final psbtInp_lifted = + FfiConverterUInt32.read(Uint8List.view(buf.buffer, new_offset)); + final psbtInp = psbtInp_lifted.value; + new_offset += psbtInp_lifted.bytesRead; + final requested_lifted = + FfiConverterUInt32.read(Uint8List.view(buf.buffer, new_offset)); + final requested = requested_lifted.value; + new_offset += requested_lifted.bytesRead; + return LiftRetVal( + InputIdxOutofBoundsPsbtFinalizeException._( + psbtInp, + requested, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterUInt32.allocationSize(psbtInp) + + FfiConverterUInt32.allocationSize(requested) + + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 3); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterUInt32.write( + psbtInp, Uint8List.view(buf.buffer, new_offset)); + new_offset += FfiConverterUInt32.write( + requested, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "InputIdxOutofBoundsPsbtFinalizeException($psbtInp, $requested)"; + } +} + +class PsbtFinalizeExceptionErrorHandler + extends UniffiRustCallStatusErrorHandler { + @override + Exception lift(RustBuffer errorBuf) { + return FfiConverterPsbtFinalizeException.lift(errorBuf); + } +} + +final PsbtFinalizeExceptionErrorHandler psbtFinalizeExceptionErrorHandler = + PsbtFinalizeExceptionErrorHandler(); + +abstract class PsbtParseException implements Exception { + RustBuffer lower(); + int allocationSize(); + int write(Uint8List buf); +} + +class FfiConverterPsbtParseException { + static PsbtParseException lift(RustBuffer buffer) { + return FfiConverterPsbtParseException.read(buffer.asUint8List()).value; + } + + static LiftRetVal read(Uint8List buf) { + final index = buf.buffer.asByteData(buf.offsetInBytes).getInt32(0); + final subview = Uint8List.view(buf.buffer, buf.offsetInBytes + 4); + switch (index) { + case 1: + return PsbtEncodingPsbtParseException.read(subview); + case 2: + return Base64EncodingPsbtParseException.read(subview); + default: + throw UniffiInternalError(UniffiInternalError.unexpectedEnumCase, + "Unable to determine enum variant"); + } + } + + static RustBuffer lower(PsbtParseException value) { + return value.lower(); + } + + static int allocationSize(PsbtParseException value) { + return value.allocationSize(); + } + + static int write(PsbtParseException value, Uint8List buf) { + return value.write(buf); + } +} + +class PsbtEncodingPsbtParseException extends PsbtParseException { + final String errorMessage; + PsbtEncodingPsbtParseException( + String this.errorMessage, + ); + PsbtEncodingPsbtParseException._( + String this.errorMessage, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final errorMessage_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final errorMessage = errorMessage_lifted.value; + new_offset += errorMessage_lifted.bytesRead; + return LiftRetVal( + PsbtEncodingPsbtParseException._( + errorMessage, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(errorMessage) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 1); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterString.write( + errorMessage, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "PsbtEncodingPsbtParseException($errorMessage)"; + } +} + +class Base64EncodingPsbtParseException extends PsbtParseException { + final String errorMessage; + Base64EncodingPsbtParseException( + String this.errorMessage, + ); + Base64EncodingPsbtParseException._( + String this.errorMessage, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final errorMessage_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final errorMessage = errorMessage_lifted.value; + new_offset += errorMessage_lifted.bytesRead; + return LiftRetVal( + Base64EncodingPsbtParseException._( + errorMessage, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(errorMessage) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 2); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterString.write( + errorMessage, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "Base64EncodingPsbtParseException($errorMessage)"; + } +} + +class PsbtParseExceptionErrorHandler extends UniffiRustCallStatusErrorHandler { + @override + Exception lift(RustBuffer errorBuf) { + return FfiConverterPsbtParseException.lift(errorBuf); + } +} + +final PsbtParseExceptionErrorHandler psbtParseExceptionErrorHandler = + PsbtParseExceptionErrorHandler(); + +abstract class RequestBuilderException implements Exception { + RustBuffer lower(); + int allocationSize(); + int write(Uint8List buf); +} + +class FfiConverterRequestBuilderException { + static RequestBuilderException lift(RustBuffer buffer) { + return FfiConverterRequestBuilderException.read(buffer.asUint8List()).value; + } + + static LiftRetVal read(Uint8List buf) { + final index = buf.buffer.asByteData(buf.offsetInBytes).getInt32(0); + final subview = Uint8List.view(buf.buffer, buf.offsetInBytes + 4); + switch (index) { + case 1: + return RequestAlreadyConsumedRequestBuilderException.read(subview); + default: + throw UniffiInternalError(UniffiInternalError.unexpectedEnumCase, + "Unable to determine enum variant"); + } + } + + static RustBuffer lower(RequestBuilderException value) { + return value.lower(); + } + + static int allocationSize(RequestBuilderException value) { + return value.allocationSize(); + } + + static int write(RequestBuilderException value, Uint8List buf) { + return value.write(buf); + } +} + +class RequestAlreadyConsumedRequestBuilderException + extends RequestBuilderException { + RequestAlreadyConsumedRequestBuilderException(); + RequestAlreadyConsumedRequestBuilderException._(); + static LiftRetVal read( + Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal( + RequestAlreadyConsumedRequestBuilderException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 1); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "RequestAlreadyConsumedRequestBuilderException"; + } +} + +class RequestBuilderExceptionErrorHandler + extends UniffiRustCallStatusErrorHandler { + @override + Exception lift(RustBuffer errorBuf) { + return FfiConverterRequestBuilderException.lift(errorBuf); + } +} + +final RequestBuilderExceptionErrorHandler requestBuilderExceptionErrorHandler = + RequestBuilderExceptionErrorHandler(); + +abstract class Satisfaction { + RustBuffer lower(); + int allocationSize(); + int write(Uint8List buf); +} + +class FfiConverterSatisfaction { + static Satisfaction lift(RustBuffer buffer) { + return FfiConverterSatisfaction.read(buffer.asUint8List()).value; + } + + static LiftRetVal read(Uint8List buf) { + final index = buf.buffer.asByteData(buf.offsetInBytes).getInt32(0); + final subview = Uint8List.view(buf.buffer, buf.offsetInBytes + 4); + switch (index) { + case 1: + return PartialSatisfaction.read(subview); + case 2: + return PartialCompleteSatisfaction.read(subview); + case 3: + return CompleteSatisfaction.read(subview); + case 4: + return NoneSatisfaction.read(subview); + default: + throw UniffiInternalError(UniffiInternalError.unexpectedEnumCase, + "Unable to determine enum variant"); + } + } + + static RustBuffer lower(Satisfaction value) { + return value.lower(); + } + + static int allocationSize(Satisfaction value) { + return value.allocationSize(); + } + + static int write(Satisfaction value, Uint8List buf) { + return value.write(buf); + } +} + +class PartialSatisfaction extends Satisfaction { + final int n; + final int m; + final List items; + final bool? sorted; + final Map> conditions; + PartialSatisfaction({ + required int this.n, + required int this.m, + required List this.items, + required bool? this.sorted, + required Map> this.conditions, + }); + PartialSatisfaction._( + int this.n, + int this.m, + List this.items, + bool? this.sorted, + Map> this.conditions, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final n_lifted = + FfiConverterUInt64.read(Uint8List.view(buf.buffer, new_offset)); + final n = n_lifted.value; + new_offset += n_lifted.bytesRead; + final m_lifted = + FfiConverterUInt64.read(Uint8List.view(buf.buffer, new_offset)); + final m = m_lifted.value; + new_offset += m_lifted.bytesRead; + final items_lifted = + FfiConverterSequenceUInt64.read(Uint8List.view(buf.buffer, new_offset)); + final items = items_lifted.value; + new_offset += items_lifted.bytesRead; + final sorted_lifted = + FfiConverterOptionalBool.read(Uint8List.view(buf.buffer, new_offset)); + final sorted = sorted_lifted.value; + new_offset += sorted_lifted.bytesRead; + final conditions_lifted = FfiConverterMapUInt32ToSequenceCondition.read( + Uint8List.view(buf.buffer, new_offset)); + final conditions = conditions_lifted.value; + new_offset += conditions_lifted.bytesRead; + return LiftRetVal( + PartialSatisfaction._( + n, + m, + items, + sorted, + conditions, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterUInt64.allocationSize(n) + + FfiConverterUInt64.allocationSize(m) + + FfiConverterSequenceUInt64.allocationSize(items) + + FfiConverterOptionalBool.allocationSize(sorted) + + FfiConverterMapUInt32ToSequenceCondition.allocationSize(conditions) + + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 1); + int new_offset = buf.offsetInBytes + 4; + new_offset += + FfiConverterUInt64.write(n, Uint8List.view(buf.buffer, new_offset)); + new_offset += + FfiConverterUInt64.write(m, Uint8List.view(buf.buffer, new_offset)); + new_offset += FfiConverterSequenceUInt64.write( + items, Uint8List.view(buf.buffer, new_offset)); + new_offset += FfiConverterOptionalBool.write( + sorted, Uint8List.view(buf.buffer, new_offset)); + new_offset += FfiConverterMapUInt32ToSequenceCondition.write( + conditions, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } +} + +class PartialCompleteSatisfaction extends Satisfaction { + final int n; + final int m; + final List items; + final bool? sorted; + final Map, List> conditions; + PartialCompleteSatisfaction({ + required int this.n, + required int this.m, + required List this.items, + required bool? this.sorted, + required Map, List> this.conditions, + }); + PartialCompleteSatisfaction._( + int this.n, + int this.m, + List this.items, + bool? this.sorted, + Map, List> this.conditions, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final n_lifted = + FfiConverterUInt64.read(Uint8List.view(buf.buffer, new_offset)); + final n = n_lifted.value; + new_offset += n_lifted.bytesRead; + final m_lifted = + FfiConverterUInt64.read(Uint8List.view(buf.buffer, new_offset)); + final m = m_lifted.value; + new_offset += m_lifted.bytesRead; + final items_lifted = + FfiConverterSequenceUInt64.read(Uint8List.view(buf.buffer, new_offset)); + final items = items_lifted.value; + new_offset += items_lifted.bytesRead; + final sorted_lifted = + FfiConverterOptionalBool.read(Uint8List.view(buf.buffer, new_offset)); + final sorted = sorted_lifted.value; + new_offset += sorted_lifted.bytesRead; + final conditions_lifted = + FfiConverterMapSequenceUInt32ToSequenceCondition.read( + Uint8List.view(buf.buffer, new_offset)); + final conditions = conditions_lifted.value; + new_offset += conditions_lifted.bytesRead; + return LiftRetVal( + PartialCompleteSatisfaction._( + n, + m, + items, + sorted, + conditions, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterUInt64.allocationSize(n) + + FfiConverterUInt64.allocationSize(m) + + FfiConverterSequenceUInt64.allocationSize(items) + + FfiConverterOptionalBool.allocationSize(sorted) + + FfiConverterMapSequenceUInt32ToSequenceCondition.allocationSize( + conditions) + + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 2); + int new_offset = buf.offsetInBytes + 4; + new_offset += + FfiConverterUInt64.write(n, Uint8List.view(buf.buffer, new_offset)); + new_offset += + FfiConverterUInt64.write(m, Uint8List.view(buf.buffer, new_offset)); + new_offset += FfiConverterSequenceUInt64.write( + items, Uint8List.view(buf.buffer, new_offset)); + new_offset += FfiConverterOptionalBool.write( + sorted, Uint8List.view(buf.buffer, new_offset)); + new_offset += FfiConverterMapSequenceUInt32ToSequenceCondition.write( + conditions, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } +} + +class CompleteSatisfaction extends Satisfaction { + final Condition condition; + CompleteSatisfaction( + Condition this.condition, + ); + CompleteSatisfaction._( + Condition this.condition, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final condition_lifted = + FfiConverterCondition.read(Uint8List.view(buf.buffer, new_offset)); + final condition = condition_lifted.value; + new_offset += condition_lifted.bytesRead; + return LiftRetVal( + CompleteSatisfaction._( + condition, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterCondition.allocationSize(condition) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 3); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterCondition.write( + condition, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } +} + +class NoneSatisfaction extends Satisfaction { + final String msg; + NoneSatisfaction( + String this.msg, + ); + NoneSatisfaction._( + String this.msg, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final msg_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final msg = msg_lifted.value; + new_offset += msg_lifted.bytesRead; + return LiftRetVal( + NoneSatisfaction._( + msg, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(msg) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 4); + int new_offset = buf.offsetInBytes + 4; + new_offset += + FfiConverterString.write(msg, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } +} + +abstract class SatisfiableItem { + RustBuffer lower(); + int allocationSize(); + int write(Uint8List buf); +} + +class FfiConverterSatisfiableItem { + static SatisfiableItem lift(RustBuffer buffer) { + return FfiConverterSatisfiableItem.read(buffer.asUint8List()).value; + } + + static LiftRetVal read(Uint8List buf) { + final index = buf.buffer.asByteData(buf.offsetInBytes).getInt32(0); + final subview = Uint8List.view(buf.buffer, buf.offsetInBytes + 4); + switch (index) { + case 1: + return EcdsaSignatureSatisfiableItem.read(subview); + case 2: + return SchnorrSignatureSatisfiableItem.read(subview); + case 3: + return Sha256PreimageSatisfiableItem.read(subview); + case 4: + return Hash256PreimageSatisfiableItem.read(subview); + case 5: + return Ripemd160PreimageSatisfiableItem.read(subview); + case 6: + return Hash160PreimageSatisfiableItem.read(subview); + case 7: + return AbsoluteTimelockSatisfiableItem.read(subview); + case 8: + return RelativeTimelockSatisfiableItem.read(subview); + case 9: + return MultisigSatisfiableItem.read(subview); + case 10: + return ThreshSatisfiableItem.read(subview); + default: + throw UniffiInternalError(UniffiInternalError.unexpectedEnumCase, + "Unable to determine enum variant"); + } + } + + static RustBuffer lower(SatisfiableItem value) { + return value.lower(); + } + + static int allocationSize(SatisfiableItem value) { + return value.allocationSize(); + } + + static int write(SatisfiableItem value, Uint8List buf) { + return value.write(buf); + } +} + +class EcdsaSignatureSatisfiableItem extends SatisfiableItem { + final PkOrF key; + EcdsaSignatureSatisfiableItem( + PkOrF this.key, + ); + EcdsaSignatureSatisfiableItem._( + PkOrF this.key, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final key_lifted = + FfiConverterPkOrF.read(Uint8List.view(buf.buffer, new_offset)); + final key = key_lifted.value; + new_offset += key_lifted.bytesRead; + return LiftRetVal( + EcdsaSignatureSatisfiableItem._( + key, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterPkOrF.allocationSize(key) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 1); + int new_offset = buf.offsetInBytes + 4; + new_offset += + FfiConverterPkOrF.write(key, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } +} + +class SchnorrSignatureSatisfiableItem extends SatisfiableItem { + final PkOrF key; + SchnorrSignatureSatisfiableItem( + PkOrF this.key, + ); + SchnorrSignatureSatisfiableItem._( + PkOrF this.key, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final key_lifted = + FfiConverterPkOrF.read(Uint8List.view(buf.buffer, new_offset)); + final key = key_lifted.value; + new_offset += key_lifted.bytesRead; + return LiftRetVal( + SchnorrSignatureSatisfiableItem._( + key, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterPkOrF.allocationSize(key) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 2); + int new_offset = buf.offsetInBytes + 4; + new_offset += + FfiConverterPkOrF.write(key, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } +} + +class Sha256PreimageSatisfiableItem extends SatisfiableItem { + final String hash; + Sha256PreimageSatisfiableItem( + String this.hash, + ); + Sha256PreimageSatisfiableItem._( + String this.hash, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final hash_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final hash = hash_lifted.value; + new_offset += hash_lifted.bytesRead; + return LiftRetVal( + Sha256PreimageSatisfiableItem._( + hash, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(hash) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 3); + int new_offset = buf.offsetInBytes + 4; + new_offset += + FfiConverterString.write(hash, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } +} + +class Hash256PreimageSatisfiableItem extends SatisfiableItem { + final String hash; + Hash256PreimageSatisfiableItem( + String this.hash, + ); + Hash256PreimageSatisfiableItem._( + String this.hash, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final hash_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final hash = hash_lifted.value; + new_offset += hash_lifted.bytesRead; + return LiftRetVal( + Hash256PreimageSatisfiableItem._( + hash, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(hash) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 4); + int new_offset = buf.offsetInBytes + 4; + new_offset += + FfiConverterString.write(hash, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } +} + +class Ripemd160PreimageSatisfiableItem extends SatisfiableItem { + final String hash; + Ripemd160PreimageSatisfiableItem( + String this.hash, + ); + Ripemd160PreimageSatisfiableItem._( + String this.hash, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final hash_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final hash = hash_lifted.value; + new_offset += hash_lifted.bytesRead; + return LiftRetVal( + Ripemd160PreimageSatisfiableItem._( + hash, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(hash) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 5); + int new_offset = buf.offsetInBytes + 4; + new_offset += + FfiConverterString.write(hash, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } +} + +class Hash160PreimageSatisfiableItem extends SatisfiableItem { + final String hash; + Hash160PreimageSatisfiableItem( + String this.hash, + ); + Hash160PreimageSatisfiableItem._( + String this.hash, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final hash_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final hash = hash_lifted.value; + new_offset += hash_lifted.bytesRead; + return LiftRetVal( + Hash160PreimageSatisfiableItem._( + hash, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(hash) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 6); + int new_offset = buf.offsetInBytes + 4; + new_offset += + FfiConverterString.write(hash, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } +} + +class AbsoluteTimelockSatisfiableItem extends SatisfiableItem { + final LockTime value; + AbsoluteTimelockSatisfiableItem( + LockTime this.value, + ); + AbsoluteTimelockSatisfiableItem._( + LockTime this.value, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final value_lifted = + FfiConverterLockTime.read(Uint8List.view(buf.buffer, new_offset)); + final value = value_lifted.value; + new_offset += value_lifted.bytesRead; + return LiftRetVal( + AbsoluteTimelockSatisfiableItem._( + value, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterLockTime.allocationSize(value) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 7); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterLockTime.write( + value, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } +} + +class RelativeTimelockSatisfiableItem extends SatisfiableItem { + final int value; + RelativeTimelockSatisfiableItem( + int this.value, + ); + RelativeTimelockSatisfiableItem._( + int this.value, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final value_lifted = + FfiConverterUInt32.read(Uint8List.view(buf.buffer, new_offset)); + final value = value_lifted.value; + new_offset += value_lifted.bytesRead; + return LiftRetVal( + RelativeTimelockSatisfiableItem._( + value, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterUInt32.allocationSize(value) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 8); + int new_offset = buf.offsetInBytes + 4; + new_offset += + FfiConverterUInt32.write(value, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } +} + +class MultisigSatisfiableItem extends SatisfiableItem { + final List keys; + final int threshold; + MultisigSatisfiableItem({ + required List this.keys, + required int this.threshold, + }); + MultisigSatisfiableItem._( + List this.keys, + int this.threshold, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final keys_lifted = + FfiConverterSequencePkOrF.read(Uint8List.view(buf.buffer, new_offset)); + final keys = keys_lifted.value; + new_offset += keys_lifted.bytesRead; + final threshold_lifted = + FfiConverterUInt64.read(Uint8List.view(buf.buffer, new_offset)); + final threshold = threshold_lifted.value; + new_offset += threshold_lifted.bytesRead; + return LiftRetVal( + MultisigSatisfiableItem._( + keys, + threshold, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterSequencePkOrF.allocationSize(keys) + + FfiConverterUInt64.allocationSize(threshold) + + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 9); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterSequencePkOrF.write( + keys, Uint8List.view(buf.buffer, new_offset)); + new_offset += FfiConverterUInt64.write( + threshold, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } +} + +class ThreshSatisfiableItem extends SatisfiableItem { + final List items; + final int threshold; + ThreshSatisfiableItem({ + required List this.items, + required int this.threshold, + }); + ThreshSatisfiableItem._( + List this.items, + int this.threshold, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final items_lifted = + FfiConverterSequencePolicy.read(Uint8List.view(buf.buffer, new_offset)); + final items = items_lifted.value; + new_offset += items_lifted.bytesRead; + final threshold_lifted = + FfiConverterUInt64.read(Uint8List.view(buf.buffer, new_offset)); + final threshold = threshold_lifted.value; + new_offset += threshold_lifted.bytesRead; + return LiftRetVal( + ThreshSatisfiableItem._( + items, + threshold, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterSequencePolicy.allocationSize(items) + + FfiConverterUInt64.allocationSize(threshold) + + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 10); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterSequencePolicy.write( + items, Uint8List.view(buf.buffer, new_offset)); + new_offset += FfiConverterUInt64.write( + threshold, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } +} + +abstract class ScanType { + RustBuffer lower(); + int allocationSize(); + int write(Uint8List buf); +} + +class FfiConverterScanType { + static ScanType lift(RustBuffer buffer) { + return FfiConverterScanType.read(buffer.asUint8List()).value; + } + + static LiftRetVal read(Uint8List buf) { + final index = buf.buffer.asByteData(buf.offsetInBytes).getInt32(0); + final subview = Uint8List.view(buf.buffer, buf.offsetInBytes + 4); + switch (index) { + case 1: + return NewScanType.read(subview); + case 2: + return SyncScanType.read(subview); + case 3: + return RecoveryScanType.read(subview); + default: + throw UniffiInternalError(UniffiInternalError.unexpectedEnumCase, + "Unable to determine enum variant"); + } + } + + static RustBuffer lower(ScanType value) { + return value.lower(); + } + + static int allocationSize(ScanType value) { + return value.allocationSize(); + } + + static int write(ScanType value, Uint8List buf) { + return value.write(buf); + } +} + +class NewScanType extends ScanType { + NewScanType(); + NewScanType._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(NewScanType._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 1); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } +} + +class SyncScanType extends ScanType { + SyncScanType(); + SyncScanType._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(SyncScanType._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 2); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } +} + +class RecoveryScanType extends ScanType { + final int fromHeight; + RecoveryScanType( + int this.fromHeight, + ); + RecoveryScanType._( + int this.fromHeight, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final fromHeight_lifted = + FfiConverterUInt32.read(Uint8List.view(buf.buffer, new_offset)); + final fromHeight = fromHeight_lifted.value; + new_offset += fromHeight_lifted.bytesRead; + return LiftRetVal( + RecoveryScanType._( + fromHeight, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterUInt32.allocationSize(fromHeight) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 3); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterUInt32.write( + fromHeight, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } +} + +abstract class SignerException implements Exception { + RustBuffer lower(); + int allocationSize(); + int write(Uint8List buf); +} + +class FfiConverterSignerException { + static SignerException lift(RustBuffer buffer) { + return FfiConverterSignerException.read(buffer.asUint8List()).value; + } + + static LiftRetVal read(Uint8List buf) { + final index = buf.buffer.asByteData(buf.offsetInBytes).getInt32(0); + final subview = Uint8List.view(buf.buffer, buf.offsetInBytes + 4); + switch (index) { + case 1: + return MissingKeySignerException.read(subview); + case 2: + return InvalidKeySignerException.read(subview); + case 3: + return UserCanceledSignerException.read(subview); + case 4: + return InputIndexOutOfRangeSignerException.read(subview); + case 5: + return MissingNonWitnessUtxoSignerException.read(subview); + case 6: + return InvalidNonWitnessUtxoSignerException.read(subview); + case 7: + return MissingWitnessUtxoSignerException.read(subview); + case 8: + return MissingWitnessScriptSignerException.read(subview); + case 9: + return MissingHdKeypathSignerException.read(subview); + case 10: + return NonStandardSighashSignerException.read(subview); + case 11: + return InvalidSighashSignerException.read(subview); + case 12: + return SighashP2wpkhSignerException.read(subview); + case 13: + return SighashTaprootSignerException.read(subview); + case 14: + return TxInputsIndexExceptionSignerException.read(subview); + case 15: + return MiniscriptPsbtSignerException.read(subview); + case 16: + return ExternalSignerException.read(subview); + case 17: + return PsbtSignerException.read(subview); + default: + throw UniffiInternalError(UniffiInternalError.unexpectedEnumCase, + "Unable to determine enum variant"); + } + } + + static RustBuffer lower(SignerException value) { + return value.lower(); + } + + static int allocationSize(SignerException value) { + return value.allocationSize(); + } + + static int write(SignerException value, Uint8List buf) { + return value.write(buf); + } +} + +class MissingKeySignerException extends SignerException { + MissingKeySignerException(); + MissingKeySignerException._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(MissingKeySignerException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 1); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "MissingKeySignerException"; + } +} + +class InvalidKeySignerException extends SignerException { + InvalidKeySignerException(); + InvalidKeySignerException._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(InvalidKeySignerException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 2); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "InvalidKeySignerException"; + } +} + +class UserCanceledSignerException extends SignerException { + UserCanceledSignerException(); + UserCanceledSignerException._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(UserCanceledSignerException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 3); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "UserCanceledSignerException"; + } +} + +class InputIndexOutOfRangeSignerException extends SignerException { + InputIndexOutOfRangeSignerException(); + InputIndexOutOfRangeSignerException._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(InputIndexOutOfRangeSignerException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 4); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "InputIndexOutOfRangeSignerException"; + } +} + +class MissingNonWitnessUtxoSignerException extends SignerException { + MissingNonWitnessUtxoSignerException(); + MissingNonWitnessUtxoSignerException._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(MissingNonWitnessUtxoSignerException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 5); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "MissingNonWitnessUtxoSignerException"; + } +} + +class InvalidNonWitnessUtxoSignerException extends SignerException { + InvalidNonWitnessUtxoSignerException(); + InvalidNonWitnessUtxoSignerException._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(InvalidNonWitnessUtxoSignerException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 6); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "InvalidNonWitnessUtxoSignerException"; + } +} + +class MissingWitnessUtxoSignerException extends SignerException { + MissingWitnessUtxoSignerException(); + MissingWitnessUtxoSignerException._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(MissingWitnessUtxoSignerException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 7); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "MissingWitnessUtxoSignerException"; + } +} + +class MissingWitnessScriptSignerException extends SignerException { + MissingWitnessScriptSignerException(); + MissingWitnessScriptSignerException._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(MissingWitnessScriptSignerException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 8); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "MissingWitnessScriptSignerException"; + } +} + +class MissingHdKeypathSignerException extends SignerException { + MissingHdKeypathSignerException(); + MissingHdKeypathSignerException._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(MissingHdKeypathSignerException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 9); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "MissingHdKeypathSignerException"; + } +} + +class NonStandardSighashSignerException extends SignerException { + NonStandardSighashSignerException(); + NonStandardSighashSignerException._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(NonStandardSighashSignerException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 10); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "NonStandardSighashSignerException"; + } +} + +class InvalidSighashSignerException extends SignerException { + InvalidSighashSignerException(); + InvalidSighashSignerException._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(InvalidSighashSignerException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 11); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "InvalidSighashSignerException"; + } +} + +class SighashP2wpkhSignerException extends SignerException { + final String errorMessage; + SighashP2wpkhSignerException( + String this.errorMessage, + ); + SighashP2wpkhSignerException._( + String this.errorMessage, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final errorMessage_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final errorMessage = errorMessage_lifted.value; + new_offset += errorMessage_lifted.bytesRead; + return LiftRetVal( + SighashP2wpkhSignerException._( + errorMessage, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(errorMessage) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 12); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterString.write( + errorMessage, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "SighashP2wpkhSignerException($errorMessage)"; + } +} + +class SighashTaprootSignerException extends SignerException { + final String errorMessage; + SighashTaprootSignerException( + String this.errorMessage, + ); + SighashTaprootSignerException._( + String this.errorMessage, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final errorMessage_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final errorMessage = errorMessage_lifted.value; + new_offset += errorMessage_lifted.bytesRead; + return LiftRetVal( + SighashTaprootSignerException._( + errorMessage, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(errorMessage) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 13); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterString.write( + errorMessage, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "SighashTaprootSignerException($errorMessage)"; + } +} + +class TxInputsIndexExceptionSignerException extends SignerException { + final String errorMessage; + TxInputsIndexExceptionSignerException( + String this.errorMessage, + ); + TxInputsIndexExceptionSignerException._( + String this.errorMessage, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final errorMessage_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final errorMessage = errorMessage_lifted.value; + new_offset += errorMessage_lifted.bytesRead; + return LiftRetVal( + TxInputsIndexExceptionSignerException._( + errorMessage, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(errorMessage) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 14); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterString.write( + errorMessage, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "TxInputsIndexExceptionSignerException($errorMessage)"; + } +} + +class MiniscriptPsbtSignerException extends SignerException { + final String errorMessage; + MiniscriptPsbtSignerException( + String this.errorMessage, + ); + MiniscriptPsbtSignerException._( + String this.errorMessage, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final errorMessage_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final errorMessage = errorMessage_lifted.value; + new_offset += errorMessage_lifted.bytesRead; + return LiftRetVal( + MiniscriptPsbtSignerException._( + errorMessage, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(errorMessage) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 15); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterString.write( + errorMessage, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "MiniscriptPsbtSignerException($errorMessage)"; + } +} + +class ExternalSignerException extends SignerException { + final String errorMessage; + ExternalSignerException( + String this.errorMessage, + ); + ExternalSignerException._( + String this.errorMessage, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final errorMessage_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final errorMessage = errorMessage_lifted.value; + new_offset += errorMessage_lifted.bytesRead; + return LiftRetVal( + ExternalSignerException._( + errorMessage, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(errorMessage) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 16); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterString.write( + errorMessage, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "ExternalSignerException($errorMessage)"; + } +} + +class PsbtSignerException extends SignerException { + final String errorMessage; + PsbtSignerException( + String this.errorMessage, + ); + PsbtSignerException._( + String this.errorMessage, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final errorMessage_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final errorMessage = errorMessage_lifted.value; + new_offset += errorMessage_lifted.bytesRead; + return LiftRetVal( + PsbtSignerException._( + errorMessage, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(errorMessage) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 17); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterString.write( + errorMessage, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "PsbtSignerException($errorMessage)"; + } +} + +class SignerExceptionErrorHandler extends UniffiRustCallStatusErrorHandler { + @override + Exception lift(RustBuffer errorBuf) { + return FfiConverterSignerException.lift(errorBuf); + } +} + +final SignerExceptionErrorHandler signerExceptionErrorHandler = + SignerExceptionErrorHandler(); + +abstract class TransactionException implements Exception { + RustBuffer lower(); + int allocationSize(); + int write(Uint8List buf); +} + +class FfiConverterTransactionException { + static TransactionException lift(RustBuffer buffer) { + return FfiConverterTransactionException.read(buffer.asUint8List()).value; + } + + static LiftRetVal read(Uint8List buf) { + final index = buf.buffer.asByteData(buf.offsetInBytes).getInt32(0); + final subview = Uint8List.view(buf.buffer, buf.offsetInBytes + 4); + switch (index) { + case 1: + return IoTransactionException.read(subview); + case 2: + return OversizedVectorAllocationTransactionException.read(subview); + case 3: + return InvalidChecksumTransactionException.read(subview); + case 4: + return NonMinimalVarIntTransactionException.read(subview); + case 5: + return ParseFailedTransactionException.read(subview); + case 6: + return UnsupportedSegwitFlagTransactionException.read(subview); + case 7: + return OtherTransactionErrTransactionException.read(subview); + default: + throw UniffiInternalError(UniffiInternalError.unexpectedEnumCase, + "Unable to determine enum variant"); + } + } + + static RustBuffer lower(TransactionException value) { + return value.lower(); + } + + static int allocationSize(TransactionException value) { + return value.allocationSize(); + } + + static int write(TransactionException value, Uint8List buf) { + return value.write(buf); + } +} + +class IoTransactionException extends TransactionException { + IoTransactionException(); + IoTransactionException._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(IoTransactionException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 1); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "IoTransactionException"; + } +} + +class OversizedVectorAllocationTransactionException + extends TransactionException { + OversizedVectorAllocationTransactionException(); + OversizedVectorAllocationTransactionException._(); + static LiftRetVal read( + Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal( + OversizedVectorAllocationTransactionException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 2); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "OversizedVectorAllocationTransactionException"; + } +} + +class InvalidChecksumTransactionException extends TransactionException { + final String expected; + final String actual; + InvalidChecksumTransactionException({ + required String this.expected, + required String this.actual, + }); + InvalidChecksumTransactionException._( + String this.expected, + String this.actual, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final expected_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final expected = expected_lifted.value; + new_offset += expected_lifted.bytesRead; + final actual_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final actual = actual_lifted.value; + new_offset += actual_lifted.bytesRead; + return LiftRetVal( + InvalidChecksumTransactionException._( + expected, + actual, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(expected) + + FfiConverterString.allocationSize(actual) + + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 3); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterString.write( + expected, Uint8List.view(buf.buffer, new_offset)); + new_offset += FfiConverterString.write( + actual, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "InvalidChecksumTransactionException($expected, $actual)"; + } +} + +class NonMinimalVarIntTransactionException extends TransactionException { + NonMinimalVarIntTransactionException(); + NonMinimalVarIntTransactionException._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(NonMinimalVarIntTransactionException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 4); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "NonMinimalVarIntTransactionException"; + } +} + +class ParseFailedTransactionException extends TransactionException { + ParseFailedTransactionException(); + ParseFailedTransactionException._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(ParseFailedTransactionException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 5); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "ParseFailedTransactionException"; + } +} + +class UnsupportedSegwitFlagTransactionException extends TransactionException { + final int flag; + UnsupportedSegwitFlagTransactionException( + int this.flag, + ); + UnsupportedSegwitFlagTransactionException._( + int this.flag, + ); + static LiftRetVal read( + Uint8List buf) { + int new_offset = buf.offsetInBytes; + final flag_lifted = + FfiConverterUInt8.read(Uint8List.view(buf.buffer, new_offset)); + final flag = flag_lifted.value; + new_offset += flag_lifted.bytesRead; + return LiftRetVal( + UnsupportedSegwitFlagTransactionException._( + flag, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterUInt8.allocationSize(flag) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 6); + int new_offset = buf.offsetInBytes + 4; + new_offset += + FfiConverterUInt8.write(flag, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "UnsupportedSegwitFlagTransactionException($flag)"; + } +} + +class OtherTransactionErrTransactionException extends TransactionException { + OtherTransactionErrTransactionException(); + OtherTransactionErrTransactionException._(); + static LiftRetVal read( + Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(OtherTransactionErrTransactionException._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 7); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } + + @override + String toString() { + return "OtherTransactionErrTransactionException"; + } +} + +class TransactionExceptionErrorHandler + extends UniffiRustCallStatusErrorHandler { + @override + Exception lift(RustBuffer errorBuf) { + return FfiConverterTransactionException.lift(errorBuf); + } +} + +final TransactionExceptionErrorHandler transactionExceptionErrorHandler = + TransactionExceptionErrorHandler(); + +abstract class TxidParseException implements Exception { + RustBuffer lower(); + int allocationSize(); + int write(Uint8List buf); +} + +class FfiConverterTxidParseException { + static TxidParseException lift(RustBuffer buffer) { + return FfiConverterTxidParseException.read(buffer.asUint8List()).value; + } + + static LiftRetVal read(Uint8List buf) { + final index = buf.buffer.asByteData(buf.offsetInBytes).getInt32(0); + final subview = Uint8List.view(buf.buffer, buf.offsetInBytes + 4); + switch (index) { + case 1: + return InvalidTxidTxidParseException.read(subview); + default: + throw UniffiInternalError(UniffiInternalError.unexpectedEnumCase, + "Unable to determine enum variant"); + } + } + + static RustBuffer lower(TxidParseException value) { + return value.lower(); + } + + static int allocationSize(TxidParseException value) { + return value.allocationSize(); + } + + static int write(TxidParseException value, Uint8List buf) { + return value.write(buf); + } +} + +class InvalidTxidTxidParseException extends TxidParseException { + final String txid; + InvalidTxidTxidParseException( + String this.txid, + ); + InvalidTxidTxidParseException._( + String this.txid, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final txid_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final txid = txid_lifted.value; + new_offset += txid_lifted.bytesRead; + return LiftRetVal( + InvalidTxidTxidParseException._( + txid, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(txid) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 1); + int new_offset = buf.offsetInBytes + 4; + new_offset += + FfiConverterString.write(txid, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } + + @override + String toString() { + return "InvalidTxidTxidParseException($txid)"; + } +} + +class TxidParseExceptionErrorHandler extends UniffiRustCallStatusErrorHandler { + @override + Exception lift(RustBuffer errorBuf) { + return FfiConverterTxidParseException.lift(errorBuf); + } +} + +final TxidParseExceptionErrorHandler txidParseExceptionErrorHandler = + TxidParseExceptionErrorHandler(); + +abstract class Warning { + RustBuffer lower(); + int allocationSize(); + int write(Uint8List buf); +} + +class FfiConverterWarning { + static Warning lift(RustBuffer buffer) { + return FfiConverterWarning.read(buffer.asUint8List()).value; + } + + static LiftRetVal read(Uint8List buf) { + final index = buf.buffer.asByteData(buf.offsetInBytes).getInt32(0); + final subview = Uint8List.view(buf.buffer, buf.offsetInBytes + 4); + switch (index) { + case 1: + return NeedConnectionsWarning.read(subview); + case 2: + return PeerTimedOutWarning.read(subview); + case 3: + return CouldNotConnectWarning.read(subview); + case 4: + return NoCompactFiltersWarning.read(subview); + case 5: + return PotentialStaleTipWarning.read(subview); + case 6: + return UnsolicitedMessageWarning.read(subview); + case 7: + return InvalidStartHeightWarning.read(subview); + case 8: + return CorruptedHeadersWarning.read(subview); + case 9: + return TransactionRejectedWarning.read(subview); + case 10: + return FailedPersistenceWarning.read(subview); + case 11: + return EvaluatingForkWarning.read(subview); + case 12: + return EmptyPeerDatabaseWarning.read(subview); + case 13: + return UnexpectedSyncExceptionWarning.read(subview); + case 14: + return RequestFailedWarning.read(subview); + default: + throw UniffiInternalError(UniffiInternalError.unexpectedEnumCase, + "Unable to determine enum variant"); + } + } + + static RustBuffer lower(Warning value) { + return value.lower(); + } + + static int allocationSize(Warning value) { + return value.allocationSize(); + } + + static int write(Warning value, Uint8List buf) { + return value.write(buf); + } +} + +class NeedConnectionsWarning extends Warning { + NeedConnectionsWarning(); + NeedConnectionsWarning._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(NeedConnectionsWarning._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 1); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } +} + +class PeerTimedOutWarning extends Warning { + PeerTimedOutWarning(); + PeerTimedOutWarning._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(PeerTimedOutWarning._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 2); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } +} + +class CouldNotConnectWarning extends Warning { + CouldNotConnectWarning(); + CouldNotConnectWarning._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(CouldNotConnectWarning._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 3); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } +} + +class NoCompactFiltersWarning extends Warning { + NoCompactFiltersWarning(); + NoCompactFiltersWarning._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(NoCompactFiltersWarning._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 4); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } +} + +class PotentialStaleTipWarning extends Warning { + PotentialStaleTipWarning(); + PotentialStaleTipWarning._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(PotentialStaleTipWarning._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 5); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } +} + +class UnsolicitedMessageWarning extends Warning { + UnsolicitedMessageWarning(); + UnsolicitedMessageWarning._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(UnsolicitedMessageWarning._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 6); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } +} + +class InvalidStartHeightWarning extends Warning { + InvalidStartHeightWarning(); + InvalidStartHeightWarning._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(InvalidStartHeightWarning._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 7); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } +} + +class CorruptedHeadersWarning extends Warning { + CorruptedHeadersWarning(); + CorruptedHeadersWarning._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(CorruptedHeadersWarning._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 8); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } +} + +class TransactionRejectedWarning extends Warning { + final String wtxid; + final String? reason; + TransactionRejectedWarning({ + required String this.wtxid, + required String? this.reason, + }); + TransactionRejectedWarning._( + String this.wtxid, + String? this.reason, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final wtxid_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final wtxid = wtxid_lifted.value; + new_offset += wtxid_lifted.bytesRead; + final reason_lifted = + FfiConverterOptionalString.read(Uint8List.view(buf.buffer, new_offset)); + final reason = reason_lifted.value; + new_offset += reason_lifted.bytesRead; + return LiftRetVal( + TransactionRejectedWarning._( + wtxid, + reason, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(wtxid) + + FfiConverterOptionalString.allocationSize(reason) + + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 9); + int new_offset = buf.offsetInBytes + 4; + new_offset += + FfiConverterString.write(wtxid, Uint8List.view(buf.buffer, new_offset)); + new_offset += FfiConverterOptionalString.write( + reason, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } +} + +class FailedPersistenceWarning extends Warning { + final String warning; + FailedPersistenceWarning( + String this.warning, + ); + FailedPersistenceWarning._( + String this.warning, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final warning_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final warning = warning_lifted.value; + new_offset += warning_lifted.bytesRead; + return LiftRetVal( + FailedPersistenceWarning._( + warning, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(warning) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 10); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterString.write( + warning, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } +} + +class EvaluatingForkWarning extends Warning { + EvaluatingForkWarning(); + EvaluatingForkWarning._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(EvaluatingForkWarning._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 11); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } +} + +class EmptyPeerDatabaseWarning extends Warning { + EmptyPeerDatabaseWarning(); + EmptyPeerDatabaseWarning._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(EmptyPeerDatabaseWarning._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 12); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } +} + +class UnexpectedSyncExceptionWarning extends Warning { + final String warning; + UnexpectedSyncExceptionWarning( + String this.warning, + ); + UnexpectedSyncExceptionWarning._( + String this.warning, + ); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + final warning_lifted = + FfiConverterString.read(Uint8List.view(buf.buffer, new_offset)); + final warning = warning_lifted.value; + new_offset += warning_lifted.bytesRead; + return LiftRetVal( + UnexpectedSyncExceptionWarning._( + warning, + ), + new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return FfiConverterString.allocationSize(warning) + 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 13); + int new_offset = buf.offsetInBytes + 4; + new_offset += FfiConverterString.write( + warning, Uint8List.view(buf.buffer, new_offset)); + return new_offset; + } +} + +class RequestFailedWarning extends Warning { + RequestFailedWarning(); + RequestFailedWarning._(); + static LiftRetVal read(Uint8List buf) { + int new_offset = buf.offsetInBytes; + return LiftRetVal(RequestFailedWarning._(), new_offset); + } + + @override + RustBuffer lower() { + final buf = Uint8List(allocationSize()); + write(buf); + return toRustBuffer(buf); + } + + @override + int allocationSize() { + return 4; + } + + @override + int write(Uint8List buf) { + buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, 14); + int new_offset = buf.offsetInBytes + 4; + return new_offset; + } +} + +enum WordCount { + words12, + words15, + words18, + words21, + words24, + ; +} + +class FfiConverterWordCount { + static WordCount lift(RustBuffer buffer) { + final index = buffer.asUint8List().buffer.asByteData().getInt32(0); + switch (index) { + case 1: + return WordCount.words12; + case 2: + return WordCount.words15; + case 3: + return WordCount.words18; + case 4: + return WordCount.words21; + case 5: + return WordCount.words24; + default: + throw UniffiInternalError(UniffiInternalError.unexpectedEnumCase, + "Unable to determine enum variant"); + } + } + + static RustBuffer lower(WordCount input) { + return toRustBuffer(createUint8ListFromInt(input.index + 1)); + } +} + +final _AddressFinalizer = Finalizer>((ptr) { + rustCall((status) => + _UniffiLib.instance.uniffi_bdkffi_fn_free_address(ptr, status)); +}); + +class Address { + late final Pointer _ptr; + Address._(this._ptr) { + _AddressFinalizer.attach(this, _ptr, detach: this); + } + Address.fromScript( + Script script, + Network network, + ) : _ptr = rustCall( + (status) => _UniffiLib.instance + .uniffi_bdkffi_fn_constructor_address_from_script( + Script.lower(script), + FfiConverterNetwork.lower(network), + status), + fromScriptExceptionErrorHandler) { + _AddressFinalizer.attach(this, _ptr, detach: this); + } + Address( + String address, + Network network, + ) : _ptr = rustCall( + (status) => _UniffiLib.instance + .uniffi_bdkffi_fn_constructor_address_new( + FfiConverterString.lower(address), + FfiConverterNetwork.lower(network), + status), + addressParseExceptionErrorHandler) { + _AddressFinalizer.attach(this, _ptr, detach: this); + } + factory Address.lift(Pointer ptr) { + return Address._(ptr); + } + static Pointer lower(Address value) { + return value.uniffiClonePointer(); + } + + Pointer uniffiClonePointer() { + return rustCall((status) => + _UniffiLib.instance.uniffi_bdkffi_fn_clone_address(_ptr, status)); + } + + static int allocationSize(Address value) { + return 8; + } + + static LiftRetVal
read(Uint8List buf) { + final handle = buf.buffer.asByteData(buf.offsetInBytes).getInt64(0); + final pointer = Pointer.fromAddress(handle); + return LiftRetVal(Address.lift(pointer), 8); + } + + static int write(Address value, Uint8List buf) { + final handle = lower(value); + buf.buffer.asByteData(buf.offsetInBytes).setInt64(0, handle.address); + return 8; + } + + void dispose() { + _AddressFinalizer.detach(this); + rustCall((status) => + _UniffiLib.instance.uniffi_bdkffi_fn_free_address(_ptr, status)); + } + + bool isValidForNetwork( + Network network, + ) { + return rustCall( + (status) => FfiConverterBool.lift(_UniffiLib.instance + .uniffi_bdkffi_fn_method_address_is_valid_for_network( + uniffiClonePointer(), + FfiConverterNetwork.lower(network), + status)), + null); + } + + Script scriptPubkey() { + return rustCall( + (status) => Script.lift(_UniffiLib.instance + .uniffi_bdkffi_fn_method_address_script_pubkey( + uniffiClonePointer(), status)), + null); + } + + AddressData toAddressData() { + return rustCall( + (status) => FfiConverterAddressData.lift(_UniffiLib.instance + .uniffi_bdkffi_fn_method_address_to_address_data( + uniffiClonePointer(), status)), + null); + } + + String toQrUri() { + return rustCall( + (status) => FfiConverterString.lift(_UniffiLib.instance + .uniffi_bdkffi_fn_method_address_to_qr_uri( + uniffiClonePointer(), status)), + null); + } +} + +final _AmountFinalizer = Finalizer>((ptr) { + rustCall((status) => + _UniffiLib.instance.uniffi_bdkffi_fn_free_amount(ptr, status)); +}); + +class Amount { + late final Pointer _ptr; + Amount._(this._ptr) { + _AmountFinalizer.attach(this, _ptr, detach: this); + } + Amount.fromBtc( + double btc, + ) : _ptr = rustCall( + (status) => _UniffiLib.instance + .uniffi_bdkffi_fn_constructor_amount_from_btc(btc, status), + parseAmountExceptionErrorHandler) { + _AmountFinalizer.attach(this, _ptr, detach: this); + } + Amount.fromSat( + int satoshi, + ) : _ptr = rustCall( + (status) => _UniffiLib.instance + .uniffi_bdkffi_fn_constructor_amount_from_sat(satoshi, status), + null) { + _AmountFinalizer.attach(this, _ptr, detach: this); + } + factory Amount.lift(Pointer ptr) { + return Amount._(ptr); + } + static Pointer lower(Amount value) { + return value.uniffiClonePointer(); + } + + Pointer uniffiClonePointer() { + return rustCall((status) => + _UniffiLib.instance.uniffi_bdkffi_fn_clone_amount(_ptr, status)); + } + + static int allocationSize(Amount value) { + return 8; + } + + static LiftRetVal read(Uint8List buf) { + final handle = buf.buffer.asByteData(buf.offsetInBytes).getInt64(0); + final pointer = Pointer.fromAddress(handle); + return LiftRetVal(Amount.lift(pointer), 8); + } + + static int write(Amount value, Uint8List buf) { + final handle = lower(value); + buf.buffer.asByteData(buf.offsetInBytes).setInt64(0, handle.address); + return 8; + } + + void dispose() { + _AmountFinalizer.detach(this); + rustCall((status) => + _UniffiLib.instance.uniffi_bdkffi_fn_free_amount(_ptr, status)); + } + + double toBtc() { + return rustCall( + (status) => FfiConverterDouble64.lift(_UniffiLib.instance + .uniffi_bdkffi_fn_method_amount_to_btc( + uniffiClonePointer(), status)), + null); + } + + int toSat() { + return rustCall( + (status) => FfiConverterUInt64.lift(_UniffiLib.instance + .uniffi_bdkffi_fn_method_amount_to_sat( + uniffiClonePointer(), status)), + null); + } +} + +final _BlockHashFinalizer = Finalizer>((ptr) { + rustCall((status) => + _UniffiLib.instance.uniffi_bdkffi_fn_free_blockhash(ptr, status)); +}); + +class BlockHash { + late final Pointer _ptr; + BlockHash._(this._ptr) { + _BlockHashFinalizer.attach(this, _ptr, detach: this); + } + BlockHash.fromBytes( + Uint8List bytes, + ) : _ptr = rustCall( + (status) => _UniffiLib.instance + .uniffi_bdkffi_fn_constructor_blockhash_from_bytes( + FfiConverterUint8List.lower(bytes), status), + hashParseExceptionErrorHandler) { + _BlockHashFinalizer.attach(this, _ptr, detach: this); + } + BlockHash.fromString( + String hex, + ) : _ptr = rustCall( + (status) => _UniffiLib.instance + .uniffi_bdkffi_fn_constructor_blockhash_from_string( + FfiConverterString.lower(hex), status), + hashParseExceptionErrorHandler) { + _BlockHashFinalizer.attach(this, _ptr, detach: this); + } + factory BlockHash.lift(Pointer ptr) { + return BlockHash._(ptr); + } + static Pointer lower(BlockHash value) { + return value.uniffiClonePointer(); + } + + Pointer uniffiClonePointer() { + return rustCall((status) => + _UniffiLib.instance.uniffi_bdkffi_fn_clone_blockhash(_ptr, status)); + } + + static int allocationSize(BlockHash value) { + return 8; + } + + static LiftRetVal read(Uint8List buf) { + final handle = buf.buffer.asByteData(buf.offsetInBytes).getInt64(0); + final pointer = Pointer.fromAddress(handle); + return LiftRetVal(BlockHash.lift(pointer), 8); + } + + static int write(BlockHash value, Uint8List buf) { + final handle = lower(value); + buf.buffer.asByteData(buf.offsetInBytes).setInt64(0, handle.address); + return 8; + } + + void dispose() { + _BlockHashFinalizer.detach(this); + rustCall((status) => + _UniffiLib.instance.uniffi_bdkffi_fn_free_blockhash(_ptr, status)); + } + + Uint8List serialize() { + return rustCall( + (status) => FfiConverterUint8List.lift(_UniffiLib.instance + .uniffi_bdkffi_fn_method_blockhash_serialize( + uniffiClonePointer(), status)), + null); + } +} + +final _BumpFeeTxBuilderFinalizer = Finalizer>((ptr) { + rustCall((status) => + _UniffiLib.instance.uniffi_bdkffi_fn_free_bumpfeetxbuilder(ptr, status)); +}); + +class BumpFeeTxBuilder { + late final Pointer _ptr; + BumpFeeTxBuilder._(this._ptr) { + _BumpFeeTxBuilderFinalizer.attach(this, _ptr, detach: this); + } + BumpFeeTxBuilder( + Txid txid, + FeeRate feeRate, + ) : _ptr = rustCall( + (status) => _UniffiLib.instance + .uniffi_bdkffi_fn_constructor_bumpfeetxbuilder_new( + Txid.lower(txid), FeeRate.lower(feeRate), status), + null) { + _BumpFeeTxBuilderFinalizer.attach(this, _ptr, detach: this); + } + factory BumpFeeTxBuilder.lift(Pointer ptr) { + return BumpFeeTxBuilder._(ptr); + } + static Pointer lower(BumpFeeTxBuilder value) { + return value.uniffiClonePointer(); + } + + Pointer uniffiClonePointer() { + return rustCall((status) => _UniffiLib.instance + .uniffi_bdkffi_fn_clone_bumpfeetxbuilder(_ptr, status)); + } + + static int allocationSize(BumpFeeTxBuilder value) { + return 8; + } + + static LiftRetVal read(Uint8List buf) { + final handle = buf.buffer.asByteData(buf.offsetInBytes).getInt64(0); + final pointer = Pointer.fromAddress(handle); + return LiftRetVal(BumpFeeTxBuilder.lift(pointer), 8); + } + + static int write(BumpFeeTxBuilder value, Uint8List buf) { + final handle = lower(value); + buf.buffer.asByteData(buf.offsetInBytes).setInt64(0, handle.address); + return 8; + } + + void dispose() { + _BumpFeeTxBuilderFinalizer.detach(this); + rustCall((status) => _UniffiLib.instance + .uniffi_bdkffi_fn_free_bumpfeetxbuilder(_ptr, status)); + } + + BumpFeeTxBuilder allowDust( + bool allowDust, + ) { + return rustCall( + (status) => BumpFeeTxBuilder.lift(_UniffiLib.instance + .uniffi_bdkffi_fn_method_bumpfeetxbuilder_allow_dust( + uniffiClonePointer(), + FfiConverterBool.lower(allowDust), + status)), + null); + } + + BumpFeeTxBuilder currentHeight( + int height, + ) { + return rustCall( + (status) => BumpFeeTxBuilder.lift(_UniffiLib.instance + .uniffi_bdkffi_fn_method_bumpfeetxbuilder_current_height( + uniffiClonePointer(), height, status)), + null); + } + + Psbt finish( + Wallet wallet, + ) { + return rustCall( + (status) => Psbt.lift(_UniffiLib.instance + .uniffi_bdkffi_fn_method_bumpfeetxbuilder_finish( + uniffiClonePointer(), Wallet.lower(wallet), status)), + createTxExceptionErrorHandler); + } + + BumpFeeTxBuilder nlocktime( + LockTime locktime, + ) { + return rustCall( + (status) => BumpFeeTxBuilder.lift(_UniffiLib.instance + .uniffi_bdkffi_fn_method_bumpfeetxbuilder_nlocktime( + uniffiClonePointer(), + FfiConverterLockTime.lower(locktime), + status)), + null); + } + + BumpFeeTxBuilder setExactSequence( + int nsequence, + ) { + return rustCall( + (status) => BumpFeeTxBuilder.lift(_UniffiLib.instance + .uniffi_bdkffi_fn_method_bumpfeetxbuilder_set_exact_sequence( + uniffiClonePointer(), nsequence, status)), + null); + } + + BumpFeeTxBuilder version( + int version, + ) { + return rustCall( + (status) => BumpFeeTxBuilder.lift(_UniffiLib.instance + .uniffi_bdkffi_fn_method_bumpfeetxbuilder_version( + uniffiClonePointer(), version, status)), + null); + } +} + +final _CbfBuilderFinalizer = Finalizer>((ptr) { + rustCall((status) => + _UniffiLib.instance.uniffi_bdkffi_fn_free_cbfbuilder(ptr, status)); +}); + +class CbfBuilder { + late final Pointer _ptr; + CbfBuilder._(this._ptr) { + _CbfBuilderFinalizer.attach(this, _ptr, detach: this); + } + CbfBuilder() + : _ptr = rustCall( + (status) => _UniffiLib.instance + .uniffi_bdkffi_fn_constructor_cbfbuilder_new(status), + null) { + _CbfBuilderFinalizer.attach(this, _ptr, detach: this); + } + factory CbfBuilder.lift(Pointer ptr) { + return CbfBuilder._(ptr); + } + static Pointer lower(CbfBuilder value) { + return value.uniffiClonePointer(); + } + + Pointer uniffiClonePointer() { + return rustCall((status) => + _UniffiLib.instance.uniffi_bdkffi_fn_clone_cbfbuilder(_ptr, status)); + } + + static int allocationSize(CbfBuilder value) { + return 8; + } + + static LiftRetVal read(Uint8List buf) { + final handle = buf.buffer.asByteData(buf.offsetInBytes).getInt64(0); + final pointer = Pointer.fromAddress(handle); + return LiftRetVal(CbfBuilder.lift(pointer), 8); + } + + static int write(CbfBuilder value, Uint8List buf) { + final handle = lower(value); + buf.buffer.asByteData(buf.offsetInBytes).setInt64(0, handle.address); + return 8; + } + + void dispose() { + _CbfBuilderFinalizer.detach(this); + rustCall((status) => + _UniffiLib.instance.uniffi_bdkffi_fn_free_cbfbuilder(_ptr, status)); + } + + CbfComponents build( + Wallet wallet, + ) { + return rustCall( + (status) => FfiConverterCbfComponents.lift(_UniffiLib.instance + .uniffi_bdkffi_fn_method_cbfbuilder_build( + uniffiClonePointer(), Wallet.lower(wallet), status)), + cbfBuilderExceptionErrorHandler); + } + + CbfBuilder configureTimeoutMillis( + int handshake, + int response, + ) { + return rustCall( + (status) => CbfBuilder.lift(_UniffiLib.instance + .uniffi_bdkffi_fn_method_cbfbuilder_configure_timeout_millis( + uniffiClonePointer(), handshake, response, status)), + null); + } + + CbfBuilder connections( + int connections, + ) { + return rustCall( + (status) => CbfBuilder.lift(_UniffiLib.instance + .uniffi_bdkffi_fn_method_cbfbuilder_connections( + uniffiClonePointer(), connections, status)), + null); + } + + CbfBuilder dataDir( + String dataDir, + ) { + return rustCall( + (status) => CbfBuilder.lift(_UniffiLib.instance + .uniffi_bdkffi_fn_method_cbfbuilder_data_dir(uniffiClonePointer(), + FfiConverterString.lower(dataDir), status)), + null); + } + + CbfBuilder dnsResolver( + IpAddress dnsResolver, + ) { + return rustCall( + (status) => CbfBuilder.lift(_UniffiLib.instance + .uniffi_bdkffi_fn_method_cbfbuilder_dns_resolver( + uniffiClonePointer(), IpAddress.lower(dnsResolver), status)), + null); + } + + CbfBuilder peers( + List peers, + ) { + return rustCall( + (status) => CbfBuilder.lift(_UniffiLib.instance + .uniffi_bdkffi_fn_method_cbfbuilder_peers(uniffiClonePointer(), + FfiConverterSequencePeer.lower(peers), status)), + null); + } + + CbfBuilder scanType( + ScanType scanType, + ) { + return rustCall( + (status) => CbfBuilder.lift(_UniffiLib.instance + .uniffi_bdkffi_fn_method_cbfbuilder_scan_type(uniffiClonePointer(), + FfiConverterScanType.lower(scanType), status)), + null); + } + + CbfBuilder socks5Proxy( + Socks5Proxy proxy, + ) { + return rustCall( + (status) => CbfBuilder.lift(_UniffiLib.instance + .uniffi_bdkffi_fn_method_cbfbuilder_socks5_proxy( + uniffiClonePointer(), + FfiConverterSocks5Proxy.lower(proxy), + status)), + null); + } +} + +final _CbfClientFinalizer = Finalizer>((ptr) { + rustCall((status) => + _UniffiLib.instance.uniffi_bdkffi_fn_free_cbfclient(ptr, status)); +}); + +class CbfClient { + late final Pointer _ptr; + CbfClient._(this._ptr) { + _CbfClientFinalizer.attach(this, _ptr, detach: this); + } + factory CbfClient.lift(Pointer ptr) { + return CbfClient._(ptr); + } + static Pointer lower(CbfClient value) { + return value.uniffiClonePointer(); + } + + Pointer uniffiClonePointer() { + return rustCall((status) => + _UniffiLib.instance.uniffi_bdkffi_fn_clone_cbfclient(_ptr, status)); + } + + static int allocationSize(CbfClient value) { + return 8; + } + + static LiftRetVal read(Uint8List buf) { + final handle = buf.buffer.asByteData(buf.offsetInBytes).getInt64(0); + final pointer = Pointer.fromAddress(handle); + return LiftRetVal(CbfClient.lift(pointer), 8); + } + + static int write(CbfClient value, Uint8List buf) { + final handle = lower(value); + buf.buffer.asByteData(buf.offsetInBytes).setInt64(0, handle.address); + return 8; + } + + void dispose() { + _CbfClientFinalizer.detach(this); + rustCall((status) => + _UniffiLib.instance.uniffi_bdkffi_fn_free_cbfclient(_ptr, status)); + } + + void addRevealedScripts( + Wallet wallet, + ) { + return rustCall((status) { + _UniffiLib.instance + .uniffi_bdkffi_fn_method_cbfclient_add_revealed_scripts( + uniffiClonePointer(), Wallet.lower(wallet), status); + }, cbfExceptionErrorHandler); + } + + Future averageFeeRate( + BlockHash blockhash, + ) { + return uniffiRustCallAsync( + () => _UniffiLib.instance + .uniffi_bdkffi_fn_method_cbfclient_average_fee_rate( + uniffiClonePointer(), + BlockHash.lower(blockhash), + ), + _UniffiLib.instance.ffi_bdkffi_rust_future_poll_pointer, + _UniffiLib.instance.ffi_bdkffi_rust_future_complete_pointer, + _UniffiLib.instance.ffi_bdkffi_rust_future_free_pointer, + FeeRate.lift, + cbfExceptionErrorHandler, + ); + } + + void broadcast( + Transaction transaction, + ) { + return rustCall((status) { + _UniffiLib.instance.uniffi_bdkffi_fn_method_cbfclient_broadcast( + uniffiClonePointer(), Transaction.lower(transaction), status); + }, cbfExceptionErrorHandler); + } + + void connect( + Peer peer, + ) { + return rustCall((status) { + _UniffiLib.instance.uniffi_bdkffi_fn_method_cbfclient_connect( + uniffiClonePointer(), FfiConverterPeer.lower(peer), status); + }, cbfExceptionErrorHandler); + } + + bool isRunning() { + return rustCall( + (status) => FfiConverterBool.lift(_UniffiLib.instance + .uniffi_bdkffi_fn_method_cbfclient_is_running( + uniffiClonePointer(), status)), + null); + } + + Future> lookupHost( + String hostname, + ) { + return uniffiRustCallAsync( + () => _UniffiLib.instance.uniffi_bdkffi_fn_method_cbfclient_lookup_host( + uniffiClonePointer(), + FfiConverterString.lower(hostname), + ), + _UniffiLib.instance.ffi_bdkffi_rust_future_poll_rust_buffer, + _UniffiLib.instance.ffi_bdkffi_rust_future_complete_rust_buffer, + _UniffiLib.instance.ffi_bdkffi_rust_future_free_rust_buffer, + FfiConverterSequenceIpAddress.lift, + null, + ); + } + + Future minBroadcastFeerate() { + return uniffiRustCallAsync( + () => _UniffiLib.instance + .uniffi_bdkffi_fn_method_cbfclient_min_broadcast_feerate( + uniffiClonePointer(), + ), + _UniffiLib.instance.ffi_bdkffi_rust_future_poll_pointer, + _UniffiLib.instance.ffi_bdkffi_rust_future_complete_pointer, + _UniffiLib.instance.ffi_bdkffi_rust_future_free_pointer, + FeeRate.lift, + cbfExceptionErrorHandler, + ); + } + + Future nextInfo() { + return uniffiRustCallAsync( + () => _UniffiLib.instance.uniffi_bdkffi_fn_method_cbfclient_next_info( + uniffiClonePointer(), + ), + _UniffiLib.instance.ffi_bdkffi_rust_future_poll_rust_buffer, + _UniffiLib.instance.ffi_bdkffi_rust_future_complete_rust_buffer, + _UniffiLib.instance.ffi_bdkffi_rust_future_free_rust_buffer, + FfiConverterInfo.lift, + cbfExceptionErrorHandler, + ); + } + + Future nextWarning() { + return uniffiRustCallAsync( + () => _UniffiLib.instance.uniffi_bdkffi_fn_method_cbfclient_next_warning( + uniffiClonePointer(), + ), + _UniffiLib.instance.ffi_bdkffi_rust_future_poll_rust_buffer, + _UniffiLib.instance.ffi_bdkffi_rust_future_complete_rust_buffer, + _UniffiLib.instance.ffi_bdkffi_rust_future_free_rust_buffer, + FfiConverterWarning.lift, + cbfExceptionErrorHandler, + ); + } + + void shutdown() { + return rustCall((status) { + _UniffiLib.instance.uniffi_bdkffi_fn_method_cbfclient_shutdown( + uniffiClonePointer(), status); + }, cbfExceptionErrorHandler); + } + + Future update() { + return uniffiRustCallAsync( + () => _UniffiLib.instance.uniffi_bdkffi_fn_method_cbfclient_update( + uniffiClonePointer(), + ), + _UniffiLib.instance.ffi_bdkffi_rust_future_poll_pointer, + _UniffiLib.instance.ffi_bdkffi_rust_future_complete_pointer, + _UniffiLib.instance.ffi_bdkffi_rust_future_free_pointer, + Update.lift, + cbfExceptionErrorHandler, + ); + } +} + +final _CbfNodeFinalizer = Finalizer>((ptr) { + rustCall((status) => + _UniffiLib.instance.uniffi_bdkffi_fn_free_cbfnode(ptr, status)); +}); + +class CbfNode { + late final Pointer _ptr; + CbfNode._(this._ptr) { + _CbfNodeFinalizer.attach(this, _ptr, detach: this); + } + factory CbfNode.lift(Pointer ptr) { + return CbfNode._(ptr); + } + static Pointer lower(CbfNode value) { + return value.uniffiClonePointer(); + } + + Pointer uniffiClonePointer() { + return rustCall((status) => + _UniffiLib.instance.uniffi_bdkffi_fn_clone_cbfnode(_ptr, status)); + } + + static int allocationSize(CbfNode value) { + return 8; + } + + static LiftRetVal read(Uint8List buf) { + final handle = buf.buffer.asByteData(buf.offsetInBytes).getInt64(0); + final pointer = Pointer.fromAddress(handle); + return LiftRetVal(CbfNode.lift(pointer), 8); + } + + static int write(CbfNode value, Uint8List buf) { + final handle = lower(value); + buf.buffer.asByteData(buf.offsetInBytes).setInt64(0, handle.address); + return 8; + } + + void dispose() { + _CbfNodeFinalizer.detach(this); + rustCall((status) => + _UniffiLib.instance.uniffi_bdkffi_fn_free_cbfnode(_ptr, status)); + } + + void run() { + return rustCall((status) { + _UniffiLib.instance + .uniffi_bdkffi_fn_method_cbfnode_run(uniffiClonePointer(), status); + }, null); + } +} + +final _ChangeSetFinalizer = Finalizer>((ptr) { + rustCall((status) => + _UniffiLib.instance.uniffi_bdkffi_fn_free_changeset(ptr, status)); +}); + +class ChangeSet { + late final Pointer _ptr; + ChangeSet._(this._ptr) { + _ChangeSetFinalizer.attach(this, _ptr, detach: this); + } + ChangeSet.fromAggregate( + Descriptor? descriptor, + Descriptor? changeDescriptor, + Network? network, + LocalChainChangeSet localChain, + TxGraphChangeSet txGraph, + IndexerChangeSet indexer, + ) : _ptr = rustCall( + (status) => _UniffiLib.instance + .uniffi_bdkffi_fn_constructor_changeset_from_aggregate( + FfiConverterOptionalDescriptor.lower(descriptor), + FfiConverterOptionalDescriptor.lower(changeDescriptor), + FfiConverterOptionalNetwork.lower(network), + FfiConverterLocalChainChangeSet.lower(localChain), + FfiConverterTxGraphChangeSet.lower(txGraph), + FfiConverterIndexerChangeSet.lower(indexer), + status), + null) { + _ChangeSetFinalizer.attach(this, _ptr, detach: this); + } + ChangeSet.fromDescriptorAndNetwork( + Descriptor? descriptor, + Descriptor? changeDescriptor, + Network? network, + ) : _ptr = rustCall( + (status) => _UniffiLib.instance + .uniffi_bdkffi_fn_constructor_changeset_from_descriptor_and_network( + FfiConverterOptionalDescriptor.lower(descriptor), + FfiConverterOptionalDescriptor.lower(changeDescriptor), + FfiConverterOptionalNetwork.lower(network), + status), + null) { + _ChangeSetFinalizer.attach(this, _ptr, detach: this); + } + ChangeSet.fromIndexerChangeset( + IndexerChangeSet indexerChanges, + ) : _ptr = rustCall( + (status) => _UniffiLib.instance + .uniffi_bdkffi_fn_constructor_changeset_from_indexer_changeset( + FfiConverterIndexerChangeSet.lower(indexerChanges), status), + null) { + _ChangeSetFinalizer.attach(this, _ptr, detach: this); + } + ChangeSet.fromLocalChainChanges( + LocalChainChangeSet localChainChanges, + ) : _ptr = rustCall( + (status) => _UniffiLib.instance + .uniffi_bdkffi_fn_constructor_changeset_from_local_chain_changes( + FfiConverterLocalChainChangeSet.lower(localChainChanges), + status), + null) { + _ChangeSetFinalizer.attach(this, _ptr, detach: this); + } + ChangeSet.fromMerge( + ChangeSet left, + ChangeSet right, + ) : _ptr = rustCall( + (status) => _UniffiLib.instance + .uniffi_bdkffi_fn_constructor_changeset_from_merge( + ChangeSet.lower(left), ChangeSet.lower(right), status), + null) { + _ChangeSetFinalizer.attach(this, _ptr, detach: this); + } + ChangeSet.fromTxGraphChangeset( + TxGraphChangeSet txGraphChangeset, + ) : _ptr = rustCall( + (status) => _UniffiLib.instance + .uniffi_bdkffi_fn_constructor_changeset_from_tx_graph_changeset( + FfiConverterTxGraphChangeSet.lower(txGraphChangeset), + status), + null) { + _ChangeSetFinalizer.attach(this, _ptr, detach: this); + } + ChangeSet() + : _ptr = rustCall( + (status) => _UniffiLib.instance + .uniffi_bdkffi_fn_constructor_changeset_new(status), + null) { + _ChangeSetFinalizer.attach(this, _ptr, detach: this); + } + factory ChangeSet.lift(Pointer ptr) { + return ChangeSet._(ptr); + } + static Pointer lower(ChangeSet value) { + return value.uniffiClonePointer(); + } + + Pointer uniffiClonePointer() { + return rustCall((status) => + _UniffiLib.instance.uniffi_bdkffi_fn_clone_changeset(_ptr, status)); + } + + static int allocationSize(ChangeSet value) { + return 8; + } + + static LiftRetVal read(Uint8List buf) { + final handle = buf.buffer.asByteData(buf.offsetInBytes).getInt64(0); + final pointer = Pointer.fromAddress(handle); + return LiftRetVal(ChangeSet.lift(pointer), 8); + } + + static int write(ChangeSet value, Uint8List buf) { + final handle = lower(value); + buf.buffer.asByteData(buf.offsetInBytes).setInt64(0, handle.address); + return 8; + } + + void dispose() { + _ChangeSetFinalizer.detach(this); + rustCall((status) => + _UniffiLib.instance.uniffi_bdkffi_fn_free_changeset(_ptr, status)); + } + + Descriptor? changeDescriptor() { + return rustCall( + (status) => FfiConverterOptionalDescriptor.lift(_UniffiLib.instance + .uniffi_bdkffi_fn_method_changeset_change_descriptor( + uniffiClonePointer(), status)), + null); + } + + Descriptor? descriptor() { + return rustCall( + (status) => FfiConverterOptionalDescriptor.lift(_UniffiLib.instance + .uniffi_bdkffi_fn_method_changeset_descriptor( + uniffiClonePointer(), status)), + null); + } + + IndexerChangeSet indexerChangeset() { + return rustCall( + (status) => FfiConverterIndexerChangeSet.lift(_UniffiLib.instance + .uniffi_bdkffi_fn_method_changeset_indexer_changeset( + uniffiClonePointer(), status)), + null); + } + + LocalChainChangeSet localchainChangeset() { + return rustCall( + (status) => FfiConverterLocalChainChangeSet.lift(_UniffiLib.instance + .uniffi_bdkffi_fn_method_changeset_localchain_changeset( + uniffiClonePointer(), status)), + null); + } + + Network? network() { + return rustCall( + (status) => FfiConverterOptionalNetwork.lift(_UniffiLib.instance + .uniffi_bdkffi_fn_method_changeset_network( + uniffiClonePointer(), status)), + null); + } + + TxGraphChangeSet txGraphChangeset() { + return rustCall( + (status) => FfiConverterTxGraphChangeSet.lift(_UniffiLib.instance + .uniffi_bdkffi_fn_method_changeset_tx_graph_changeset( + uniffiClonePointer(), status)), + null); + } +} + +final _DerivationPathFinalizer = Finalizer>((ptr) { + rustCall((status) => + _UniffiLib.instance.uniffi_bdkffi_fn_free_derivationpath(ptr, status)); +}); + +class DerivationPath { + late final Pointer _ptr; + DerivationPath._(this._ptr) { + _DerivationPathFinalizer.attach(this, _ptr, detach: this); + } + DerivationPath( + String path, + ) : _ptr = rustCall( + (status) => _UniffiLib.instance + .uniffi_bdkffi_fn_constructor_derivationpath_new( + FfiConverterString.lower(path), status), + bip32ExceptionErrorHandler) { + _DerivationPathFinalizer.attach(this, _ptr, detach: this); + } + factory DerivationPath.lift(Pointer ptr) { + return DerivationPath._(ptr); + } + static Pointer lower(DerivationPath value) { + return value.uniffiClonePointer(); + } + + Pointer uniffiClonePointer() { + return rustCall((status) => _UniffiLib.instance + .uniffi_bdkffi_fn_clone_derivationpath(_ptr, status)); + } + + static int allocationSize(DerivationPath value) { + return 8; + } + + static LiftRetVal read(Uint8List buf) { + final handle = buf.buffer.asByteData(buf.offsetInBytes).getInt64(0); + final pointer = Pointer.fromAddress(handle); + return LiftRetVal(DerivationPath.lift(pointer), 8); + } + + static int write(DerivationPath value, Uint8List buf) { + final handle = lower(value); + buf.buffer.asByteData(buf.offsetInBytes).setInt64(0, handle.address); + return 8; + } + + void dispose() { + _DerivationPathFinalizer.detach(this); + rustCall((status) => + _UniffiLib.instance.uniffi_bdkffi_fn_free_derivationpath(_ptr, status)); + } +} + +final _DescriptorFinalizer = Finalizer>((ptr) { + rustCall((status) => + _UniffiLib.instance.uniffi_bdkffi_fn_free_descriptor(ptr, status)); +}); + +class Descriptor { + late final Pointer _ptr; + Descriptor._(this._ptr) { + _DescriptorFinalizer.attach(this, _ptr, detach: this); + } + Descriptor( + String descriptor, + Network network, + ) : _ptr = rustCall( + (status) => _UniffiLib.instance + .uniffi_bdkffi_fn_constructor_descriptor_new( + FfiConverterString.lower(descriptor), + FfiConverterNetwork.lower(network), + status), + descriptorExceptionErrorHandler) { + _DescriptorFinalizer.attach(this, _ptr, detach: this); + } + Descriptor.newBip44( + DescriptorSecretKey secretKey, + KeychainKind keychainKind, + Network network, + ) : _ptr = rustCall( + (status) => _UniffiLib.instance + .uniffi_bdkffi_fn_constructor_descriptor_new_bip44( + DescriptorSecretKey.lower(secretKey), + FfiConverterKeychainKind.lower(keychainKind), + FfiConverterNetwork.lower(network), + status), + null) { + _DescriptorFinalizer.attach(this, _ptr, detach: this); + } + Descriptor.newBip44Public( + DescriptorPublicKey publicKey, + String fingerprint, + KeychainKind keychainKind, + Network network, + ) : _ptr = rustCall( + (status) => _UniffiLib.instance + .uniffi_bdkffi_fn_constructor_descriptor_new_bip44_public( + DescriptorPublicKey.lower(publicKey), + FfiConverterString.lower(fingerprint), + FfiConverterKeychainKind.lower(keychainKind), + FfiConverterNetwork.lower(network), + status), + null) { + _DescriptorFinalizer.attach(this, _ptr, detach: this); + } + Descriptor.newBip49( + DescriptorSecretKey secretKey, + KeychainKind keychainKind, + Network network, + ) : _ptr = rustCall( + (status) => _UniffiLib.instance + .uniffi_bdkffi_fn_constructor_descriptor_new_bip49( + DescriptorSecretKey.lower(secretKey), + FfiConverterKeychainKind.lower(keychainKind), + FfiConverterNetwork.lower(network), + status), + null) { + _DescriptorFinalizer.attach(this, _ptr, detach: this); + } + Descriptor.newBip49Public( + DescriptorPublicKey publicKey, + String fingerprint, + KeychainKind keychainKind, + Network network, + ) : _ptr = rustCall( + (status) => _UniffiLib.instance + .uniffi_bdkffi_fn_constructor_descriptor_new_bip49_public( + DescriptorPublicKey.lower(publicKey), + FfiConverterString.lower(fingerprint), + FfiConverterKeychainKind.lower(keychainKind), + FfiConverterNetwork.lower(network), + status), + null) { + _DescriptorFinalizer.attach(this, _ptr, detach: this); + } + Descriptor.newBip84( + DescriptorSecretKey secretKey, + KeychainKind keychainKind, + Network network, + ) : _ptr = rustCall( + (status) => _UniffiLib.instance + .uniffi_bdkffi_fn_constructor_descriptor_new_bip84( + DescriptorSecretKey.lower(secretKey), + FfiConverterKeychainKind.lower(keychainKind), + FfiConverterNetwork.lower(network), + status), + null) { + _DescriptorFinalizer.attach(this, _ptr, detach: this); + } + Descriptor.newBip84Public( + DescriptorPublicKey publicKey, + String fingerprint, + KeychainKind keychainKind, + Network network, + ) : _ptr = rustCall( + (status) => _UniffiLib.instance + .uniffi_bdkffi_fn_constructor_descriptor_new_bip84_public( + DescriptorPublicKey.lower(publicKey), + FfiConverterString.lower(fingerprint), + FfiConverterKeychainKind.lower(keychainKind), + FfiConverterNetwork.lower(network), + status), + null) { + _DescriptorFinalizer.attach(this, _ptr, detach: this); + } + Descriptor.newBip86( + DescriptorSecretKey secretKey, + KeychainKind keychainKind, + Network network, + ) : _ptr = rustCall( + (status) => _UniffiLib.instance + .uniffi_bdkffi_fn_constructor_descriptor_new_bip86( + DescriptorSecretKey.lower(secretKey), + FfiConverterKeychainKind.lower(keychainKind), + FfiConverterNetwork.lower(network), + status), + null) { + _DescriptorFinalizer.attach(this, _ptr, detach: this); + } + Descriptor.newBip86Public( + DescriptorPublicKey publicKey, + String fingerprint, + KeychainKind keychainKind, + Network network, + ) : _ptr = rustCall( + (status) => _UniffiLib.instance + .uniffi_bdkffi_fn_constructor_descriptor_new_bip86_public( + DescriptorPublicKey.lower(publicKey), + FfiConverterString.lower(fingerprint), + FfiConverterKeychainKind.lower(keychainKind), + FfiConverterNetwork.lower(network), + status), + null) { + _DescriptorFinalizer.attach(this, _ptr, detach: this); + } + factory Descriptor.lift(Pointer ptr) { + return Descriptor._(ptr); + } + static Pointer lower(Descriptor value) { + return value.uniffiClonePointer(); + } + + Pointer uniffiClonePointer() { + return rustCall((status) => + _UniffiLib.instance.uniffi_bdkffi_fn_clone_descriptor(_ptr, status)); + } + + static int allocationSize(Descriptor value) { + return 8; + } + + static LiftRetVal read(Uint8List buf) { + final handle = buf.buffer.asByteData(buf.offsetInBytes).getInt64(0); + final pointer = Pointer.fromAddress(handle); + return LiftRetVal(Descriptor.lift(pointer), 8); + } + + static int write(Descriptor value, Uint8List buf) { + final handle = lower(value); + buf.buffer.asByteData(buf.offsetInBytes).setInt64(0, handle.address); + return 8; + } + + void dispose() { + _DescriptorFinalizer.detach(this); + rustCall((status) => + _UniffiLib.instance.uniffi_bdkffi_fn_free_descriptor(_ptr, status)); + } + + DescriptorType descType() { + return rustCall( + (status) => FfiConverterDescriptorType.lift(_UniffiLib.instance + .uniffi_bdkffi_fn_method_descriptor_desc_type( + uniffiClonePointer(), status)), + null); + } + + DescriptorId descriptorId() { + return rustCall( + (status) => DescriptorId.lift(_UniffiLib.instance + .uniffi_bdkffi_fn_method_descriptor_descriptor_id( + uniffiClonePointer(), status)), + null); + } + + bool isMultipath() { + return rustCall( + (status) => FfiConverterBool.lift(_UniffiLib.instance + .uniffi_bdkffi_fn_method_descriptor_is_multipath( + uniffiClonePointer(), status)), + null); + } + + int maxWeightToSatisfy() { + return rustCall( + (status) => FfiConverterUInt64.lift(_UniffiLib.instance + .uniffi_bdkffi_fn_method_descriptor_max_weight_to_satisfy( + uniffiClonePointer(), status)), + descriptorExceptionErrorHandler); + } + + List toSingleDescriptors() { + return rustCall( + (status) => FfiConverterSequenceDescriptor.lift(_UniffiLib.instance + .uniffi_bdkffi_fn_method_descriptor_to_single_descriptors( + uniffiClonePointer(), status)), + miniscriptExceptionErrorHandler); + } + + String toStringWithSecret() { + return rustCall( + (status) => FfiConverterString.lift(_UniffiLib.instance + .uniffi_bdkffi_fn_method_descriptor_to_string_with_secret( + uniffiClonePointer(), status)), + null); + } +} + +final _DescriptorIdFinalizer = Finalizer>((ptr) { + rustCall((status) => + _UniffiLib.instance.uniffi_bdkffi_fn_free_descriptorid(ptr, status)); +}); + +class DescriptorId { + late final Pointer _ptr; + DescriptorId._(this._ptr) { + _DescriptorIdFinalizer.attach(this, _ptr, detach: this); + } + DescriptorId.fromBytes( + Uint8List bytes, + ) : _ptr = rustCall( + (status) => _UniffiLib.instance + .uniffi_bdkffi_fn_constructor_descriptorid_from_bytes( + FfiConverterUint8List.lower(bytes), status), + hashParseExceptionErrorHandler) { + _DescriptorIdFinalizer.attach(this, _ptr, detach: this); + } + DescriptorId.fromString( + String hex, + ) : _ptr = rustCall( + (status) => _UniffiLib.instance + .uniffi_bdkffi_fn_constructor_descriptorid_from_string( + FfiConverterString.lower(hex), status), + hashParseExceptionErrorHandler) { + _DescriptorIdFinalizer.attach(this, _ptr, detach: this); + } + factory DescriptorId.lift(Pointer ptr) { + return DescriptorId._(ptr); + } + static Pointer lower(DescriptorId value) { + return value.uniffiClonePointer(); + } + + Pointer uniffiClonePointer() { + return rustCall((status) => + _UniffiLib.instance.uniffi_bdkffi_fn_clone_descriptorid(_ptr, status)); + } + + static int allocationSize(DescriptorId value) { + return 8; + } + + static LiftRetVal read(Uint8List buf) { + final handle = buf.buffer.asByteData(buf.offsetInBytes).getInt64(0); + final pointer = Pointer.fromAddress(handle); + return LiftRetVal(DescriptorId.lift(pointer), 8); + } + + static int write(DescriptorId value, Uint8List buf) { + final handle = lower(value); + buf.buffer.asByteData(buf.offsetInBytes).setInt64(0, handle.address); + return 8; + } + + void dispose() { + _DescriptorIdFinalizer.detach(this); + rustCall((status) => + _UniffiLib.instance.uniffi_bdkffi_fn_free_descriptorid(_ptr, status)); + } + + Uint8List serialize() { + return rustCall( + (status) => FfiConverterUint8List.lift(_UniffiLib.instance + .uniffi_bdkffi_fn_method_descriptorid_serialize( + uniffiClonePointer(), status)), + null); + } +} + +final _DescriptorPublicKeyFinalizer = Finalizer>((ptr) { + rustCall((status) => _UniffiLib.instance + .uniffi_bdkffi_fn_free_descriptorpublickey(ptr, status)); +}); + +class DescriptorPublicKey { + late final Pointer _ptr; + DescriptorPublicKey._(this._ptr) { + _DescriptorPublicKeyFinalizer.attach(this, _ptr, detach: this); + } + DescriptorPublicKey.fromString( + String publicKey, + ) : _ptr = rustCall( + (status) => _UniffiLib.instance + .uniffi_bdkffi_fn_constructor_descriptorpublickey_from_string( + FfiConverterString.lower(publicKey), status), + descriptorKeyExceptionErrorHandler) { + _DescriptorPublicKeyFinalizer.attach(this, _ptr, detach: this); + } + factory DescriptorPublicKey.lift(Pointer ptr) { + return DescriptorPublicKey._(ptr); + } + static Pointer lower(DescriptorPublicKey value) { + return value.uniffiClonePointer(); + } + + Pointer uniffiClonePointer() { + return rustCall((status) => _UniffiLib.instance + .uniffi_bdkffi_fn_clone_descriptorpublickey(_ptr, status)); + } + + static int allocationSize(DescriptorPublicKey value) { + return 8; + } + + static LiftRetVal read(Uint8List buf) { + final handle = buf.buffer.asByteData(buf.offsetInBytes).getInt64(0); + final pointer = Pointer.fromAddress(handle); + return LiftRetVal(DescriptorPublicKey.lift(pointer), 8); + } + + static int write(DescriptorPublicKey value, Uint8List buf) { + final handle = lower(value); + buf.buffer.asByteData(buf.offsetInBytes).setInt64(0, handle.address); + return 8; + } + + void dispose() { + _DescriptorPublicKeyFinalizer.detach(this); + rustCall((status) => _UniffiLib.instance + .uniffi_bdkffi_fn_free_descriptorpublickey(_ptr, status)); + } + + DescriptorPublicKey derive( + DerivationPath path, + ) { + return rustCall( + (status) => DescriptorPublicKey.lift(_UniffiLib.instance + .uniffi_bdkffi_fn_method_descriptorpublickey_derive( + uniffiClonePointer(), DerivationPath.lower(path), status)), + descriptorKeyExceptionErrorHandler); + } + + DescriptorPublicKey extend( + DerivationPath path, + ) { + return rustCall( + (status) => DescriptorPublicKey.lift(_UniffiLib.instance + .uniffi_bdkffi_fn_method_descriptorpublickey_extend( + uniffiClonePointer(), DerivationPath.lower(path), status)), + descriptorKeyExceptionErrorHandler); + } + + bool isMultipath() { + return rustCall( + (status) => FfiConverterBool.lift(_UniffiLib.instance + .uniffi_bdkffi_fn_method_descriptorpublickey_is_multipath( + uniffiClonePointer(), status)), + null); + } + + String masterFingerprint() { + return rustCall( + (status) => FfiConverterString.lift(_UniffiLib.instance + .uniffi_bdkffi_fn_method_descriptorpublickey_master_fingerprint( + uniffiClonePointer(), status)), + null); + } +} + +final _DescriptorSecretKeyFinalizer = Finalizer>((ptr) { + rustCall((status) => _UniffiLib.instance + .uniffi_bdkffi_fn_free_descriptorsecretkey(ptr, status)); +}); + +class DescriptorSecretKey { + late final Pointer _ptr; + DescriptorSecretKey._(this._ptr) { + _DescriptorSecretKeyFinalizer.attach(this, _ptr, detach: this); + } + DescriptorSecretKey.fromString( + String privateKey, + ) : _ptr = rustCall( + (status) => _UniffiLib.instance + .uniffi_bdkffi_fn_constructor_descriptorsecretkey_from_string( + FfiConverterString.lower(privateKey), status), + descriptorKeyExceptionErrorHandler) { + _DescriptorSecretKeyFinalizer.attach(this, _ptr, detach: this); + } + DescriptorSecretKey( + Network network, + Mnemonic mnemonic, + String? password, + ) : _ptr = rustCall( + (status) => _UniffiLib.instance + .uniffi_bdkffi_fn_constructor_descriptorsecretkey_new( + FfiConverterNetwork.lower(network), + Mnemonic.lower(mnemonic), + FfiConverterOptionalString.lower(password), + status), + null) { + _DescriptorSecretKeyFinalizer.attach(this, _ptr, detach: this); + } + factory DescriptorSecretKey.lift(Pointer ptr) { + return DescriptorSecretKey._(ptr); + } + static Pointer lower(DescriptorSecretKey value) { + return value.uniffiClonePointer(); + } + + Pointer uniffiClonePointer() { + return rustCall((status) => _UniffiLib.instance + .uniffi_bdkffi_fn_clone_descriptorsecretkey(_ptr, status)); + } + + static int allocationSize(DescriptorSecretKey value) { + return 8; + } + + static LiftRetVal read(Uint8List buf) { + final handle = buf.buffer.asByteData(buf.offsetInBytes).getInt64(0); + final pointer = Pointer.fromAddress(handle); + return LiftRetVal(DescriptorSecretKey.lift(pointer), 8); + } + + static int write(DescriptorSecretKey value, Uint8List buf) { + final handle = lower(value); + buf.buffer.asByteData(buf.offsetInBytes).setInt64(0, handle.address); + return 8; + } + + void dispose() { + _DescriptorSecretKeyFinalizer.detach(this); + rustCall((status) => _UniffiLib.instance + .uniffi_bdkffi_fn_free_descriptorsecretkey(_ptr, status)); + } + + DescriptorPublicKey asPublic() { + return rustCall( + (status) => DescriptorPublicKey.lift(_UniffiLib.instance + .uniffi_bdkffi_fn_method_descriptorsecretkey_as_public( + uniffiClonePointer(), status)), + null); + } + + DescriptorSecretKey derive( + DerivationPath path, + ) { + return rustCall( + (status) => DescriptorSecretKey.lift(_UniffiLib.instance + .uniffi_bdkffi_fn_method_descriptorsecretkey_derive( + uniffiClonePointer(), DerivationPath.lower(path), status)), + descriptorKeyExceptionErrorHandler); + } + + DescriptorSecretKey extend( + DerivationPath path, + ) { + return rustCall( + (status) => DescriptorSecretKey.lift(_UniffiLib.instance + .uniffi_bdkffi_fn_method_descriptorsecretkey_extend( + uniffiClonePointer(), DerivationPath.lower(path), status)), + descriptorKeyExceptionErrorHandler); + } + + Uint8List secretBytes() { + return rustCall( + (status) => FfiConverterUint8List.lift(_UniffiLib.instance + .uniffi_bdkffi_fn_method_descriptorsecretkey_secret_bytes( + uniffiClonePointer(), status)), + null); + } +} + +final _ElectrumClientFinalizer = Finalizer>((ptr) { + rustCall((status) => + _UniffiLib.instance.uniffi_bdkffi_fn_free_electrumclient(ptr, status)); +}); + +class ElectrumClient { + late final Pointer _ptr; + ElectrumClient._(this._ptr) { + _ElectrumClientFinalizer.attach(this, _ptr, detach: this); + } + ElectrumClient( + String url, + String? socks5, + ) : _ptr = rustCall( + (status) => _UniffiLib.instance + .uniffi_bdkffi_fn_constructor_electrumclient_new( + FfiConverterString.lower(url), + FfiConverterOptionalString.lower(socks5), + status), + electrumExceptionErrorHandler) { + _ElectrumClientFinalizer.attach(this, _ptr, detach: this); + } + factory ElectrumClient.lift(Pointer ptr) { + return ElectrumClient._(ptr); + } + static Pointer lower(ElectrumClient value) { + return value.uniffiClonePointer(); + } + + Pointer uniffiClonePointer() { + return rustCall((status) => _UniffiLib.instance + .uniffi_bdkffi_fn_clone_electrumclient(_ptr, status)); + } + + static int allocationSize(ElectrumClient value) { + return 8; + } + + static LiftRetVal read(Uint8List buf) { + final handle = buf.buffer.asByteData(buf.offsetInBytes).getInt64(0); + final pointer = Pointer.fromAddress(handle); + return LiftRetVal(ElectrumClient.lift(pointer), 8); + } + + static int write(ElectrumClient value, Uint8List buf) { + final handle = lower(value); + buf.buffer.asByteData(buf.offsetInBytes).setInt64(0, handle.address); + return 8; + } + + void dispose() { + _ElectrumClientFinalizer.detach(this); + rustCall((status) => + _UniffiLib.instance.uniffi_bdkffi_fn_free_electrumclient(_ptr, status)); + } + + HeaderNotification blockHeadersSubscribe() { + return rustCall( + (status) => FfiConverterHeaderNotification.lift(_UniffiLib.instance + .uniffi_bdkffi_fn_method_electrumclient_block_headers_subscribe( + uniffiClonePointer(), status)), + electrumExceptionErrorHandler); + } + + double estimateFee( + int number, + ) { + return rustCall( + (status) => FfiConverterDouble64.lift(_UniffiLib.instance + .uniffi_bdkffi_fn_method_electrumclient_estimate_fee( + uniffiClonePointer(), number, status)), + electrumExceptionErrorHandler); + } + + Update fullScan( + FullScanRequest request, + int stopGap, + int batchSize, + bool fetchPrevTxouts, + ) { + return rustCall( + (status) => Update.lift(_UniffiLib.instance + .uniffi_bdkffi_fn_method_electrumclient_full_scan( + uniffiClonePointer(), + FullScanRequest.lower(request), + stopGap, + batchSize, + FfiConverterBool.lower(fetchPrevTxouts), + status)), + electrumExceptionErrorHandler); + } + + void ping() { + return rustCall((status) { + _UniffiLib.instance.uniffi_bdkffi_fn_method_electrumclient_ping( + uniffiClonePointer(), status); + }, electrumExceptionErrorHandler); + } + + ServerFeaturesRes serverFeatures() { + return rustCall( + (status) => FfiConverterServerFeaturesRes.lift(_UniffiLib.instance + .uniffi_bdkffi_fn_method_electrumclient_server_features( + uniffiClonePointer(), status)), + electrumExceptionErrorHandler); + } + + Update sync_( + SyncRequest request, + int batchSize, + bool fetchPrevTxouts, + ) { + return rustCall( + (status) => Update.lift(_UniffiLib.instance + .uniffi_bdkffi_fn_method_electrumclient_sync( + uniffiClonePointer(), + SyncRequest.lower(request), + batchSize, + FfiConverterBool.lower(fetchPrevTxouts), + status)), + electrumExceptionErrorHandler); + } + + Txid transactionBroadcast( + Transaction tx, + ) { + return rustCall( + (status) => Txid.lift(_UniffiLib.instance + .uniffi_bdkffi_fn_method_electrumclient_transaction_broadcast( + uniffiClonePointer(), Transaction.lower(tx), status)), + electrumExceptionErrorHandler); + } +} + +final _EsploraClientFinalizer = Finalizer>((ptr) { + rustCall((status) => + _UniffiLib.instance.uniffi_bdkffi_fn_free_esploraclient(ptr, status)); +}); + +class EsploraClient { + late final Pointer _ptr; + EsploraClient._(this._ptr) { + _EsploraClientFinalizer.attach(this, _ptr, detach: this); + } + EsploraClient( + String url, + String? proxy, + ) : _ptr = rustCall( + (status) => _UniffiLib.instance + .uniffi_bdkffi_fn_constructor_esploraclient_new( + FfiConverterString.lower(url), + FfiConverterOptionalString.lower(proxy), + status), + null) { + _EsploraClientFinalizer.attach(this, _ptr, detach: this); + } + factory EsploraClient.lift(Pointer ptr) { + return EsploraClient._(ptr); + } + static Pointer lower(EsploraClient value) { + return value.uniffiClonePointer(); + } + + Pointer uniffiClonePointer() { + return rustCall((status) => + _UniffiLib.instance.uniffi_bdkffi_fn_clone_esploraclient(_ptr, status)); + } + + static int allocationSize(EsploraClient value) { + return 8; + } + + static LiftRetVal read(Uint8List buf) { + final handle = buf.buffer.asByteData(buf.offsetInBytes).getInt64(0); + final pointer = Pointer.fromAddress(handle); + return LiftRetVal(EsploraClient.lift(pointer), 8); + } + + static int write(EsploraClient value, Uint8List buf) { + final handle = lower(value); + buf.buffer.asByteData(buf.offsetInBytes).setInt64(0, handle.address); + return 8; + } + + void dispose() { + _EsploraClientFinalizer.detach(this); + rustCall((status) => + _UniffiLib.instance.uniffi_bdkffi_fn_free_esploraclient(_ptr, status)); + } + + void broadcast( + Transaction transaction, + ) { + return rustCall((status) { + _UniffiLib.instance.uniffi_bdkffi_fn_method_esploraclient_broadcast( + uniffiClonePointer(), Transaction.lower(transaction), status); + }, esploraExceptionErrorHandler); + } + + Update fullScan( + FullScanRequest request, + int stopGap, + int parallelRequests, + ) { + return rustCall( + (status) => Update.lift(_UniffiLib.instance + .uniffi_bdkffi_fn_method_esploraclient_full_scan( + uniffiClonePointer(), + FullScanRequest.lower(request), + stopGap, + parallelRequests, + status)), + esploraExceptionErrorHandler); + } + + BlockHash getBlockHash( + int blockHeight, + ) { + return rustCall( + (status) => BlockHash.lift(_UniffiLib.instance + .uniffi_bdkffi_fn_method_esploraclient_get_block_hash( + uniffiClonePointer(), blockHeight, status)), + esploraExceptionErrorHandler); + } + + Map getFeeEstimates() { + return rustCall( + (status) => FfiConverterMapUInt16ToDouble64.lift(_UniffiLib.instance + .uniffi_bdkffi_fn_method_esploraclient_get_fee_estimates( + uniffiClonePointer(), status)), + esploraExceptionErrorHandler); + } + + int getHeight() { + return rustCall( + (status) => FfiConverterUInt32.lift(_UniffiLib.instance + .uniffi_bdkffi_fn_method_esploraclient_get_height( + uniffiClonePointer(), status)), + esploraExceptionErrorHandler); + } + + Transaction? getTx( + Txid txid, + ) { + return rustCall( + (status) => FfiConverterOptionalTransaction.lift(_UniffiLib.instance + .uniffi_bdkffi_fn_method_esploraclient_get_tx( + uniffiClonePointer(), Txid.lower(txid), status)), + esploraExceptionErrorHandler); + } + + Tx? getTxInfo( + Txid txid, + ) { + return rustCall( + (status) => FfiConverterOptionalTx.lift(_UniffiLib.instance + .uniffi_bdkffi_fn_method_esploraclient_get_tx_info( + uniffiClonePointer(), Txid.lower(txid), status)), + esploraExceptionErrorHandler); + } + + TxStatus getTxStatus( + Txid txid, + ) { + return rustCall( + (status) => FfiConverterTxStatus.lift(_UniffiLib.instance + .uniffi_bdkffi_fn_method_esploraclient_get_tx_status( + uniffiClonePointer(), Txid.lower(txid), status)), + esploraExceptionErrorHandler); + } + + Update sync_( + SyncRequest request, + int parallelRequests, + ) { + return rustCall( + (status) => Update.lift(_UniffiLib.instance + .uniffi_bdkffi_fn_method_esploraclient_sync(uniffiClonePointer(), + SyncRequest.lower(request), parallelRequests, status)), + esploraExceptionErrorHandler); + } +} + +final _FeeRateFinalizer = Finalizer>((ptr) { + rustCall((status) => + _UniffiLib.instance.uniffi_bdkffi_fn_free_feerate(ptr, status)); +}); + +class FeeRate { + late final Pointer _ptr; + FeeRate._(this._ptr) { + _FeeRateFinalizer.attach(this, _ptr, detach: this); + } + FeeRate.fromSatPerKwu( + int satKwu, + ) : _ptr = rustCall( + (status) => _UniffiLib.instance + .uniffi_bdkffi_fn_constructor_feerate_from_sat_per_kwu( + satKwu, status), + null) { + _FeeRateFinalizer.attach(this, _ptr, detach: this); + } + FeeRate.fromSatPerVb( + int satVb, + ) : _ptr = rustCall( + (status) => _UniffiLib.instance + .uniffi_bdkffi_fn_constructor_feerate_from_sat_per_vb( + satVb, status), + feeRateExceptionErrorHandler) { + _FeeRateFinalizer.attach(this, _ptr, detach: this); + } + factory FeeRate.lift(Pointer ptr) { + return FeeRate._(ptr); + } + static Pointer lower(FeeRate value) { + return value.uniffiClonePointer(); + } + + Pointer uniffiClonePointer() { + return rustCall((status) => + _UniffiLib.instance.uniffi_bdkffi_fn_clone_feerate(_ptr, status)); + } + + static int allocationSize(FeeRate value) { + return 8; + } + + static LiftRetVal read(Uint8List buf) { + final handle = buf.buffer.asByteData(buf.offsetInBytes).getInt64(0); + final pointer = Pointer.fromAddress(handle); + return LiftRetVal(FeeRate.lift(pointer), 8); + } + + static int write(FeeRate value, Uint8List buf) { + final handle = lower(value); + buf.buffer.asByteData(buf.offsetInBytes).setInt64(0, handle.address); + return 8; + } + + void dispose() { + _FeeRateFinalizer.detach(this); + rustCall((status) => + _UniffiLib.instance.uniffi_bdkffi_fn_free_feerate(_ptr, status)); + } + + int toSatPerKwu() { + return rustCall( + (status) => FfiConverterUInt64.lift(_UniffiLib.instance + .uniffi_bdkffi_fn_method_feerate_to_sat_per_kwu( + uniffiClonePointer(), status)), + null); + } + + int toSatPerVbCeil() { + return rustCall( + (status) => FfiConverterUInt64.lift(_UniffiLib.instance + .uniffi_bdkffi_fn_method_feerate_to_sat_per_vb_ceil( + uniffiClonePointer(), status)), + null); + } + + int toSatPerVbFloor() { + return rustCall( + (status) => FfiConverterUInt64.lift(_UniffiLib.instance + .uniffi_bdkffi_fn_method_feerate_to_sat_per_vb_floor( + uniffiClonePointer(), status)), + null); + } +} + +final _FullScanRequestFinalizer = Finalizer>((ptr) { + rustCall((status) => + _UniffiLib.instance.uniffi_bdkffi_fn_free_fullscanrequest(ptr, status)); +}); + +class FullScanRequest { + late final Pointer _ptr; + FullScanRequest._(this._ptr) { + _FullScanRequestFinalizer.attach(this, _ptr, detach: this); + } + factory FullScanRequest.lift(Pointer ptr) { + return FullScanRequest._(ptr); + } + static Pointer lower(FullScanRequest value) { + return value.uniffiClonePointer(); + } + + Pointer uniffiClonePointer() { + return rustCall((status) => _UniffiLib.instance + .uniffi_bdkffi_fn_clone_fullscanrequest(_ptr, status)); + } + + static int allocationSize(FullScanRequest value) { + return 8; + } + + static LiftRetVal read(Uint8List buf) { + final handle = buf.buffer.asByteData(buf.offsetInBytes).getInt64(0); + final pointer = Pointer.fromAddress(handle); + return LiftRetVal(FullScanRequest.lift(pointer), 8); + } + + static int write(FullScanRequest value, Uint8List buf) { + final handle = lower(value); + buf.buffer.asByteData(buf.offsetInBytes).setInt64(0, handle.address); + return 8; + } + + void dispose() { + _FullScanRequestFinalizer.detach(this); + rustCall((status) => _UniffiLib.instance + .uniffi_bdkffi_fn_free_fullscanrequest(_ptr, status)); + } +} + +final _FullScanRequestBuilderFinalizer = Finalizer>((ptr) { + rustCall((status) => _UniffiLib.instance + .uniffi_bdkffi_fn_free_fullscanrequestbuilder(ptr, status)); +}); + +class FullScanRequestBuilder { + late final Pointer _ptr; + FullScanRequestBuilder._(this._ptr) { + _FullScanRequestBuilderFinalizer.attach(this, _ptr, detach: this); + } + factory FullScanRequestBuilder.lift(Pointer ptr) { + return FullScanRequestBuilder._(ptr); + } + static Pointer lower(FullScanRequestBuilder value) { + return value.uniffiClonePointer(); + } + + Pointer uniffiClonePointer() { + return rustCall((status) => _UniffiLib.instance + .uniffi_bdkffi_fn_clone_fullscanrequestbuilder(_ptr, status)); + } + + static int allocationSize(FullScanRequestBuilder value) { + return 8; + } + + static LiftRetVal read(Uint8List buf) { + final handle = buf.buffer.asByteData(buf.offsetInBytes).getInt64(0); + final pointer = Pointer.fromAddress(handle); + return LiftRetVal(FullScanRequestBuilder.lift(pointer), 8); + } + + static int write(FullScanRequestBuilder value, Uint8List buf) { + final handle = lower(value); + buf.buffer.asByteData(buf.offsetInBytes).setInt64(0, handle.address); + return 8; + } + + void dispose() { + _FullScanRequestBuilderFinalizer.detach(this); + rustCall((status) => _UniffiLib.instance + .uniffi_bdkffi_fn_free_fullscanrequestbuilder(_ptr, status)); + } + + FullScanRequest build() { + return rustCall( + (status) => FullScanRequest.lift(_UniffiLib.instance + .uniffi_bdkffi_fn_method_fullscanrequestbuilder_build( + uniffiClonePointer(), status)), + requestBuilderExceptionErrorHandler); + } + + FullScanRequestBuilder inspectSpksForAllKeychains( + FullScanScriptInspector inspector, + ) { + return rustCall( + (status) => FullScanRequestBuilder.lift(_UniffiLib.instance + .uniffi_bdkffi_fn_method_fullscanrequestbuilder_inspect_spks_for_all_keychains( + uniffiClonePointer(), + Pointer.fromAddress( + FfiConverterCallbackInterfaceFullScanScriptInspector.lower( + inspector)), + status)), + requestBuilderExceptionErrorHandler); + } +} + +abstract class FullScanScriptInspector { + void inspect( + KeychainKind keychain, + int index, + Script script, + ); +} + +class FfiConverterCallbackInterfaceFullScanScriptInspector { + static final _handleMap = UniffiHandleMap(); + static bool _vtableInitialized = false; + static FullScanScriptInspector lift(int handle) { + return _handleMap.get(handle); + } + + static int lower(FullScanScriptInspector value) { + _ensureVTableInitialized(); + return _handleMap.insert(value); + } + + static void _ensureVTableInitialized() { + if (!_vtableInitialized) { + initFullScanScriptInspectorVTable(); + _vtableInitialized = true; + } + } + + static LiftRetVal read(Uint8List buf) { + final handle = buf.buffer.asByteData(buf.offsetInBytes).getInt64(0); + return LiftRetVal(lift(handle), 8); + } + + static int write(FullScanScriptInspector value, Uint8List buf) { + final handle = lower(value); + buf.buffer.asByteData(buf.offsetInBytes).setInt64(0, handle); + return 8; + } + + static int allocationSize(FullScanScriptInspector value) { + return 8; + } +} + +typedef UniffiCallbackInterfaceFullScanScriptInspectorMethod0 = Void Function( + Uint64, + Int32, + Uint32, + Pointer, + Pointer, + Pointer); +typedef UniffiCallbackInterfaceFullScanScriptInspectorMethod0Dart + = void Function( + int, int, int, Pointer, Pointer, Pointer); +typedef UniffiCallbackInterfaceFullScanScriptInspectorFree = Void Function( + Uint64); +typedef UniffiCallbackInterfaceFullScanScriptInspectorFreeDart = void Function( + int); + +final class UniffiVTableCallbackInterfaceFullScanScriptInspector + extends Struct { + external Pointer< + NativeFunction> + inspect; + external Pointer< + NativeFunction> + uniffiFree; +} + +void fullScanScriptInspectorInspect( + int uniffiHandle, + KeychainKind keychain, + int index, + Script script, + Pointer outReturn, + Pointer callStatus) { + final status = callStatus.ref; + try { + final obj = FfiConverterCallbackInterfaceFullScanScriptInspector._handleMap + .get(uniffiHandle); + final arg0 = FfiConverterKeychainKind.lift(keychain); + final arg1 = FfiConverterUInt32.lift(index); + final arg2 = Script.lift(script); + obj.inspect( + arg0, + arg1, + arg2, + ); + status.code = CALL_SUCCESS; + } catch (e) { + status.code = CALL_UNEXPECTED_ERROR; + status.errorBuf = FfiConverterString.lower(e.toString()); + } +} + +final Pointer< + NativeFunction> + fullScanScriptInspectorInspectPointer = + Pointer.fromFunction( + fullScanScriptInspectorInspect); +void fullScanScriptInspectorFreeCallback(int handle) { + try { + FfiConverterCallbackInterfaceFullScanScriptInspector._handleMap + .remove(handle); + } catch (e) {} +} + +final Pointer< + NativeFunction> + fullScanScriptInspectorFreePointer = + Pointer.fromFunction( + fullScanScriptInspectorFreeCallback); +late final Pointer + fullScanScriptInspectorVTable; +void initFullScanScriptInspectorVTable() { + if (FfiConverterCallbackInterfaceFullScanScriptInspector._vtableInitialized) { + return; + } + fullScanScriptInspectorVTable = + calloc(); + fullScanScriptInspectorVTable.ref.inspect = + fullScanScriptInspectorInspectPointer; + fullScanScriptInspectorVTable.ref.uniffiFree = + fullScanScriptInspectorFreePointer; + rustCall((status) { + _UniffiLib.instance + .uniffi_bdk_fn_init_callback_vtable_fullscanscriptinspector( + fullScanScriptInspectorVTable, + ); + checkCallStatus(NullRustCallStatusErrorHandler(), status); + }); + FfiConverterCallbackInterfaceFullScanScriptInspector._vtableInitialized = + true; +} + +final _HashableOutPointFinalizer = Finalizer>((ptr) { + rustCall((status) => + _UniffiLib.instance.uniffi_bdkffi_fn_free_hashableoutpoint(ptr, status)); +}); + +class HashableOutPoint { + late final Pointer _ptr; + HashableOutPoint._(this._ptr) { + _HashableOutPointFinalizer.attach(this, _ptr, detach: this); + } + HashableOutPoint( + OutPoint outpoint, + ) : _ptr = rustCall( + (status) => _UniffiLib.instance + .uniffi_bdkffi_fn_constructor_hashableoutpoint_new( + FfiConverterOutPoint.lower(outpoint), status), + null) { + _HashableOutPointFinalizer.attach(this, _ptr, detach: this); + } + factory HashableOutPoint.lift(Pointer ptr) { + return HashableOutPoint._(ptr); + } + static Pointer lower(HashableOutPoint value) { + return value.uniffiClonePointer(); + } + + Pointer uniffiClonePointer() { + return rustCall((status) => _UniffiLib.instance + .uniffi_bdkffi_fn_clone_hashableoutpoint(_ptr, status)); + } + + static int allocationSize(HashableOutPoint value) { + return 8; + } + + static LiftRetVal read(Uint8List buf) { + final handle = buf.buffer.asByteData(buf.offsetInBytes).getInt64(0); + final pointer = Pointer.fromAddress(handle); + return LiftRetVal(HashableOutPoint.lift(pointer), 8); + } + + static int write(HashableOutPoint value, Uint8List buf) { + final handle = lower(value); + buf.buffer.asByteData(buf.offsetInBytes).setInt64(0, handle.address); + return 8; + } + + void dispose() { + _HashableOutPointFinalizer.detach(this); + rustCall((status) => _UniffiLib.instance + .uniffi_bdkffi_fn_free_hashableoutpoint(_ptr, status)); + } + + OutPoint outpoint() { + return rustCall( + (status) => FfiConverterOutPoint.lift(_UniffiLib.instance + .uniffi_bdkffi_fn_method_hashableoutpoint_outpoint( + uniffiClonePointer(), status)), + null); + } +} + +final _IpAddressFinalizer = Finalizer>((ptr) { + rustCall((status) => + _UniffiLib.instance.uniffi_bdkffi_fn_free_ipaddress(ptr, status)); +}); + +class IpAddress { + late final Pointer _ptr; + IpAddress._(this._ptr) { + _IpAddressFinalizer.attach(this, _ptr, detach: this); + } + IpAddress.fromIpv4( + int q1, + int q2, + int q3, + int q4, + ) : _ptr = rustCall( + (status) => _UniffiLib.instance + .uniffi_bdkffi_fn_constructor_ipaddress_from_ipv4( + q1, q2, q3, q4, status), + null) { + _IpAddressFinalizer.attach(this, _ptr, detach: this); + } + IpAddress.fromIpv6( + int a, + int b, + int c, + int d, + int e, + int f, + int g, + int h, + ) : _ptr = rustCall( + (status) => _UniffiLib.instance + .uniffi_bdkffi_fn_constructor_ipaddress_from_ipv6( + a, b, c, d, e, f, g, h, status), + null) { + _IpAddressFinalizer.attach(this, _ptr, detach: this); + } + factory IpAddress.lift(Pointer ptr) { + return IpAddress._(ptr); + } + static Pointer lower(IpAddress value) { + return value.uniffiClonePointer(); + } + + Pointer uniffiClonePointer() { + return rustCall((status) => + _UniffiLib.instance.uniffi_bdkffi_fn_clone_ipaddress(_ptr, status)); + } + + static int allocationSize(IpAddress value) { + return 8; + } + + static LiftRetVal read(Uint8List buf) { + final handle = buf.buffer.asByteData(buf.offsetInBytes).getInt64(0); + final pointer = Pointer.fromAddress(handle); + return LiftRetVal(IpAddress.lift(pointer), 8); + } + + static int write(IpAddress value, Uint8List buf) { + final handle = lower(value); + buf.buffer.asByteData(buf.offsetInBytes).setInt64(0, handle.address); + return 8; + } + + void dispose() { + _IpAddressFinalizer.detach(this); + rustCall((status) => + _UniffiLib.instance.uniffi_bdkffi_fn_free_ipaddress(_ptr, status)); + } +} + +final _MnemonicFinalizer = Finalizer>((ptr) { + rustCall((status) => + _UniffiLib.instance.uniffi_bdkffi_fn_free_mnemonic(ptr, status)); +}); + +class Mnemonic { + late final Pointer _ptr; + Mnemonic._(this._ptr) { + _MnemonicFinalizer.attach(this, _ptr, detach: this); + } + Mnemonic.fromEntropy( + Uint8List entropy, + ) : _ptr = rustCall( + (status) => _UniffiLib.instance + .uniffi_bdkffi_fn_constructor_mnemonic_from_entropy( + FfiConverterUint8List.lower(entropy), status), + bip39ExceptionErrorHandler) { + _MnemonicFinalizer.attach(this, _ptr, detach: this); + } + Mnemonic.fromString( + String mnemonic, + ) : _ptr = rustCall( + (status) => _UniffiLib.instance + .uniffi_bdkffi_fn_constructor_mnemonic_from_string( + FfiConverterString.lower(mnemonic), status), + bip39ExceptionErrorHandler) { + _MnemonicFinalizer.attach(this, _ptr, detach: this); + } + Mnemonic( + WordCount wordCount, + ) : _ptr = rustCall( + (status) => _UniffiLib.instance + .uniffi_bdkffi_fn_constructor_mnemonic_new( + FfiConverterWordCount.lower(wordCount), status), + null) { + _MnemonicFinalizer.attach(this, _ptr, detach: this); + } + factory Mnemonic.lift(Pointer ptr) { + return Mnemonic._(ptr); + } + static Pointer lower(Mnemonic value) { + return value.uniffiClonePointer(); + } + + Pointer uniffiClonePointer() { + return rustCall((status) => + _UniffiLib.instance.uniffi_bdkffi_fn_clone_mnemonic(_ptr, status)); + } + + static int allocationSize(Mnemonic value) { + return 8; + } + + static LiftRetVal read(Uint8List buf) { + final handle = buf.buffer.asByteData(buf.offsetInBytes).getInt64(0); + final pointer = Pointer.fromAddress(handle); + return LiftRetVal(Mnemonic.lift(pointer), 8); + } + + static int write(Mnemonic value, Uint8List buf) { + final handle = lower(value); + buf.buffer.asByteData(buf.offsetInBytes).setInt64(0, handle.address); + return 8; + } + + void dispose() { + _MnemonicFinalizer.detach(this); + rustCall((status) => + _UniffiLib.instance.uniffi_bdkffi_fn_free_mnemonic(_ptr, status)); + } +} + +abstract class Persistence { + ChangeSet initialize(); + void persist( + ChangeSet changeset, + ); +} + +class FfiConverterCallbackInterfacePersistence { + static final _handleMap = UniffiHandleMap(); + static bool _vtableInitialized = false; + static Persistence lift(int handle) { + return _handleMap.get(handle); + } + + static int lower(Persistence value) { + _ensureVTableInitialized(); + return _handleMap.insert(value); + } + + static void _ensureVTableInitialized() { + if (!_vtableInitialized) { + initPersistenceVTable(); + _vtableInitialized = true; + } + } + + static LiftRetVal read(Uint8List buf) { + final handle = buf.buffer.asByteData(buf.offsetInBytes).getInt64(0); + return LiftRetVal(lift(handle), 8); + } + + static int write(Persistence value, Uint8List buf) { + final handle = lower(value); + buf.buffer.asByteData(buf.offsetInBytes).setInt64(0, handle); + return 8; + } + + static int allocationSize(Persistence value) { + return 8; + } +} + +typedef UniffiCallbackInterfacePersistenceMethod0 = Void Function( + Uint64, Pointer>, Pointer); +typedef UniffiCallbackInterfacePersistenceMethod0Dart = void Function( + int, Pointer>, Pointer); +typedef UniffiCallbackInterfacePersistenceMethod1 = Void Function( + Uint64, Pointer, Pointer, Pointer); +typedef UniffiCallbackInterfacePersistenceMethod1Dart = void Function( + int, Pointer, Pointer, Pointer); +typedef UniffiCallbackInterfacePersistenceFree = Void Function(Uint64); +typedef UniffiCallbackInterfacePersistenceFreeDart = void Function(int); + +final class UniffiVTableCallbackInterfacePersistence extends Struct { + external Pointer> + initialize; + external Pointer> + persist; + external Pointer> + uniffiFree; +} + +void persistenceInitialize(int uniffiHandle, Pointer outReturn, + Pointer callStatus) { + final status = callStatus.ref; + try { + final obj = + FfiConverterCallbackInterfacePersistence._handleMap.get(uniffiHandle); + final result = obj.initialize(); + outReturn.ref = ChangeSet.lower(result); + } catch (e) { + status.code = CALL_UNEXPECTED_ERROR; + status.errorBuf = FfiConverterString.lower(e.toString()); + } +} + +final Pointer> + persistenceInitializePointer = + Pointer.fromFunction( + persistenceInitialize); +void persistencePersist(int uniffiHandle, ChangeSet changeset, + Pointer outReturn, Pointer callStatus) { + final status = callStatus.ref; + try { + final obj = + FfiConverterCallbackInterfacePersistence._handleMap.get(uniffiHandle); + final arg0 = ChangeSet.lift(changeset); + obj.persist( + arg0, + ); + status.code = CALL_SUCCESS; + } catch (e) { + status.code = CALL_UNEXPECTED_ERROR; + status.errorBuf = FfiConverterString.lower(e.toString()); + } +} + +final Pointer> + persistencePersistPointer = + Pointer.fromFunction( + persistencePersist); +void persistenceFreeCallback(int handle) { + try { + FfiConverterCallbackInterfacePersistence._handleMap.remove(handle); + } catch (e) {} +} + +final Pointer> + persistenceFreePointer = + Pointer.fromFunction( + persistenceFreeCallback); +late final Pointer persistenceVTable; +void initPersistenceVTable() { + if (FfiConverterCallbackInterfacePersistence._vtableInitialized) { + return; + } + persistenceVTable = calloc(); + persistenceVTable.ref.initialize = persistenceInitializePointer; + persistenceVTable.ref.persist = persistencePersistPointer; + persistenceVTable.ref.uniffiFree = persistenceFreePointer; + rustCall((status) { + _UniffiLib.instance.uniffi_bdk_fn_init_callback_vtable_persistence( + persistenceVTable, + ); + checkCallStatus(NullRustCallStatusErrorHandler(), status); + }); + FfiConverterCallbackInterfacePersistence._vtableInitialized = true; +} + +final _PersisterFinalizer = Finalizer>((ptr) { + rustCall((status) => + _UniffiLib.instance.uniffi_bdkffi_fn_free_persister(ptr, status)); +}); + +class Persister { + late final Pointer _ptr; + Persister._(this._ptr) { + _PersisterFinalizer.attach(this, _ptr, detach: this); + } + Persister.custom( + Persistence persistence, + ) : _ptr = rustCall( + (status) => _UniffiLib.instance + .uniffi_bdkffi_fn_constructor_persister_custom( + FfiConverterCallbackInterfacePersistence.lower(persistence), + status), + null) { + _PersisterFinalizer.attach(this, _ptr, detach: this); + } + Persister.newInMemory() + : _ptr = rustCall( + (status) => _UniffiLib.instance + .uniffi_bdkffi_fn_constructor_persister_new_in_memory(status), + persistenceExceptionErrorHandler) { + _PersisterFinalizer.attach(this, _ptr, detach: this); + } + Persister.newSqlite( + String path, + ) : _ptr = rustCall( + (status) => _UniffiLib.instance + .uniffi_bdkffi_fn_constructor_persister_new_sqlite( + FfiConverterString.lower(path), status), + persistenceExceptionErrorHandler) { + _PersisterFinalizer.attach(this, _ptr, detach: this); + } + factory Persister.lift(Pointer ptr) { + return Persister._(ptr); + } + static Pointer lower(Persister value) { + return value.uniffiClonePointer(); + } + + Pointer uniffiClonePointer() { + return rustCall((status) => + _UniffiLib.instance.uniffi_bdkffi_fn_clone_persister(_ptr, status)); + } + + static int allocationSize(Persister value) { + return 8; + } + + static LiftRetVal read(Uint8List buf) { + final handle = buf.buffer.asByteData(buf.offsetInBytes).getInt64(0); + final pointer = Pointer.fromAddress(handle); + return LiftRetVal(Persister.lift(pointer), 8); + } + + static int write(Persister value, Uint8List buf) { + final handle = lower(value); + buf.buffer.asByteData(buf.offsetInBytes).setInt64(0, handle.address); + return 8; + } + + void dispose() { + _PersisterFinalizer.detach(this); + rustCall((status) => + _UniffiLib.instance.uniffi_bdkffi_fn_free_persister(_ptr, status)); + } +} + +final _PolicyFinalizer = Finalizer>((ptr) { + rustCall((status) => + _UniffiLib.instance.uniffi_bdkffi_fn_free_policy(ptr, status)); +}); + +class Policy { + late final Pointer _ptr; + Policy._(this._ptr) { + _PolicyFinalizer.attach(this, _ptr, detach: this); + } + factory Policy.lift(Pointer ptr) { + return Policy._(ptr); + } + static Pointer lower(Policy value) { + return value.uniffiClonePointer(); + } + + Pointer uniffiClonePointer() { + return rustCall((status) => + _UniffiLib.instance.uniffi_bdkffi_fn_clone_policy(_ptr, status)); + } + + static int allocationSize(Policy value) { + return 8; + } + + static LiftRetVal read(Uint8List buf) { + final handle = buf.buffer.asByteData(buf.offsetInBytes).getInt64(0); + final pointer = Pointer.fromAddress(handle); + return LiftRetVal(Policy.lift(pointer), 8); + } + + static int write(Policy value, Uint8List buf) { + final handle = lower(value); + buf.buffer.asByteData(buf.offsetInBytes).setInt64(0, handle.address); + return 8; + } + + void dispose() { + _PolicyFinalizer.detach(this); + rustCall((status) => + _UniffiLib.instance.uniffi_bdkffi_fn_free_policy(_ptr, status)); + } + + String asString() { + return rustCall( + (status) => FfiConverterString.lift(_UniffiLib.instance + .uniffi_bdkffi_fn_method_policy_as_string( + uniffiClonePointer(), status)), + null); + } + + Satisfaction contribution() { + return rustCall( + (status) => FfiConverterSatisfaction.lift(_UniffiLib.instance + .uniffi_bdkffi_fn_method_policy_contribution( + uniffiClonePointer(), status)), + null); + } + + String id() { + return rustCall( + (status) => FfiConverterString.lift(_UniffiLib.instance + .uniffi_bdkffi_fn_method_policy_id(uniffiClonePointer(), status)), + null); + } + + SatisfiableItem item() { + return rustCall( + (status) => FfiConverterSatisfiableItem.lift(_UniffiLib.instance + .uniffi_bdkffi_fn_method_policy_item(uniffiClonePointer(), status)), + null); + } + + bool requiresPath() { + return rustCall( + (status) => FfiConverterBool.lift(_UniffiLib.instance + .uniffi_bdkffi_fn_method_policy_requires_path( + uniffiClonePointer(), status)), + null); + } + + Satisfaction satisfaction() { + return rustCall( + (status) => FfiConverterSatisfaction.lift(_UniffiLib.instance + .uniffi_bdkffi_fn_method_policy_satisfaction( + uniffiClonePointer(), status)), + null); + } +} + +final _PsbtFinalizer = Finalizer>((ptr) { + rustCall( + (status) => _UniffiLib.instance.uniffi_bdkffi_fn_free_psbt(ptr, status)); +}); + +class Psbt { + late final Pointer _ptr; + Psbt._(this._ptr) { + _PsbtFinalizer.attach(this, _ptr, detach: this); + } + Psbt.fromFile( + String path, + ) : _ptr = rustCall( + (status) => _UniffiLib.instance + .uniffi_bdkffi_fn_constructor_psbt_from_file( + FfiConverterString.lower(path), status), + psbtExceptionErrorHandler) { + _PsbtFinalizer.attach(this, _ptr, detach: this); + } + Psbt.fromUnsignedTx( + Transaction tx, + ) : _ptr = rustCall( + (status) => _UniffiLib.instance + .uniffi_bdkffi_fn_constructor_psbt_from_unsigned_tx( + Transaction.lower(tx), status), + psbtExceptionErrorHandler) { + _PsbtFinalizer.attach(this, _ptr, detach: this); + } + Psbt( + String psbtBase64, + ) : _ptr = rustCall( + (status) => _UniffiLib.instance + .uniffi_bdkffi_fn_constructor_psbt_new( + FfiConverterString.lower(psbtBase64), status), + psbtParseExceptionErrorHandler) { + _PsbtFinalizer.attach(this, _ptr, detach: this); + } + factory Psbt.lift(Pointer ptr) { + return Psbt._(ptr); + } + static Pointer lower(Psbt value) { + return value.uniffiClonePointer(); + } + + Pointer uniffiClonePointer() { + return rustCall((status) => + _UniffiLib.instance.uniffi_bdkffi_fn_clone_psbt(_ptr, status)); + } + + static int allocationSize(Psbt value) { + return 8; + } + + static LiftRetVal read(Uint8List buf) { + final handle = buf.buffer.asByteData(buf.offsetInBytes).getInt64(0); + final pointer = Pointer.fromAddress(handle); + return LiftRetVal(Psbt.lift(pointer), 8); + } + + static int write(Psbt value, Uint8List buf) { + final handle = lower(value); + buf.buffer.asByteData(buf.offsetInBytes).setInt64(0, handle.address); + return 8; + } + + void dispose() { + _PsbtFinalizer.detach(this); + rustCall((status) => + _UniffiLib.instance.uniffi_bdkffi_fn_free_psbt(_ptr, status)); + } + + Psbt combine( + Psbt other, + ) { + return rustCall( + (status) => Psbt.lift(_UniffiLib.instance + .uniffi_bdkffi_fn_method_psbt_combine( + uniffiClonePointer(), Psbt.lower(other), status)), + psbtExceptionErrorHandler); + } + + Transaction extractTx() { + return rustCall( + (status) => Transaction.lift(_UniffiLib.instance + .uniffi_bdkffi_fn_method_psbt_extract_tx( + uniffiClonePointer(), status)), + extractTxExceptionErrorHandler); + } + + int fee() { + return rustCall( + (status) => FfiConverterUInt64.lift(_UniffiLib.instance + .uniffi_bdkffi_fn_method_psbt_fee(uniffiClonePointer(), status)), + psbtExceptionErrorHandler); + } + + FinalizedPsbtResult finalize() { + return rustCall( + (status) => FfiConverterFinalizedPsbtResult.lift(_UniffiLib.instance + .uniffi_bdkffi_fn_method_psbt_finalize( + uniffiClonePointer(), status)), + null); + } + + String jsonSerialize() { + return rustCall( + (status) => FfiConverterString.lift(_UniffiLib.instance + .uniffi_bdkffi_fn_method_psbt_json_serialize( + uniffiClonePointer(), status)), + null); + } + + String serialize() { + return rustCall( + (status) => FfiConverterString.lift(_UniffiLib.instance + .uniffi_bdkffi_fn_method_psbt_serialize( + uniffiClonePointer(), status)), + null); + } + + String spendUtxo( + int inputIndex, + ) { + return rustCall( + (status) => FfiConverterString.lift(_UniffiLib.instance + .uniffi_bdkffi_fn_method_psbt_spend_utxo( + uniffiClonePointer(), inputIndex, status)), + null); + } + + void writeToFile( + String path, + ) { + return rustCall((status) { + _UniffiLib.instance.uniffi_bdkffi_fn_method_psbt_write_to_file( + uniffiClonePointer(), FfiConverterString.lower(path), status); + }, psbtExceptionErrorHandler); + } +} + +final _ScriptFinalizer = Finalizer>((ptr) { + rustCall((status) => + _UniffiLib.instance.uniffi_bdkffi_fn_free_script(ptr, status)); +}); + +class Script { + late final Pointer _ptr; + Script._(this._ptr) { + _ScriptFinalizer.attach(this, _ptr, detach: this); + } + Script( + Uint8List rawOutputScript, + ) : _ptr = rustCall( + (status) => _UniffiLib.instance + .uniffi_bdkffi_fn_constructor_script_new( + FfiConverterUint8List.lower(rawOutputScript), status), + null) { + _ScriptFinalizer.attach(this, _ptr, detach: this); + } + factory Script.lift(Pointer ptr) { + return Script._(ptr); + } + static Pointer lower(Script value) { + return value.uniffiClonePointer(); + } + + Pointer uniffiClonePointer() { + return rustCall((status) => + _UniffiLib.instance.uniffi_bdkffi_fn_clone_script(_ptr, status)); + } + + static int allocationSize(Script value) { + return 8; + } + + static LiftRetVal