diff --git a/AGENTS.md b/AGENTS.md index 8af2db3..c182e83 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -20,7 +20,7 @@ Android bindings are built and published by `.github/workflows/gradle-publish.ym ```bash cargo test # All tests -cargo test modules:: # Single module (scanner, lnurl, onchain, activity, blocktank, trezor, pubky) +cargo test modules:: # Single module (scanner, lnurl, onchain, activity, blocktank, boltz, trezor, jade, hardware_wallet, ur, pubky) ``` ## Lint & Format @@ -35,7 +35,7 @@ Android bindings use ktlint via Gradle plugin (`org.jlleitschuh.gradle.ktlint`), ## Architecture - `src/lib.rs` — UniFFI exports and module re-exports -- `src/modules/` — Core modules: scanner, lnurl, onchain, activity, blocktank, trezor, pubky +- `src/modules/`: core modules: scanner, lnurl, onchain, activity, blocktank, boltz, trezor, jade, hardware_wallet, ur, pubky - `bindings/` — Platform-specific binding outputs (ios/, android/, python/) - `build.sh`, `build_ios.sh`, `build_android.sh`, `build_python.sh` — Build scripts @@ -43,7 +43,8 @@ Android bindings use ktlint via Gradle plugin (`org.jlleitschuh.gradle.ktlint`), - **Version sync**: Version must match across `Cargo.toml`, `Package.swift`, and `bindings/android/gradle.properties`. Use `build.sh -r` to bump all three. - **UniFFI**: Public types exposed to bindings are declared in `src/lib.rs`. Follow existing UniFFI patterns when adding new types. -- **Platform-specific deps**: Trezor uses Bluetooth-only on iOS, USB+Bluetooth on other platforms (see `Cargo.toml` target-specific dependencies). +- **Platform-specific deps**: Trezor uses Bluetooth-only on iOS, USB+Bluetooth on other platforms (see `Cargo.toml` target-specific dependencies). Jade's serial transport is desktop-only; `serialport` must keep `default-features = false` or CI loses `libudev`. +- **No cfg-gated UniFFI exports**: bindings are generated from the host library, so a host-only `#[uniffi::export]` would appear in the Swift and Kotlin output while being absent from the device library. - **Android build**: `build_android.sh` temporarily modifies `Cargo.toml` crate-type and removes `example/main.rs` during build — don't run concurrent builds. - **Android bindings**: Keep `bindings/android/lib/src/main/jniLibs/` untracked. GitHub Actions generates the JNI libraries before publishing the Android package. diff --git a/CHANGELOG.md b/CHANGELOG.md index 183e6fe..0e63cba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ # Changelog -## Unreleased +## 0.5.15 - 2026-09-07 + +- Add Blockstream Jade hardware wallet support: device discovery, connect, PIN unlock via the blind pinserver, extended public key and account export, on-device address verification, message signing, and PSBT signing, over Bluetooth on every platform and USB CDC serial on desktop and Python. Signed PSBTs feed the existing `finalize_psbt` path. The protocol lives in the `jade-client-rs` crate; this repo carries the UniFFI adapter. +- Add `HardwareWalletVendor.Blockstream` and catalog entries for Jade and Jade Plus. Note that adding an enum case makes exhaustive Kotlin `when` and Swift `switch` statements over `HardwareWalletVendor` non-exhaustive, which is source breaking for consumers. ## 0.5.14 - 2026-09-02 diff --git a/Cargo.lock b/Cargo.lock index 3896201..1728c1b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -589,7 +589,7 @@ dependencies = [ [[package]] name = "bitkitcore" -version = "0.5.14" +version = "0.5.15" dependencies = [ "android_logger", "async-trait", @@ -602,6 +602,7 @@ dependencies = [ "btleplug", "chrono", "hex", + "jade-client-rs", "jni", "lazy-regex", "lightning-invoice 0.32.0", @@ -967,6 +968,33 @@ dependencies = [ "windows-link 0.2.1", ] +[[package]] +name = "ciborium" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42e69ffd6f0917f5c029256a24d0161db17cea3997d185db0d35926308770f0e" +dependencies = [ + "ciborium-io", + "ciborium-ll", + "serde", +] + +[[package]] +name = "ciborium-io" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05afea1e0a06c9be33d539b876f1ce3692f4afea2cb41f740e7743225ed1c757" + +[[package]] +name = "ciborium-ll" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57663b653d948a338bfb3eeba9bb2fd5fcfaecb9e199e87e1eda4d9e8b240fd9" +dependencies = [ + "ciborium-io", + "half", +] + [[package]] name = "cipher" version = "0.4.4" @@ -1204,6 +1232,12 @@ version = "0.8.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" +[[package]] +name = "crunchy" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5" + [[package]] name = "crypto-bigint" version = "0.5.5" @@ -2016,6 +2050,17 @@ dependencies = [ "subtle", ] +[[package]] +name = "half" +version = "2.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ea2d84b969582b4b1864a92dc5d27cd2b77b622a8d79306834f1be5ba20d84b" +dependencies = [ + "cfg-if", + "crunchy", + "zerocopy", +] + [[package]] name = "hash32" version = "0.2.1" @@ -2452,6 +2497,16 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "io-kit-sys" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "617ee6cf8e3f66f3b4ea67a4058564628cde41901316e19f559e14c7c72c5e7b" +dependencies = [ + "core-foundation-sys", + "mach2", +] + [[package]] name = "ipnet" version = "2.12.0" @@ -2489,6 +2544,29 @@ version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "92ecc6618181def0457392ccd0ee51198e065e016d1d527a7ac1b6dc7c1f09d2" +[[package]] +name = "jade-client-rs" +version = "0.1.0" +source = "git+https://github.com/coreyphillips/jade-client-rs?rev=247c22f#247c22f6f5094826546a72614974d30c021aed28" +dependencies = [ + "async-trait", + "base64 0.22.1", + "bitcoin 0.32.8", + "ciborium", + "log", + "minicbor", + "rand 0.8.5", + "reqwest", + "serde", + "serde_bytes", + "serde_json", + "serialport", + "thiserror 2.0.18", + "tokio", + "url", + "zeroize", +] + [[package]] name = "jiff" version = "0.2.29" @@ -2828,6 +2906,15 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "112b39cec0b298b6c1999fee3e31427f74f676e4cb9879ed1a121b43661a4154" +[[package]] +name = "mach2" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d640282b302c0bb0a2a8e0233ead9035e3bed871f0b7e81fe4a1ec829765db44" +dependencies = [ + "libc", +] + [[package]] name = "mainline" version = "5.4.0" @@ -2948,6 +3035,17 @@ dependencies = [ "tempfile", ] +[[package]] +name = "nix" +version = "0.26.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "598beaf3cc6fdd9a5dfb1630c2800c7acd31df7aaf0f565796fba2b53ca1af1b" +dependencies = [ + "bitflags 1.3.2", + "cfg-if", + "libc", +] + [[package]] name = "nom" version = "7.1.3" @@ -4595,6 +4693,24 @@ dependencies = [ "syn 2.0.117", ] +[[package]] +name = "serialport" +version = "4.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a2f4ac56b5d3af3c40fbbee17be96d532cba02fa5853926aacdb77d926272ab" +dependencies = [ + "bitflags 2.11.0", + "cfg-if", + "core-foundation", + "core-foundation-sys", + "io-kit-sys", + "mach2", + "nix", + "scopeguard", + "unescaper", + "windows-sys 0.52.0", +] + [[package]] name = "sha1" version = "0.10.6" @@ -5342,6 +5458,15 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "562d481066bde0658276a35467c4af00bdc6ee726305698a55b86e61d7ad82bb" +[[package]] +name = "unescaper" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7285e83a80ce76f5e7bce79fa41f68d78ba62d1003cf27bf748ab24413808cf4" +dependencies = [ + "thiserror 2.0.18", +] + [[package]] name = "unicode-ident" version = "1.0.24" diff --git a/Cargo.toml b/Cargo.toml index 4a24f98..6d04713 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bitkitcore" -version = "0.5.14" +version = "0.5.15" edition = "2021" [lib] @@ -12,7 +12,7 @@ path = "src/lib.rs" uniffi = { version = "0.29.4", features = [ "cli", "bindgen" ] } serde_json = "1.0.114" serde = { version = "^1.0.209", features = ["derive"] } -tokio = { version = "1.40.0", features = ["rt", "rt-multi-thread", "macros"] } +tokio = { version = "1.40.0", features = ["rt", "rt-multi-thread", "macros", "time", "sync"] } bitcoin = "0.32.4" miniscript = "12.3.7" chrono = "0.4" @@ -62,6 +62,16 @@ trezor-connect-rs = { version = "0.4.0", default-features = false, features = [" jni = "0.19" android_logger = "0.14" +# Jade hardware wallet protocol. Bluetooth is driven by the native application +# through JadeTransportCallback, so the crate's own serial transport is only +# wanted where a Rust side serial port makes sense. +[target.'cfg(any(target_os = "ios", target_os = "android"))'.dependencies] +jade-client-rs = { git = "https://github.com/coreyphillips/jade-client-rs", rev = "247c22f", default-features = false, features = ["reqwest-pinserver"] } + +# Desktop and Python additionally get the crate's serial transport. +[target.'cfg(not(any(target_os = "ios", target_os = "android")))'.dependencies] +jade-client-rs = { git = "https://github.com/coreyphillips/jade-client-rs", rev = "247c22f", features = ["reqwest-pinserver", "serial"] } + [dev-dependencies] tokio = { version = "1.40.0", features = ["full"] } serde_json = "1.0.114" diff --git a/Package.swift b/Package.swift index 18395bb..808605a 100644 --- a/Package.swift +++ b/Package.swift @@ -3,8 +3,8 @@ import PackageDescription -let tag = "v0.5.14" -let checksum = "2e5d3a3e263d2de044c3d5b9a9ddcc789c8cf651b6bbd240fb7fe407b5e9be84" +let tag = "v0.5.15" +let checksum = "cd1435fa84b34f85cdafc1e71e8a5620e087b5d89af69e86f98110942b528bc2" let url = "https://github.com/synonymdev/bitkit-core/releases/download/\(tag)/BitkitCore.xcframework.zip" let package = Package( diff --git a/bindings/android/gradle.properties b/bindings/android/gradle.properties index 8c3a0e2..e46869a 100644 --- a/bindings/android/gradle.properties +++ b/bindings/android/gradle.properties @@ -3,4 +3,4 @@ android.useAndroidX=true android.enableJetifier=true kotlin.code.style=official group=com.synonym -version=0.5.14 +version=0.5.15 diff --git a/bindings/android/lib/src/main/kotlin/com/synonym/bitkitcore/bitkitcore.android.kt b/bindings/android/lib/src/main/kotlin/com/synonym/bitkitcore/bitkitcore.android.kt index f4056c5..fe50011 100644 --- a/bindings/android/lib/src/main/kotlin/com/synonym/bitkitcore/bitkitcore.android.kt +++ b/bindings/android/lib/src/main/kotlin/com/synonym/bitkitcore/bitkitcore.android.kt @@ -904,6 +904,24 @@ internal interface UniffiCallbackInterfaceBoltzEventListenerMethod0: com.sun.jna internal interface UniffiCallbackInterfaceEventListenerMethod0: com.sun.jna.Callback { public fun callback(`uniffiHandle`: Long,`watcherId`: RustBufferByValue,`event`: RustBufferByValue,`uniffiOutReturn`: Pointer,uniffiCallStatus: UniffiRustCallStatus,) } +internal interface UniffiCallbackInterfaceJadeTransportCallbackMethod0: com.sun.jna.Callback { + public fun callback(`uniffiHandle`: Long,`timeoutMs`: Int,`uniffiOutReturn`: RustBuffer,uniffiCallStatus: UniffiRustCallStatus,) +} +internal interface UniffiCallbackInterfaceJadeTransportCallbackMethod1: com.sun.jna.Callback { + public fun callback(`uniffiHandle`: Long,`path`: RustBufferByValue,`uniffiOutReturn`: RustBuffer,uniffiCallStatus: UniffiRustCallStatus,) +} +internal interface UniffiCallbackInterfaceJadeTransportCallbackMethod2: com.sun.jna.Callback { + public fun callback(`uniffiHandle`: Long,`path`: RustBufferByValue,`uniffiOutReturn`: RustBuffer,uniffiCallStatus: UniffiRustCallStatus,) +} +internal interface UniffiCallbackInterfaceJadeTransportCallbackMethod3: com.sun.jna.Callback { + public fun callback(`uniffiHandle`: Long,`path`: RustBufferByValue,`data`: RustBufferByValue,`uniffiOutReturn`: RustBuffer,uniffiCallStatus: UniffiRustCallStatus,) +} +internal interface UniffiCallbackInterfaceJadeTransportCallbackMethod4: com.sun.jna.Callback { + public fun callback(`uniffiHandle`: Long,`path`: RustBufferByValue,`timeoutMs`: Int,`uniffiOutReturn`: RustBuffer,uniffiCallStatus: UniffiRustCallStatus,) +} +internal interface UniffiCallbackInterfaceJadeTransportCallbackMethod5: com.sun.jna.Callback { + public fun callback(`uniffiHandle`: Long,`path`: RustBufferByValue,`uniffiOutReturn`: IntByReference,uniffiCallStatus: UniffiRustCallStatus,) +} internal interface UniffiCallbackInterfaceTrezorTransportCallbackMethod0: com.sun.jna.Callback { public fun callback(`uniffiHandle`: Long,`uniffiOutReturn`: RustBuffer,uniffiCallStatus: UniffiRustCallStatus,) } @@ -1005,6 +1023,67 @@ internal fun UniffiVTableCallbackInterfaceEventListener.uniffiSetValue(other: Un } internal typealias UniffiVTableCallbackInterfaceEventListenerUniffiByValue = UniffiVTableCallbackInterfaceEventListenerStruct.UniffiByValue +@Structure.FieldOrder("scanDevices", "openDevice", "closeDevice", "writeChunk", "readChunk", "getChunkSize", "uniffiFree") +internal open class UniffiVTableCallbackInterfaceJadeTransportCallbackStruct( + @JvmField public var `scanDevices`: UniffiCallbackInterfaceJadeTransportCallbackMethod0?, + @JvmField public var `openDevice`: UniffiCallbackInterfaceJadeTransportCallbackMethod1?, + @JvmField public var `closeDevice`: UniffiCallbackInterfaceJadeTransportCallbackMethod2?, + @JvmField public var `writeChunk`: UniffiCallbackInterfaceJadeTransportCallbackMethod3?, + @JvmField public var `readChunk`: UniffiCallbackInterfaceJadeTransportCallbackMethod4?, + @JvmField public var `getChunkSize`: UniffiCallbackInterfaceJadeTransportCallbackMethod5?, + @JvmField public var `uniffiFree`: UniffiCallbackInterfaceFree?, +) : com.sun.jna.Structure() { + internal constructor(): this( + + `scanDevices` = null, + + `openDevice` = null, + + `closeDevice` = null, + + `writeChunk` = null, + + `readChunk` = null, + + `getChunkSize` = null, + + `uniffiFree` = null, + + ) + + internal class UniffiByValue( + `scanDevices`: UniffiCallbackInterfaceJadeTransportCallbackMethod0?, + `openDevice`: UniffiCallbackInterfaceJadeTransportCallbackMethod1?, + `closeDevice`: UniffiCallbackInterfaceJadeTransportCallbackMethod2?, + `writeChunk`: UniffiCallbackInterfaceJadeTransportCallbackMethod3?, + `readChunk`: UniffiCallbackInterfaceJadeTransportCallbackMethod4?, + `getChunkSize`: UniffiCallbackInterfaceJadeTransportCallbackMethod5?, + `uniffiFree`: UniffiCallbackInterfaceFree?, + ): UniffiVTableCallbackInterfaceJadeTransportCallback(`scanDevices`,`openDevice`,`closeDevice`,`writeChunk`,`readChunk`,`getChunkSize`,`uniffiFree`,), Structure.ByValue +} + +internal typealias UniffiVTableCallbackInterfaceJadeTransportCallback = UniffiVTableCallbackInterfaceJadeTransportCallbackStruct + +internal fun UniffiVTableCallbackInterfaceJadeTransportCallback.uniffiSetValue(other: UniffiVTableCallbackInterfaceJadeTransportCallback) { + `scanDevices` = other.`scanDevices` + `openDevice` = other.`openDevice` + `closeDevice` = other.`closeDevice` + `writeChunk` = other.`writeChunk` + `readChunk` = other.`readChunk` + `getChunkSize` = other.`getChunkSize` + `uniffiFree` = other.`uniffiFree` +} +internal fun UniffiVTableCallbackInterfaceJadeTransportCallback.uniffiSetValue(other: UniffiVTableCallbackInterfaceJadeTransportCallbackUniffiByValue) { + `scanDevices` = other.`scanDevices` + `openDevice` = other.`openDevice` + `closeDevice` = other.`closeDevice` + `writeChunk` = other.`writeChunk` + `readChunk` = other.`readChunk` + `getChunkSize` = other.`getChunkSize` + `uniffiFree` = other.`uniffiFree` +} + +internal typealias UniffiVTableCallbackInterfaceJadeTransportCallbackUniffiByValue = UniffiVTableCallbackInterfaceJadeTransportCallbackStruct.UniffiByValue @Structure.FieldOrder("enumerateDevices", "openDevice", "closeDevice", "readChunk", "writeChunk", "getChunkSize", "callMessage", "getPairingCode", "saveThpCredential", "loadThpCredential", "logDebug", "uniffiFree") internal open class UniffiVTableCallbackInterfaceTrezorTransportCallbackStruct( @JvmField public var `enumerateDevices`: UniffiCallbackInterfaceTrezorTransportCallbackMethod0?, @@ -1582,6 +1661,63 @@ internal typealias UniffiVTableCallbackInterfaceTrezorUiCallbackUniffiByValue = + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1909,6 +2045,69 @@ internal object IntegrityCheckingUniffiLib : Library { if (uniffi_bitkitcore_checksum_func_is_valid_bip39_word() != 31846) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } + if (uniffi_bitkitcore_checksum_func_jade_account_type_to_variant() != 35222) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (uniffi_bitkitcore_checksum_func_jade_cancel() != 64344) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (uniffi_bitkitcore_checksum_func_jade_connect() != 62038) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (uniffi_bitkitcore_checksum_func_jade_disconnect() != 22575) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (uniffi_bitkitcore_checksum_func_jade_get_account_export() != 39143) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (uniffi_bitkitcore_checksum_func_jade_get_connected_device() != 31749) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (uniffi_bitkitcore_checksum_func_jade_get_master_fingerprint() != 29630) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (uniffi_bitkitcore_checksum_func_jade_get_version_info() != 28653) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (uniffi_bitkitcore_checksum_func_jade_get_xpub() != 51180) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (uniffi_bitkitcore_checksum_func_jade_is_connected() != 16304) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (uniffi_bitkitcore_checksum_func_jade_list_devices() != 31161) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (uniffi_bitkitcore_checksum_func_jade_logout() != 2301) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (uniffi_bitkitcore_checksum_func_jade_notify_disconnected() != 24935) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (uniffi_bitkitcore_checksum_func_jade_ping() != 45620) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (uniffi_bitkitcore_checksum_func_jade_refresh_version_info() != 52539) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (uniffi_bitkitcore_checksum_func_jade_scan() != 445) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (uniffi_bitkitcore_checksum_func_jade_set_transport_callback() != 61572) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (uniffi_bitkitcore_checksum_func_jade_sign_message() != 257) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (uniffi_bitkitcore_checksum_func_jade_sign_psbt() != 20865) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (uniffi_bitkitcore_checksum_func_jade_unlock() != 35535) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (uniffi_bitkitcore_checksum_func_jade_verify_address() != 54249) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } if (uniffi_bitkitcore_checksum_func_lnurl_auth() != 58593) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } @@ -2191,6 +2390,24 @@ internal object IntegrityCheckingUniffiLib : Library { if (uniffi_bitkitcore_checksum_method_eventlistener_on_event() != 35531) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } + if (uniffi_bitkitcore_checksum_method_jadetransportcallback_scan_devices() != 38147) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (uniffi_bitkitcore_checksum_method_jadetransportcallback_open_device() != 21299) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (uniffi_bitkitcore_checksum_method_jadetransportcallback_close_device() != 16955) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (uniffi_bitkitcore_checksum_method_jadetransportcallback_write_chunk() != 12779) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (uniffi_bitkitcore_checksum_method_jadetransportcallback_read_chunk() != 21790) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (uniffi_bitkitcore_checksum_method_jadetransportcallback_get_chunk_size() != 29973) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } if (uniffi_bitkitcore_checksum_method_trezortransportcallback_enumerate_devices() != 18766) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } @@ -2510,6 +2727,69 @@ internal object IntegrityCheckingUniffiLib : Library { external fun uniffi_bitkitcore_checksum_func_is_valid_bip39_word( ): Int @JvmStatic + external fun uniffi_bitkitcore_checksum_func_jade_account_type_to_variant( + ): Int + @JvmStatic + external fun uniffi_bitkitcore_checksum_func_jade_cancel( + ): Int + @JvmStatic + external fun uniffi_bitkitcore_checksum_func_jade_connect( + ): Int + @JvmStatic + external fun uniffi_bitkitcore_checksum_func_jade_disconnect( + ): Int + @JvmStatic + external fun uniffi_bitkitcore_checksum_func_jade_get_account_export( + ): Int + @JvmStatic + external fun uniffi_bitkitcore_checksum_func_jade_get_connected_device( + ): Int + @JvmStatic + external fun uniffi_bitkitcore_checksum_func_jade_get_master_fingerprint( + ): Int + @JvmStatic + external fun uniffi_bitkitcore_checksum_func_jade_get_version_info( + ): Int + @JvmStatic + external fun uniffi_bitkitcore_checksum_func_jade_get_xpub( + ): Int + @JvmStatic + external fun uniffi_bitkitcore_checksum_func_jade_is_connected( + ): Int + @JvmStatic + external fun uniffi_bitkitcore_checksum_func_jade_list_devices( + ): Int + @JvmStatic + external fun uniffi_bitkitcore_checksum_func_jade_logout( + ): Int + @JvmStatic + external fun uniffi_bitkitcore_checksum_func_jade_notify_disconnected( + ): Int + @JvmStatic + external fun uniffi_bitkitcore_checksum_func_jade_ping( + ): Int + @JvmStatic + external fun uniffi_bitkitcore_checksum_func_jade_refresh_version_info( + ): Int + @JvmStatic + external fun uniffi_bitkitcore_checksum_func_jade_scan( + ): Int + @JvmStatic + external fun uniffi_bitkitcore_checksum_func_jade_set_transport_callback( + ): Int + @JvmStatic + external fun uniffi_bitkitcore_checksum_func_jade_sign_message( + ): Int + @JvmStatic + external fun uniffi_bitkitcore_checksum_func_jade_sign_psbt( + ): Int + @JvmStatic + external fun uniffi_bitkitcore_checksum_func_jade_unlock( + ): Int + @JvmStatic + external fun uniffi_bitkitcore_checksum_func_jade_verify_address( + ): Int + @JvmStatic external fun uniffi_bitkitcore_checksum_func_lnurl_auth( ): Int @JvmStatic @@ -2792,6 +3072,24 @@ internal object IntegrityCheckingUniffiLib : Library { external fun uniffi_bitkitcore_checksum_method_eventlistener_on_event( ): Int @JvmStatic + external fun uniffi_bitkitcore_checksum_method_jadetransportcallback_scan_devices( + ): Int + @JvmStatic + external fun uniffi_bitkitcore_checksum_method_jadetransportcallback_open_device( + ): Int + @JvmStatic + external fun uniffi_bitkitcore_checksum_method_jadetransportcallback_close_device( + ): Int + @JvmStatic + external fun uniffi_bitkitcore_checksum_method_jadetransportcallback_write_chunk( + ): Int + @JvmStatic + external fun uniffi_bitkitcore_checksum_method_jadetransportcallback_read_chunk( + ): Int + @JvmStatic + external fun uniffi_bitkitcore_checksum_method_jadetransportcallback_get_chunk_size( + ): Int + @JvmStatic external fun uniffi_bitkitcore_checksum_method_trezortransportcallback_enumerate_devices( ): Int @JvmStatic @@ -2855,6 +3153,7 @@ internal object UniffiLib : Library { // we already did that with `IntegrityCheckingUniffiLib` above. uniffiCallbackInterfaceBoltzEventListener.register(this) uniffiCallbackInterfaceEventListener.register(this) + uniffiCallbackInterfaceJadeTransportCallback.register(this) uniffiCallbackInterfaceTrezorTransportCallback.register(this) uniffiCallbackInterfaceTrezorUiCallback.register(this) } @@ -2904,6 +3203,58 @@ internal object UniffiLib : Library { uniffiCallStatus: UniffiRustCallStatus, ): Unit @JvmStatic + external fun uniffi_bitkitcore_fn_clone_jadetransportcallback( + `ptr`: Pointer?, + uniffiCallStatus: UniffiRustCallStatus, + ): Pointer? + @JvmStatic + external fun uniffi_bitkitcore_fn_free_jadetransportcallback( + `ptr`: Pointer?, + uniffiCallStatus: UniffiRustCallStatus, + ): Unit + @JvmStatic + external fun uniffi_bitkitcore_fn_init_callback_vtable_jadetransportcallback( + `vtable`: UniffiVTableCallbackInterfaceJadeTransportCallback, + ): Unit + @JvmStatic + external fun uniffi_bitkitcore_fn_method_jadetransportcallback_scan_devices( + `ptr`: Pointer?, + `timeoutMs`: Int, + uniffiCallStatus: UniffiRustCallStatus, + ): RustBufferByValue + @JvmStatic + external fun uniffi_bitkitcore_fn_method_jadetransportcallback_open_device( + `ptr`: Pointer?, + `path`: RustBufferByValue, + uniffiCallStatus: UniffiRustCallStatus, + ): RustBufferByValue + @JvmStatic + external fun uniffi_bitkitcore_fn_method_jadetransportcallback_close_device( + `ptr`: Pointer?, + `path`: RustBufferByValue, + uniffiCallStatus: UniffiRustCallStatus, + ): RustBufferByValue + @JvmStatic + external fun uniffi_bitkitcore_fn_method_jadetransportcallback_write_chunk( + `ptr`: Pointer?, + `path`: RustBufferByValue, + `data`: RustBufferByValue, + uniffiCallStatus: UniffiRustCallStatus, + ): RustBufferByValue + @JvmStatic + external fun uniffi_bitkitcore_fn_method_jadetransportcallback_read_chunk( + `ptr`: Pointer?, + `path`: RustBufferByValue, + `timeoutMs`: Int, + uniffiCallStatus: UniffiRustCallStatus, + ): RustBufferByValue + @JvmStatic + external fun uniffi_bitkitcore_fn_method_jadetransportcallback_get_chunk_size( + `ptr`: Pointer?, + `path`: RustBufferByValue, + uniffiCallStatus: UniffiRustCallStatus, + ): Int + @JvmStatic external fun uniffi_bitkitcore_fn_clone_trezortransportcallback( `ptr`: Pointer?, uniffiCallStatus: UniffiRustCallStatus, @@ -3524,8 +3875,96 @@ internal object UniffiLib : Library { uniffiCallStatus: UniffiRustCallStatus, ): Byte @JvmStatic - external fun uniffi_bitkitcore_fn_func_lnurl_auth( - `domain`: RustBufferByValue, + external fun uniffi_bitkitcore_fn_func_jade_account_type_to_variant( + `accountType`: RustBufferByValue, + uniffiCallStatus: UniffiRustCallStatus, + ): RustBufferByValue + @JvmStatic + external fun uniffi_bitkitcore_fn_func_jade_cancel( + ): Long + @JvmStatic + external fun uniffi_bitkitcore_fn_func_jade_connect( + `transport`: RustBufferByValue, + `path`: RustBufferByValue, + ): Long + @JvmStatic + external fun uniffi_bitkitcore_fn_func_jade_disconnect( + ): Long + @JvmStatic + external fun uniffi_bitkitcore_fn_func_jade_get_account_export( + `network`: RustBufferByValue, + `accountIndex`: Int, + `accountTypes`: RustBufferByValue, + ): Long + @JvmStatic + external fun uniffi_bitkitcore_fn_func_jade_get_connected_device( + ): Long + @JvmStatic + external fun uniffi_bitkitcore_fn_func_jade_get_master_fingerprint( + `network`: RustBufferByValue, + ): Long + @JvmStatic + external fun uniffi_bitkitcore_fn_func_jade_get_version_info( + ): Long + @JvmStatic + external fun uniffi_bitkitcore_fn_func_jade_get_xpub( + `network`: RustBufferByValue, + `derivationPath`: RustBufferByValue, + ): Long + @JvmStatic + external fun uniffi_bitkitcore_fn_func_jade_is_connected( + uniffiCallStatus: UniffiRustCallStatus, + ): Byte + @JvmStatic + external fun uniffi_bitkitcore_fn_func_jade_list_devices( + ): Long + @JvmStatic + external fun uniffi_bitkitcore_fn_func_jade_logout( + ): Long + @JvmStatic + external fun uniffi_bitkitcore_fn_func_jade_notify_disconnected( + `path`: RustBufferByValue, + ): Long + @JvmStatic + external fun uniffi_bitkitcore_fn_func_jade_ping( + ): Long + @JvmStatic + external fun uniffi_bitkitcore_fn_func_jade_refresh_version_info( + ): Long + @JvmStatic + external fun uniffi_bitkitcore_fn_func_jade_scan( + `timeoutMs`: Int, + ): Long + @JvmStatic + external fun uniffi_bitkitcore_fn_func_jade_set_transport_callback( + `callback`: Pointer?, + uniffiCallStatus: UniffiRustCallStatus, + ): Byte + @JvmStatic + external fun uniffi_bitkitcore_fn_func_jade_sign_message( + `network`: RustBufferByValue, + `derivationPath`: RustBufferByValue, + `message`: RustBufferByValue, + ): Long + @JvmStatic + external fun uniffi_bitkitcore_fn_func_jade_sign_psbt( + `network`: RustBufferByValue, + `psbt`: RustBufferByValue, + ): Long + @JvmStatic + external fun uniffi_bitkitcore_fn_func_jade_unlock( + `network`: RustBufferByValue, + ): Long + @JvmStatic + external fun uniffi_bitkitcore_fn_func_jade_verify_address( + `network`: RustBufferByValue, + `variant`: RustBufferByValue, + `derivationPath`: RustBufferByValue, + `expectedAddress`: RustBufferByValue, + ): Long + @JvmStatic + external fun uniffi_bitkitcore_fn_func_lnurl_auth( + `domain`: RustBufferByValue, `k1`: RustBufferByValue, `callback`: RustBufferByValue, `bip32Mnemonic`: RustBufferByValue, @@ -4965,28 +5404,31 @@ internal object uniffiCallbackInterfaceEventListener { /** - * Callback interface for native Trezor transport operations + * Native transport for Jade. * - * This trait must be implemented by the native iOS/Android code. - * The implementation handles actual USB or Bluetooth communication. + * # Bluetooth contract * - * # Android Implementation - * Use Android USB Host API for USB devices: - * - Enumerate devices with vendorId 0x1209 (0x534c for older), productId 0x53c1 - * - Request USB permission, claim interface, get endpoints - * - Chunk size: 64 bytes for USB + * Jade advertises the Nordic UART Service: * - * Use Android BLE API for Bluetooth: - * - Scan for Trezor BLE service UUID: 8c000001-a59b-4d58-a9ad-073df69fa1b1 - * - Connect and discover characteristics - * - Read from: 8c000002-a59b-4d58-a9ad-073df69fa1b1 - * - Write to: 8c000003-a59b-4d58-a9ad-073df69fa1b1 - * - Chunk size: 244 bytes for BLE + * - service `6e400001-b5a3-f393-e0a9-e50e24dcca9e` + * - write `6e400002-b5a3-f393-e0a9-e50e24dcca9e` (host to Jade) + * - notify `6e400003-b5a3-f393-e0a9-e50e24dcca9e` (Jade to host) * - * # iOS Implementation - * Use IOKit/CoreBluetooth with same service/characteristic UUIDs. + * Devices advertise as "Jade" or "Jade ". + * + * Three requirements that are easy to miss and break signing on real hardware: + * + * 1. **Write with response.** Write-without-response silently drops chunks on + * the ESP32 GATT stack. + * 2. **Do not pause between chunks.** Firmware discards a partially received + * message after two seconds of silence, three on Jade v1, and answers with + * an unattributed error. A 30 KB PSBT is roughly 60 writes, so any UI thread + * stall in the middle of a send breaks the operation. + * 3. **`read_chunk` must return promptly.** Honour `timeout_ms`, which this + * crate keeps short. The long per-operation deadline is enforced in Rust so + * the user can cancel. */ -public open class TrezorTransportCallbackImpl: Disposable, TrezorTransportCallback { +public open class JadeTransportCallbackImpl: Disposable, JadeTransportCallback { public constructor(pointer: Pointer) { this.pointer = pointer @@ -5064,7 +5506,7 @@ public open class TrezorTransportCallbackImpl: Disposable, TrezorTransportCallba override fun destroy() { pointer?.let { ptr -> uniffiRustCall { status -> - UniffiLib.uniffi_bitkitcore_fn_free_trezortransportcallback(ptr, status) + UniffiLib.uniffi_bitkitcore_fn_free_jadetransportcallback(ptr, status) } } } @@ -5072,34 +5514,20 @@ public open class TrezorTransportCallbackImpl: Disposable, TrezorTransportCallba public fun uniffiClonePointer(): Pointer { return uniffiRustCall { status -> - UniffiLib.uniffi_bitkitcore_fn_clone_trezortransportcallback(pointer!!, status) + UniffiLib.uniffi_bitkitcore_fn_clone_jadetransportcallback(pointer!!, status) }!! } /** - * Enumerate all connected Trezor devices - */ - public override fun `enumerateDevices`(): List { - return FfiConverterSequenceTypeNativeDeviceInfo.lift(callWithPointer { - uniffiRustCall { uniffiRustCallStatus -> - UniffiLib.uniffi_bitkitcore_fn_method_trezortransportcallback_enumerate_devices( - it, - uniffiRustCallStatus, - ) - } - }) - } - - /** - * Open a connection to a device + * Discover devices, blocking up to `timeout_ms`. */ - public override fun `openDevice`(`path`: kotlin.String): TrezorTransportWriteResult { - return FfiConverterTypeTrezorTransportWriteResult.lift(callWithPointer { + public override fun `scanDevices`(`timeoutMs`: kotlin.UInt): List { + return FfiConverterSequenceTypeJadeNativeDevice.lift(callWithPointer { uniffiRustCall { uniffiRustCallStatus -> - UniffiLib.uniffi_bitkitcore_fn_method_trezortransportcallback_open_device( + UniffiLib.uniffi_bitkitcore_fn_method_jadetransportcallback_scan_devices( it, - FfiConverterString.lower(`path`), + FfiConverterUInt.lower(`timeoutMs`), uniffiRustCallStatus, ) } @@ -5107,12 +5535,12 @@ public open class TrezorTransportCallbackImpl: Disposable, TrezorTransportCallba } /** - * Close the connection to a device + * Open a connection and enable notifications. */ - public override fun `closeDevice`(`path`: kotlin.String): TrezorTransportWriteResult { - return FfiConverterTypeTrezorTransportWriteResult.lift(callWithPointer { + public override fun `openDevice`(`path`: kotlin.String): JadeTransportResult { + return FfiConverterTypeJadeTransportResult.lift(callWithPointer { uniffiRustCall { uniffiRustCallStatus -> - UniffiLib.uniffi_bitkitcore_fn_method_trezortransportcallback_close_device( + UniffiLib.uniffi_bitkitcore_fn_method_jadetransportcallback_open_device( it, FfiConverterString.lower(`path`), uniffiRustCallStatus, @@ -5122,12 +5550,12 @@ public open class TrezorTransportCallbackImpl: Disposable, TrezorTransportCallba } /** - * Read a chunk of data from the device + * Close the connection and release the device. */ - public override fun `readChunk`(`path`: kotlin.String): TrezorTransportReadResult { - return FfiConverterTypeTrezorTransportReadResult.lift(callWithPointer { + public override fun `closeDevice`(`path`: kotlin.String): JadeTransportResult { + return FfiConverterTypeJadeTransportResult.lift(callWithPointer { uniffiRustCall { uniffiRustCallStatus -> - UniffiLib.uniffi_bitkitcore_fn_method_trezortransportcallback_read_chunk( + UniffiLib.uniffi_bitkitcore_fn_method_jadetransportcallback_close_device( it, FfiConverterString.lower(`path`), uniffiRustCallStatus, @@ -5137,12 +5565,12 @@ public open class TrezorTransportCallbackImpl: Disposable, TrezorTransportCallba } /** - * Write a chunk of data to the device + * Write one chunk, no larger than `get_chunk_size`. */ - public override fun `writeChunk`(`path`: kotlin.String, `data`: kotlin.ByteArray): TrezorTransportWriteResult { - return FfiConverterTypeTrezorTransportWriteResult.lift(callWithPointer { + public override fun `writeChunk`(`path`: kotlin.String, `data`: kotlin.ByteArray): JadeTransportResult { + return FfiConverterTypeJadeTransportResult.lift(callWithPointer { uniffiRustCall { uniffiRustCallStatus -> - UniffiLib.uniffi_bitkitcore_fn_method_trezortransportcallback_write_chunk( + UniffiLib.uniffi_bitkitcore_fn_method_jadetransportcallback_write_chunk( it, FfiConverterString.lower(`path`), FfiConverterByteArray.lower(`data`), @@ -5153,90 +5581,17 @@ public open class TrezorTransportCallbackImpl: Disposable, TrezorTransportCallba } /** - * Get the chunk size for a device (64 for USB, 244 for Bluetooth) - */ - public override fun `getChunkSize`(`path`: kotlin.String): kotlin.UInt { - return FfiConverterUInt.lift(callWithPointer { - uniffiRustCall { uniffiRustCallStatus -> - UniffiLib.uniffi_bitkitcore_fn_method_trezortransportcallback_get_chunk_size( - it, - FfiConverterString.lower(`path`), - uniffiRustCallStatus, - ) - } - }) - } - - /** - * High-level message call for BLE/THP devices. - * - * For BLE devices that use THP protocol (encrypted communication), - * the native layer should handle encryption/decryption via - * android-trezor-connect and return the raw protobuf response. - * - * Returns None if not supported (will fall back to Protocol V1 chunks). - * Returns Some(result) to use native THP handling. + * Read whatever has arrived, waiting at most `timeout_ms`. * - * # Arguments - * * `path` - Device path - * * `message_type` - Protobuf message type (e.g., GetAddress = 29) - * * `data` - Serialized protobuf message data + * Returning success with an empty vector is normal and means "nothing yet". */ - public override fun `callMessage`(`path`: kotlin.String, `messageType`: kotlin.UShort, `data`: kotlin.ByteArray): TrezorCallMessageResult? { - return FfiConverterOptionalTypeTrezorCallMessageResult.lift(callWithPointer { + public override fun `readChunk`(`path`: kotlin.String, `timeoutMs`: kotlin.UInt): JadeTransportReadResult { + return FfiConverterTypeJadeTransportReadResult.lift(callWithPointer { uniffiRustCall { uniffiRustCallStatus -> - UniffiLib.uniffi_bitkitcore_fn_method_trezortransportcallback_call_message( + UniffiLib.uniffi_bitkitcore_fn_method_jadetransportcallback_read_chunk( it, FfiConverterString.lower(`path`), - FfiConverterUShort.lower(`messageType`), - FfiConverterByteArray.lower(`data`), - uniffiRustCallStatus, - ) - } - }) - } - - /** - * Get pairing code from user during BLE THP pairing. - * - * This is called when the Trezor device displays a 6-digit code - * that must be entered to complete Bluetooth pairing. - * - * The native layer should display a UI for the user to enter the code - * shown on the Trezor screen. - * - * Returns the 6-digit code as a string, or empty string to cancel. - */ - public override fun `getPairingCode`(): kotlin.String { - return FfiConverterString.lift(callWithPointer { - uniffiRustCall { uniffiRustCallStatus -> - UniffiLib.uniffi_bitkitcore_fn_method_trezortransportcallback_get_pairing_code( - it, - uniffiRustCallStatus, - ) - } - }) - } - - /** - * Save THP pairing credentials for a device. - * - * Called after successful BLE pairing to store credentials for reconnection. - * The credential_json is a JSON string containing the serialized ThpCredentials. - * - * # Arguments - * * `device_id` - Device identifier (e.g., BLE address like "ble:AA:BB:CC:DD:EE:FF") - * * `credential_json` - JSON string with credential data - * - * Returns true if credentials were saved successfully. - */ - public override fun `saveThpCredential`(`deviceId`: kotlin.String, `credentialJson`: kotlin.String): kotlin.Boolean { - return FfiConverterBoolean.lift(callWithPointer { - uniffiRustCall { uniffiRustCallStatus -> - UniffiLib.uniffi_bitkitcore_fn_method_trezortransportcallback_save_thp_credential( - it, - FfiConverterString.lower(`deviceId`), - FfiConverterString.lower(`credentialJson`), + FfiConverterUInt.lower(`timeoutMs`), uniffiRustCallStatus, ) } @@ -5244,52 +5599,23 @@ public open class TrezorTransportCallbackImpl: Disposable, TrezorTransportCallba } /** - * Load THP pairing credentials for a device. - * - * Called before BLE handshake to check for stored credentials. - * If credentials are found, they will be used to skip the pairing dialog. + * Maximum bytes per write. * - * # Arguments - * * `device_id` - Device identifier (e.g., BLE address like "ble:AA:BB:CC:DD:EE:FF") - * - * Returns the JSON string containing ThpCredentials, or None if not found. + * For Bluetooth this is `min(negotiated_mtu - 3, 509)`. The value is + * clamped into a usable range, so an unnegotiated `0` is not fatal. */ - public override fun `loadThpCredential`(`deviceId`: kotlin.String): kotlin.String? { - return FfiConverterOptionalString.lift(callWithPointer { + public override fun `getChunkSize`(`path`: kotlin.String): kotlin.UInt { + return FfiConverterUInt.lift(callWithPointer { uniffiRustCall { uniffiRustCallStatus -> - UniffiLib.uniffi_bitkitcore_fn_method_trezortransportcallback_load_thp_credential( + UniffiLib.uniffi_bitkitcore_fn_method_jadetransportcallback_get_chunk_size( it, - FfiConverterString.lower(`deviceId`), + FfiConverterString.lower(`path`), uniffiRustCallStatus, ) } }) } - /** - * Log a debug message from the Rust THP handshake layer. - * - * This forwards Rust-level errors and state information to the native - * debug UI (e.g., TrezorDebugLog on Android) so they are visible - * alongside the Kotlin-level logs. - * - * # Arguments - * * `tag` - Short tag identifying the subsystem (e.g., "HANDSHAKE", "THP") - * * `message` - Human-readable debug message - */ - public override fun `logDebug`(`tag`: kotlin.String, `message`: kotlin.String) { - callWithPointer { - uniffiRustCall { uniffiRustCallStatus -> - UniffiLib.uniffi_bitkitcore_fn_method_trezortransportcallback_log_debug( - it, - FfiConverterString.lower(`tag`), - FfiConverterString.lower(`message`), - uniffiRustCallStatus, - ) - } - } - } - @@ -5304,26 +5630,26 @@ public open class TrezorTransportCallbackImpl: Disposable, TrezorTransportCallba -public object FfiConverterTypeTrezorTransportCallback: FfiConverter { - internal val handleMap = UniffiHandleMap() +public object FfiConverterTypeJadeTransportCallback: FfiConverter { + internal val handleMap = UniffiHandleMap() - override fun lower(value: TrezorTransportCallback): Pointer { + override fun lower(value: JadeTransportCallback): Pointer { return handleMap.insert(value).toPointer() } - override fun lift(value: Pointer): TrezorTransportCallback { - return TrezorTransportCallbackImpl(value) + override fun lift(value: Pointer): JadeTransportCallback { + return JadeTransportCallbackImpl(value) } - override fun read(buf: ByteBuffer): TrezorTransportCallback { + override fun read(buf: ByteBuffer): JadeTransportCallback { // The Rust code always writes pointers as 8 bytes, and will // fail to compile if they don't fit. return lift(buf.getLong().toPointer()) } - override fun allocationSize(value: TrezorTransportCallback): ULong = 8UL + override fun allocationSize(value: JadeTransportCallback): ULong = 8UL - override fun write(value: TrezorTransportCallback, buf: ByteBuffer) { + override fun write(value: JadeTransportCallback, buf: ByteBuffer) { // The Rust code always expects pointers written as 8 bytes, // and will fail to compile if they don't fit. buf.putLong(lower(value).toLong()) @@ -5332,110 +5658,114 @@ public object FfiConverterTypeTrezorTransportCallback: FfiConverter - uniffiObj.`enumerateDevices`( + uniffiObj.`scanDevices`( + FfiConverterUInt.lift(`timeoutMs`), ) } - val writeReturn = { uniffiResultValue: List -> - uniffiOutReturn.setValue(FfiConverterSequenceTypeNativeDeviceInfo.lower(uniffiResultValue)) + val writeReturn = { uniffiResultValue: List -> + uniffiOutReturn.setValue(FfiConverterSequenceTypeJadeNativeDevice.lower(uniffiResultValue)) } uniffiTraitInterfaceCall(uniffiCallStatus, makeCall, writeReturn) } } - internal object `openDevice`: UniffiCallbackInterfaceTrezorTransportCallbackMethod1 { + internal object `openDevice`: UniffiCallbackInterfaceJadeTransportCallbackMethod1 { override fun callback ( `uniffiHandle`: Long, `path`: RustBufferByValue, `uniffiOutReturn`: RustBuffer, uniffiCallStatus: UniffiRustCallStatus, ) { - val uniffiObj = FfiConverterTypeTrezorTransportCallback.handleMap.get(uniffiHandle) + val uniffiObj = FfiConverterTypeJadeTransportCallback.handleMap.get(uniffiHandle) val makeCall = { -> uniffiObj.`openDevice`( FfiConverterString.lift(`path`), ) } - val writeReturn = { uniffiResultValue: TrezorTransportWriteResult -> - uniffiOutReturn.setValue(FfiConverterTypeTrezorTransportWriteResult.lower(uniffiResultValue)) + val writeReturn = { uniffiResultValue: JadeTransportResult -> + uniffiOutReturn.setValue(FfiConverterTypeJadeTransportResult.lower(uniffiResultValue)) } uniffiTraitInterfaceCall(uniffiCallStatus, makeCall, writeReturn) } } - internal object `closeDevice`: UniffiCallbackInterfaceTrezorTransportCallbackMethod2 { + internal object `closeDevice`: UniffiCallbackInterfaceJadeTransportCallbackMethod2 { override fun callback ( `uniffiHandle`: Long, `path`: RustBufferByValue, `uniffiOutReturn`: RustBuffer, uniffiCallStatus: UniffiRustCallStatus, ) { - val uniffiObj = FfiConverterTypeTrezorTransportCallback.handleMap.get(uniffiHandle) + val uniffiObj = FfiConverterTypeJadeTransportCallback.handleMap.get(uniffiHandle) val makeCall = { -> uniffiObj.`closeDevice`( FfiConverterString.lift(`path`), ) } - val writeReturn = { uniffiResultValue: TrezorTransportWriteResult -> - uniffiOutReturn.setValue(FfiConverterTypeTrezorTransportWriteResult.lower(uniffiResultValue)) + val writeReturn = { uniffiResultValue: JadeTransportResult -> + uniffiOutReturn.setValue(FfiConverterTypeJadeTransportResult.lower(uniffiResultValue)) } uniffiTraitInterfaceCall(uniffiCallStatus, makeCall, writeReturn) } } - internal object `readChunk`: UniffiCallbackInterfaceTrezorTransportCallbackMethod3 { + internal object `writeChunk`: UniffiCallbackInterfaceJadeTransportCallbackMethod3 { override fun callback ( `uniffiHandle`: Long, `path`: RustBufferByValue, + `data`: RustBufferByValue, `uniffiOutReturn`: RustBuffer, uniffiCallStatus: UniffiRustCallStatus, ) { - val uniffiObj = FfiConverterTypeTrezorTransportCallback.handleMap.get(uniffiHandle) + val uniffiObj = FfiConverterTypeJadeTransportCallback.handleMap.get(uniffiHandle) val makeCall = { -> - uniffiObj.`readChunk`( + uniffiObj.`writeChunk`( FfiConverterString.lift(`path`), + FfiConverterByteArray.lift(`data`), ) } - val writeReturn = { uniffiResultValue: TrezorTransportReadResult -> - uniffiOutReturn.setValue(FfiConverterTypeTrezorTransportReadResult.lower(uniffiResultValue)) + val writeReturn = { uniffiResultValue: JadeTransportResult -> + uniffiOutReturn.setValue(FfiConverterTypeJadeTransportResult.lower(uniffiResultValue)) } uniffiTraitInterfaceCall(uniffiCallStatus, makeCall, writeReturn) } } - internal object `writeChunk`: UniffiCallbackInterfaceTrezorTransportCallbackMethod4 { + internal object `readChunk`: UniffiCallbackInterfaceJadeTransportCallbackMethod4 { override fun callback ( `uniffiHandle`: Long, `path`: RustBufferByValue, - `data`: RustBufferByValue, + `timeoutMs`: Int, `uniffiOutReturn`: RustBuffer, uniffiCallStatus: UniffiRustCallStatus, ) { - val uniffiObj = FfiConverterTypeTrezorTransportCallback.handleMap.get(uniffiHandle) + val uniffiObj = FfiConverterTypeJadeTransportCallback.handleMap.get(uniffiHandle) val makeCall = { -> - uniffiObj.`writeChunk`( + uniffiObj.`readChunk`( FfiConverterString.lift(`path`), - FfiConverterByteArray.lift(`data`), + FfiConverterUInt.lift(`timeoutMs`), ) } - val writeReturn = { uniffiResultValue: TrezorTransportWriteResult -> - uniffiOutReturn.setValue(FfiConverterTypeTrezorTransportWriteResult.lower(uniffiResultValue)) + val writeReturn = { uniffiResultValue: JadeTransportReadResult -> + uniffiOutReturn.setValue(FfiConverterTypeJadeTransportReadResult.lower(uniffiResultValue)) } uniffiTraitInterfaceCall(uniffiCallStatus, makeCall, writeReturn) } } - internal object `getChunkSize`: UniffiCallbackInterfaceTrezorTransportCallbackMethod5 { + internal object `getChunkSize`: UniffiCallbackInterfaceJadeTransportCallbackMethod5 { override fun callback ( `uniffiHandle`: Long, `path`: RustBufferByValue, `uniffiOutReturn`: IntByReference, uniffiCallStatus: UniffiRustCallStatus, ) { - val uniffiObj = FfiConverterTypeTrezorTransportCallback.handleMap.get(uniffiHandle) + val uniffiObj = FfiConverterTypeJadeTransportCallback.handleMap.get(uniffiHandle) val makeCall = { -> uniffiObj.`getChunkSize`( FfiConverterString.lift(`path`), @@ -5447,144 +5777,52 @@ internal object uniffiCallbackInterfaceTrezorTransportCallback { uniffiTraitInterfaceCall(uniffiCallStatus, makeCall, writeReturn) } } - internal object `callMessage`: UniffiCallbackInterfaceTrezorTransportCallbackMethod6 { - override fun callback ( - `uniffiHandle`: Long, - `path`: RustBufferByValue, - `messageType`: Short, - `data`: RustBufferByValue, - `uniffiOutReturn`: RustBuffer, - uniffiCallStatus: UniffiRustCallStatus, - ) { - val uniffiObj = FfiConverterTypeTrezorTransportCallback.handleMap.get(uniffiHandle) - val makeCall = { -> - uniffiObj.`callMessage`( - FfiConverterString.lift(`path`), - FfiConverterUShort.lift(`messageType`), - FfiConverterByteArray.lift(`data`), - ) - } - val writeReturn = { uniffiResultValue: TrezorCallMessageResult? -> - uniffiOutReturn.setValue(FfiConverterOptionalTypeTrezorCallMessageResult.lower(uniffiResultValue)) - } - uniffiTraitInterfaceCall(uniffiCallStatus, makeCall, writeReturn) - } - } - internal object `getPairingCode`: UniffiCallbackInterfaceTrezorTransportCallbackMethod7 { - override fun callback ( - `uniffiHandle`: Long, - `uniffiOutReturn`: RustBuffer, - uniffiCallStatus: UniffiRustCallStatus, - ) { - val uniffiObj = FfiConverterTypeTrezorTransportCallback.handleMap.get(uniffiHandle) - val makeCall = { -> - uniffiObj.`getPairingCode`( - ) - } - val writeReturn = { uniffiResultValue: kotlin.String -> - uniffiOutReturn.setValue(FfiConverterString.lower(uniffiResultValue)) - } - uniffiTraitInterfaceCall(uniffiCallStatus, makeCall, writeReturn) - } - } - internal object `saveThpCredential`: UniffiCallbackInterfaceTrezorTransportCallbackMethod8 { - override fun callback ( - `uniffiHandle`: Long, - `deviceId`: RustBufferByValue, - `credentialJson`: RustBufferByValue, - `uniffiOutReturn`: ByteByReference, - uniffiCallStatus: UniffiRustCallStatus, - ) { - val uniffiObj = FfiConverterTypeTrezorTransportCallback.handleMap.get(uniffiHandle) - val makeCall = { -> - uniffiObj.`saveThpCredential`( - FfiConverterString.lift(`deviceId`), - FfiConverterString.lift(`credentialJson`), - ) - } - val writeReturn = { uniffiResultValue: kotlin.Boolean -> - uniffiOutReturn.setValue(FfiConverterBoolean.lower(uniffiResultValue)) - } - uniffiTraitInterfaceCall(uniffiCallStatus, makeCall, writeReturn) - } - } - internal object `loadThpCredential`: UniffiCallbackInterfaceTrezorTransportCallbackMethod9 { - override fun callback ( - `uniffiHandle`: Long, - `deviceId`: RustBufferByValue, - `uniffiOutReturn`: RustBuffer, - uniffiCallStatus: UniffiRustCallStatus, - ) { - val uniffiObj = FfiConverterTypeTrezorTransportCallback.handleMap.get(uniffiHandle) - val makeCall = { -> - uniffiObj.`loadThpCredential`( - FfiConverterString.lift(`deviceId`), - ) - } - val writeReturn = { uniffiResultValue: kotlin.String? -> - uniffiOutReturn.setValue(FfiConverterOptionalString.lower(uniffiResultValue)) - } - uniffiTraitInterfaceCall(uniffiCallStatus, makeCall, writeReturn) - } - } - internal object `logDebug`: UniffiCallbackInterfaceTrezorTransportCallbackMethod10 { - override fun callback ( - `uniffiHandle`: Long, - `tag`: RustBufferByValue, - `message`: RustBufferByValue, - `uniffiOutReturn`: Pointer, - uniffiCallStatus: UniffiRustCallStatus, - ) { - val uniffiObj = FfiConverterTypeTrezorTransportCallback.handleMap.get(uniffiHandle) - val makeCall = { -> - uniffiObj.`logDebug`( - FfiConverterString.lift(`tag`), - FfiConverterString.lift(`message`), - ) - } - val writeReturn = { _: Unit -> - @Suppress("UNUSED_EXPRESSION") - uniffiOutReturn - Unit - } - uniffiTraitInterfaceCall(uniffiCallStatus, makeCall, writeReturn) - } - } internal object uniffiFree: UniffiCallbackInterfaceFree { override fun callback(handle: Long) { - FfiConverterTypeTrezorTransportCallback.handleMap.remove(handle) + FfiConverterTypeJadeTransportCallback.handleMap.remove(handle) } } - internal val vtable = UniffiVTableCallbackInterfaceTrezorTransportCallback( - `enumerateDevices`, + internal val vtable = UniffiVTableCallbackInterfaceJadeTransportCallback( + `scanDevices`, `openDevice`, `closeDevice`, - `readChunk`, `writeChunk`, + `readChunk`, `getChunkSize`, - `callMessage`, - `getPairingCode`, - `saveThpCredential`, - `loadThpCredential`, - `logDebug`, uniffiFree, ) internal fun register(lib: UniffiLib) { - lib.uniffi_bitkitcore_fn_init_callback_vtable_trezortransportcallback(vtable) + lib.uniffi_bitkitcore_fn_init_callback_vtable_jadetransportcallback(vtable) } } /** - * Callback interface for handling PIN and passphrase requests from the Trezor device. + * Callback interface for native Trezor transport operations * - * The native layer (iOS/Android) should implement this to show PIN/passphrase - * input UI when the device requests it during operations like signing. + * This trait must be implemented by the native iOS/Android code. + * The implementation handles actual USB or Bluetooth communication. + * + * # Android Implementation + * Use Android USB Host API for USB devices: + * - Enumerate devices with vendorId 0x1209 (0x534c for older), productId 0x53c1 + * - Request USB permission, claim interface, get endpoints + * - Chunk size: 64 bytes for USB + * + * Use Android BLE API for Bluetooth: + * - Scan for Trezor BLE service UUID: 8c000001-a59b-4d58-a9ad-073df69fa1b1 + * - Connect and discover characteristics + * - Read from: 8c000002-a59b-4d58-a9ad-073df69fa1b1 + * - Write to: 8c000003-a59b-4d58-a9ad-073df69fa1b1 + * - Chunk size: 244 bytes for BLE + * + * # iOS Implementation + * Use IOKit/CoreBluetooth with same service/characteristic UUIDs. */ -public open class TrezorUiCallbackImpl: Disposable, TrezorUiCallback { +public open class TrezorTransportCallbackImpl: Disposable, TrezorTransportCallback { public constructor(pointer: Pointer) { this.pointer = pointer @@ -5662,7 +5900,7 @@ public open class TrezorUiCallbackImpl: Disposable, TrezorUiCallback { override fun destroy() { pointer?.let { ptr -> uniffiRustCall { status -> - UniffiLib.uniffi_bitkitcore_fn_free_trezoruicallback(ptr, status) + UniffiLib.uniffi_bitkitcore_fn_free_trezortransportcallback(ptr, status) } } } @@ -5670,21 +5908,18 @@ public open class TrezorUiCallbackImpl: Disposable, TrezorUiCallback { public fun uniffiClonePointer(): Pointer { return uniffiRustCall { status -> - UniffiLib.uniffi_bitkitcore_fn_clone_trezoruicallback(pointer!!, status) + UniffiLib.uniffi_bitkitcore_fn_clone_trezortransportcallback(pointer!!, status) }!! } /** - * Called when the device requests a PIN. - * - * Show a PIN matrix UI and return the matrix-encoded PIN string. - * Return empty string to cancel. + * Enumerate all connected Trezor devices */ - public override fun `onPinRequest`(): kotlin.String { - return FfiConverterString.lift(callWithPointer { + public override fun `enumerateDevices`(): List { + return FfiConverterSequenceTypeNativeDeviceInfo.lift(callWithPointer { uniffiRustCall { uniffiRustCallStatus -> - UniffiLib.uniffi_bitkitcore_fn_method_trezoruicallback_on_pin_request( + UniffiLib.uniffi_bitkitcore_fn_method_trezortransportcallback_enumerate_devices( it, uniffiRustCallStatus, ) @@ -5693,64 +5928,665 @@ public open class TrezorUiCallbackImpl: Disposable, TrezorUiCallback { } /** - * Called when the device requests a passphrase. - * - * If `on_device` is true, the device is asking for the passphrase to be - * entered on the Trezor itself — return `PassphraseResponse::OnDevice`. - * - * If `on_device` is false, show a passphrase input UI and return - * `Standard` (no passphrase), `Hidden { value }` (host-entered passphrase), - * `OnDevice` (defer entry to the Trezor), or `Cancel`. + * Open a connection to a device */ - public override fun `onPassphraseRequest`(`onDevice`: kotlin.Boolean): PassphraseResponse { - return FfiConverterTypePassphraseResponse.lift(callWithPointer { + public override fun `openDevice`(`path`: kotlin.String): TrezorTransportWriteResult { + return FfiConverterTypeTrezorTransportWriteResult.lift(callWithPointer { uniffiRustCall { uniffiRustCallStatus -> - UniffiLib.uniffi_bitkitcore_fn_method_trezoruicallback_on_passphrase_request( + UniffiLib.uniffi_bitkitcore_fn_method_trezortransportcallback_open_device( it, - FfiConverterBoolean.lower(`onDevice`), + FfiConverterString.lower(`path`), uniffiRustCallStatus, ) } }) } - - - - - - - public companion object - -} - - - - - -public object FfiConverterTypeTrezorUiCallback: FfiConverter { - internal val handleMap = UniffiHandleMap() - - override fun lower(value: TrezorUiCallback): Pointer { - return handleMap.insert(value).toPointer() + /** + * Close the connection to a device + */ + public override fun `closeDevice`(`path`: kotlin.String): TrezorTransportWriteResult { + return FfiConverterTypeTrezorTransportWriteResult.lift(callWithPointer { + uniffiRustCall { uniffiRustCallStatus -> + UniffiLib.uniffi_bitkitcore_fn_method_trezortransportcallback_close_device( + it, + FfiConverterString.lower(`path`), + uniffiRustCallStatus, + ) + } + }) } - override fun lift(value: Pointer): TrezorUiCallback { - return TrezorUiCallbackImpl(value) + /** + * Read a chunk of data from the device + */ + public override fun `readChunk`(`path`: kotlin.String): TrezorTransportReadResult { + return FfiConverterTypeTrezorTransportReadResult.lift(callWithPointer { + uniffiRustCall { uniffiRustCallStatus -> + UniffiLib.uniffi_bitkitcore_fn_method_trezortransportcallback_read_chunk( + it, + FfiConverterString.lower(`path`), + uniffiRustCallStatus, + ) + } + }) } - override fun read(buf: ByteBuffer): TrezorUiCallback { - // The Rust code always writes pointers as 8 bytes, and will - // fail to compile if they don't fit. - return lift(buf.getLong().toPointer()) + /** + * Write a chunk of data to the device + */ + public override fun `writeChunk`(`path`: kotlin.String, `data`: kotlin.ByteArray): TrezorTransportWriteResult { + return FfiConverterTypeTrezorTransportWriteResult.lift(callWithPointer { + uniffiRustCall { uniffiRustCallStatus -> + UniffiLib.uniffi_bitkitcore_fn_method_trezortransportcallback_write_chunk( + it, + FfiConverterString.lower(`path`), + FfiConverterByteArray.lower(`data`), + uniffiRustCallStatus, + ) + } + }) } - override fun allocationSize(value: TrezorUiCallback): ULong = 8UL - - override fun write(value: TrezorUiCallback, buf: ByteBuffer) { - // The Rust code always expects pointers written as 8 bytes, - // and will fail to compile if they don't fit. - buf.putLong(lower(value).toLong()) + /** + * Get the chunk size for a device (64 for USB, 244 for Bluetooth) + */ + public override fun `getChunkSize`(`path`: kotlin.String): kotlin.UInt { + return FfiConverterUInt.lift(callWithPointer { + uniffiRustCall { uniffiRustCallStatus -> + UniffiLib.uniffi_bitkitcore_fn_method_trezortransportcallback_get_chunk_size( + it, + FfiConverterString.lower(`path`), + uniffiRustCallStatus, + ) + } + }) + } + + /** + * High-level message call for BLE/THP devices. + * + * For BLE devices that use THP protocol (encrypted communication), + * the native layer should handle encryption/decryption via + * android-trezor-connect and return the raw protobuf response. + * + * Returns None if not supported (will fall back to Protocol V1 chunks). + * Returns Some(result) to use native THP handling. + * + * # Arguments + * * `path` - Device path + * * `message_type` - Protobuf message type (e.g., GetAddress = 29) + * * `data` - Serialized protobuf message data + */ + public override fun `callMessage`(`path`: kotlin.String, `messageType`: kotlin.UShort, `data`: kotlin.ByteArray): TrezorCallMessageResult? { + return FfiConverterOptionalTypeTrezorCallMessageResult.lift(callWithPointer { + uniffiRustCall { uniffiRustCallStatus -> + UniffiLib.uniffi_bitkitcore_fn_method_trezortransportcallback_call_message( + it, + FfiConverterString.lower(`path`), + FfiConverterUShort.lower(`messageType`), + FfiConverterByteArray.lower(`data`), + uniffiRustCallStatus, + ) + } + }) + } + + /** + * Get pairing code from user during BLE THP pairing. + * + * This is called when the Trezor device displays a 6-digit code + * that must be entered to complete Bluetooth pairing. + * + * The native layer should display a UI for the user to enter the code + * shown on the Trezor screen. + * + * Returns the 6-digit code as a string, or empty string to cancel. + */ + public override fun `getPairingCode`(): kotlin.String { + return FfiConverterString.lift(callWithPointer { + uniffiRustCall { uniffiRustCallStatus -> + UniffiLib.uniffi_bitkitcore_fn_method_trezortransportcallback_get_pairing_code( + it, + uniffiRustCallStatus, + ) + } + }) + } + + /** + * Save THP pairing credentials for a device. + * + * Called after successful BLE pairing to store credentials for reconnection. + * The credential_json is a JSON string containing the serialized ThpCredentials. + * + * # Arguments + * * `device_id` - Device identifier (e.g., BLE address like "ble:AA:BB:CC:DD:EE:FF") + * * `credential_json` - JSON string with credential data + * + * Returns true if credentials were saved successfully. + */ + public override fun `saveThpCredential`(`deviceId`: kotlin.String, `credentialJson`: kotlin.String): kotlin.Boolean { + return FfiConverterBoolean.lift(callWithPointer { + uniffiRustCall { uniffiRustCallStatus -> + UniffiLib.uniffi_bitkitcore_fn_method_trezortransportcallback_save_thp_credential( + it, + FfiConverterString.lower(`deviceId`), + FfiConverterString.lower(`credentialJson`), + uniffiRustCallStatus, + ) + } + }) + } + + /** + * Load THP pairing credentials for a device. + * + * Called before BLE handshake to check for stored credentials. + * If credentials are found, they will be used to skip the pairing dialog. + * + * # Arguments + * * `device_id` - Device identifier (e.g., BLE address like "ble:AA:BB:CC:DD:EE:FF") + * + * Returns the JSON string containing ThpCredentials, or None if not found. + */ + public override fun `loadThpCredential`(`deviceId`: kotlin.String): kotlin.String? { + return FfiConverterOptionalString.lift(callWithPointer { + uniffiRustCall { uniffiRustCallStatus -> + UniffiLib.uniffi_bitkitcore_fn_method_trezortransportcallback_load_thp_credential( + it, + FfiConverterString.lower(`deviceId`), + uniffiRustCallStatus, + ) + } + }) + } + + /** + * Log a debug message from the Rust THP handshake layer. + * + * This forwards Rust-level errors and state information to the native + * debug UI (e.g., TrezorDebugLog on Android) so they are visible + * alongside the Kotlin-level logs. + * + * # Arguments + * * `tag` - Short tag identifying the subsystem (e.g., "HANDSHAKE", "THP") + * * `message` - Human-readable debug message + */ + public override fun `logDebug`(`tag`: kotlin.String, `message`: kotlin.String) { + callWithPointer { + uniffiRustCall { uniffiRustCallStatus -> + UniffiLib.uniffi_bitkitcore_fn_method_trezortransportcallback_log_debug( + it, + FfiConverterString.lower(`tag`), + FfiConverterString.lower(`message`), + uniffiRustCallStatus, + ) + } + } + } + + + + + + + + public companion object + +} + + + + + +public object FfiConverterTypeTrezorTransportCallback: FfiConverter { + internal val handleMap = UniffiHandleMap() + + override fun lower(value: TrezorTransportCallback): Pointer { + return handleMap.insert(value).toPointer() + } + + override fun lift(value: Pointer): TrezorTransportCallback { + return TrezorTransportCallbackImpl(value) + } + + override fun read(buf: ByteBuffer): TrezorTransportCallback { + // The Rust code always writes pointers as 8 bytes, and will + // fail to compile if they don't fit. + return lift(buf.getLong().toPointer()) + } + + override fun allocationSize(value: TrezorTransportCallback): ULong = 8UL + + override fun write(value: TrezorTransportCallback, buf: ByteBuffer) { + // The Rust code always expects pointers written as 8 bytes, + // and will fail to compile if they don't fit. + buf.putLong(lower(value).toLong()) + } +} + + +// Put the implementation in an object so we don't pollute the top-level namespace +internal object uniffiCallbackInterfaceTrezorTransportCallback { + internal object `enumerateDevices`: UniffiCallbackInterfaceTrezorTransportCallbackMethod0 { + override fun callback ( + `uniffiHandle`: Long, + `uniffiOutReturn`: RustBuffer, + uniffiCallStatus: UniffiRustCallStatus, + ) { + val uniffiObj = FfiConverterTypeTrezorTransportCallback.handleMap.get(uniffiHandle) + val makeCall = { -> + uniffiObj.`enumerateDevices`( + ) + } + val writeReturn = { uniffiResultValue: List -> + uniffiOutReturn.setValue(FfiConverterSequenceTypeNativeDeviceInfo.lower(uniffiResultValue)) + } + uniffiTraitInterfaceCall(uniffiCallStatus, makeCall, writeReturn) + } + } + internal object `openDevice`: UniffiCallbackInterfaceTrezorTransportCallbackMethod1 { + override fun callback ( + `uniffiHandle`: Long, + `path`: RustBufferByValue, + `uniffiOutReturn`: RustBuffer, + uniffiCallStatus: UniffiRustCallStatus, + ) { + val uniffiObj = FfiConverterTypeTrezorTransportCallback.handleMap.get(uniffiHandle) + val makeCall = { -> + uniffiObj.`openDevice`( + FfiConverterString.lift(`path`), + ) + } + val writeReturn = { uniffiResultValue: TrezorTransportWriteResult -> + uniffiOutReturn.setValue(FfiConverterTypeTrezorTransportWriteResult.lower(uniffiResultValue)) + } + uniffiTraitInterfaceCall(uniffiCallStatus, makeCall, writeReturn) + } + } + internal object `closeDevice`: UniffiCallbackInterfaceTrezorTransportCallbackMethod2 { + override fun callback ( + `uniffiHandle`: Long, + `path`: RustBufferByValue, + `uniffiOutReturn`: RustBuffer, + uniffiCallStatus: UniffiRustCallStatus, + ) { + val uniffiObj = FfiConverterTypeTrezorTransportCallback.handleMap.get(uniffiHandle) + val makeCall = { -> + uniffiObj.`closeDevice`( + FfiConverterString.lift(`path`), + ) + } + val writeReturn = { uniffiResultValue: TrezorTransportWriteResult -> + uniffiOutReturn.setValue(FfiConverterTypeTrezorTransportWriteResult.lower(uniffiResultValue)) + } + uniffiTraitInterfaceCall(uniffiCallStatus, makeCall, writeReturn) + } + } + internal object `readChunk`: UniffiCallbackInterfaceTrezorTransportCallbackMethod3 { + override fun callback ( + `uniffiHandle`: Long, + `path`: RustBufferByValue, + `uniffiOutReturn`: RustBuffer, + uniffiCallStatus: UniffiRustCallStatus, + ) { + val uniffiObj = FfiConverterTypeTrezorTransportCallback.handleMap.get(uniffiHandle) + val makeCall = { -> + uniffiObj.`readChunk`( + FfiConverterString.lift(`path`), + ) + } + val writeReturn = { uniffiResultValue: TrezorTransportReadResult -> + uniffiOutReturn.setValue(FfiConverterTypeTrezorTransportReadResult.lower(uniffiResultValue)) + } + uniffiTraitInterfaceCall(uniffiCallStatus, makeCall, writeReturn) + } + } + internal object `writeChunk`: UniffiCallbackInterfaceTrezorTransportCallbackMethod4 { + override fun callback ( + `uniffiHandle`: Long, + `path`: RustBufferByValue, + `data`: RustBufferByValue, + `uniffiOutReturn`: RustBuffer, + uniffiCallStatus: UniffiRustCallStatus, + ) { + val uniffiObj = FfiConverterTypeTrezorTransportCallback.handleMap.get(uniffiHandle) + val makeCall = { -> + uniffiObj.`writeChunk`( + FfiConverterString.lift(`path`), + FfiConverterByteArray.lift(`data`), + ) + } + val writeReturn = { uniffiResultValue: TrezorTransportWriteResult -> + uniffiOutReturn.setValue(FfiConverterTypeTrezorTransportWriteResult.lower(uniffiResultValue)) + } + uniffiTraitInterfaceCall(uniffiCallStatus, makeCall, writeReturn) + } + } + internal object `getChunkSize`: UniffiCallbackInterfaceTrezorTransportCallbackMethod5 { + override fun callback ( + `uniffiHandle`: Long, + `path`: RustBufferByValue, + `uniffiOutReturn`: IntByReference, + uniffiCallStatus: UniffiRustCallStatus, + ) { + val uniffiObj = FfiConverterTypeTrezorTransportCallback.handleMap.get(uniffiHandle) + val makeCall = { -> + uniffiObj.`getChunkSize`( + FfiConverterString.lift(`path`), + ) + } + val writeReturn = { uniffiResultValue: kotlin.UInt -> + uniffiOutReturn.setValue(FfiConverterUInt.lower(uniffiResultValue)) + } + uniffiTraitInterfaceCall(uniffiCallStatus, makeCall, writeReturn) + } + } + internal object `callMessage`: UniffiCallbackInterfaceTrezorTransportCallbackMethod6 { + override fun callback ( + `uniffiHandle`: Long, + `path`: RustBufferByValue, + `messageType`: Short, + `data`: RustBufferByValue, + `uniffiOutReturn`: RustBuffer, + uniffiCallStatus: UniffiRustCallStatus, + ) { + val uniffiObj = FfiConverterTypeTrezorTransportCallback.handleMap.get(uniffiHandle) + val makeCall = { -> + uniffiObj.`callMessage`( + FfiConverterString.lift(`path`), + FfiConverterUShort.lift(`messageType`), + FfiConverterByteArray.lift(`data`), + ) + } + val writeReturn = { uniffiResultValue: TrezorCallMessageResult? -> + uniffiOutReturn.setValue(FfiConverterOptionalTypeTrezorCallMessageResult.lower(uniffiResultValue)) + } + uniffiTraitInterfaceCall(uniffiCallStatus, makeCall, writeReturn) + } + } + internal object `getPairingCode`: UniffiCallbackInterfaceTrezorTransportCallbackMethod7 { + override fun callback ( + `uniffiHandle`: Long, + `uniffiOutReturn`: RustBuffer, + uniffiCallStatus: UniffiRustCallStatus, + ) { + val uniffiObj = FfiConverterTypeTrezorTransportCallback.handleMap.get(uniffiHandle) + val makeCall = { -> + uniffiObj.`getPairingCode`( + ) + } + val writeReturn = { uniffiResultValue: kotlin.String -> + uniffiOutReturn.setValue(FfiConverterString.lower(uniffiResultValue)) + } + uniffiTraitInterfaceCall(uniffiCallStatus, makeCall, writeReturn) + } + } + internal object `saveThpCredential`: UniffiCallbackInterfaceTrezorTransportCallbackMethod8 { + override fun callback ( + `uniffiHandle`: Long, + `deviceId`: RustBufferByValue, + `credentialJson`: RustBufferByValue, + `uniffiOutReturn`: ByteByReference, + uniffiCallStatus: UniffiRustCallStatus, + ) { + val uniffiObj = FfiConverterTypeTrezorTransportCallback.handleMap.get(uniffiHandle) + val makeCall = { -> + uniffiObj.`saveThpCredential`( + FfiConverterString.lift(`deviceId`), + FfiConverterString.lift(`credentialJson`), + ) + } + val writeReturn = { uniffiResultValue: kotlin.Boolean -> + uniffiOutReturn.setValue(FfiConverterBoolean.lower(uniffiResultValue)) + } + uniffiTraitInterfaceCall(uniffiCallStatus, makeCall, writeReturn) + } + } + internal object `loadThpCredential`: UniffiCallbackInterfaceTrezorTransportCallbackMethod9 { + override fun callback ( + `uniffiHandle`: Long, + `deviceId`: RustBufferByValue, + `uniffiOutReturn`: RustBuffer, + uniffiCallStatus: UniffiRustCallStatus, + ) { + val uniffiObj = FfiConverterTypeTrezorTransportCallback.handleMap.get(uniffiHandle) + val makeCall = { -> + uniffiObj.`loadThpCredential`( + FfiConverterString.lift(`deviceId`), + ) + } + val writeReturn = { uniffiResultValue: kotlin.String? -> + uniffiOutReturn.setValue(FfiConverterOptionalString.lower(uniffiResultValue)) + } + uniffiTraitInterfaceCall(uniffiCallStatus, makeCall, writeReturn) + } + } + internal object `logDebug`: UniffiCallbackInterfaceTrezorTransportCallbackMethod10 { + override fun callback ( + `uniffiHandle`: Long, + `tag`: RustBufferByValue, + `message`: RustBufferByValue, + `uniffiOutReturn`: Pointer, + uniffiCallStatus: UniffiRustCallStatus, + ) { + val uniffiObj = FfiConverterTypeTrezorTransportCallback.handleMap.get(uniffiHandle) + val makeCall = { -> + uniffiObj.`logDebug`( + FfiConverterString.lift(`tag`), + FfiConverterString.lift(`message`), + ) + } + val writeReturn = { _: Unit -> + @Suppress("UNUSED_EXPRESSION") + uniffiOutReturn + Unit + } + uniffiTraitInterfaceCall(uniffiCallStatus, makeCall, writeReturn) + } + } + internal object uniffiFree: UniffiCallbackInterfaceFree { + override fun callback(handle: Long) { + FfiConverterTypeTrezorTransportCallback.handleMap.remove(handle) + } + } + + internal val vtable = UniffiVTableCallbackInterfaceTrezorTransportCallback( + `enumerateDevices`, + `openDevice`, + `closeDevice`, + `readChunk`, + `writeChunk`, + `getChunkSize`, + `callMessage`, + `getPairingCode`, + `saveThpCredential`, + `loadThpCredential`, + `logDebug`, + uniffiFree, + ) + + internal fun register(lib: UniffiLib) { + lib.uniffi_bitkitcore_fn_init_callback_vtable_trezortransportcallback(vtable) + } +} + + + +/** + * Callback interface for handling PIN and passphrase requests from the Trezor device. + * + * The native layer (iOS/Android) should implement this to show PIN/passphrase + * input UI when the device requests it during operations like signing. + */ +public open class TrezorUiCallbackImpl: Disposable, TrezorUiCallback { + + public constructor(pointer: Pointer) { + this.pointer = pointer + this.cleanable = UniffiLib.CLEANER.register(this, UniffiPointerDestroyer(pointer)) + } + + /** + * This constructor can be used to instantiate a fake object. Only used for tests. Any + * attempt to actually use an object constructed this way will fail as there is no + * connected Rust object. + */ + public constructor(noPointer: NoPointer) { + this.pointer = null + this.cleanable = UniffiLib.CLEANER.register(this, UniffiPointerDestroyer(null)) + } + + protected val pointer: Pointer? + protected val cleanable: UniffiCleaner.Cleanable + + private val wasDestroyed: kotlinx.atomicfu.AtomicBoolean = kotlinx.atomicfu.atomic(false) + private val callCounter: kotlinx.atomicfu.AtomicLong = kotlinx.atomicfu.atomic(1L) + + private val lock = kotlinx.atomicfu.locks.ReentrantLock() + + private fun synchronized(block: () -> T): T { + lock.lock() + try { + return block() + } finally { + lock.unlock() + } + } + + override fun destroy() { + // Only allow a single call to this method. + // TODO: maybe we should log a warning if called more than once? + if (this.wasDestroyed.compareAndSet(false, true)) { + // This decrement always matches the initial count of 1 given at creation time. + if (this.callCounter.decrementAndGet() == 0L) { + cleanable.clean() + } + } + } + + override fun close() { + synchronized { this.destroy() } + } + + internal inline fun callWithPointer(block: (ptr: Pointer) -> R): R { + // Check and increment the call counter, to keep the object alive. + // This needs a compare-and-set retry loop in case of concurrent updates. + do { + val c = this.callCounter.value + if (c == 0L) { + throw IllegalStateException("${this::class::simpleName} object has already been destroyed") + } + if (c == Long.MAX_VALUE) { + throw IllegalStateException("${this::class::simpleName} call counter would overflow") + } + } while (! this.callCounter.compareAndSet(c, c + 1L)) + // Now we can safely do the method call without the pointer being freed concurrently. + try { + return block(this.uniffiClonePointer()) + } finally { + // This decrement always matches the increment we performed above. + if (this.callCounter.decrementAndGet() == 0L) { + cleanable.clean() + } + } + } + + // Use a static inner class instead of a closure so as not to accidentally + // capture `this` as part of the cleanable's action. + private class UniffiPointerDestroyer(private val pointer: Pointer?) : Disposable { + override fun destroy() { + pointer?.let { ptr -> + uniffiRustCall { status -> + UniffiLib.uniffi_bitkitcore_fn_free_trezoruicallback(ptr, status) + } + } + } + } + + public fun uniffiClonePointer(): Pointer { + return uniffiRustCall { status -> + UniffiLib.uniffi_bitkitcore_fn_clone_trezoruicallback(pointer!!, status) + }!! + } + + + /** + * Called when the device requests a PIN. + * + * Show a PIN matrix UI and return the matrix-encoded PIN string. + * Return empty string to cancel. + */ + public override fun `onPinRequest`(): kotlin.String { + return FfiConverterString.lift(callWithPointer { + uniffiRustCall { uniffiRustCallStatus -> + UniffiLib.uniffi_bitkitcore_fn_method_trezoruicallback_on_pin_request( + it, + uniffiRustCallStatus, + ) + } + }) + } + + /** + * Called when the device requests a passphrase. + * + * If `on_device` is true, the device is asking for the passphrase to be + * entered on the Trezor itself — return `PassphraseResponse::OnDevice`. + * + * If `on_device` is false, show a passphrase input UI and return + * `Standard` (no passphrase), `Hidden { value }` (host-entered passphrase), + * `OnDevice` (defer entry to the Trezor), or `Cancel`. + */ + public override fun `onPassphraseRequest`(`onDevice`: kotlin.Boolean): PassphraseResponse { + return FfiConverterTypePassphraseResponse.lift(callWithPointer { + uniffiRustCall { uniffiRustCallStatus -> + UniffiLib.uniffi_bitkitcore_fn_method_trezoruicallback_on_passphrase_request( + it, + FfiConverterBoolean.lower(`onDevice`), + uniffiRustCallStatus, + ) + } + }) + } + + + + + + + + public companion object + +} + + + + + +public object FfiConverterTypeTrezorUiCallback: FfiConverter { + internal val handleMap = UniffiHandleMap() + + override fun lower(value: TrezorUiCallback): Pointer { + return handleMap.insert(value).toPointer() + } + + override fun lift(value: Pointer): TrezorUiCallback { + return TrezorUiCallbackImpl(value) + } + + override fun read(buf: ByteBuffer): TrezorUiCallback { + // The Rust code always writes pointers as 8 bytes, and will + // fail to compile if they don't fit. + return lift(buf.getLong().toPointer()) + } + + override fun allocationSize(value: TrezorUiCallback): ULong = 8UL + + override fun write(value: TrezorUiCallback, buf: ByteBuffer) { + // The Rust code always expects pointers written as 8 bytes, + // and will fail to compile if they don't fit. + buf.putLong(lower(value).toLong()) } } @@ -7668,14 +8504,275 @@ public object FfiConverterTypeIManualRefund: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): JadeAccount { + return JadeAccount( + FfiConverterTypeJadeAddressVariant.read(buf), + FfiConverterString.read(buf), + FfiConverterString.read(buf), + ) + } + + override fun allocationSize(value: JadeAccount): ULong = ( + FfiConverterTypeJadeAddressVariant.allocationSize(value.`variant`) + + FfiConverterString.allocationSize(value.`xpub`) + + FfiConverterString.allocationSize(value.`derivationPath`) + ) + + override fun write(value: JadeAccount, buf: ByteBuffer) { + FfiConverterTypeJadeAddressVariant.write(value.`variant`, buf) + FfiConverterString.write(value.`xpub`, buf) + FfiConverterString.write(value.`derivationPath`, buf) + } +} + + + + +public object FfiConverterTypeJadeAccountExport: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): JadeAccountExport { + return JadeAccountExport( + FfiConverterString.read(buf), + FfiConverterUInt.read(buf), + FfiConverterSequenceTypeJadeAccount.read(buf), + ) + } + + override fun allocationSize(value: JadeAccountExport): ULong = ( + FfiConverterString.allocationSize(value.`masterFingerprint`) + + FfiConverterUInt.allocationSize(value.`accountIndex`) + + FfiConverterSequenceTypeJadeAccount.allocationSize(value.`accounts`) + ) + + override fun write(value: JadeAccountExport, buf: ByteBuffer) { + FfiConverterString.write(value.`masterFingerprint`, buf) + FfiConverterUInt.write(value.`accountIndex`, buf) + FfiConverterSequenceTypeJadeAccount.write(value.`accounts`, buf) + } +} + + + + +public object FfiConverterTypeJadeDeviceInfo: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): JadeDeviceInfo { + return JadeDeviceInfo( + FfiConverterString.read(buf), + FfiConverterTypeJadeTransportKind.read(buf), + FfiConverterOptionalString.read(buf), + FfiConverterOptionalString.read(buf), + ) + } + + override fun allocationSize(value: JadeDeviceInfo): ULong = ( + FfiConverterString.allocationSize(value.`path`) + + FfiConverterTypeJadeTransportKind.allocationSize(value.`transport`) + + FfiConverterOptionalString.allocationSize(value.`name`) + + FfiConverterOptionalString.allocationSize(value.`serialNumber`) + ) + + override fun write(value: JadeDeviceInfo, buf: ByteBuffer) { + FfiConverterString.write(value.`path`, buf) + FfiConverterTypeJadeTransportKind.write(value.`transport`, buf) + FfiConverterOptionalString.write(value.`name`, buf) + FfiConverterOptionalString.write(value.`serialNumber`, buf) + } +} + + + + +public object FfiConverterTypeJadeNativeDevice: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): JadeNativeDevice { + return JadeNativeDevice( + FfiConverterString.read(buf), + FfiConverterTypeJadeTransportKind.read(buf), + FfiConverterOptionalString.read(buf), + FfiConverterOptionalString.read(buf), + ) + } + + override fun allocationSize(value: JadeNativeDevice): ULong = ( + FfiConverterString.allocationSize(value.`path`) + + FfiConverterTypeJadeTransportKind.allocationSize(value.`transport`) + + FfiConverterOptionalString.allocationSize(value.`name`) + + FfiConverterOptionalString.allocationSize(value.`serialNumber`) + ) + + override fun write(value: JadeNativeDevice, buf: ByteBuffer) { + FfiConverterString.write(value.`path`, buf) + FfiConverterTypeJadeTransportKind.write(value.`transport`, buf) + FfiConverterOptionalString.write(value.`name`, buf) + FfiConverterOptionalString.write(value.`serialNumber`, buf) + } +} + + + + +public object FfiConverterTypeJadeSignedMessage: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): JadeSignedMessage { + return JadeSignedMessage( + FfiConverterString.read(buf), + FfiConverterString.read(buf), + FfiConverterString.read(buf), + ) + } + + override fun allocationSize(value: JadeSignedMessage): ULong = ( + FfiConverterString.allocationSize(value.`signature`) + + FfiConverterString.allocationSize(value.`address`) + + FfiConverterString.allocationSize(value.`derivationPath`) + ) + + override fun write(value: JadeSignedMessage, buf: ByteBuffer) { + FfiConverterString.write(value.`signature`, buf) + FfiConverterString.write(value.`address`, buf) + FfiConverterString.write(value.`derivationPath`, buf) + } +} + + + + +public object FfiConverterTypeJadeTransportReadResult: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): JadeTransportReadResult { + return JadeTransportReadResult( + FfiConverterBoolean.read(buf), + FfiConverterByteArray.read(buf), + FfiConverterString.read(buf), + FfiConverterOptionalTypeJadeTransportErrorCode.read(buf), + ) + } + + override fun allocationSize(value: JadeTransportReadResult): ULong = ( + FfiConverterBoolean.allocationSize(value.`success`) + + FfiConverterByteArray.allocationSize(value.`data`) + + FfiConverterString.allocationSize(value.`error`) + + FfiConverterOptionalTypeJadeTransportErrorCode.allocationSize(value.`errorCode`) + ) + + override fun write(value: JadeTransportReadResult, buf: ByteBuffer) { + FfiConverterBoolean.write(value.`success`, buf) + FfiConverterByteArray.write(value.`data`, buf) + FfiConverterString.write(value.`error`, buf) + FfiConverterOptionalTypeJadeTransportErrorCode.write(value.`errorCode`, buf) + } +} + + + + +public object FfiConverterTypeJadeTransportResult: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): JadeTransportResult { + return JadeTransportResult( + FfiConverterBoolean.read(buf), + FfiConverterString.read(buf), + FfiConverterOptionalTypeJadeTransportErrorCode.read(buf), + ) + } + + override fun allocationSize(value: JadeTransportResult): ULong = ( + FfiConverterBoolean.allocationSize(value.`success`) + + FfiConverterString.allocationSize(value.`error`) + + FfiConverterOptionalTypeJadeTransportErrorCode.allocationSize(value.`errorCode`) + ) + + override fun write(value: JadeTransportResult, buf: ByteBuffer) { + FfiConverterBoolean.write(value.`success`, buf) + FfiConverterString.write(value.`error`, buf) + FfiConverterOptionalTypeJadeTransportErrorCode.write(value.`errorCode`, buf) + } +} + + + + +public object FfiConverterTypeJadeVersionInfo: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): JadeVersionInfo { + return JadeVersionInfo( + FfiConverterString.read(buf), + FfiConverterTypeJadeState.read(buf), + FfiConverterOptionalString.read(buf), + FfiConverterOptionalBoolean.read(buf), + FfiConverterOptionalString.read(buf), + FfiConverterOptionalString.read(buf), + FfiConverterOptionalString.read(buf), + FfiConverterOptionalString.read(buf), + FfiConverterOptionalString.read(buf), + FfiConverterOptionalString.read(buf), + FfiConverterOptionalUInt.read(buf), + FfiConverterOptionalUInt.read(buf), + ) + } + + override fun allocationSize(value: JadeVersionInfo): ULong = ( + FfiConverterString.allocationSize(value.`jadeVersion`) + + FfiConverterTypeJadeState.allocationSize(value.`jadeState`) + + FfiConverterOptionalString.allocationSize(value.`jadeNetworks`) + + FfiConverterOptionalBoolean.allocationSize(value.`jadeHasPin`) + + FfiConverterOptionalString.allocationSize(value.`boardType`) + + FfiConverterOptionalString.allocationSize(value.`jadeConfig`) + + FfiConverterOptionalString.allocationSize(value.`jadeFeatures`) + + FfiConverterOptionalString.allocationSize(value.`idfVersion`) + + FfiConverterOptionalString.allocationSize(value.`chipFeatures`) + + FfiConverterOptionalString.allocationSize(value.`efuseMac`) + + FfiConverterOptionalUInt.allocationSize(value.`batteryStatus`) + + FfiConverterOptionalUInt.allocationSize(value.`jadeOtaMaxChunk`) + ) + + override fun write(value: JadeVersionInfo, buf: ByteBuffer) { + FfiConverterString.write(value.`jadeVersion`, buf) + FfiConverterTypeJadeState.write(value.`jadeState`, buf) + FfiConverterOptionalString.write(value.`jadeNetworks`, buf) + FfiConverterOptionalBoolean.write(value.`jadeHasPin`, buf) + FfiConverterOptionalString.write(value.`boardType`, buf) + FfiConverterOptionalString.write(value.`jadeConfig`, buf) + FfiConverterOptionalString.write(value.`jadeFeatures`, buf) + FfiConverterOptionalString.write(value.`idfVersion`, buf) + FfiConverterOptionalString.write(value.`chipFeatures`, buf) + FfiConverterOptionalString.write(value.`efuseMac`, buf) + FfiConverterOptionalUInt.write(value.`batteryStatus`, buf) + FfiConverterOptionalUInt.write(value.`jadeOtaMaxChunk`, buf) + } +} + + + + +public object FfiConverterTypeJadeXpubResponse: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): JadeXpubResponse { + return JadeXpubResponse( + FfiConverterString.read(buf), + FfiConverterString.read(buf), + FfiConverterString.read(buf), + ) + } + + override fun allocationSize(value: JadeXpubResponse): ULong = ( + FfiConverterString.allocationSize(value.`xpub`) + + FfiConverterString.allocationSize(value.`derivationPath`) + + FfiConverterString.allocationSize(value.`masterFingerprint`) + ) + + override fun write(value: JadeXpubResponse, buf: ByteBuffer) { + FfiConverterString.write(value.`xpub`, buf) + FfiConverterString.write(value.`derivationPath`, buf) + FfiConverterString.write(value.`masterFingerprint`, buf) } } @@ -11192,109 +12289,468 @@ public object FfiConverterTypeDecodingError : FfiConverterRustBuffer ( + is DecodingException.InvalidNetwork -> ( + // Add the size for the Int that specifies the variant plus the size needed for all fields + 4UL + ) + is DecodingException.InvalidAmount -> ( + // Add the size for the Int that specifies the variant plus the size needed for all fields + 4UL + ) + is DecodingException.InvalidLnurlPayAmount -> ( + // Add the size for the Int that specifies the variant plus the size needed for all fields + 4UL + + FfiConverterULong.allocationSize(value.`amountSatoshis`) + + FfiConverterULong.allocationSize(value.`min`) + + FfiConverterULong.allocationSize(value.`max`) + ) + is DecodingException.InvalidTimestamp -> ( + // Add the size for the Int that specifies the variant plus the size needed for all fields + 4UL + ) + is DecodingException.InvalidChecksum -> ( + // Add the size for the Int that specifies the variant plus the size needed for all fields + 4UL + ) + is DecodingException.InvalidResponse -> ( + // Add the size for the Int that specifies the variant plus the size needed for all fields + 4UL + ) + is DecodingException.UnsupportedType -> ( + // Add the size for the Int that specifies the variant plus the size needed for all fields + 4UL + ) + is DecodingException.InvalidAddress -> ( + // Add the size for the Int that specifies the variant plus the size needed for all fields + 4UL + ) + is DecodingException.RequestFailed -> ( + // Add the size for the Int that specifies the variant plus the size needed for all fields + 4UL + ) + is DecodingException.ClientCreationFailed -> ( + // Add the size for the Int that specifies the variant plus the size needed for all fields + 4UL + ) + is DecodingException.InvoiceCreationFailed -> ( + // Add the size for the Int that specifies the variant plus the size needed for all fields + 4UL + + FfiConverterString.allocationSize(value.`errorMessage`) + ) + } + } + + override fun write(value: DecodingException, buf: ByteBuffer) { + when (value) { + is DecodingException.InvalidFormat -> { + buf.putInt(1) + Unit + } + is DecodingException.InvalidNetwork -> { + buf.putInt(2) + Unit + } + is DecodingException.InvalidAmount -> { + buf.putInt(3) + Unit + } + is DecodingException.InvalidLnurlPayAmount -> { + buf.putInt(4) + FfiConverterULong.write(value.`amountSatoshis`, buf) + FfiConverterULong.write(value.`min`, buf) + FfiConverterULong.write(value.`max`, buf) + Unit + } + is DecodingException.InvalidTimestamp -> { + buf.putInt(5) + Unit + } + is DecodingException.InvalidChecksum -> { + buf.putInt(6) + Unit + } + is DecodingException.InvalidResponse -> { + buf.putInt(7) + Unit + } + is DecodingException.UnsupportedType -> { + buf.putInt(8) + Unit + } + is DecodingException.InvalidAddress -> { + buf.putInt(9) + Unit + } + is DecodingException.RequestFailed -> { + buf.putInt(10) + Unit + } + is DecodingException.ClientCreationFailed -> { + buf.putInt(11) + Unit + } + is DecodingException.InvoiceCreationFailed -> { + buf.putInt(12) + FfiConverterString.write(value.`errorMessage`, buf) + Unit + } + }.let { /* this makes the `when` an expression, which ensures it is exhaustive */ } + } +} + + + + + +public object FfiConverterTypeHardwareWalletTransport: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): HardwareWalletTransport = try { + HardwareWalletTransport.entries[buf.getInt() - 1] + } catch (e: IndexOutOfBoundsException) { + throw RuntimeException("invalid enum value, something is very wrong!!", e) + } + + override fun allocationSize(value: HardwareWalletTransport): ULong = 4UL + + override fun write(value: HardwareWalletTransport, buf: ByteBuffer) { + buf.putInt(value.ordinal + 1) + } +} + + + + + +public object FfiConverterTypeHardwareWalletVendor: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): HardwareWalletVendor = try { + HardwareWalletVendor.entries[buf.getInt() - 1] + } catch (e: IndexOutOfBoundsException) { + throw RuntimeException("invalid enum value, something is very wrong!!", e) + } + + override fun allocationSize(value: HardwareWalletVendor): ULong = 4UL + + override fun write(value: HardwareWalletVendor, buf: ByteBuffer) { + buf.putInt(value.ordinal + 1) + } +} + + + + + +public object FfiConverterTypeJadeAddressVariant: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): JadeAddressVariant = try { + JadeAddressVariant.entries[buf.getInt() - 1] + } catch (e: IndexOutOfBoundsException) { + throw RuntimeException("invalid enum value, something is very wrong!!", e) + } + + override fun allocationSize(value: JadeAddressVariant): ULong = 4UL + + override fun write(value: JadeAddressVariant, buf: ByteBuffer) { + buf.putInt(value.ordinal + 1) + } +} + + + + +public object JadeExceptionErrorHandler : UniffiRustCallStatusErrorHandler { + override fun lift(errorBuf: RustBufferByValue): JadeException = FfiConverterTypeJadeError.lift(errorBuf) +} + +public object FfiConverterTypeJadeError : FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): JadeException { + return when (buf.getInt()) { + 1 -> JadeException.TransportException( + FfiConverterString.read(buf), + ) + 2 -> JadeException.DeviceNotFound() + 3 -> JadeException.DeviceDisconnected() + 4 -> JadeException.DeviceBusy() + 5 -> JadeException.NotConnected() + 6 -> JadeException.NotInitialized() + 7 -> JadeException.ConnectionException( + FfiConverterString.read(buf), + ) + 8 -> JadeException.ProtocolException( + FfiConverterString.read(buf), + ) + 9 -> JadeException.Timeout() + 10 -> JadeException.UserCancelled() + 11 -> JadeException.DeviceLocked() + 12 -> JadeException.DeviceUninitialized() + 13 -> JadeException.InvalidPin() + 14 -> JadeException.NetworkMismatch( + FfiConverterString.read(buf), + ) + 15 -> JadeException.UnsupportedFirmware( + FfiConverterString.read(buf), + FfiConverterString.read(buf), + ) + 16 -> JadeException.InvalidPath( + FfiConverterString.read(buf), + ) + 17 -> JadeException.InvalidPsbt( + FfiConverterString.read(buf), + ) + 18 -> JadeException.PsbtTooLarge( + FfiConverterULong.read(buf), + FfiConverterULong.read(buf), + ) + 19 -> JadeException.FingerprintMismatch( + FfiConverterString.read(buf), + FfiConverterString.read(buf), + ) + 20 -> JadeException.NothingSigned() + 21 -> JadeException.AddressMismatch( + FfiConverterString.read(buf), + FfiConverterString.read(buf), + ) + 22 -> JadeException.PinServerException( + FfiConverterString.read(buf), + ) + 23 -> JadeException.DeviceException( + FfiConverterString.read(buf), + ) + 24 -> JadeException.IoException( + FfiConverterString.read(buf), + ) + else -> throw RuntimeException("invalid error enum value, something is very wrong!!") + } + } + + override fun allocationSize(value: JadeException): ULong { + return when (value) { + is JadeException.TransportException -> ( + // Add the size for the Int that specifies the variant plus the size needed for all fields + 4UL + + FfiConverterString.allocationSize(value.`errorDetails`) + ) + is JadeException.DeviceNotFound -> ( + // Add the size for the Int that specifies the variant plus the size needed for all fields + 4UL + ) + is JadeException.DeviceDisconnected -> ( + // Add the size for the Int that specifies the variant plus the size needed for all fields + 4UL + ) + is JadeException.DeviceBusy -> ( + // Add the size for the Int that specifies the variant plus the size needed for all fields + 4UL + ) + is JadeException.NotConnected -> ( + // Add the size for the Int that specifies the variant plus the size needed for all fields + 4UL + ) + is JadeException.NotInitialized -> ( + // Add the size for the Int that specifies the variant plus the size needed for all fields + 4UL + ) + is JadeException.ConnectionException -> ( + // Add the size for the Int that specifies the variant plus the size needed for all fields + 4UL + + FfiConverterString.allocationSize(value.`errorDetails`) + ) + is JadeException.ProtocolException -> ( + // Add the size for the Int that specifies the variant plus the size needed for all fields + 4UL + + FfiConverterString.allocationSize(value.`errorDetails`) + ) + is JadeException.Timeout -> ( + // Add the size for the Int that specifies the variant plus the size needed for all fields + 4UL + ) + is JadeException.UserCancelled -> ( + // Add the size for the Int that specifies the variant plus the size needed for all fields + 4UL + ) + is JadeException.DeviceLocked -> ( + // Add the size for the Int that specifies the variant plus the size needed for all fields + 4UL + ) + is JadeException.DeviceUninitialized -> ( + // Add the size for the Int that specifies the variant plus the size needed for all fields + 4UL + ) + is JadeException.InvalidPin -> ( + // Add the size for the Int that specifies the variant plus the size needed for all fields + 4UL + ) + is JadeException.NetworkMismatch -> ( // Add the size for the Int that specifies the variant plus the size needed for all fields 4UL + + FfiConverterString.allocationSize(value.`errorDetails`) ) - is DecodingException.InvalidAmount -> ( + is JadeException.UnsupportedFirmware -> ( // Add the size for the Int that specifies the variant plus the size needed for all fields 4UL + + FfiConverterString.allocationSize(value.`installed`) + + FfiConverterString.allocationSize(value.`required`) ) - is DecodingException.InvalidLnurlPayAmount -> ( + is JadeException.InvalidPath -> ( // Add the size for the Int that specifies the variant plus the size needed for all fields 4UL - + FfiConverterULong.allocationSize(value.`amountSatoshis`) - + FfiConverterULong.allocationSize(value.`min`) - + FfiConverterULong.allocationSize(value.`max`) + + FfiConverterString.allocationSize(value.`errorDetails`) ) - is DecodingException.InvalidTimestamp -> ( + is JadeException.InvalidPsbt -> ( // Add the size for the Int that specifies the variant plus the size needed for all fields 4UL + + FfiConverterString.allocationSize(value.`errorDetails`) ) - is DecodingException.InvalidChecksum -> ( + is JadeException.PsbtTooLarge -> ( // Add the size for the Int that specifies the variant plus the size needed for all fields 4UL + + FfiConverterULong.allocationSize(value.`size`) + + FfiConverterULong.allocationSize(value.`max`) ) - is DecodingException.InvalidResponse -> ( + is JadeException.FingerprintMismatch -> ( // Add the size for the Int that specifies the variant plus the size needed for all fields 4UL + + FfiConverterString.allocationSize(value.`device`) + + FfiConverterString.allocationSize(value.`psbt`) ) - is DecodingException.UnsupportedType -> ( + is JadeException.NothingSigned -> ( // Add the size for the Int that specifies the variant plus the size needed for all fields 4UL ) - is DecodingException.InvalidAddress -> ( + is JadeException.AddressMismatch -> ( // Add the size for the Int that specifies the variant plus the size needed for all fields 4UL + + FfiConverterString.allocationSize(value.`expected`) + + FfiConverterString.allocationSize(value.`returned`) ) - is DecodingException.RequestFailed -> ( + is JadeException.PinServerException -> ( // Add the size for the Int that specifies the variant plus the size needed for all fields 4UL + + FfiConverterString.allocationSize(value.`errorDetails`) ) - is DecodingException.ClientCreationFailed -> ( + is JadeException.DeviceException -> ( // Add the size for the Int that specifies the variant plus the size needed for all fields 4UL + + FfiConverterString.allocationSize(value.`errorDetails`) ) - is DecodingException.InvoiceCreationFailed -> ( + is JadeException.IoException -> ( // Add the size for the Int that specifies the variant plus the size needed for all fields 4UL - + FfiConverterString.allocationSize(value.`errorMessage`) + + FfiConverterString.allocationSize(value.`errorDetails`) ) } } - override fun write(value: DecodingException, buf: ByteBuffer) { + override fun write(value: JadeException, buf: ByteBuffer) { when (value) { - is DecodingException.InvalidFormat -> { + is JadeException.TransportException -> { buf.putInt(1) + FfiConverterString.write(value.`errorDetails`, buf) Unit } - is DecodingException.InvalidNetwork -> { + is JadeException.DeviceNotFound -> { buf.putInt(2) Unit } - is DecodingException.InvalidAmount -> { + is JadeException.DeviceDisconnected -> { buf.putInt(3) Unit } - is DecodingException.InvalidLnurlPayAmount -> { + is JadeException.DeviceBusy -> { buf.putInt(4) - FfiConverterULong.write(value.`amountSatoshis`, buf) - FfiConverterULong.write(value.`min`, buf) - FfiConverterULong.write(value.`max`, buf) Unit } - is DecodingException.InvalidTimestamp -> { + is JadeException.NotConnected -> { buf.putInt(5) Unit } - is DecodingException.InvalidChecksum -> { + is JadeException.NotInitialized -> { buf.putInt(6) Unit } - is DecodingException.InvalidResponse -> { + is JadeException.ConnectionException -> { buf.putInt(7) + FfiConverterString.write(value.`errorDetails`, buf) Unit } - is DecodingException.UnsupportedType -> { + is JadeException.ProtocolException -> { buf.putInt(8) + FfiConverterString.write(value.`errorDetails`, buf) Unit } - is DecodingException.InvalidAddress -> { + is JadeException.Timeout -> { buf.putInt(9) Unit } - is DecodingException.RequestFailed -> { + is JadeException.UserCancelled -> { buf.putInt(10) Unit } - is DecodingException.ClientCreationFailed -> { + is JadeException.DeviceLocked -> { buf.putInt(11) Unit } - is DecodingException.InvoiceCreationFailed -> { + is JadeException.DeviceUninitialized -> { buf.putInt(12) - FfiConverterString.write(value.`errorMessage`, buf) + Unit + } + is JadeException.InvalidPin -> { + buf.putInt(13) + Unit + } + is JadeException.NetworkMismatch -> { + buf.putInt(14) + FfiConverterString.write(value.`errorDetails`, buf) + Unit + } + is JadeException.UnsupportedFirmware -> { + buf.putInt(15) + FfiConverterString.write(value.`installed`, buf) + FfiConverterString.write(value.`required`, buf) + Unit + } + is JadeException.InvalidPath -> { + buf.putInt(16) + FfiConverterString.write(value.`errorDetails`, buf) + Unit + } + is JadeException.InvalidPsbt -> { + buf.putInt(17) + FfiConverterString.write(value.`errorDetails`, buf) + Unit + } + is JadeException.PsbtTooLarge -> { + buf.putInt(18) + FfiConverterULong.write(value.`size`, buf) + FfiConverterULong.write(value.`max`, buf) + Unit + } + is JadeException.FingerprintMismatch -> { + buf.putInt(19) + FfiConverterString.write(value.`device`, buf) + FfiConverterString.write(value.`psbt`, buf) + Unit + } + is JadeException.NothingSigned -> { + buf.putInt(20) + Unit + } + is JadeException.AddressMismatch -> { + buf.putInt(21) + FfiConverterString.write(value.`expected`, buf) + FfiConverterString.write(value.`returned`, buf) + Unit + } + is JadeException.PinServerException -> { + buf.putInt(22) + FfiConverterString.write(value.`errorDetails`, buf) + Unit + } + is JadeException.DeviceException -> { + buf.putInt(23) + FfiConverterString.write(value.`errorDetails`, buf) + Unit + } + is JadeException.IoException -> { + buf.putInt(24) + FfiConverterString.write(value.`errorDetails`, buf) Unit } }.let { /* this makes the `when` an expression, which ensures it is exhaustive */ } @@ -11305,16 +12761,16 @@ public object FfiConverterTypeDecodingError : FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): HardwareWalletTransport = try { - HardwareWalletTransport.entries[buf.getInt() - 1] +public object FfiConverterTypeJadeNetwork: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): JadeNetwork = try { + JadeNetwork.entries[buf.getInt() - 1] } catch (e: IndexOutOfBoundsException) { throw RuntimeException("invalid enum value, something is very wrong!!", e) } - override fun allocationSize(value: HardwareWalletTransport): ULong = 4UL + override fun allocationSize(value: JadeNetwork): ULong = 4UL - override fun write(value: HardwareWalletTransport, buf: ByteBuffer) { + override fun write(value: JadeNetwork, buf: ByteBuffer) { buf.putInt(value.ordinal + 1) } } @@ -11323,16 +12779,70 @@ public object FfiConverterTypeHardwareWalletTransport: FfiConverterRustBuffer { - override fun read(buf: ByteBuffer): HardwareWalletVendor = try { - HardwareWalletVendor.entries[buf.getInt() - 1] +public object FfiConverterTypeJadePingStatus: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): JadePingStatus = try { + JadePingStatus.entries[buf.getInt() - 1] } catch (e: IndexOutOfBoundsException) { throw RuntimeException("invalid enum value, something is very wrong!!", e) } - override fun allocationSize(value: HardwareWalletVendor): ULong = 4UL + override fun allocationSize(value: JadePingStatus): ULong = 4UL - override fun write(value: HardwareWalletVendor, buf: ByteBuffer) { + override fun write(value: JadePingStatus, buf: ByteBuffer) { + buf.putInt(value.ordinal + 1) + } +} + + + + + +public object FfiConverterTypeJadeState: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): JadeState = try { + JadeState.entries[buf.getInt() - 1] + } catch (e: IndexOutOfBoundsException) { + throw RuntimeException("invalid enum value, something is very wrong!!", e) + } + + override fun allocationSize(value: JadeState): ULong = 4UL + + override fun write(value: JadeState, buf: ByteBuffer) { + buf.putInt(value.ordinal + 1) + } +} + + + + + +public object FfiConverterTypeJadeTransportErrorCode: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): JadeTransportErrorCode = try { + JadeTransportErrorCode.entries[buf.getInt() - 1] + } catch (e: IndexOutOfBoundsException) { + throw RuntimeException("invalid enum value, something is very wrong!!", e) + } + + override fun allocationSize(value: JadeTransportErrorCode): ULong = 4UL + + override fun write(value: JadeTransportErrorCode, buf: ByteBuffer) { + buf.putInt(value.ordinal + 1) + } +} + + + + + +public object FfiConverterTypeJadeTransportKind: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): JadeTransportKind = try { + JadeTransportKind.entries[buf.getInt() - 1] + } catch (e: IndexOutOfBoundsException) { + throw RuntimeException("invalid enum value, something is very wrong!!", e) + } + + override fun allocationSize(value: JadeTransportKind): ULong = 4UL + + override fun write(value: JadeTransportKind, buf: ByteBuffer) { buf.putInt(value.ordinal + 1) } } @@ -13534,6 +15044,64 @@ public object FfiConverterOptionalTypeILspNode: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): JadeDeviceInfo? { + if (buf.get().toInt() == 0) { + return null + } + return FfiConverterTypeJadeDeviceInfo.read(buf) + } + + override fun allocationSize(value: JadeDeviceInfo?): ULong { + if (value == null) { + return 1UL + } else { + return 1UL + FfiConverterTypeJadeDeviceInfo.allocationSize(value) + } + } + + override fun write(value: JadeDeviceInfo?, buf: ByteBuffer) { + if (value == null) { + buf.put(0) + } else { + buf.put(1) + FfiConverterTypeJadeDeviceInfo.write(value, buf) + } + } +} + + + + +public object FfiConverterOptionalTypeJadeVersionInfo: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): JadeVersionInfo? { + if (buf.get().toInt() == 0) { + return null + } + return FfiConverterTypeJadeVersionInfo.read(buf) + } + + override fun allocationSize(value: JadeVersionInfo?): ULong { + if (value == null) { + return 1UL + } else { + return 1UL + FfiConverterTypeJadeVersionInfo.allocationSize(value) + } + } + + override fun write(value: JadeVersionInfo?, buf: ByteBuffer) { + if (value == null) { + buf.put(0) + } else { + buf.put(1) + FfiConverterTypeJadeVersionInfo.write(value, buf) + } + } +} + + + + public object FfiConverterOptionalTypeOnchainActivity: FfiConverterRustBuffer { override fun read(buf: ByteBuffer): OnchainActivity? { if (buf.get().toInt() == 0) { @@ -13911,6 +15479,35 @@ public object FfiConverterOptionalTypeCoinSelection: FfiConverterRustBuffer { + override fun read(buf: ByteBuffer): JadeTransportErrorCode? { + if (buf.get().toInt() == 0) { + return null + } + return FfiConverterTypeJadeTransportErrorCode.read(buf) + } + + override fun allocationSize(value: JadeTransportErrorCode?): ULong { + if (value == null) { + return 1UL + } else { + return 1UL + FfiConverterTypeJadeTransportErrorCode.allocationSize(value) + } + } + + override fun write(value: JadeTransportErrorCode?, buf: ByteBuffer) { + if (value == null) { + buf.put(0) + } else { + buf.put(1) + FfiConverterTypeJadeTransportErrorCode.write(value, buf) + } + } +} + + + + public object FfiConverterOptionalTypeNetwork: FfiConverterRustBuffer { override fun read(buf: ByteBuffer): Network? { if (buf.get().toInt() == 0) { @@ -14587,21 +16184,96 @@ public object FfiConverterSequenceTypeILspNode: FfiConverterRustBuffer> { override fun read(buf: ByteBuffer): List { val len = buf.getInt() - return List(len) { - FfiConverterTypeIManualRefund.read(buf) + return List(len) { + FfiConverterTypeIManualRefund.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.sumOf { FfiConverterTypeIManualRefund.allocationSize(it) } + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeIManualRefund.write(it, buf) + } + } +} + + + + +public object FfiConverterSequenceTypeJadeAccount: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeJadeAccount.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.sumOf { FfiConverterTypeJadeAccount.allocationSize(it) } + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeJadeAccount.write(it, buf) + } + } +} + + + + +public object FfiConverterSequenceTypeJadeDeviceInfo: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeJadeDeviceInfo.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.sumOf { FfiConverterTypeJadeDeviceInfo.allocationSize(it) } + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeJadeDeviceInfo.write(it, buf) + } + } +} + + + + +public object FfiConverterSequenceTypeJadeNativeDevice: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeJadeNativeDevice.read(buf) } } - override fun allocationSize(value: List): ULong { + override fun allocationSize(value: List): ULong { val sizeForLength = 4UL - val sizeForItems = value.sumOf { FfiConverterTypeIManualRefund.allocationSize(it) } + val sizeForItems = value.sumOf { FfiConverterTypeJadeNativeDevice.allocationSize(it) } return sizeForLength + sizeForItems } - override fun write(value: List, buf: ByteBuffer) { + override fun write(value: List, buf: ByteBuffer) { buf.putInt(value.size) value.iterator().forEach { - FfiConverterTypeIManualRefund.write(it, buf) + FfiConverterTypeJadeNativeDevice.write(it, buf) } } } @@ -15059,6 +16731,31 @@ public object FfiConverterSequenceTypeTxOutput: FfiConverterRustBuffer> { + override fun read(buf: ByteBuffer): List { + val len = buf.getInt() + return List(len) { + FfiConverterTypeAccountType.read(buf) + } + } + + override fun allocationSize(value: List): ULong { + val sizeForLength = 4UL + val sizeForItems = value.sumOf { FfiConverterTypeAccountType.allocationSize(it) } + return sizeForLength + sizeForItems + } + + override fun write(value: List, buf: ByteBuffer) { + buf.putInt(value.size) + value.iterator().forEach { + FfiConverterTypeAccountType.write(it, buf) + } + } +} + + + + public object FfiConverterSequenceTypeActivity: FfiConverterRustBuffer> { override fun read(buf: ByteBuffer): List { val len = buf.getInt() @@ -15476,685 +17173,989 @@ public suspend fun `boltzGetReverseLimits`(`network`: BoltzNetwork): BoltzPairIn // lift function { FfiConverterTypeBoltzPairInfo.lift(it) }, // Error FFI converter - BoltzExceptionErrorHandler, + BoltzExceptionErrorHandler, + ) +} + +/** + * Fetch fees and limits for submarine swaps (onchain -> Lightning). + */ +@Throws(BoltzException::class, kotlin.coroutines.cancellation.CancellationException::class) +public suspend fun `boltzGetSubmarineLimits`(`network`: BoltzNetwork): BoltzPairInfo { + return uniffiRustCallAsync( + UniffiLib.uniffi_bitkitcore_fn_func_boltz_get_submarine_limits( + FfiConverterTypeBoltzNetwork.lower(`network`), + ), + { future, callback, continuation -> UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer(future, callback, continuation) }, + { future, continuation -> UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer(future, continuation) }, + { future -> UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer(future) }, + { future -> UniffiLib.ffi_bitkitcore_rust_future_cancel_rust_buffer(future) }, + // lift function + { FfiConverterTypeBoltzPairInfo.lift(it) }, + // Error FFI converter + BoltzExceptionErrorHandler, + ) +} + +/** + * Fetch a single swap by id. + */ +@Throws(BoltzException::class, kotlin.coroutines.cancellation.CancellationException::class) +public suspend fun `boltzGetSwap`(`swapId`: kotlin.String): BoltzSwap? { + return uniffiRustCallAsync( + UniffiLib.uniffi_bitkitcore_fn_func_boltz_get_swap( + FfiConverterString.lower(`swapId`), + ), + { future, callback, continuation -> UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer(future, callback, continuation) }, + { future, continuation -> UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer(future, continuation) }, + { future -> UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer(future) }, + { future -> UniffiLib.ffi_bitkitcore_rust_future_cancel_rust_buffer(future) }, + // lift function + { FfiConverterOptionalTypeBoltzSwap.lift(it) }, + // Error FFI converter + BoltzExceptionErrorHandler, + ) +} + +/** + * List swaps that have not reached a terminal state (for recovery/resume). + */ +@Throws(BoltzException::class, kotlin.coroutines.cancellation.CancellationException::class) +public suspend fun `boltzListPendingSwaps`(): List { + return uniffiRustCallAsync( + UniffiLib.uniffi_bitkitcore_fn_func_boltz_list_pending_swaps( + ), + { future, callback, continuation -> UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer(future, callback, continuation) }, + { future, continuation -> UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer(future, continuation) }, + { future -> UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer(future) }, + { future -> UniffiLib.ffi_bitkitcore_rust_future_cancel_rust_buffer(future) }, + // lift function + { FfiConverterSequenceTypeBoltzSwap.lift(it) }, + // Error FFI converter + BoltzExceptionErrorHandler, + ) +} + +/** + * List every persisted swap, newest first. + */ +@Throws(BoltzException::class, kotlin.coroutines.cancellation.CancellationException::class) +public suspend fun `boltzListSwaps`(): List { + return uniffiRustCallAsync( + UniffiLib.uniffi_bitkitcore_fn_func_boltz_list_swaps( + ), + { future, callback, continuation -> UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer(future, callback, continuation) }, + { future, continuation -> UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer(future, continuation) }, + { future -> UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer(future) }, + { future -> UniffiLib.ffi_bitkitcore_rust_future_cancel_rust_buffer(future) }, + // lift function + { FfiConverterSequenceTypeBoltzSwap.lift(it) }, + // Error FFI converter + BoltzExceptionErrorHandler, + ) +} + +/** + * Refund a submarine swap's locked funds to `refund_address`, returning the + * broadcast refund transaction id. Used when Boltz fails to pay the invoice or + * the swap expires. The refund key is re-derived from `mnemonic`. Refunds are + * serialized per swap, so two concurrent calls cannot both broadcast: the second + * waits for the first and returns its txid. + */ +@Throws(BoltzException::class, kotlin.coroutines.cancellation.CancellationException::class) +public suspend fun `boltzRefundSubmarineSwap`(`swapId`: kotlin.String, `refundAddress`: kotlin.String, `mnemonic`: kotlin.String, `bip39Passphrase`: kotlin.String?, `feeRateSatPerVb`: kotlin.Double?): kotlin.String { + return uniffiRustCallAsync( + UniffiLib.uniffi_bitkitcore_fn_func_boltz_refund_submarine_swap( + FfiConverterString.lower(`swapId`), + FfiConverterString.lower(`refundAddress`), + FfiConverterString.lower(`mnemonic`), + FfiConverterOptionalString.lower(`bip39Passphrase`), + FfiConverterOptionalDouble.lower(`feeRateSatPerVb`), + ), + { future, callback, continuation -> UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer(future, callback, continuation) }, + { future, continuation -> UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer(future, continuation) }, + { future -> UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer(future) }, + { future -> UniffiLib.ffi_bitkitcore_rust_future_cancel_rust_buffer(future) }, + // lift function + { FfiConverterString.lift(it) }, + // Error FFI converter + BoltzExceptionErrorHandler, + ) +} + +/** + * Open a Boltz WebSocket for `network`, subscribe to all pending swaps, and + * drive their lifecycle (auto-claiming reverse swaps) until stopped. Replaces + * any previously running updates stream (only one network is tracked at a + * time). `mnemonic` is held in memory for the lifetime of the stream so + * confirmed reverse swaps can be auto-claimed; it is never persisted. Events + * are delivered to `listener`. + * + * `fee_rate_sat_per_vb` is the fee rate used for automatic claim transactions. + * Bitkit owns fee estimation and should pass its current recommended rate; when + * `None`, a conservative built-in default is used. To auto-claim at an updated + * fee rate, call this again (it restarts the stream). + * + * `accept_zero_conf` claims reverse swaps as soon as Boltz's lockup enters the + * mempool instead of waiting for its confirmation. That reveals the preimage + * against an unconfirmed lockup: if the lockup were replaced before + * confirming, the user would be debited on Lightning without receiving + * onchain funds. Pass `false` to keep the confirmation-gated default. + */ +@Throws(BoltzException::class, kotlin.coroutines.cancellation.CancellationException::class) +public suspend fun `boltzStartSwapUpdates`(`network`: BoltzNetwork, `listener`: BoltzEventListener, `mnemonic`: kotlin.String, `bip39Passphrase`: kotlin.String?, `feeRateSatPerVb`: kotlin.Double?, `acceptZeroConf`: kotlin.Boolean) { + return uniffiRustCallAsync( + UniffiLib.uniffi_bitkitcore_fn_func_boltz_start_swap_updates( + FfiConverterTypeBoltzNetwork.lower(`network`), + FfiConverterTypeBoltzEventListener.lower(`listener`), + FfiConverterString.lower(`mnemonic`), + FfiConverterOptionalString.lower(`bip39Passphrase`), + FfiConverterOptionalDouble.lower(`feeRateSatPerVb`), + FfiConverterBoolean.lower(`acceptZeroConf`), + ), + { future, callback, continuation -> UniffiLib.ffi_bitkitcore_rust_future_poll_void(future, callback, continuation) }, + { future, continuation -> UniffiLib.ffi_bitkitcore_rust_future_complete_void(future, continuation) }, + { future -> UniffiLib.ffi_bitkitcore_rust_future_free_void(future) }, + { future -> UniffiLib.ffi_bitkitcore_rust_future_cancel_void(future) }, + // lift function + { Unit }, + + // Error FFI converter + BoltzExceptionErrorHandler, + ) +} + +/** + * Stop the running Boltz updates stream, if any. + */ +public suspend fun `boltzStopSwapUpdates`() { + return uniffiRustCallAsync( + UniffiLib.uniffi_bitkitcore_fn_func_boltz_stop_swap_updates( + ), + { future, callback, continuation -> UniffiLib.ffi_bitkitcore_rust_future_poll_void(future, callback, continuation) }, + { future, continuation -> UniffiLib.ffi_bitkitcore_rust_future_complete_void(future, continuation) }, + { future -> UniffiLib.ffi_bitkitcore_rust_future_free_void(future) }, + { future -> UniffiLib.ffi_bitkitcore_rust_future_cancel_void(future) }, + // lift function + { Unit }, + + // Error FFI converter + UniffiNullRustCallStatusErrorHandler, + ) +} + +@Throws(SweepException::class, kotlin.coroutines.cancellation.CancellationException::class) +public suspend fun `broadcastSweepTransaction`(`psbt`: kotlin.String, `mnemonicPhrase`: kotlin.String, `network`: Network?, `bip39Passphrase`: kotlin.String?, `electrumUrl`: kotlin.String): SweepResult { + return uniffiRustCallAsync( + UniffiLib.uniffi_bitkitcore_fn_func_broadcast_sweep_transaction( + FfiConverterString.lower(`psbt`), + FfiConverterString.lower(`mnemonicPhrase`), + FfiConverterOptionalTypeNetwork.lower(`network`), + FfiConverterOptionalString.lower(`bip39Passphrase`), + FfiConverterString.lower(`electrumUrl`), + ), + { future, callback, continuation -> UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer(future, callback, continuation) }, + { future, continuation -> UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer(future, continuation) }, + { future -> UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer(future) }, + { future -> UniffiLib.ffi_bitkitcore_rust_future_cancel_rust_buffer(future) }, + // lift function + { FfiConverterTypeSweepResult.lift(it) }, + // Error FFI converter + SweepExceptionErrorHandler, + ) +} + +public fun `calculateChannelLiquidityOptions`(`params`: ChannelLiquidityParams): ChannelLiquidityOptions { + return FfiConverterTypeChannelLiquidityOptions.lift(uniffiRustCall { uniffiRustCallStatus -> + UniffiLib.uniffi_bitkitcore_fn_func_calculate_channel_liquidity_options( + FfiConverterTypeChannelLiquidityParams.lower(`params`), + uniffiRustCallStatus, + ) + }) +} + +@Throws(PubkyException::class, kotlin.coroutines.cancellation.CancellationException::class) +public suspend fun `cancelPubkyAuth`() { + return uniffiRustCallAsync( + UniffiLib.uniffi_bitkitcore_fn_func_cancel_pubky_auth( + ), + { future, callback, continuation -> UniffiLib.ffi_bitkitcore_rust_future_poll_void(future, callback, continuation) }, + { future, continuation -> UniffiLib.ffi_bitkitcore_rust_future_complete_void(future, continuation) }, + { future -> UniffiLib.ffi_bitkitcore_rust_future_free_void(future) }, + { future -> UniffiLib.ffi_bitkitcore_rust_future_cancel_void(future) }, + // lift function + { Unit }, + + // Error FFI converter + PubkyExceptionErrorHandler, + ) +} + +@Throws(SweepException::class, kotlin.coroutines.cancellation.CancellationException::class) +public suspend fun `checkSweepableBalances`(`mnemonicPhrase`: kotlin.String, `network`: Network?, `bip39Passphrase`: kotlin.String?, `electrumUrl`: kotlin.String): SweepableBalances { + return uniffiRustCallAsync( + UniffiLib.uniffi_bitkitcore_fn_func_check_sweepable_balances( + FfiConverterString.lower(`mnemonicPhrase`), + FfiConverterOptionalTypeNetwork.lower(`network`), + FfiConverterOptionalString.lower(`bip39Passphrase`), + FfiConverterString.lower(`electrumUrl`), + ), + { future, callback, continuation -> UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer(future, callback, continuation) }, + { future, continuation -> UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer(future, continuation) }, + { future -> UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer(future) }, + { future -> UniffiLib.ffi_bitkitcore_rust_future_cancel_rust_buffer(future) }, + // lift function + { FfiConverterTypeSweepableBalances.lift(it) }, + // Error FFI converter + SweepExceptionErrorHandler, ) } /** - * Fetch fees and limits for submarine swaps (onchain -> Lightning). + * Decode closed channels from Core's canonical backup JSON. */ -@Throws(BoltzException::class, kotlin.coroutines.cancellation.CancellationException::class) -public suspend fun `boltzGetSubmarineLimits`(`network`: BoltzNetwork): BoltzPairInfo { +@Throws(ActivityException::class) +public fun `closedChannelsFromJson`(`json`: kotlin.String): List { + return FfiConverterSequenceTypeClosedChannelDetails.lift(uniffiRustCallWithError(ActivityExceptionErrorHandler) { uniffiRustCallStatus -> + UniffiLib.uniffi_bitkitcore_fn_func_closed_channels_from_json( + FfiConverterString.lower(`json`), + uniffiRustCallStatus, + ) + }) +} + +/** + * Serialize closed channels to Core's canonical backup JSON. Closed channels + * are not wallet-scoped, so no wallet-id normalization is applied. + */ +@Throws(ActivityException::class) +public fun `closedChannelsToJson`(`channels`: List): kotlin.String { + return FfiConverterString.lift(uniffiRustCallWithError(ActivityExceptionErrorHandler) { uniffiRustCallStatus -> + UniffiLib.uniffi_bitkitcore_fn_func_closed_channels_to_json( + FfiConverterSequenceTypeClosedChannelDetails.lower(`channels`), + uniffiRustCallStatus, + ) + }) +} + +@Throws(PubkyException::class, kotlin.coroutines.cancellation.CancellationException::class) +public suspend fun `completePubkyAuth`(): kotlin.String { return uniffiRustCallAsync( - UniffiLib.uniffi_bitkitcore_fn_func_boltz_get_submarine_limits( - FfiConverterTypeBoltzNetwork.lower(`network`), + UniffiLib.uniffi_bitkitcore_fn_func_complete_pubky_auth( ), { future, callback, continuation -> UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer(future, callback, continuation) }, { future, continuation -> UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer(future, continuation) }, { future -> UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer(future) }, { future -> UniffiLib.ffi_bitkitcore_rust_future_cancel_rust_buffer(future) }, // lift function - { FfiConverterTypeBoltzPairInfo.lift(it) }, + { FfiConverterString.lift(it) }, // Error FFI converter - BoltzExceptionErrorHandler, + PubkyExceptionErrorHandler, ) } -/** - * Fetch a single swap by id. - */ -@Throws(BoltzException::class, kotlin.coroutines.cancellation.CancellationException::class) -public suspend fun `boltzGetSwap`(`swapId`: kotlin.String): BoltzSwap? { +@Throws(LnurlException::class) +public fun `createChannelRequestUrl`(`k1`: kotlin.String, `callback`: kotlin.String, `localNodeId`: kotlin.String, `isPrivate`: kotlin.Boolean, `cancel`: kotlin.Boolean): kotlin.String { + return FfiConverterString.lift(uniffiRustCallWithError(LnurlExceptionErrorHandler) { uniffiRustCallStatus -> + UniffiLib.uniffi_bitkitcore_fn_func_create_channel_request_url( + FfiConverterString.lower(`k1`), + FfiConverterString.lower(`callback`), + FfiConverterString.lower(`localNodeId`), + FfiConverterBoolean.lower(`isPrivate`), + FfiConverterBoolean.lower(`cancel`), + uniffiRustCallStatus, + ) + }) +} + +@Throws(BlocktankException::class, kotlin.coroutines.cancellation.CancellationException::class) +public suspend fun `createCjitEntry`(`channelSizeSat`: kotlin.ULong, `invoiceSat`: kotlin.ULong, `invoiceDescription`: kotlin.String, `nodeId`: kotlin.String, `channelExpiryWeeks`: kotlin.UInt, `options`: CreateCjitOptions?): IcJitEntry { return uniffiRustCallAsync( - UniffiLib.uniffi_bitkitcore_fn_func_boltz_get_swap( - FfiConverterString.lower(`swapId`), + UniffiLib.uniffi_bitkitcore_fn_func_create_cjit_entry( + FfiConverterULong.lower(`channelSizeSat`), + FfiConverterULong.lower(`invoiceSat`), + FfiConverterString.lower(`invoiceDescription`), + FfiConverterString.lower(`nodeId`), + FfiConverterUInt.lower(`channelExpiryWeeks`), + FfiConverterOptionalTypeCreateCjitOptions.lower(`options`), ), { future, callback, continuation -> UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer(future, callback, continuation) }, { future, continuation -> UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer(future, continuation) }, { future -> UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer(future) }, { future -> UniffiLib.ffi_bitkitcore_rust_future_cancel_rust_buffer(future) }, // lift function - { FfiConverterOptionalTypeBoltzSwap.lift(it) }, + { FfiConverterTypeICJitEntry.lift(it) }, // Error FFI converter - BoltzExceptionErrorHandler, + BlocktankExceptionErrorHandler, ) } -/** - * List swaps that have not reached a terminal state (for recovery/resume). - */ -@Throws(BoltzException::class, kotlin.coroutines.cancellation.CancellationException::class) -public suspend fun `boltzListPendingSwaps`(): List { +@Throws(BlocktankException::class, kotlin.coroutines.cancellation.CancellationException::class) +public suspend fun `createOrder`(`lspBalanceSat`: kotlin.ULong, `channelExpiryWeeks`: kotlin.UInt, `options`: CreateOrderOptions?): IBtOrder { return uniffiRustCallAsync( - UniffiLib.uniffi_bitkitcore_fn_func_boltz_list_pending_swaps( + UniffiLib.uniffi_bitkitcore_fn_func_create_order( + FfiConverterULong.lower(`lspBalanceSat`), + FfiConverterUInt.lower(`channelExpiryWeeks`), + FfiConverterOptionalTypeCreateOrderOptions.lower(`options`), ), { future, callback, continuation -> UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer(future, callback, continuation) }, { future, continuation -> UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer(future, continuation) }, { future -> UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer(future) }, { future -> UniffiLib.ffi_bitkitcore_rust_future_cancel_rust_buffer(future) }, // lift function - { FfiConverterSequenceTypeBoltzSwap.lift(it) }, + { FfiConverterTypeIBtOrder.lift(it) }, // Error FFI converter - BoltzExceptionErrorHandler, + BlocktankExceptionErrorHandler, ) } -/** - * List every persisted swap, newest first. - */ -@Throws(BoltzException::class, kotlin.coroutines.cancellation.CancellationException::class) -public suspend fun `boltzListSwaps`(): List { +@Throws(LnurlException::class) +public fun `createWithdrawCallbackUrl`(`k1`: kotlin.String, `callback`: kotlin.String, `paymentRequest`: kotlin.String): kotlin.String { + return FfiConverterString.lift(uniffiRustCallWithError(LnurlExceptionErrorHandler) { uniffiRustCallStatus -> + UniffiLib.uniffi_bitkitcore_fn_func_create_withdraw_callback_url( + FfiConverterString.lower(`k1`), + FfiConverterString.lower(`callback`), + FfiConverterString.lower(`paymentRequest`), + uniffiRustCallStatus, + ) + }) +} + +@Throws(DecodingException::class, kotlin.coroutines.cancellation.CancellationException::class) +public suspend fun `decode`(`invoice`: kotlin.String): Scanner { return uniffiRustCallAsync( - UniffiLib.uniffi_bitkitcore_fn_func_boltz_list_swaps( + UniffiLib.uniffi_bitkitcore_fn_func_decode( + FfiConverterString.lower(`invoice`), ), { future, callback, continuation -> UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer(future, callback, continuation) }, { future, continuation -> UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer(future, continuation) }, { future -> UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer(future) }, { future -> UniffiLib.ffi_bitkitcore_rust_future_cancel_rust_buffer(future) }, // lift function - { FfiConverterSequenceTypeBoltzSwap.lift(it) }, + { FfiConverterTypeScanner.lift(it) }, // Error FFI converter - BoltzExceptionErrorHandler, + DecodingExceptionErrorHandler, ) } +@Throws(ActivityException::class) +public fun `deleteActivitiesByWalletId`(`walletId`: kotlin.String): kotlin.UInt { + return FfiConverterUInt.lift(uniffiRustCallWithError(ActivityExceptionErrorHandler) { uniffiRustCallStatus -> + UniffiLib.uniffi_bitkitcore_fn_func_delete_activities_by_wallet_id( + FfiConverterString.lower(`walletId`), + uniffiRustCallStatus, + ) + }) +} + +@Throws(ActivityException::class) +public fun `deleteActivityById`(`walletId`: kotlin.String, `activityId`: kotlin.String): kotlin.Boolean { + return FfiConverterBoolean.lift(uniffiRustCallWithError(ActivityExceptionErrorHandler) { uniffiRustCallStatus -> + UniffiLib.uniffi_bitkitcore_fn_func_delete_activity_by_id( + FfiConverterString.lower(`walletId`), + FfiConverterString.lower(`activityId`), + uniffiRustCallStatus, + ) + }) +} + +@Throws(ActivityException::class) +public fun `deletePreActivityMetadata`(`walletId`: kotlin.String, `paymentId`: kotlin.String) { + uniffiRustCallWithError(ActivityExceptionErrorHandler) { uniffiRustCallStatus -> + UniffiLib.uniffi_bitkitcore_fn_func_delete_pre_activity_metadata( + FfiConverterString.lower(`walletId`), + FfiConverterString.lower(`paymentId`), + uniffiRustCallStatus, + ) + } +} + +@Throws(ActivityException::class) +public fun `deleteTransactionDetails`(`walletId`: kotlin.String, `txId`: kotlin.String): kotlin.Boolean { + return FfiConverterBoolean.lift(uniffiRustCallWithError(ActivityExceptionErrorHandler) { uniffiRustCallStatus -> + UniffiLib.uniffi_bitkitcore_fn_func_delete_transaction_details( + FfiConverterString.lower(`walletId`), + FfiConverterString.lower(`txId`), + uniffiRustCallStatus, + ) + }) +} + +@Throws(AddressException::class) +public fun `deriveBitcoinAddress`(`mnemonicPhrase`: kotlin.String, `derivationPathStr`: kotlin.String?, `network`: Network?, `bip39Passphrase`: kotlin.String?): GetAddressResponse { + return FfiConverterTypeGetAddressResponse.lift(uniffiRustCallWithError(AddressExceptionErrorHandler) { uniffiRustCallStatus -> + UniffiLib.uniffi_bitkitcore_fn_func_derive_bitcoin_address( + FfiConverterString.lower(`mnemonicPhrase`), + FfiConverterOptionalString.lower(`derivationPathStr`), + FfiConverterOptionalTypeNetwork.lower(`network`), + FfiConverterOptionalString.lower(`bip39Passphrase`), + uniffiRustCallStatus, + ) + }) +} + +@Throws(AddressException::class) +public fun `deriveBitcoinAddresses`(`mnemonicPhrase`: kotlin.String, `derivationPathStr`: kotlin.String?, `network`: Network?, `bip39Passphrase`: kotlin.String?, `isChange`: kotlin.Boolean?, `startIndex`: kotlin.UInt?, `count`: kotlin.UInt?): GetAddressesResponse { + return FfiConverterTypeGetAddressesResponse.lift(uniffiRustCallWithError(AddressExceptionErrorHandler) { uniffiRustCallStatus -> + UniffiLib.uniffi_bitkitcore_fn_func_derive_bitcoin_addresses( + FfiConverterString.lower(`mnemonicPhrase`), + FfiConverterOptionalString.lower(`derivationPathStr`), + FfiConverterOptionalTypeNetwork.lower(`network`), + FfiConverterOptionalString.lower(`bip39Passphrase`), + FfiConverterOptionalBoolean.lower(`isChange`), + FfiConverterOptionalUInt.lower(`startIndex`), + FfiConverterOptionalUInt.lower(`count`), + uniffiRustCallStatus, + ) + }) +} + +@Throws(AddressException::class) +public fun `deriveOnchainDescriptor`(`mnemonicPhrase`: kotlin.String, `network`: Network, `bip39Passphrase`: kotlin.String?, `accountType`: AccountType, `accountIndex`: kotlin.UInt): kotlin.String { + return FfiConverterString.lift(uniffiRustCallWithError(AddressExceptionErrorHandler) { uniffiRustCallStatus -> + UniffiLib.uniffi_bitkitcore_fn_func_derive_onchain_descriptor( + FfiConverterString.lower(`mnemonicPhrase`), + FfiConverterTypeNetwork.lower(`network`), + FfiConverterOptionalString.lower(`bip39Passphrase`), + FfiConverterTypeAccountType.lower(`accountType`), + FfiConverterUInt.lower(`accountIndex`), + uniffiRustCallStatus, + ) + }) +} + +@Throws(AddressException::class) +public fun `derivePrivateKey`(`mnemonicPhrase`: kotlin.String, `derivationPathStr`: kotlin.String?, `network`: Network?, `bip39Passphrase`: kotlin.String?): kotlin.String { + return FfiConverterString.lift(uniffiRustCallWithError(AddressExceptionErrorHandler) { uniffiRustCallStatus -> + UniffiLib.uniffi_bitkitcore_fn_func_derive_private_key( + FfiConverterString.lower(`mnemonicPhrase`), + FfiConverterOptionalString.lower(`derivationPathStr`), + FfiConverterOptionalTypeNetwork.lower(`network`), + FfiConverterOptionalString.lower(`bip39Passphrase`), + uniffiRustCallStatus, + ) + }) +} + +@Throws(PubkyException::class) +public fun `derivePubkySecretKey`(`seed`: kotlin.ByteArray): kotlin.String { + return FfiConverterString.lift(uniffiRustCallWithError(PubkyExceptionErrorHandler) { uniffiRustCallStatus -> + UniffiLib.uniffi_bitkitcore_fn_func_derive_pubky_secret_key( + FfiConverterByteArray.lower(`seed`), + uniffiRustCallStatus, + ) + }) +} + /** - * Refund a submarine swap's locked funds to `refund_address`, returning the - * broadcast refund transaction id. Used when Boltz fails to pay the invoice or - * the swap expires. The refund key is re-derived from `mnemonic`. Refunds are - * serialized per swap, so two concurrent calls cannot both broadcast: the second - * waits for the first and returns its txid. + * Derive a stable, cross-platform `wallet_id` for a hardware (watch-only) wallet + * from its account extended public keys. See `derive_wallet_id` in the activity + * module for the exact derivation. Order of `xpubs` does not matter. Returns an + * error if `device_type` is blank or `xpubs` is empty / has a blank entry. */ -@Throws(BoltzException::class, kotlin.coroutines.cancellation.CancellationException::class) -public suspend fun `boltzRefundSubmarineSwap`(`swapId`: kotlin.String, `refundAddress`: kotlin.String, `mnemonic`: kotlin.String, `bip39Passphrase`: kotlin.String?, `feeRateSatPerVb`: kotlin.Double?): kotlin.String { +@Throws(ActivityException::class) +public fun `deriveWalletId`(`deviceType`: kotlin.String, `xpubs`: List): kotlin.String { + return FfiConverterString.lift(uniffiRustCallWithError(ActivityExceptionErrorHandler) { uniffiRustCallStatus -> + UniffiLib.uniffi_bitkitcore_fn_func_derive_wallet_id( + FfiConverterString.lower(`deviceType`), + FfiConverterSequenceString.lower(`xpubs`), + uniffiRustCallStatus, + ) + }) +} + +@Throws(AddressException::class) +public fun `entropyToMnemonic`(`entropy`: kotlin.ByteArray): kotlin.String { + return FfiConverterString.lift(uniffiRustCallWithError(AddressExceptionErrorHandler) { uniffiRustCallStatus -> + UniffiLib.uniffi_bitkitcore_fn_func_entropy_to_mnemonic( + FfiConverterByteArray.lower(`entropy`), + uniffiRustCallStatus, + ) + }) +} + +@Throws(BlocktankException::class, kotlin.coroutines.cancellation.CancellationException::class) +public suspend fun `estimateOrderFee`(`lspBalanceSat`: kotlin.ULong, `channelExpiryWeeks`: kotlin.UInt, `options`: CreateOrderOptions?): IBtEstimateFeeResponse { return uniffiRustCallAsync( - UniffiLib.uniffi_bitkitcore_fn_func_boltz_refund_submarine_swap( - FfiConverterString.lower(`swapId`), - FfiConverterString.lower(`refundAddress`), - FfiConverterString.lower(`mnemonic`), - FfiConverterOptionalString.lower(`bip39Passphrase`), - FfiConverterOptionalDouble.lower(`feeRateSatPerVb`), + UniffiLib.uniffi_bitkitcore_fn_func_estimate_order_fee( + FfiConverterULong.lower(`lspBalanceSat`), + FfiConverterUInt.lower(`channelExpiryWeeks`), + FfiConverterOptionalTypeCreateOrderOptions.lower(`options`), ), { future, callback, continuation -> UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer(future, callback, continuation) }, { future, continuation -> UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer(future, continuation) }, { future -> UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer(future) }, { future -> UniffiLib.ffi_bitkitcore_rust_future_cancel_rust_buffer(future) }, // lift function - { FfiConverterString.lift(it) }, + { FfiConverterTypeIBtEstimateFeeResponse.lift(it) }, // Error FFI converter - BoltzExceptionErrorHandler, + BlocktankExceptionErrorHandler, ) } -/** - * Open a Boltz WebSocket for `network`, subscribe to all pending swaps, and - * drive their lifecycle (auto-claiming reverse swaps) until stopped. Replaces - * any previously running updates stream (only one network is tracked at a - * time). `mnemonic` is held in memory for the lifetime of the stream so - * confirmed reverse swaps can be auto-claimed; it is never persisted. Events - * are delivered to `listener`. - * - * `fee_rate_sat_per_vb` is the fee rate used for automatic claim transactions. - * Bitkit owns fee estimation and should pass its current recommended rate; when - * `None`, a conservative built-in default is used. To auto-claim at an updated - * fee rate, call this again (it restarts the stream). - * - * `accept_zero_conf` claims reverse swaps as soon as Boltz's lockup enters the - * mempool instead of waiting for its confirmation. That reveals the preimage - * against an unconfirmed lockup: if the lockup were replaced before - * confirming, the user would be debited on Lightning without receiving - * onchain funds. Pass `false` to keep the confirmation-gated default. - */ -@Throws(BoltzException::class, kotlin.coroutines.cancellation.CancellationException::class) -public suspend fun `boltzStartSwapUpdates`(`network`: BoltzNetwork, `listener`: BoltzEventListener, `mnemonic`: kotlin.String, `bip39Passphrase`: kotlin.String?, `feeRateSatPerVb`: kotlin.Double?, `acceptZeroConf`: kotlin.Boolean) { +@Throws(BlocktankException::class, kotlin.coroutines.cancellation.CancellationException::class) +public suspend fun `estimateOrderFeeFull`(`lspBalanceSat`: kotlin.ULong, `channelExpiryWeeks`: kotlin.UInt, `options`: CreateOrderOptions?): IBtEstimateFeeResponse2 { return uniffiRustCallAsync( - UniffiLib.uniffi_bitkitcore_fn_func_boltz_start_swap_updates( - FfiConverterTypeBoltzNetwork.lower(`network`), - FfiConverterTypeBoltzEventListener.lower(`listener`), - FfiConverterString.lower(`mnemonic`), - FfiConverterOptionalString.lower(`bip39Passphrase`), - FfiConverterOptionalDouble.lower(`feeRateSatPerVb`), - FfiConverterBoolean.lower(`acceptZeroConf`), + UniffiLib.uniffi_bitkitcore_fn_func_estimate_order_fee_full( + FfiConverterULong.lower(`lspBalanceSat`), + FfiConverterUInt.lower(`channelExpiryWeeks`), + FfiConverterOptionalTypeCreateOrderOptions.lower(`options`), ), - { future, callback, continuation -> UniffiLib.ffi_bitkitcore_rust_future_poll_void(future, callback, continuation) }, - { future, continuation -> UniffiLib.ffi_bitkitcore_rust_future_complete_void(future, continuation) }, - { future -> UniffiLib.ffi_bitkitcore_rust_future_free_void(future) }, - { future -> UniffiLib.ffi_bitkitcore_rust_future_cancel_void(future) }, + { future, callback, continuation -> UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer(future, callback, continuation) }, + { future, continuation -> UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer(future, continuation) }, + { future -> UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer(future) }, + { future -> UniffiLib.ffi_bitkitcore_rust_future_cancel_rust_buffer(future) }, // lift function - { Unit }, - + { FfiConverterTypeIBtEstimateFeeResponse2.lift(it) }, // Error FFI converter - BoltzExceptionErrorHandler, + BlocktankExceptionErrorHandler, ) } -/** - * Stop the running Boltz updates stream, if any. - */ -public suspend fun `boltzStopSwapUpdates`() { +@Throws(PubkyException::class, kotlin.coroutines.cancellation.CancellationException::class) +public suspend fun `fetchPubkyContacts`(`publicKey`: kotlin.String): List { return uniffiRustCallAsync( - UniffiLib.uniffi_bitkitcore_fn_func_boltz_stop_swap_updates( + UniffiLib.uniffi_bitkitcore_fn_func_fetch_pubky_contacts( + FfiConverterString.lower(`publicKey`), ), - { future, callback, continuation -> UniffiLib.ffi_bitkitcore_rust_future_poll_void(future, callback, continuation) }, - { future, continuation -> UniffiLib.ffi_bitkitcore_rust_future_complete_void(future, continuation) }, - { future -> UniffiLib.ffi_bitkitcore_rust_future_free_void(future) }, - { future -> UniffiLib.ffi_bitkitcore_rust_future_cancel_void(future) }, + { future, callback, continuation -> UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer(future, callback, continuation) }, + { future, continuation -> UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer(future, continuation) }, + { future -> UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer(future) }, + { future -> UniffiLib.ffi_bitkitcore_rust_future_cancel_rust_buffer(future) }, // lift function - { Unit }, - + { FfiConverterSequenceString.lift(it) }, // Error FFI converter - UniffiNullRustCallStatusErrorHandler, + PubkyExceptionErrorHandler, ) } -@Throws(SweepException::class, kotlin.coroutines.cancellation.CancellationException::class) -public suspend fun `broadcastSweepTransaction`(`psbt`: kotlin.String, `mnemonicPhrase`: kotlin.String, `network`: Network?, `bip39Passphrase`: kotlin.String?, `electrumUrl`: kotlin.String): SweepResult { +@Throws(PubkyException::class, kotlin.coroutines.cancellation.CancellationException::class) +public suspend fun `fetchPubkyFile`(`uri`: kotlin.String): kotlin.ByteArray { return uniffiRustCallAsync( - UniffiLib.uniffi_bitkitcore_fn_func_broadcast_sweep_transaction( - FfiConverterString.lower(`psbt`), - FfiConverterString.lower(`mnemonicPhrase`), - FfiConverterOptionalTypeNetwork.lower(`network`), - FfiConverterOptionalString.lower(`bip39Passphrase`), - FfiConverterString.lower(`electrumUrl`), + UniffiLib.uniffi_bitkitcore_fn_func_fetch_pubky_file( + FfiConverterString.lower(`uri`), ), { future, callback, continuation -> UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer(future, callback, continuation) }, { future, continuation -> UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer(future, continuation) }, { future -> UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer(future) }, { future -> UniffiLib.ffi_bitkitcore_rust_future_cancel_rust_buffer(future) }, // lift function - { FfiConverterTypeSweepResult.lift(it) }, + { FfiConverterByteArray.lift(it) }, // Error FFI converter - SweepExceptionErrorHandler, + PubkyExceptionErrorHandler, ) } -public fun `calculateChannelLiquidityOptions`(`params`: ChannelLiquidityParams): ChannelLiquidityOptions { - return FfiConverterTypeChannelLiquidityOptions.lift(uniffiRustCall { uniffiRustCallStatus -> - UniffiLib.uniffi_bitkitcore_fn_func_calculate_channel_liquidity_options( - FfiConverterTypeChannelLiquidityParams.lower(`params`), - uniffiRustCallStatus, - ) - }) -} - @Throws(PubkyException::class, kotlin.coroutines.cancellation.CancellationException::class) -public suspend fun `cancelPubkyAuth`() { +public suspend fun `fetchPubkyFileString`(`uri`: kotlin.String): kotlin.String { return uniffiRustCallAsync( - UniffiLib.uniffi_bitkitcore_fn_func_cancel_pubky_auth( + UniffiLib.uniffi_bitkitcore_fn_func_fetch_pubky_file_string( + FfiConverterString.lower(`uri`), ), - { future, callback, continuation -> UniffiLib.ffi_bitkitcore_rust_future_poll_void(future, callback, continuation) }, - { future, continuation -> UniffiLib.ffi_bitkitcore_rust_future_complete_void(future, continuation) }, - { future -> UniffiLib.ffi_bitkitcore_rust_future_free_void(future) }, - { future -> UniffiLib.ffi_bitkitcore_rust_future_cancel_void(future) }, + { future, callback, continuation -> UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer(future, callback, continuation) }, + { future, continuation -> UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer(future, continuation) }, + { future -> UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer(future) }, + { future -> UniffiLib.ffi_bitkitcore_rust_future_cancel_rust_buffer(future) }, // lift function - { Unit }, - + { FfiConverterString.lift(it) }, // Error FFI converter PubkyExceptionErrorHandler, ) } -@Throws(SweepException::class, kotlin.coroutines.cancellation.CancellationException::class) -public suspend fun `checkSweepableBalances`(`mnemonicPhrase`: kotlin.String, `network`: Network?, `bip39Passphrase`: kotlin.String?, `electrumUrl`: kotlin.String): SweepableBalances { +@Throws(PubkyException::class, kotlin.coroutines.cancellation.CancellationException::class) +public suspend fun `fetchPubkyProfile`(`publicKey`: kotlin.String): PubkyProfile { return uniffiRustCallAsync( - UniffiLib.uniffi_bitkitcore_fn_func_check_sweepable_balances( - FfiConverterString.lower(`mnemonicPhrase`), - FfiConverterOptionalTypeNetwork.lower(`network`), - FfiConverterOptionalString.lower(`bip39Passphrase`), - FfiConverterString.lower(`electrumUrl`), + UniffiLib.uniffi_bitkitcore_fn_func_fetch_pubky_profile( + FfiConverterString.lower(`publicKey`), ), { future, callback, continuation -> UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer(future, callback, continuation) }, { future, continuation -> UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer(future, continuation) }, { future -> UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer(future) }, { future -> UniffiLib.ffi_bitkitcore_rust_future_cancel_rust_buffer(future) }, // lift function - { FfiConverterTypeSweepableBalances.lift(it) }, + { FfiConverterTypePubkyProfile.lift(it) }, // Error FFI converter - SweepExceptionErrorHandler, + PubkyExceptionErrorHandler, ) } /** - * Decode closed channels from Core's canonical backup JSON. + * Combine and finalize a signed PSBT, then extract its broadcastable transaction. */ -@Throws(ActivityException::class) -public fun `closedChannelsFromJson`(`json`: kotlin.String): List { - return FfiConverterSequenceTypeClosedChannelDetails.lift(uniffiRustCallWithError(ActivityExceptionErrorHandler) { uniffiRustCallStatus -> - UniffiLib.uniffi_bitkitcore_fn_func_closed_channels_from_json( - FfiConverterString.lower(`json`), +@Throws(PsbtCompletionException::class) +public fun `finalizePsbt`(`originalPsbt`: kotlin.String, `signedPsbt`: kotlin.String): CompletedTransaction { + return FfiConverterTypeCompletedTransaction.lift(uniffiRustCallWithError(PsbtCompletionExceptionErrorHandler) { uniffiRustCallStatus -> + UniffiLib.uniffi_bitkitcore_fn_func_finalize_psbt( + FfiConverterString.lower(`originalPsbt`), + FfiConverterString.lower(`signedPsbt`), uniffiRustCallStatus, ) }) } -/** - * Serialize closed channels to Core's canonical backup JSON. Closed channels - * are not wallet-scoped, so no wallet-id normalization is applied. - */ -@Throws(ActivityException::class) -public fun `closedChannelsToJson`(`channels`: List): kotlin.String { - return FfiConverterString.lift(uniffiRustCallWithError(ActivityExceptionErrorHandler) { uniffiRustCallStatus -> - UniffiLib.uniffi_bitkitcore_fn_func_closed_channels_to_json( - FfiConverterSequenceTypeClosedChannelDetails.lower(`channels`), +@Throws(AddressException::class) +public fun `generateMnemonic`(`wordCount`: WordCount?): kotlin.String { + return FfiConverterString.lift(uniffiRustCallWithError(AddressExceptionErrorHandler) { uniffiRustCallStatus -> + UniffiLib.uniffi_bitkitcore_fn_func_generate_mnemonic( + FfiConverterOptionalTypeWordCount.lower(`wordCount`), uniffiRustCallStatus, ) }) } -@Throws(PubkyException::class, kotlin.coroutines.cancellation.CancellationException::class) -public suspend fun `completePubkyAuth`(): kotlin.String { - return uniffiRustCallAsync( - UniffiLib.uniffi_bitkitcore_fn_func_complete_pubky_auth( - ), - { future, callback, continuation -> UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer(future, callback, continuation) }, - { future, continuation -> UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer(future, continuation) }, - { future -> UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer(future) }, - { future -> UniffiLib.ffi_bitkitcore_rust_future_cancel_rust_buffer(future) }, - // lift function - { FfiConverterString.lift(it) }, - // Error FFI converter - PubkyExceptionErrorHandler, - ) -} - -@Throws(LnurlException::class) -public fun `createChannelRequestUrl`(`k1`: kotlin.String, `callback`: kotlin.String, `localNodeId`: kotlin.String, `isPrivate`: kotlin.Boolean, `cancel`: kotlin.Boolean): kotlin.String { - return FfiConverterString.lift(uniffiRustCallWithError(LnurlExceptionErrorHandler) { uniffiRustCallStatus -> - UniffiLib.uniffi_bitkitcore_fn_func_create_channel_request_url( - FfiConverterString.lower(`k1`), - FfiConverterString.lower(`callback`), - FfiConverterString.lower(`localNodeId`), - FfiConverterBoolean.lower(`isPrivate`), - FfiConverterBoolean.lower(`cancel`), +@Throws(ActivityException::class) +public fun `getActivities`(`walletId`: kotlin.String?, `filter`: ActivityFilter?, `txType`: PaymentType?, `tags`: List?, `search`: kotlin.String?, `minDate`: kotlin.ULong?, `maxDate`: kotlin.ULong?, `limit`: kotlin.UInt?, `sortDirection`: SortDirection?): List { + return FfiConverterSequenceTypeActivity.lift(uniffiRustCallWithError(ActivityExceptionErrorHandler) { uniffiRustCallStatus -> + UniffiLib.uniffi_bitkitcore_fn_func_get_activities( + FfiConverterOptionalString.lower(`walletId`), + FfiConverterOptionalTypeActivityFilter.lower(`filter`), + FfiConverterOptionalTypePaymentType.lower(`txType`), + FfiConverterOptionalSequenceString.lower(`tags`), + FfiConverterOptionalString.lower(`search`), + FfiConverterOptionalULong.lower(`minDate`), + FfiConverterOptionalULong.lower(`maxDate`), + FfiConverterOptionalUInt.lower(`limit`), + FfiConverterOptionalTypeSortDirection.lower(`sortDirection`), uniffiRustCallStatus, ) }) } -@Throws(BlocktankException::class, kotlin.coroutines.cancellation.CancellationException::class) -public suspend fun `createCjitEntry`(`channelSizeSat`: kotlin.ULong, `invoiceSat`: kotlin.ULong, `invoiceDescription`: kotlin.String, `nodeId`: kotlin.String, `channelExpiryWeeks`: kotlin.UInt, `options`: CreateCjitOptions?): IcJitEntry { - return uniffiRustCallAsync( - UniffiLib.uniffi_bitkitcore_fn_func_create_cjit_entry( - FfiConverterULong.lower(`channelSizeSat`), - FfiConverterULong.lower(`invoiceSat`), - FfiConverterString.lower(`invoiceDescription`), - FfiConverterString.lower(`nodeId`), - FfiConverterUInt.lower(`channelExpiryWeeks`), - FfiConverterOptionalTypeCreateCjitOptions.lower(`options`), - ), - { future, callback, continuation -> UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer(future, callback, continuation) }, - { future, continuation -> UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer(future, continuation) }, - { future -> UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer(future) }, - { future -> UniffiLib.ffi_bitkitcore_rust_future_cancel_rust_buffer(future) }, - // lift function - { FfiConverterTypeICJitEntry.lift(it) }, - // Error FFI converter - BlocktankExceptionErrorHandler, - ) -} - -@Throws(BlocktankException::class, kotlin.coroutines.cancellation.CancellationException::class) -public suspend fun `createOrder`(`lspBalanceSat`: kotlin.ULong, `channelExpiryWeeks`: kotlin.UInt, `options`: CreateOrderOptions?): IBtOrder { - return uniffiRustCallAsync( - UniffiLib.uniffi_bitkitcore_fn_func_create_order( - FfiConverterULong.lower(`lspBalanceSat`), - FfiConverterUInt.lower(`channelExpiryWeeks`), - FfiConverterOptionalTypeCreateOrderOptions.lower(`options`), - ), - { future, callback, continuation -> UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer(future, callback, continuation) }, - { future, continuation -> UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer(future, continuation) }, - { future -> UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer(future) }, - { future -> UniffiLib.ffi_bitkitcore_rust_future_cancel_rust_buffer(future) }, - // lift function - { FfiConverterTypeIBtOrder.lift(it) }, - // Error FFI converter - BlocktankExceptionErrorHandler, - ) +@Throws(ActivityException::class) +public fun `getActivitiesByTag`(`walletId`: kotlin.String?, `tag`: kotlin.String, `limit`: kotlin.UInt?, `sortDirection`: SortDirection?): List { + return FfiConverterSequenceTypeActivity.lift(uniffiRustCallWithError(ActivityExceptionErrorHandler) { uniffiRustCallStatus -> + UniffiLib.uniffi_bitkitcore_fn_func_get_activities_by_tag( + FfiConverterOptionalString.lower(`walletId`), + FfiConverterString.lower(`tag`), + FfiConverterOptionalUInt.lower(`limit`), + FfiConverterOptionalTypeSortDirection.lower(`sortDirection`), + uniffiRustCallStatus, + ) + }) } -@Throws(LnurlException::class) -public fun `createWithdrawCallbackUrl`(`k1`: kotlin.String, `callback`: kotlin.String, `paymentRequest`: kotlin.String): kotlin.String { - return FfiConverterString.lift(uniffiRustCallWithError(LnurlExceptionErrorHandler) { uniffiRustCallStatus -> - UniffiLib.uniffi_bitkitcore_fn_func_create_withdraw_callback_url( - FfiConverterString.lower(`k1`), - FfiConverterString.lower(`callback`), - FfiConverterString.lower(`paymentRequest`), +/** + * Activity tags for a single wallet scope, or every scope when `wallet_id` is `None`. + */ +@Throws(ActivityException::class) +public fun `getActivitiesTags`(`walletId`: kotlin.String?): List { + return FfiConverterSequenceTypeActivityTags.lift(uniffiRustCallWithError(ActivityExceptionErrorHandler) { uniffiRustCallStatus -> + UniffiLib.uniffi_bitkitcore_fn_func_get_activities_tags( + FfiConverterOptionalString.lower(`walletId`), uniffiRustCallStatus, ) }) } -@Throws(DecodingException::class, kotlin.coroutines.cancellation.CancellationException::class) -public suspend fun `decode`(`invoice`: kotlin.String): Scanner { - return uniffiRustCallAsync( - UniffiLib.uniffi_bitkitcore_fn_func_decode( - FfiConverterString.lower(`invoice`), - ), - { future, callback, continuation -> UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer(future, callback, continuation) }, - { future, continuation -> UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer(future, continuation) }, - { future -> UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer(future) }, - { future -> UniffiLib.ffi_bitkitcore_rust_future_cancel_rust_buffer(future) }, - // lift function - { FfiConverterTypeScanner.lift(it) }, - // Error FFI converter - DecodingExceptionErrorHandler, - ) +@Throws(ActivityException::class) +public fun `getActivityById`(`walletId`: kotlin.String, `activityId`: kotlin.String): Activity? { + return FfiConverterOptionalTypeActivity.lift(uniffiRustCallWithError(ActivityExceptionErrorHandler) { uniffiRustCallStatus -> + UniffiLib.uniffi_bitkitcore_fn_func_get_activity_by_id( + FfiConverterString.lower(`walletId`), + FfiConverterString.lower(`activityId`), + uniffiRustCallStatus, + ) + }) } @Throws(ActivityException::class) -public fun `deleteActivitiesByWalletId`(`walletId`: kotlin.String): kotlin.UInt { - return FfiConverterUInt.lift(uniffiRustCallWithError(ActivityExceptionErrorHandler) { uniffiRustCallStatus -> - UniffiLib.uniffi_bitkitcore_fn_func_delete_activities_by_wallet_id( +public fun `getActivityByTxId`(`walletId`: kotlin.String, `txId`: kotlin.String): OnchainActivity? { + return FfiConverterOptionalTypeOnchainActivity.lift(uniffiRustCallWithError(ActivityExceptionErrorHandler) { uniffiRustCallStatus -> + UniffiLib.uniffi_bitkitcore_fn_func_get_activity_by_tx_id( FfiConverterString.lower(`walletId`), + FfiConverterString.lower(`txId`), uniffiRustCallStatus, ) }) } @Throws(ActivityException::class) -public fun `deleteActivityById`(`walletId`: kotlin.String, `activityId`: kotlin.String): kotlin.Boolean { - return FfiConverterBoolean.lift(uniffiRustCallWithError(ActivityExceptionErrorHandler) { uniffiRustCallStatus -> - UniffiLib.uniffi_bitkitcore_fn_func_delete_activity_by_id( - FfiConverterString.lower(`walletId`), - FfiConverterString.lower(`activityId`), +public fun `getAllActivitiesTags`(): List { + return FfiConverterSequenceTypeActivityTags.lift(uniffiRustCallWithError(ActivityExceptionErrorHandler) { uniffiRustCallStatus -> + UniffiLib.uniffi_bitkitcore_fn_func_get_all_activities_tags( uniffiRustCallStatus, ) }) } @Throws(ActivityException::class) -public fun `deletePreActivityMetadata`(`walletId`: kotlin.String, `paymentId`: kotlin.String) { - uniffiRustCallWithError(ActivityExceptionErrorHandler) { uniffiRustCallStatus -> - UniffiLib.uniffi_bitkitcore_fn_func_delete_pre_activity_metadata( - FfiConverterString.lower(`walletId`), - FfiConverterString.lower(`paymentId`), +public fun `getAllClosedChannels`(`sortDirection`: SortDirection?): List { + return FfiConverterSequenceTypeClosedChannelDetails.lift(uniffiRustCallWithError(ActivityExceptionErrorHandler) { uniffiRustCallStatus -> + UniffiLib.uniffi_bitkitcore_fn_func_get_all_closed_channels( + FfiConverterOptionalTypeSortDirection.lower(`sortDirection`), uniffiRustCallStatus, ) - } + }) } @Throws(ActivityException::class) -public fun `deleteTransactionDetails`(`walletId`: kotlin.String, `txId`: kotlin.String): kotlin.Boolean { - return FfiConverterBoolean.lift(uniffiRustCallWithError(ActivityExceptionErrorHandler) { uniffiRustCallStatus -> - UniffiLib.uniffi_bitkitcore_fn_func_delete_transaction_details( - FfiConverterString.lower(`walletId`), - FfiConverterString.lower(`txId`), +public fun `getAllPreActivityMetadata`(): List { + return FfiConverterSequenceTypePreActivityMetadata.lift(uniffiRustCallWithError(ActivityExceptionErrorHandler) { uniffiRustCallStatus -> + UniffiLib.uniffi_bitkitcore_fn_func_get_all_pre_activity_metadata( uniffiRustCallStatus, ) }) } -@Throws(AddressException::class) -public fun `deriveBitcoinAddress`(`mnemonicPhrase`: kotlin.String, `derivationPathStr`: kotlin.String?, `network`: Network?, `bip39Passphrase`: kotlin.String?): GetAddressResponse { - return FfiConverterTypeGetAddressResponse.lift(uniffiRustCallWithError(AddressExceptionErrorHandler) { uniffiRustCallStatus -> - UniffiLib.uniffi_bitkitcore_fn_func_derive_bitcoin_address( - FfiConverterString.lower(`mnemonicPhrase`), - FfiConverterOptionalString.lower(`derivationPathStr`), - FfiConverterOptionalTypeNetwork.lower(`network`), - FfiConverterOptionalString.lower(`bip39Passphrase`), +@Throws(ActivityException::class) +public fun `getAllTransactionDetails`(): List { + return FfiConverterSequenceTypeTransactionDetails.lift(uniffiRustCallWithError(ActivityExceptionErrorHandler) { uniffiRustCallStatus -> + UniffiLib.uniffi_bitkitcore_fn_func_get_all_transaction_details( uniffiRustCallStatus, ) }) } -@Throws(AddressException::class) -public fun `deriveBitcoinAddresses`(`mnemonicPhrase`: kotlin.String, `derivationPathStr`: kotlin.String?, `network`: Network?, `bip39Passphrase`: kotlin.String?, `isChange`: kotlin.Boolean?, `startIndex`: kotlin.UInt?, `count`: kotlin.UInt?): GetAddressesResponse { - return FfiConverterTypeGetAddressesResponse.lift(uniffiRustCallWithError(AddressExceptionErrorHandler) { uniffiRustCallStatus -> - UniffiLib.uniffi_bitkitcore_fn_func_derive_bitcoin_addresses( - FfiConverterString.lower(`mnemonicPhrase`), - FfiConverterOptionalString.lower(`derivationPathStr`), - FfiConverterOptionalTypeNetwork.lower(`network`), - FfiConverterOptionalString.lower(`bip39Passphrase`), - FfiConverterOptionalBoolean.lower(`isChange`), - FfiConverterOptionalUInt.lower(`startIndex`), - FfiConverterOptionalUInt.lower(`count`), +@Throws(ActivityException::class) +public fun `getAllUniqueTags`(): List { + return FfiConverterSequenceString.lift(uniffiRustCallWithError(ActivityExceptionErrorHandler) { uniffiRustCallStatus -> + UniffiLib.uniffi_bitkitcore_fn_func_get_all_unique_tags( uniffiRustCallStatus, ) }) } -@Throws(AddressException::class) -public fun `deriveOnchainDescriptor`(`mnemonicPhrase`: kotlin.String, `network`: Network, `bip39Passphrase`: kotlin.String?, `accountType`: AccountType, `accountIndex`: kotlin.UInt): kotlin.String { - return FfiConverterString.lift(uniffiRustCallWithError(AddressExceptionErrorHandler) { uniffiRustCallStatus -> - UniffiLib.uniffi_bitkitcore_fn_func_derive_onchain_descriptor( - FfiConverterString.lower(`mnemonicPhrase`), - FfiConverterTypeNetwork.lower(`network`), - FfiConverterOptionalString.lower(`bip39Passphrase`), - FfiConverterTypeAccountType.lower(`accountType`), - FfiConverterUInt.lower(`accountIndex`), +public fun `getBip39Suggestions`(`partialWord`: kotlin.String, `limit`: kotlin.UInt): List { + return FfiConverterSequenceString.lift(uniffiRustCall { uniffiRustCallStatus -> + UniffiLib.uniffi_bitkitcore_fn_func_get_bip39_suggestions( + FfiConverterString.lower(`partialWord`), + FfiConverterUInt.lower(`limit`), uniffiRustCallStatus, ) }) } -@Throws(AddressException::class) -public fun `derivePrivateKey`(`mnemonicPhrase`: kotlin.String, `derivationPathStr`: kotlin.String?, `network`: Network?, `bip39Passphrase`: kotlin.String?): kotlin.String { - return FfiConverterString.lift(uniffiRustCallWithError(AddressExceptionErrorHandler) { uniffiRustCallStatus -> - UniffiLib.uniffi_bitkitcore_fn_func_derive_private_key( - FfiConverterString.lower(`mnemonicPhrase`), - FfiConverterOptionalString.lower(`derivationPathStr`), - FfiConverterOptionalTypeNetwork.lower(`network`), - FfiConverterOptionalString.lower(`bip39Passphrase`), +public fun `getBip39Wordlist`(): List { + return FfiConverterSequenceString.lift(uniffiRustCall { uniffiRustCallStatus -> + UniffiLib.uniffi_bitkitcore_fn_func_get_bip39_wordlist( uniffiRustCallStatus, ) }) } -@Throws(PubkyException::class) -public fun `derivePubkySecretKey`(`seed`: kotlin.ByteArray): kotlin.String { - return FfiConverterString.lift(uniffiRustCallWithError(PubkyExceptionErrorHandler) { uniffiRustCallStatus -> - UniffiLib.uniffi_bitkitcore_fn_func_derive_pubky_secret_key( - FfiConverterByteArray.lower(`seed`), +@Throws(BlocktankException::class, kotlin.coroutines.cancellation.CancellationException::class) +public suspend fun `getCjitEntries`(`entryIds`: List?, `filter`: CJitStateEnum?, `refresh`: kotlin.Boolean): List { + return uniffiRustCallAsync( + UniffiLib.uniffi_bitkitcore_fn_func_get_cjit_entries( + FfiConverterOptionalSequenceString.lower(`entryIds`), + FfiConverterOptionalTypeCJitStateEnum.lower(`filter`), + FfiConverterBoolean.lower(`refresh`), + ), + { future, callback, continuation -> UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer(future, callback, continuation) }, + { future, continuation -> UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer(future, continuation) }, + { future -> UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer(future) }, + { future -> UniffiLib.ffi_bitkitcore_rust_future_cancel_rust_buffer(future) }, + // lift function + { FfiConverterSequenceTypeICJitEntry.lift(it) }, + // Error FFI converter + BlocktankExceptionErrorHandler, + ) +} + +@Throws(ActivityException::class) +public fun `getClosedChannelById`(`channelId`: kotlin.String): ClosedChannelDetails? { + return FfiConverterOptionalTypeClosedChannelDetails.lift(uniffiRustCallWithError(ActivityExceptionErrorHandler) { uniffiRustCallStatus -> + UniffiLib.uniffi_bitkitcore_fn_func_get_closed_channel_by_id( + FfiConverterString.lower(`channelId`), uniffiRustCallStatus, ) }) } /** - * Derive a stable, cross-platform `wallet_id` for a hardware (watch-only) wallet - * from its account extended public keys. See `derive_wallet_id` in the activity - * module for the exact derivation. Order of `xpubs` does not matter. Returns an - * error if `device_type` is blank or `xpubs` is empty / has a blank entry. + * The default address gap limit used by account scanning and the xpub watcher. + * Exposed so platforms reference one source of truth instead of hardcoding 20. */ -@Throws(ActivityException::class) -public fun `deriveWalletId`(`deviceType`: kotlin.String, `xpubs`: List): kotlin.String { - return FfiConverterString.lift(uniffiRustCallWithError(ActivityExceptionErrorHandler) { uniffiRustCallStatus -> - UniffiLib.uniffi_bitkitcore_fn_func_derive_wallet_id( - FfiConverterString.lower(`deviceType`), - FfiConverterSequenceString.lower(`xpubs`), +public fun `getDefaultGapLimit`(): kotlin.UInt { + return FfiConverterUInt.lift(uniffiRustCall { uniffiRustCallStatus -> + UniffiLib.uniffi_bitkitcore_fn_func_get_default_gap_limit( uniffiRustCallStatus, ) }) } -@Throws(AddressException::class) -public fun `entropyToMnemonic`(`entropy`: kotlin.ByteArray): kotlin.String { - return FfiConverterString.lift(uniffiRustCallWithError(AddressExceptionErrorHandler) { uniffiRustCallStatus -> - UniffiLib.uniffi_bitkitcore_fn_func_entropy_to_mnemonic( - FfiConverterByteArray.lower(`entropy`), +public fun `getDefaultLspBalance`(`params`: DefaultLspBalanceParams): kotlin.ULong { + return FfiConverterULong.lift(uniffiRustCall { uniffiRustCallStatus -> + UniffiLib.uniffi_bitkitcore_fn_func_get_default_lsp_balance( + FfiConverterTypeDefaultLspBalanceParams.lower(`params`), + uniffiRustCallStatus, + ) + }) +} + +public fun `getDefaultWalletId`(): kotlin.String { + return FfiConverterString.lift(uniffiRustCall { uniffiRustCallStatus -> + UniffiLib.uniffi_bitkitcore_fn_func_get_default_wallet_id( uniffiRustCallStatus, ) }) } @Throws(BlocktankException::class, kotlin.coroutines.cancellation.CancellationException::class) -public suspend fun `estimateOrderFee`(`lspBalanceSat`: kotlin.ULong, `channelExpiryWeeks`: kotlin.UInt, `options`: CreateOrderOptions?): IBtEstimateFeeResponse { +public suspend fun `getGift`(`giftId`: kotlin.String): IGift { return uniffiRustCallAsync( - UniffiLib.uniffi_bitkitcore_fn_func_estimate_order_fee( - FfiConverterULong.lower(`lspBalanceSat`), - FfiConverterUInt.lower(`channelExpiryWeeks`), - FfiConverterOptionalTypeCreateOrderOptions.lower(`options`), + UniffiLib.uniffi_bitkitcore_fn_func_get_gift( + FfiConverterString.lower(`giftId`), ), { future, callback, continuation -> UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer(future, callback, continuation) }, { future, continuation -> UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer(future, continuation) }, { future -> UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer(future) }, { future -> UniffiLib.ffi_bitkitcore_rust_future_cancel_rust_buffer(future) }, // lift function - { FfiConverterTypeIBtEstimateFeeResponse.lift(it) }, + { FfiConverterTypeIGift.lift(it) }, // Error FFI converter BlocktankExceptionErrorHandler, ) } @Throws(BlocktankException::class, kotlin.coroutines.cancellation.CancellationException::class) -public suspend fun `estimateOrderFeeFull`(`lspBalanceSat`: kotlin.ULong, `channelExpiryWeeks`: kotlin.UInt, `options`: CreateOrderOptions?): IBtEstimateFeeResponse2 { +public suspend fun `getInfo`(`refresh`: kotlin.Boolean?): IBtInfo? { return uniffiRustCallAsync( - UniffiLib.uniffi_bitkitcore_fn_func_estimate_order_fee_full( - FfiConverterULong.lower(`lspBalanceSat`), - FfiConverterUInt.lower(`channelExpiryWeeks`), - FfiConverterOptionalTypeCreateOrderOptions.lower(`options`), + UniffiLib.uniffi_bitkitcore_fn_func_get_info( + FfiConverterOptionalBoolean.lower(`refresh`), ), { future, callback, continuation -> UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer(future, callback, continuation) }, { future, continuation -> UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer(future, continuation) }, { future -> UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer(future) }, { future -> UniffiLib.ffi_bitkitcore_rust_future_cancel_rust_buffer(future) }, // lift function - { FfiConverterTypeIBtEstimateFeeResponse2.lift(it) }, + { FfiConverterOptionalTypeIBtInfo.lift(it) }, // Error FFI converter BlocktankExceptionErrorHandler, ) } -@Throws(PubkyException::class, kotlin.coroutines.cancellation.CancellationException::class) -public suspend fun `fetchPubkyContacts`(`publicKey`: kotlin.String): List { +@Throws(LnurlException::class, kotlin.coroutines.cancellation.CancellationException::class) +public suspend fun `getLnurlInvoice`(`address`: kotlin.String, `amountSatoshis`: kotlin.ULong): kotlin.String { return uniffiRustCallAsync( - UniffiLib.uniffi_bitkitcore_fn_func_fetch_pubky_contacts( - FfiConverterString.lower(`publicKey`), + UniffiLib.uniffi_bitkitcore_fn_func_get_lnurl_invoice( + FfiConverterString.lower(`address`), + FfiConverterULong.lower(`amountSatoshis`), ), { future, callback, continuation -> UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer(future, callback, continuation) }, { future, continuation -> UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer(future, continuation) }, { future -> UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer(future) }, { future -> UniffiLib.ffi_bitkitcore_rust_future_cancel_rust_buffer(future) }, // lift function - { FfiConverterSequenceString.lift(it) }, + { FfiConverterString.lift(it) }, // Error FFI converter - PubkyExceptionErrorHandler, + LnurlExceptionErrorHandler, ) } -@Throws(PubkyException::class, kotlin.coroutines.cancellation.CancellationException::class) -public suspend fun `fetchPubkyFile`(`uri`: kotlin.String): kotlin.ByteArray { +@Throws(LnurlException::class, kotlin.coroutines.cancellation.CancellationException::class) +public suspend fun `getLnurlInvoiceForPayData`(`data`: LnurlPayData, `amountMsats`: kotlin.ULong, `comment`: kotlin.String?): kotlin.String { return uniffiRustCallAsync( - UniffiLib.uniffi_bitkitcore_fn_func_fetch_pubky_file( - FfiConverterString.lower(`uri`), + UniffiLib.uniffi_bitkitcore_fn_func_get_lnurl_invoice_for_pay_data( + FfiConverterTypeLnurlPayData.lower(`data`), + FfiConverterULong.lower(`amountMsats`), + FfiConverterOptionalString.lower(`comment`), ), { future, callback, continuation -> UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer(future, callback, continuation) }, { future, continuation -> UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer(future, continuation) }, { future -> UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer(future) }, { future -> UniffiLib.ffi_bitkitcore_rust_future_cancel_rust_buffer(future) }, // lift function - { FfiConverterByteArray.lift(it) }, + { FfiConverterString.lift(it) }, // Error FFI converter - PubkyExceptionErrorHandler, + LnurlExceptionErrorHandler, ) } -@Throws(PubkyException::class, kotlin.coroutines.cancellation.CancellationException::class) -public suspend fun `fetchPubkyFileString`(`uri`: kotlin.String): kotlin.String { +@Throws(BlocktankException::class, kotlin.coroutines.cancellation.CancellationException::class) +public suspend fun `getMinZeroConfTxFee`(`orderId`: kotlin.String): IBt0ConfMinTxFeeWindow { return uniffiRustCallAsync( - UniffiLib.uniffi_bitkitcore_fn_func_fetch_pubky_file_string( - FfiConverterString.lower(`uri`), + UniffiLib.uniffi_bitkitcore_fn_func_get_min_zero_conf_tx_fee( + FfiConverterString.lower(`orderId`), + ), + { future, callback, continuation -> UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer(future, callback, continuation) }, + { future, continuation -> UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer(future, continuation) }, + { future -> UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer(future) }, + { future -> UniffiLib.ffi_bitkitcore_rust_future_cancel_rust_buffer(future) }, + // lift function + { FfiConverterTypeIBt0ConfMinTxFeeWindow.lift(it) }, + // Error FFI converter + BlocktankExceptionErrorHandler, + ) +} + +@Throws(BlocktankException::class, kotlin.coroutines.cancellation.CancellationException::class) +public suspend fun `getOrders`(`orderIds`: List?, `filter`: BtOrderState2?, `refresh`: kotlin.Boolean): List { + return uniffiRustCallAsync( + UniffiLib.uniffi_bitkitcore_fn_func_get_orders( + FfiConverterOptionalSequenceString.lower(`orderIds`), + FfiConverterOptionalTypeBtOrderState2.lower(`filter`), + FfiConverterBoolean.lower(`refresh`), ), { future, callback, continuation -> UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer(future, callback, continuation) }, { future, continuation -> UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer(future, continuation) }, { future -> UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer(future) }, { future -> UniffiLib.ffi_bitkitcore_rust_future_cancel_rust_buffer(future) }, // lift function - { FfiConverterString.lift(it) }, + { FfiConverterSequenceTypeIBtOrder.lift(it) }, // Error FFI converter - PubkyExceptionErrorHandler, + BlocktankExceptionErrorHandler, ) } -@Throws(PubkyException::class, kotlin.coroutines.cancellation.CancellationException::class) -public suspend fun `fetchPubkyProfile`(`publicKey`: kotlin.String): PubkyProfile { +@Throws(BlocktankException::class, kotlin.coroutines.cancellation.CancellationException::class) +public suspend fun `getPayment`(`paymentId`: kotlin.String): IBtBolt11Invoice { return uniffiRustCallAsync( - UniffiLib.uniffi_bitkitcore_fn_func_fetch_pubky_profile( - FfiConverterString.lower(`publicKey`), + UniffiLib.uniffi_bitkitcore_fn_func_get_payment( + FfiConverterString.lower(`paymentId`), ), { future, callback, continuation -> UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer(future, callback, continuation) }, { future, continuation -> UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer(future, continuation) }, { future -> UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer(future) }, { future -> UniffiLib.ffi_bitkitcore_rust_future_cancel_rust_buffer(future) }, // lift function - { FfiConverterTypePubkyProfile.lift(it) }, + { FfiConverterTypeIBtBolt11Invoice.lift(it) }, // Error FFI converter - PubkyExceptionErrorHandler, + BlocktankExceptionErrorHandler, ) } -/** - * Combine and finalize a signed PSBT, then extract its broadcastable transaction. - */ -@Throws(PsbtCompletionException::class) -public fun `finalizePsbt`(`originalPsbt`: kotlin.String, `signedPsbt`: kotlin.String): CompletedTransaction { - return FfiConverterTypeCompletedTransaction.lift(uniffiRustCallWithError(PsbtCompletionExceptionErrorHandler) { uniffiRustCallStatus -> - UniffiLib.uniffi_bitkitcore_fn_func_finalize_psbt( - FfiConverterString.lower(`originalPsbt`), - FfiConverterString.lower(`signedPsbt`), - uniffiRustCallStatus, - ) - }) -} - -@Throws(AddressException::class) -public fun `generateMnemonic`(`wordCount`: WordCount?): kotlin.String { - return FfiConverterString.lift(uniffiRustCallWithError(AddressExceptionErrorHandler) { uniffiRustCallStatus -> - UniffiLib.uniffi_bitkitcore_fn_func_generate_mnemonic( - FfiConverterOptionalTypeWordCount.lower(`wordCount`), - uniffiRustCallStatus, - ) - }) -} - @Throws(ActivityException::class) -public fun `getActivities`(`walletId`: kotlin.String?, `filter`: ActivityFilter?, `txType`: PaymentType?, `tags`: List?, `search`: kotlin.String?, `minDate`: kotlin.ULong?, `maxDate`: kotlin.ULong?, `limit`: kotlin.UInt?, `sortDirection`: SortDirection?): List { - return FfiConverterSequenceTypeActivity.lift(uniffiRustCallWithError(ActivityExceptionErrorHandler) { uniffiRustCallStatus -> - UniffiLib.uniffi_bitkitcore_fn_func_get_activities( - FfiConverterOptionalString.lower(`walletId`), - FfiConverterOptionalTypeActivityFilter.lower(`filter`), - FfiConverterOptionalTypePaymentType.lower(`txType`), - FfiConverterOptionalSequenceString.lower(`tags`), - FfiConverterOptionalString.lower(`search`), - FfiConverterOptionalULong.lower(`minDate`), - FfiConverterOptionalULong.lower(`maxDate`), - FfiConverterOptionalUInt.lower(`limit`), - FfiConverterOptionalTypeSortDirection.lower(`sortDirection`), +public fun `getPreActivityMetadata`(`walletId`: kotlin.String, `searchKey`: kotlin.String, `searchByAddress`: kotlin.Boolean): PreActivityMetadata? { + return FfiConverterOptionalTypePreActivityMetadata.lift(uniffiRustCallWithError(ActivityExceptionErrorHandler) { uniffiRustCallStatus -> + UniffiLib.uniffi_bitkitcore_fn_func_get_pre_activity_metadata( + FfiConverterString.lower(`walletId`), + FfiConverterString.lower(`searchKey`), + FfiConverterBoolean.lower(`searchByAddress`), uniffiRustCallStatus, ) }) } +/** + * Pre-activity metadata for a single wallet scope, or every scope when `wallet_id` is `None`. + */ @Throws(ActivityException::class) -public fun `getActivitiesByTag`(`walletId`: kotlin.String?, `tag`: kotlin.String, `limit`: kotlin.UInt?, `sortDirection`: SortDirection?): List { - return FfiConverterSequenceTypeActivity.lift(uniffiRustCallWithError(ActivityExceptionErrorHandler) { uniffiRustCallStatus -> - UniffiLib.uniffi_bitkitcore_fn_func_get_activities_by_tag( +public fun `getPreActivityMetadataList`(`walletId`: kotlin.String?): List { + return FfiConverterSequenceTypePreActivityMetadata.lift(uniffiRustCallWithError(ActivityExceptionErrorHandler) { uniffiRustCallStatus -> + UniffiLib.uniffi_bitkitcore_fn_func_get_pre_activity_metadata_list( FfiConverterOptionalString.lower(`walletId`), - FfiConverterString.lower(`tag`), - FfiConverterOptionalUInt.lower(`limit`), - FfiConverterOptionalTypeSortDirection.lower(`sortDirection`), uniffiRustCallStatus, ) }) } /** - * Activity tags for a single wallet scope, or every scope when `wallet_id` is `None`. + * The hardware-wallet models supported by Bitkit and their available transports. */ -@Throws(ActivityException::class) -public fun `getActivitiesTags`(`walletId`: kotlin.String?): List { - return FfiConverterSequenceTypeActivityTags.lift(uniffiRustCallWithError(ActivityExceptionErrorHandler) { uniffiRustCallStatus -> - UniffiLib.uniffi_bitkitcore_fn_func_get_activities_tags( - FfiConverterOptionalString.lower(`walletId`), +public fun `getSupportedHardwareWallets`(): List { + return FfiConverterSequenceTypeSupportedHardwareWallet.lift(uniffiRustCall { uniffiRustCallStatus -> + UniffiLib.uniffi_bitkitcore_fn_func_get_supported_hardware_wallets( uniffiRustCallStatus, ) }) } @Throws(ActivityException::class) -public fun `getActivityById`(`walletId`: kotlin.String, `activityId`: kotlin.String): Activity? { - return FfiConverterOptionalTypeActivity.lift(uniffiRustCallWithError(ActivityExceptionErrorHandler) { uniffiRustCallStatus -> - UniffiLib.uniffi_bitkitcore_fn_func_get_activity_by_id( +public fun `getTags`(`walletId`: kotlin.String, `activityId`: kotlin.String): List { + return FfiConverterSequenceString.lift(uniffiRustCallWithError(ActivityExceptionErrorHandler) { uniffiRustCallStatus -> + UniffiLib.uniffi_bitkitcore_fn_func_get_tags( FfiConverterString.lower(`walletId`), FfiConverterString.lower(`activityId`), uniffiRustCallStatus, @@ -16163,9 +18164,9 @@ public fun `getActivityById`(`walletId`: kotlin.String, `activityId`: kotlin.Str } @Throws(ActivityException::class) -public fun `getActivityByTxId`(`walletId`: kotlin.String, `txId`: kotlin.String): OnchainActivity? { - return FfiConverterOptionalTypeOnchainActivity.lift(uniffiRustCallWithError(ActivityExceptionErrorHandler) { uniffiRustCallStatus -> - UniffiLib.uniffi_bitkitcore_fn_func_get_activity_by_tx_id( +public fun `getTransactionDetails`(`walletId`: kotlin.String, `txId`: kotlin.String): TransactionDetails? { + return FfiConverterOptionalTypeTransactionDetails.lift(uniffiRustCallWithError(ActivityExceptionErrorHandler) { uniffiRustCallStatus -> + UniffiLib.uniffi_bitkitcore_fn_func_get_transaction_details( FfiConverterString.lower(`walletId`), FfiConverterString.lower(`txId`), uniffiRustCallStatus, @@ -16173,168 +18174,218 @@ public fun `getActivityByTxId`(`walletId`: kotlin.String, `txId`: kotlin.String) }) } -@Throws(ActivityException::class) -public fun `getAllActivitiesTags`(): List { - return FfiConverterSequenceTypeActivityTags.lift(uniffiRustCallWithError(ActivityExceptionErrorHandler) { uniffiRustCallStatus -> - UniffiLib.uniffi_bitkitcore_fn_func_get_all_activities_tags( - uniffiRustCallStatus, - ) - }) +@Throws(BlocktankException::class, kotlin.coroutines.cancellation.CancellationException::class) +public suspend fun `giftOrder`(`clientNodeId`: kotlin.String, `code`: kotlin.String): IGift { + return uniffiRustCallAsync( + UniffiLib.uniffi_bitkitcore_fn_func_gift_order( + FfiConverterString.lower(`clientNodeId`), + FfiConverterString.lower(`code`), + ), + { future, callback, continuation -> UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer(future, callback, continuation) }, + { future, continuation -> UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer(future, continuation) }, + { future -> UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer(future) }, + { future -> UniffiLib.ffi_bitkitcore_rust_future_cancel_rust_buffer(future) }, + // lift function + { FfiConverterTypeIGift.lift(it) }, + // Error FFI converter + BlocktankExceptionErrorHandler, + ) } -@Throws(ActivityException::class) -public fun `getAllClosedChannels`(`sortDirection`: SortDirection?): List { - return FfiConverterSequenceTypeClosedChannelDetails.lift(uniffiRustCallWithError(ActivityExceptionErrorHandler) { uniffiRustCallStatus -> - UniffiLib.uniffi_bitkitcore_fn_func_get_all_closed_channels( - FfiConverterOptionalTypeSortDirection.lower(`sortDirection`), - uniffiRustCallStatus, - ) - }) +@Throws(BlocktankException::class, kotlin.coroutines.cancellation.CancellationException::class) +public suspend fun `giftPay`(`invoice`: kotlin.String): IGift { + return uniffiRustCallAsync( + UniffiLib.uniffi_bitkitcore_fn_func_gift_pay( + FfiConverterString.lower(`invoice`), + ), + { future, callback, continuation -> UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer(future, callback, continuation) }, + { future, continuation -> UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer(future, continuation) }, + { future -> UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer(future) }, + { future -> UniffiLib.ffi_bitkitcore_rust_future_cancel_rust_buffer(future) }, + // lift function + { FfiConverterTypeIGift.lift(it) }, + // Error FFI converter + BlocktankExceptionErrorHandler, + ) } -@Throws(ActivityException::class) -public fun `getAllPreActivityMetadata`(): List { - return FfiConverterSequenceTypePreActivityMetadata.lift(uniffiRustCallWithError(ActivityExceptionErrorHandler) { uniffiRustCallStatus -> - UniffiLib.uniffi_bitkitcore_fn_func_get_all_pre_activity_metadata( +@Throws(DbException::class) +public fun `initDb`(`basePath`: kotlin.String): kotlin.String { + return FfiConverterString.lift(uniffiRustCallWithError(DbExceptionErrorHandler) { uniffiRustCallStatus -> + UniffiLib.uniffi_bitkitcore_fn_func_init_db( + FfiConverterString.lower(`basePath`), uniffiRustCallStatus, ) }) } @Throws(ActivityException::class) -public fun `getAllTransactionDetails`(): List { - return FfiConverterSequenceTypeTransactionDetails.lift(uniffiRustCallWithError(ActivityExceptionErrorHandler) { uniffiRustCallStatus -> - UniffiLib.uniffi_bitkitcore_fn_func_get_all_transaction_details( +public fun `insertActivity`(`activity`: Activity) { + uniffiRustCallWithError(ActivityExceptionErrorHandler) { uniffiRustCallStatus -> + UniffiLib.uniffi_bitkitcore_fn_func_insert_activity( + FfiConverterTypeActivity.lower(`activity`), uniffiRustCallStatus, ) - }) + } } @Throws(ActivityException::class) -public fun `getAllUniqueTags`(): List { - return FfiConverterSequenceString.lift(uniffiRustCallWithError(ActivityExceptionErrorHandler) { uniffiRustCallStatus -> - UniffiLib.uniffi_bitkitcore_fn_func_get_all_unique_tags( +public fun `isAddressUsed`(`address`: kotlin.String): kotlin.Boolean { + return FfiConverterBoolean.lift(uniffiRustCallWithError(ActivityExceptionErrorHandler) { uniffiRustCallStatus -> + UniffiLib.uniffi_bitkitcore_fn_func_is_address_used( + FfiConverterString.lower(`address`), uniffiRustCallStatus, ) }) } -public fun `getBip39Suggestions`(`partialWord`: kotlin.String, `limit`: kotlin.UInt): List { - return FfiConverterSequenceString.lift(uniffiRustCall { uniffiRustCallStatus -> - UniffiLib.uniffi_bitkitcore_fn_func_get_bip39_suggestions( - FfiConverterString.lower(`partialWord`), - FfiConverterUInt.lower(`limit`), +public fun `isValidBip39Word`(`word`: kotlin.String): kotlin.Boolean { + return FfiConverterBoolean.lift(uniffiRustCall { uniffiRustCallStatus -> + UniffiLib.uniffi_bitkitcore_fn_func_is_valid_bip39_word( + FfiConverterString.lower(`word`), uniffiRustCallStatus, ) }) } -public fun `getBip39Wordlist`(): List { - return FfiConverterSequenceString.lift(uniffiRustCall { uniffiRustCallStatus -> - UniffiLib.uniffi_bitkitcore_fn_func_get_bip39_wordlist( +/** + * Map a generic account type onto Jade's descriptor variant. + */ +public fun `jadeAccountTypeToVariant`(`accountType`: AccountType): JadeAddressVariant { + return FfiConverterTypeJadeAddressVariant.lift(uniffiRustCall { uniffiRustCallStatus -> + UniffiLib.uniffi_bitkitcore_fn_func_jade_account_type_to_variant( + FfiConverterTypeAccountType.lower(`accountType`), uniffiRustCallStatus, ) }) } -@Throws(BlocktankException::class, kotlin.coroutines.cancellation.CancellationException::class) -public suspend fun `getCjitEntries`(`entryIds`: List?, `filter`: CJitStateEnum?, `refresh`: kotlin.Boolean): List { +/** + * Abort the operation in flight. + * + * Jade has no cancel message, so this closes the link. The application should + * reconnect afterwards. This is what backs a cancel button on a signing screen. + */ +@Throws(JadeException::class, kotlin.coroutines.cancellation.CancellationException::class) +public suspend fun `jadeCancel`() { return uniffiRustCallAsync( - UniffiLib.uniffi_bitkitcore_fn_func_get_cjit_entries( - FfiConverterOptionalSequenceString.lower(`entryIds`), - FfiConverterOptionalTypeCJitStateEnum.lower(`filter`), - FfiConverterBoolean.lower(`refresh`), + UniffiLib.uniffi_bitkitcore_fn_func_jade_cancel( + ), + { future, callback, continuation -> UniffiLib.ffi_bitkitcore_rust_future_poll_void(future, callback, continuation) }, + { future, continuation -> UniffiLib.ffi_bitkitcore_rust_future_complete_void(future, continuation) }, + { future -> UniffiLib.ffi_bitkitcore_rust_future_free_void(future) }, + { future -> UniffiLib.ffi_bitkitcore_rust_future_cancel_void(future) }, + // lift function + { Unit }, + + // Error FFI converter + JadeExceptionErrorHandler, + ) +} + +/** + * Open a device and read its firmware and state summary. + * + * The path normally comes from the last `jade_scan`, but a known Bluetooth + * address or serial path can be passed directly to reconnect without a scan. + * Any previously open connection is closed first. The returned `jade_state` + * tells the application what to do next: `Locked` means call `jade_unlock`, + * `Ready` means the device is already usable, and `Uninit` means the user must + * create or restore a wallet on the device itself. + */ +@Throws(JadeException::class, kotlin.coroutines.cancellation.CancellationException::class) +public suspend fun `jadeConnect`(`transport`: JadeTransportKind, `path`: kotlin.String): JadeVersionInfo { + return uniffiRustCallAsync( + UniffiLib.uniffi_bitkitcore_fn_func_jade_connect( + FfiConverterTypeJadeTransportKind.lower(`transport`), + FfiConverterString.lower(`path`), ), { future, callback, continuation -> UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer(future, callback, continuation) }, { future, continuation -> UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer(future, continuation) }, { future -> UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer(future) }, { future -> UniffiLib.ffi_bitkitcore_rust_future_cancel_rust_buffer(future) }, // lift function - { FfiConverterSequenceTypeICJitEntry.lift(it) }, + { FfiConverterTypeJadeVersionInfo.lift(it) }, // Error FFI converter - BlocktankExceptionErrorHandler, + JadeExceptionErrorHandler, ) } -@Throws(ActivityException::class) -public fun `getClosedChannelById`(`channelId`: kotlin.String): ClosedChannelDetails? { - return FfiConverterOptionalTypeClosedChannelDetails.lift(uniffiRustCallWithError(ActivityExceptionErrorHandler) { uniffiRustCallStatus -> - UniffiLib.uniffi_bitkitcore_fn_func_get_closed_channel_by_id( - FfiConverterString.lower(`channelId`), - uniffiRustCallStatus, - ) - }) -} - /** - * The default address gap limit used by account scanning and the xpub watcher. - * Exposed so platforms reference one source of truth instead of hardcoding 20. + * Close the device and clear session state. + * + * Safe to call while an operation is waiting on a confirmation: the pending + * request returns `UserCancelled` promptly rather than running out its deadline. */ -public fun `getDefaultGapLimit`(): kotlin.UInt { - return FfiConverterUInt.lift(uniffiRustCall { uniffiRustCallStatus -> - UniffiLib.uniffi_bitkitcore_fn_func_get_default_gap_limit( - uniffiRustCallStatus, - ) - }) -} - -public fun `getDefaultLspBalance`(`params`: DefaultLspBalanceParams): kotlin.ULong { - return FfiConverterULong.lift(uniffiRustCall { uniffiRustCallStatus -> - UniffiLib.uniffi_bitkitcore_fn_func_get_default_lsp_balance( - FfiConverterTypeDefaultLspBalanceParams.lower(`params`), - uniffiRustCallStatus, - ) - }) -} - -public fun `getDefaultWalletId`(): kotlin.String { - return FfiConverterString.lift(uniffiRustCall { uniffiRustCallStatus -> - UniffiLib.uniffi_bitkitcore_fn_func_get_default_wallet_id( - uniffiRustCallStatus, - ) - }) +@Throws(JadeException::class, kotlin.coroutines.cancellation.CancellationException::class) +public suspend fun `jadeDisconnect`() { + return uniffiRustCallAsync( + UniffiLib.uniffi_bitkitcore_fn_func_jade_disconnect( + ), + { future, callback, continuation -> UniffiLib.ffi_bitkitcore_rust_future_poll_void(future, callback, continuation) }, + { future, continuation -> UniffiLib.ffi_bitkitcore_rust_future_complete_void(future, continuation) }, + { future -> UniffiLib.ffi_bitkitcore_rust_future_free_void(future) }, + { future -> UniffiLib.ffi_bitkitcore_rust_future_cancel_void(future) }, + // lift function + { Unit }, + + // Error FFI converter + JadeExceptionErrorHandler, + ) } -@Throws(BlocktankException::class, kotlin.coroutines.cancellation.CancellationException::class) -public suspend fun `getGift`(`giftId`: kotlin.String): IGift { +/** + * Fetch the account keys an import needs in one call. + * + * Shaped like `passport_parse_account_export` so applications have a single + * import path across signers. Each key is fetched under one held connection, + * which matters over Bluetooth where every round trip is slow. + */ +@Throws(JadeException::class, kotlin.coroutines.cancellation.CancellationException::class) +public suspend fun `jadeGetAccountExport`(`network`: JadeNetwork, `accountIndex`: kotlin.UInt, `accountTypes`: List): JadeAccountExport { return uniffiRustCallAsync( - UniffiLib.uniffi_bitkitcore_fn_func_get_gift( - FfiConverterString.lower(`giftId`), + UniffiLib.uniffi_bitkitcore_fn_func_jade_get_account_export( + FfiConverterTypeJadeNetwork.lower(`network`), + FfiConverterUInt.lower(`accountIndex`), + FfiConverterSequenceTypeAccountType.lower(`accountTypes`), ), { future, callback, continuation -> UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer(future, callback, continuation) }, { future, continuation -> UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer(future, continuation) }, { future -> UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer(future) }, { future -> UniffiLib.ffi_bitkitcore_rust_future_cancel_rust_buffer(future) }, // lift function - { FfiConverterTypeIGift.lift(it) }, + { FfiConverterTypeJadeAccountExport.lift(it) }, // Error FFI converter - BlocktankExceptionErrorHandler, + JadeExceptionErrorHandler, ) } -@Throws(BlocktankException::class, kotlin.coroutines.cancellation.CancellationException::class) -public suspend fun `getInfo`(`refresh`: kotlin.Boolean?): IBtInfo? { +public suspend fun `jadeGetConnectedDevice`(): JadeDeviceInfo? { return uniffiRustCallAsync( - UniffiLib.uniffi_bitkitcore_fn_func_get_info( - FfiConverterOptionalBoolean.lower(`refresh`), + UniffiLib.uniffi_bitkitcore_fn_func_jade_get_connected_device( ), { future, callback, continuation -> UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer(future, callback, continuation) }, { future, continuation -> UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer(future, continuation) }, { future -> UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer(future) }, { future -> UniffiLib.ffi_bitkitcore_rust_future_cancel_rust_buffer(future) }, // lift function - { FfiConverterOptionalTypeIBtInfo.lift(it) }, + { FfiConverterOptionalTypeJadeDeviceInfo.lift(it) }, // Error FFI converter - BlocktankExceptionErrorHandler, + UniffiNullRustCallStatusErrorHandler, ) } -@Throws(LnurlException::class, kotlin.coroutines.cancellation.CancellationException::class) -public suspend fun `getLnurlInvoice`(`address`: kotlin.String, `amountSatoshis`: kotlin.ULong): kotlin.String { +/** + * The device's master fingerprint, eight lowercase hex characters. + * + * This must be supplied as `WalletParams.fingerprint` when composing, or the + * resulting PSBT carries no BIP32 key origins and the device signs nothing. + */ +@Throws(JadeException::class, kotlin.coroutines.cancellation.CancellationException::class) +public suspend fun `jadeGetMasterFingerprint`(`network`: JadeNetwork): kotlin.String { return uniffiRustCallAsync( - UniffiLib.uniffi_bitkitcore_fn_func_get_lnurl_invoice( - FfiConverterString.lower(`address`), - FfiConverterULong.lower(`amountSatoshis`), + UniffiLib.uniffi_bitkitcore_fn_func_jade_get_master_fingerprint( + FfiConverterTypeJadeNetwork.lower(`network`), ), { future, callback, continuation -> UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer(future, callback, continuation) }, { future, continuation -> UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer(future, continuation) }, @@ -16343,212 +18394,292 @@ public suspend fun `getLnurlInvoice`(`address`: kotlin.String, `amountSatoshis`: // lift function { FfiConverterString.lift(it) }, // Error FFI converter - LnurlExceptionErrorHandler, + JadeExceptionErrorHandler, ) } -@Throws(LnurlException::class, kotlin.coroutines.cancellation.CancellationException::class) -public suspend fun `getLnurlInvoiceForPayData`(`data`: LnurlPayData, `amountMsats`: kotlin.ULong, `comment`: kotlin.String?): kotlin.String { +/** + * The version summary read at connect, without touching the device. + */ +public suspend fun `jadeGetVersionInfo`(): JadeVersionInfo? { return uniffiRustCallAsync( - UniffiLib.uniffi_bitkitcore_fn_func_get_lnurl_invoice_for_pay_data( - FfiConverterTypeLnurlPayData.lower(`data`), - FfiConverterULong.lower(`amountMsats`), - FfiConverterOptionalString.lower(`comment`), + UniffiLib.uniffi_bitkitcore_fn_func_jade_get_version_info( ), { future, callback, continuation -> UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer(future, callback, continuation) }, { future, continuation -> UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer(future, continuation) }, { future -> UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer(future) }, { future -> UniffiLib.ffi_bitkitcore_rust_future_cancel_rust_buffer(future) }, // lift function - { FfiConverterString.lift(it) }, + { FfiConverterOptionalTypeJadeVersionInfo.lift(it) }, // Error FFI converter - LnurlExceptionErrorHandler, + UniffiNullRustCallStatusErrorHandler, ) } -@Throws(BlocktankException::class, kotlin.coroutines.cancellation.CancellationException::class) -public suspend fun `getMinZeroConfTxFee`(`orderId`: kotlin.String): IBt0ConfMinTxFeeWindow { +/** + * Fetch an extended public key, echoed back with the path and fingerprint. + */ +@Throws(JadeException::class, kotlin.coroutines.cancellation.CancellationException::class) +public suspend fun `jadeGetXpub`(`network`: JadeNetwork, `derivationPath`: kotlin.String): JadeXpubResponse { return uniffiRustCallAsync( - UniffiLib.uniffi_bitkitcore_fn_func_get_min_zero_conf_tx_fee( - FfiConverterString.lower(`orderId`), + UniffiLib.uniffi_bitkitcore_fn_func_jade_get_xpub( + FfiConverterTypeJadeNetwork.lower(`network`), + FfiConverterString.lower(`derivationPath`), ), { future, callback, continuation -> UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer(future, callback, continuation) }, { future, continuation -> UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer(future, continuation) }, { future -> UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer(future) }, { future -> UniffiLib.ffi_bitkitcore_rust_future_cancel_rust_buffer(future) }, // lift function - { FfiConverterTypeIBt0ConfMinTxFeeWindow.lift(it) }, + { FfiConverterTypeJadeXpubResponse.lift(it) }, // Error FFI converter - BlocktankExceptionErrorHandler, + JadeExceptionErrorHandler, ) } -@Throws(BlocktankException::class, kotlin.coroutines.cancellation.CancellationException::class) -public suspend fun `getOrders`(`orderIds`: List?, `filter`: BtOrderState2?, `refresh`: kotlin.Boolean): List { +public fun `jadeIsConnected`(): kotlin.Boolean { + return FfiConverterBoolean.lift(uniffiRustCall { uniffiRustCallStatus -> + UniffiLib.uniffi_bitkitcore_fn_func_jade_is_connected( + uniffiRustCallStatus, + ) + }) +} + +/** + * The devices found by the last scan, without starting a new one. + */ +public suspend fun `jadeListDevices`(): List { return uniffiRustCallAsync( - UniffiLib.uniffi_bitkitcore_fn_func_get_orders( - FfiConverterOptionalSequenceString.lower(`orderIds`), - FfiConverterOptionalTypeBtOrderState2.lower(`filter`), - FfiConverterBoolean.lower(`refresh`), + UniffiLib.uniffi_bitkitcore_fn_func_jade_list_devices( ), { future, callback, continuation -> UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer(future, callback, continuation) }, { future, continuation -> UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer(future, continuation) }, { future -> UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer(future) }, { future -> UniffiLib.ffi_bitkitcore_rust_future_cancel_rust_buffer(future) }, // lift function - { FfiConverterSequenceTypeIBtOrder.lift(it) }, + { FfiConverterSequenceTypeJadeDeviceInfo.lift(it) }, // Error FFI converter - BlocktankExceptionErrorHandler, + UniffiNullRustCallStatusErrorHandler, ) } -@Throws(BlocktankException::class, kotlin.coroutines.cancellation.CancellationException::class) -public suspend fun `getPayment`(`paymentId`: kotlin.String): IBtBolt11Invoice { +/** + * Lock the device and zero its in-memory key material. + */ +@Throws(JadeException::class, kotlin.coroutines.cancellation.CancellationException::class) +public suspend fun `jadeLogout`() { return uniffiRustCallAsync( - UniffiLib.uniffi_bitkitcore_fn_func_get_payment( - FfiConverterString.lower(`paymentId`), + UniffiLib.uniffi_bitkitcore_fn_func_jade_logout( ), - { future, callback, continuation -> UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer(future, callback, continuation) }, - { future, continuation -> UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer(future, continuation) }, - { future -> UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer(future) }, - { future -> UniffiLib.ffi_bitkitcore_rust_future_cancel_rust_buffer(future) }, + { future, callback, continuation -> UniffiLib.ffi_bitkitcore_rust_future_poll_void(future, callback, continuation) }, + { future, continuation -> UniffiLib.ffi_bitkitcore_rust_future_complete_void(future, continuation) }, + { future -> UniffiLib.ffi_bitkitcore_rust_future_free_void(future) }, + { future -> UniffiLib.ffi_bitkitcore_rust_future_cancel_void(future) }, // lift function - { FfiConverterTypeIBtBolt11Invoice.lift(it) }, + { Unit }, + // Error FFI converter - BlocktankExceptionErrorHandler, + JadeExceptionErrorHandler, ) } -@Throws(ActivityException::class) -public fun `getPreActivityMetadata`(`walletId`: kotlin.String, `searchKey`: kotlin.String, `searchByAddress`: kotlin.Boolean): PreActivityMetadata? { - return FfiConverterOptionalTypePreActivityMetadata.lift(uniffiRustCallWithError(ActivityExceptionErrorHandler) { uniffiRustCallStatus -> - UniffiLib.uniffi_bitkitcore_fn_func_get_pre_activity_metadata( - FfiConverterString.lower(`walletId`), - FfiConverterString.lower(`searchKey`), - FfiConverterBoolean.lower(`searchByAddress`), - uniffiRustCallStatus, - ) - }) +/** + * Tell the library that the native layer saw the device disconnect. + * + * Without this, an idle Bluetooth drop is invisible until the next request. + */ +public suspend fun `jadeNotifyDisconnected`(`path`: kotlin.String) { + return uniffiRustCallAsync( + UniffiLib.uniffi_bitkitcore_fn_func_jade_notify_disconnected( + FfiConverterString.lower(`path`), + ), + { future, callback, continuation -> UniffiLib.ffi_bitkitcore_rust_future_poll_void(future, callback, continuation) }, + { future, continuation -> UniffiLib.ffi_bitkitcore_rust_future_complete_void(future, continuation) }, + { future -> UniffiLib.ffi_bitkitcore_rust_future_free_void(future) }, + { future -> UniffiLib.ffi_bitkitcore_rust_future_cancel_void(future) }, + // lift function + { Unit }, + + // Error FFI converter + UniffiNullRustCallStatusErrorHandler, + ) } /** - * Pre-activity metadata for a single wallet scope, or every scope when `wallet_id` is `None`. + * Check whether the device is idle, busy, or waiting on the user. */ -@Throws(ActivityException::class) -public fun `getPreActivityMetadataList`(`walletId`: kotlin.String?): List { - return FfiConverterSequenceTypePreActivityMetadata.lift(uniffiRustCallWithError(ActivityExceptionErrorHandler) { uniffiRustCallStatus -> - UniffiLib.uniffi_bitkitcore_fn_func_get_pre_activity_metadata_list( - FfiConverterOptionalString.lower(`walletId`), - uniffiRustCallStatus, - ) - }) +@Throws(JadeException::class, kotlin.coroutines.cancellation.CancellationException::class) +public suspend fun `jadePing`(): JadePingStatus { + return uniffiRustCallAsync( + UniffiLib.uniffi_bitkitcore_fn_func_jade_ping( + ), + { future, callback, continuation -> UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer(future, callback, continuation) }, + { future, continuation -> UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer(future, continuation) }, + { future -> UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer(future) }, + { future -> UniffiLib.ffi_bitkitcore_rust_future_cancel_rust_buffer(future) }, + // lift function + { FfiConverterTypeJadePingStatus.lift(it) }, + // Error FFI converter + JadeExceptionErrorHandler, + ) } /** - * The hardware-wallet models supported by Bitkit and their available transports. + * Re-read the version summary from the device. */ -public fun `getSupportedHardwareWallets`(): List { - return FfiConverterSequenceTypeSupportedHardwareWallet.lift(uniffiRustCall { uniffiRustCallStatus -> - UniffiLib.uniffi_bitkitcore_fn_func_get_supported_hardware_wallets( - uniffiRustCallStatus, - ) - }) +@Throws(JadeException::class, kotlin.coroutines.cancellation.CancellationException::class) +public suspend fun `jadeRefreshVersionInfo`(): JadeVersionInfo { + return uniffiRustCallAsync( + UniffiLib.uniffi_bitkitcore_fn_func_jade_refresh_version_info( + ), + { future, callback, continuation -> UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer(future, callback, continuation) }, + { future, continuation -> UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer(future, continuation) }, + { future -> UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer(future) }, + { future -> UniffiLib.ffi_bitkitcore_rust_future_cancel_rust_buffer(future) }, + // lift function + { FfiConverterTypeJadeVersionInfo.lift(it) }, + // Error FFI converter + JadeExceptionErrorHandler, + ) } -@Throws(ActivityException::class) -public fun `getTags`(`walletId`: kotlin.String, `activityId`: kotlin.String): List { - return FfiConverterSequenceString.lift(uniffiRustCallWithError(ActivityExceptionErrorHandler) { uniffiRustCallStatus -> - UniffiLib.uniffi_bitkitcore_fn_func_get_tags( - FfiConverterString.lower(`walletId`), - FfiConverterString.lower(`activityId`), - uniffiRustCallStatus, - ) - }) +/** + * Discover Jade devices. + * + * Bluetooth discovery is performed by the registered transport callback; on + * desktop and Python builds, attached USB serial units are enumerated too. + * Returns `DeviceBusy` while a connection is open, because starting a + * Bluetooth scan during an active link drops it on Android. + */ +@Throws(JadeException::class, kotlin.coroutines.cancellation.CancellationException::class) +public suspend fun `jadeScan`(`timeoutMs`: kotlin.UInt): List { + return uniffiRustCallAsync( + UniffiLib.uniffi_bitkitcore_fn_func_jade_scan( + FfiConverterUInt.lower(`timeoutMs`), + ), + { future, callback, continuation -> UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer(future, callback, continuation) }, + { future, continuation -> UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer(future, continuation) }, + { future -> UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer(future) }, + { future -> UniffiLib.ffi_bitkitcore_rust_future_cancel_rust_buffer(future) }, + // lift function + { FfiConverterSequenceTypeJadeDeviceInfo.lift(it) }, + // Error FFI converter + JadeExceptionErrorHandler, + ) } -@Throws(ActivityException::class) -public fun `getTransactionDetails`(`walletId`: kotlin.String, `txId`: kotlin.String): TransactionDetails? { - return FfiConverterOptionalTypeTransactionDetails.lift(uniffiRustCallWithError(ActivityExceptionErrorHandler) { uniffiRustCallStatus -> - UniffiLib.uniffi_bitkitcore_fn_func_get_transaction_details( - FfiConverterString.lower(`walletId`), - FfiConverterString.lower(`txId`), +/** + * Register the native transport. + * + * Returns `true` when this replaced a previously registered callback, which + * lets the application tell a fresh registration from a re-registration. + */ +public fun `jadeSetTransportCallback`(`callback`: JadeTransportCallback): kotlin.Boolean { + return FfiConverterBoolean.lift(uniffiRustCall { uniffiRustCallStatus -> + UniffiLib.uniffi_bitkitcore_fn_func_jade_set_transport_callback( + FfiConverterTypeJadeTransportCallback.lower(`callback`), uniffiRustCallStatus, ) }) } -@Throws(BlocktankException::class, kotlin.coroutines.cancellation.CancellationException::class) -public suspend fun `giftOrder`(`clientNodeId`: kotlin.String, `code`: kotlin.String): IGift { +/** + * Sign a message, returning the signature with the address that verifies it. + */ +@Throws(JadeException::class, kotlin.coroutines.cancellation.CancellationException::class) +public suspend fun `jadeSignMessage`(`network`: JadeNetwork, `derivationPath`: kotlin.String, `message`: kotlin.String): JadeSignedMessage { return uniffiRustCallAsync( - UniffiLib.uniffi_bitkitcore_fn_func_gift_order( - FfiConverterString.lower(`clientNodeId`), - FfiConverterString.lower(`code`), + UniffiLib.uniffi_bitkitcore_fn_func_jade_sign_message( + FfiConverterTypeJadeNetwork.lower(`network`), + FfiConverterString.lower(`derivationPath`), + FfiConverterString.lower(`message`), ), { future, callback, continuation -> UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer(future, callback, continuation) }, { future, continuation -> UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer(future, continuation) }, { future -> UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer(future) }, { future -> UniffiLib.ffi_bitkitcore_rust_future_cancel_rust_buffer(future) }, // lift function - { FfiConverterTypeIGift.lift(it) }, + { FfiConverterTypeJadeSignedMessage.lift(it) }, // Error FFI converter - BlocktankExceptionErrorHandler, + JadeExceptionErrorHandler, ) } -@Throws(BlocktankException::class, kotlin.coroutines.cancellation.CancellationException::class) -public suspend fun `giftPay`(`invoice`: kotlin.String): IGift { +/** + * Sign a PSBT, returning the signed PSBT base64 encoded. + * + * The reply is checked against what was sent before it is returned. Feed the + * result to `finalize_psbt` with the original PSBT, then broadcast with + * `onchain_broadcast_raw_tx`. + */ +@Throws(JadeException::class, kotlin.coroutines.cancellation.CancellationException::class) +public suspend fun `jadeSignPsbt`(`network`: JadeNetwork, `psbt`: kotlin.String): kotlin.String { return uniffiRustCallAsync( - UniffiLib.uniffi_bitkitcore_fn_func_gift_pay( - FfiConverterString.lower(`invoice`), + UniffiLib.uniffi_bitkitcore_fn_func_jade_sign_psbt( + FfiConverterTypeJadeNetwork.lower(`network`), + FfiConverterString.lower(`psbt`), ), { future, callback, continuation -> UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer(future, callback, continuation) }, { future, continuation -> UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer(future, continuation) }, { future -> UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer(future) }, { future -> UniffiLib.ffi_bitkitcore_rust_future_cancel_rust_buffer(future) }, // lift function - { FfiConverterTypeIGift.lift(it) }, + { FfiConverterString.lift(it) }, // Error FFI converter - BlocktankExceptionErrorHandler, + JadeExceptionErrorHandler, ) } -@Throws(DbException::class) -public fun `initDb`(`basePath`: kotlin.String): kotlin.String { - return FfiConverterString.lift(uniffiRustCallWithError(DbExceptionErrorHandler) { uniffiRustCallStatus -> - UniffiLib.uniffi_bitkitcore_fn_func_init_db( - FfiConverterString.lower(`basePath`), - uniffiRustCallStatus, - ) - }) -} - -@Throws(ActivityException::class) -public fun `insertActivity`(`activity`: Activity) { - uniffiRustCallWithError(ActivityExceptionErrorHandler) { uniffiRustCallStatus -> - UniffiLib.uniffi_bitkitcore_fn_func_insert_activity( - FfiConverterTypeActivity.lower(`activity`), - uniffiRustCallStatus, - ) - } -} - -@Throws(ActivityException::class) -public fun `isAddressUsed`(`address`: kotlin.String): kotlin.Boolean { - return FfiConverterBoolean.lift(uniffiRustCallWithError(ActivityExceptionErrorHandler) { uniffiRustCallStatus -> - UniffiLib.uniffi_bitkitcore_fn_func_is_address_used( - FfiConverterString.lower(`address`), - uniffiRustCallStatus, - ) - }) +/** + * Unlock the device for a network. + * + * Runs the blind pinserver exchange when the device asks for it, which needs + * network access. The PIN is entered on the device and never reaches the host. + */ +@Throws(JadeException::class, kotlin.coroutines.cancellation.CancellationException::class) +public suspend fun `jadeUnlock`(`network`: JadeNetwork) { + return uniffiRustCallAsync( + UniffiLib.uniffi_bitkitcore_fn_func_jade_unlock( + FfiConverterTypeJadeNetwork.lower(`network`), + ), + { future, callback, continuation -> UniffiLib.ffi_bitkitcore_rust_future_poll_void(future, callback, continuation) }, + { future, continuation -> UniffiLib.ffi_bitkitcore_rust_future_complete_void(future, continuation) }, + { future -> UniffiLib.ffi_bitkitcore_rust_future_free_void(future) }, + { future -> UniffiLib.ffi_bitkitcore_rust_future_cancel_void(future) }, + // lift function + { Unit }, + + // Error FFI converter + JadeExceptionErrorHandler, + ) } -public fun `isValidBip39Word`(`word`: kotlin.String): kotlin.Boolean { - return FfiConverterBoolean.lift(uniffiRustCall { uniffiRustCallStatus -> - UniffiLib.uniffi_bitkitcore_fn_func_is_valid_bip39_word( - FfiConverterString.lower(`word`), - uniffiRustCallStatus, - ) - }) +/** + * Display an address on the device and check it against the expected one. + * + * This always prompts on the device screen, so it is a verification step + * rather than a way to fetch an address. Returns `AddressMismatch` when the + * device disagrees with `expected_address`. + */ +@Throws(JadeException::class, kotlin.coroutines.cancellation.CancellationException::class) +public suspend fun `jadeVerifyAddress`(`network`: JadeNetwork, `variant`: JadeAddressVariant, `derivationPath`: kotlin.String, `expectedAddress`: kotlin.String) { + return uniffiRustCallAsync( + UniffiLib.uniffi_bitkitcore_fn_func_jade_verify_address( + FfiConverterTypeJadeNetwork.lower(`network`), + FfiConverterTypeJadeAddressVariant.lower(`variant`), + FfiConverterString.lower(`derivationPath`), + FfiConverterString.lower(`expectedAddress`), + ), + { future, callback, continuation -> UniffiLib.ffi_bitkitcore_rust_future_poll_void(future, callback, continuation) }, + { future, continuation -> UniffiLib.ffi_bitkitcore_rust_future_complete_void(future, continuation) }, + { future -> UniffiLib.ffi_bitkitcore_rust_future_free_void(future) }, + { future -> UniffiLib.ffi_bitkitcore_rust_future_cancel_void(future) }, + // lift function + { Unit }, + + // Error FFI converter + JadeExceptionErrorHandler, + ) } @Throws(LnurlException::class, kotlin.coroutines.cancellation.CancellationException::class) diff --git a/bindings/android/lib/src/main/kotlin/com/synonym/bitkitcore/bitkitcore.common.kt b/bindings/android/lib/src/main/kotlin/com/synonym/bitkitcore/bitkitcore.common.kt index 14bc3b4..6a125d6 100644 --- a/bindings/android/lib/src/main/kotlin/com/synonym/bitkitcore/bitkitcore.common.kt +++ b/bindings/android/lib/src/main/kotlin/com/synonym/bitkitcore/bitkitcore.common.kt @@ -153,6 +153,74 @@ public interface EventListener { +/** + * Native transport for Jade. + * + * # Bluetooth contract + * + * Jade advertises the Nordic UART Service: + * + * - service `6e400001-b5a3-f393-e0a9-e50e24dcca9e` + * - write `6e400002-b5a3-f393-e0a9-e50e24dcca9e` (host to Jade) + * - notify `6e400003-b5a3-f393-e0a9-e50e24dcca9e` (Jade to host) + * + * Devices advertise as "Jade" or "Jade ". + * + * Three requirements that are easy to miss and break signing on real hardware: + * + * 1. **Write with response.** Write-without-response silently drops chunks on + * the ESP32 GATT stack. + * 2. **Do not pause between chunks.** Firmware discards a partially received + * message after two seconds of silence, three on Jade v1, and answers with + * an unattributed error. A 30 KB PSBT is roughly 60 writes, so any UI thread + * stall in the middle of a send breaks the operation. + * 3. **`read_chunk` must return promptly.** Honour `timeout_ms`, which this + * crate keeps short. The long per-operation deadline is enforced in Rust so + * the user can cancel. + */ +public interface JadeTransportCallback { + + /** + * Discover devices, blocking up to `timeout_ms`. + */ + public fun `scanDevices`(`timeoutMs`: kotlin.UInt): List + + /** + * Open a connection and enable notifications. + */ + public fun `openDevice`(`path`: kotlin.String): JadeTransportResult + + /** + * Close the connection and release the device. + */ + public fun `closeDevice`(`path`: kotlin.String): JadeTransportResult + + /** + * Write one chunk, no larger than `get_chunk_size`. + */ + public fun `writeChunk`(`path`: kotlin.String, `data`: kotlin.ByteArray): JadeTransportResult + + /** + * Read whatever has arrived, waiting at most `timeout_ms`. + * + * Returning success with an empty vector is normal and means "nothing yet". + */ + public fun `readChunk`(`path`: kotlin.String, `timeoutMs`: kotlin.UInt): JadeTransportReadResult + + /** + * Maximum bytes per write. + * + * For Bluetooth this is `min(negotiated_mtu - 3, 509)`. The value is + * clamped into a usable range, so an unnegotiated `0` is not fatal. + */ + public fun `getChunkSize`(`path`: kotlin.String): kotlin.UInt + + public companion object +} + + + + /** * Callback interface for native Trezor transport operations * @@ -1244,6 +1312,161 @@ public data class IManualRefund ( +@kotlinx.serialization.Serializable +public data class JadeAccount ( + val `variant`: JadeAddressVariant, + val `xpub`: kotlin.String, + val `derivationPath`: kotlin.String +) { + public companion object +} + + + +@kotlinx.serialization.Serializable +public data class JadeAccountExport ( + val `masterFingerprint`: kotlin.String, + val `accountIndex`: kotlin.UInt, + val `accounts`: List +) { + public companion object +} + + + +@kotlinx.serialization.Serializable +public data class JadeDeviceInfo ( + val `path`: kotlin.String, + val `transport`: JadeTransportKind, + val `name`: kotlin.String?, + val `serialNumber`: kotlin.String? +) { + public companion object +} + + + +/** + * A device the native layer discovered. + */ +@kotlinx.serialization.Serializable +public data class JadeNativeDevice ( + /** + * Transport specific address: a BLE identifier or a serial device path. + */ + val `path`: kotlin.String, + val `transport`: JadeTransportKind, + /** + * Advertised or descriptor name, for example "Jade C0FFEE". + */ + val `name`: kotlin.String?, + val `serialNumber`: kotlin.String? +) { + public companion object +} + + + +@kotlinx.serialization.Serializable +public data class JadeSignedMessage ( + val `signature`: kotlin.String, + val `address`: kotlin.String, + val `derivationPath`: kotlin.String +) { + public companion object +} + + + +/** + * Outcome of a read. + */ +@kotlinx.serialization.Serializable +public data class JadeTransportReadResult ( + val `success`: kotlin.Boolean, + /** + * Bytes read. Success with an empty vector means nothing has arrived yet, + * which is the normal case while the user is deciding on the device. + */ + val `data`: kotlin.ByteArray, + /** + * Empty on success. + */ + val `error`: kotlin.String, + val `errorCode`: JadeTransportErrorCode? +) { + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (other == null || this::class != other::class) return false + + other as JadeTransportReadResult + if (`success` != other.`success`) return false + if (!`data`.contentEquals(other.`data`)) return false + if (`error` != other.`error`) return false + if (`errorCode` != other.`errorCode`) return false + + return true + } + override fun hashCode(): Int { + var result = `success`.hashCode() + result = 31 * result + `data`.contentHashCode() + result = 31 * result + `error`.hashCode() + result = 31 * result + (`errorCode`?.hashCode() ?: 0) + return result + } + public companion object +} + + + +/** + * Outcome of an operation that returns no data. + */ +@kotlinx.serialization.Serializable +public data class JadeTransportResult ( + val `success`: kotlin.Boolean, + /** + * Empty on success. + */ + val `error`: kotlin.String, + val `errorCode`: JadeTransportErrorCode? +) { + public companion object +} + + + +@kotlinx.serialization.Serializable +public data class JadeVersionInfo ( + val `jadeVersion`: kotlin.String, + val `jadeState`: JadeState, + val `jadeNetworks`: kotlin.String?, + val `jadeHasPin`: kotlin.Boolean?, + val `boardType`: kotlin.String?, + val `jadeConfig`: kotlin.String?, + val `jadeFeatures`: kotlin.String?, + val `idfVersion`: kotlin.String?, + val `chipFeatures`: kotlin.String?, + val `efuseMac`: kotlin.String?, + val `batteryStatus`: kotlin.UInt?, + val `jadeOtaMaxChunk`: kotlin.UInt? +) { + public companion object +} + + + +@kotlinx.serialization.Serializable +public data class JadeXpubResponse ( + val `xpub`: kotlin.String, + val `derivationPath`: kotlin.String, + val `masterFingerprint`: kotlin.String +) { + public companion object +} + + + @kotlinx.serialization.Serializable public data class LegacyRnCloseRecoveryScanResult ( /** @@ -4050,7 +4273,272 @@ public enum class HardwareWalletTransport { public enum class HardwareWalletVendor { TREZOR, - FOUNDATION; + FOUNDATION, + BLOCKSTREAM; + public companion object +} + + + + + + + +@kotlinx.serialization.Serializable +public enum class JadeAddressVariant { + + PKH, + WPKH, + SH_WPKH, + TR; + public companion object +} + + + + + + + +public sealed class JadeException: kotlin.Exception() { + + public class TransportException( + public val `errorDetails`: kotlin.String, + ) : JadeException() { + override val message: String + get() = "errorDetails=${ `errorDetails` }" + } + + public class DeviceNotFound( + ) : JadeException() { + override val message: String + get() = "" + } + + public class DeviceDisconnected( + ) : JadeException() { + override val message: String + get() = "" + } + + public class DeviceBusy( + ) : JadeException() { + override val message: String + get() = "" + } + + public class NotConnected( + ) : JadeException() { + override val message: String + get() = "" + } + + public class NotInitialized( + ) : JadeException() { + override val message: String + get() = "" + } + + public class ConnectionException( + public val `errorDetails`: kotlin.String, + ) : JadeException() { + override val message: String + get() = "errorDetails=${ `errorDetails` }" + } + + public class ProtocolException( + public val `errorDetails`: kotlin.String, + ) : JadeException() { + override val message: String + get() = "errorDetails=${ `errorDetails` }" + } + + public class Timeout( + ) : JadeException() { + override val message: String + get() = "" + } + + public class UserCancelled( + ) : JadeException() { + override val message: String + get() = "" + } + + public class DeviceLocked( + ) : JadeException() { + override val message: String + get() = "" + } + + public class DeviceUninitialized( + ) : JadeException() { + override val message: String + get() = "" + } + + public class InvalidPin( + ) : JadeException() { + override val message: String + get() = "" + } + + public class NetworkMismatch( + public val `errorDetails`: kotlin.String, + ) : JadeException() { + override val message: String + get() = "errorDetails=${ `errorDetails` }" + } + + public class UnsupportedFirmware( + public val `installed`: kotlin.String, + public val `required`: kotlin.String, + ) : JadeException() { + override val message: String + get() = "installed=${ `installed` }, required=${ `required` }" + } + + public class InvalidPath( + public val `errorDetails`: kotlin.String, + ) : JadeException() { + override val message: String + get() = "errorDetails=${ `errorDetails` }" + } + + public class InvalidPsbt( + public val `errorDetails`: kotlin.String, + ) : JadeException() { + override val message: String + get() = "errorDetails=${ `errorDetails` }" + } + + public class PsbtTooLarge( + public val `size`: kotlin.ULong, + public val `max`: kotlin.ULong, + ) : JadeException() { + override val message: String + get() = "size=${ `size` }, max=${ `max` }" + } + + public class FingerprintMismatch( + public val `device`: kotlin.String, + public val `psbt`: kotlin.String, + ) : JadeException() { + override val message: String + get() = "device=${ `device` }, psbt=${ `psbt` }" + } + + public class NothingSigned( + ) : JadeException() { + override val message: String + get() = "" + } + + public class AddressMismatch( + public val `expected`: kotlin.String, + public val `returned`: kotlin.String, + ) : JadeException() { + override val message: String + get() = "expected=${ `expected` }, returned=${ `returned` }" + } + + public class PinServerException( + public val `errorDetails`: kotlin.String, + ) : JadeException() { + override val message: String + get() = "errorDetails=${ `errorDetails` }" + } + + public class DeviceException( + public val `errorDetails`: kotlin.String, + ) : JadeException() { + override val message: String + get() = "errorDetails=${ `errorDetails` }" + } + + public class IoException( + public val `errorDetails`: kotlin.String, + ) : JadeException() { + override val message: String + get() = "errorDetails=${ `errorDetails` }" + } + +} + + + + + +@kotlinx.serialization.Serializable +public enum class JadeNetwork { + + MAINNET, + TESTNET, + REGTEST; + public companion object +} + + + + + + + +@kotlinx.serialization.Serializable +public enum class JadePingStatus { + + IDLE, + BUSY, + AWAITING_USER_INPUT; + public companion object +} + + + + + + + +@kotlinx.serialization.Serializable +public enum class JadeState { + + UNINIT, + UNSAVED, + LOCKED, + READY, + TEMP, + UNKNOWN; + public companion object +} + + + + + + + +@kotlinx.serialization.Serializable +public enum class JadeTransportErrorCode { + + DEVICE_BUSY, + NOT_CONNECTED, + DISCONNECTED, + TIMEOUT, + PERMISSION_DENIED; + public companion object +} + + + + + + + +@kotlinx.serialization.Serializable +public enum class JadeTransportKind { + + BLUETOOTH, + SERIAL; public companion object } @@ -5240,6 +5728,20 @@ public enum class WordCount { + + + + + + + + + + + + + + diff --git a/bindings/ios/BitkitCore.xcframework.zip b/bindings/ios/BitkitCore.xcframework.zip index 915049d..b33798f 100644 Binary files a/bindings/ios/BitkitCore.xcframework.zip and b/bindings/ios/BitkitCore.xcframework.zip differ diff --git a/bindings/ios/BitkitCore.xcframework/Info.plist b/bindings/ios/BitkitCore.xcframework/Info.plist index b7357e0..478a88f 100644 --- a/bindings/ios/BitkitCore.xcframework/Info.plist +++ b/bindings/ios/BitkitCore.xcframework/Info.plist @@ -10,7 +10,7 @@ HeadersPath Headers LibraryIdentifier - ios-arm64-simulator + ios-arm64 LibraryPath libbitkitcore.a SupportedArchitectures @@ -19,8 +19,6 @@ SupportedPlatform ios - SupportedPlatformVariant - simulator BinaryPath @@ -28,7 +26,7 @@ HeadersPath Headers LibraryIdentifier - ios-arm64 + ios-arm64-simulator LibraryPath libbitkitcore.a SupportedArchitectures @@ -37,6 +35,8 @@ SupportedPlatform ios + SupportedPlatformVariant + simulator CFBundlePackageType diff --git a/bindings/ios/BitkitCore.xcframework/ios-arm64-simulator/Headers/bitkitcoreFFI.h b/bindings/ios/BitkitCore.xcframework/ios-arm64-simulator/Headers/bitkitcoreFFI.h index 79b2fb2..b4dc45f 100644 --- a/bindings/ios/BitkitCore.xcframework/ios-arm64-simulator/Headers/bitkitcoreFFI.h +++ b/bindings/ios/BitkitCore.xcframework/ios-arm64-simulator/Headers/bitkitcoreFFI.h @@ -264,6 +264,48 @@ typedef void (*UniffiCallbackInterfaceEventListenerMethod0)(uint64_t, RustBuffer RustCallStatus *_Nonnull uniffiCallStatus ); +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_JADE_TRANSPORT_CALLBACK_METHOD0 +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_JADE_TRANSPORT_CALLBACK_METHOD0 +typedef void (*UniffiCallbackInterfaceJadeTransportCallbackMethod0)(uint64_t, uint32_t, RustBuffer* _Nonnull, + RustCallStatus *_Nonnull uniffiCallStatus + ); + +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_JADE_TRANSPORT_CALLBACK_METHOD1 +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_JADE_TRANSPORT_CALLBACK_METHOD1 +typedef void (*UniffiCallbackInterfaceJadeTransportCallbackMethod1)(uint64_t, RustBuffer, RustBuffer* _Nonnull, + RustCallStatus *_Nonnull uniffiCallStatus + ); + +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_JADE_TRANSPORT_CALLBACK_METHOD2 +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_JADE_TRANSPORT_CALLBACK_METHOD2 +typedef void (*UniffiCallbackInterfaceJadeTransportCallbackMethod2)(uint64_t, RustBuffer, RustBuffer* _Nonnull, + RustCallStatus *_Nonnull uniffiCallStatus + ); + +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_JADE_TRANSPORT_CALLBACK_METHOD3 +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_JADE_TRANSPORT_CALLBACK_METHOD3 +typedef void (*UniffiCallbackInterfaceJadeTransportCallbackMethod3)(uint64_t, RustBuffer, RustBuffer, RustBuffer* _Nonnull, + RustCallStatus *_Nonnull uniffiCallStatus + ); + +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_JADE_TRANSPORT_CALLBACK_METHOD4 +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_JADE_TRANSPORT_CALLBACK_METHOD4 +typedef void (*UniffiCallbackInterfaceJadeTransportCallbackMethod4)(uint64_t, RustBuffer, uint32_t, RustBuffer* _Nonnull, + RustCallStatus *_Nonnull uniffiCallStatus + ); + +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_JADE_TRANSPORT_CALLBACK_METHOD5 +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_JADE_TRANSPORT_CALLBACK_METHOD5 +typedef void (*UniffiCallbackInterfaceJadeTransportCallbackMethod5)(uint64_t, RustBuffer, uint32_t* _Nonnull, + RustCallStatus *_Nonnull uniffiCallStatus + ); + #endif #ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD0 #define UNIFFI_FFIDEF_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD0 @@ -371,6 +413,19 @@ typedef struct UniffiVTableCallbackInterfaceEventListener { UniffiCallbackInterfaceFree _Nonnull uniffiFree; } UniffiVTableCallbackInterfaceEventListener; +#endif +#ifndef UNIFFI_FFIDEF_V_TABLE_CALLBACK_INTERFACE_JADE_TRANSPORT_CALLBACK +#define UNIFFI_FFIDEF_V_TABLE_CALLBACK_INTERFACE_JADE_TRANSPORT_CALLBACK +typedef struct UniffiVTableCallbackInterfaceJadeTransportCallback { + UniffiCallbackInterfaceJadeTransportCallbackMethod0 _Nonnull scanDevices; + UniffiCallbackInterfaceJadeTransportCallbackMethod1 _Nonnull openDevice; + UniffiCallbackInterfaceJadeTransportCallbackMethod2 _Nonnull closeDevice; + UniffiCallbackInterfaceJadeTransportCallbackMethod3 _Nonnull writeChunk; + UniffiCallbackInterfaceJadeTransportCallbackMethod4 _Nonnull readChunk; + UniffiCallbackInterfaceJadeTransportCallbackMethod5 _Nonnull getChunkSize; + UniffiCallbackInterfaceFree _Nonnull uniffiFree; +} UniffiVTableCallbackInterfaceJadeTransportCallback; + #endif #ifndef UNIFFI_FFIDEF_V_TABLE_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK #define UNIFFI_FFIDEF_V_TABLE_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK @@ -439,6 +494,51 @@ void uniffi_bitkitcore_fn_init_callback_vtable_eventlistener(const UniffiVTableC void uniffi_bitkitcore_fn_method_eventlistener_on_event(void*_Nonnull ptr, RustBuffer watcher_id, RustBuffer event, RustCallStatus *_Nonnull out_status ); #endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_CLONE_JADETRANSPORTCALLBACK +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_CLONE_JADETRANSPORTCALLBACK +void*_Nonnull uniffi_bitkitcore_fn_clone_jadetransportcallback(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FREE_JADETRANSPORTCALLBACK +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FREE_JADETRANSPORTCALLBACK +void uniffi_bitkitcore_fn_free_jadetransportcallback(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_INIT_CALLBACK_VTABLE_JADETRANSPORTCALLBACK +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_INIT_CALLBACK_VTABLE_JADETRANSPORTCALLBACK +void uniffi_bitkitcore_fn_init_callback_vtable_jadetransportcallback(const UniffiVTableCallbackInterfaceJadeTransportCallback* _Nonnull vtable +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_JADETRANSPORTCALLBACK_SCAN_DEVICES +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_JADETRANSPORTCALLBACK_SCAN_DEVICES +RustBuffer uniffi_bitkitcore_fn_method_jadetransportcallback_scan_devices(void*_Nonnull ptr, uint32_t timeout_ms, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_JADETRANSPORTCALLBACK_OPEN_DEVICE +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_JADETRANSPORTCALLBACK_OPEN_DEVICE +RustBuffer uniffi_bitkitcore_fn_method_jadetransportcallback_open_device(void*_Nonnull ptr, RustBuffer path, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_JADETRANSPORTCALLBACK_CLOSE_DEVICE +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_JADETRANSPORTCALLBACK_CLOSE_DEVICE +RustBuffer uniffi_bitkitcore_fn_method_jadetransportcallback_close_device(void*_Nonnull ptr, RustBuffer path, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_JADETRANSPORTCALLBACK_WRITE_CHUNK +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_JADETRANSPORTCALLBACK_WRITE_CHUNK +RustBuffer uniffi_bitkitcore_fn_method_jadetransportcallback_write_chunk(void*_Nonnull ptr, RustBuffer path, RustBuffer data, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_JADETRANSPORTCALLBACK_READ_CHUNK +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_JADETRANSPORTCALLBACK_READ_CHUNK +RustBuffer uniffi_bitkitcore_fn_method_jadetransportcallback_read_chunk(void*_Nonnull ptr, RustBuffer path, uint32_t timeout_ms, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_JADETRANSPORTCALLBACK_GET_CHUNK_SIZE +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_JADETRANSPORTCALLBACK_GET_CHUNK_SIZE +uint32_t uniffi_bitkitcore_fn_method_jadetransportcallback_get_chunk_size(void*_Nonnull ptr, RustBuffer path, RustCallStatus *_Nonnull out_status +); +#endif #ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_CLONE_TREZORTRANSPORTCALLBACK #define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_CLONE_TREZORTRANSPORTCALLBACK void*_Nonnull uniffi_bitkitcore_fn_clone_trezortransportcallback(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status @@ -1022,6 +1122,120 @@ int8_t uniffi_bitkitcore_fn_func_is_address_used(RustBuffer address, RustCallSta int8_t uniffi_bitkitcore_fn_func_is_valid_bip39_word(RustBuffer word, RustCallStatus *_Nonnull out_status ); #endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_ACCOUNT_TYPE_TO_VARIANT +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_ACCOUNT_TYPE_TO_VARIANT +RustBuffer uniffi_bitkitcore_fn_func_jade_account_type_to_variant(RustBuffer account_type, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_CANCEL +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_CANCEL +uint64_t uniffi_bitkitcore_fn_func_jade_cancel(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_CONNECT +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_CONNECT +uint64_t uniffi_bitkitcore_fn_func_jade_connect(RustBuffer transport, RustBuffer path +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_DISCONNECT +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_DISCONNECT +uint64_t uniffi_bitkitcore_fn_func_jade_disconnect(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_GET_ACCOUNT_EXPORT +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_GET_ACCOUNT_EXPORT +uint64_t uniffi_bitkitcore_fn_func_jade_get_account_export(RustBuffer network, uint32_t account_index, RustBuffer account_types +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_GET_CONNECTED_DEVICE +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_GET_CONNECTED_DEVICE +uint64_t uniffi_bitkitcore_fn_func_jade_get_connected_device(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_GET_MASTER_FINGERPRINT +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_GET_MASTER_FINGERPRINT +uint64_t uniffi_bitkitcore_fn_func_jade_get_master_fingerprint(RustBuffer network +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_GET_VERSION_INFO +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_GET_VERSION_INFO +uint64_t uniffi_bitkitcore_fn_func_jade_get_version_info(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_GET_XPUB +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_GET_XPUB +uint64_t uniffi_bitkitcore_fn_func_jade_get_xpub(RustBuffer network, RustBuffer derivation_path +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_IS_CONNECTED +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_IS_CONNECTED +int8_t uniffi_bitkitcore_fn_func_jade_is_connected(RustCallStatus *_Nonnull out_status + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_LIST_DEVICES +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_LIST_DEVICES +uint64_t uniffi_bitkitcore_fn_func_jade_list_devices(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_LOGOUT +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_LOGOUT +uint64_t uniffi_bitkitcore_fn_func_jade_logout(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_NOTIFY_DISCONNECTED +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_NOTIFY_DISCONNECTED +uint64_t uniffi_bitkitcore_fn_func_jade_notify_disconnected(RustBuffer path +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_PING +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_PING +uint64_t uniffi_bitkitcore_fn_func_jade_ping(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_REFRESH_VERSION_INFO +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_REFRESH_VERSION_INFO +uint64_t uniffi_bitkitcore_fn_func_jade_refresh_version_info(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_SCAN +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_SCAN +uint64_t uniffi_bitkitcore_fn_func_jade_scan(uint32_t timeout_ms +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_SET_TRANSPORT_CALLBACK +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_SET_TRANSPORT_CALLBACK +int8_t uniffi_bitkitcore_fn_func_jade_set_transport_callback(void*_Nonnull callback, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_SIGN_MESSAGE +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_SIGN_MESSAGE +uint64_t uniffi_bitkitcore_fn_func_jade_sign_message(RustBuffer network, RustBuffer derivation_path, RustBuffer message +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_SIGN_PSBT +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_SIGN_PSBT +uint64_t uniffi_bitkitcore_fn_func_jade_sign_psbt(RustBuffer network, RustBuffer psbt +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_UNLOCK +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_UNLOCK +uint64_t uniffi_bitkitcore_fn_func_jade_unlock(RustBuffer network +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_VERIFY_ADDRESS +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_VERIFY_ADDRESS +uint64_t uniffi_bitkitcore_fn_func_jade_verify_address(RustBuffer network, RustBuffer variant, RustBuffer derivation_path, RustBuffer expected_address +); +#endif #ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_LNURL_AUTH #define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_LNURL_AUTH uint64_t uniffi_bitkitcore_fn_func_lnurl_auth(RustBuffer domain, RustBuffer k1, RustBuffer callback, RustBuffer bip32_mnemonic, RustBuffer network, RustBuffer bip39_passphrase @@ -2310,6 +2524,132 @@ uint16_t uniffi_bitkitcore_checksum_func_is_address_used(void #define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_IS_VALID_BIP39_WORD uint16_t uniffi_bitkitcore_checksum_func_is_valid_bip39_word(void +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_ACCOUNT_TYPE_TO_VARIANT +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_ACCOUNT_TYPE_TO_VARIANT +uint16_t uniffi_bitkitcore_checksum_func_jade_account_type_to_variant(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_CANCEL +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_CANCEL +uint16_t uniffi_bitkitcore_checksum_func_jade_cancel(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_CONNECT +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_CONNECT +uint16_t uniffi_bitkitcore_checksum_func_jade_connect(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_DISCONNECT +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_DISCONNECT +uint16_t uniffi_bitkitcore_checksum_func_jade_disconnect(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_GET_ACCOUNT_EXPORT +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_GET_ACCOUNT_EXPORT +uint16_t uniffi_bitkitcore_checksum_func_jade_get_account_export(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_GET_CONNECTED_DEVICE +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_GET_CONNECTED_DEVICE +uint16_t uniffi_bitkitcore_checksum_func_jade_get_connected_device(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_GET_MASTER_FINGERPRINT +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_GET_MASTER_FINGERPRINT +uint16_t uniffi_bitkitcore_checksum_func_jade_get_master_fingerprint(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_GET_VERSION_INFO +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_GET_VERSION_INFO +uint16_t uniffi_bitkitcore_checksum_func_jade_get_version_info(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_GET_XPUB +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_GET_XPUB +uint16_t uniffi_bitkitcore_checksum_func_jade_get_xpub(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_IS_CONNECTED +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_IS_CONNECTED +uint16_t uniffi_bitkitcore_checksum_func_jade_is_connected(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_LIST_DEVICES +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_LIST_DEVICES +uint16_t uniffi_bitkitcore_checksum_func_jade_list_devices(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_LOGOUT +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_LOGOUT +uint16_t uniffi_bitkitcore_checksum_func_jade_logout(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_NOTIFY_DISCONNECTED +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_NOTIFY_DISCONNECTED +uint16_t uniffi_bitkitcore_checksum_func_jade_notify_disconnected(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_PING +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_PING +uint16_t uniffi_bitkitcore_checksum_func_jade_ping(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_REFRESH_VERSION_INFO +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_REFRESH_VERSION_INFO +uint16_t uniffi_bitkitcore_checksum_func_jade_refresh_version_info(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_SCAN +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_SCAN +uint16_t uniffi_bitkitcore_checksum_func_jade_scan(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_SET_TRANSPORT_CALLBACK +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_SET_TRANSPORT_CALLBACK +uint16_t uniffi_bitkitcore_checksum_func_jade_set_transport_callback(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_SIGN_MESSAGE +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_SIGN_MESSAGE +uint16_t uniffi_bitkitcore_checksum_func_jade_sign_message(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_SIGN_PSBT +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_SIGN_PSBT +uint16_t uniffi_bitkitcore_checksum_func_jade_sign_psbt(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_UNLOCK +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_UNLOCK +uint16_t uniffi_bitkitcore_checksum_func_jade_unlock(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_VERIFY_ADDRESS +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_VERIFY_ADDRESS +uint16_t uniffi_bitkitcore_checksum_func_jade_verify_address(void + ); #endif #ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_LNURL_AUTH @@ -2874,6 +3214,42 @@ uint16_t uniffi_bitkitcore_checksum_method_boltzeventlistener_on_event(void #define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_EVENTLISTENER_ON_EVENT uint16_t uniffi_bitkitcore_checksum_method_eventlistener_on_event(void +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_JADETRANSPORTCALLBACK_SCAN_DEVICES +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_JADETRANSPORTCALLBACK_SCAN_DEVICES +uint16_t uniffi_bitkitcore_checksum_method_jadetransportcallback_scan_devices(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_JADETRANSPORTCALLBACK_OPEN_DEVICE +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_JADETRANSPORTCALLBACK_OPEN_DEVICE +uint16_t uniffi_bitkitcore_checksum_method_jadetransportcallback_open_device(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_JADETRANSPORTCALLBACK_CLOSE_DEVICE +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_JADETRANSPORTCALLBACK_CLOSE_DEVICE +uint16_t uniffi_bitkitcore_checksum_method_jadetransportcallback_close_device(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_JADETRANSPORTCALLBACK_WRITE_CHUNK +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_JADETRANSPORTCALLBACK_WRITE_CHUNK +uint16_t uniffi_bitkitcore_checksum_method_jadetransportcallback_write_chunk(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_JADETRANSPORTCALLBACK_READ_CHUNK +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_JADETRANSPORTCALLBACK_READ_CHUNK +uint16_t uniffi_bitkitcore_checksum_method_jadetransportcallback_read_chunk(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_JADETRANSPORTCALLBACK_GET_CHUNK_SIZE +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_JADETRANSPORTCALLBACK_GET_CHUNK_SIZE +uint16_t uniffi_bitkitcore_checksum_method_jadetransportcallback_get_chunk_size(void + ); #endif #ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_TREZORTRANSPORTCALLBACK_ENUMERATE_DEVICES diff --git a/bindings/ios/BitkitCore.xcframework/ios-arm64/Headers/bitkitcoreFFI.h b/bindings/ios/BitkitCore.xcframework/ios-arm64/Headers/bitkitcoreFFI.h index 79b2fb2..b4dc45f 100644 --- a/bindings/ios/BitkitCore.xcframework/ios-arm64/Headers/bitkitcoreFFI.h +++ b/bindings/ios/BitkitCore.xcframework/ios-arm64/Headers/bitkitcoreFFI.h @@ -264,6 +264,48 @@ typedef void (*UniffiCallbackInterfaceEventListenerMethod0)(uint64_t, RustBuffer RustCallStatus *_Nonnull uniffiCallStatus ); +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_JADE_TRANSPORT_CALLBACK_METHOD0 +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_JADE_TRANSPORT_CALLBACK_METHOD0 +typedef void (*UniffiCallbackInterfaceJadeTransportCallbackMethod0)(uint64_t, uint32_t, RustBuffer* _Nonnull, + RustCallStatus *_Nonnull uniffiCallStatus + ); + +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_JADE_TRANSPORT_CALLBACK_METHOD1 +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_JADE_TRANSPORT_CALLBACK_METHOD1 +typedef void (*UniffiCallbackInterfaceJadeTransportCallbackMethod1)(uint64_t, RustBuffer, RustBuffer* _Nonnull, + RustCallStatus *_Nonnull uniffiCallStatus + ); + +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_JADE_TRANSPORT_CALLBACK_METHOD2 +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_JADE_TRANSPORT_CALLBACK_METHOD2 +typedef void (*UniffiCallbackInterfaceJadeTransportCallbackMethod2)(uint64_t, RustBuffer, RustBuffer* _Nonnull, + RustCallStatus *_Nonnull uniffiCallStatus + ); + +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_JADE_TRANSPORT_CALLBACK_METHOD3 +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_JADE_TRANSPORT_CALLBACK_METHOD3 +typedef void (*UniffiCallbackInterfaceJadeTransportCallbackMethod3)(uint64_t, RustBuffer, RustBuffer, RustBuffer* _Nonnull, + RustCallStatus *_Nonnull uniffiCallStatus + ); + +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_JADE_TRANSPORT_CALLBACK_METHOD4 +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_JADE_TRANSPORT_CALLBACK_METHOD4 +typedef void (*UniffiCallbackInterfaceJadeTransportCallbackMethod4)(uint64_t, RustBuffer, uint32_t, RustBuffer* _Nonnull, + RustCallStatus *_Nonnull uniffiCallStatus + ); + +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_JADE_TRANSPORT_CALLBACK_METHOD5 +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_JADE_TRANSPORT_CALLBACK_METHOD5 +typedef void (*UniffiCallbackInterfaceJadeTransportCallbackMethod5)(uint64_t, RustBuffer, uint32_t* _Nonnull, + RustCallStatus *_Nonnull uniffiCallStatus + ); + #endif #ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD0 #define UNIFFI_FFIDEF_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD0 @@ -371,6 +413,19 @@ typedef struct UniffiVTableCallbackInterfaceEventListener { UniffiCallbackInterfaceFree _Nonnull uniffiFree; } UniffiVTableCallbackInterfaceEventListener; +#endif +#ifndef UNIFFI_FFIDEF_V_TABLE_CALLBACK_INTERFACE_JADE_TRANSPORT_CALLBACK +#define UNIFFI_FFIDEF_V_TABLE_CALLBACK_INTERFACE_JADE_TRANSPORT_CALLBACK +typedef struct UniffiVTableCallbackInterfaceJadeTransportCallback { + UniffiCallbackInterfaceJadeTransportCallbackMethod0 _Nonnull scanDevices; + UniffiCallbackInterfaceJadeTransportCallbackMethod1 _Nonnull openDevice; + UniffiCallbackInterfaceJadeTransportCallbackMethod2 _Nonnull closeDevice; + UniffiCallbackInterfaceJadeTransportCallbackMethod3 _Nonnull writeChunk; + UniffiCallbackInterfaceJadeTransportCallbackMethod4 _Nonnull readChunk; + UniffiCallbackInterfaceJadeTransportCallbackMethod5 _Nonnull getChunkSize; + UniffiCallbackInterfaceFree _Nonnull uniffiFree; +} UniffiVTableCallbackInterfaceJadeTransportCallback; + #endif #ifndef UNIFFI_FFIDEF_V_TABLE_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK #define UNIFFI_FFIDEF_V_TABLE_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK @@ -439,6 +494,51 @@ void uniffi_bitkitcore_fn_init_callback_vtable_eventlistener(const UniffiVTableC void uniffi_bitkitcore_fn_method_eventlistener_on_event(void*_Nonnull ptr, RustBuffer watcher_id, RustBuffer event, RustCallStatus *_Nonnull out_status ); #endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_CLONE_JADETRANSPORTCALLBACK +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_CLONE_JADETRANSPORTCALLBACK +void*_Nonnull uniffi_bitkitcore_fn_clone_jadetransportcallback(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FREE_JADETRANSPORTCALLBACK +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FREE_JADETRANSPORTCALLBACK +void uniffi_bitkitcore_fn_free_jadetransportcallback(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_INIT_CALLBACK_VTABLE_JADETRANSPORTCALLBACK +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_INIT_CALLBACK_VTABLE_JADETRANSPORTCALLBACK +void uniffi_bitkitcore_fn_init_callback_vtable_jadetransportcallback(const UniffiVTableCallbackInterfaceJadeTransportCallback* _Nonnull vtable +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_JADETRANSPORTCALLBACK_SCAN_DEVICES +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_JADETRANSPORTCALLBACK_SCAN_DEVICES +RustBuffer uniffi_bitkitcore_fn_method_jadetransportcallback_scan_devices(void*_Nonnull ptr, uint32_t timeout_ms, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_JADETRANSPORTCALLBACK_OPEN_DEVICE +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_JADETRANSPORTCALLBACK_OPEN_DEVICE +RustBuffer uniffi_bitkitcore_fn_method_jadetransportcallback_open_device(void*_Nonnull ptr, RustBuffer path, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_JADETRANSPORTCALLBACK_CLOSE_DEVICE +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_JADETRANSPORTCALLBACK_CLOSE_DEVICE +RustBuffer uniffi_bitkitcore_fn_method_jadetransportcallback_close_device(void*_Nonnull ptr, RustBuffer path, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_JADETRANSPORTCALLBACK_WRITE_CHUNK +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_JADETRANSPORTCALLBACK_WRITE_CHUNK +RustBuffer uniffi_bitkitcore_fn_method_jadetransportcallback_write_chunk(void*_Nonnull ptr, RustBuffer path, RustBuffer data, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_JADETRANSPORTCALLBACK_READ_CHUNK +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_JADETRANSPORTCALLBACK_READ_CHUNK +RustBuffer uniffi_bitkitcore_fn_method_jadetransportcallback_read_chunk(void*_Nonnull ptr, RustBuffer path, uint32_t timeout_ms, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_JADETRANSPORTCALLBACK_GET_CHUNK_SIZE +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_JADETRANSPORTCALLBACK_GET_CHUNK_SIZE +uint32_t uniffi_bitkitcore_fn_method_jadetransportcallback_get_chunk_size(void*_Nonnull ptr, RustBuffer path, RustCallStatus *_Nonnull out_status +); +#endif #ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_CLONE_TREZORTRANSPORTCALLBACK #define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_CLONE_TREZORTRANSPORTCALLBACK void*_Nonnull uniffi_bitkitcore_fn_clone_trezortransportcallback(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status @@ -1022,6 +1122,120 @@ int8_t uniffi_bitkitcore_fn_func_is_address_used(RustBuffer address, RustCallSta int8_t uniffi_bitkitcore_fn_func_is_valid_bip39_word(RustBuffer word, RustCallStatus *_Nonnull out_status ); #endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_ACCOUNT_TYPE_TO_VARIANT +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_ACCOUNT_TYPE_TO_VARIANT +RustBuffer uniffi_bitkitcore_fn_func_jade_account_type_to_variant(RustBuffer account_type, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_CANCEL +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_CANCEL +uint64_t uniffi_bitkitcore_fn_func_jade_cancel(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_CONNECT +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_CONNECT +uint64_t uniffi_bitkitcore_fn_func_jade_connect(RustBuffer transport, RustBuffer path +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_DISCONNECT +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_DISCONNECT +uint64_t uniffi_bitkitcore_fn_func_jade_disconnect(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_GET_ACCOUNT_EXPORT +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_GET_ACCOUNT_EXPORT +uint64_t uniffi_bitkitcore_fn_func_jade_get_account_export(RustBuffer network, uint32_t account_index, RustBuffer account_types +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_GET_CONNECTED_DEVICE +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_GET_CONNECTED_DEVICE +uint64_t uniffi_bitkitcore_fn_func_jade_get_connected_device(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_GET_MASTER_FINGERPRINT +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_GET_MASTER_FINGERPRINT +uint64_t uniffi_bitkitcore_fn_func_jade_get_master_fingerprint(RustBuffer network +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_GET_VERSION_INFO +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_GET_VERSION_INFO +uint64_t uniffi_bitkitcore_fn_func_jade_get_version_info(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_GET_XPUB +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_GET_XPUB +uint64_t uniffi_bitkitcore_fn_func_jade_get_xpub(RustBuffer network, RustBuffer derivation_path +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_IS_CONNECTED +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_IS_CONNECTED +int8_t uniffi_bitkitcore_fn_func_jade_is_connected(RustCallStatus *_Nonnull out_status + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_LIST_DEVICES +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_LIST_DEVICES +uint64_t uniffi_bitkitcore_fn_func_jade_list_devices(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_LOGOUT +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_LOGOUT +uint64_t uniffi_bitkitcore_fn_func_jade_logout(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_NOTIFY_DISCONNECTED +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_NOTIFY_DISCONNECTED +uint64_t uniffi_bitkitcore_fn_func_jade_notify_disconnected(RustBuffer path +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_PING +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_PING +uint64_t uniffi_bitkitcore_fn_func_jade_ping(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_REFRESH_VERSION_INFO +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_REFRESH_VERSION_INFO +uint64_t uniffi_bitkitcore_fn_func_jade_refresh_version_info(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_SCAN +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_SCAN +uint64_t uniffi_bitkitcore_fn_func_jade_scan(uint32_t timeout_ms +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_SET_TRANSPORT_CALLBACK +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_SET_TRANSPORT_CALLBACK +int8_t uniffi_bitkitcore_fn_func_jade_set_transport_callback(void*_Nonnull callback, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_SIGN_MESSAGE +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_SIGN_MESSAGE +uint64_t uniffi_bitkitcore_fn_func_jade_sign_message(RustBuffer network, RustBuffer derivation_path, RustBuffer message +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_SIGN_PSBT +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_SIGN_PSBT +uint64_t uniffi_bitkitcore_fn_func_jade_sign_psbt(RustBuffer network, RustBuffer psbt +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_UNLOCK +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_UNLOCK +uint64_t uniffi_bitkitcore_fn_func_jade_unlock(RustBuffer network +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_VERIFY_ADDRESS +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_VERIFY_ADDRESS +uint64_t uniffi_bitkitcore_fn_func_jade_verify_address(RustBuffer network, RustBuffer variant, RustBuffer derivation_path, RustBuffer expected_address +); +#endif #ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_LNURL_AUTH #define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_LNURL_AUTH uint64_t uniffi_bitkitcore_fn_func_lnurl_auth(RustBuffer domain, RustBuffer k1, RustBuffer callback, RustBuffer bip32_mnemonic, RustBuffer network, RustBuffer bip39_passphrase @@ -2310,6 +2524,132 @@ uint16_t uniffi_bitkitcore_checksum_func_is_address_used(void #define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_IS_VALID_BIP39_WORD uint16_t uniffi_bitkitcore_checksum_func_is_valid_bip39_word(void +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_ACCOUNT_TYPE_TO_VARIANT +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_ACCOUNT_TYPE_TO_VARIANT +uint16_t uniffi_bitkitcore_checksum_func_jade_account_type_to_variant(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_CANCEL +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_CANCEL +uint16_t uniffi_bitkitcore_checksum_func_jade_cancel(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_CONNECT +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_CONNECT +uint16_t uniffi_bitkitcore_checksum_func_jade_connect(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_DISCONNECT +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_DISCONNECT +uint16_t uniffi_bitkitcore_checksum_func_jade_disconnect(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_GET_ACCOUNT_EXPORT +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_GET_ACCOUNT_EXPORT +uint16_t uniffi_bitkitcore_checksum_func_jade_get_account_export(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_GET_CONNECTED_DEVICE +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_GET_CONNECTED_DEVICE +uint16_t uniffi_bitkitcore_checksum_func_jade_get_connected_device(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_GET_MASTER_FINGERPRINT +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_GET_MASTER_FINGERPRINT +uint16_t uniffi_bitkitcore_checksum_func_jade_get_master_fingerprint(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_GET_VERSION_INFO +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_GET_VERSION_INFO +uint16_t uniffi_bitkitcore_checksum_func_jade_get_version_info(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_GET_XPUB +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_GET_XPUB +uint16_t uniffi_bitkitcore_checksum_func_jade_get_xpub(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_IS_CONNECTED +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_IS_CONNECTED +uint16_t uniffi_bitkitcore_checksum_func_jade_is_connected(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_LIST_DEVICES +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_LIST_DEVICES +uint16_t uniffi_bitkitcore_checksum_func_jade_list_devices(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_LOGOUT +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_LOGOUT +uint16_t uniffi_bitkitcore_checksum_func_jade_logout(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_NOTIFY_DISCONNECTED +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_NOTIFY_DISCONNECTED +uint16_t uniffi_bitkitcore_checksum_func_jade_notify_disconnected(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_PING +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_PING +uint16_t uniffi_bitkitcore_checksum_func_jade_ping(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_REFRESH_VERSION_INFO +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_REFRESH_VERSION_INFO +uint16_t uniffi_bitkitcore_checksum_func_jade_refresh_version_info(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_SCAN +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_SCAN +uint16_t uniffi_bitkitcore_checksum_func_jade_scan(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_SET_TRANSPORT_CALLBACK +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_SET_TRANSPORT_CALLBACK +uint16_t uniffi_bitkitcore_checksum_func_jade_set_transport_callback(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_SIGN_MESSAGE +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_SIGN_MESSAGE +uint16_t uniffi_bitkitcore_checksum_func_jade_sign_message(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_SIGN_PSBT +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_SIGN_PSBT +uint16_t uniffi_bitkitcore_checksum_func_jade_sign_psbt(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_UNLOCK +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_UNLOCK +uint16_t uniffi_bitkitcore_checksum_func_jade_unlock(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_VERIFY_ADDRESS +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_VERIFY_ADDRESS +uint16_t uniffi_bitkitcore_checksum_func_jade_verify_address(void + ); #endif #ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_LNURL_AUTH @@ -2874,6 +3214,42 @@ uint16_t uniffi_bitkitcore_checksum_method_boltzeventlistener_on_event(void #define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_EVENTLISTENER_ON_EVENT uint16_t uniffi_bitkitcore_checksum_method_eventlistener_on_event(void +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_JADETRANSPORTCALLBACK_SCAN_DEVICES +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_JADETRANSPORTCALLBACK_SCAN_DEVICES +uint16_t uniffi_bitkitcore_checksum_method_jadetransportcallback_scan_devices(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_JADETRANSPORTCALLBACK_OPEN_DEVICE +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_JADETRANSPORTCALLBACK_OPEN_DEVICE +uint16_t uniffi_bitkitcore_checksum_method_jadetransportcallback_open_device(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_JADETRANSPORTCALLBACK_CLOSE_DEVICE +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_JADETRANSPORTCALLBACK_CLOSE_DEVICE +uint16_t uniffi_bitkitcore_checksum_method_jadetransportcallback_close_device(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_JADETRANSPORTCALLBACK_WRITE_CHUNK +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_JADETRANSPORTCALLBACK_WRITE_CHUNK +uint16_t uniffi_bitkitcore_checksum_method_jadetransportcallback_write_chunk(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_JADETRANSPORTCALLBACK_READ_CHUNK +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_JADETRANSPORTCALLBACK_READ_CHUNK +uint16_t uniffi_bitkitcore_checksum_method_jadetransportcallback_read_chunk(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_JADETRANSPORTCALLBACK_GET_CHUNK_SIZE +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_JADETRANSPORTCALLBACK_GET_CHUNK_SIZE +uint16_t uniffi_bitkitcore_checksum_method_jadetransportcallback_get_chunk_size(void + ); #endif #ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_TREZORTRANSPORTCALLBACK_ENUMERATE_DEVICES diff --git a/bindings/ios/bitkitcore.swift b/bindings/ios/bitkitcore.swift index 8db98fc..013774b 100644 --- a/bindings/ios/bitkitcore.swift +++ b/bindings/ios/bitkitcore.swift @@ -975,153 +975,94 @@ public func FfiConverterTypeEventListener_lower(_ value: EventListener) -> Unsaf /** - * Callback interface for native Trezor transport operations + * Native transport for Jade. * - * This trait must be implemented by the native iOS/Android code. - * The implementation handles actual USB or Bluetooth communication. + * # Bluetooth contract * - * # Android Implementation - * Use Android USB Host API for USB devices: - * - Enumerate devices with vendorId 0x1209 (0x534c for older), productId 0x53c1 - * - Request USB permission, claim interface, get endpoints - * - Chunk size: 64 bytes for USB + * Jade advertises the Nordic UART Service: * - * Use Android BLE API for Bluetooth: - * - Scan for Trezor BLE service UUID: 8c000001-a59b-4d58-a9ad-073df69fa1b1 - * - Connect and discover characteristics - * - Read from: 8c000002-a59b-4d58-a9ad-073df69fa1b1 - * - Write to: 8c000003-a59b-4d58-a9ad-073df69fa1b1 - * - Chunk size: 244 bytes for BLE + * - service `6e400001-b5a3-f393-e0a9-e50e24dcca9e` + * - write `6e400002-b5a3-f393-e0a9-e50e24dcca9e` (host to Jade) + * - notify `6e400003-b5a3-f393-e0a9-e50e24dcca9e` (Jade to host) * - * # iOS Implementation - * Use IOKit/CoreBluetooth with same service/characteristic UUIDs. + * Devices advertise as "Jade" or "Jade ". + * + * Three requirements that are easy to miss and break signing on real hardware: + * + * 1. **Write with response.** Write-without-response silently drops chunks on + * the ESP32 GATT stack. + * 2. **Do not pause between chunks.** Firmware discards a partially received + * message after two seconds of silence, three on Jade v1, and answers with + * an unattributed error. A 30 KB PSBT is roughly 60 writes, so any UI thread + * stall in the middle of a send breaks the operation. + * 3. **`read_chunk` must return promptly.** Honour `timeout_ms`, which this + * crate keeps short. The long per-operation deadline is enforced in Rust so + * the user can cancel. */ -public protocol TrezorTransportCallback: AnyObject, Sendable { - - /** - * Enumerate all connected Trezor devices - */ - func enumerateDevices() -> [NativeDeviceInfo] - - /** - * Open a connection to a device - */ - func openDevice(path: String) -> TrezorTransportWriteResult - - /** - * Close the connection to a device - */ - func closeDevice(path: String) -> TrezorTransportWriteResult - - /** - * Read a chunk of data from the device - */ - func readChunk(path: String) -> TrezorTransportReadResult - - /** - * Write a chunk of data to the device - */ - func writeChunk(path: String, data: Data) -> TrezorTransportWriteResult +public protocol JadeTransportCallback: AnyObject, Sendable { /** - * Get the chunk size for a device (64 for USB, 244 for Bluetooth) + * Discover devices, blocking up to `timeout_ms`. */ - func getChunkSize(path: String) -> UInt32 + func scanDevices(timeoutMs: UInt32) -> [JadeNativeDevice] /** - * High-level message call for BLE/THP devices. - * - * For BLE devices that use THP protocol (encrypted communication), - * the native layer should handle encryption/decryption via - * android-trezor-connect and return the raw protobuf response. - * - * Returns None if not supported (will fall back to Protocol V1 chunks). - * Returns Some(result) to use native THP handling. - * - * # Arguments - * * `path` - Device path - * * `message_type` - Protobuf message type (e.g., GetAddress = 29) - * * `data` - Serialized protobuf message data + * Open a connection and enable notifications. */ - func callMessage(path: String, messageType: UInt16, data: Data) -> TrezorCallMessageResult? + func openDevice(path: String) -> JadeTransportResult /** - * Get pairing code from user during BLE THP pairing. - * - * This is called when the Trezor device displays a 6-digit code - * that must be entered to complete Bluetooth pairing. - * - * The native layer should display a UI for the user to enter the code - * shown on the Trezor screen. - * - * Returns the 6-digit code as a string, or empty string to cancel. + * Close the connection and release the device. */ - func getPairingCode() -> String + func closeDevice(path: String) -> JadeTransportResult /** - * Save THP pairing credentials for a device. - * - * Called after successful BLE pairing to store credentials for reconnection. - * The credential_json is a JSON string containing the serialized ThpCredentials. - * - * # Arguments - * * `device_id` - Device identifier (e.g., BLE address like "ble:AA:BB:CC:DD:EE:FF") - * * `credential_json` - JSON string with credential data - * - * Returns true if credentials were saved successfully. + * Write one chunk, no larger than `get_chunk_size`. */ - func saveThpCredential(deviceId: String, credentialJson: String) -> Bool + func writeChunk(path: String, data: Data) -> JadeTransportResult /** - * Load THP pairing credentials for a device. - * - * Called before BLE handshake to check for stored credentials. - * If credentials are found, they will be used to skip the pairing dialog. - * - * # Arguments - * * `device_id` - Device identifier (e.g., BLE address like "ble:AA:BB:CC:DD:EE:FF") + * Read whatever has arrived, waiting at most `timeout_ms`. * - * Returns the JSON string containing ThpCredentials, or None if not found. + * Returning success with an empty vector is normal and means "nothing yet". */ - func loadThpCredential(deviceId: String) -> String? + func readChunk(path: String, timeoutMs: UInt32) -> JadeTransportReadResult /** - * Log a debug message from the Rust THP handshake layer. - * - * This forwards Rust-level errors and state information to the native - * debug UI (e.g., TrezorDebugLog on Android) so they are visible - * alongside the Kotlin-level logs. + * Maximum bytes per write. * - * # Arguments - * * `tag` - Short tag identifying the subsystem (e.g., "HANDSHAKE", "THP") - * * `message` - Human-readable debug message + * For Bluetooth this is `min(negotiated_mtu - 3, 509)`. The value is + * clamped into a usable range, so an unnegotiated `0` is not fatal. */ - func logDebug(tag: String, message: String) + func getChunkSize(path: String) -> UInt32 } /** - * Callback interface for native Trezor transport operations + * Native transport for Jade. * - * This trait must be implemented by the native iOS/Android code. - * The implementation handles actual USB or Bluetooth communication. + * # Bluetooth contract * - * # Android Implementation - * Use Android USB Host API for USB devices: - * - Enumerate devices with vendorId 0x1209 (0x534c for older), productId 0x53c1 - * - Request USB permission, claim interface, get endpoints - * - Chunk size: 64 bytes for USB + * Jade advertises the Nordic UART Service: * - * Use Android BLE API for Bluetooth: - * - Scan for Trezor BLE service UUID: 8c000001-a59b-4d58-a9ad-073df69fa1b1 - * - Connect and discover characteristics - * - Read from: 8c000002-a59b-4d58-a9ad-073df69fa1b1 - * - Write to: 8c000003-a59b-4d58-a9ad-073df69fa1b1 - * - Chunk size: 244 bytes for BLE + * - service `6e400001-b5a3-f393-e0a9-e50e24dcca9e` + * - write `6e400002-b5a3-f393-e0a9-e50e24dcca9e` (host to Jade) + * - notify `6e400003-b5a3-f393-e0a9-e50e24dcca9e` (Jade to host) * - * # iOS Implementation - * Use IOKit/CoreBluetooth with same service/characteristic UUIDs. + * Devices advertise as "Jade" or "Jade ". + * + * Three requirements that are easy to miss and break signing on real hardware: + * + * 1. **Write with response.** Write-without-response silently drops chunks on + * the ESP32 GATT stack. + * 2. **Do not pause between chunks.** Firmware discards a partially received + * message after two seconds of silence, three on Jade v1, and answers with + * an unattributed error. A 30 KB PSBT is roughly 60 writes, so any UI thread + * stall in the middle of a send breaks the operation. + * 3. **`read_chunk` must return promptly.** Honour `timeout_ms`, which this + * crate keeps short. The long per-operation deadline is enforced in Rust so + * the user can cancel. */ -open class TrezorTransportCallbackImpl: TrezorTransportCallback, @unchecked Sendable { +open class JadeTransportCallbackImpl: JadeTransportCallback, @unchecked Sendable { fileprivate let pointer: UnsafeMutableRawPointer! /// Used to instantiate a [FFIObject] without an actual pointer, for fakes in tests, mostly. @@ -1158,7 +1099,7 @@ open class TrezorTransportCallbackImpl: TrezorTransportCallback, @unchecked Send @_documentation(visibility: private) #endif public func uniffiClonePointer() -> UnsafeMutableRawPointer { - return try! rustCall { uniffi_bitkitcore_fn_clone_trezortransportcallback(self.pointer, $0) } + return try! rustCall { uniffi_bitkitcore_fn_clone_jadetransportcallback(self.pointer, $0) } } // No primary constructor declared for this class. @@ -1167,61 +1108,51 @@ open class TrezorTransportCallbackImpl: TrezorTransportCallback, @unchecked Send return } - try! rustCall { uniffi_bitkitcore_fn_free_trezortransportcallback(pointer, $0) } + try! rustCall { uniffi_bitkitcore_fn_free_jadetransportcallback(pointer, $0) } } /** - * Enumerate all connected Trezor devices - */ -open func enumerateDevices() -> [NativeDeviceInfo] { - return try! FfiConverterSequenceTypeNativeDeviceInfo.lift(try! rustCall() { - uniffi_bitkitcore_fn_method_trezortransportcallback_enumerate_devices(self.uniffiClonePointer(),$0 - ) -}) -} - - /** - * Open a connection to a device + * Discover devices, blocking up to `timeout_ms`. */ -open func openDevice(path: String) -> TrezorTransportWriteResult { - return try! FfiConverterTypeTrezorTransportWriteResult_lift(try! rustCall() { - uniffi_bitkitcore_fn_method_trezortransportcallback_open_device(self.uniffiClonePointer(), - FfiConverterString.lower(path),$0 +open func scanDevices(timeoutMs: UInt32) -> [JadeNativeDevice] { + return try! FfiConverterSequenceTypeJadeNativeDevice.lift(try! rustCall() { + uniffi_bitkitcore_fn_method_jadetransportcallback_scan_devices(self.uniffiClonePointer(), + FfiConverterUInt32.lower(timeoutMs),$0 ) }) } /** - * Close the connection to a device + * Open a connection and enable notifications. */ -open func closeDevice(path: String) -> TrezorTransportWriteResult { - return try! FfiConverterTypeTrezorTransportWriteResult_lift(try! rustCall() { - uniffi_bitkitcore_fn_method_trezortransportcallback_close_device(self.uniffiClonePointer(), +open func openDevice(path: String) -> JadeTransportResult { + return try! FfiConverterTypeJadeTransportResult_lift(try! rustCall() { + uniffi_bitkitcore_fn_method_jadetransportcallback_open_device(self.uniffiClonePointer(), FfiConverterString.lower(path),$0 ) }) } /** - * Read a chunk of data from the device + * Close the connection and release the device. */ -open func readChunk(path: String) -> TrezorTransportReadResult { - return try! FfiConverterTypeTrezorTransportReadResult_lift(try! rustCall() { - uniffi_bitkitcore_fn_method_trezortransportcallback_read_chunk(self.uniffiClonePointer(), +open func closeDevice(path: String) -> JadeTransportResult { + return try! FfiConverterTypeJadeTransportResult_lift(try! rustCall() { + uniffi_bitkitcore_fn_method_jadetransportcallback_close_device(self.uniffiClonePointer(), FfiConverterString.lower(path),$0 ) }) } /** - * Write a chunk of data to the device + * Write one chunk, no larger than `get_chunk_size`. */ -open func writeChunk(path: String, data: Data) -> TrezorTransportWriteResult { - return try! FfiConverterTypeTrezorTransportWriteResult_lift(try! rustCall() { - uniffi_bitkitcore_fn_method_trezortransportcallback_write_chunk(self.uniffiClonePointer(), +open func writeChunk(path: String, data: Data) -> JadeTransportResult { + return try! FfiConverterTypeJadeTransportResult_lift(try! rustCall() { + uniffi_bitkitcore_fn_method_jadetransportcallback_write_chunk(self.uniffiClonePointer(), FfiConverterString.lower(path), FfiConverterData.lower(data),$0 ) @@ -1229,147 +1160,64 @@ open func writeChunk(path: String, data: Data) -> TrezorTransportWriteResult { } /** - * Get the chunk size for a device (64 for USB, 244 for Bluetooth) - */ -open func getChunkSize(path: String) -> UInt32 { - return try! FfiConverterUInt32.lift(try! rustCall() { - uniffi_bitkitcore_fn_method_trezortransportcallback_get_chunk_size(self.uniffiClonePointer(), - FfiConverterString.lower(path),$0 - ) -}) -} - - /** - * High-level message call for BLE/THP devices. + * Read whatever has arrived, waiting at most `timeout_ms`. * - * For BLE devices that use THP protocol (encrypted communication), - * the native layer should handle encryption/decryption via - * android-trezor-connect and return the raw protobuf response. - * - * Returns None if not supported (will fall back to Protocol V1 chunks). - * Returns Some(result) to use native THP handling. - * - * # Arguments - * * `path` - Device path - * * `message_type` - Protobuf message type (e.g., GetAddress = 29) - * * `data` - Serialized protobuf message data + * Returning success with an empty vector is normal and means "nothing yet". */ -open func callMessage(path: String, messageType: UInt16, data: Data) -> TrezorCallMessageResult? { - return try! FfiConverterOptionTypeTrezorCallMessageResult.lift(try! rustCall() { - uniffi_bitkitcore_fn_method_trezortransportcallback_call_message(self.uniffiClonePointer(), +open func readChunk(path: String, timeoutMs: UInt32) -> JadeTransportReadResult { + return try! FfiConverterTypeJadeTransportReadResult_lift(try! rustCall() { + uniffi_bitkitcore_fn_method_jadetransportcallback_read_chunk(self.uniffiClonePointer(), FfiConverterString.lower(path), - FfiConverterUInt16.lower(messageType), - FfiConverterData.lower(data),$0 - ) -}) -} - - /** - * Get pairing code from user during BLE THP pairing. - * - * This is called when the Trezor device displays a 6-digit code - * that must be entered to complete Bluetooth pairing. - * - * The native layer should display a UI for the user to enter the code - * shown on the Trezor screen. - * - * Returns the 6-digit code as a string, or empty string to cancel. - */ -open func getPairingCode() -> String { - return try! FfiConverterString.lift(try! rustCall() { - uniffi_bitkitcore_fn_method_trezortransportcallback_get_pairing_code(self.uniffiClonePointer(),$0 - ) -}) -} - - /** - * Save THP pairing credentials for a device. - * - * Called after successful BLE pairing to store credentials for reconnection. - * The credential_json is a JSON string containing the serialized ThpCredentials. - * - * # Arguments - * * `device_id` - Device identifier (e.g., BLE address like "ble:AA:BB:CC:DD:EE:FF") - * * `credential_json` - JSON string with credential data - * - * Returns true if credentials were saved successfully. - */ -open func saveThpCredential(deviceId: String, credentialJson: String) -> Bool { - return try! FfiConverterBool.lift(try! rustCall() { - uniffi_bitkitcore_fn_method_trezortransportcallback_save_thp_credential(self.uniffiClonePointer(), - FfiConverterString.lower(deviceId), - FfiConverterString.lower(credentialJson),$0 + FfiConverterUInt32.lower(timeoutMs),$0 ) }) } /** - * Load THP pairing credentials for a device. + * Maximum bytes per write. * - * Called before BLE handshake to check for stored credentials. - * If credentials are found, they will be used to skip the pairing dialog. - * - * # Arguments - * * `device_id` - Device identifier (e.g., BLE address like "ble:AA:BB:CC:DD:EE:FF") - * - * Returns the JSON string containing ThpCredentials, or None if not found. + * For Bluetooth this is `min(negotiated_mtu - 3, 509)`. The value is + * clamped into a usable range, so an unnegotiated `0` is not fatal. */ -open func loadThpCredential(deviceId: String) -> String? { - return try! FfiConverterOptionString.lift(try! rustCall() { - uniffi_bitkitcore_fn_method_trezortransportcallback_load_thp_credential(self.uniffiClonePointer(), - FfiConverterString.lower(deviceId),$0 +open func getChunkSize(path: String) -> UInt32 { + return try! FfiConverterUInt32.lift(try! rustCall() { + uniffi_bitkitcore_fn_method_jadetransportcallback_get_chunk_size(self.uniffiClonePointer(), + FfiConverterString.lower(path),$0 ) }) } - /** - * Log a debug message from the Rust THP handshake layer. - * - * This forwards Rust-level errors and state information to the native - * debug UI (e.g., TrezorDebugLog on Android) so they are visible - * alongside the Kotlin-level logs. - * - * # Arguments - * * `tag` - Short tag identifying the subsystem (e.g., "HANDSHAKE", "THP") - * * `message` - Human-readable debug message - */ -open func logDebug(tag: String, message: String) {try! rustCall() { - uniffi_bitkitcore_fn_method_trezortransportcallback_log_debug(self.uniffiClonePointer(), - FfiConverterString.lower(tag), - FfiConverterString.lower(message),$0 - ) -} -} - } // Put the implementation in a struct so we don't pollute the top-level namespace -fileprivate struct UniffiCallbackInterfaceTrezorTransportCallback { +fileprivate struct UniffiCallbackInterfaceJadeTransportCallback { // Create the VTable using a series of closures. // Swift automatically converts these into C callback functions. // // This creates 1-element array, since this seems to be the only way to construct a const // pointer that we can pass to the Rust code. - static let vtable: [UniffiVTableCallbackInterfaceTrezorTransportCallback] = [UniffiVTableCallbackInterfaceTrezorTransportCallback( - enumerateDevices: { ( + static let vtable: [UniffiVTableCallbackInterfaceJadeTransportCallback] = [UniffiVTableCallbackInterfaceJadeTransportCallback( + scanDevices: { ( uniffiHandle: UInt64, + timeoutMs: UInt32, uniffiOutReturn: UnsafeMutablePointer, uniffiCallStatus: UnsafeMutablePointer ) in let makeCall = { - () throws -> [NativeDeviceInfo] in - guard let uniffiObj = try? FfiConverterTypeTrezorTransportCallback.handleMap.get(handle: uniffiHandle) else { + () throws -> [JadeNativeDevice] in + guard let uniffiObj = try? FfiConverterTypeJadeTransportCallback.handleMap.get(handle: uniffiHandle) else { throw UniffiInternalError.unexpectedStaleHandle } - return uniffiObj.enumerateDevices( + return uniffiObj.scanDevices( + timeoutMs: try FfiConverterUInt32.lift(timeoutMs) ) } - let writeReturn = { uniffiOutReturn.pointee = FfiConverterSequenceTypeNativeDeviceInfo.lower($0) } + let writeReturn = { uniffiOutReturn.pointee = FfiConverterSequenceTypeJadeNativeDevice.lower($0) } uniffiTraitInterfaceCall( callStatus: uniffiCallStatus, makeCall: makeCall, @@ -1383,8 +1231,8 @@ fileprivate struct UniffiCallbackInterfaceTrezorTransportCallback { uniffiCallStatus: UnsafeMutablePointer ) in let makeCall = { - () throws -> TrezorTransportWriteResult in - guard let uniffiObj = try? FfiConverterTypeTrezorTransportCallback.handleMap.get(handle: uniffiHandle) else { + () throws -> JadeTransportResult in + guard let uniffiObj = try? FfiConverterTypeJadeTransportCallback.handleMap.get(handle: uniffiHandle) else { throw UniffiInternalError.unexpectedStaleHandle } return uniffiObj.openDevice( @@ -1393,7 +1241,7 @@ fileprivate struct UniffiCallbackInterfaceTrezorTransportCallback { } - let writeReturn = { uniffiOutReturn.pointee = FfiConverterTypeTrezorTransportWriteResult_lower($0) } + let writeReturn = { uniffiOutReturn.pointee = FfiConverterTypeJadeTransportResult_lower($0) } uniffiTraitInterfaceCall( callStatus: uniffiCallStatus, makeCall: makeCall, @@ -1407,8 +1255,8 @@ fileprivate struct UniffiCallbackInterfaceTrezorTransportCallback { uniffiCallStatus: UnsafeMutablePointer ) in let makeCall = { - () throws -> TrezorTransportWriteResult in - guard let uniffiObj = try? FfiConverterTypeTrezorTransportCallback.handleMap.get(handle: uniffiHandle) else { + () throws -> JadeTransportResult in + guard let uniffiObj = try? FfiConverterTypeJadeTransportCallback.handleMap.get(handle: uniffiHandle) else { throw UniffiInternalError.unexpectedStaleHandle } return uniffiObj.closeDevice( @@ -1417,57 +1265,59 @@ fileprivate struct UniffiCallbackInterfaceTrezorTransportCallback { } - let writeReturn = { uniffiOutReturn.pointee = FfiConverterTypeTrezorTransportWriteResult_lower($0) } + let writeReturn = { uniffiOutReturn.pointee = FfiConverterTypeJadeTransportResult_lower($0) } uniffiTraitInterfaceCall( callStatus: uniffiCallStatus, makeCall: makeCall, writeReturn: writeReturn ) }, - readChunk: { ( + writeChunk: { ( uniffiHandle: UInt64, path: RustBuffer, + data: RustBuffer, uniffiOutReturn: UnsafeMutablePointer, uniffiCallStatus: UnsafeMutablePointer ) in let makeCall = { - () throws -> TrezorTransportReadResult in - guard let uniffiObj = try? FfiConverterTypeTrezorTransportCallback.handleMap.get(handle: uniffiHandle) else { + () throws -> JadeTransportResult in + guard let uniffiObj = try? FfiConverterTypeJadeTransportCallback.handleMap.get(handle: uniffiHandle) else { throw UniffiInternalError.unexpectedStaleHandle } - return uniffiObj.readChunk( - path: try FfiConverterString.lift(path) + return uniffiObj.writeChunk( + path: try FfiConverterString.lift(path), + data: try FfiConverterData.lift(data) ) } - let writeReturn = { uniffiOutReturn.pointee = FfiConverterTypeTrezorTransportReadResult_lower($0) } + let writeReturn = { uniffiOutReturn.pointee = FfiConverterTypeJadeTransportResult_lower($0) } uniffiTraitInterfaceCall( callStatus: uniffiCallStatus, makeCall: makeCall, writeReturn: writeReturn ) }, - writeChunk: { ( + readChunk: { ( uniffiHandle: UInt64, path: RustBuffer, - data: RustBuffer, + timeoutMs: UInt32, uniffiOutReturn: UnsafeMutablePointer, uniffiCallStatus: UnsafeMutablePointer ) in let makeCall = { - () throws -> TrezorTransportWriteResult in - guard let uniffiObj = try? FfiConverterTypeTrezorTransportCallback.handleMap.get(handle: uniffiHandle) else { + () throws -> JadeTransportReadResult in + guard let uniffiObj = try? FfiConverterTypeJadeTransportCallback.handleMap.get(handle: uniffiHandle) else { throw UniffiInternalError.unexpectedStaleHandle } - return uniffiObj.writeChunk( + return uniffiObj.readChunk( path: try FfiConverterString.lift(path), - data: try FfiConverterData.lift(data) + timeoutMs: try FfiConverterUInt32.lift(timeoutMs) ) } - let writeReturn = { uniffiOutReturn.pointee = FfiConverterTypeTrezorTransportWriteResult_lower($0) } + let writeReturn = { uniffiOutReturn.pointee = FfiConverterTypeJadeTransportReadResult_lower($0) } uniffiTraitInterfaceCall( callStatus: uniffiCallStatus, makeCall: makeCall, @@ -1482,7 +1332,7 @@ fileprivate struct UniffiCallbackInterfaceTrezorTransportCallback { ) in let makeCall = { () throws -> UInt32 in - guard let uniffiObj = try? FfiConverterTypeTrezorTransportCallback.handleMap.get(handle: uniffiHandle) else { + guard let uniffiObj = try? FfiConverterTypeJadeTransportCallback.handleMap.get(handle: uniffiHandle) else { throw UniffiInternalError.unexpectedStaleHandle } return uniffiObj.getChunkSize( @@ -1498,167 +1348,41 @@ fileprivate struct UniffiCallbackInterfaceTrezorTransportCallback { writeReturn: writeReturn ) }, - callMessage: { ( - uniffiHandle: UInt64, - path: RustBuffer, - messageType: UInt16, - data: RustBuffer, - uniffiOutReturn: UnsafeMutablePointer, - uniffiCallStatus: UnsafeMutablePointer - ) in - let makeCall = { - () throws -> TrezorCallMessageResult? in - guard let uniffiObj = try? FfiConverterTypeTrezorTransportCallback.handleMap.get(handle: uniffiHandle) else { - throw UniffiInternalError.unexpectedStaleHandle - } - return uniffiObj.callMessage( - path: try FfiConverterString.lift(path), - messageType: try FfiConverterUInt16.lift(messageType), - data: try FfiConverterData.lift(data) - ) - } - - - let writeReturn = { uniffiOutReturn.pointee = FfiConverterOptionTypeTrezorCallMessageResult.lower($0) } - uniffiTraitInterfaceCall( - callStatus: uniffiCallStatus, - makeCall: makeCall, - writeReturn: writeReturn - ) - }, - getPairingCode: { ( - uniffiHandle: UInt64, - uniffiOutReturn: UnsafeMutablePointer, - uniffiCallStatus: UnsafeMutablePointer - ) in - let makeCall = { - () throws -> String in - guard let uniffiObj = try? FfiConverterTypeTrezorTransportCallback.handleMap.get(handle: uniffiHandle) else { - throw UniffiInternalError.unexpectedStaleHandle - } - return uniffiObj.getPairingCode( - ) - } - - - let writeReturn = { uniffiOutReturn.pointee = FfiConverterString.lower($0) } - uniffiTraitInterfaceCall( - callStatus: uniffiCallStatus, - makeCall: makeCall, - writeReturn: writeReturn - ) - }, - saveThpCredential: { ( - uniffiHandle: UInt64, - deviceId: RustBuffer, - credentialJson: RustBuffer, - uniffiOutReturn: UnsafeMutablePointer, - uniffiCallStatus: UnsafeMutablePointer - ) in - let makeCall = { - () throws -> Bool in - guard let uniffiObj = try? FfiConverterTypeTrezorTransportCallback.handleMap.get(handle: uniffiHandle) else { - throw UniffiInternalError.unexpectedStaleHandle - } - return uniffiObj.saveThpCredential( - deviceId: try FfiConverterString.lift(deviceId), - credentialJson: try FfiConverterString.lift(credentialJson) - ) - } - - - let writeReturn = { uniffiOutReturn.pointee = FfiConverterBool.lower($0) } - uniffiTraitInterfaceCall( - callStatus: uniffiCallStatus, - makeCall: makeCall, - writeReturn: writeReturn - ) - }, - loadThpCredential: { ( - uniffiHandle: UInt64, - deviceId: RustBuffer, - uniffiOutReturn: UnsafeMutablePointer, - uniffiCallStatus: UnsafeMutablePointer - ) in - let makeCall = { - () throws -> String? in - guard let uniffiObj = try? FfiConverterTypeTrezorTransportCallback.handleMap.get(handle: uniffiHandle) else { - throw UniffiInternalError.unexpectedStaleHandle - } - return uniffiObj.loadThpCredential( - deviceId: try FfiConverterString.lift(deviceId) - ) - } - - - let writeReturn = { uniffiOutReturn.pointee = FfiConverterOptionString.lower($0) } - uniffiTraitInterfaceCall( - callStatus: uniffiCallStatus, - makeCall: makeCall, - writeReturn: writeReturn - ) - }, - logDebug: { ( - uniffiHandle: UInt64, - tag: RustBuffer, - message: RustBuffer, - uniffiOutReturn: UnsafeMutableRawPointer, - uniffiCallStatus: UnsafeMutablePointer - ) in - let makeCall = { - () throws -> () in - guard let uniffiObj = try? FfiConverterTypeTrezorTransportCallback.handleMap.get(handle: uniffiHandle) else { - throw UniffiInternalError.unexpectedStaleHandle - } - return uniffiObj.logDebug( - tag: try FfiConverterString.lift(tag), - message: try FfiConverterString.lift(message) - ) - } - - - let writeReturn = { () } - uniffiTraitInterfaceCall( - callStatus: uniffiCallStatus, - makeCall: makeCall, - writeReturn: writeReturn - ) - }, uniffiFree: { (uniffiHandle: UInt64) -> () in - let result = try? FfiConverterTypeTrezorTransportCallback.handleMap.remove(handle: uniffiHandle) + let result = try? FfiConverterTypeJadeTransportCallback.handleMap.remove(handle: uniffiHandle) if result == nil { - print("Uniffi callback interface TrezorTransportCallback: handle missing in uniffiFree") + print("Uniffi callback interface JadeTransportCallback: handle missing in uniffiFree") } } )] } -private func uniffiCallbackInitTrezorTransportCallback() { - uniffi_bitkitcore_fn_init_callback_vtable_trezortransportcallback(UniffiCallbackInterfaceTrezorTransportCallback.vtable) +private func uniffiCallbackInitJadeTransportCallback() { + uniffi_bitkitcore_fn_init_callback_vtable_jadetransportcallback(UniffiCallbackInterfaceJadeTransportCallback.vtable) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeTrezorTransportCallback: FfiConverter { - fileprivate static let handleMap = UniffiHandleMap() +public struct FfiConverterTypeJadeTransportCallback: FfiConverter { + fileprivate static let handleMap = UniffiHandleMap() typealias FfiType = UnsafeMutableRawPointer - typealias SwiftType = TrezorTransportCallback + typealias SwiftType = JadeTransportCallback - public static func lift(_ pointer: UnsafeMutableRawPointer) throws -> TrezorTransportCallback { - return TrezorTransportCallbackImpl(unsafeFromRawPointer: pointer) + public static func lift(_ pointer: UnsafeMutableRawPointer) throws -> JadeTransportCallback { + return JadeTransportCallbackImpl(unsafeFromRawPointer: pointer) } - public static func lower(_ value: TrezorTransportCallback) -> UnsafeMutableRawPointer { + public static func lower(_ value: JadeTransportCallback) -> UnsafeMutableRawPointer { guard let ptr = UnsafeMutableRawPointer(bitPattern: UInt(truncatingIfNeeded: handleMap.insert(obj: value))) else { fatalError("Cast to UnsafeMutableRawPointer failed") } return ptr } - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorTransportCallback { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> JadeTransportCallback { let v: UInt64 = try readInt(&buf) // The Rust code won't compile if a pointer won't fit in a UInt64. // We have to go via `UInt` because that's the thing that's the size of a pointer. @@ -1669,7 +1393,7 @@ public struct FfiConverterTypeTrezorTransportCallback: FfiConverter { return try lift(ptr!) } - public static func write(_ value: TrezorTransportCallback, into buf: inout [UInt8]) { + public static func write(_ value: JadeTransportCallback, into buf: inout [UInt8]) { // This fiddling is because `Int` is the thing that's the same size as a pointer. // The Rust code won't compile if a pointer won't fit in a `UInt64`. writeInt(&buf, UInt64(bitPattern: Int64(Int(bitPattern: lower(value))))) @@ -1680,15 +1404,15 @@ public struct FfiConverterTypeTrezorTransportCallback: FfiConverter { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTrezorTransportCallback_lift(_ pointer: UnsafeMutableRawPointer) throws -> TrezorTransportCallback { - return try FfiConverterTypeTrezorTransportCallback.lift(pointer) +public func FfiConverterTypeJadeTransportCallback_lift(_ pointer: UnsafeMutableRawPointer) throws -> JadeTransportCallback { + return try FfiConverterTypeJadeTransportCallback.lift(pointer) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTrezorTransportCallback_lower(_ value: TrezorTransportCallback) -> UnsafeMutableRawPointer { - return FfiConverterTypeTrezorTransportCallback.lower(value) +public func FfiConverterTypeJadeTransportCallback_lower(_ value: JadeTransportCallback) -> UnsafeMutableRawPointer { + return FfiConverterTypeJadeTransportCallback.lower(value) } @@ -1697,41 +1421,153 @@ public func FfiConverterTypeTrezorTransportCallback_lower(_ value: TrezorTranspo /** - * Callback interface for handling PIN and passphrase requests from the Trezor device. + * Callback interface for native Trezor transport operations * - * The native layer (iOS/Android) should implement this to show PIN/passphrase - * input UI when the device requests it during operations like signing. + * This trait must be implemented by the native iOS/Android code. + * The implementation handles actual USB or Bluetooth communication. + * + * # Android Implementation + * Use Android USB Host API for USB devices: + * - Enumerate devices with vendorId 0x1209 (0x534c for older), productId 0x53c1 + * - Request USB permission, claim interface, get endpoints + * - Chunk size: 64 bytes for USB + * + * Use Android BLE API for Bluetooth: + * - Scan for Trezor BLE service UUID: 8c000001-a59b-4d58-a9ad-073df69fa1b1 + * - Connect and discover characteristics + * - Read from: 8c000002-a59b-4d58-a9ad-073df69fa1b1 + * - Write to: 8c000003-a59b-4d58-a9ad-073df69fa1b1 + * - Chunk size: 244 bytes for BLE + * + * # iOS Implementation + * Use IOKit/CoreBluetooth with same service/characteristic UUIDs. */ -public protocol TrezorUiCallback: AnyObject, Sendable { +public protocol TrezorTransportCallback: AnyObject, Sendable { /** - * Called when the device requests a PIN. + * Enumerate all connected Trezor devices + */ + func enumerateDevices() -> [NativeDeviceInfo] + + /** + * Open a connection to a device + */ + func openDevice(path: String) -> TrezorTransportWriteResult + + /** + * Close the connection to a device + */ + func closeDevice(path: String) -> TrezorTransportWriteResult + + /** + * Read a chunk of data from the device + */ + func readChunk(path: String) -> TrezorTransportReadResult + + /** + * Write a chunk of data to the device + */ + func writeChunk(path: String, data: Data) -> TrezorTransportWriteResult + + /** + * Get the chunk size for a device (64 for USB, 244 for Bluetooth) + */ + func getChunkSize(path: String) -> UInt32 + + /** + * High-level message call for BLE/THP devices. * - * Show a PIN matrix UI and return the matrix-encoded PIN string. - * Return empty string to cancel. + * For BLE devices that use THP protocol (encrypted communication), + * the native layer should handle encryption/decryption via + * android-trezor-connect and return the raw protobuf response. + * + * Returns None if not supported (will fall back to Protocol V1 chunks). + * Returns Some(result) to use native THP handling. + * + * # Arguments + * * `path` - Device path + * * `message_type` - Protobuf message type (e.g., GetAddress = 29) + * * `data` - Serialized protobuf message data */ - func onPinRequest() -> String + func callMessage(path: String, messageType: UInt16, data: Data) -> TrezorCallMessageResult? /** - * Called when the device requests a passphrase. + * Get pairing code from user during BLE THP pairing. * - * If `on_device` is true, the device is asking for the passphrase to be - * entered on the Trezor itself — return `PassphraseResponse::OnDevice`. + * This is called when the Trezor device displays a 6-digit code + * that must be entered to complete Bluetooth pairing. * - * If `on_device` is false, show a passphrase input UI and return - * `Standard` (no passphrase), `Hidden { value }` (host-entered passphrase), - * `OnDevice` (defer entry to the Trezor), or `Cancel`. + * The native layer should display a UI for the user to enter the code + * shown on the Trezor screen. + * + * Returns the 6-digit code as a string, or empty string to cancel. */ - func onPassphraseRequest(onDevice: Bool) -> PassphraseResponse + func getPairingCode() -> String -} + /** + * Save THP pairing credentials for a device. + * + * Called after successful BLE pairing to store credentials for reconnection. + * The credential_json is a JSON string containing the serialized ThpCredentials. + * + * # Arguments + * * `device_id` - Device identifier (e.g., BLE address like "ble:AA:BB:CC:DD:EE:FF") + * * `credential_json` - JSON string with credential data + * + * Returns true if credentials were saved successfully. + */ + func saveThpCredential(deviceId: String, credentialJson: String) -> Bool + + /** + * Load THP pairing credentials for a device. + * + * Called before BLE handshake to check for stored credentials. + * If credentials are found, they will be used to skip the pairing dialog. + * + * # Arguments + * * `device_id` - Device identifier (e.g., BLE address like "ble:AA:BB:CC:DD:EE:FF") + * + * Returns the JSON string containing ThpCredentials, or None if not found. + */ + func loadThpCredential(deviceId: String) -> String? + + /** + * Log a debug message from the Rust THP handshake layer. + * + * This forwards Rust-level errors and state information to the native + * debug UI (e.g., TrezorDebugLog on Android) so they are visible + * alongside the Kotlin-level logs. + * + * # Arguments + * * `tag` - Short tag identifying the subsystem (e.g., "HANDSHAKE", "THP") + * * `message` - Human-readable debug message + */ + func logDebug(tag: String, message: String) + +} /** - * Callback interface for handling PIN and passphrase requests from the Trezor device. + * Callback interface for native Trezor transport operations * - * The native layer (iOS/Android) should implement this to show PIN/passphrase - * input UI when the device requests it during operations like signing. + * This trait must be implemented by the native iOS/Android code. + * The implementation handles actual USB or Bluetooth communication. + * + * # Android Implementation + * Use Android USB Host API for USB devices: + * - Enumerate devices with vendorId 0x1209 (0x534c for older), productId 0x53c1 + * - Request USB permission, claim interface, get endpoints + * - Chunk size: 64 bytes for USB + * + * Use Android BLE API for Bluetooth: + * - Scan for Trezor BLE service UUID: 8c000001-a59b-4d58-a9ad-073df69fa1b1 + * - Connect and discover characteristics + * - Read from: 8c000002-a59b-4d58-a9ad-073df69fa1b1 + * - Write to: 8c000003-a59b-4d58-a9ad-073df69fa1b1 + * - Chunk size: 244 bytes for BLE + * + * # iOS Implementation + * Use IOKit/CoreBluetooth with same service/characteristic UUIDs. */ -open class TrezorUiCallbackImpl: TrezorUiCallback, @unchecked Sendable { +open class TrezorTransportCallbackImpl: TrezorTransportCallback, @unchecked Sendable { fileprivate let pointer: UnsafeMutableRawPointer! /// Used to instantiate a [FFIObject] without an actual pointer, for fakes in tests, mostly. @@ -1768,7 +1604,7 @@ open class TrezorUiCallbackImpl: TrezorUiCallback, @unchecked Sendable { @_documentation(visibility: private) #endif public func uniffiClonePointer() -> UnsafeMutableRawPointer { - return try! rustCall { uniffi_bitkitcore_fn_clone_trezoruicallback(self.pointer, $0) } + return try! rustCall { uniffi_bitkitcore_fn_clone_trezortransportcallback(self.pointer, $0) } } // No primary constructor declared for this class. @@ -1777,96 +1613,457 @@ open class TrezorUiCallbackImpl: TrezorUiCallback, @unchecked Sendable { return } - try! rustCall { uniffi_bitkitcore_fn_free_trezoruicallback(pointer, $0) } + try! rustCall { uniffi_bitkitcore_fn_free_trezortransportcallback(pointer, $0) } } /** - * Called when the device requests a PIN. + * Enumerate all connected Trezor devices + */ +open func enumerateDevices() -> [NativeDeviceInfo] { + return try! FfiConverterSequenceTypeNativeDeviceInfo.lift(try! rustCall() { + uniffi_bitkitcore_fn_method_trezortransportcallback_enumerate_devices(self.uniffiClonePointer(),$0 + ) +}) +} + + /** + * Open a connection to a device + */ +open func openDevice(path: String) -> TrezorTransportWriteResult { + return try! FfiConverterTypeTrezorTransportWriteResult_lift(try! rustCall() { + uniffi_bitkitcore_fn_method_trezortransportcallback_open_device(self.uniffiClonePointer(), + FfiConverterString.lower(path),$0 + ) +}) +} + + /** + * Close the connection to a device + */ +open func closeDevice(path: String) -> TrezorTransportWriteResult { + return try! FfiConverterTypeTrezorTransportWriteResult_lift(try! rustCall() { + uniffi_bitkitcore_fn_method_trezortransportcallback_close_device(self.uniffiClonePointer(), + FfiConverterString.lower(path),$0 + ) +}) +} + + /** + * Read a chunk of data from the device + */ +open func readChunk(path: String) -> TrezorTransportReadResult { + return try! FfiConverterTypeTrezorTransportReadResult_lift(try! rustCall() { + uniffi_bitkitcore_fn_method_trezortransportcallback_read_chunk(self.uniffiClonePointer(), + FfiConverterString.lower(path),$0 + ) +}) +} + + /** + * Write a chunk of data to the device + */ +open func writeChunk(path: String, data: Data) -> TrezorTransportWriteResult { + return try! FfiConverterTypeTrezorTransportWriteResult_lift(try! rustCall() { + uniffi_bitkitcore_fn_method_trezortransportcallback_write_chunk(self.uniffiClonePointer(), + FfiConverterString.lower(path), + FfiConverterData.lower(data),$0 + ) +}) +} + + /** + * Get the chunk size for a device (64 for USB, 244 for Bluetooth) + */ +open func getChunkSize(path: String) -> UInt32 { + return try! FfiConverterUInt32.lift(try! rustCall() { + uniffi_bitkitcore_fn_method_trezortransportcallback_get_chunk_size(self.uniffiClonePointer(), + FfiConverterString.lower(path),$0 + ) +}) +} + + /** + * High-level message call for BLE/THP devices. * - * Show a PIN matrix UI and return the matrix-encoded PIN string. - * Return empty string to cancel. + * For BLE devices that use THP protocol (encrypted communication), + * the native layer should handle encryption/decryption via + * android-trezor-connect and return the raw protobuf response. + * + * Returns None if not supported (will fall back to Protocol V1 chunks). + * Returns Some(result) to use native THP handling. + * + * # Arguments + * * `path` - Device path + * * `message_type` - Protobuf message type (e.g., GetAddress = 29) + * * `data` - Serialized protobuf message data */ -open func onPinRequest() -> String { +open func callMessage(path: String, messageType: UInt16, data: Data) -> TrezorCallMessageResult? { + return try! FfiConverterOptionTypeTrezorCallMessageResult.lift(try! rustCall() { + uniffi_bitkitcore_fn_method_trezortransportcallback_call_message(self.uniffiClonePointer(), + FfiConverterString.lower(path), + FfiConverterUInt16.lower(messageType), + FfiConverterData.lower(data),$0 + ) +}) +} + + /** + * Get pairing code from user during BLE THP pairing. + * + * This is called when the Trezor device displays a 6-digit code + * that must be entered to complete Bluetooth pairing. + * + * The native layer should display a UI for the user to enter the code + * shown on the Trezor screen. + * + * Returns the 6-digit code as a string, or empty string to cancel. + */ +open func getPairingCode() -> String { return try! FfiConverterString.lift(try! rustCall() { - uniffi_bitkitcore_fn_method_trezoruicallback_on_pin_request(self.uniffiClonePointer(),$0 + uniffi_bitkitcore_fn_method_trezortransportcallback_get_pairing_code(self.uniffiClonePointer(),$0 ) }) } /** - * Called when the device requests a passphrase. + * Save THP pairing credentials for a device. * - * If `on_device` is true, the device is asking for the passphrase to be - * entered on the Trezor itself — return `PassphraseResponse::OnDevice`. + * Called after successful BLE pairing to store credentials for reconnection. + * The credential_json is a JSON string containing the serialized ThpCredentials. * - * If `on_device` is false, show a passphrase input UI and return - * `Standard` (no passphrase), `Hidden { value }` (host-entered passphrase), - * `OnDevice` (defer entry to the Trezor), or `Cancel`. + * # Arguments + * * `device_id` - Device identifier (e.g., BLE address like "ble:AA:BB:CC:DD:EE:FF") + * * `credential_json` - JSON string with credential data + * + * Returns true if credentials were saved successfully. */ -open func onPassphraseRequest(onDevice: Bool) -> PassphraseResponse { - return try! FfiConverterTypePassphraseResponse_lift(try! rustCall() { - uniffi_bitkitcore_fn_method_trezoruicallback_on_passphrase_request(self.uniffiClonePointer(), - FfiConverterBool.lower(onDevice),$0 +open func saveThpCredential(deviceId: String, credentialJson: String) -> Bool { + return try! FfiConverterBool.lift(try! rustCall() { + uniffi_bitkitcore_fn_method_trezortransportcallback_save_thp_credential(self.uniffiClonePointer(), + FfiConverterString.lower(deviceId), + FfiConverterString.lower(credentialJson),$0 + ) +}) +} + + /** + * Load THP pairing credentials for a device. + * + * Called before BLE handshake to check for stored credentials. + * If credentials are found, they will be used to skip the pairing dialog. + * + * # Arguments + * * `device_id` - Device identifier (e.g., BLE address like "ble:AA:BB:CC:DD:EE:FF") + * + * Returns the JSON string containing ThpCredentials, or None if not found. + */ +open func loadThpCredential(deviceId: String) -> String? { + return try! FfiConverterOptionString.lift(try! rustCall() { + uniffi_bitkitcore_fn_method_trezortransportcallback_load_thp_credential(self.uniffiClonePointer(), + FfiConverterString.lower(deviceId),$0 ) }) } + /** + * Log a debug message from the Rust THP handshake layer. + * + * This forwards Rust-level errors and state information to the native + * debug UI (e.g., TrezorDebugLog on Android) so they are visible + * alongside the Kotlin-level logs. + * + * # Arguments + * * `tag` - Short tag identifying the subsystem (e.g., "HANDSHAKE", "THP") + * * `message` - Human-readable debug message + */ +open func logDebug(tag: String, message: String) {try! rustCall() { + uniffi_bitkitcore_fn_method_trezortransportcallback_log_debug(self.uniffiClonePointer(), + FfiConverterString.lower(tag), + FfiConverterString.lower(message),$0 + ) +} +} + } // Put the implementation in a struct so we don't pollute the top-level namespace -fileprivate struct UniffiCallbackInterfaceTrezorUiCallback { +fileprivate struct UniffiCallbackInterfaceTrezorTransportCallback { // Create the VTable using a series of closures. // Swift automatically converts these into C callback functions. // // This creates 1-element array, since this seems to be the only way to construct a const // pointer that we can pass to the Rust code. - static let vtable: [UniffiVTableCallbackInterfaceTrezorUiCallback] = [UniffiVTableCallbackInterfaceTrezorUiCallback( - onPinRequest: { ( + static let vtable: [UniffiVTableCallbackInterfaceTrezorTransportCallback] = [UniffiVTableCallbackInterfaceTrezorTransportCallback( + enumerateDevices: { ( uniffiHandle: UInt64, uniffiOutReturn: UnsafeMutablePointer, uniffiCallStatus: UnsafeMutablePointer ) in let makeCall = { - () throws -> String in - guard let uniffiObj = try? FfiConverterTypeTrezorUiCallback.handleMap.get(handle: uniffiHandle) else { + () throws -> [NativeDeviceInfo] in + guard let uniffiObj = try? FfiConverterTypeTrezorTransportCallback.handleMap.get(handle: uniffiHandle) else { throw UniffiInternalError.unexpectedStaleHandle } - return uniffiObj.onPinRequest( + return uniffiObj.enumerateDevices( ) } - let writeReturn = { uniffiOutReturn.pointee = FfiConverterString.lower($0) } + let writeReturn = { uniffiOutReturn.pointee = FfiConverterSequenceTypeNativeDeviceInfo.lower($0) } uniffiTraitInterfaceCall( callStatus: uniffiCallStatus, makeCall: makeCall, writeReturn: writeReturn ) }, - onPassphraseRequest: { ( + openDevice: { ( uniffiHandle: UInt64, - onDevice: Int8, + path: RustBuffer, uniffiOutReturn: UnsafeMutablePointer, uniffiCallStatus: UnsafeMutablePointer ) in let makeCall = { - () throws -> PassphraseResponse in - guard let uniffiObj = try? FfiConverterTypeTrezorUiCallback.handleMap.get(handle: uniffiHandle) else { + () throws -> TrezorTransportWriteResult in + guard let uniffiObj = try? FfiConverterTypeTrezorTransportCallback.handleMap.get(handle: uniffiHandle) else { throw UniffiInternalError.unexpectedStaleHandle } - return uniffiObj.onPassphraseRequest( - onDevice: try FfiConverterBool.lift(onDevice) + return uniffiObj.openDevice( + path: try FfiConverterString.lift(path) ) } - let writeReturn = { uniffiOutReturn.pointee = FfiConverterTypePassphraseResponse_lower($0) } + let writeReturn = { uniffiOutReturn.pointee = FfiConverterTypeTrezorTransportWriteResult_lower($0) } + uniffiTraitInterfaceCall( + callStatus: uniffiCallStatus, + makeCall: makeCall, + writeReturn: writeReturn + ) + }, + closeDevice: { ( + uniffiHandle: UInt64, + path: RustBuffer, + uniffiOutReturn: UnsafeMutablePointer, + uniffiCallStatus: UnsafeMutablePointer + ) in + let makeCall = { + () throws -> TrezorTransportWriteResult in + guard let uniffiObj = try? FfiConverterTypeTrezorTransportCallback.handleMap.get(handle: uniffiHandle) else { + throw UniffiInternalError.unexpectedStaleHandle + } + return uniffiObj.closeDevice( + path: try FfiConverterString.lift(path) + ) + } + + + let writeReturn = { uniffiOutReturn.pointee = FfiConverterTypeTrezorTransportWriteResult_lower($0) } + uniffiTraitInterfaceCall( + callStatus: uniffiCallStatus, + makeCall: makeCall, + writeReturn: writeReturn + ) + }, + readChunk: { ( + uniffiHandle: UInt64, + path: RustBuffer, + uniffiOutReturn: UnsafeMutablePointer, + uniffiCallStatus: UnsafeMutablePointer + ) in + let makeCall = { + () throws -> TrezorTransportReadResult in + guard let uniffiObj = try? FfiConverterTypeTrezorTransportCallback.handleMap.get(handle: uniffiHandle) else { + throw UniffiInternalError.unexpectedStaleHandle + } + return uniffiObj.readChunk( + path: try FfiConverterString.lift(path) + ) + } + + + let writeReturn = { uniffiOutReturn.pointee = FfiConverterTypeTrezorTransportReadResult_lower($0) } + uniffiTraitInterfaceCall( + callStatus: uniffiCallStatus, + makeCall: makeCall, + writeReturn: writeReturn + ) + }, + writeChunk: { ( + uniffiHandle: UInt64, + path: RustBuffer, + data: RustBuffer, + uniffiOutReturn: UnsafeMutablePointer, + uniffiCallStatus: UnsafeMutablePointer + ) in + let makeCall = { + () throws -> TrezorTransportWriteResult in + guard let uniffiObj = try? FfiConverterTypeTrezorTransportCallback.handleMap.get(handle: uniffiHandle) else { + throw UniffiInternalError.unexpectedStaleHandle + } + return uniffiObj.writeChunk( + path: try FfiConverterString.lift(path), + data: try FfiConverterData.lift(data) + ) + } + + + let writeReturn = { uniffiOutReturn.pointee = FfiConverterTypeTrezorTransportWriteResult_lower($0) } + uniffiTraitInterfaceCall( + callStatus: uniffiCallStatus, + makeCall: makeCall, + writeReturn: writeReturn + ) + }, + getChunkSize: { ( + uniffiHandle: UInt64, + path: RustBuffer, + uniffiOutReturn: UnsafeMutablePointer, + uniffiCallStatus: UnsafeMutablePointer + ) in + let makeCall = { + () throws -> UInt32 in + guard let uniffiObj = try? FfiConverterTypeTrezorTransportCallback.handleMap.get(handle: uniffiHandle) else { + throw UniffiInternalError.unexpectedStaleHandle + } + return uniffiObj.getChunkSize( + path: try FfiConverterString.lift(path) + ) + } + + + let writeReturn = { uniffiOutReturn.pointee = FfiConverterUInt32.lower($0) } + uniffiTraitInterfaceCall( + callStatus: uniffiCallStatus, + makeCall: makeCall, + writeReturn: writeReturn + ) + }, + callMessage: { ( + uniffiHandle: UInt64, + path: RustBuffer, + messageType: UInt16, + data: RustBuffer, + uniffiOutReturn: UnsafeMutablePointer, + uniffiCallStatus: UnsafeMutablePointer + ) in + let makeCall = { + () throws -> TrezorCallMessageResult? in + guard let uniffiObj = try? FfiConverterTypeTrezorTransportCallback.handleMap.get(handle: uniffiHandle) else { + throw UniffiInternalError.unexpectedStaleHandle + } + return uniffiObj.callMessage( + path: try FfiConverterString.lift(path), + messageType: try FfiConverterUInt16.lift(messageType), + data: try FfiConverterData.lift(data) + ) + } + + + let writeReturn = { uniffiOutReturn.pointee = FfiConverterOptionTypeTrezorCallMessageResult.lower($0) } + uniffiTraitInterfaceCall( + callStatus: uniffiCallStatus, + makeCall: makeCall, + writeReturn: writeReturn + ) + }, + getPairingCode: { ( + uniffiHandle: UInt64, + uniffiOutReturn: UnsafeMutablePointer, + uniffiCallStatus: UnsafeMutablePointer + ) in + let makeCall = { + () throws -> String in + guard let uniffiObj = try? FfiConverterTypeTrezorTransportCallback.handleMap.get(handle: uniffiHandle) else { + throw UniffiInternalError.unexpectedStaleHandle + } + return uniffiObj.getPairingCode( + ) + } + + + let writeReturn = { uniffiOutReturn.pointee = FfiConverterString.lower($0) } + uniffiTraitInterfaceCall( + callStatus: uniffiCallStatus, + makeCall: makeCall, + writeReturn: writeReturn + ) + }, + saveThpCredential: { ( + uniffiHandle: UInt64, + deviceId: RustBuffer, + credentialJson: RustBuffer, + uniffiOutReturn: UnsafeMutablePointer, + uniffiCallStatus: UnsafeMutablePointer + ) in + let makeCall = { + () throws -> Bool in + guard let uniffiObj = try? FfiConverterTypeTrezorTransportCallback.handleMap.get(handle: uniffiHandle) else { + throw UniffiInternalError.unexpectedStaleHandle + } + return uniffiObj.saveThpCredential( + deviceId: try FfiConverterString.lift(deviceId), + credentialJson: try FfiConverterString.lift(credentialJson) + ) + } + + + let writeReturn = { uniffiOutReturn.pointee = FfiConverterBool.lower($0) } + uniffiTraitInterfaceCall( + callStatus: uniffiCallStatus, + makeCall: makeCall, + writeReturn: writeReturn + ) + }, + loadThpCredential: { ( + uniffiHandle: UInt64, + deviceId: RustBuffer, + uniffiOutReturn: UnsafeMutablePointer, + uniffiCallStatus: UnsafeMutablePointer + ) in + let makeCall = { + () throws -> String? in + guard let uniffiObj = try? FfiConverterTypeTrezorTransportCallback.handleMap.get(handle: uniffiHandle) else { + throw UniffiInternalError.unexpectedStaleHandle + } + return uniffiObj.loadThpCredential( + deviceId: try FfiConverterString.lift(deviceId) + ) + } + + + let writeReturn = { uniffiOutReturn.pointee = FfiConverterOptionString.lower($0) } + uniffiTraitInterfaceCall( + callStatus: uniffiCallStatus, + makeCall: makeCall, + writeReturn: writeReturn + ) + }, + logDebug: { ( + uniffiHandle: UInt64, + tag: RustBuffer, + message: RustBuffer, + uniffiOutReturn: UnsafeMutableRawPointer, + uniffiCallStatus: UnsafeMutablePointer + ) in + let makeCall = { + () throws -> () in + guard let uniffiObj = try? FfiConverterTypeTrezorTransportCallback.handleMap.get(handle: uniffiHandle) else { + throw UniffiInternalError.unexpectedStaleHandle + } + return uniffiObj.logDebug( + tag: try FfiConverterString.lift(tag), + message: try FfiConverterString.lift(message) + ) + } + + + let writeReturn = { () } uniffiTraitInterfaceCall( callStatus: uniffiCallStatus, makeCall: makeCall, @@ -1874,40 +2071,40 @@ fileprivate struct UniffiCallbackInterfaceTrezorUiCallback { ) }, uniffiFree: { (uniffiHandle: UInt64) -> () in - let result = try? FfiConverterTypeTrezorUiCallback.handleMap.remove(handle: uniffiHandle) + let result = try? FfiConverterTypeTrezorTransportCallback.handleMap.remove(handle: uniffiHandle) if result == nil { - print("Uniffi callback interface TrezorUiCallback: handle missing in uniffiFree") + print("Uniffi callback interface TrezorTransportCallback: handle missing in uniffiFree") } } )] } -private func uniffiCallbackInitTrezorUiCallback() { - uniffi_bitkitcore_fn_init_callback_vtable_trezoruicallback(UniffiCallbackInterfaceTrezorUiCallback.vtable) +private func uniffiCallbackInitTrezorTransportCallback() { + uniffi_bitkitcore_fn_init_callback_vtable_trezortransportcallback(UniffiCallbackInterfaceTrezorTransportCallback.vtable) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeTrezorUiCallback: FfiConverter { - fileprivate static let handleMap = UniffiHandleMap() +public struct FfiConverterTypeTrezorTransportCallback: FfiConverter { + fileprivate static let handleMap = UniffiHandleMap() typealias FfiType = UnsafeMutableRawPointer - typealias SwiftType = TrezorUiCallback + typealias SwiftType = TrezorTransportCallback - public static func lift(_ pointer: UnsafeMutableRawPointer) throws -> TrezorUiCallback { - return TrezorUiCallbackImpl(unsafeFromRawPointer: pointer) + public static func lift(_ pointer: UnsafeMutableRawPointer) throws -> TrezorTransportCallback { + return TrezorTransportCallbackImpl(unsafeFromRawPointer: pointer) } - public static func lower(_ value: TrezorUiCallback) -> UnsafeMutableRawPointer { + public static func lower(_ value: TrezorTransportCallback) -> UnsafeMutableRawPointer { guard let ptr = UnsafeMutableRawPointer(bitPattern: UInt(truncatingIfNeeded: handleMap.insert(obj: value))) else { fatalError("Cast to UnsafeMutableRawPointer failed") } return ptr } - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorUiCallback { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorTransportCallback { let v: UInt64 = try readInt(&buf) // The Rust code won't compile if a pointer won't fit in a UInt64. // We have to go via `UInt` because that's the thing that's the size of a pointer. @@ -1918,7 +2115,256 @@ public struct FfiConverterTypeTrezorUiCallback: FfiConverter { return try lift(ptr!) } - public static func write(_ value: TrezorUiCallback, into buf: inout [UInt8]) { + public static func write(_ value: TrezorTransportCallback, into buf: inout [UInt8]) { + // This fiddling is because `Int` is the thing that's the same size as a pointer. + // The Rust code won't compile if a pointer won't fit in a `UInt64`. + writeInt(&buf, UInt64(bitPattern: Int64(Int(bitPattern: lower(value))))) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeTrezorTransportCallback_lift(_ pointer: UnsafeMutableRawPointer) throws -> TrezorTransportCallback { + return try FfiConverterTypeTrezorTransportCallback.lift(pointer) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeTrezorTransportCallback_lower(_ value: TrezorTransportCallback) -> UnsafeMutableRawPointer { + return FfiConverterTypeTrezorTransportCallback.lower(value) +} + + + + + + +/** + * Callback interface for handling PIN and passphrase requests from the Trezor device. + * + * The native layer (iOS/Android) should implement this to show PIN/passphrase + * input UI when the device requests it during operations like signing. + */ +public protocol TrezorUiCallback: AnyObject, Sendable { + + /** + * Called when the device requests a PIN. + * + * Show a PIN matrix UI and return the matrix-encoded PIN string. + * Return empty string to cancel. + */ + func onPinRequest() -> String + + /** + * Called when the device requests a passphrase. + * + * If `on_device` is true, the device is asking for the passphrase to be + * entered on the Trezor itself — return `PassphraseResponse::OnDevice`. + * + * If `on_device` is false, show a passphrase input UI and return + * `Standard` (no passphrase), `Hidden { value }` (host-entered passphrase), + * `OnDevice` (defer entry to the Trezor), or `Cancel`. + */ + func onPassphraseRequest(onDevice: Bool) -> PassphraseResponse + +} +/** + * Callback interface for handling PIN and passphrase requests from the Trezor device. + * + * The native layer (iOS/Android) should implement this to show PIN/passphrase + * input UI when the device requests it during operations like signing. + */ +open class TrezorUiCallbackImpl: TrezorUiCallback, @unchecked Sendable { + fileprivate let pointer: UnsafeMutableRawPointer! + + /// Used to instantiate a [FFIObject] without an actual pointer, for fakes in tests, mostly. +#if swift(>=5.8) + @_documentation(visibility: private) +#endif + public struct NoPointer { + public init() {} + } + + // TODO: We'd like this to be `private` but for Swifty reasons, + // we can't implement `FfiConverter` without making this `required` and we can't + // make it `required` without making it `public`. +#if swift(>=5.8) + @_documentation(visibility: private) +#endif + required public init(unsafeFromRawPointer pointer: UnsafeMutableRawPointer) { + self.pointer = pointer + } + + // This constructor can be used to instantiate a fake object. + // - Parameter noPointer: Placeholder value so we can have a constructor separate from the default empty one that may be implemented for classes extending [FFIObject]. + // + // - Warning: + // Any object instantiated with this constructor cannot be passed to an actual Rust-backed object. Since there isn't a backing [Pointer] the FFI lower functions will crash. +#if swift(>=5.8) + @_documentation(visibility: private) +#endif + public init(noPointer: NoPointer) { + self.pointer = nil + } + +#if swift(>=5.8) + @_documentation(visibility: private) +#endif + public func uniffiClonePointer() -> UnsafeMutableRawPointer { + return try! rustCall { uniffi_bitkitcore_fn_clone_trezoruicallback(self.pointer, $0) } + } + // No primary constructor declared for this class. + + deinit { + guard let pointer = pointer else { + return + } + + try! rustCall { uniffi_bitkitcore_fn_free_trezoruicallback(pointer, $0) } + } + + + + + /** + * Called when the device requests a PIN. + * + * Show a PIN matrix UI and return the matrix-encoded PIN string. + * Return empty string to cancel. + */ +open func onPinRequest() -> String { + return try! FfiConverterString.lift(try! rustCall() { + uniffi_bitkitcore_fn_method_trezoruicallback_on_pin_request(self.uniffiClonePointer(),$0 + ) +}) +} + + /** + * Called when the device requests a passphrase. + * + * If `on_device` is true, the device is asking for the passphrase to be + * entered on the Trezor itself — return `PassphraseResponse::OnDevice`. + * + * If `on_device` is false, show a passphrase input UI and return + * `Standard` (no passphrase), `Hidden { value }` (host-entered passphrase), + * `OnDevice` (defer entry to the Trezor), or `Cancel`. + */ +open func onPassphraseRequest(onDevice: Bool) -> PassphraseResponse { + return try! FfiConverterTypePassphraseResponse_lift(try! rustCall() { + uniffi_bitkitcore_fn_method_trezoruicallback_on_passphrase_request(self.uniffiClonePointer(), + FfiConverterBool.lower(onDevice),$0 + ) +}) +} + + +} + + +// Put the implementation in a struct so we don't pollute the top-level namespace +fileprivate struct UniffiCallbackInterfaceTrezorUiCallback { + + // Create the VTable using a series of closures. + // Swift automatically converts these into C callback functions. + // + // This creates 1-element array, since this seems to be the only way to construct a const + // pointer that we can pass to the Rust code. + static let vtable: [UniffiVTableCallbackInterfaceTrezorUiCallback] = [UniffiVTableCallbackInterfaceTrezorUiCallback( + onPinRequest: { ( + uniffiHandle: UInt64, + uniffiOutReturn: UnsafeMutablePointer, + uniffiCallStatus: UnsafeMutablePointer + ) in + let makeCall = { + () throws -> String in + guard let uniffiObj = try? FfiConverterTypeTrezorUiCallback.handleMap.get(handle: uniffiHandle) else { + throw UniffiInternalError.unexpectedStaleHandle + } + return uniffiObj.onPinRequest( + ) + } + + + let writeReturn = { uniffiOutReturn.pointee = FfiConverterString.lower($0) } + uniffiTraitInterfaceCall( + callStatus: uniffiCallStatus, + makeCall: makeCall, + writeReturn: writeReturn + ) + }, + onPassphraseRequest: { ( + uniffiHandle: UInt64, + onDevice: Int8, + uniffiOutReturn: UnsafeMutablePointer, + uniffiCallStatus: UnsafeMutablePointer + ) in + let makeCall = { + () throws -> PassphraseResponse in + guard let uniffiObj = try? FfiConverterTypeTrezorUiCallback.handleMap.get(handle: uniffiHandle) else { + throw UniffiInternalError.unexpectedStaleHandle + } + return uniffiObj.onPassphraseRequest( + onDevice: try FfiConverterBool.lift(onDevice) + ) + } + + + let writeReturn = { uniffiOutReturn.pointee = FfiConverterTypePassphraseResponse_lower($0) } + uniffiTraitInterfaceCall( + callStatus: uniffiCallStatus, + makeCall: makeCall, + writeReturn: writeReturn + ) + }, + uniffiFree: { (uniffiHandle: UInt64) -> () in + let result = try? FfiConverterTypeTrezorUiCallback.handleMap.remove(handle: uniffiHandle) + if result == nil { + print("Uniffi callback interface TrezorUiCallback: handle missing in uniffiFree") + } + } + )] +} + +private func uniffiCallbackInitTrezorUiCallback() { + uniffi_bitkitcore_fn_init_callback_vtable_trezoruicallback(UniffiCallbackInterfaceTrezorUiCallback.vtable) +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeTrezorUiCallback: FfiConverter { + fileprivate static let handleMap = UniffiHandleMap() + + typealias FfiType = UnsafeMutableRawPointer + typealias SwiftType = TrezorUiCallback + + public static func lift(_ pointer: UnsafeMutableRawPointer) throws -> TrezorUiCallback { + return TrezorUiCallbackImpl(unsafeFromRawPointer: pointer) + } + + public static func lower(_ value: TrezorUiCallback) -> UnsafeMutableRawPointer { + guard let ptr = UnsafeMutableRawPointer(bitPattern: UInt(truncatingIfNeeded: handleMap.insert(obj: value))) else { + fatalError("Cast to UnsafeMutableRawPointer failed") + } + return ptr + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorUiCallback { + let v: UInt64 = try readInt(&buf) + // The Rust code won't compile if a pointer won't fit in a UInt64. + // We have to go via `UInt` because that's the thing that's the size of a pointer. + let ptr = UnsafeMutableRawPointer(bitPattern: UInt(truncatingIfNeeded: v)) + if (ptr == nil) { + throw UniffiInternalError.unexpectedNullPointer + } + return try lift(ptr!) + } + + public static func write(_ value: TrezorUiCallback, into buf: inout [UInt8]) { // This fiddling is because `Int` is the thing that's the same size as a pointer. // The Rust code won't compile if a pointer won't fit in a `UInt64`. writeInt(&buf, UInt64(bitPattern: Int64(Int(bitPattern: lower(value))))) @@ -7649,71 +8095,67 @@ public func FfiConverterTypeIManualRefund_lower(_ value: IManualRefund) -> RustB } -public struct LegacyRnCloseRecoveryScanResult { - /** - * Total balance found in legacy RN P2WPKH close outputs (in satoshis). - */ - public var totalAmount: UInt64 - /** - * Number of P2WPKH outputs found. - */ - public var outputsCount: UInt32 +public struct JadeAccount { + public var variant: JadeAddressVariant + public var xpub: String + public var derivationPath: String // Default memberwise initializers are never public by default, so we // declare one manually. - public init( - /** - * Total balance found in legacy RN P2WPKH close outputs (in satoshis). - */totalAmount: UInt64, - /** - * Number of P2WPKH outputs found. - */outputsCount: UInt32) { - self.totalAmount = totalAmount - self.outputsCount = outputsCount + public init(variant: JadeAddressVariant, xpub: String, derivationPath: String) { + self.variant = variant + self.xpub = xpub + self.derivationPath = derivationPath } } #if compiler(>=6) -extension LegacyRnCloseRecoveryScanResult: Sendable {} +extension JadeAccount: Sendable {} #endif -extension LegacyRnCloseRecoveryScanResult: Equatable, Hashable { - public static func ==(lhs: LegacyRnCloseRecoveryScanResult, rhs: LegacyRnCloseRecoveryScanResult) -> Bool { - if lhs.totalAmount != rhs.totalAmount { +extension JadeAccount: Equatable, Hashable { + public static func ==(lhs: JadeAccount, rhs: JadeAccount) -> Bool { + if lhs.variant != rhs.variant { return false } - if lhs.outputsCount != rhs.outputsCount { + if lhs.xpub != rhs.xpub { + return false + } + if lhs.derivationPath != rhs.derivationPath { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(totalAmount) - hasher.combine(outputsCount) + hasher.combine(variant) + hasher.combine(xpub) + hasher.combine(derivationPath) } } -extension LegacyRnCloseRecoveryScanResult: Codable {} +extension JadeAccount: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeLegacyRnCloseRecoveryScanResult: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> LegacyRnCloseRecoveryScanResult { +public struct FfiConverterTypeJadeAccount: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> JadeAccount { return - try LegacyRnCloseRecoveryScanResult( - totalAmount: FfiConverterUInt64.read(from: &buf), - outputsCount: FfiConverterUInt32.read(from: &buf) + try JadeAccount( + variant: FfiConverterTypeJadeAddressVariant.read(from: &buf), + xpub: FfiConverterString.read(from: &buf), + derivationPath: FfiConverterString.read(from: &buf) ) } - public static func write(_ value: LegacyRnCloseRecoveryScanResult, into buf: inout [UInt8]) { - FfiConverterUInt64.write(value.totalAmount, into: &buf) - FfiConverterUInt32.write(value.outputsCount, into: &buf) + public static func write(_ value: JadeAccount, into buf: inout [UInt8]) { + FfiConverterTypeJadeAddressVariant.write(value.variant, into: &buf) + FfiConverterString.write(value.xpub, into: &buf) + FfiConverterString.write(value.derivationPath, into: &buf) } } @@ -7721,167 +8163,79 @@ public struct FfiConverterTypeLegacyRnCloseRecoveryScanResult: FfiConverterRustB #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeLegacyRnCloseRecoveryScanResult_lift(_ buf: RustBuffer) throws -> LegacyRnCloseRecoveryScanResult { - return try FfiConverterTypeLegacyRnCloseRecoveryScanResult.lift(buf) +public func FfiConverterTypeJadeAccount_lift(_ buf: RustBuffer) throws -> JadeAccount { + return try FfiConverterTypeJadeAccount.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeLegacyRnCloseRecoveryScanResult_lower(_ value: LegacyRnCloseRecoveryScanResult) -> RustBuffer { - return FfiConverterTypeLegacyRnCloseRecoveryScanResult.lower(value) +public func FfiConverterTypeJadeAccount_lower(_ value: JadeAccount) -> RustBuffer { + return FfiConverterTypeJadeAccount.lower(value) } -public struct LegacyRnCloseRecoverySweepPreview { - /** - * Fully signed raw sweep transaction hex. Broadcast only after user confirmation. - */ - public var txHex: String - /** - * Transaction id of the sweep transaction. - */ - public var txid: String - /** - * Total input amount in satoshis. - */ - public var totalAmount: UInt64 - /** - * Fee in satoshis. - */ - public var estimatedFee: UInt64 - /** - * Transaction virtual size in vbytes. - */ - public var estimatedVsize: UInt64 - /** - * Number of recovered outputs swept. - */ - public var outputsCount: UInt32 - /** - * Destination address receiving the sweep. - */ - public var destinationAddress: String - /** - * Amount sent to destination after fees. - */ - public var amountAfterFees: UInt64 +public struct JadeAccountExport { + public var masterFingerprint: String + public var accountIndex: UInt32 + public var accounts: [JadeAccount] // Default memberwise initializers are never public by default, so we // declare one manually. - public init( - /** - * Fully signed raw sweep transaction hex. Broadcast only after user confirmation. - */txHex: String, - /** - * Transaction id of the sweep transaction. - */txid: String, - /** - * Total input amount in satoshis. - */totalAmount: UInt64, - /** - * Fee in satoshis. - */estimatedFee: UInt64, - /** - * Transaction virtual size in vbytes. - */estimatedVsize: UInt64, - /** - * Number of recovered outputs swept. - */outputsCount: UInt32, - /** - * Destination address receiving the sweep. - */destinationAddress: String, - /** - * Amount sent to destination after fees. - */amountAfterFees: UInt64) { - self.txHex = txHex - self.txid = txid - self.totalAmount = totalAmount - self.estimatedFee = estimatedFee - self.estimatedVsize = estimatedVsize - self.outputsCount = outputsCount - self.destinationAddress = destinationAddress - self.amountAfterFees = amountAfterFees + public init(masterFingerprint: String, accountIndex: UInt32, accounts: [JadeAccount]) { + self.masterFingerprint = masterFingerprint + self.accountIndex = accountIndex + self.accounts = accounts } } #if compiler(>=6) -extension LegacyRnCloseRecoverySweepPreview: Sendable {} +extension JadeAccountExport: Sendable {} #endif -extension LegacyRnCloseRecoverySweepPreview: Equatable, Hashable { - public static func ==(lhs: LegacyRnCloseRecoverySweepPreview, rhs: LegacyRnCloseRecoverySweepPreview) -> Bool { - if lhs.txHex != rhs.txHex { - return false - } - if lhs.txid != rhs.txid { - return false - } - if lhs.totalAmount != rhs.totalAmount { - return false - } - if lhs.estimatedFee != rhs.estimatedFee { - return false - } - if lhs.estimatedVsize != rhs.estimatedVsize { - return false - } - if lhs.outputsCount != rhs.outputsCount { +extension JadeAccountExport: Equatable, Hashable { + public static func ==(lhs: JadeAccountExport, rhs: JadeAccountExport) -> Bool { + if lhs.masterFingerprint != rhs.masterFingerprint { return false } - if lhs.destinationAddress != rhs.destinationAddress { + if lhs.accountIndex != rhs.accountIndex { return false } - if lhs.amountAfterFees != rhs.amountAfterFees { + if lhs.accounts != rhs.accounts { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(txHex) - hasher.combine(txid) - hasher.combine(totalAmount) - hasher.combine(estimatedFee) - hasher.combine(estimatedVsize) - hasher.combine(outputsCount) - hasher.combine(destinationAddress) - hasher.combine(amountAfterFees) + hasher.combine(masterFingerprint) + hasher.combine(accountIndex) + hasher.combine(accounts) } } -extension LegacyRnCloseRecoverySweepPreview: Codable {} +extension JadeAccountExport: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeLegacyRnCloseRecoverySweepPreview: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> LegacyRnCloseRecoverySweepPreview { +public struct FfiConverterTypeJadeAccountExport: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> JadeAccountExport { return - try LegacyRnCloseRecoverySweepPreview( - txHex: FfiConverterString.read(from: &buf), - txid: FfiConverterString.read(from: &buf), - totalAmount: FfiConverterUInt64.read(from: &buf), - estimatedFee: FfiConverterUInt64.read(from: &buf), - estimatedVsize: FfiConverterUInt64.read(from: &buf), - outputsCount: FfiConverterUInt32.read(from: &buf), - destinationAddress: FfiConverterString.read(from: &buf), - amountAfterFees: FfiConverterUInt64.read(from: &buf) + try JadeAccountExport( + masterFingerprint: FfiConverterString.read(from: &buf), + accountIndex: FfiConverterUInt32.read(from: &buf), + accounts: FfiConverterSequenceTypeJadeAccount.read(from: &buf) ) } - public static func write(_ value: LegacyRnCloseRecoverySweepPreview, into buf: inout [UInt8]) { - FfiConverterString.write(value.txHex, into: &buf) - FfiConverterString.write(value.txid, into: &buf) - FfiConverterUInt64.write(value.totalAmount, into: &buf) - FfiConverterUInt64.write(value.estimatedFee, into: &buf) - FfiConverterUInt64.write(value.estimatedVsize, into: &buf) - FfiConverterUInt32.write(value.outputsCount, into: &buf) - FfiConverterString.write(value.destinationAddress, into: &buf) - FfiConverterUInt64.write(value.amountAfterFees, into: &buf) + public static func write(_ value: JadeAccountExport, into buf: inout [UInt8]) { + FfiConverterString.write(value.masterFingerprint, into: &buf) + FfiConverterUInt32.write(value.accountIndex, into: &buf) + FfiConverterSequenceTypeJadeAccount.write(value.accounts, into: &buf) } } @@ -7889,167 +8243,87 @@ public struct FfiConverterTypeLegacyRnCloseRecoverySweepPreview: FfiConverterRus #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeLegacyRnCloseRecoverySweepPreview_lift(_ buf: RustBuffer) throws -> LegacyRnCloseRecoverySweepPreview { - return try FfiConverterTypeLegacyRnCloseRecoverySweepPreview.lift(buf) +public func FfiConverterTypeJadeAccountExport_lift(_ buf: RustBuffer) throws -> JadeAccountExport { + return try FfiConverterTypeJadeAccountExport.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeLegacyRnCloseRecoverySweepPreview_lower(_ value: LegacyRnCloseRecoverySweepPreview) -> RustBuffer { - return FfiConverterTypeLegacyRnCloseRecoverySweepPreview.lower(value) +public func FfiConverterTypeJadeAccountExport_lower(_ value: JadeAccountExport) -> RustBuffer { + return FfiConverterTypeJadeAccountExport.lower(value) } -public struct LightningActivity { - public var walletId: String - public var id: String - public var txType: PaymentType - public var status: PaymentState - public var value: UInt64 - public var fee: UInt64? - public var invoice: String - public var message: String - public var timestamp: UInt64 - public var preimage: String? - public var contact: String? - public var createdAt: UInt64? - public var updatedAt: UInt64? - public var seenAt: UInt64? +public struct JadeDeviceInfo { + public var path: String + public var transport: JadeTransportKind + public var name: String? + public var serialNumber: String? // Default memberwise initializers are never public by default, so we // declare one manually. - public init(walletId: String, id: String, txType: PaymentType, status: PaymentState, value: UInt64, fee: UInt64?, invoice: String, message: String, timestamp: UInt64, preimage: String?, contact: String?, createdAt: UInt64?, updatedAt: UInt64?, seenAt: UInt64?) { - self.walletId = walletId - self.id = id - self.txType = txType - self.status = status - self.value = value - self.fee = fee - self.invoice = invoice - self.message = message - self.timestamp = timestamp - self.preimage = preimage - self.contact = contact - self.createdAt = createdAt - self.updatedAt = updatedAt - self.seenAt = seenAt + public init(path: String, transport: JadeTransportKind, name: String?, serialNumber: String?) { + self.path = path + self.transport = transport + self.name = name + self.serialNumber = serialNumber } } #if compiler(>=6) -extension LightningActivity: Sendable {} +extension JadeDeviceInfo: Sendable {} #endif -extension LightningActivity: Equatable, Hashable { - public static func ==(lhs: LightningActivity, rhs: LightningActivity) -> Bool { - if lhs.walletId != rhs.walletId { - return false - } - if lhs.id != rhs.id { - return false - } - if lhs.txType != rhs.txType { - return false - } - if lhs.status != rhs.status { - return false - } - if lhs.value != rhs.value { - return false - } - if lhs.fee != rhs.fee { - return false - } - if lhs.invoice != rhs.invoice { - return false - } - if lhs.message != rhs.message { - return false - } - if lhs.timestamp != rhs.timestamp { - return false - } - if lhs.preimage != rhs.preimage { - return false - } - if lhs.contact != rhs.contact { +extension JadeDeviceInfo: Equatable, Hashable { + public static func ==(lhs: JadeDeviceInfo, rhs: JadeDeviceInfo) -> Bool { + if lhs.path != rhs.path { return false } - if lhs.createdAt != rhs.createdAt { + if lhs.transport != rhs.transport { return false } - if lhs.updatedAt != rhs.updatedAt { + if lhs.name != rhs.name { return false } - if lhs.seenAt != rhs.seenAt { + if lhs.serialNumber != rhs.serialNumber { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(walletId) - hasher.combine(id) - hasher.combine(txType) - hasher.combine(status) - hasher.combine(value) - hasher.combine(fee) - hasher.combine(invoice) - hasher.combine(message) - hasher.combine(timestamp) - hasher.combine(preimage) - hasher.combine(contact) - hasher.combine(createdAt) - hasher.combine(updatedAt) - hasher.combine(seenAt) + hasher.combine(path) + hasher.combine(transport) + hasher.combine(name) + hasher.combine(serialNumber) } } -extension LightningActivity: Codable {} +extension JadeDeviceInfo: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeLightningActivity: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> LightningActivity { +public struct FfiConverterTypeJadeDeviceInfo: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> JadeDeviceInfo { return - try LightningActivity( - walletId: FfiConverterString.read(from: &buf), - id: FfiConverterString.read(from: &buf), - txType: FfiConverterTypePaymentType.read(from: &buf), - status: FfiConverterTypePaymentState.read(from: &buf), - value: FfiConverterUInt64.read(from: &buf), - fee: FfiConverterOptionUInt64.read(from: &buf), - invoice: FfiConverterString.read(from: &buf), - message: FfiConverterString.read(from: &buf), - timestamp: FfiConverterUInt64.read(from: &buf), - preimage: FfiConverterOptionString.read(from: &buf), - contact: FfiConverterOptionString.read(from: &buf), - createdAt: FfiConverterOptionUInt64.read(from: &buf), - updatedAt: FfiConverterOptionUInt64.read(from: &buf), - seenAt: FfiConverterOptionUInt64.read(from: &buf) + try JadeDeviceInfo( + path: FfiConverterString.read(from: &buf), + transport: FfiConverterTypeJadeTransportKind.read(from: &buf), + name: FfiConverterOptionString.read(from: &buf), + serialNumber: FfiConverterOptionString.read(from: &buf) ) } - public static func write(_ value: LightningActivity, into buf: inout [UInt8]) { - FfiConverterString.write(value.walletId, into: &buf) - FfiConverterString.write(value.id, into: &buf) - FfiConverterTypePaymentType.write(value.txType, into: &buf) - FfiConverterTypePaymentState.write(value.status, into: &buf) - FfiConverterUInt64.write(value.value, into: &buf) - FfiConverterOptionUInt64.write(value.fee, into: &buf) - FfiConverterString.write(value.invoice, into: &buf) - FfiConverterString.write(value.message, into: &buf) - FfiConverterUInt64.write(value.timestamp, into: &buf) - FfiConverterOptionString.write(value.preimage, into: &buf) - FfiConverterOptionString.write(value.contact, into: &buf) - FfiConverterOptionUInt64.write(value.createdAt, into: &buf) - FfiConverterOptionUInt64.write(value.updatedAt, into: &buf) - FfiConverterOptionUInt64.write(value.seenAt, into: &buf) + public static func write(_ value: JadeDeviceInfo, into buf: inout [UInt8]) { + FfiConverterString.write(value.path, into: &buf) + FfiConverterTypeJadeTransportKind.write(value.transport, into: &buf) + FfiConverterOptionString.write(value.name, into: &buf) + FfiConverterOptionString.write(value.serialNumber, into: &buf) } } @@ -8057,127 +8331,102 @@ public struct FfiConverterTypeLightningActivity: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeLightningActivity_lift(_ buf: RustBuffer) throws -> LightningActivity { - return try FfiConverterTypeLightningActivity.lift(buf) +public func FfiConverterTypeJadeDeviceInfo_lift(_ buf: RustBuffer) throws -> JadeDeviceInfo { + return try FfiConverterTypeJadeDeviceInfo.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeLightningActivity_lower(_ value: LightningActivity) -> RustBuffer { - return FfiConverterTypeLightningActivity.lower(value) +public func FfiConverterTypeJadeDeviceInfo_lower(_ value: JadeDeviceInfo) -> RustBuffer { + return FfiConverterTypeJadeDeviceInfo.lower(value) } -public struct LightningInvoice { - public var bolt11: String - public var paymentHash: Data - public var amountSatoshis: UInt64 - public var timestampSeconds: UInt64 - public var expirySeconds: UInt64 - public var isExpired: Bool - public var description: String? - public var networkType: NetworkType - public var payeeNodeId: Data? +/** + * A device the native layer discovered. + */ +public struct JadeNativeDevice { + /** + * Transport specific address: a BLE identifier or a serial device path. + */ + public var path: String + public var transport: JadeTransportKind + /** + * Advertised or descriptor name, for example "Jade C0FFEE". + */ + public var name: String? + public var serialNumber: String? // Default memberwise initializers are never public by default, so we // declare one manually. - public init(bolt11: String, paymentHash: Data, amountSatoshis: UInt64, timestampSeconds: UInt64, expirySeconds: UInt64, isExpired: Bool, description: String?, networkType: NetworkType, payeeNodeId: Data?) { - self.bolt11 = bolt11 - self.paymentHash = paymentHash - self.amountSatoshis = amountSatoshis - self.timestampSeconds = timestampSeconds - self.expirySeconds = expirySeconds - self.isExpired = isExpired - self.description = description - self.networkType = networkType - self.payeeNodeId = payeeNodeId + public init( + /** + * Transport specific address: a BLE identifier or a serial device path. + */path: String, transport: JadeTransportKind, + /** + * Advertised or descriptor name, for example "Jade C0FFEE". + */name: String?, serialNumber: String?) { + self.path = path + self.transport = transport + self.name = name + self.serialNumber = serialNumber } } #if compiler(>=6) -extension LightningInvoice: Sendable {} +extension JadeNativeDevice: Sendable {} #endif -extension LightningInvoice: Equatable, Hashable { - public static func ==(lhs: LightningInvoice, rhs: LightningInvoice) -> Bool { - if lhs.bolt11 != rhs.bolt11 { - return false - } - if lhs.paymentHash != rhs.paymentHash { - return false - } - if lhs.amountSatoshis != rhs.amountSatoshis { - return false - } - if lhs.timestampSeconds != rhs.timestampSeconds { - return false - } - if lhs.expirySeconds != rhs.expirySeconds { - return false - } - if lhs.isExpired != rhs.isExpired { +extension JadeNativeDevice: Equatable, Hashable { + public static func ==(lhs: JadeNativeDevice, rhs: JadeNativeDevice) -> Bool { + if lhs.path != rhs.path { return false } - if lhs.description != rhs.description { + if lhs.transport != rhs.transport { return false } - if lhs.networkType != rhs.networkType { + if lhs.name != rhs.name { return false } - if lhs.payeeNodeId != rhs.payeeNodeId { + if lhs.serialNumber != rhs.serialNumber { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(bolt11) - hasher.combine(paymentHash) - hasher.combine(amountSatoshis) - hasher.combine(timestampSeconds) - hasher.combine(expirySeconds) - hasher.combine(isExpired) - hasher.combine(description) - hasher.combine(networkType) - hasher.combine(payeeNodeId) + hasher.combine(path) + hasher.combine(transport) + hasher.combine(name) + hasher.combine(serialNumber) } } -extension LightningInvoice: Codable {} +extension JadeNativeDevice: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeLightningInvoice: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> LightningInvoice { +public struct FfiConverterTypeJadeNativeDevice: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> JadeNativeDevice { return - try LightningInvoice( - bolt11: FfiConverterString.read(from: &buf), - paymentHash: FfiConverterData.read(from: &buf), - amountSatoshis: FfiConverterUInt64.read(from: &buf), - timestampSeconds: FfiConverterUInt64.read(from: &buf), - expirySeconds: FfiConverterUInt64.read(from: &buf), - isExpired: FfiConverterBool.read(from: &buf), - description: FfiConverterOptionString.read(from: &buf), - networkType: FfiConverterTypeNetworkType.read(from: &buf), - payeeNodeId: FfiConverterOptionData.read(from: &buf) + try JadeNativeDevice( + path: FfiConverterString.read(from: &buf), + transport: FfiConverterTypeJadeTransportKind.read(from: &buf), + name: FfiConverterOptionString.read(from: &buf), + serialNumber: FfiConverterOptionString.read(from: &buf) ) } - public static func write(_ value: LightningInvoice, into buf: inout [UInt8]) { - FfiConverterString.write(value.bolt11, into: &buf) - FfiConverterData.write(value.paymentHash, into: &buf) - FfiConverterUInt64.write(value.amountSatoshis, into: &buf) - FfiConverterUInt64.write(value.timestampSeconds, into: &buf) - FfiConverterUInt64.write(value.expirySeconds, into: &buf) - FfiConverterBool.write(value.isExpired, into: &buf) - FfiConverterOptionString.write(value.description, into: &buf) - FfiConverterTypeNetworkType.write(value.networkType, into: &buf) - FfiConverterOptionData.write(value.payeeNodeId, into: &buf) + public static func write(_ value: JadeNativeDevice, into buf: inout [UInt8]) { + FfiConverterString.write(value.path, into: &buf) + FfiConverterTypeJadeTransportKind.write(value.transport, into: &buf) + FfiConverterOptionString.write(value.name, into: &buf) + FfiConverterOptionString.write(value.serialNumber, into: &buf) } } @@ -8185,79 +8434,79 @@ public struct FfiConverterTypeLightningInvoice: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeLightningInvoice_lift(_ buf: RustBuffer) throws -> LightningInvoice { - return try FfiConverterTypeLightningInvoice.lift(buf) +public func FfiConverterTypeJadeNativeDevice_lift(_ buf: RustBuffer) throws -> JadeNativeDevice { + return try FfiConverterTypeJadeNativeDevice.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeLightningInvoice_lower(_ value: LightningInvoice) -> RustBuffer { - return FfiConverterTypeLightningInvoice.lower(value) +public func FfiConverterTypeJadeNativeDevice_lower(_ value: JadeNativeDevice) -> RustBuffer { + return FfiConverterTypeJadeNativeDevice.lower(value) } -public struct LnurlAddressData { - public var uri: String - public var domain: String - public var username: String +public struct JadeSignedMessage { + public var signature: String + public var address: String + public var derivationPath: String // Default memberwise initializers are never public by default, so we // declare one manually. - public init(uri: String, domain: String, username: String) { - self.uri = uri - self.domain = domain - self.username = username + public init(signature: String, address: String, derivationPath: String) { + self.signature = signature + self.address = address + self.derivationPath = derivationPath } } #if compiler(>=6) -extension LnurlAddressData: Sendable {} +extension JadeSignedMessage: Sendable {} #endif -extension LnurlAddressData: Equatable, Hashable { - public static func ==(lhs: LnurlAddressData, rhs: LnurlAddressData) -> Bool { - if lhs.uri != rhs.uri { +extension JadeSignedMessage: Equatable, Hashable { + public static func ==(lhs: JadeSignedMessage, rhs: JadeSignedMessage) -> Bool { + if lhs.signature != rhs.signature { return false } - if lhs.domain != rhs.domain { + if lhs.address != rhs.address { return false } - if lhs.username != rhs.username { + if lhs.derivationPath != rhs.derivationPath { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(uri) - hasher.combine(domain) - hasher.combine(username) + hasher.combine(signature) + hasher.combine(address) + hasher.combine(derivationPath) } } -extension LnurlAddressData: Codable {} +extension JadeSignedMessage: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeLnurlAddressData: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> LnurlAddressData { +public struct FfiConverterTypeJadeSignedMessage: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> JadeSignedMessage { return - try LnurlAddressData( - uri: FfiConverterString.read(from: &buf), - domain: FfiConverterString.read(from: &buf), - username: FfiConverterString.read(from: &buf) + try JadeSignedMessage( + signature: FfiConverterString.read(from: &buf), + address: FfiConverterString.read(from: &buf), + derivationPath: FfiConverterString.read(from: &buf) ) } - public static func write(_ value: LnurlAddressData, into buf: inout [UInt8]) { - FfiConverterString.write(value.uri, into: &buf) - FfiConverterString.write(value.domain, into: &buf) - FfiConverterString.write(value.username, into: &buf) + public static func write(_ value: JadeSignedMessage, into buf: inout [UInt8]) { + FfiConverterString.write(value.signature, into: &buf) + FfiConverterString.write(value.address, into: &buf) + FfiConverterString.write(value.derivationPath, into: &buf) } } @@ -8265,87 +8514,104 @@ public struct FfiConverterTypeLnurlAddressData: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeLnurlAddressData_lift(_ buf: RustBuffer) throws -> LnurlAddressData { - return try FfiConverterTypeLnurlAddressData.lift(buf) +public func FfiConverterTypeJadeSignedMessage_lift(_ buf: RustBuffer) throws -> JadeSignedMessage { + return try FfiConverterTypeJadeSignedMessage.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeLnurlAddressData_lower(_ value: LnurlAddressData) -> RustBuffer { - return FfiConverterTypeLnurlAddressData.lower(value) +public func FfiConverterTypeJadeSignedMessage_lower(_ value: JadeSignedMessage) -> RustBuffer { + return FfiConverterTypeJadeSignedMessage.lower(value) } -public struct LnurlAuthData { - public var uri: String - public var tag: String - public var k1: String - public var domain: String +/** + * Outcome of a read. + */ +public struct JadeTransportReadResult { + public var success: Bool + /** + * Bytes read. Success with an empty vector means nothing has arrived yet, + * which is the normal case while the user is deciding on the device. + */ + public var data: Data + /** + * Empty on success. + */ + public var error: String + public var errorCode: JadeTransportErrorCode? // Default memberwise initializers are never public by default, so we // declare one manually. - public init(uri: String, tag: String, k1: String, domain: String) { - self.uri = uri - self.tag = tag - self.k1 = k1 - self.domain = domain + public init(success: Bool, + /** + * Bytes read. Success with an empty vector means nothing has arrived yet, + * which is the normal case while the user is deciding on the device. + */data: Data, + /** + * Empty on success. + */error: String, errorCode: JadeTransportErrorCode?) { + self.success = success + self.data = data + self.error = error + self.errorCode = errorCode } } #if compiler(>=6) -extension LnurlAuthData: Sendable {} +extension JadeTransportReadResult: Sendable {} #endif -extension LnurlAuthData: Equatable, Hashable { - public static func ==(lhs: LnurlAuthData, rhs: LnurlAuthData) -> Bool { - if lhs.uri != rhs.uri { +extension JadeTransportReadResult: Equatable, Hashable { + public static func ==(lhs: JadeTransportReadResult, rhs: JadeTransportReadResult) -> Bool { + if lhs.success != rhs.success { return false } - if lhs.tag != rhs.tag { + if lhs.data != rhs.data { return false } - if lhs.k1 != rhs.k1 { + if lhs.error != rhs.error { return false } - if lhs.domain != rhs.domain { + if lhs.errorCode != rhs.errorCode { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(uri) - hasher.combine(tag) - hasher.combine(k1) - hasher.combine(domain) + hasher.combine(success) + hasher.combine(data) + hasher.combine(error) + hasher.combine(errorCode) } } -extension LnurlAuthData: Codable {} +extension JadeTransportReadResult: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeLnurlAuthData: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> LnurlAuthData { +public struct FfiConverterTypeJadeTransportReadResult: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> JadeTransportReadResult { return - try LnurlAuthData( - uri: FfiConverterString.read(from: &buf), - tag: FfiConverterString.read(from: &buf), - k1: FfiConverterString.read(from: &buf), - domain: FfiConverterString.read(from: &buf) + try JadeTransportReadResult( + success: FfiConverterBool.read(from: &buf), + data: FfiConverterData.read(from: &buf), + error: FfiConverterString.read(from: &buf), + errorCode: FfiConverterOptionTypeJadeTransportErrorCode.read(from: &buf) ) } - public static func write(_ value: LnurlAuthData, into buf: inout [UInt8]) { - FfiConverterString.write(value.uri, into: &buf) - FfiConverterString.write(value.tag, into: &buf) - FfiConverterString.write(value.k1, into: &buf) - FfiConverterString.write(value.domain, into: &buf) + public static func write(_ value: JadeTransportReadResult, into buf: inout [UInt8]) { + FfiConverterBool.write(value.success, into: &buf) + FfiConverterData.write(value.data, into: &buf) + FfiConverterString.write(value.error, into: &buf) + FfiConverterOptionTypeJadeTransportErrorCode.write(value.errorCode, into: &buf) } } @@ -8353,87 +8619,88 @@ public struct FfiConverterTypeLnurlAuthData: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeLnurlAuthData_lift(_ buf: RustBuffer) throws -> LnurlAuthData { - return try FfiConverterTypeLnurlAuthData.lift(buf) +public func FfiConverterTypeJadeTransportReadResult_lift(_ buf: RustBuffer) throws -> JadeTransportReadResult { + return try FfiConverterTypeJadeTransportReadResult.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeLnurlAuthData_lower(_ value: LnurlAuthData) -> RustBuffer { - return FfiConverterTypeLnurlAuthData.lower(value) +public func FfiConverterTypeJadeTransportReadResult_lower(_ value: JadeTransportReadResult) -> RustBuffer { + return FfiConverterTypeJadeTransportReadResult.lower(value) } -public struct LnurlChannelData { - public var uri: String - public var callback: String - public var k1: String - public var tag: String +/** + * Outcome of an operation that returns no data. + */ +public struct JadeTransportResult { + public var success: Bool + /** + * Empty on success. + */ + public var error: String + public var errorCode: JadeTransportErrorCode? // Default memberwise initializers are never public by default, so we // declare one manually. - public init(uri: String, callback: String, k1: String, tag: String) { - self.uri = uri - self.callback = callback - self.k1 = k1 - self.tag = tag + public init(success: Bool, + /** + * Empty on success. + */error: String, errorCode: JadeTransportErrorCode?) { + self.success = success + self.error = error + self.errorCode = errorCode } } #if compiler(>=6) -extension LnurlChannelData: Sendable {} +extension JadeTransportResult: Sendable {} #endif -extension LnurlChannelData: Equatable, Hashable { - public static func ==(lhs: LnurlChannelData, rhs: LnurlChannelData) -> Bool { - if lhs.uri != rhs.uri { - return false - } - if lhs.callback != rhs.callback { +extension JadeTransportResult: Equatable, Hashable { + public static func ==(lhs: JadeTransportResult, rhs: JadeTransportResult) -> Bool { + if lhs.success != rhs.success { return false } - if lhs.k1 != rhs.k1 { + if lhs.error != rhs.error { return false } - if lhs.tag != rhs.tag { + if lhs.errorCode != rhs.errorCode { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(uri) - hasher.combine(callback) - hasher.combine(k1) - hasher.combine(tag) + hasher.combine(success) + hasher.combine(error) + hasher.combine(errorCode) } } -extension LnurlChannelData: Codable {} +extension JadeTransportResult: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeLnurlChannelData: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> LnurlChannelData { +public struct FfiConverterTypeJadeTransportResult: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> JadeTransportResult { return - try LnurlChannelData( - uri: FfiConverterString.read(from: &buf), - callback: FfiConverterString.read(from: &buf), - k1: FfiConverterString.read(from: &buf), - tag: FfiConverterString.read(from: &buf) + try JadeTransportResult( + success: FfiConverterBool.read(from: &buf), + error: FfiConverterString.read(from: &buf), + errorCode: FfiConverterOptionTypeJadeTransportErrorCode.read(from: &buf) ) } - public static func write(_ value: LnurlChannelData, into buf: inout [UInt8]) { - FfiConverterString.write(value.uri, into: &buf) - FfiConverterString.write(value.callback, into: &buf) - FfiConverterString.write(value.k1, into: &buf) - FfiConverterString.write(value.tag, into: &buf) + public static func write(_ value: JadeTransportResult, into buf: inout [UInt8]) { + FfiConverterBool.write(value.success, into: &buf) + FfiConverterString.write(value.error, into: &buf) + FfiConverterOptionTypeJadeTransportErrorCode.write(value.errorCode, into: &buf) } } @@ -8441,119 +8708,151 @@ public struct FfiConverterTypeLnurlChannelData: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeLnurlChannelData_lift(_ buf: RustBuffer) throws -> LnurlChannelData { - return try FfiConverterTypeLnurlChannelData.lift(buf) +public func FfiConverterTypeJadeTransportResult_lift(_ buf: RustBuffer) throws -> JadeTransportResult { + return try FfiConverterTypeJadeTransportResult.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeLnurlChannelData_lower(_ value: LnurlChannelData) -> RustBuffer { - return FfiConverterTypeLnurlChannelData.lower(value) +public func FfiConverterTypeJadeTransportResult_lower(_ value: JadeTransportResult) -> RustBuffer { + return FfiConverterTypeJadeTransportResult.lower(value) } -public struct LnurlPayData { - public var uri: String - public var callback: String - public var minSendable: UInt64 - public var maxSendable: UInt64 - public var metadataStr: String - public var commentAllowed: UInt32? - public var allowsNostr: Bool - public var nostrPubkey: Data? +public struct JadeVersionInfo { + public var jadeVersion: String + public var jadeState: JadeState + public var jadeNetworks: String? + public var jadeHasPin: Bool? + public var boardType: String? + public var jadeConfig: String? + public var jadeFeatures: String? + public var idfVersion: String? + public var chipFeatures: String? + public var efuseMac: String? + public var batteryStatus: UInt32? + public var jadeOtaMaxChunk: UInt32? // Default memberwise initializers are never public by default, so we // declare one manually. - public init(uri: String, callback: String, minSendable: UInt64, maxSendable: UInt64, metadataStr: String, commentAllowed: UInt32?, allowsNostr: Bool, nostrPubkey: Data?) { - self.uri = uri - self.callback = callback - self.minSendable = minSendable - self.maxSendable = maxSendable - self.metadataStr = metadataStr - self.commentAllowed = commentAllowed - self.allowsNostr = allowsNostr - self.nostrPubkey = nostrPubkey + public init(jadeVersion: String, jadeState: JadeState, jadeNetworks: String?, jadeHasPin: Bool?, boardType: String?, jadeConfig: String?, jadeFeatures: String?, idfVersion: String?, chipFeatures: String?, efuseMac: String?, batteryStatus: UInt32?, jadeOtaMaxChunk: UInt32?) { + self.jadeVersion = jadeVersion + self.jadeState = jadeState + self.jadeNetworks = jadeNetworks + self.jadeHasPin = jadeHasPin + self.boardType = boardType + self.jadeConfig = jadeConfig + self.jadeFeatures = jadeFeatures + self.idfVersion = idfVersion + self.chipFeatures = chipFeatures + self.efuseMac = efuseMac + self.batteryStatus = batteryStatus + self.jadeOtaMaxChunk = jadeOtaMaxChunk } } #if compiler(>=6) -extension LnurlPayData: Sendable {} +extension JadeVersionInfo: Sendable {} #endif -extension LnurlPayData: Equatable, Hashable { - public static func ==(lhs: LnurlPayData, rhs: LnurlPayData) -> Bool { - if lhs.uri != rhs.uri { +extension JadeVersionInfo: Equatable, Hashable { + public static func ==(lhs: JadeVersionInfo, rhs: JadeVersionInfo) -> Bool { + if lhs.jadeVersion != rhs.jadeVersion { return false } - if lhs.callback != rhs.callback { + if lhs.jadeState != rhs.jadeState { return false } - if lhs.minSendable != rhs.minSendable { + if lhs.jadeNetworks != rhs.jadeNetworks { return false } - if lhs.maxSendable != rhs.maxSendable { + if lhs.jadeHasPin != rhs.jadeHasPin { return false } - if lhs.metadataStr != rhs.metadataStr { + if lhs.boardType != rhs.boardType { return false } - if lhs.commentAllowed != rhs.commentAllowed { + if lhs.jadeConfig != rhs.jadeConfig { return false } - if lhs.allowsNostr != rhs.allowsNostr { + if lhs.jadeFeatures != rhs.jadeFeatures { return false } - if lhs.nostrPubkey != rhs.nostrPubkey { + if lhs.idfVersion != rhs.idfVersion { + return false + } + if lhs.chipFeatures != rhs.chipFeatures { + return false + } + if lhs.efuseMac != rhs.efuseMac { + return false + } + if lhs.batteryStatus != rhs.batteryStatus { + return false + } + if lhs.jadeOtaMaxChunk != rhs.jadeOtaMaxChunk { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(uri) - hasher.combine(callback) - hasher.combine(minSendable) - hasher.combine(maxSendable) - hasher.combine(metadataStr) - hasher.combine(commentAllowed) - hasher.combine(allowsNostr) - hasher.combine(nostrPubkey) + hasher.combine(jadeVersion) + hasher.combine(jadeState) + hasher.combine(jadeNetworks) + hasher.combine(jadeHasPin) + hasher.combine(boardType) + hasher.combine(jadeConfig) + hasher.combine(jadeFeatures) + hasher.combine(idfVersion) + hasher.combine(chipFeatures) + hasher.combine(efuseMac) + hasher.combine(batteryStatus) + hasher.combine(jadeOtaMaxChunk) } } -extension LnurlPayData: Codable {} +extension JadeVersionInfo: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeLnurlPayData: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> LnurlPayData { +public struct FfiConverterTypeJadeVersionInfo: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> JadeVersionInfo { return - try LnurlPayData( - uri: FfiConverterString.read(from: &buf), - callback: FfiConverterString.read(from: &buf), - minSendable: FfiConverterUInt64.read(from: &buf), - maxSendable: FfiConverterUInt64.read(from: &buf), - metadataStr: FfiConverterString.read(from: &buf), - commentAllowed: FfiConverterOptionUInt32.read(from: &buf), - allowsNostr: FfiConverterBool.read(from: &buf), - nostrPubkey: FfiConverterOptionData.read(from: &buf) + try JadeVersionInfo( + jadeVersion: FfiConverterString.read(from: &buf), + jadeState: FfiConverterTypeJadeState.read(from: &buf), + jadeNetworks: FfiConverterOptionString.read(from: &buf), + jadeHasPin: FfiConverterOptionBool.read(from: &buf), + boardType: FfiConverterOptionString.read(from: &buf), + jadeConfig: FfiConverterOptionString.read(from: &buf), + jadeFeatures: FfiConverterOptionString.read(from: &buf), + idfVersion: FfiConverterOptionString.read(from: &buf), + chipFeatures: FfiConverterOptionString.read(from: &buf), + efuseMac: FfiConverterOptionString.read(from: &buf), + batteryStatus: FfiConverterOptionUInt32.read(from: &buf), + jadeOtaMaxChunk: FfiConverterOptionUInt32.read(from: &buf) ) } - public static func write(_ value: LnurlPayData, into buf: inout [UInt8]) { - FfiConverterString.write(value.uri, into: &buf) - FfiConverterString.write(value.callback, into: &buf) - FfiConverterUInt64.write(value.minSendable, into: &buf) - FfiConverterUInt64.write(value.maxSendable, into: &buf) - FfiConverterString.write(value.metadataStr, into: &buf) - FfiConverterOptionUInt32.write(value.commentAllowed, into: &buf) - FfiConverterBool.write(value.allowsNostr, into: &buf) - FfiConverterOptionData.write(value.nostrPubkey, into: &buf) + public static func write(_ value: JadeVersionInfo, into buf: inout [UInt8]) { + FfiConverterString.write(value.jadeVersion, into: &buf) + FfiConverterTypeJadeState.write(value.jadeState, into: &buf) + FfiConverterOptionString.write(value.jadeNetworks, into: &buf) + FfiConverterOptionBool.write(value.jadeHasPin, into: &buf) + FfiConverterOptionString.write(value.boardType, into: &buf) + FfiConverterOptionString.write(value.jadeConfig, into: &buf) + FfiConverterOptionString.write(value.jadeFeatures, into: &buf) + FfiConverterOptionString.write(value.idfVersion, into: &buf) + FfiConverterOptionString.write(value.chipFeatures, into: &buf) + FfiConverterOptionString.write(value.efuseMac, into: &buf) + FfiConverterOptionUInt32.write(value.batteryStatus, into: &buf) + FfiConverterOptionUInt32.write(value.jadeOtaMaxChunk, into: &buf) } } @@ -8561,111 +8860,79 @@ public struct FfiConverterTypeLnurlPayData: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeLnurlPayData_lift(_ buf: RustBuffer) throws -> LnurlPayData { - return try FfiConverterTypeLnurlPayData.lift(buf) +public func FfiConverterTypeJadeVersionInfo_lift(_ buf: RustBuffer) throws -> JadeVersionInfo { + return try FfiConverterTypeJadeVersionInfo.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeLnurlPayData_lower(_ value: LnurlPayData) -> RustBuffer { - return FfiConverterTypeLnurlPayData.lower(value) +public func FfiConverterTypeJadeVersionInfo_lower(_ value: JadeVersionInfo) -> RustBuffer { + return FfiConverterTypeJadeVersionInfo.lower(value) } -public struct LnurlWithdrawData { - public var uri: String - public var callback: String - public var k1: String - public var defaultDescription: String - public var minWithdrawable: UInt64? - public var maxWithdrawable: UInt64 - public var tag: String +public struct JadeXpubResponse { + public var xpub: String + public var derivationPath: String + public var masterFingerprint: String // Default memberwise initializers are never public by default, so we // declare one manually. - public init(uri: String, callback: String, k1: String, defaultDescription: String, minWithdrawable: UInt64?, maxWithdrawable: UInt64, tag: String) { - self.uri = uri - self.callback = callback - self.k1 = k1 - self.defaultDescription = defaultDescription - self.minWithdrawable = minWithdrawable - self.maxWithdrawable = maxWithdrawable - self.tag = tag + public init(xpub: String, derivationPath: String, masterFingerprint: String) { + self.xpub = xpub + self.derivationPath = derivationPath + self.masterFingerprint = masterFingerprint } } #if compiler(>=6) -extension LnurlWithdrawData: Sendable {} +extension JadeXpubResponse: Sendable {} #endif -extension LnurlWithdrawData: Equatable, Hashable { - public static func ==(lhs: LnurlWithdrawData, rhs: LnurlWithdrawData) -> Bool { - if lhs.uri != rhs.uri { - return false - } - if lhs.callback != rhs.callback { - return false - } - if lhs.k1 != rhs.k1 { - return false - } - if lhs.defaultDescription != rhs.defaultDescription { - return false - } - if lhs.minWithdrawable != rhs.minWithdrawable { +extension JadeXpubResponse: Equatable, Hashable { + public static func ==(lhs: JadeXpubResponse, rhs: JadeXpubResponse) -> Bool { + if lhs.xpub != rhs.xpub { return false } - if lhs.maxWithdrawable != rhs.maxWithdrawable { + if lhs.derivationPath != rhs.derivationPath { return false } - if lhs.tag != rhs.tag { + if lhs.masterFingerprint != rhs.masterFingerprint { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(uri) - hasher.combine(callback) - hasher.combine(k1) - hasher.combine(defaultDescription) - hasher.combine(minWithdrawable) - hasher.combine(maxWithdrawable) - hasher.combine(tag) + hasher.combine(xpub) + hasher.combine(derivationPath) + hasher.combine(masterFingerprint) } } -extension LnurlWithdrawData: Codable {} +extension JadeXpubResponse: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeLnurlWithdrawData: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> LnurlWithdrawData { +public struct FfiConverterTypeJadeXpubResponse: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> JadeXpubResponse { return - try LnurlWithdrawData( - uri: FfiConverterString.read(from: &buf), - callback: FfiConverterString.read(from: &buf), - k1: FfiConverterString.read(from: &buf), - defaultDescription: FfiConverterString.read(from: &buf), - minWithdrawable: FfiConverterOptionUInt64.read(from: &buf), - maxWithdrawable: FfiConverterUInt64.read(from: &buf), - tag: FfiConverterString.read(from: &buf) + try JadeXpubResponse( + xpub: FfiConverterString.read(from: &buf), + derivationPath: FfiConverterString.read(from: &buf), + masterFingerprint: FfiConverterString.read(from: &buf) ) } - public static func write(_ value: LnurlWithdrawData, into buf: inout [UInt8]) { - FfiConverterString.write(value.uri, into: &buf) - FfiConverterString.write(value.callback, into: &buf) - FfiConverterString.write(value.k1, into: &buf) - FfiConverterString.write(value.defaultDescription, into: &buf) - FfiConverterOptionUInt64.write(value.minWithdrawable, into: &buf) - FfiConverterUInt64.write(value.maxWithdrawable, into: &buf) - FfiConverterString.write(value.tag, into: &buf) + public static func write(_ value: JadeXpubResponse, into buf: inout [UInt8]) { + FfiConverterString.write(value.xpub, into: &buf) + FfiConverterString.write(value.derivationPath, into: &buf) + FfiConverterString.write(value.masterFingerprint, into: &buf) } } @@ -8673,128 +8940,83 @@ public struct FfiConverterTypeLnurlWithdrawData: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeLnurlWithdrawData_lift(_ buf: RustBuffer) throws -> LnurlWithdrawData { - return try FfiConverterTypeLnurlWithdrawData.lift(buf) +public func FfiConverterTypeJadeXpubResponse_lift(_ buf: RustBuffer) throws -> JadeXpubResponse { + return try FfiConverterTypeJadeXpubResponse.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeLnurlWithdrawData_lower(_ value: LnurlWithdrawData) -> RustBuffer { - return FfiConverterTypeLnurlWithdrawData.lower(value) +public func FfiConverterTypeJadeXpubResponse_lower(_ value: JadeXpubResponse) -> RustBuffer { + return FfiConverterTypeJadeXpubResponse.lower(value) } -/** - * Native device information returned from enumeration - */ -public struct NativeDeviceInfo { - /** - * Unique path/identifier for this device - */ - public var path: String - /** - * Transport type: "usb" or "bluetooth" - */ - public var transportType: String - /** - * Optional device name (from BLE advertisement or USB descriptor) - */ - public var name: String? +public struct LegacyRnCloseRecoveryScanResult { /** - * USB Vendor ID (for USB devices) + * Total balance found in legacy RN P2WPKH close outputs (in satoshis). */ - public var vendorId: UInt16? + public var totalAmount: UInt64 /** - * USB Product ID (for USB devices) + * Number of P2WPKH outputs found. */ - public var productId: UInt16? + public var outputsCount: UInt32 // Default memberwise initializers are never public by default, so we // declare one manually. public init( /** - * Unique path/identifier for this device - */path: String, + * Total balance found in legacy RN P2WPKH close outputs (in satoshis). + */totalAmount: UInt64, /** - * Transport type: "usb" or "bluetooth" - */transportType: String, - /** - * Optional device name (from BLE advertisement or USB descriptor) - */name: String?, - /** - * USB Vendor ID (for USB devices) - */vendorId: UInt16?, - /** - * USB Product ID (for USB devices) - */productId: UInt16?) { - self.path = path - self.transportType = transportType - self.name = name - self.vendorId = vendorId - self.productId = productId + * Number of P2WPKH outputs found. + */outputsCount: UInt32) { + self.totalAmount = totalAmount + self.outputsCount = outputsCount } } #if compiler(>=6) -extension NativeDeviceInfo: Sendable {} +extension LegacyRnCloseRecoveryScanResult: Sendable {} #endif -extension NativeDeviceInfo: Equatable, Hashable { - public static func ==(lhs: NativeDeviceInfo, rhs: NativeDeviceInfo) -> Bool { - if lhs.path != rhs.path { - return false - } - if lhs.transportType != rhs.transportType { - return false - } - if lhs.name != rhs.name { - return false - } - if lhs.vendorId != rhs.vendorId { +extension LegacyRnCloseRecoveryScanResult: Equatable, Hashable { + public static func ==(lhs: LegacyRnCloseRecoveryScanResult, rhs: LegacyRnCloseRecoveryScanResult) -> Bool { + if lhs.totalAmount != rhs.totalAmount { return false } - if lhs.productId != rhs.productId { + if lhs.outputsCount != rhs.outputsCount { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(path) - hasher.combine(transportType) - hasher.combine(name) - hasher.combine(vendorId) - hasher.combine(productId) + hasher.combine(totalAmount) + hasher.combine(outputsCount) } } -extension NativeDeviceInfo: Codable {} +extension LegacyRnCloseRecoveryScanResult: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeNativeDeviceInfo: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> NativeDeviceInfo { +public struct FfiConverterTypeLegacyRnCloseRecoveryScanResult: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> LegacyRnCloseRecoveryScanResult { return - try NativeDeviceInfo( - path: FfiConverterString.read(from: &buf), - transportType: FfiConverterString.read(from: &buf), - name: FfiConverterOptionString.read(from: &buf), - vendorId: FfiConverterOptionUInt16.read(from: &buf), - productId: FfiConverterOptionUInt16.read(from: &buf) + try LegacyRnCloseRecoveryScanResult( + totalAmount: FfiConverterUInt64.read(from: &buf), + outputsCount: FfiConverterUInt32.read(from: &buf) ) } - public static func write(_ value: NativeDeviceInfo, into buf: inout [UInt8]) { - FfiConverterString.write(value.path, into: &buf) - FfiConverterString.write(value.transportType, into: &buf) - FfiConverterOptionString.write(value.name, into: &buf) - FfiConverterOptionUInt16.write(value.vendorId, into: &buf) - FfiConverterOptionUInt16.write(value.productId, into: &buf) + public static func write(_ value: LegacyRnCloseRecoveryScanResult, into buf: inout [UInt8]) { + FfiConverterUInt64.write(value.totalAmount, into: &buf) + FfiConverterUInt32.write(value.outputsCount, into: &buf) } } @@ -8802,95 +9024,167 @@ public struct FfiConverterTypeNativeDeviceInfo: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeNativeDeviceInfo_lift(_ buf: RustBuffer) throws -> NativeDeviceInfo { - return try FfiConverterTypeNativeDeviceInfo.lift(buf) +public func FfiConverterTypeLegacyRnCloseRecoveryScanResult_lift(_ buf: RustBuffer) throws -> LegacyRnCloseRecoveryScanResult { + return try FfiConverterTypeLegacyRnCloseRecoveryScanResult.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeNativeDeviceInfo_lower(_ value: NativeDeviceInfo) -> RustBuffer { - return FfiConverterTypeNativeDeviceInfo.lower(value) +public func FfiConverterTypeLegacyRnCloseRecoveryScanResult_lower(_ value: LegacyRnCloseRecoveryScanResult) -> RustBuffer { + return FfiConverterTypeLegacyRnCloseRecoveryScanResult.lower(value) } -public struct OnChainInvoice { - public var address: String - public var amountSatoshis: UInt64 - public var label: String? - public var message: String? - public var params: [String: String]? +public struct LegacyRnCloseRecoverySweepPreview { + /** + * Fully signed raw sweep transaction hex. Broadcast only after user confirmation. + */ + public var txHex: String + /** + * Transaction id of the sweep transaction. + */ + public var txid: String + /** + * Total input amount in satoshis. + */ + public var totalAmount: UInt64 + /** + * Fee in satoshis. + */ + public var estimatedFee: UInt64 + /** + * Transaction virtual size in vbytes. + */ + public var estimatedVsize: UInt64 + /** + * Number of recovered outputs swept. + */ + public var outputsCount: UInt32 + /** + * Destination address receiving the sweep. + */ + public var destinationAddress: String + /** + * Amount sent to destination after fees. + */ + public var amountAfterFees: UInt64 // Default memberwise initializers are never public by default, so we // declare one manually. - public init(address: String, amountSatoshis: UInt64, label: String?, message: String?, params: [String: String]?) { - self.address = address - self.amountSatoshis = amountSatoshis - self.label = label - self.message = message - self.params = params + public init( + /** + * Fully signed raw sweep transaction hex. Broadcast only after user confirmation. + */txHex: String, + /** + * Transaction id of the sweep transaction. + */txid: String, + /** + * Total input amount in satoshis. + */totalAmount: UInt64, + /** + * Fee in satoshis. + */estimatedFee: UInt64, + /** + * Transaction virtual size in vbytes. + */estimatedVsize: UInt64, + /** + * Number of recovered outputs swept. + */outputsCount: UInt32, + /** + * Destination address receiving the sweep. + */destinationAddress: String, + /** + * Amount sent to destination after fees. + */amountAfterFees: UInt64) { + self.txHex = txHex + self.txid = txid + self.totalAmount = totalAmount + self.estimatedFee = estimatedFee + self.estimatedVsize = estimatedVsize + self.outputsCount = outputsCount + self.destinationAddress = destinationAddress + self.amountAfterFees = amountAfterFees } } #if compiler(>=6) -extension OnChainInvoice: Sendable {} +extension LegacyRnCloseRecoverySweepPreview: Sendable {} #endif -extension OnChainInvoice: Equatable, Hashable { - public static func ==(lhs: OnChainInvoice, rhs: OnChainInvoice) -> Bool { - if lhs.address != rhs.address { +extension LegacyRnCloseRecoverySweepPreview: Equatable, Hashable { + public static func ==(lhs: LegacyRnCloseRecoverySweepPreview, rhs: LegacyRnCloseRecoverySweepPreview) -> Bool { + if lhs.txHex != rhs.txHex { return false } - if lhs.amountSatoshis != rhs.amountSatoshis { + if lhs.txid != rhs.txid { return false } - if lhs.label != rhs.label { + if lhs.totalAmount != rhs.totalAmount { return false } - if lhs.message != rhs.message { + if lhs.estimatedFee != rhs.estimatedFee { return false } - if lhs.params != rhs.params { + if lhs.estimatedVsize != rhs.estimatedVsize { + return false + } + if lhs.outputsCount != rhs.outputsCount { + return false + } + if lhs.destinationAddress != rhs.destinationAddress { + return false + } + if lhs.amountAfterFees != rhs.amountAfterFees { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(address) - hasher.combine(amountSatoshis) - hasher.combine(label) - hasher.combine(message) - hasher.combine(params) + hasher.combine(txHex) + hasher.combine(txid) + hasher.combine(totalAmount) + hasher.combine(estimatedFee) + hasher.combine(estimatedVsize) + hasher.combine(outputsCount) + hasher.combine(destinationAddress) + hasher.combine(amountAfterFees) } } -extension OnChainInvoice: Codable {} +extension LegacyRnCloseRecoverySweepPreview: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeOnChainInvoice: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> OnChainInvoice { +public struct FfiConverterTypeLegacyRnCloseRecoverySweepPreview: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> LegacyRnCloseRecoverySweepPreview { return - try OnChainInvoice( - address: FfiConverterString.read(from: &buf), - amountSatoshis: FfiConverterUInt64.read(from: &buf), - label: FfiConverterOptionString.read(from: &buf), - message: FfiConverterOptionString.read(from: &buf), - params: FfiConverterOptionDictionaryStringString.read(from: &buf) + try LegacyRnCloseRecoverySweepPreview( + txHex: FfiConverterString.read(from: &buf), + txid: FfiConverterString.read(from: &buf), + totalAmount: FfiConverterUInt64.read(from: &buf), + estimatedFee: FfiConverterUInt64.read(from: &buf), + estimatedVsize: FfiConverterUInt64.read(from: &buf), + outputsCount: FfiConverterUInt32.read(from: &buf), + destinationAddress: FfiConverterString.read(from: &buf), + amountAfterFees: FfiConverterUInt64.read(from: &buf) ) } - public static func write(_ value: OnChainInvoice, into buf: inout [UInt8]) { - FfiConverterString.write(value.address, into: &buf) - FfiConverterUInt64.write(value.amountSatoshis, into: &buf) - FfiConverterOptionString.write(value.label, into: &buf) - FfiConverterOptionString.write(value.message, into: &buf) - FfiConverterOptionDictionaryStringString.write(value.params, into: &buf) + public static func write(_ value: LegacyRnCloseRecoverySweepPreview, into buf: inout [UInt8]) { + FfiConverterString.write(value.txHex, into: &buf) + FfiConverterString.write(value.txid, into: &buf) + FfiConverterUInt64.write(value.totalAmount, into: &buf) + FfiConverterUInt64.write(value.estimatedFee, into: &buf) + FfiConverterUInt64.write(value.estimatedVsize, into: &buf) + FfiConverterUInt32.write(value.outputsCount, into: &buf) + FfiConverterString.write(value.destinationAddress, into: &buf) + FfiConverterUInt64.write(value.amountAfterFees, into: &buf) } } @@ -8898,36 +9192,29 @@ public struct FfiConverterTypeOnChainInvoice: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeOnChainInvoice_lift(_ buf: RustBuffer) throws -> OnChainInvoice { - return try FfiConverterTypeOnChainInvoice.lift(buf) +public func FfiConverterTypeLegacyRnCloseRecoverySweepPreview_lift(_ buf: RustBuffer) throws -> LegacyRnCloseRecoverySweepPreview { + return try FfiConverterTypeLegacyRnCloseRecoverySweepPreview.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeOnChainInvoice_lower(_ value: OnChainInvoice) -> RustBuffer { - return FfiConverterTypeOnChainInvoice.lower(value) +public func FfiConverterTypeLegacyRnCloseRecoverySweepPreview_lower(_ value: LegacyRnCloseRecoverySweepPreview) -> RustBuffer { + return FfiConverterTypeLegacyRnCloseRecoverySweepPreview.lower(value) } -public struct OnchainActivity { +public struct LightningActivity { public var walletId: String public var id: String public var txType: PaymentType - public var txId: String + public var status: PaymentState public var value: UInt64 - public var fee: UInt64 - public var feeRate: UInt64 - public var address: String - public var confirmed: Bool + public var fee: UInt64? + public var invoice: String + public var message: String public var timestamp: UInt64 - public var isBoosted: Bool - public var boostTxIds: [String] - public var isTransfer: Bool - public var doesExist: Bool - public var confirmTimestamp: UInt64? - public var channelId: String? - public var transferTxId: String? + public var preimage: String? public var contact: String? public var createdAt: UInt64? public var updatedAt: UInt64? @@ -8935,24 +9222,17 @@ public struct OnchainActivity { // Default memberwise initializers are never public by default, so we // declare one manually. - public init(walletId: String, id: String, txType: PaymentType, txId: String, value: UInt64, fee: UInt64, feeRate: UInt64, address: String, confirmed: Bool, timestamp: UInt64, isBoosted: Bool, boostTxIds: [String], isTransfer: Bool, doesExist: Bool, confirmTimestamp: UInt64?, channelId: String?, transferTxId: String?, contact: String?, createdAt: UInt64?, updatedAt: UInt64?, seenAt: UInt64?) { + public init(walletId: String, id: String, txType: PaymentType, status: PaymentState, value: UInt64, fee: UInt64?, invoice: String, message: String, timestamp: UInt64, preimage: String?, contact: String?, createdAt: UInt64?, updatedAt: UInt64?, seenAt: UInt64?) { self.walletId = walletId self.id = id self.txType = txType - self.txId = txId + self.status = status self.value = value self.fee = fee - self.feeRate = feeRate - self.address = address - self.confirmed = confirmed + self.invoice = invoice + self.message = message self.timestamp = timestamp - self.isBoosted = isBoosted - self.boostTxIds = boostTxIds - self.isTransfer = isTransfer - self.doesExist = doesExist - self.confirmTimestamp = confirmTimestamp - self.channelId = channelId - self.transferTxId = transferTxId + self.preimage = preimage self.contact = contact self.createdAt = createdAt self.updatedAt = updatedAt @@ -8961,12 +9241,12 @@ public struct OnchainActivity { } #if compiler(>=6) -extension OnchainActivity: Sendable {} +extension LightningActivity: Sendable {} #endif -extension OnchainActivity: Equatable, Hashable { - public static func ==(lhs: OnchainActivity, rhs: OnchainActivity) -> Bool { +extension LightningActivity: Equatable, Hashable { + public static func ==(lhs: LightningActivity, rhs: LightningActivity) -> Bool { if lhs.walletId != rhs.walletId { return false } @@ -8976,7 +9256,7 @@ extension OnchainActivity: Equatable, Hashable { if lhs.txType != rhs.txType { return false } - if lhs.txId != rhs.txId { + if lhs.status != rhs.status { return false } if lhs.value != rhs.value { @@ -8985,37 +9265,16 @@ extension OnchainActivity: Equatable, Hashable { if lhs.fee != rhs.fee { return false } - if lhs.feeRate != rhs.feeRate { - return false - } - if lhs.address != rhs.address { + if lhs.invoice != rhs.invoice { return false } - if lhs.confirmed != rhs.confirmed { + if lhs.message != rhs.message { return false } if lhs.timestamp != rhs.timestamp { return false } - if lhs.isBoosted != rhs.isBoosted { - return false - } - if lhs.boostTxIds != rhs.boostTxIds { - return false - } - if lhs.isTransfer != rhs.isTransfer { - return false - } - if lhs.doesExist != rhs.doesExist { - return false - } - if lhs.confirmTimestamp != rhs.confirmTimestamp { - return false - } - if lhs.channelId != rhs.channelId { - return false - } - if lhs.transferTxId != rhs.transferTxId { + if lhs.preimage != rhs.preimage { return false } if lhs.contact != rhs.contact { @@ -9037,20 +9296,13 @@ extension OnchainActivity: Equatable, Hashable { hasher.combine(walletId) hasher.combine(id) hasher.combine(txType) - hasher.combine(txId) + hasher.combine(status) hasher.combine(value) hasher.combine(fee) - hasher.combine(feeRate) - hasher.combine(address) - hasher.combine(confirmed) + hasher.combine(invoice) + hasher.combine(message) hasher.combine(timestamp) - hasher.combine(isBoosted) - hasher.combine(boostTxIds) - hasher.combine(isTransfer) - hasher.combine(doesExist) - hasher.combine(confirmTimestamp) - hasher.combine(channelId) - hasher.combine(transferTxId) + hasher.combine(preimage) hasher.combine(contact) hasher.combine(createdAt) hasher.combine(updatedAt) @@ -9058,34 +9310,27 @@ extension OnchainActivity: Equatable, Hashable { } } -extension OnchainActivity: Codable {} +extension LightningActivity: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeOnchainActivity: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> OnchainActivity { +public struct FfiConverterTypeLightningActivity: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> LightningActivity { return - try OnchainActivity( + try LightningActivity( walletId: FfiConverterString.read(from: &buf), id: FfiConverterString.read(from: &buf), txType: FfiConverterTypePaymentType.read(from: &buf), - txId: FfiConverterString.read(from: &buf), + status: FfiConverterTypePaymentState.read(from: &buf), value: FfiConverterUInt64.read(from: &buf), - fee: FfiConverterUInt64.read(from: &buf), - feeRate: FfiConverterUInt64.read(from: &buf), - address: FfiConverterString.read(from: &buf), - confirmed: FfiConverterBool.read(from: &buf), + fee: FfiConverterOptionUInt64.read(from: &buf), + invoice: FfiConverterString.read(from: &buf), + message: FfiConverterString.read(from: &buf), timestamp: FfiConverterUInt64.read(from: &buf), - isBoosted: FfiConverterBool.read(from: &buf), - boostTxIds: FfiConverterSequenceString.read(from: &buf), - isTransfer: FfiConverterBool.read(from: &buf), - doesExist: FfiConverterBool.read(from: &buf), - confirmTimestamp: FfiConverterOptionUInt64.read(from: &buf), - channelId: FfiConverterOptionString.read(from: &buf), - transferTxId: FfiConverterOptionString.read(from: &buf), + preimage: FfiConverterOptionString.read(from: &buf), contact: FfiConverterOptionString.read(from: &buf), createdAt: FfiConverterOptionUInt64.read(from: &buf), updatedAt: FfiConverterOptionUInt64.read(from: &buf), @@ -9093,24 +9338,17 @@ public struct FfiConverterTypeOnchainActivity: FfiConverterRustBuffer { ) } - public static func write(_ value: OnchainActivity, into buf: inout [UInt8]) { + public static func write(_ value: LightningActivity, into buf: inout [UInt8]) { FfiConverterString.write(value.walletId, into: &buf) FfiConverterString.write(value.id, into: &buf) FfiConverterTypePaymentType.write(value.txType, into: &buf) - FfiConverterString.write(value.txId, into: &buf) + FfiConverterTypePaymentState.write(value.status, into: &buf) FfiConverterUInt64.write(value.value, into: &buf) - FfiConverterUInt64.write(value.fee, into: &buf) - FfiConverterUInt64.write(value.feeRate, into: &buf) - FfiConverterString.write(value.address, into: &buf) - FfiConverterBool.write(value.confirmed, into: &buf) + FfiConverterOptionUInt64.write(value.fee, into: &buf) + FfiConverterString.write(value.invoice, into: &buf) + FfiConverterString.write(value.message, into: &buf) FfiConverterUInt64.write(value.timestamp, into: &buf) - FfiConverterBool.write(value.isBoosted, into: &buf) - FfiConverterSequenceString.write(value.boostTxIds, into: &buf) - FfiConverterBool.write(value.isTransfer, into: &buf) - FfiConverterBool.write(value.doesExist, into: &buf) - FfiConverterOptionUInt64.write(value.confirmTimestamp, into: &buf) - FfiConverterOptionString.write(value.channelId, into: &buf) - FfiConverterOptionString.write(value.transferTxId, into: &buf) + FfiConverterOptionString.write(value.preimage, into: &buf) FfiConverterOptionString.write(value.contact, into: &buf) FfiConverterOptionUInt64.write(value.createdAt, into: &buf) FfiConverterOptionUInt64.write(value.updatedAt, into: &buf) @@ -9122,94 +9360,127 @@ public struct FfiConverterTypeOnchainActivity: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeOnchainActivity_lift(_ buf: RustBuffer) throws -> OnchainActivity { - return try FfiConverterTypeOnchainActivity.lift(buf) +public func FfiConverterTypeLightningActivity_lift(_ buf: RustBuffer) throws -> LightningActivity { + return try FfiConverterTypeLightningActivity.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeOnchainActivity_lower(_ value: OnchainActivity) -> RustBuffer { - return FfiConverterTypeOnchainActivity.lower(value) +public func FfiConverterTypeLightningActivity_lower(_ value: LightningActivity) -> RustBuffer { + return FfiConverterTypeLightningActivity.lower(value) } -/** - * One single-signature account in Passport's generic JSON export. - */ -public struct PassportAccount { - public var accountType: AccountType - /** - * Standard xpub/tpub encoding used by Passport's export. - */ - public var xpub: String - /** - * Account-level BIP32 path, such as `m/84'/0'/0'`. - */ - public var derivationPath: String +public struct LightningInvoice { + public var bolt11: String + public var paymentHash: Data + public var amountSatoshis: UInt64 + public var timestampSeconds: UInt64 + public var expirySeconds: UInt64 + public var isExpired: Bool + public var description: String? + public var networkType: NetworkType + public var payeeNodeId: Data? // Default memberwise initializers are never public by default, so we // declare one manually. - public init(accountType: AccountType, - /** - * Standard xpub/tpub encoding used by Passport's export. - */xpub: String, - /** - * Account-level BIP32 path, such as `m/84'/0'/0'`. - */derivationPath: String) { - self.accountType = accountType - self.xpub = xpub - self.derivationPath = derivationPath + public init(bolt11: String, paymentHash: Data, amountSatoshis: UInt64, timestampSeconds: UInt64, expirySeconds: UInt64, isExpired: Bool, description: String?, networkType: NetworkType, payeeNodeId: Data?) { + self.bolt11 = bolt11 + self.paymentHash = paymentHash + self.amountSatoshis = amountSatoshis + self.timestampSeconds = timestampSeconds + self.expirySeconds = expirySeconds + self.isExpired = isExpired + self.description = description + self.networkType = networkType + self.payeeNodeId = payeeNodeId } } #if compiler(>=6) -extension PassportAccount: Sendable {} +extension LightningInvoice: Sendable {} #endif -extension PassportAccount: Equatable, Hashable { - public static func ==(lhs: PassportAccount, rhs: PassportAccount) -> Bool { - if lhs.accountType != rhs.accountType { +extension LightningInvoice: Equatable, Hashable { + public static func ==(lhs: LightningInvoice, rhs: LightningInvoice) -> Bool { + if lhs.bolt11 != rhs.bolt11 { return false } - if lhs.xpub != rhs.xpub { + if lhs.paymentHash != rhs.paymentHash { return false } - if lhs.derivationPath != rhs.derivationPath { + if lhs.amountSatoshis != rhs.amountSatoshis { + return false + } + if lhs.timestampSeconds != rhs.timestampSeconds { + return false + } + if lhs.expirySeconds != rhs.expirySeconds { + return false + } + if lhs.isExpired != rhs.isExpired { + return false + } + if lhs.description != rhs.description { + return false + } + if lhs.networkType != rhs.networkType { + return false + } + if lhs.payeeNodeId != rhs.payeeNodeId { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(accountType) - hasher.combine(xpub) - hasher.combine(derivationPath) + hasher.combine(bolt11) + hasher.combine(paymentHash) + hasher.combine(amountSatoshis) + hasher.combine(timestampSeconds) + hasher.combine(expirySeconds) + hasher.combine(isExpired) + hasher.combine(description) + hasher.combine(networkType) + hasher.combine(payeeNodeId) } } -extension PassportAccount: Codable {} +extension LightningInvoice: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypePassportAccount: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> PassportAccount { +public struct FfiConverterTypeLightningInvoice: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> LightningInvoice { return - try PassportAccount( - accountType: FfiConverterTypeAccountType.read(from: &buf), - xpub: FfiConverterString.read(from: &buf), - derivationPath: FfiConverterString.read(from: &buf) + try LightningInvoice( + bolt11: FfiConverterString.read(from: &buf), + paymentHash: FfiConverterData.read(from: &buf), + amountSatoshis: FfiConverterUInt64.read(from: &buf), + timestampSeconds: FfiConverterUInt64.read(from: &buf), + expirySeconds: FfiConverterUInt64.read(from: &buf), + isExpired: FfiConverterBool.read(from: &buf), + description: FfiConverterOptionString.read(from: &buf), + networkType: FfiConverterTypeNetworkType.read(from: &buf), + payeeNodeId: FfiConverterOptionData.read(from: &buf) ) } - public static func write(_ value: PassportAccount, into buf: inout [UInt8]) { - FfiConverterTypeAccountType.write(value.accountType, into: &buf) - FfiConverterString.write(value.xpub, into: &buf) - FfiConverterString.write(value.derivationPath, into: &buf) + public static func write(_ value: LightningInvoice, into buf: inout [UInt8]) { + FfiConverterString.write(value.bolt11, into: &buf) + FfiConverterData.write(value.paymentHash, into: &buf) + FfiConverterUInt64.write(value.amountSatoshis, into: &buf) + FfiConverterUInt64.write(value.timestampSeconds, into: &buf) + FfiConverterUInt64.write(value.expirySeconds, into: &buf) + FfiConverterBool.write(value.isExpired, into: &buf) + FfiConverterOptionString.write(value.description, into: &buf) + FfiConverterTypeNetworkType.write(value.networkType, into: &buf) + FfiConverterOptionData.write(value.payeeNodeId, into: &buf) } } @@ -9217,88 +9488,79 @@ public struct FfiConverterTypePassportAccount: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypePassportAccount_lift(_ buf: RustBuffer) throws -> PassportAccount { - return try FfiConverterTypePassportAccount.lift(buf) +public func FfiConverterTypeLightningInvoice_lift(_ buf: RustBuffer) throws -> LightningInvoice { + return try FfiConverterTypeLightningInvoice.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypePassportAccount_lower(_ value: PassportAccount) -> RustBuffer { - return FfiConverterTypePassportAccount.lower(value) +public func FfiConverterTypeLightningInvoice_lower(_ value: LightningInvoice) -> RustBuffer { + return FfiConverterTypeLightningInvoice.lower(value) } -/** - * The single-signature accounts exported by Passport for one account index. - */ -public struct PassportAccountExport { - /** - * Root fingerprint used in descriptors and PSBT key origins. - */ - public var masterFingerprint: String - public var accountIndex: UInt32 - public var accounts: [PassportAccount] - +public struct LnurlAddressData { + public var uri: String + public var domain: String + public var username: String + // Default memberwise initializers are never public by default, so we // declare one manually. - public init( - /** - * Root fingerprint used in descriptors and PSBT key origins. - */masterFingerprint: String, accountIndex: UInt32, accounts: [PassportAccount]) { - self.masterFingerprint = masterFingerprint - self.accountIndex = accountIndex - self.accounts = accounts + public init(uri: String, domain: String, username: String) { + self.uri = uri + self.domain = domain + self.username = username } } #if compiler(>=6) -extension PassportAccountExport: Sendable {} +extension LnurlAddressData: Sendable {} #endif -extension PassportAccountExport: Equatable, Hashable { - public static func ==(lhs: PassportAccountExport, rhs: PassportAccountExport) -> Bool { - if lhs.masterFingerprint != rhs.masterFingerprint { +extension LnurlAddressData: Equatable, Hashable { + public static func ==(lhs: LnurlAddressData, rhs: LnurlAddressData) -> Bool { + if lhs.uri != rhs.uri { return false } - if lhs.accountIndex != rhs.accountIndex { + if lhs.domain != rhs.domain { return false } - if lhs.accounts != rhs.accounts { + if lhs.username != rhs.username { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(masterFingerprint) - hasher.combine(accountIndex) - hasher.combine(accounts) + hasher.combine(uri) + hasher.combine(domain) + hasher.combine(username) } } -extension PassportAccountExport: Codable {} +extension LnurlAddressData: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypePassportAccountExport: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> PassportAccountExport { +public struct FfiConverterTypeLnurlAddressData: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> LnurlAddressData { return - try PassportAccountExport( - masterFingerprint: FfiConverterString.read(from: &buf), - accountIndex: FfiConverterUInt32.read(from: &buf), - accounts: FfiConverterSequenceTypePassportAccount.read(from: &buf) + try LnurlAddressData( + uri: FfiConverterString.read(from: &buf), + domain: FfiConverterString.read(from: &buf), + username: FfiConverterString.read(from: &buf) ) } - public static func write(_ value: PassportAccountExport, into buf: inout [UInt8]) { - FfiConverterString.write(value.masterFingerprint, into: &buf) - FfiConverterUInt32.write(value.accountIndex, into: &buf) - FfiConverterSequenceTypePassportAccount.write(value.accounts, into: &buf) + public static func write(_ value: LnurlAddressData, into buf: inout [UInt8]) { + FfiConverterString.write(value.uri, into: &buf) + FfiConverterString.write(value.domain, into: &buf) + FfiConverterString.write(value.username, into: &buf) } } @@ -9306,143 +9568,87 @@ public struct FfiConverterTypePassportAccountExport: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypePassportAccountExport_lift(_ buf: RustBuffer) throws -> PassportAccountExport { - return try FfiConverterTypePassportAccountExport.lift(buf) +public func FfiConverterTypeLnurlAddressData_lift(_ buf: RustBuffer) throws -> LnurlAddressData { + return try FfiConverterTypeLnurlAddressData.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypePassportAccountExport_lower(_ value: PassportAccountExport) -> RustBuffer { - return FfiConverterTypePassportAccountExport.lower(value) +public func FfiConverterTypeLnurlAddressData_lower(_ value: LnurlAddressData) -> RustBuffer { + return FfiConverterTypeLnurlAddressData.lower(value) } -public struct PreActivityMetadata { - public var walletId: String - public var paymentId: String - public var tags: [String] - public var paymentHash: String? - public var txId: String? - public var address: String? - public var isReceive: Bool - public var feeRate: UInt64 - public var isTransfer: Bool - public var channelId: String? - public var createdAt: UInt64 +public struct LnurlAuthData { + public var uri: String + public var tag: String + public var k1: String + public var domain: String // Default memberwise initializers are never public by default, so we // declare one manually. - public init(walletId: String, paymentId: String, tags: [String], paymentHash: String?, txId: String?, address: String?, isReceive: Bool, feeRate: UInt64, isTransfer: Bool, channelId: String?, createdAt: UInt64) { - self.walletId = walletId - self.paymentId = paymentId - self.tags = tags - self.paymentHash = paymentHash - self.txId = txId - self.address = address - self.isReceive = isReceive - self.feeRate = feeRate - self.isTransfer = isTransfer - self.channelId = channelId - self.createdAt = createdAt + public init(uri: String, tag: String, k1: String, domain: String) { + self.uri = uri + self.tag = tag + self.k1 = k1 + self.domain = domain } } #if compiler(>=6) -extension PreActivityMetadata: Sendable {} +extension LnurlAuthData: Sendable {} #endif -extension PreActivityMetadata: Equatable, Hashable { - public static func ==(lhs: PreActivityMetadata, rhs: PreActivityMetadata) -> Bool { - if lhs.walletId != rhs.walletId { - return false - } - if lhs.paymentId != rhs.paymentId { - return false - } - if lhs.tags != rhs.tags { - return false - } - if lhs.paymentHash != rhs.paymentHash { - return false - } - if lhs.txId != rhs.txId { - return false - } - if lhs.address != rhs.address { - return false - } - if lhs.isReceive != rhs.isReceive { - return false - } - if lhs.feeRate != rhs.feeRate { +extension LnurlAuthData: Equatable, Hashable { + public static func ==(lhs: LnurlAuthData, rhs: LnurlAuthData) -> Bool { + if lhs.uri != rhs.uri { return false } - if lhs.isTransfer != rhs.isTransfer { + if lhs.tag != rhs.tag { return false } - if lhs.channelId != rhs.channelId { + if lhs.k1 != rhs.k1 { return false } - if lhs.createdAt != rhs.createdAt { + if lhs.domain != rhs.domain { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(walletId) - hasher.combine(paymentId) - hasher.combine(tags) - hasher.combine(paymentHash) - hasher.combine(txId) - hasher.combine(address) - hasher.combine(isReceive) - hasher.combine(feeRate) - hasher.combine(isTransfer) - hasher.combine(channelId) - hasher.combine(createdAt) + hasher.combine(uri) + hasher.combine(tag) + hasher.combine(k1) + hasher.combine(domain) } } -extension PreActivityMetadata: Codable {} +extension LnurlAuthData: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypePreActivityMetadata: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> PreActivityMetadata { +public struct FfiConverterTypeLnurlAuthData: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> LnurlAuthData { return - try PreActivityMetadata( - walletId: FfiConverterString.read(from: &buf), - paymentId: FfiConverterString.read(from: &buf), - tags: FfiConverterSequenceString.read(from: &buf), - paymentHash: FfiConverterOptionString.read(from: &buf), - txId: FfiConverterOptionString.read(from: &buf), - address: FfiConverterOptionString.read(from: &buf), - isReceive: FfiConverterBool.read(from: &buf), - feeRate: FfiConverterUInt64.read(from: &buf), - isTransfer: FfiConverterBool.read(from: &buf), - channelId: FfiConverterOptionString.read(from: &buf), - createdAt: FfiConverterUInt64.read(from: &buf) + try LnurlAuthData( + uri: FfiConverterString.read(from: &buf), + tag: FfiConverterString.read(from: &buf), + k1: FfiConverterString.read(from: &buf), + domain: FfiConverterString.read(from: &buf) ) } - public static func write(_ value: PreActivityMetadata, into buf: inout [UInt8]) { - FfiConverterString.write(value.walletId, into: &buf) - FfiConverterString.write(value.paymentId, into: &buf) - FfiConverterSequenceString.write(value.tags, into: &buf) - FfiConverterOptionString.write(value.paymentHash, into: &buf) - FfiConverterOptionString.write(value.txId, into: &buf) - FfiConverterOptionString.write(value.address, into: &buf) - FfiConverterBool.write(value.isReceive, into: &buf) - FfiConverterUInt64.write(value.feeRate, into: &buf) - FfiConverterBool.write(value.isTransfer, into: &buf) - FfiConverterOptionString.write(value.channelId, into: &buf) - FfiConverterUInt64.write(value.createdAt, into: &buf) + public static func write(_ value: LnurlAuthData, into buf: inout [UInt8]) { + FfiConverterString.write(value.uri, into: &buf) + FfiConverterString.write(value.tag, into: &buf) + FfiConverterString.write(value.k1, into: &buf) + FfiConverterString.write(value.domain, into: &buf) } } @@ -9450,63 +9656,87 @@ public struct FfiConverterTypePreActivityMetadata: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypePreActivityMetadata_lift(_ buf: RustBuffer) throws -> PreActivityMetadata { - return try FfiConverterTypePreActivityMetadata.lift(buf) +public func FfiConverterTypeLnurlAuthData_lift(_ buf: RustBuffer) throws -> LnurlAuthData { + return try FfiConverterTypeLnurlAuthData.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypePreActivityMetadata_lower(_ value: PreActivityMetadata) -> RustBuffer { - return FfiConverterTypePreActivityMetadata.lower(value) +public func FfiConverterTypeLnurlAuthData_lower(_ value: LnurlAuthData) -> RustBuffer { + return FfiConverterTypeLnurlAuthData.lower(value) } -public struct PubkyAuth { - public var data: String +public struct LnurlChannelData { + public var uri: String + public var callback: String + public var k1: String + public var tag: String // Default memberwise initializers are never public by default, so we // declare one manually. - public init(data: String) { - self.data = data + public init(uri: String, callback: String, k1: String, tag: String) { + self.uri = uri + self.callback = callback + self.k1 = k1 + self.tag = tag } } #if compiler(>=6) -extension PubkyAuth: Sendable {} +extension LnurlChannelData: Sendable {} #endif -extension PubkyAuth: Equatable, Hashable { - public static func ==(lhs: PubkyAuth, rhs: PubkyAuth) -> Bool { - if lhs.data != rhs.data { +extension LnurlChannelData: Equatable, Hashable { + public static func ==(lhs: LnurlChannelData, rhs: LnurlChannelData) -> Bool { + if lhs.uri != rhs.uri { + return false + } + if lhs.callback != rhs.callback { + return false + } + if lhs.k1 != rhs.k1 { + return false + } + if lhs.tag != rhs.tag { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(data) + hasher.combine(uri) + hasher.combine(callback) + hasher.combine(k1) + hasher.combine(tag) } } -extension PubkyAuth: Codable {} +extension LnurlChannelData: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypePubkyAuth: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> PubkyAuth { +public struct FfiConverterTypeLnurlChannelData: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> LnurlChannelData { return - try PubkyAuth( - data: FfiConverterString.read(from: &buf) + try LnurlChannelData( + uri: FfiConverterString.read(from: &buf), + callback: FfiConverterString.read(from: &buf), + k1: FfiConverterString.read(from: &buf), + tag: FfiConverterString.read(from: &buf) ) } - public static func write(_ value: PubkyAuth, into buf: inout [UInt8]) { - FfiConverterString.write(value.data, into: &buf) + public static func write(_ value: LnurlChannelData, into buf: inout [UInt8]) { + FfiConverterString.write(value.uri, into: &buf) + FfiConverterString.write(value.callback, into: &buf) + FfiConverterString.write(value.k1, into: &buf) + FfiConverterString.write(value.tag, into: &buf) } } @@ -9514,128 +9744,119 @@ public struct FfiConverterTypePubkyAuth: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypePubkyAuth_lift(_ buf: RustBuffer) throws -> PubkyAuth { - return try FfiConverterTypePubkyAuth.lift(buf) +public func FfiConverterTypeLnurlChannelData_lift(_ buf: RustBuffer) throws -> LnurlChannelData { + return try FfiConverterTypeLnurlChannelData.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypePubkyAuth_lower(_ value: PubkyAuth) -> RustBuffer { - return FfiConverterTypePubkyAuth.lower(value) +public func FfiConverterTypeLnurlChannelData_lower(_ value: LnurlChannelData) -> RustBuffer { + return FfiConverterTypeLnurlChannelData.lower(value) } -/** - * Details extracted from a `pubkyauth://` deep-link URL. - */ -public struct PubkyAuthDetails { - /** - * Whether this is a signin or signup flow. - */ - public var kind: PubkyAuthKind - /** - * Requested capabilities (e.g. `"/pub/pubky.app/:rw"`). - */ - public var capabilities: String - /** - * Relay URL used for the auth exchange. - */ - public var relay: String - /** - * Homeserver public key (z32-encoded). Present only for signup flows. - */ - public var homeserver: String? - /** - * Signup token. Present only for signup flows. - */ - public var signupToken: String? +public struct LnurlPayData { + public var uri: String + public var callback: String + public var minSendable: UInt64 + public var maxSendable: UInt64 + public var metadataStr: String + public var commentAllowed: UInt32? + public var allowsNostr: Bool + public var nostrPubkey: Data? // Default memberwise initializers are never public by default, so we // declare one manually. - public init( - /** - * Whether this is a signin or signup flow. - */kind: PubkyAuthKind, - /** - * Requested capabilities (e.g. `"/pub/pubky.app/:rw"`). - */capabilities: String, - /** - * Relay URL used for the auth exchange. - */relay: String, - /** - * Homeserver public key (z32-encoded). Present only for signup flows. - */homeserver: String?, - /** - * Signup token. Present only for signup flows. - */signupToken: String?) { - self.kind = kind - self.capabilities = capabilities - self.relay = relay - self.homeserver = homeserver - self.signupToken = signupToken + public init(uri: String, callback: String, minSendable: UInt64, maxSendable: UInt64, metadataStr: String, commentAllowed: UInt32?, allowsNostr: Bool, nostrPubkey: Data?) { + self.uri = uri + self.callback = callback + self.minSendable = minSendable + self.maxSendable = maxSendable + self.metadataStr = metadataStr + self.commentAllowed = commentAllowed + self.allowsNostr = allowsNostr + self.nostrPubkey = nostrPubkey } } #if compiler(>=6) -extension PubkyAuthDetails: Sendable {} +extension LnurlPayData: Sendable {} #endif -extension PubkyAuthDetails: Equatable, Hashable { - public static func ==(lhs: PubkyAuthDetails, rhs: PubkyAuthDetails) -> Bool { - if lhs.kind != rhs.kind { +extension LnurlPayData: Equatable, Hashable { + public static func ==(lhs: LnurlPayData, rhs: LnurlPayData) -> Bool { + if lhs.uri != rhs.uri { return false } - if lhs.capabilities != rhs.capabilities { + if lhs.callback != rhs.callback { return false } - if lhs.relay != rhs.relay { + if lhs.minSendable != rhs.minSendable { return false } - if lhs.homeserver != rhs.homeserver { + if lhs.maxSendable != rhs.maxSendable { return false } - if lhs.signupToken != rhs.signupToken { + if lhs.metadataStr != rhs.metadataStr { + return false + } + if lhs.commentAllowed != rhs.commentAllowed { + return false + } + if lhs.allowsNostr != rhs.allowsNostr { + return false + } + if lhs.nostrPubkey != rhs.nostrPubkey { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(kind) - hasher.combine(capabilities) - hasher.combine(relay) - hasher.combine(homeserver) - hasher.combine(signupToken) + hasher.combine(uri) + hasher.combine(callback) + hasher.combine(minSendable) + hasher.combine(maxSendable) + hasher.combine(metadataStr) + hasher.combine(commentAllowed) + hasher.combine(allowsNostr) + hasher.combine(nostrPubkey) } } -extension PubkyAuthDetails: Codable {} +extension LnurlPayData: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypePubkyAuthDetails: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> PubkyAuthDetails { +public struct FfiConverterTypeLnurlPayData: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> LnurlPayData { return - try PubkyAuthDetails( - kind: FfiConverterTypePubkyAuthKind.read(from: &buf), - capabilities: FfiConverterString.read(from: &buf), - relay: FfiConverterString.read(from: &buf), - homeserver: FfiConverterOptionString.read(from: &buf), - signupToken: FfiConverterOptionString.read(from: &buf) + try LnurlPayData( + uri: FfiConverterString.read(from: &buf), + callback: FfiConverterString.read(from: &buf), + minSendable: FfiConverterUInt64.read(from: &buf), + maxSendable: FfiConverterUInt64.read(from: &buf), + metadataStr: FfiConverterString.read(from: &buf), + commentAllowed: FfiConverterOptionUInt32.read(from: &buf), + allowsNostr: FfiConverterBool.read(from: &buf), + nostrPubkey: FfiConverterOptionData.read(from: &buf) ) } - public static func write(_ value: PubkyAuthDetails, into buf: inout [UInt8]) { - FfiConverterTypePubkyAuthKind.write(value.kind, into: &buf) - FfiConverterString.write(value.capabilities, into: &buf) - FfiConverterString.write(value.relay, into: &buf) - FfiConverterOptionString.write(value.homeserver, into: &buf) - FfiConverterOptionString.write(value.signupToken, into: &buf) + public static func write(_ value: LnurlPayData, into buf: inout [UInt8]) { + FfiConverterString.write(value.uri, into: &buf) + FfiConverterString.write(value.callback, into: &buf) + FfiConverterUInt64.write(value.minSendable, into: &buf) + FfiConverterUInt64.write(value.maxSendable, into: &buf) + FfiConverterString.write(value.metadataStr, into: &buf) + FfiConverterOptionUInt32.write(value.commentAllowed, into: &buf) + FfiConverterBool.write(value.allowsNostr, into: &buf) + FfiConverterOptionData.write(value.nostrPubkey, into: &buf) } } @@ -9643,95 +9864,111 @@ public struct FfiConverterTypePubkyAuthDetails: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypePubkyAuthDetails_lift(_ buf: RustBuffer) throws -> PubkyAuthDetails { - return try FfiConverterTypePubkyAuthDetails.lift(buf) +public func FfiConverterTypeLnurlPayData_lift(_ buf: RustBuffer) throws -> LnurlPayData { + return try FfiConverterTypeLnurlPayData.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypePubkyAuthDetails_lower(_ value: PubkyAuthDetails) -> RustBuffer { - return FfiConverterTypePubkyAuthDetails.lower(value) +public func FfiConverterTypeLnurlPayData_lower(_ value: LnurlPayData) -> RustBuffer { + return FfiConverterTypeLnurlPayData.lower(value) } -public struct PubkyProfile { - public var name: String - public var bio: String? - public var image: String? - public var links: [PubkyProfileLink]? - public var status: String? +public struct LnurlWithdrawData { + public var uri: String + public var callback: String + public var k1: String + public var defaultDescription: String + public var minWithdrawable: UInt64? + public var maxWithdrawable: UInt64 + public var tag: String // Default memberwise initializers are never public by default, so we // declare one manually. - public init(name: String, bio: String?, image: String?, links: [PubkyProfileLink]?, status: String?) { - self.name = name - self.bio = bio - self.image = image - self.links = links - self.status = status + public init(uri: String, callback: String, k1: String, defaultDescription: String, minWithdrawable: UInt64?, maxWithdrawable: UInt64, tag: String) { + self.uri = uri + self.callback = callback + self.k1 = k1 + self.defaultDescription = defaultDescription + self.minWithdrawable = minWithdrawable + self.maxWithdrawable = maxWithdrawable + self.tag = tag } } #if compiler(>=6) -extension PubkyProfile: Sendable {} +extension LnurlWithdrawData: Sendable {} #endif -extension PubkyProfile: Equatable, Hashable { - public static func ==(lhs: PubkyProfile, rhs: PubkyProfile) -> Bool { - if lhs.name != rhs.name { +extension LnurlWithdrawData: Equatable, Hashable { + public static func ==(lhs: LnurlWithdrawData, rhs: LnurlWithdrawData) -> Bool { + if lhs.uri != rhs.uri { return false } - if lhs.bio != rhs.bio { + if lhs.callback != rhs.callback { return false } - if lhs.image != rhs.image { + if lhs.k1 != rhs.k1 { return false } - if lhs.links != rhs.links { + if lhs.defaultDescription != rhs.defaultDescription { return false } - if lhs.status != rhs.status { + if lhs.minWithdrawable != rhs.minWithdrawable { + return false + } + if lhs.maxWithdrawable != rhs.maxWithdrawable { + return false + } + if lhs.tag != rhs.tag { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(name) - hasher.combine(bio) - hasher.combine(image) - hasher.combine(links) - hasher.combine(status) + hasher.combine(uri) + hasher.combine(callback) + hasher.combine(k1) + hasher.combine(defaultDescription) + hasher.combine(minWithdrawable) + hasher.combine(maxWithdrawable) + hasher.combine(tag) } } -extension PubkyProfile: Codable {} +extension LnurlWithdrawData: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypePubkyProfile: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> PubkyProfile { +public struct FfiConverterTypeLnurlWithdrawData: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> LnurlWithdrawData { return - try PubkyProfile( - name: FfiConverterString.read(from: &buf), - bio: FfiConverterOptionString.read(from: &buf), - image: FfiConverterOptionString.read(from: &buf), - links: FfiConverterOptionSequenceTypePubkyProfileLink.read(from: &buf), - status: FfiConverterOptionString.read(from: &buf) + try LnurlWithdrawData( + uri: FfiConverterString.read(from: &buf), + callback: FfiConverterString.read(from: &buf), + k1: FfiConverterString.read(from: &buf), + defaultDescription: FfiConverterString.read(from: &buf), + minWithdrawable: FfiConverterOptionUInt64.read(from: &buf), + maxWithdrawable: FfiConverterUInt64.read(from: &buf), + tag: FfiConverterString.read(from: &buf) ) } - public static func write(_ value: PubkyProfile, into buf: inout [UInt8]) { - FfiConverterString.write(value.name, into: &buf) - FfiConverterOptionString.write(value.bio, into: &buf) - FfiConverterOptionString.write(value.image, into: &buf) - FfiConverterOptionSequenceTypePubkyProfileLink.write(value.links, into: &buf) - FfiConverterOptionString.write(value.status, into: &buf) + public static func write(_ value: LnurlWithdrawData, into buf: inout [UInt8]) { + FfiConverterString.write(value.uri, into: &buf) + FfiConverterString.write(value.callback, into: &buf) + FfiConverterString.write(value.k1, into: &buf) + FfiConverterString.write(value.defaultDescription, into: &buf) + FfiConverterOptionUInt64.write(value.minWithdrawable, into: &buf) + FfiConverterUInt64.write(value.maxWithdrawable, into: &buf) + FfiConverterString.write(value.tag, into: &buf) } } @@ -9739,71 +9976,128 @@ public struct FfiConverterTypePubkyProfile: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypePubkyProfile_lift(_ buf: RustBuffer) throws -> PubkyProfile { - return try FfiConverterTypePubkyProfile.lift(buf) +public func FfiConverterTypeLnurlWithdrawData_lift(_ buf: RustBuffer) throws -> LnurlWithdrawData { + return try FfiConverterTypeLnurlWithdrawData.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypePubkyProfile_lower(_ value: PubkyProfile) -> RustBuffer { - return FfiConverterTypePubkyProfile.lower(value) +public func FfiConverterTypeLnurlWithdrawData_lower(_ value: LnurlWithdrawData) -> RustBuffer { + return FfiConverterTypeLnurlWithdrawData.lower(value) } -public struct PubkyProfileLink { - public var title: String - public var url: String +/** + * Native device information returned from enumeration + */ +public struct NativeDeviceInfo { + /** + * Unique path/identifier for this device + */ + public var path: String + /** + * Transport type: "usb" or "bluetooth" + */ + public var transportType: String + /** + * Optional device name (from BLE advertisement or USB descriptor) + */ + public var name: String? + /** + * USB Vendor ID (for USB devices) + */ + public var vendorId: UInt16? + /** + * USB Product ID (for USB devices) + */ + public var productId: UInt16? // Default memberwise initializers are never public by default, so we // declare one manually. - public init(title: String, url: String) { - self.title = title - self.url = url + public init( + /** + * Unique path/identifier for this device + */path: String, + /** + * Transport type: "usb" or "bluetooth" + */transportType: String, + /** + * Optional device name (from BLE advertisement or USB descriptor) + */name: String?, + /** + * USB Vendor ID (for USB devices) + */vendorId: UInt16?, + /** + * USB Product ID (for USB devices) + */productId: UInt16?) { + self.path = path + self.transportType = transportType + self.name = name + self.vendorId = vendorId + self.productId = productId } } #if compiler(>=6) -extension PubkyProfileLink: Sendable {} +extension NativeDeviceInfo: Sendable {} #endif -extension PubkyProfileLink: Equatable, Hashable { - public static func ==(lhs: PubkyProfileLink, rhs: PubkyProfileLink) -> Bool { - if lhs.title != rhs.title { +extension NativeDeviceInfo: Equatable, Hashable { + public static func ==(lhs: NativeDeviceInfo, rhs: NativeDeviceInfo) -> Bool { + if lhs.path != rhs.path { return false } - if lhs.url != rhs.url { + if lhs.transportType != rhs.transportType { + return false + } + if lhs.name != rhs.name { + return false + } + if lhs.vendorId != rhs.vendorId { + return false + } + if lhs.productId != rhs.productId { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(title) - hasher.combine(url) + hasher.combine(path) + hasher.combine(transportType) + hasher.combine(name) + hasher.combine(vendorId) + hasher.combine(productId) } } -extension PubkyProfileLink: Codable {} +extension NativeDeviceInfo: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypePubkyProfileLink: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> PubkyProfileLink { +public struct FfiConverterTypeNativeDeviceInfo: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> NativeDeviceInfo { return - try PubkyProfileLink( - title: FfiConverterString.read(from: &buf), - url: FfiConverterString.read(from: &buf) + try NativeDeviceInfo( + path: FfiConverterString.read(from: &buf), + transportType: FfiConverterString.read(from: &buf), + name: FfiConverterOptionString.read(from: &buf), + vendorId: FfiConverterOptionUInt16.read(from: &buf), + productId: FfiConverterOptionUInt16.read(from: &buf) ) } - public static func write(_ value: PubkyProfileLink, into buf: inout [UInt8]) { - FfiConverterString.write(value.title, into: &buf) - FfiConverterString.write(value.url, into: &buf) + public static func write(_ value: NativeDeviceInfo, into buf: inout [UInt8]) { + FfiConverterString.write(value.path, into: &buf) + FfiConverterString.write(value.transportType, into: &buf) + FfiConverterOptionString.write(value.name, into: &buf) + FfiConverterOptionUInt16.write(value.vendorId, into: &buf) + FfiConverterOptionUInt16.write(value.productId, into: &buf) } } @@ -9811,125 +10105,95 @@ public struct FfiConverterTypePubkyProfileLink: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypePubkyProfileLink_lift(_ buf: RustBuffer) throws -> PubkyProfileLink { - return try FfiConverterTypePubkyProfileLink.lift(buf) +public func FfiConverterTypeNativeDeviceInfo_lift(_ buf: RustBuffer) throws -> NativeDeviceInfo { + return try FfiConverterTypeNativeDeviceInfo.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypePubkyProfileLink_lower(_ value: PubkyProfileLink) -> RustBuffer { - return FfiConverterTypePubkyProfileLink.lower(value) +public func FfiConverterTypeNativeDeviceInfo_lower(_ value: NativeDeviceInfo) -> RustBuffer { + return FfiConverterTypeNativeDeviceInfo.lower(value) } -/** - * Result of creating a reverse swap (Lightning -> onchain). - * - * The caller pays `invoice` from its Lightning node; once Boltz locks funds at - * `lockup_address`, the module claims them to the provided onchain address. - */ -public struct ReverseSwapResponse { - public var id: String - /** - * Hold invoice the caller must pay via Lightning. - */ - public var invoice: String - /** - * Address Boltz locks the onchain funds to. - */ - public var lockupAddress: String - /** - * Amount in satoshis that will be received onchain (after Boltz fees). - */ - public var onchainAmountSat: UInt64 - /** - * Onchain timeout height for the swap. - */ - public var timeoutBlockHeight: UInt64 +public struct OnChainInvoice { + public var address: String + public var amountSatoshis: UInt64 + public var label: String? + public var message: String? + public var params: [String: String]? // Default memberwise initializers are never public by default, so we // declare one manually. - public init(id: String, - /** - * Hold invoice the caller must pay via Lightning. - */invoice: String, - /** - * Address Boltz locks the onchain funds to. - */lockupAddress: String, - /** - * Amount in satoshis that will be received onchain (after Boltz fees). - */onchainAmountSat: UInt64, - /** - * Onchain timeout height for the swap. - */timeoutBlockHeight: UInt64) { - self.id = id - self.invoice = invoice - self.lockupAddress = lockupAddress - self.onchainAmountSat = onchainAmountSat - self.timeoutBlockHeight = timeoutBlockHeight + public init(address: String, amountSatoshis: UInt64, label: String?, message: String?, params: [String: String]?) { + self.address = address + self.amountSatoshis = amountSatoshis + self.label = label + self.message = message + self.params = params } } #if compiler(>=6) -extension ReverseSwapResponse: Sendable {} +extension OnChainInvoice: Sendable {} #endif -extension ReverseSwapResponse: Equatable, Hashable { - public static func ==(lhs: ReverseSwapResponse, rhs: ReverseSwapResponse) -> Bool { - if lhs.id != rhs.id { +extension OnChainInvoice: Equatable, Hashable { + public static func ==(lhs: OnChainInvoice, rhs: OnChainInvoice) -> Bool { + if lhs.address != rhs.address { return false } - if lhs.invoice != rhs.invoice { + if lhs.amountSatoshis != rhs.amountSatoshis { return false } - if lhs.lockupAddress != rhs.lockupAddress { + if lhs.label != rhs.label { return false } - if lhs.onchainAmountSat != rhs.onchainAmountSat { + if lhs.message != rhs.message { return false } - if lhs.timeoutBlockHeight != rhs.timeoutBlockHeight { + if lhs.params != rhs.params { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(id) - hasher.combine(invoice) - hasher.combine(lockupAddress) - hasher.combine(onchainAmountSat) - hasher.combine(timeoutBlockHeight) + hasher.combine(address) + hasher.combine(amountSatoshis) + hasher.combine(label) + hasher.combine(message) + hasher.combine(params) } } -extension ReverseSwapResponse: Codable {} +extension OnChainInvoice: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeReverseSwapResponse: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ReverseSwapResponse { +public struct FfiConverterTypeOnChainInvoice: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> OnChainInvoice { return - try ReverseSwapResponse( - id: FfiConverterString.read(from: &buf), - invoice: FfiConverterString.read(from: &buf), - lockupAddress: FfiConverterString.read(from: &buf), - onchainAmountSat: FfiConverterUInt64.read(from: &buf), - timeoutBlockHeight: FfiConverterUInt64.read(from: &buf) + try OnChainInvoice( + address: FfiConverterString.read(from: &buf), + amountSatoshis: FfiConverterUInt64.read(from: &buf), + label: FfiConverterOptionString.read(from: &buf), + message: FfiConverterOptionString.read(from: &buf), + params: FfiConverterOptionDictionaryStringString.read(from: &buf) ) } - public static func write(_ value: ReverseSwapResponse, into buf: inout [UInt8]) { - FfiConverterString.write(value.id, into: &buf) - FfiConverterString.write(value.invoice, into: &buf) - FfiConverterString.write(value.lockupAddress, into: &buf) - FfiConverterUInt64.write(value.onchainAmountSat, into: &buf) - FfiConverterUInt64.write(value.timeoutBlockHeight, into: &buf) + public static func write(_ value: OnChainInvoice, into buf: inout [UInt8]) { + FfiConverterString.write(value.address, into: &buf) + FfiConverterUInt64.write(value.amountSatoshis, into: &buf) + FfiConverterOptionString.write(value.label, into: &buf) + FfiConverterOptionString.write(value.message, into: &buf) + FfiConverterOptionDictionaryStringString.write(value.params, into: &buf) } } @@ -9937,128 +10201,223 @@ public struct FfiConverterTypeReverseSwapResponse: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeReverseSwapResponse_lift(_ buf: RustBuffer) throws -> ReverseSwapResponse { - return try FfiConverterTypeReverseSwapResponse.lift(buf) +public func FfiConverterTypeOnChainInvoice_lift(_ buf: RustBuffer) throws -> OnChainInvoice { + return try FfiConverterTypeOnChainInvoice.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeReverseSwapResponse_lower(_ value: ReverseSwapResponse) -> RustBuffer { - return FfiConverterTypeReverseSwapResponse.lower(value) +public func FfiConverterTypeOnChainInvoice_lower(_ value: OnChainInvoice) -> RustBuffer { + return FfiConverterTypeOnChainInvoice.lower(value) } -/** - * Result from querying a single Bitcoin address. - */ -public struct SingleAddressInfoResult { - /** - * The queried address - */ +public struct OnchainActivity { + public var walletId: String + public var id: String + public var txType: PaymentType + public var txId: String + public var value: UInt64 + public var fee: UInt64 + public var feeRate: UInt64 public var address: String - /** - * Total confirmed balance in satoshis - */ - public var balance: UInt64 - /** - * UTXOs for this address - */ - public var utxos: [AccountUtxo] - /** - * Number of transactions involving this address - */ - public var transfers: UInt32 - /** - * Current blockchain tip height - */ - public var blockHeight: UInt32 - + public var confirmed: Bool + public var timestamp: UInt64 + public var isBoosted: Bool + public var boostTxIds: [String] + public var isTransfer: Bool + public var doesExist: Bool + public var confirmTimestamp: UInt64? + public var channelId: String? + public var transferTxId: String? + public var contact: String? + public var createdAt: UInt64? + public var updatedAt: UInt64? + public var seenAt: UInt64? + // Default memberwise initializers are never public by default, so we // declare one manually. - public init( - /** - * The queried address - */address: String, - /** - * Total confirmed balance in satoshis - */balance: UInt64, - /** - * UTXOs for this address - */utxos: [AccountUtxo], - /** - * Number of transactions involving this address - */transfers: UInt32, - /** - * Current blockchain tip height - */blockHeight: UInt32) { + public init(walletId: String, id: String, txType: PaymentType, txId: String, value: UInt64, fee: UInt64, feeRate: UInt64, address: String, confirmed: Bool, timestamp: UInt64, isBoosted: Bool, boostTxIds: [String], isTransfer: Bool, doesExist: Bool, confirmTimestamp: UInt64?, channelId: String?, transferTxId: String?, contact: String?, createdAt: UInt64?, updatedAt: UInt64?, seenAt: UInt64?) { + self.walletId = walletId + self.id = id + self.txType = txType + self.txId = txId + self.value = value + self.fee = fee + self.feeRate = feeRate self.address = address - self.balance = balance - self.utxos = utxos - self.transfers = transfers - self.blockHeight = blockHeight + self.confirmed = confirmed + self.timestamp = timestamp + self.isBoosted = isBoosted + self.boostTxIds = boostTxIds + self.isTransfer = isTransfer + self.doesExist = doesExist + self.confirmTimestamp = confirmTimestamp + self.channelId = channelId + self.transferTxId = transferTxId + self.contact = contact + self.createdAt = createdAt + self.updatedAt = updatedAt + self.seenAt = seenAt } } #if compiler(>=6) -extension SingleAddressInfoResult: Sendable {} +extension OnchainActivity: Sendable {} #endif -extension SingleAddressInfoResult: Equatable, Hashable { - public static func ==(lhs: SingleAddressInfoResult, rhs: SingleAddressInfoResult) -> Bool { +extension OnchainActivity: Equatable, Hashable { + public static func ==(lhs: OnchainActivity, rhs: OnchainActivity) -> Bool { + if lhs.walletId != rhs.walletId { + return false + } + if lhs.id != rhs.id { + return false + } + if lhs.txType != rhs.txType { + return false + } + if lhs.txId != rhs.txId { + return false + } + if lhs.value != rhs.value { + return false + } + if lhs.fee != rhs.fee { + return false + } + if lhs.feeRate != rhs.feeRate { + return false + } if lhs.address != rhs.address { return false } - if lhs.balance != rhs.balance { + if lhs.confirmed != rhs.confirmed { return false } - if lhs.utxos != rhs.utxos { + if lhs.timestamp != rhs.timestamp { return false } - if lhs.transfers != rhs.transfers { + if lhs.isBoosted != rhs.isBoosted { return false } - if lhs.blockHeight != rhs.blockHeight { + if lhs.boostTxIds != rhs.boostTxIds { + return false + } + if lhs.isTransfer != rhs.isTransfer { + return false + } + if lhs.doesExist != rhs.doesExist { + return false + } + if lhs.confirmTimestamp != rhs.confirmTimestamp { + return false + } + if lhs.channelId != rhs.channelId { + return false + } + if lhs.transferTxId != rhs.transferTxId { + return false + } + if lhs.contact != rhs.contact { + return false + } + if lhs.createdAt != rhs.createdAt { + return false + } + if lhs.updatedAt != rhs.updatedAt { + return false + } + if lhs.seenAt != rhs.seenAt { return false } return true } public func hash(into hasher: inout Hasher) { + hasher.combine(walletId) + hasher.combine(id) + hasher.combine(txType) + hasher.combine(txId) + hasher.combine(value) + hasher.combine(fee) + hasher.combine(feeRate) hasher.combine(address) - hasher.combine(balance) - hasher.combine(utxos) - hasher.combine(transfers) - hasher.combine(blockHeight) + hasher.combine(confirmed) + hasher.combine(timestamp) + hasher.combine(isBoosted) + hasher.combine(boostTxIds) + hasher.combine(isTransfer) + hasher.combine(doesExist) + hasher.combine(confirmTimestamp) + hasher.combine(channelId) + hasher.combine(transferTxId) + hasher.combine(contact) + hasher.combine(createdAt) + hasher.combine(updatedAt) + hasher.combine(seenAt) } } -extension SingleAddressInfoResult: Codable {} +extension OnchainActivity: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeSingleAddressInfoResult: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SingleAddressInfoResult { +public struct FfiConverterTypeOnchainActivity: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> OnchainActivity { return - try SingleAddressInfoResult( + try OnchainActivity( + walletId: FfiConverterString.read(from: &buf), + id: FfiConverterString.read(from: &buf), + txType: FfiConverterTypePaymentType.read(from: &buf), + txId: FfiConverterString.read(from: &buf), + value: FfiConverterUInt64.read(from: &buf), + fee: FfiConverterUInt64.read(from: &buf), + feeRate: FfiConverterUInt64.read(from: &buf), address: FfiConverterString.read(from: &buf), - balance: FfiConverterUInt64.read(from: &buf), - utxos: FfiConverterSequenceTypeAccountUtxo.read(from: &buf), - transfers: FfiConverterUInt32.read(from: &buf), - blockHeight: FfiConverterUInt32.read(from: &buf) + confirmed: FfiConverterBool.read(from: &buf), + timestamp: FfiConverterUInt64.read(from: &buf), + isBoosted: FfiConverterBool.read(from: &buf), + boostTxIds: FfiConverterSequenceString.read(from: &buf), + isTransfer: FfiConverterBool.read(from: &buf), + doesExist: FfiConverterBool.read(from: &buf), + confirmTimestamp: FfiConverterOptionUInt64.read(from: &buf), + channelId: FfiConverterOptionString.read(from: &buf), + transferTxId: FfiConverterOptionString.read(from: &buf), + contact: FfiConverterOptionString.read(from: &buf), + createdAt: FfiConverterOptionUInt64.read(from: &buf), + updatedAt: FfiConverterOptionUInt64.read(from: &buf), + seenAt: FfiConverterOptionUInt64.read(from: &buf) ) } - public static func write(_ value: SingleAddressInfoResult, into buf: inout [UInt8]) { + public static func write(_ value: OnchainActivity, into buf: inout [UInt8]) { + FfiConverterString.write(value.walletId, into: &buf) + FfiConverterString.write(value.id, into: &buf) + FfiConverterTypePaymentType.write(value.txType, into: &buf) + FfiConverterString.write(value.txId, into: &buf) + FfiConverterUInt64.write(value.value, into: &buf) + FfiConverterUInt64.write(value.fee, into: &buf) + FfiConverterUInt64.write(value.feeRate, into: &buf) FfiConverterString.write(value.address, into: &buf) - FfiConverterUInt64.write(value.balance, into: &buf) - FfiConverterSequenceTypeAccountUtxo.write(value.utxos, into: &buf) - FfiConverterUInt32.write(value.transfers, into: &buf) - FfiConverterUInt32.write(value.blockHeight, into: &buf) + FfiConverterBool.write(value.confirmed, into: &buf) + FfiConverterUInt64.write(value.timestamp, into: &buf) + FfiConverterBool.write(value.isBoosted, into: &buf) + FfiConverterSequenceString.write(value.boostTxIds, into: &buf) + FfiConverterBool.write(value.isTransfer, into: &buf) + FfiConverterBool.write(value.doesExist, into: &buf) + FfiConverterOptionUInt64.write(value.confirmTimestamp, into: &buf) + FfiConverterOptionString.write(value.channelId, into: &buf) + FfiConverterOptionString.write(value.transferTxId, into: &buf) + FfiConverterOptionString.write(value.contact, into: &buf) + FfiConverterOptionUInt64.write(value.createdAt, into: &buf) + FfiConverterOptionUInt64.write(value.updatedAt, into: &buf) + FfiConverterOptionUInt64.write(value.seenAt, into: &buf) } } @@ -10066,139 +10425,94 @@ public struct FfiConverterTypeSingleAddressInfoResult: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeSingleAddressInfoResult_lift(_ buf: RustBuffer) throws -> SingleAddressInfoResult { - return try FfiConverterTypeSingleAddressInfoResult.lift(buf) +public func FfiConverterTypeOnchainActivity_lift(_ buf: RustBuffer) throws -> OnchainActivity { + return try FfiConverterTypeOnchainActivity.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeSingleAddressInfoResult_lower(_ value: SingleAddressInfoResult) -> RustBuffer { - return FfiConverterTypeSingleAddressInfoResult.lower(value) +public func FfiConverterTypeOnchainActivity_lower(_ value: OnchainActivity) -> RustBuffer { + return FfiConverterTypeOnchainActivity.lower(value) } /** - * Result of creating a submarine swap (onchain -> Lightning). - * - * The caller funds `address` with `expected_amount_sat` from its onchain - * wallet; Boltz then pays the Lightning invoice supplied at creation. + * One single-signature account in Passport's generic JSON export. */ -public struct SubmarineSwapResponse { - public var id: String - /** - * Onchain lockup address to send funds to. - */ - public var address: String - /** - * BIP21 URI for the lockup payment. - */ - public var bip21: String - /** - * Exact amount in satoshis the caller must send to `address`. - */ - public var expectedAmountSat: UInt64 +public struct PassportAccount { + public var accountType: AccountType /** - * Whether Boltz will accept a zero-conf lockup. + * Standard xpub/tpub encoding used by Passport's export. */ - public var acceptZeroConf: Bool + public var xpub: String /** - * Onchain timeout height after which a refund is possible. + * Account-level BIP32 path, such as `m/84'/0'/0'`. */ - public var timeoutBlockHeight: UInt64 + public var derivationPath: String // Default memberwise initializers are never public by default, so we // declare one manually. - public init(id: String, - /** - * Onchain lockup address to send funds to. - */address: String, - /** - * BIP21 URI for the lockup payment. - */bip21: String, - /** - * Exact amount in satoshis the caller must send to `address`. - */expectedAmountSat: UInt64, + public init(accountType: AccountType, /** - * Whether Boltz will accept a zero-conf lockup. - */acceptZeroConf: Bool, + * Standard xpub/tpub encoding used by Passport's export. + */xpub: String, /** - * Onchain timeout height after which a refund is possible. - */timeoutBlockHeight: UInt64) { - self.id = id - self.address = address - self.bip21 = bip21 - self.expectedAmountSat = expectedAmountSat - self.acceptZeroConf = acceptZeroConf - self.timeoutBlockHeight = timeoutBlockHeight + * Account-level BIP32 path, such as `m/84'/0'/0'`. + */derivationPath: String) { + self.accountType = accountType + self.xpub = xpub + self.derivationPath = derivationPath } } #if compiler(>=6) -extension SubmarineSwapResponse: Sendable {} +extension PassportAccount: Sendable {} #endif -extension SubmarineSwapResponse: Equatable, Hashable { - public static func ==(lhs: SubmarineSwapResponse, rhs: SubmarineSwapResponse) -> Bool { - if lhs.id != rhs.id { - return false - } - if lhs.address != rhs.address { - return false - } - if lhs.bip21 != rhs.bip21 { - return false - } - if lhs.expectedAmountSat != rhs.expectedAmountSat { +extension PassportAccount: Equatable, Hashable { + public static func ==(lhs: PassportAccount, rhs: PassportAccount) -> Bool { + if lhs.accountType != rhs.accountType { return false } - if lhs.acceptZeroConf != rhs.acceptZeroConf { + if lhs.xpub != rhs.xpub { return false } - if lhs.timeoutBlockHeight != rhs.timeoutBlockHeight { + if lhs.derivationPath != rhs.derivationPath { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(id) - hasher.combine(address) - hasher.combine(bip21) - hasher.combine(expectedAmountSat) - hasher.combine(acceptZeroConf) - hasher.combine(timeoutBlockHeight) + hasher.combine(accountType) + hasher.combine(xpub) + hasher.combine(derivationPath) } } -extension SubmarineSwapResponse: Codable {} +extension PassportAccount: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeSubmarineSwapResponse: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SubmarineSwapResponse { +public struct FfiConverterTypePassportAccount: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> PassportAccount { return - try SubmarineSwapResponse( - id: FfiConverterString.read(from: &buf), - address: FfiConverterString.read(from: &buf), - bip21: FfiConverterString.read(from: &buf), - expectedAmountSat: FfiConverterUInt64.read(from: &buf), - acceptZeroConf: FfiConverterBool.read(from: &buf), - timeoutBlockHeight: FfiConverterUInt64.read(from: &buf) + try PassportAccount( + accountType: FfiConverterTypeAccountType.read(from: &buf), + xpub: FfiConverterString.read(from: &buf), + derivationPath: FfiConverterString.read(from: &buf) ) } - public static func write(_ value: SubmarineSwapResponse, into buf: inout [UInt8]) { - FfiConverterString.write(value.id, into: &buf) - FfiConverterString.write(value.address, into: &buf) - FfiConverterString.write(value.bip21, into: &buf) - FfiConverterUInt64.write(value.expectedAmountSat, into: &buf) - FfiConverterBool.write(value.acceptZeroConf, into: &buf) - FfiConverterUInt64.write(value.timeoutBlockHeight, into: &buf) + public static func write(_ value: PassportAccount, into buf: inout [UInt8]) { + FfiConverterTypeAccountType.write(value.accountType, into: &buf) + FfiConverterString.write(value.xpub, into: &buf) + FfiConverterString.write(value.derivationPath, into: &buf) } } @@ -10206,122 +10520,88 @@ public struct FfiConverterTypeSubmarineSwapResponse: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeSubmarineSwapResponse_lift(_ buf: RustBuffer) throws -> SubmarineSwapResponse { - return try FfiConverterTypeSubmarineSwapResponse.lift(buf) +public func FfiConverterTypePassportAccount_lift(_ buf: RustBuffer) throws -> PassportAccount { + return try FfiConverterTypePassportAccount.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeSubmarineSwapResponse_lower(_ value: SubmarineSwapResponse) -> RustBuffer { - return FfiConverterTypeSubmarineSwapResponse.lower(value) +public func FfiConverterTypePassportAccount_lower(_ value: PassportAccount) -> RustBuffer { + return FfiConverterTypePassportAccount.lower(value) } /** - * A hardware-wallet model Bitkit supports. + * The single-signature accounts exported by Passport for one account index. */ -public struct SupportedHardwareWallet { - public var vendor: HardwareWalletVendor - /** - * Human-readable manufacturer name, e.g. "Foundation". - */ - public var vendorName: String - /** - * Stable model identifier that applications can map to bundled assets. - */ - public var model: String - /** - * Full user-facing name. - */ - public var displayName: String +public struct PassportAccountExport { /** - * Transports over which the application can interact with this model. + * Root fingerprint used in descriptors and PSBT key origins. */ - public var transports: [HardwareWalletTransport] + public var masterFingerprint: String + public var accountIndex: UInt32 + public var accounts: [PassportAccount] // Default memberwise initializers are never public by default, so we // declare one manually. - public init(vendor: HardwareWalletVendor, - /** - * Human-readable manufacturer name, e.g. "Foundation". - */vendorName: String, - /** - * Stable model identifier that applications can map to bundled assets. - */model: String, - /** - * Full user-facing name. - */displayName: String, + public init( /** - * Transports over which the application can interact with this model. - */transports: [HardwareWalletTransport]) { - self.vendor = vendor - self.vendorName = vendorName - self.model = model - self.displayName = displayName - self.transports = transports + * Root fingerprint used in descriptors and PSBT key origins. + */masterFingerprint: String, accountIndex: UInt32, accounts: [PassportAccount]) { + self.masterFingerprint = masterFingerprint + self.accountIndex = accountIndex + self.accounts = accounts } } #if compiler(>=6) -extension SupportedHardwareWallet: Sendable {} +extension PassportAccountExport: Sendable {} #endif -extension SupportedHardwareWallet: Equatable, Hashable { - public static func ==(lhs: SupportedHardwareWallet, rhs: SupportedHardwareWallet) -> Bool { - if lhs.vendor != rhs.vendor { - return false - } - if lhs.vendorName != rhs.vendorName { - return false - } - if lhs.model != rhs.model { +extension PassportAccountExport: Equatable, Hashable { + public static func ==(lhs: PassportAccountExport, rhs: PassportAccountExport) -> Bool { + if lhs.masterFingerprint != rhs.masterFingerprint { return false } - if lhs.displayName != rhs.displayName { + if lhs.accountIndex != rhs.accountIndex { return false } - if lhs.transports != rhs.transports { + if lhs.accounts != rhs.accounts { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(vendor) - hasher.combine(vendorName) - hasher.combine(model) - hasher.combine(displayName) - hasher.combine(transports) + hasher.combine(masterFingerprint) + hasher.combine(accountIndex) + hasher.combine(accounts) } } -extension SupportedHardwareWallet: Codable {} +extension PassportAccountExport: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeSupportedHardwareWallet: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SupportedHardwareWallet { +public struct FfiConverterTypePassportAccountExport: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> PassportAccountExport { return - try SupportedHardwareWallet( - vendor: FfiConverterTypeHardwareWalletVendor.read(from: &buf), - vendorName: FfiConverterString.read(from: &buf), - model: FfiConverterString.read(from: &buf), - displayName: FfiConverterString.read(from: &buf), - transports: FfiConverterSequenceTypeHardwareWalletTransport.read(from: &buf) + try PassportAccountExport( + masterFingerprint: FfiConverterString.read(from: &buf), + accountIndex: FfiConverterUInt32.read(from: &buf), + accounts: FfiConverterSequenceTypePassportAccount.read(from: &buf) ) } - public static func write(_ value: SupportedHardwareWallet, into buf: inout [UInt8]) { - FfiConverterTypeHardwareWalletVendor.write(value.vendor, into: &buf) - FfiConverterString.write(value.vendorName, into: &buf) - FfiConverterString.write(value.model, into: &buf) - FfiConverterString.write(value.displayName, into: &buf) - FfiConverterSequenceTypeHardwareWalletTransport.write(value.transports, into: &buf) + public static func write(_ value: PassportAccountExport, into buf: inout [UInt8]) { + FfiConverterString.write(value.masterFingerprint, into: &buf) + FfiConverterUInt32.write(value.accountIndex, into: &buf) + FfiConverterSequenceTypePassportAccount.write(value.accounts, into: &buf) } } @@ -10329,111 +10609,143 @@ public struct FfiConverterTypeSupportedHardwareWallet: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeSupportedHardwareWallet_lift(_ buf: RustBuffer) throws -> SupportedHardwareWallet { - return try FfiConverterTypeSupportedHardwareWallet.lift(buf) +public func FfiConverterTypePassportAccountExport_lift(_ buf: RustBuffer) throws -> PassportAccountExport { + return try FfiConverterTypePassportAccountExport.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeSupportedHardwareWallet_lower(_ value: SupportedHardwareWallet) -> RustBuffer { - return FfiConverterTypeSupportedHardwareWallet.lower(value) +public func FfiConverterTypePassportAccountExport_lower(_ value: PassportAccountExport) -> RustBuffer { + return FfiConverterTypePassportAccountExport.lower(value) } -public struct SweepResult { - /** - * The transaction ID of the sweep transaction - */ - public var txid: String - /** - * The total amount swept (in satoshis) - */ - public var amountSwept: UInt64 - /** - * The fee paid (in satoshis) - */ - public var feePaid: UInt64 - /** - * The number of UTXOs swept - */ - public var utxosSwept: UInt32 +public struct PreActivityMetadata { + public var walletId: String + public var paymentId: String + public var tags: [String] + public var paymentHash: String? + public var txId: String? + public var address: String? + public var isReceive: Bool + public var feeRate: UInt64 + public var isTransfer: Bool + public var channelId: String? + public var createdAt: UInt64 // Default memberwise initializers are never public by default, so we // declare one manually. - public init( - /** - * The transaction ID of the sweep transaction - */txid: String, - /** - * The total amount swept (in satoshis) - */amountSwept: UInt64, - /** - * The fee paid (in satoshis) - */feePaid: UInt64, - /** - * The number of UTXOs swept - */utxosSwept: UInt32) { - self.txid = txid - self.amountSwept = amountSwept - self.feePaid = feePaid - self.utxosSwept = utxosSwept + public init(walletId: String, paymentId: String, tags: [String], paymentHash: String?, txId: String?, address: String?, isReceive: Bool, feeRate: UInt64, isTransfer: Bool, channelId: String?, createdAt: UInt64) { + self.walletId = walletId + self.paymentId = paymentId + self.tags = tags + self.paymentHash = paymentHash + self.txId = txId + self.address = address + self.isReceive = isReceive + self.feeRate = feeRate + self.isTransfer = isTransfer + self.channelId = channelId + self.createdAt = createdAt } } #if compiler(>=6) -extension SweepResult: Sendable {} +extension PreActivityMetadata: Sendable {} #endif -extension SweepResult: Equatable, Hashable { - public static func ==(lhs: SweepResult, rhs: SweepResult) -> Bool { - if lhs.txid != rhs.txid { +extension PreActivityMetadata: Equatable, Hashable { + public static func ==(lhs: PreActivityMetadata, rhs: PreActivityMetadata) -> Bool { + if lhs.walletId != rhs.walletId { return false } - if lhs.amountSwept != rhs.amountSwept { + if lhs.paymentId != rhs.paymentId { return false } - if lhs.feePaid != rhs.feePaid { + if lhs.tags != rhs.tags { return false } - if lhs.utxosSwept != rhs.utxosSwept { + if lhs.paymentHash != rhs.paymentHash { return false } - return true - } - - public func hash(into hasher: inout Hasher) { - hasher.combine(txid) - hasher.combine(amountSwept) - hasher.combine(feePaid) - hasher.combine(utxosSwept) + if lhs.txId != rhs.txId { + return false + } + if lhs.address != rhs.address { + return false + } + if lhs.isReceive != rhs.isReceive { + return false + } + if lhs.feeRate != rhs.feeRate { + return false + } + if lhs.isTransfer != rhs.isTransfer { + return false + } + if lhs.channelId != rhs.channelId { + return false + } + if lhs.createdAt != rhs.createdAt { + return false + } + return true + } + + public func hash(into hasher: inout Hasher) { + hasher.combine(walletId) + hasher.combine(paymentId) + hasher.combine(tags) + hasher.combine(paymentHash) + hasher.combine(txId) + hasher.combine(address) + hasher.combine(isReceive) + hasher.combine(feeRate) + hasher.combine(isTransfer) + hasher.combine(channelId) + hasher.combine(createdAt) } } -extension SweepResult: Codable {} +extension PreActivityMetadata: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeSweepResult: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SweepResult { +public struct FfiConverterTypePreActivityMetadata: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> PreActivityMetadata { return - try SweepResult( - txid: FfiConverterString.read(from: &buf), - amountSwept: FfiConverterUInt64.read(from: &buf), - feePaid: FfiConverterUInt64.read(from: &buf), - utxosSwept: FfiConverterUInt32.read(from: &buf) + try PreActivityMetadata( + walletId: FfiConverterString.read(from: &buf), + paymentId: FfiConverterString.read(from: &buf), + tags: FfiConverterSequenceString.read(from: &buf), + paymentHash: FfiConverterOptionString.read(from: &buf), + txId: FfiConverterOptionString.read(from: &buf), + address: FfiConverterOptionString.read(from: &buf), + isReceive: FfiConverterBool.read(from: &buf), + feeRate: FfiConverterUInt64.read(from: &buf), + isTransfer: FfiConverterBool.read(from: &buf), + channelId: FfiConverterOptionString.read(from: &buf), + createdAt: FfiConverterUInt64.read(from: &buf) ) } - public static func write(_ value: SweepResult, into buf: inout [UInt8]) { - FfiConverterString.write(value.txid, into: &buf) - FfiConverterUInt64.write(value.amountSwept, into: &buf) - FfiConverterUInt64.write(value.feePaid, into: &buf) - FfiConverterUInt32.write(value.utxosSwept, into: &buf) + public static func write(_ value: PreActivityMetadata, into buf: inout [UInt8]) { + FfiConverterString.write(value.walletId, into: &buf) + FfiConverterString.write(value.paymentId, into: &buf) + FfiConverterSequenceString.write(value.tags, into: &buf) + FfiConverterOptionString.write(value.paymentHash, into: &buf) + FfiConverterOptionString.write(value.txId, into: &buf) + FfiConverterOptionString.write(value.address, into: &buf) + FfiConverterBool.write(value.isReceive, into: &buf) + FfiConverterUInt64.write(value.feeRate, into: &buf) + FfiConverterBool.write(value.isTransfer, into: &buf) + FfiConverterOptionString.write(value.channelId, into: &buf) + FfiConverterUInt64.write(value.createdAt, into: &buf) } } @@ -10441,153 +10753,63 @@ public struct FfiConverterTypeSweepResult: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeSweepResult_lift(_ buf: RustBuffer) throws -> SweepResult { - return try FfiConverterTypeSweepResult.lift(buf) +public func FfiConverterTypePreActivityMetadata_lift(_ buf: RustBuffer) throws -> PreActivityMetadata { + return try FfiConverterTypePreActivityMetadata.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeSweepResult_lower(_ value: SweepResult) -> RustBuffer { - return FfiConverterTypeSweepResult.lower(value) +public func FfiConverterTypePreActivityMetadata_lower(_ value: PreActivityMetadata) -> RustBuffer { + return FfiConverterTypePreActivityMetadata.lower(value) } -public struct SweepTransactionPreview { - /** - * The PSBT (Partially Signed Bitcoin Transaction) in base64 format - */ - public var psbt: String - /** - * The total amount available to sweep (in satoshis) - */ - public var totalAmount: UInt64 - /** - * The estimated fee for the transaction (in satoshis) - */ - public var estimatedFee: UInt64 - /** - * The estimated virtual size of the transaction (in vbytes) - */ - public var estimatedVsize: UInt64 - /** - * The number of UTXOs that will be swept - */ - public var utxosCount: UInt32 - /** - * The destination address - */ - public var destinationAddress: String - /** - * The amount that will be sent to destination after fees (in satoshis) - */ - public var amountAfterFees: UInt64 +public struct PubkyAuth { + public var data: String // Default memberwise initializers are never public by default, so we // declare one manually. - public init( - /** - * The PSBT (Partially Signed Bitcoin Transaction) in base64 format - */psbt: String, - /** - * The total amount available to sweep (in satoshis) - */totalAmount: UInt64, - /** - * The estimated fee for the transaction (in satoshis) - */estimatedFee: UInt64, - /** - * The estimated virtual size of the transaction (in vbytes) - */estimatedVsize: UInt64, - /** - * The number of UTXOs that will be swept - */utxosCount: UInt32, - /** - * The destination address - */destinationAddress: String, - /** - * The amount that will be sent to destination after fees (in satoshis) - */amountAfterFees: UInt64) { - self.psbt = psbt - self.totalAmount = totalAmount - self.estimatedFee = estimatedFee - self.estimatedVsize = estimatedVsize - self.utxosCount = utxosCount - self.destinationAddress = destinationAddress - self.amountAfterFees = amountAfterFees + public init(data: String) { + self.data = data } } #if compiler(>=6) -extension SweepTransactionPreview: Sendable {} +extension PubkyAuth: Sendable {} #endif -extension SweepTransactionPreview: Equatable, Hashable { - public static func ==(lhs: SweepTransactionPreview, rhs: SweepTransactionPreview) -> Bool { - if lhs.psbt != rhs.psbt { - return false - } - if lhs.totalAmount != rhs.totalAmount { - return false - } - if lhs.estimatedFee != rhs.estimatedFee { - return false - } - if lhs.estimatedVsize != rhs.estimatedVsize { - return false - } - if lhs.utxosCount != rhs.utxosCount { - return false - } - if lhs.destinationAddress != rhs.destinationAddress { - return false - } - if lhs.amountAfterFees != rhs.amountAfterFees { +extension PubkyAuth: Equatable, Hashable { + public static func ==(lhs: PubkyAuth, rhs: PubkyAuth) -> Bool { + if lhs.data != rhs.data { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(psbt) - hasher.combine(totalAmount) - hasher.combine(estimatedFee) - hasher.combine(estimatedVsize) - hasher.combine(utxosCount) - hasher.combine(destinationAddress) - hasher.combine(amountAfterFees) + hasher.combine(data) } } -extension SweepTransactionPreview: Codable {} +extension PubkyAuth: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeSweepTransactionPreview: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SweepTransactionPreview { +public struct FfiConverterTypePubkyAuth: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> PubkyAuth { return - try SweepTransactionPreview( - psbt: FfiConverterString.read(from: &buf), - totalAmount: FfiConverterUInt64.read(from: &buf), - estimatedFee: FfiConverterUInt64.read(from: &buf), - estimatedVsize: FfiConverterUInt64.read(from: &buf), - utxosCount: FfiConverterUInt32.read(from: &buf), - destinationAddress: FfiConverterString.read(from: &buf), - amountAfterFees: FfiConverterUInt64.read(from: &buf) + try PubkyAuth( + data: FfiConverterString.read(from: &buf) ) } - public static func write(_ value: SweepTransactionPreview, into buf: inout [UInt8]) { - FfiConverterString.write(value.psbt, into: &buf) - FfiConverterUInt64.write(value.totalAmount, into: &buf) - FfiConverterUInt64.write(value.estimatedFee, into: &buf) - FfiConverterUInt64.write(value.estimatedVsize, into: &buf) - FfiConverterUInt32.write(value.utxosCount, into: &buf) - FfiConverterString.write(value.destinationAddress, into: &buf) - FfiConverterUInt64.write(value.amountAfterFees, into: &buf) + public static func write(_ value: PubkyAuth, into buf: inout [UInt8]) { + FfiConverterString.write(value.data, into: &buf) } } @@ -10595,167 +10817,224 @@ public struct FfiConverterTypeSweepTransactionPreview: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeSweepTransactionPreview_lift(_ buf: RustBuffer) throws -> SweepTransactionPreview { - return try FfiConverterTypeSweepTransactionPreview.lift(buf) +public func FfiConverterTypePubkyAuth_lift(_ buf: RustBuffer) throws -> PubkyAuth { + return try FfiConverterTypePubkyAuth.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeSweepTransactionPreview_lower(_ value: SweepTransactionPreview) -> RustBuffer { - return FfiConverterTypeSweepTransactionPreview.lower(value) +public func FfiConverterTypePubkyAuth_lower(_ value: PubkyAuth) -> RustBuffer { + return FfiConverterTypePubkyAuth.lower(value) } -public struct SweepableBalances { - /** - * Balance in legacy (P2PKH) addresses (in satoshis) - */ - public var legacyBalance: UInt64 - /** - * Balance in P2SH-SegWit (P2SH-P2WPKH) addresses (in satoshis) - */ - public var p2shBalance: UInt64 - /** - * Balance in Taproot (P2TR) addresses (in satoshis) - */ - public var taprootBalance: UInt64 +/** + * Details extracted from a `pubkyauth://` deep-link URL. + */ +public struct PubkyAuthDetails { /** - * Total balance across all wallet types (in satoshis) + * Whether this is a signin or signup flow. */ - public var totalBalance: UInt64 + public var kind: PubkyAuthKind /** - * Number of UTXOs in legacy wallet + * Requested capabilities (e.g. `"/pub/pubky.app/:rw"`). */ - public var legacyUtxosCount: UInt32 + public var capabilities: String /** - * Number of UTXOs in P2SH-SegWit wallet + * Relay URL used for the auth exchange. */ - public var p2shUtxosCount: UInt32 + public var relay: String /** - * Number of UTXOs in Taproot wallet + * Homeserver public key (z32-encoded). Present only for signup flows. */ - public var taprootUtxosCount: UInt32 + public var homeserver: String? /** - * Total number of UTXOs across all wallet types + * Signup token. Present only for signup flows. */ - public var totalUtxosCount: UInt32 + public var signupToken: String? // Default memberwise initializers are never public by default, so we // declare one manually. public init( /** - * Balance in legacy (P2PKH) addresses (in satoshis) - */legacyBalance: UInt64, - /** - * Balance in P2SH-SegWit (P2SH-P2WPKH) addresses (in satoshis) - */p2shBalance: UInt64, - /** - * Balance in Taproot (P2TR) addresses (in satoshis) - */taprootBalance: UInt64, - /** - * Total balance across all wallet types (in satoshis) - */totalBalance: UInt64, + * Whether this is a signin or signup flow. + */kind: PubkyAuthKind, /** - * Number of UTXOs in legacy wallet - */legacyUtxosCount: UInt32, + * Requested capabilities (e.g. `"/pub/pubky.app/:rw"`). + */capabilities: String, /** - * Number of UTXOs in P2SH-SegWit wallet - */p2shUtxosCount: UInt32, + * Relay URL used for the auth exchange. + */relay: String, /** - * Number of UTXOs in Taproot wallet - */taprootUtxosCount: UInt32, + * Homeserver public key (z32-encoded). Present only for signup flows. + */homeserver: String?, /** - * Total number of UTXOs across all wallet types - */totalUtxosCount: UInt32) { - self.legacyBalance = legacyBalance - self.p2shBalance = p2shBalance - self.taprootBalance = taprootBalance - self.totalBalance = totalBalance - self.legacyUtxosCount = legacyUtxosCount - self.p2shUtxosCount = p2shUtxosCount - self.taprootUtxosCount = taprootUtxosCount - self.totalUtxosCount = totalUtxosCount + * Signup token. Present only for signup flows. + */signupToken: String?) { + self.kind = kind + self.capabilities = capabilities + self.relay = relay + self.homeserver = homeserver + self.signupToken = signupToken } } #if compiler(>=6) -extension SweepableBalances: Sendable {} +extension PubkyAuthDetails: Sendable {} #endif -extension SweepableBalances: Equatable, Hashable { - public static func ==(lhs: SweepableBalances, rhs: SweepableBalances) -> Bool { - if lhs.legacyBalance != rhs.legacyBalance { +extension PubkyAuthDetails: Equatable, Hashable { + public static func ==(lhs: PubkyAuthDetails, rhs: PubkyAuthDetails) -> Bool { + if lhs.kind != rhs.kind { return false } - if lhs.p2shBalance != rhs.p2shBalance { + if lhs.capabilities != rhs.capabilities { return false } - if lhs.taprootBalance != rhs.taprootBalance { + if lhs.relay != rhs.relay { return false } - if lhs.totalBalance != rhs.totalBalance { + if lhs.homeserver != rhs.homeserver { return false } - if lhs.legacyUtxosCount != rhs.legacyUtxosCount { + if lhs.signupToken != rhs.signupToken { return false } - if lhs.p2shUtxosCount != rhs.p2shUtxosCount { + return true + } + + public func hash(into hasher: inout Hasher) { + hasher.combine(kind) + hasher.combine(capabilities) + hasher.combine(relay) + hasher.combine(homeserver) + hasher.combine(signupToken) + } +} + +extension PubkyAuthDetails: Codable {} + + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypePubkyAuthDetails: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> PubkyAuthDetails { + return + try PubkyAuthDetails( + kind: FfiConverterTypePubkyAuthKind.read(from: &buf), + capabilities: FfiConverterString.read(from: &buf), + relay: FfiConverterString.read(from: &buf), + homeserver: FfiConverterOptionString.read(from: &buf), + signupToken: FfiConverterOptionString.read(from: &buf) + ) + } + + public static func write(_ value: PubkyAuthDetails, into buf: inout [UInt8]) { + FfiConverterTypePubkyAuthKind.write(value.kind, into: &buf) + FfiConverterString.write(value.capabilities, into: &buf) + FfiConverterString.write(value.relay, into: &buf) + FfiConverterOptionString.write(value.homeserver, into: &buf) + FfiConverterOptionString.write(value.signupToken, into: &buf) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypePubkyAuthDetails_lift(_ buf: RustBuffer) throws -> PubkyAuthDetails { + return try FfiConverterTypePubkyAuthDetails.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypePubkyAuthDetails_lower(_ value: PubkyAuthDetails) -> RustBuffer { + return FfiConverterTypePubkyAuthDetails.lower(value) +} + + +public struct PubkyProfile { + public var name: String + public var bio: String? + public var image: String? + public var links: [PubkyProfileLink]? + public var status: String? + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init(name: String, bio: String?, image: String?, links: [PubkyProfileLink]?, status: String?) { + self.name = name + self.bio = bio + self.image = image + self.links = links + self.status = status + } +} + +#if compiler(>=6) +extension PubkyProfile: Sendable {} +#endif + + +extension PubkyProfile: Equatable, Hashable { + public static func ==(lhs: PubkyProfile, rhs: PubkyProfile) -> Bool { + if lhs.name != rhs.name { return false } - if lhs.taprootUtxosCount != rhs.taprootUtxosCount { + if lhs.bio != rhs.bio { return false } - if lhs.totalUtxosCount != rhs.totalUtxosCount { + if lhs.image != rhs.image { + return false + } + if lhs.links != rhs.links { + return false + } + if lhs.status != rhs.status { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(legacyBalance) - hasher.combine(p2shBalance) - hasher.combine(taprootBalance) - hasher.combine(totalBalance) - hasher.combine(legacyUtxosCount) - hasher.combine(p2shUtxosCount) - hasher.combine(taprootUtxosCount) - hasher.combine(totalUtxosCount) + hasher.combine(name) + hasher.combine(bio) + hasher.combine(image) + hasher.combine(links) + hasher.combine(status) } } -extension SweepableBalances: Codable {} +extension PubkyProfile: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeSweepableBalances: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SweepableBalances { +public struct FfiConverterTypePubkyProfile: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> PubkyProfile { return - try SweepableBalances( - legacyBalance: FfiConverterUInt64.read(from: &buf), - p2shBalance: FfiConverterUInt64.read(from: &buf), - taprootBalance: FfiConverterUInt64.read(from: &buf), - totalBalance: FfiConverterUInt64.read(from: &buf), - legacyUtxosCount: FfiConverterUInt32.read(from: &buf), - p2shUtxosCount: FfiConverterUInt32.read(from: &buf), - taprootUtxosCount: FfiConverterUInt32.read(from: &buf), - totalUtxosCount: FfiConverterUInt32.read(from: &buf) + try PubkyProfile( + name: FfiConverterString.read(from: &buf), + bio: FfiConverterOptionString.read(from: &buf), + image: FfiConverterOptionString.read(from: &buf), + links: FfiConverterOptionSequenceTypePubkyProfileLink.read(from: &buf), + status: FfiConverterOptionString.read(from: &buf) ) } - public static func write(_ value: SweepableBalances, into buf: inout [UInt8]) { - FfiConverterUInt64.write(value.legacyBalance, into: &buf) - FfiConverterUInt64.write(value.p2shBalance, into: &buf) - FfiConverterUInt64.write(value.taprootBalance, into: &buf) - FfiConverterUInt64.write(value.totalBalance, into: &buf) - FfiConverterUInt32.write(value.legacyUtxosCount, into: &buf) - FfiConverterUInt32.write(value.p2shUtxosCount, into: &buf) - FfiConverterUInt32.write(value.taprootUtxosCount, into: &buf) - FfiConverterUInt32.write(value.totalUtxosCount, into: &buf) + public static func write(_ value: PubkyProfile, into buf: inout [UInt8]) { + FfiConverterString.write(value.name, into: &buf) + FfiConverterOptionString.write(value.bio, into: &buf) + FfiConverterOptionString.write(value.image, into: &buf) + FfiConverterOptionSequenceTypePubkyProfileLink.write(value.links, into: &buf) + FfiConverterOptionString.write(value.status, into: &buf) } } @@ -10763,282 +11042,71 @@ public struct FfiConverterTypeSweepableBalances: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeSweepableBalances_lift(_ buf: RustBuffer) throws -> SweepableBalances { - return try FfiConverterTypeSweepableBalances.lift(buf) +public func FfiConverterTypePubkyProfile_lift(_ buf: RustBuffer) throws -> PubkyProfile { + return try FfiConverterTypePubkyProfile.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeSweepableBalances_lower(_ value: SweepableBalances) -> RustBuffer { - return FfiConverterTypeSweepableBalances.lower(value) +public func FfiConverterTypePubkyProfile_lower(_ value: PubkyProfile) -> RustBuffer { + return FfiConverterTypePubkyProfile.lower(value) } -/** - * Full details for a single transaction, including raw inputs/outputs and size metrics. - */ -public struct TransactionDetail { - /** - * Transaction ID (hex) - */ - public var txid: String - /** - * Amount received by the wallet (sats) - */ - public var received: UInt64 - /** - * Amount sent by the wallet (sats) — includes change sent back to self - */ - public var sent: UInt64 - /** - * Net value from wallet's perspective: received - sent (positive = inflow, negative = outflow) - */ - public var net: Int64 - /** - * Display amount in sats (same semantics as HistoryTransaction.amount) - */ - public var amount: UInt64 - /** - * Transaction fee in sats (None if not available) - */ - public var fee: UInt64? - /** - * Transaction direction - */ - public var direction: TxDirection - /** - * Block height (None if unconfirmed/mempool) - */ - public var blockHeight: UInt32? - /** - * Block timestamp as unix epoch seconds (None if unconfirmed) - */ - public var timestamp: UInt64? - /** - * Number of confirmations (0 if unconfirmed) - */ - public var confirmations: UInt32 - /** - * Transaction inputs - */ - public var inputs: [TxDetailInput] - /** - * Transaction outputs - */ - public var outputs: [TxDetailOutput] - /** - * Serialized transaction size in bytes - */ - public var size: UInt32 - /** - * Virtual size in vbytes (ceil(weight / 4)) - */ - public var vsize: UInt32 - /** - * Transaction weight in weight units - */ - public var weight: UInt32 - /** - * Fee rate in sat/vB (fee / vsize), None if fee is unavailable or vsize is zero - */ - public var feeRate: Double? +public struct PubkyProfileLink { + public var title: String + public var url: String // Default memberwise initializers are never public by default, so we // declare one manually. - public init( - /** - * Transaction ID (hex) - */txid: String, - /** - * Amount received by the wallet (sats) - */received: UInt64, - /** - * Amount sent by the wallet (sats) — includes change sent back to self - */sent: UInt64, - /** - * Net value from wallet's perspective: received - sent (positive = inflow, negative = outflow) - */net: Int64, - /** - * Display amount in sats (same semantics as HistoryTransaction.amount) - */amount: UInt64, - /** - * Transaction fee in sats (None if not available) - */fee: UInt64?, - /** - * Transaction direction - */direction: TxDirection, - /** - * Block height (None if unconfirmed/mempool) - */blockHeight: UInt32?, - /** - * Block timestamp as unix epoch seconds (None if unconfirmed) - */timestamp: UInt64?, - /** - * Number of confirmations (0 if unconfirmed) - */confirmations: UInt32, - /** - * Transaction inputs - */inputs: [TxDetailInput], - /** - * Transaction outputs - */outputs: [TxDetailOutput], - /** - * Serialized transaction size in bytes - */size: UInt32, - /** - * Virtual size in vbytes (ceil(weight / 4)) - */vsize: UInt32, - /** - * Transaction weight in weight units - */weight: UInt32, - /** - * Fee rate in sat/vB (fee / vsize), None if fee is unavailable or vsize is zero - */feeRate: Double?) { - self.txid = txid - self.received = received - self.sent = sent - self.net = net - self.amount = amount - self.fee = fee - self.direction = direction - self.blockHeight = blockHeight - self.timestamp = timestamp - self.confirmations = confirmations - self.inputs = inputs - self.outputs = outputs - self.size = size - self.vsize = vsize - self.weight = weight - self.feeRate = feeRate + public init(title: String, url: String) { + self.title = title + self.url = url } } #if compiler(>=6) -extension TransactionDetail: Sendable {} +extension PubkyProfileLink: Sendable {} #endif -extension TransactionDetail: Equatable, Hashable { - public static func ==(lhs: TransactionDetail, rhs: TransactionDetail) -> Bool { - if lhs.txid != rhs.txid { - return false - } - if lhs.received != rhs.received { - return false - } - if lhs.sent != rhs.sent { - return false - } - if lhs.net != rhs.net { - return false - } - if lhs.amount != rhs.amount { - return false - } - if lhs.fee != rhs.fee { - return false - } - if lhs.direction != rhs.direction { - return false - } - if lhs.blockHeight != rhs.blockHeight { - return false - } - if lhs.timestamp != rhs.timestamp { - return false - } - if lhs.confirmations != rhs.confirmations { - return false - } - if lhs.inputs != rhs.inputs { - return false - } - if lhs.outputs != rhs.outputs { - return false - } - if lhs.size != rhs.size { - return false - } - if lhs.vsize != rhs.vsize { - return false - } - if lhs.weight != rhs.weight { +extension PubkyProfileLink: Equatable, Hashable { + public static func ==(lhs: PubkyProfileLink, rhs: PubkyProfileLink) -> Bool { + if lhs.title != rhs.title { return false } - if lhs.feeRate != rhs.feeRate { + if lhs.url != rhs.url { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(txid) - hasher.combine(received) - hasher.combine(sent) - hasher.combine(net) - hasher.combine(amount) - hasher.combine(fee) - hasher.combine(direction) - hasher.combine(blockHeight) - hasher.combine(timestamp) - hasher.combine(confirmations) - hasher.combine(inputs) - hasher.combine(outputs) - hasher.combine(size) - hasher.combine(vsize) - hasher.combine(weight) - hasher.combine(feeRate) + hasher.combine(title) + hasher.combine(url) } } -extension TransactionDetail: Codable {} +extension PubkyProfileLink: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeTransactionDetail: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TransactionDetail { +public struct FfiConverterTypePubkyProfileLink: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> PubkyProfileLink { return - try TransactionDetail( - txid: FfiConverterString.read(from: &buf), - received: FfiConverterUInt64.read(from: &buf), - sent: FfiConverterUInt64.read(from: &buf), - net: FfiConverterInt64.read(from: &buf), - amount: FfiConverterUInt64.read(from: &buf), - fee: FfiConverterOptionUInt64.read(from: &buf), - direction: FfiConverterTypeTxDirection.read(from: &buf), - blockHeight: FfiConverterOptionUInt32.read(from: &buf), - timestamp: FfiConverterOptionUInt64.read(from: &buf), - confirmations: FfiConverterUInt32.read(from: &buf), - inputs: FfiConverterSequenceTypeTxDetailInput.read(from: &buf), - outputs: FfiConverterSequenceTypeTxDetailOutput.read(from: &buf), - size: FfiConverterUInt32.read(from: &buf), - vsize: FfiConverterUInt32.read(from: &buf), - weight: FfiConverterUInt32.read(from: &buf), - feeRate: FfiConverterOptionDouble.read(from: &buf) + try PubkyProfileLink( + title: FfiConverterString.read(from: &buf), + url: FfiConverterString.read(from: &buf) ) } - public static func write(_ value: TransactionDetail, into buf: inout [UInt8]) { - FfiConverterString.write(value.txid, into: &buf) - FfiConverterUInt64.write(value.received, into: &buf) - FfiConverterUInt64.write(value.sent, into: &buf) - FfiConverterInt64.write(value.net, into: &buf) - FfiConverterUInt64.write(value.amount, into: &buf) - FfiConverterOptionUInt64.write(value.fee, into: &buf) - FfiConverterTypeTxDirection.write(value.direction, into: &buf) - FfiConverterOptionUInt32.write(value.blockHeight, into: &buf) - FfiConverterOptionUInt64.write(value.timestamp, into: &buf) - FfiConverterUInt32.write(value.confirmations, into: &buf) - FfiConverterSequenceTypeTxDetailInput.write(value.inputs, into: &buf) - FfiConverterSequenceTypeTxDetailOutput.write(value.outputs, into: &buf) - FfiConverterUInt32.write(value.size, into: &buf) - FfiConverterUInt32.write(value.vsize, into: &buf) - FfiConverterUInt32.write(value.weight, into: &buf) - FfiConverterOptionDouble.write(value.feeRate, into: &buf) + public static func write(_ value: PubkyProfileLink, into buf: inout [UInt8]) { + FfiConverterString.write(value.title, into: &buf) + FfiConverterString.write(value.url, into: &buf) } } @@ -11046,132 +11114,125 @@ public struct FfiConverterTypeTransactionDetail: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTransactionDetail_lift(_ buf: RustBuffer) throws -> TransactionDetail { - return try FfiConverterTypeTransactionDetail.lift(buf) +public func FfiConverterTypePubkyProfileLink_lift(_ buf: RustBuffer) throws -> PubkyProfileLink { + return try FfiConverterTypePubkyProfileLink.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTransactionDetail_lower(_ value: TransactionDetail) -> RustBuffer { - return FfiConverterTypeTransactionDetail.lower(value) +public func FfiConverterTypePubkyProfileLink_lower(_ value: PubkyProfileLink) -> RustBuffer { + return FfiConverterTypePubkyProfileLink.lower(value) } /** - * Details about an onchain transaction. + * Result of creating a reverse swap (Lightning -> onchain). + * + * The caller pays `invoice` from its Lightning node; once Boltz locks funds at + * `lockup_address`, the module claims them to the provided onchain address. */ -public struct TransactionDetails { - public var walletId: String +public struct ReverseSwapResponse { + public var id: String /** - * The transaction ID. + * Hold invoice the caller must pay via Lightning. */ - public var txId: String + public var invoice: String /** - * The net amount in this transaction (in satoshis). - * - * This is calculated as: (received - sent). For incoming payments, - * this will be positive. For outgoing payments, this will be negative. - * - * Note: This amount does NOT include transaction fees. + * Address Boltz locks the onchain funds to. */ - public var amountSats: Int64 + public var lockupAddress: String /** - * The transaction inputs with full details. + * Amount in satoshis that will be received onchain (after Boltz fees). */ - public var inputs: [TxInput] + public var onchainAmountSat: UInt64 /** - * The transaction outputs with full details. + * Onchain timeout height for the swap. */ - public var outputs: [TxOutput] + public var timeoutBlockHeight: UInt64 // Default memberwise initializers are never public by default, so we // declare one manually. - public init(walletId: String, + public init(id: String, /** - * The transaction ID. - */txId: String, + * Hold invoice the caller must pay via Lightning. + */invoice: String, /** - * The net amount in this transaction (in satoshis). - * - * This is calculated as: (received - sent). For incoming payments, - * this will be positive. For outgoing payments, this will be negative. - * - * Note: This amount does NOT include transaction fees. - */amountSats: Int64, + * Address Boltz locks the onchain funds to. + */lockupAddress: String, /** - * The transaction inputs with full details. - */inputs: [TxInput], + * Amount in satoshis that will be received onchain (after Boltz fees). + */onchainAmountSat: UInt64, /** - * The transaction outputs with full details. - */outputs: [TxOutput]) { - self.walletId = walletId - self.txId = txId - self.amountSats = amountSats - self.inputs = inputs - self.outputs = outputs + * Onchain timeout height for the swap. + */timeoutBlockHeight: UInt64) { + self.id = id + self.invoice = invoice + self.lockupAddress = lockupAddress + self.onchainAmountSat = onchainAmountSat + self.timeoutBlockHeight = timeoutBlockHeight } } #if compiler(>=6) -extension TransactionDetails: Sendable {} +extension ReverseSwapResponse: Sendable {} #endif -extension TransactionDetails: Equatable, Hashable { - public static func ==(lhs: TransactionDetails, rhs: TransactionDetails) -> Bool { - if lhs.walletId != rhs.walletId { +extension ReverseSwapResponse: Equatable, Hashable { + public static func ==(lhs: ReverseSwapResponse, rhs: ReverseSwapResponse) -> Bool { + if lhs.id != rhs.id { return false } - if lhs.txId != rhs.txId { + if lhs.invoice != rhs.invoice { return false } - if lhs.amountSats != rhs.amountSats { + if lhs.lockupAddress != rhs.lockupAddress { return false } - if lhs.inputs != rhs.inputs { + if lhs.onchainAmountSat != rhs.onchainAmountSat { return false } - if lhs.outputs != rhs.outputs { + if lhs.timeoutBlockHeight != rhs.timeoutBlockHeight { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(walletId) - hasher.combine(txId) - hasher.combine(amountSats) - hasher.combine(inputs) - hasher.combine(outputs) + hasher.combine(id) + hasher.combine(invoice) + hasher.combine(lockupAddress) + hasher.combine(onchainAmountSat) + hasher.combine(timeoutBlockHeight) } } -extension TransactionDetails: Codable {} +extension ReverseSwapResponse: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeTransactionDetails: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TransactionDetails { +public struct FfiConverterTypeReverseSwapResponse: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ReverseSwapResponse { return - try TransactionDetails( - walletId: FfiConverterString.read(from: &buf), - txId: FfiConverterString.read(from: &buf), - amountSats: FfiConverterInt64.read(from: &buf), - inputs: FfiConverterSequenceTypeTxInput.read(from: &buf), - outputs: FfiConverterSequenceTypeTxOutput.read(from: &buf) + try ReverseSwapResponse( + id: FfiConverterString.read(from: &buf), + invoice: FfiConverterString.read(from: &buf), + lockupAddress: FfiConverterString.read(from: &buf), + onchainAmountSat: FfiConverterUInt64.read(from: &buf), + timeoutBlockHeight: FfiConverterUInt64.read(from: &buf) ) } - public static func write(_ value: TransactionDetails, into buf: inout [UInt8]) { - FfiConverterString.write(value.walletId, into: &buf) - FfiConverterString.write(value.txId, into: &buf) - FfiConverterInt64.write(value.amountSats, into: &buf) - FfiConverterSequenceTypeTxInput.write(value.inputs, into: &buf) - FfiConverterSequenceTypeTxOutput.write(value.outputs, into: &buf) + public static func write(_ value: ReverseSwapResponse, into buf: inout [UInt8]) { + FfiConverterString.write(value.id, into: &buf) + FfiConverterString.write(value.invoice, into: &buf) + FfiConverterString.write(value.lockupAddress, into: &buf) + FfiConverterUInt64.write(value.onchainAmountSat, into: &buf) + FfiConverterUInt64.write(value.timeoutBlockHeight, into: &buf) } } @@ -11179,128 +11240,128 @@ public struct FfiConverterTypeTransactionDetails: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTransactionDetails_lift(_ buf: RustBuffer) throws -> TransactionDetails { - return try FfiConverterTypeTransactionDetails.lift(buf) +public func FfiConverterTypeReverseSwapResponse_lift(_ buf: RustBuffer) throws -> ReverseSwapResponse { + return try FfiConverterTypeReverseSwapResponse.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTransactionDetails_lower(_ value: TransactionDetails) -> RustBuffer { - return FfiConverterTypeTransactionDetails.lower(value) +public func FfiConverterTypeReverseSwapResponse_lower(_ value: ReverseSwapResponse) -> RustBuffer { + return FfiConverterTypeReverseSwapResponse.lower(value) } /** - * Result from querying transaction history for an xpub. + * Result from querying a single Bitcoin address. */ -public struct TransactionHistoryResult { +public struct SingleAddressInfoResult { /** - * All transactions, sorted: unconfirmed first, then by timestamp descending + * The queried address */ - public var transactions: [HistoryTransaction] + public var address: String /** - * Balance breakdown + * Total confirmed balance in satoshis */ - public var balance: WalletBalance + public var balance: UInt64 /** - * Total number of transactions + * UTXOs for this address */ - public var txCount: UInt32 + public var utxos: [AccountUtxo] /** - * Current blockchain tip height + * Number of transactions involving this address */ - public var blockHeight: UInt32 + public var transfers: UInt32 /** - * The detected or specified account type + * Current blockchain tip height */ - public var accountType: AccountType + public var blockHeight: UInt32 // Default memberwise initializers are never public by default, so we // declare one manually. public init( /** - * All transactions, sorted: unconfirmed first, then by timestamp descending - */transactions: [HistoryTransaction], + * The queried address + */address: String, /** - * Balance breakdown - */balance: WalletBalance, + * Total confirmed balance in satoshis + */balance: UInt64, /** - * Total number of transactions - */txCount: UInt32, + * UTXOs for this address + */utxos: [AccountUtxo], /** - * Current blockchain tip height - */blockHeight: UInt32, + * Number of transactions involving this address + */transfers: UInt32, /** - * The detected or specified account type - */accountType: AccountType) { - self.transactions = transactions + * Current blockchain tip height + */blockHeight: UInt32) { + self.address = address self.balance = balance - self.txCount = txCount + self.utxos = utxos + self.transfers = transfers self.blockHeight = blockHeight - self.accountType = accountType } } #if compiler(>=6) -extension TransactionHistoryResult: Sendable {} +extension SingleAddressInfoResult: Sendable {} #endif -extension TransactionHistoryResult: Equatable, Hashable { - public static func ==(lhs: TransactionHistoryResult, rhs: TransactionHistoryResult) -> Bool { - if lhs.transactions != rhs.transactions { +extension SingleAddressInfoResult: Equatable, Hashable { + public static func ==(lhs: SingleAddressInfoResult, rhs: SingleAddressInfoResult) -> Bool { + if lhs.address != rhs.address { return false } if lhs.balance != rhs.balance { return false } - if lhs.txCount != rhs.txCount { + if lhs.utxos != rhs.utxos { return false } - if lhs.blockHeight != rhs.blockHeight { + if lhs.transfers != rhs.transfers { return false } - if lhs.accountType != rhs.accountType { + if lhs.blockHeight != rhs.blockHeight { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(transactions) + hasher.combine(address) hasher.combine(balance) - hasher.combine(txCount) + hasher.combine(utxos) + hasher.combine(transfers) hasher.combine(blockHeight) - hasher.combine(accountType) } } -extension TransactionHistoryResult: Codable {} +extension SingleAddressInfoResult: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeTransactionHistoryResult: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TransactionHistoryResult { +public struct FfiConverterTypeSingleAddressInfoResult: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SingleAddressInfoResult { return - try TransactionHistoryResult( - transactions: FfiConverterSequenceTypeHistoryTransaction.read(from: &buf), - balance: FfiConverterTypeWalletBalance.read(from: &buf), - txCount: FfiConverterUInt32.read(from: &buf), - blockHeight: FfiConverterUInt32.read(from: &buf), - accountType: FfiConverterTypeAccountType.read(from: &buf) + try SingleAddressInfoResult( + address: FfiConverterString.read(from: &buf), + balance: FfiConverterUInt64.read(from: &buf), + utxos: FfiConverterSequenceTypeAccountUtxo.read(from: &buf), + transfers: FfiConverterUInt32.read(from: &buf), + blockHeight: FfiConverterUInt32.read(from: &buf) ) } - public static func write(_ value: TransactionHistoryResult, into buf: inout [UInt8]) { - FfiConverterSequenceTypeHistoryTransaction.write(value.transactions, into: &buf) - FfiConverterTypeWalletBalance.write(value.balance, into: &buf) - FfiConverterUInt32.write(value.txCount, into: &buf) + public static func write(_ value: SingleAddressInfoResult, into buf: inout [UInt8]) { + FfiConverterString.write(value.address, into: &buf) + FfiConverterUInt64.write(value.balance, into: &buf) + FfiConverterSequenceTypeAccountUtxo.write(value.utxos, into: &buf) + FfiConverterUInt32.write(value.transfers, into: &buf) FfiConverterUInt32.write(value.blockHeight, into: &buf) - FfiConverterTypeAccountType.write(value.accountType, into: &buf) } } @@ -11308,86 +11369,139 @@ public struct FfiConverterTypeTransactionHistoryResult: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTransactionHistoryResult_lift(_ buf: RustBuffer) throws -> TransactionHistoryResult { - return try FfiConverterTypeTransactionHistoryResult.lift(buf) +public func FfiConverterTypeSingleAddressInfoResult_lift(_ buf: RustBuffer) throws -> SingleAddressInfoResult { + return try FfiConverterTypeSingleAddressInfoResult.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTransactionHistoryResult_lower(_ value: TransactionHistoryResult) -> RustBuffer { - return FfiConverterTypeTransactionHistoryResult.lower(value) +public func FfiConverterTypeSingleAddressInfoResult_lower(_ value: SingleAddressInfoResult) -> RustBuffer { + return FfiConverterTypeSingleAddressInfoResult.lower(value) } /** - * Address response from device. + * Result of creating a submarine swap (onchain -> Lightning). + * + * The caller funds `address` with `expected_amount_sat` from its onchain + * wallet; Boltz then pays the Lightning invoice supplied at creation. */ -public struct TrezorAddressResponse { +public struct SubmarineSwapResponse { + public var id: String /** - * The Bitcoin address + * Onchain lockup address to send funds to. */ public var address: String /** - * The serialized path (e.g., "m/84'/0'/0'/0/0") + * BIP21 URI for the lockup payment. */ - public var path: String + public var bip21: String + /** + * Exact amount in satoshis the caller must send to `address`. + */ + public var expectedAmountSat: UInt64 + /** + * Whether Boltz will accept a zero-conf lockup. + */ + public var acceptZeroConf: Bool + /** + * Onchain timeout height after which a refund is possible. + */ + public var timeoutBlockHeight: UInt64 // Default memberwise initializers are never public by default, so we // declare one manually. - public init( + public init(id: String, /** - * The Bitcoin address + * Onchain lockup address to send funds to. */address: String, /** - * The serialized path (e.g., "m/84'/0'/0'/0/0") - */path: String) { + * BIP21 URI for the lockup payment. + */bip21: String, + /** + * Exact amount in satoshis the caller must send to `address`. + */expectedAmountSat: UInt64, + /** + * Whether Boltz will accept a zero-conf lockup. + */acceptZeroConf: Bool, + /** + * Onchain timeout height after which a refund is possible. + */timeoutBlockHeight: UInt64) { + self.id = id self.address = address - self.path = path + self.bip21 = bip21 + self.expectedAmountSat = expectedAmountSat + self.acceptZeroConf = acceptZeroConf + self.timeoutBlockHeight = timeoutBlockHeight } } #if compiler(>=6) -extension TrezorAddressResponse: Sendable {} +extension SubmarineSwapResponse: Sendable {} #endif -extension TrezorAddressResponse: Equatable, Hashable { - public static func ==(lhs: TrezorAddressResponse, rhs: TrezorAddressResponse) -> Bool { +extension SubmarineSwapResponse: Equatable, Hashable { + public static func ==(lhs: SubmarineSwapResponse, rhs: SubmarineSwapResponse) -> Bool { + if lhs.id != rhs.id { + return false + } if lhs.address != rhs.address { return false } - if lhs.path != rhs.path { + if lhs.bip21 != rhs.bip21 { return false } - return true - } - - public func hash(into hasher: inout Hasher) { - hasher.combine(address) - hasher.combine(path) + if lhs.expectedAmountSat != rhs.expectedAmountSat { + return false + } + if lhs.acceptZeroConf != rhs.acceptZeroConf { + return false + } + if lhs.timeoutBlockHeight != rhs.timeoutBlockHeight { + return false + } + return true + } + + public func hash(into hasher: inout Hasher) { + hasher.combine(id) + hasher.combine(address) + hasher.combine(bip21) + hasher.combine(expectedAmountSat) + hasher.combine(acceptZeroConf) + hasher.combine(timeoutBlockHeight) } } -extension TrezorAddressResponse: Codable {} +extension SubmarineSwapResponse: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeTrezorAddressResponse: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorAddressResponse { +public struct FfiConverterTypeSubmarineSwapResponse: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SubmarineSwapResponse { return - try TrezorAddressResponse( + try SubmarineSwapResponse( + id: FfiConverterString.read(from: &buf), address: FfiConverterString.read(from: &buf), - path: FfiConverterString.read(from: &buf) + bip21: FfiConverterString.read(from: &buf), + expectedAmountSat: FfiConverterUInt64.read(from: &buf), + acceptZeroConf: FfiConverterBool.read(from: &buf), + timeoutBlockHeight: FfiConverterUInt64.read(from: &buf) ) } - public static func write(_ value: TrezorAddressResponse, into buf: inout [UInt8]) { + public static func write(_ value: SubmarineSwapResponse, into buf: inout [UInt8]) { + FfiConverterString.write(value.id, into: &buf) FfiConverterString.write(value.address, into: &buf) - FfiConverterString.write(value.path, into: &buf) + FfiConverterString.write(value.bip21, into: &buf) + FfiConverterUInt64.write(value.expectedAmountSat, into: &buf) + FfiConverterBool.write(value.acceptZeroConf, into: &buf) + FfiConverterUInt64.write(value.timeoutBlockHeight, into: &buf) } } @@ -11395,128 +11509,122 @@ public struct FfiConverterTypeTrezorAddressResponse: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTrezorAddressResponse_lift(_ buf: RustBuffer) throws -> TrezorAddressResponse { - return try FfiConverterTypeTrezorAddressResponse.lift(buf) +public func FfiConverterTypeSubmarineSwapResponse_lift(_ buf: RustBuffer) throws -> SubmarineSwapResponse { + return try FfiConverterTypeSubmarineSwapResponse.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTrezorAddressResponse_lower(_ value: TrezorAddressResponse) -> RustBuffer { - return FfiConverterTypeTrezorAddressResponse.lower(value) +public func FfiConverterTypeSubmarineSwapResponse_lower(_ value: SubmarineSwapResponse) -> RustBuffer { + return FfiConverterTypeSubmarineSwapResponse.lower(value) } /** - * Result from a high-level message call (for BLE/THP devices) + * A hardware-wallet model Bitkit supports. */ -public struct TrezorCallMessageResult { - /** - * Whether the call succeeded - */ - public var success: Bool +public struct SupportedHardwareWallet { + public var vendor: HardwareWalletVendor /** - * Response message type + * Human-readable manufacturer name, e.g. "Foundation". */ - public var messageType: UInt16 + public var vendorName: String /** - * Response protobuf data + * Stable model identifier that applications can map to bundled assets. */ - public var data: Data + public var model: String /** - * Error message (empty on success) + * Full user-facing name. */ - public var error: String + public var displayName: String /** - * Structured error code (None on success or when the native error is generic) + * Transports over which the application can interact with this model. */ - public var errorCode: TrezorTransportErrorCode? + public var transports: [HardwareWalletTransport] // Default memberwise initializers are never public by default, so we // declare one manually. - public init( - /** - * Whether the call succeeded - */success: Bool, + public init(vendor: HardwareWalletVendor, /** - * Response message type - */messageType: UInt16, + * Human-readable manufacturer name, e.g. "Foundation". + */vendorName: String, /** - * Response protobuf data - */data: Data, + * Stable model identifier that applications can map to bundled assets. + */model: String, /** - * Error message (empty on success) - */error: String, + * Full user-facing name. + */displayName: String, /** - * Structured error code (None on success or when the native error is generic) - */errorCode: TrezorTransportErrorCode?) { - self.success = success - self.messageType = messageType - self.data = data - self.error = error - self.errorCode = errorCode + * Transports over which the application can interact with this model. + */transports: [HardwareWalletTransport]) { + self.vendor = vendor + self.vendorName = vendorName + self.model = model + self.displayName = displayName + self.transports = transports } } #if compiler(>=6) -extension TrezorCallMessageResult: Sendable {} +extension SupportedHardwareWallet: Sendable {} #endif -extension TrezorCallMessageResult: Equatable, Hashable { - public static func ==(lhs: TrezorCallMessageResult, rhs: TrezorCallMessageResult) -> Bool { - if lhs.success != rhs.success { +extension SupportedHardwareWallet: Equatable, Hashable { + public static func ==(lhs: SupportedHardwareWallet, rhs: SupportedHardwareWallet) -> Bool { + if lhs.vendor != rhs.vendor { return false } - if lhs.messageType != rhs.messageType { + if lhs.vendorName != rhs.vendorName { return false } - if lhs.data != rhs.data { + if lhs.model != rhs.model { return false } - if lhs.error != rhs.error { + if lhs.displayName != rhs.displayName { return false } - if lhs.errorCode != rhs.errorCode { + if lhs.transports != rhs.transports { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(success) - hasher.combine(messageType) - hasher.combine(data) - hasher.combine(error) - hasher.combine(errorCode) + hasher.combine(vendor) + hasher.combine(vendorName) + hasher.combine(model) + hasher.combine(displayName) + hasher.combine(transports) } } -extension TrezorCallMessageResult: Codable {} +extension SupportedHardwareWallet: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeTrezorCallMessageResult: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorCallMessageResult { +public struct FfiConverterTypeSupportedHardwareWallet: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SupportedHardwareWallet { return - try TrezorCallMessageResult( - success: FfiConverterBool.read(from: &buf), - messageType: FfiConverterUInt16.read(from: &buf), - data: FfiConverterData.read(from: &buf), - error: FfiConverterString.read(from: &buf), - errorCode: FfiConverterOptionTypeTrezorTransportErrorCode.read(from: &buf) + try SupportedHardwareWallet( + vendor: FfiConverterTypeHardwareWalletVendor.read(from: &buf), + vendorName: FfiConverterString.read(from: &buf), + model: FfiConverterString.read(from: &buf), + displayName: FfiConverterString.read(from: &buf), + transports: FfiConverterSequenceTypeHardwareWalletTransport.read(from: &buf) ) } - public static func write(_ value: TrezorCallMessageResult, into buf: inout [UInt8]) { - FfiConverterBool.write(value.success, into: &buf) - FfiConverterUInt16.write(value.messageType, into: &buf) - FfiConverterData.write(value.data, into: &buf) - FfiConverterString.write(value.error, into: &buf) - FfiConverterOptionTypeTrezorTransportErrorCode.write(value.errorCode, into: &buf) + public static func write(_ value: SupportedHardwareWallet, into buf: inout [UInt8]) { + FfiConverterTypeHardwareWalletVendor.write(value.vendor, into: &buf) + FfiConverterString.write(value.vendorName, into: &buf) + FfiConverterString.write(value.model, into: &buf) + FfiConverterString.write(value.displayName, into: &buf) + FfiConverterSequenceTypeHardwareWalletTransport.write(value.transports, into: &buf) } } @@ -11524,156 +11632,111 @@ public struct FfiConverterTypeTrezorCallMessageResult: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTrezorCallMessageResult_lift(_ buf: RustBuffer) throws -> TrezorCallMessageResult { - return try FfiConverterTypeTrezorCallMessageResult.lift(buf) +public func FfiConverterTypeSupportedHardwareWallet_lift(_ buf: RustBuffer) throws -> SupportedHardwareWallet { + return try FfiConverterTypeSupportedHardwareWallet.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTrezorCallMessageResult_lower(_ value: TrezorCallMessageResult) -> RustBuffer { - return FfiConverterTypeTrezorCallMessageResult.lower(value) +public func FfiConverterTypeSupportedHardwareWallet_lower(_ value: SupportedHardwareWallet) -> RustBuffer { + return FfiConverterTypeSupportedHardwareWallet.lower(value) } -/** - * Device information exposed to FFI. - */ -public struct TrezorDeviceInfo { - /** - * Unique identifier for the device - */ - public var id: String - /** - * Transport type (USB or Bluetooth) - */ - public var transportType: TrezorTransportType - /** - * Device name (from BLE advertisement or USB descriptor) - */ - public var name: String? +public struct SweepResult { /** - * Transport-specific path (used internally for connection) + * The transaction ID of the sweep transaction */ - public var path: String + public var txid: String /** - * Device label (set by user during device setup) + * The total amount swept (in satoshis) */ - public var label: String? + public var amountSwept: UInt64 /** - * Device model (e.g., "T2", "Safe 5", "Safe 7") + * The fee paid (in satoshis) */ - public var model: String? + public var feePaid: UInt64 /** - * Whether the device is in bootloader mode + * The number of UTXOs swept */ - public var isBootloader: Bool + public var utxosSwept: UInt32 // Default memberwise initializers are never public by default, so we // declare one manually. public init( /** - * Unique identifier for the device - */id: String, - /** - * Transport type (USB or Bluetooth) - */transportType: TrezorTransportType, - /** - * Device name (from BLE advertisement or USB descriptor) - */name: String?, - /** - * Transport-specific path (used internally for connection) - */path: String, + * The transaction ID of the sweep transaction + */txid: String, /** - * Device label (set by user during device setup) - */label: String?, + * The total amount swept (in satoshis) + */amountSwept: UInt64, /** - * Device model (e.g., "T2", "Safe 5", "Safe 7") - */model: String?, + * The fee paid (in satoshis) + */feePaid: UInt64, /** - * Whether the device is in bootloader mode - */isBootloader: Bool) { - self.id = id - self.transportType = transportType - self.name = name - self.path = path - self.label = label - self.model = model - self.isBootloader = isBootloader + * The number of UTXOs swept + */utxosSwept: UInt32) { + self.txid = txid + self.amountSwept = amountSwept + self.feePaid = feePaid + self.utxosSwept = utxosSwept } } #if compiler(>=6) -extension TrezorDeviceInfo: Sendable {} +extension SweepResult: Sendable {} #endif -extension TrezorDeviceInfo: Equatable, Hashable { - public static func ==(lhs: TrezorDeviceInfo, rhs: TrezorDeviceInfo) -> Bool { - if lhs.id != rhs.id { - return false - } - if lhs.transportType != rhs.transportType { +extension SweepResult: Equatable, Hashable { + public static func ==(lhs: SweepResult, rhs: SweepResult) -> Bool { + if lhs.txid != rhs.txid { return false } - if lhs.name != rhs.name { + if lhs.amountSwept != rhs.amountSwept { return false } - if lhs.path != rhs.path { + if lhs.feePaid != rhs.feePaid { return false } - if lhs.label != rhs.label { - return false - } - if lhs.model != rhs.model { - return false - } - if lhs.isBootloader != rhs.isBootloader { + if lhs.utxosSwept != rhs.utxosSwept { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(id) - hasher.combine(transportType) - hasher.combine(name) - hasher.combine(path) - hasher.combine(label) - hasher.combine(model) - hasher.combine(isBootloader) + hasher.combine(txid) + hasher.combine(amountSwept) + hasher.combine(feePaid) + hasher.combine(utxosSwept) } } -extension TrezorDeviceInfo: Codable {} +extension SweepResult: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeTrezorDeviceInfo: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorDeviceInfo { +public struct FfiConverterTypeSweepResult: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SweepResult { return - try TrezorDeviceInfo( - id: FfiConverterString.read(from: &buf), - transportType: FfiConverterTypeTrezorTransportType.read(from: &buf), - name: FfiConverterOptionString.read(from: &buf), - path: FfiConverterString.read(from: &buf), - label: FfiConverterOptionString.read(from: &buf), - model: FfiConverterOptionString.read(from: &buf), - isBootloader: FfiConverterBool.read(from: &buf) + try SweepResult( + txid: FfiConverterString.read(from: &buf), + amountSwept: FfiConverterUInt64.read(from: &buf), + feePaid: FfiConverterUInt64.read(from: &buf), + utxosSwept: FfiConverterUInt32.read(from: &buf) ) } - public static func write(_ value: TrezorDeviceInfo, into buf: inout [UInt8]) { - FfiConverterString.write(value.id, into: &buf) - FfiConverterTypeTrezorTransportType.write(value.transportType, into: &buf) - FfiConverterOptionString.write(value.name, into: &buf) - FfiConverterString.write(value.path, into: &buf) - FfiConverterOptionString.write(value.label, into: &buf) - FfiConverterOptionString.write(value.model, into: &buf) - FfiConverterBool.write(value.isBootloader, into: &buf) + public static func write(_ value: SweepResult, into buf: inout [UInt8]) { + FfiConverterString.write(value.txid, into: &buf) + FfiConverterUInt64.write(value.amountSwept, into: &buf) + FfiConverterUInt64.write(value.feePaid, into: &buf) + FfiConverterUInt32.write(value.utxosSwept, into: &buf) } } @@ -11681,246 +11744,153 @@ public struct FfiConverterTypeTrezorDeviceInfo: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTrezorDeviceInfo_lift(_ buf: RustBuffer) throws -> TrezorDeviceInfo { - return try FfiConverterTypeTrezorDeviceInfo.lift(buf) +public func FfiConverterTypeSweepResult_lift(_ buf: RustBuffer) throws -> SweepResult { + return try FfiConverterTypeSweepResult.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTrezorDeviceInfo_lower(_ value: TrezorDeviceInfo) -> RustBuffer { - return FfiConverterTypeTrezorDeviceInfo.lower(value) +public func FfiConverterTypeSweepResult_lower(_ value: SweepResult) -> RustBuffer { + return FfiConverterTypeSweepResult.lower(value) } -/** - * Device features after initialization. - */ -public struct TrezorFeatures { - /** - * Vendor string - */ - public var vendor: String? - /** - * Device model - */ - public var model: String? - /** - * Device label (set by user during device setup) - */ - public var label: String? - /** - * Device ID (unique per device) - */ - public var deviceId: String? - /** - * Major firmware version - */ - public var majorVersion: UInt32? - /** - * Minor firmware version - */ - public var minorVersion: UInt32? +public struct SweepTransactionPreview { /** - * Patch firmware version + * The PSBT (Partially Signed Bitcoin Transaction) in base64 format */ - public var patchVersion: UInt32? + public var psbt: String /** - * Whether PIN protection is enabled + * The total amount available to sweep (in satoshis) */ - public var pinProtection: Bool? + public var totalAmount: UInt64 /** - * Whether the device is currently unlocked. When PIN protection is enabled - * and this is `Some(false)`, mobile callers should back off and ask the - * user to unlock the Trezor instead of repeatedly reconnecting. + * The estimated fee for the transaction (in satoshis) */ - public var unlocked: Bool? + public var estimatedFee: UInt64 /** - * Whether passphrase protection is enabled + * The estimated virtual size of the transaction (in vbytes) */ - public var passphraseProtection: Bool? + public var estimatedVsize: UInt64 /** - * Whether the device is initialized with a seed + * The number of UTXOs that will be swept */ - public var initialized: Bool? + public var utxosCount: UInt32 /** - * Whether the device needs backup + * The destination address */ - public var needsBackup: Bool? + public var destinationAddress: String /** - * Whether the device can accept passphrase entry on the device itself - * (`Capability_PassphraseEntry`). When false/None, use host entry only. + * The amount that will be sent to destination after fees (in satoshis) */ - public var passphraseEntryCapable: Bool? + public var amountAfterFees: UInt64 // Default memberwise initializers are never public by default, so we // declare one manually. public init( /** - * Vendor string - */vendor: String?, - /** - * Device model - */model: String?, - /** - * Device label (set by user during device setup) - */label: String?, - /** - * Device ID (unique per device) - */deviceId: String?, - /** - * Major firmware version - */majorVersion: UInt32?, - /** - * Minor firmware version - */minorVersion: UInt32?, - /** - * Patch firmware version - */patchVersion: UInt32?, + * The PSBT (Partially Signed Bitcoin Transaction) in base64 format + */psbt: String, /** - * Whether PIN protection is enabled - */pinProtection: Bool?, + * The total amount available to sweep (in satoshis) + */totalAmount: UInt64, /** - * Whether the device is currently unlocked. When PIN protection is enabled - * and this is `Some(false)`, mobile callers should back off and ask the - * user to unlock the Trezor instead of repeatedly reconnecting. - */unlocked: Bool?, + * The estimated fee for the transaction (in satoshis) + */estimatedFee: UInt64, /** - * Whether passphrase protection is enabled - */passphraseProtection: Bool?, + * The estimated virtual size of the transaction (in vbytes) + */estimatedVsize: UInt64, /** - * Whether the device is initialized with a seed - */initialized: Bool?, + * The number of UTXOs that will be swept + */utxosCount: UInt32, /** - * Whether the device needs backup - */needsBackup: Bool?, + * The destination address + */destinationAddress: String, /** - * Whether the device can accept passphrase entry on the device itself - * (`Capability_PassphraseEntry`). When false/None, use host entry only. - */passphraseEntryCapable: Bool?) { - self.vendor = vendor - self.model = model - self.label = label - self.deviceId = deviceId - self.majorVersion = majorVersion - self.minorVersion = minorVersion - self.patchVersion = patchVersion - self.pinProtection = pinProtection - self.unlocked = unlocked - self.passphraseProtection = passphraseProtection - self.initialized = initialized - self.needsBackup = needsBackup - self.passphraseEntryCapable = passphraseEntryCapable + * The amount that will be sent to destination after fees (in satoshis) + */amountAfterFees: UInt64) { + self.psbt = psbt + self.totalAmount = totalAmount + self.estimatedFee = estimatedFee + self.estimatedVsize = estimatedVsize + self.utxosCount = utxosCount + self.destinationAddress = destinationAddress + self.amountAfterFees = amountAfterFees } } #if compiler(>=6) -extension TrezorFeatures: Sendable {} +extension SweepTransactionPreview: Sendable {} #endif -extension TrezorFeatures: Equatable, Hashable { - public static func ==(lhs: TrezorFeatures, rhs: TrezorFeatures) -> Bool { - if lhs.vendor != rhs.vendor { - return false - } - if lhs.model != rhs.model { - return false - } - if lhs.label != rhs.label { - return false - } - if lhs.deviceId != rhs.deviceId { - return false - } - if lhs.majorVersion != rhs.majorVersion { - return false - } - if lhs.minorVersion != rhs.minorVersion { - return false - } - if lhs.patchVersion != rhs.patchVersion { +extension SweepTransactionPreview: Equatable, Hashable { + public static func ==(lhs: SweepTransactionPreview, rhs: SweepTransactionPreview) -> Bool { + if lhs.psbt != rhs.psbt { return false } - if lhs.pinProtection != rhs.pinProtection { + if lhs.totalAmount != rhs.totalAmount { return false } - if lhs.unlocked != rhs.unlocked { + if lhs.estimatedFee != rhs.estimatedFee { return false } - if lhs.passphraseProtection != rhs.passphraseProtection { + if lhs.estimatedVsize != rhs.estimatedVsize { return false } - if lhs.initialized != rhs.initialized { + if lhs.utxosCount != rhs.utxosCount { return false } - if lhs.needsBackup != rhs.needsBackup { + if lhs.destinationAddress != rhs.destinationAddress { return false } - if lhs.passphraseEntryCapable != rhs.passphraseEntryCapable { + if lhs.amountAfterFees != rhs.amountAfterFees { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(vendor) - hasher.combine(model) - hasher.combine(label) - hasher.combine(deviceId) - hasher.combine(majorVersion) - hasher.combine(minorVersion) - hasher.combine(patchVersion) - hasher.combine(pinProtection) - hasher.combine(unlocked) - hasher.combine(passphraseProtection) - hasher.combine(initialized) - hasher.combine(needsBackup) - hasher.combine(passphraseEntryCapable) + hasher.combine(psbt) + hasher.combine(totalAmount) + hasher.combine(estimatedFee) + hasher.combine(estimatedVsize) + hasher.combine(utxosCount) + hasher.combine(destinationAddress) + hasher.combine(amountAfterFees) } } -extension TrezorFeatures: Codable {} +extension SweepTransactionPreview: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeTrezorFeatures: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorFeatures { +public struct FfiConverterTypeSweepTransactionPreview: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SweepTransactionPreview { return - try TrezorFeatures( - vendor: FfiConverterOptionString.read(from: &buf), - model: FfiConverterOptionString.read(from: &buf), - label: FfiConverterOptionString.read(from: &buf), - deviceId: FfiConverterOptionString.read(from: &buf), - majorVersion: FfiConverterOptionUInt32.read(from: &buf), - minorVersion: FfiConverterOptionUInt32.read(from: &buf), - patchVersion: FfiConverterOptionUInt32.read(from: &buf), - pinProtection: FfiConverterOptionBool.read(from: &buf), - unlocked: FfiConverterOptionBool.read(from: &buf), - passphraseProtection: FfiConverterOptionBool.read(from: &buf), - initialized: FfiConverterOptionBool.read(from: &buf), - needsBackup: FfiConverterOptionBool.read(from: &buf), - passphraseEntryCapable: FfiConverterOptionBool.read(from: &buf) + try SweepTransactionPreview( + psbt: FfiConverterString.read(from: &buf), + totalAmount: FfiConverterUInt64.read(from: &buf), + estimatedFee: FfiConverterUInt64.read(from: &buf), + estimatedVsize: FfiConverterUInt64.read(from: &buf), + utxosCount: FfiConverterUInt32.read(from: &buf), + destinationAddress: FfiConverterString.read(from: &buf), + amountAfterFees: FfiConverterUInt64.read(from: &buf) ) } - public static func write(_ value: TrezorFeatures, into buf: inout [UInt8]) { - FfiConverterOptionString.write(value.vendor, into: &buf) - FfiConverterOptionString.write(value.model, into: &buf) - FfiConverterOptionString.write(value.label, into: &buf) - FfiConverterOptionString.write(value.deviceId, into: &buf) - FfiConverterOptionUInt32.write(value.majorVersion, into: &buf) - FfiConverterOptionUInt32.write(value.minorVersion, into: &buf) - FfiConverterOptionUInt32.write(value.patchVersion, into: &buf) - FfiConverterOptionBool.write(value.pinProtection, into: &buf) - FfiConverterOptionBool.write(value.unlocked, into: &buf) - FfiConverterOptionBool.write(value.passphraseProtection, into: &buf) - FfiConverterOptionBool.write(value.initialized, into: &buf) - FfiConverterOptionBool.write(value.needsBackup, into: &buf) - FfiConverterOptionBool.write(value.passphraseEntryCapable, into: &buf) + public static func write(_ value: SweepTransactionPreview, into buf: inout [UInt8]) { + FfiConverterString.write(value.psbt, into: &buf) + FfiConverterUInt64.write(value.totalAmount, into: &buf) + FfiConverterUInt64.write(value.estimatedFee, into: &buf) + FfiConverterUInt64.write(value.estimatedVsize, into: &buf) + FfiConverterUInt32.write(value.utxosCount, into: &buf) + FfiConverterString.write(value.destinationAddress, into: &buf) + FfiConverterUInt64.write(value.amountAfterFees, into: &buf) } } @@ -11928,114 +11898,167 @@ public struct FfiConverterTypeTrezorFeatures: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTrezorFeatures_lift(_ buf: RustBuffer) throws -> TrezorFeatures { - return try FfiConverterTypeTrezorFeatures.lift(buf) +public func FfiConverterTypeSweepTransactionPreview_lift(_ buf: RustBuffer) throws -> SweepTransactionPreview { + return try FfiConverterTypeSweepTransactionPreview.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTrezorFeatures_lower(_ value: TrezorFeatures) -> RustBuffer { - return FfiConverterTypeTrezorFeatures.lower(value) +public func FfiConverterTypeSweepTransactionPreview_lower(_ value: SweepTransactionPreview) -> RustBuffer { + return FfiConverterTypeSweepTransactionPreview.lower(value) } -/** - * Parameters for getting an address from the device. - */ -public struct TrezorGetAddressParams { +public struct SweepableBalances { /** - * BIP32 path (e.g., "m/84'/0'/0'/0/0") + * Balance in legacy (P2PKH) addresses (in satoshis) */ - public var path: String + public var legacyBalance: UInt64 /** - * Coin network (default: Bitcoin) + * Balance in P2SH-SegWit (P2SH-P2WPKH) addresses (in satoshis) */ - public var coin: TrezorCoinType? + public var p2shBalance: UInt64 /** - * Whether to display the address on the device for confirmation + * Balance in Taproot (P2TR) addresses (in satoshis) */ - public var showOnTrezor: Bool + public var taprootBalance: UInt64 /** - * Script type (auto-detected from path if not specified) + * Total balance across all wallet types (in satoshis) */ - public var scriptType: TrezorScriptType? + public var totalBalance: UInt64 + /** + * Number of UTXOs in legacy wallet + */ + public var legacyUtxosCount: UInt32 + /** + * Number of UTXOs in P2SH-SegWit wallet + */ + public var p2shUtxosCount: UInt32 + /** + * Number of UTXOs in Taproot wallet + */ + public var taprootUtxosCount: UInt32 + /** + * Total number of UTXOs across all wallet types + */ + public var totalUtxosCount: UInt32 // Default memberwise initializers are never public by default, so we // declare one manually. public init( /** - * BIP32 path (e.g., "m/84'/0'/0'/0/0") - */path: String, + * Balance in legacy (P2PKH) addresses (in satoshis) + */legacyBalance: UInt64, /** - * Coin network (default: Bitcoin) - */coin: TrezorCoinType?, + * Balance in P2SH-SegWit (P2SH-P2WPKH) addresses (in satoshis) + */p2shBalance: UInt64, /** - * Whether to display the address on the device for confirmation - */showOnTrezor: Bool, + * Balance in Taproot (P2TR) addresses (in satoshis) + */taprootBalance: UInt64, /** - * Script type (auto-detected from path if not specified) - */scriptType: TrezorScriptType?) { - self.path = path - self.coin = coin - self.showOnTrezor = showOnTrezor - self.scriptType = scriptType + * Total balance across all wallet types (in satoshis) + */totalBalance: UInt64, + /** + * Number of UTXOs in legacy wallet + */legacyUtxosCount: UInt32, + /** + * Number of UTXOs in P2SH-SegWit wallet + */p2shUtxosCount: UInt32, + /** + * Number of UTXOs in Taproot wallet + */taprootUtxosCount: UInt32, + /** + * Total number of UTXOs across all wallet types + */totalUtxosCount: UInt32) { + self.legacyBalance = legacyBalance + self.p2shBalance = p2shBalance + self.taprootBalance = taprootBalance + self.totalBalance = totalBalance + self.legacyUtxosCount = legacyUtxosCount + self.p2shUtxosCount = p2shUtxosCount + self.taprootUtxosCount = taprootUtxosCount + self.totalUtxosCount = totalUtxosCount } } #if compiler(>=6) -extension TrezorGetAddressParams: Sendable {} +extension SweepableBalances: Sendable {} #endif -extension TrezorGetAddressParams: Equatable, Hashable { - public static func ==(lhs: TrezorGetAddressParams, rhs: TrezorGetAddressParams) -> Bool { - if lhs.path != rhs.path { +extension SweepableBalances: Equatable, Hashable { + public static func ==(lhs: SweepableBalances, rhs: SweepableBalances) -> Bool { + if lhs.legacyBalance != rhs.legacyBalance { return false } - if lhs.coin != rhs.coin { + if lhs.p2shBalance != rhs.p2shBalance { return false } - if lhs.showOnTrezor != rhs.showOnTrezor { + if lhs.taprootBalance != rhs.taprootBalance { return false } - if lhs.scriptType != rhs.scriptType { + if lhs.totalBalance != rhs.totalBalance { + return false + } + if lhs.legacyUtxosCount != rhs.legacyUtxosCount { + return false + } + if lhs.p2shUtxosCount != rhs.p2shUtxosCount { + return false + } + if lhs.taprootUtxosCount != rhs.taprootUtxosCount { + return false + } + if lhs.totalUtxosCount != rhs.totalUtxosCount { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(path) - hasher.combine(coin) - hasher.combine(showOnTrezor) - hasher.combine(scriptType) + hasher.combine(legacyBalance) + hasher.combine(p2shBalance) + hasher.combine(taprootBalance) + hasher.combine(totalBalance) + hasher.combine(legacyUtxosCount) + hasher.combine(p2shUtxosCount) + hasher.combine(taprootUtxosCount) + hasher.combine(totalUtxosCount) } } -extension TrezorGetAddressParams: Codable {} +extension SweepableBalances: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeTrezorGetAddressParams: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorGetAddressParams { +public struct FfiConverterTypeSweepableBalances: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SweepableBalances { return - try TrezorGetAddressParams( - path: FfiConverterString.read(from: &buf), - coin: FfiConverterOptionTypeTrezorCoinType.read(from: &buf), - showOnTrezor: FfiConverterBool.read(from: &buf), - scriptType: FfiConverterOptionTypeTrezorScriptType.read(from: &buf) + try SweepableBalances( + legacyBalance: FfiConverterUInt64.read(from: &buf), + p2shBalance: FfiConverterUInt64.read(from: &buf), + taprootBalance: FfiConverterUInt64.read(from: &buf), + totalBalance: FfiConverterUInt64.read(from: &buf), + legacyUtxosCount: FfiConverterUInt32.read(from: &buf), + p2shUtxosCount: FfiConverterUInt32.read(from: &buf), + taprootUtxosCount: FfiConverterUInt32.read(from: &buf), + totalUtxosCount: FfiConverterUInt32.read(from: &buf) ) } - public static func write(_ value: TrezorGetAddressParams, into buf: inout [UInt8]) { - FfiConverterString.write(value.path, into: &buf) - FfiConverterOptionTypeTrezorCoinType.write(value.coin, into: &buf) - FfiConverterBool.write(value.showOnTrezor, into: &buf) - FfiConverterOptionTypeTrezorScriptType.write(value.scriptType, into: &buf) + public static func write(_ value: SweepableBalances, into buf: inout [UInt8]) { + FfiConverterUInt64.write(value.legacyBalance, into: &buf) + FfiConverterUInt64.write(value.p2shBalance, into: &buf) + FfiConverterUInt64.write(value.taprootBalance, into: &buf) + FfiConverterUInt64.write(value.totalBalance, into: &buf) + FfiConverterUInt32.write(value.legacyUtxosCount, into: &buf) + FfiConverterUInt32.write(value.p2shUtxosCount, into: &buf) + FfiConverterUInt32.write(value.taprootUtxosCount, into: &buf) + FfiConverterUInt32.write(value.totalUtxosCount, into: &buf) } } @@ -12043,184 +12066,192 @@ public struct FfiConverterTypeTrezorGetAddressParams: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTrezorGetAddressParams_lift(_ buf: RustBuffer) throws -> TrezorGetAddressParams { - return try FfiConverterTypeTrezorGetAddressParams.lift(buf) +public func FfiConverterTypeSweepableBalances_lift(_ buf: RustBuffer) throws -> SweepableBalances { + return try FfiConverterTypeSweepableBalances.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTrezorGetAddressParams_lower(_ value: TrezorGetAddressParams) -> RustBuffer { - return FfiConverterTypeTrezorGetAddressParams.lower(value) +public func FfiConverterTypeSweepableBalances_lower(_ value: SweepableBalances) -> RustBuffer { + return FfiConverterTypeSweepableBalances.lower(value) } /** - * Parameters for getting a public key from the device. + * Full details for a single transaction, including raw inputs/outputs and size metrics. */ -public struct TrezorGetPublicKeyParams { +public struct TransactionDetail { /** - * BIP32 path (e.g., "m/84'/0'/0'") + * Transaction ID (hex) */ - public var path: String + public var txid: String /** - * Coin network (default: Bitcoin) + * Amount received by the wallet (sats) */ - public var coin: TrezorCoinType? + public var received: UInt64 /** - * Whether to display on device for confirmation + * Amount sent by the wallet (sats) — includes change sent back to self */ - public var showOnTrezor: Bool - - // Default memberwise initializers are never public by default, so we - // declare one manually. - public init( - /** - * BIP32 path (e.g., "m/84'/0'/0'") - */path: String, - /** - * Coin network (default: Bitcoin) - */coin: TrezorCoinType?, - /** - * Whether to display on device for confirmation - */showOnTrezor: Bool) { - self.path = path - self.coin = coin - self.showOnTrezor = showOnTrezor - } -} - -#if compiler(>=6) -extension TrezorGetPublicKeyParams: Sendable {} -#endif - - -extension TrezorGetPublicKeyParams: Equatable, Hashable { - public static func ==(lhs: TrezorGetPublicKeyParams, rhs: TrezorGetPublicKeyParams) -> Bool { - if lhs.path != rhs.path { - return false - } - if lhs.coin != rhs.coin { - return false - } - if lhs.showOnTrezor != rhs.showOnTrezor { - return false - } - return true - } - - public func hash(into hasher: inout Hasher) { - hasher.combine(path) - hasher.combine(coin) - hasher.combine(showOnTrezor) - } -} - -extension TrezorGetPublicKeyParams: Codable {} - - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeTrezorGetPublicKeyParams: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorGetPublicKeyParams { - return - try TrezorGetPublicKeyParams( - path: FfiConverterString.read(from: &buf), - coin: FfiConverterOptionTypeTrezorCoinType.read(from: &buf), - showOnTrezor: FfiConverterBool.read(from: &buf) - ) - } - - public static func write(_ value: TrezorGetPublicKeyParams, into buf: inout [UInt8]) { - FfiConverterString.write(value.path, into: &buf) - FfiConverterOptionTypeTrezorCoinType.write(value.coin, into: &buf) - FfiConverterBool.write(value.showOnTrezor, into: &buf) - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeTrezorGetPublicKeyParams_lift(_ buf: RustBuffer) throws -> TrezorGetPublicKeyParams { - return try FfiConverterTypeTrezorGetPublicKeyParams.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeTrezorGetPublicKeyParams_lower(_ value: TrezorGetPublicKeyParams) -> RustBuffer { - return FfiConverterTypeTrezorGetPublicKeyParams.lower(value) -} - - -/** - * Previous transaction data (for non-SegWit input verification). - */ -public struct TrezorPrevTx { + public var sent: UInt64 /** - * Transaction hash (hex encoded) + * Net value from wallet's perspective: received - sent (positive = inflow, negative = outflow) */ - public var hash: String + public var net: Int64 /** - * Transaction version + * Display amount in sats (same semantics as HistoryTransaction.amount) */ - public var version: UInt32 + public var amount: UInt64 /** - * Lock time + * Transaction fee in sats (None if not available) */ - public var lockTime: UInt32 + public var fee: UInt64? + /** + * Transaction direction + */ + public var direction: TxDirection + /** + * Block height (None if unconfirmed/mempool) + */ + public var blockHeight: UInt32? + /** + * Block timestamp as unix epoch seconds (None if unconfirmed) + */ + public var timestamp: UInt64? + /** + * Number of confirmations (0 if unconfirmed) + */ + public var confirmations: UInt32 /** * Transaction inputs */ - public var inputs: [TrezorPrevTxInput] + public var inputs: [TxDetailInput] /** * Transaction outputs */ - public var outputs: [TrezorPrevTxOutput] + public var outputs: [TxDetailOutput] + /** + * Serialized transaction size in bytes + */ + public var size: UInt32 + /** + * Virtual size in vbytes (ceil(weight / 4)) + */ + public var vsize: UInt32 + /** + * Transaction weight in weight units + */ + public var weight: UInt32 + /** + * Fee rate in sat/vB (fee / vsize), None if fee is unavailable or vsize is zero + */ + public var feeRate: Double? // Default memberwise initializers are never public by default, so we // declare one manually. public init( /** - * Transaction hash (hex encoded) - */hash: String, + * Transaction ID (hex) + */txid: String, /** - * Transaction version - */version: UInt32, + * Amount received by the wallet (sats) + */received: UInt64, /** - * Lock time - */lockTime: UInt32, + * Amount sent by the wallet (sats) — includes change sent back to self + */sent: UInt64, + /** + * Net value from wallet's perspective: received - sent (positive = inflow, negative = outflow) + */net: Int64, + /** + * Display amount in sats (same semantics as HistoryTransaction.amount) + */amount: UInt64, + /** + * Transaction fee in sats (None if not available) + */fee: UInt64?, + /** + * Transaction direction + */direction: TxDirection, + /** + * Block height (None if unconfirmed/mempool) + */blockHeight: UInt32?, + /** + * Block timestamp as unix epoch seconds (None if unconfirmed) + */timestamp: UInt64?, + /** + * Number of confirmations (0 if unconfirmed) + */confirmations: UInt32, /** * Transaction inputs - */inputs: [TrezorPrevTxInput], + */inputs: [TxDetailInput], /** * Transaction outputs - */outputs: [TrezorPrevTxOutput]) { - self.hash = hash - self.version = version - self.lockTime = lockTime + */outputs: [TxDetailOutput], + /** + * Serialized transaction size in bytes + */size: UInt32, + /** + * Virtual size in vbytes (ceil(weight / 4)) + */vsize: UInt32, + /** + * Transaction weight in weight units + */weight: UInt32, + /** + * Fee rate in sat/vB (fee / vsize), None if fee is unavailable or vsize is zero + */feeRate: Double?) { + self.txid = txid + self.received = received + self.sent = sent + self.net = net + self.amount = amount + self.fee = fee + self.direction = direction + self.blockHeight = blockHeight + self.timestamp = timestamp + self.confirmations = confirmations self.inputs = inputs self.outputs = outputs + self.size = size + self.vsize = vsize + self.weight = weight + self.feeRate = feeRate } } #if compiler(>=6) -extension TrezorPrevTx: Sendable {} +extension TransactionDetail: Sendable {} #endif -extension TrezorPrevTx: Equatable, Hashable { - public static func ==(lhs: TrezorPrevTx, rhs: TrezorPrevTx) -> Bool { - if lhs.hash != rhs.hash { +extension TransactionDetail: Equatable, Hashable { + public static func ==(lhs: TransactionDetail, rhs: TransactionDetail) -> Bool { + if lhs.txid != rhs.txid { return false } - if lhs.version != rhs.version { + if lhs.received != rhs.received { return false } - if lhs.lockTime != rhs.lockTime { + if lhs.sent != rhs.sent { + return false + } + if lhs.net != rhs.net { + return false + } + if lhs.amount != rhs.amount { + return false + } + if lhs.fee != rhs.fee { + return false + } + if lhs.direction != rhs.direction { + return false + } + if lhs.blockHeight != rhs.blockHeight { + return false + } + if lhs.timestamp != rhs.timestamp { + return false + } + if lhs.confirmations != rhs.confirmations { return false } if lhs.inputs != rhs.inputs { @@ -12229,158 +12260,221 @@ extension TrezorPrevTx: Equatable, Hashable { if lhs.outputs != rhs.outputs { return false } + if lhs.size != rhs.size { + return false + } + if lhs.vsize != rhs.vsize { + return false + } + if lhs.weight != rhs.weight { + return false + } + if lhs.feeRate != rhs.feeRate { + return false + } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(hash) - hasher.combine(version) - hasher.combine(lockTime) + hasher.combine(txid) + hasher.combine(received) + hasher.combine(sent) + hasher.combine(net) + hasher.combine(amount) + hasher.combine(fee) + hasher.combine(direction) + hasher.combine(blockHeight) + hasher.combine(timestamp) + hasher.combine(confirmations) hasher.combine(inputs) hasher.combine(outputs) + hasher.combine(size) + hasher.combine(vsize) + hasher.combine(weight) + hasher.combine(feeRate) } } -extension TrezorPrevTx: Codable {} +extension TransactionDetail: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeTrezorPrevTx: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorPrevTx { +public struct FfiConverterTypeTransactionDetail: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TransactionDetail { return - try TrezorPrevTx( - hash: FfiConverterString.read(from: &buf), - version: FfiConverterUInt32.read(from: &buf), - lockTime: FfiConverterUInt32.read(from: &buf), - inputs: FfiConverterSequenceTypeTrezorPrevTxInput.read(from: &buf), - outputs: FfiConverterSequenceTypeTrezorPrevTxOutput.read(from: &buf) - ) - } - - public static func write(_ value: TrezorPrevTx, into buf: inout [UInt8]) { - FfiConverterString.write(value.hash, into: &buf) - FfiConverterUInt32.write(value.version, into: &buf) - FfiConverterUInt32.write(value.lockTime, into: &buf) - FfiConverterSequenceTypeTrezorPrevTxInput.write(value.inputs, into: &buf) - FfiConverterSequenceTypeTrezorPrevTxOutput.write(value.outputs, into: &buf) - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeTrezorPrevTx_lift(_ buf: RustBuffer) throws -> TrezorPrevTx { - return try FfiConverterTypeTrezorPrevTx.lift(buf) + try TransactionDetail( + txid: FfiConverterString.read(from: &buf), + received: FfiConverterUInt64.read(from: &buf), + sent: FfiConverterUInt64.read(from: &buf), + net: FfiConverterInt64.read(from: &buf), + amount: FfiConverterUInt64.read(from: &buf), + fee: FfiConverterOptionUInt64.read(from: &buf), + direction: FfiConverterTypeTxDirection.read(from: &buf), + blockHeight: FfiConverterOptionUInt32.read(from: &buf), + timestamp: FfiConverterOptionUInt64.read(from: &buf), + confirmations: FfiConverterUInt32.read(from: &buf), + inputs: FfiConverterSequenceTypeTxDetailInput.read(from: &buf), + outputs: FfiConverterSequenceTypeTxDetailOutput.read(from: &buf), + size: FfiConverterUInt32.read(from: &buf), + vsize: FfiConverterUInt32.read(from: &buf), + weight: FfiConverterUInt32.read(from: &buf), + feeRate: FfiConverterOptionDouble.read(from: &buf) + ) + } + + public static func write(_ value: TransactionDetail, into buf: inout [UInt8]) { + FfiConverterString.write(value.txid, into: &buf) + FfiConverterUInt64.write(value.received, into: &buf) + FfiConverterUInt64.write(value.sent, into: &buf) + FfiConverterInt64.write(value.net, into: &buf) + FfiConverterUInt64.write(value.amount, into: &buf) + FfiConverterOptionUInt64.write(value.fee, into: &buf) + FfiConverterTypeTxDirection.write(value.direction, into: &buf) + FfiConverterOptionUInt32.write(value.blockHeight, into: &buf) + FfiConverterOptionUInt64.write(value.timestamp, into: &buf) + FfiConverterUInt32.write(value.confirmations, into: &buf) + FfiConverterSequenceTypeTxDetailInput.write(value.inputs, into: &buf) + FfiConverterSequenceTypeTxDetailOutput.write(value.outputs, into: &buf) + FfiConverterUInt32.write(value.size, into: &buf) + FfiConverterUInt32.write(value.vsize, into: &buf) + FfiConverterUInt32.write(value.weight, into: &buf) + FfiConverterOptionDouble.write(value.feeRate, into: &buf) + } } + #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTrezorPrevTx_lower(_ value: TrezorPrevTx) -> RustBuffer { - return FfiConverterTypeTrezorPrevTx.lower(value) +public func FfiConverterTypeTransactionDetail_lift(_ buf: RustBuffer) throws -> TransactionDetail { + return try FfiConverterTypeTransactionDetail.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeTransactionDetail_lower(_ value: TransactionDetail) -> RustBuffer { + return FfiConverterTypeTransactionDetail.lower(value) } /** - * Input of a previous transaction. + * Details about an onchain transaction. */ -public struct TrezorPrevTxInput { +public struct TransactionDetails { + public var walletId: String /** - * Previous transaction hash (hex encoded) + * The transaction ID. */ - public var prevHash: String + public var txId: String /** - * Previous output index + * The net amount in this transaction (in satoshis). + * + * This is calculated as: (received - sent). For incoming payments, + * this will be positive. For outgoing payments, this will be negative. + * + * Note: This amount does NOT include transaction fees. */ - public var prevIndex: UInt32 + public var amountSats: Int64 /** - * Script signature (hex encoded) + * The transaction inputs with full details. */ - public var scriptSig: String + public var inputs: [TxInput] /** - * Sequence number + * The transaction outputs with full details. */ - public var sequence: UInt32 + public var outputs: [TxOutput] // Default memberwise initializers are never public by default, so we // declare one manually. - public init( + public init(walletId: String, /** - * Previous transaction hash (hex encoded) - */prevHash: String, + * The transaction ID. + */txId: String, /** - * Previous output index - */prevIndex: UInt32, + * The net amount in this transaction (in satoshis). + * + * This is calculated as: (received - sent). For incoming payments, + * this will be positive. For outgoing payments, this will be negative. + * + * Note: This amount does NOT include transaction fees. + */amountSats: Int64, /** - * Script signature (hex encoded) - */scriptSig: String, + * The transaction inputs with full details. + */inputs: [TxInput], /** - * Sequence number - */sequence: UInt32) { - self.prevHash = prevHash - self.prevIndex = prevIndex - self.scriptSig = scriptSig - self.sequence = sequence + * The transaction outputs with full details. + */outputs: [TxOutput]) { + self.walletId = walletId + self.txId = txId + self.amountSats = amountSats + self.inputs = inputs + self.outputs = outputs } } #if compiler(>=6) -extension TrezorPrevTxInput: Sendable {} +extension TransactionDetails: Sendable {} #endif -extension TrezorPrevTxInput: Equatable, Hashable { - public static func ==(lhs: TrezorPrevTxInput, rhs: TrezorPrevTxInput) -> Bool { - if lhs.prevHash != rhs.prevHash { +extension TransactionDetails: Equatable, Hashable { + public static func ==(lhs: TransactionDetails, rhs: TransactionDetails) -> Bool { + if lhs.walletId != rhs.walletId { return false } - if lhs.prevIndex != rhs.prevIndex { + if lhs.txId != rhs.txId { return false } - if lhs.scriptSig != rhs.scriptSig { + if lhs.amountSats != rhs.amountSats { return false } - if lhs.sequence != rhs.sequence { + if lhs.inputs != rhs.inputs { + return false + } + if lhs.outputs != rhs.outputs { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(prevHash) - hasher.combine(prevIndex) - hasher.combine(scriptSig) - hasher.combine(sequence) + hasher.combine(walletId) + hasher.combine(txId) + hasher.combine(amountSats) + hasher.combine(inputs) + hasher.combine(outputs) } } -extension TrezorPrevTxInput: Codable {} +extension TransactionDetails: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeTrezorPrevTxInput: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorPrevTxInput { +public struct FfiConverterTypeTransactionDetails: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TransactionDetails { return - try TrezorPrevTxInput( - prevHash: FfiConverterString.read(from: &buf), - prevIndex: FfiConverterUInt32.read(from: &buf), - scriptSig: FfiConverterString.read(from: &buf), - sequence: FfiConverterUInt32.read(from: &buf) + try TransactionDetails( + walletId: FfiConverterString.read(from: &buf), + txId: FfiConverterString.read(from: &buf), + amountSats: FfiConverterInt64.read(from: &buf), + inputs: FfiConverterSequenceTypeTxInput.read(from: &buf), + outputs: FfiConverterSequenceTypeTxOutput.read(from: &buf) ) } - public static func write(_ value: TrezorPrevTxInput, into buf: inout [UInt8]) { - FfiConverterString.write(value.prevHash, into: &buf) - FfiConverterUInt32.write(value.prevIndex, into: &buf) - FfiConverterString.write(value.scriptSig, into: &buf) - FfiConverterUInt32.write(value.sequence, into: &buf) + public static func write(_ value: TransactionDetails, into buf: inout [UInt8]) { + FfiConverterString.write(value.walletId, into: &buf) + FfiConverterString.write(value.txId, into: &buf) + FfiConverterInt64.write(value.amountSats, into: &buf) + FfiConverterSequenceTypeTxInput.write(value.inputs, into: &buf) + FfiConverterSequenceTypeTxOutput.write(value.outputs, into: &buf) } } @@ -12388,86 +12482,128 @@ public struct FfiConverterTypeTrezorPrevTxInput: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTrezorPrevTxInput_lift(_ buf: RustBuffer) throws -> TrezorPrevTxInput { - return try FfiConverterTypeTrezorPrevTxInput.lift(buf) +public func FfiConverterTypeTransactionDetails_lift(_ buf: RustBuffer) throws -> TransactionDetails { + return try FfiConverterTypeTransactionDetails.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTrezorPrevTxInput_lower(_ value: TrezorPrevTxInput) -> RustBuffer { - return FfiConverterTypeTrezorPrevTxInput.lower(value) +public func FfiConverterTypeTransactionDetails_lower(_ value: TransactionDetails) -> RustBuffer { + return FfiConverterTypeTransactionDetails.lower(value) } /** - * Output of a previous transaction. + * Result from querying transaction history for an xpub. */ -public struct TrezorPrevTxOutput { +public struct TransactionHistoryResult { /** - * Amount in satoshis + * All transactions, sorted: unconfirmed first, then by timestamp descending */ - public var amount: UInt64 + public var transactions: [HistoryTransaction] /** - * Script pubkey (hex encoded) + * Balance breakdown */ - public var scriptPubkey: String + public var balance: WalletBalance + /** + * Total number of transactions + */ + public var txCount: UInt32 + /** + * Current blockchain tip height + */ + public var blockHeight: UInt32 + /** + * The detected or specified account type + */ + public var accountType: AccountType // Default memberwise initializers are never public by default, so we // declare one manually. public init( /** - * Amount in satoshis - */amount: UInt64, + * All transactions, sorted: unconfirmed first, then by timestamp descending + */transactions: [HistoryTransaction], /** - * Script pubkey (hex encoded) - */scriptPubkey: String) { - self.amount = amount - self.scriptPubkey = scriptPubkey + * Balance breakdown + */balance: WalletBalance, + /** + * Total number of transactions + */txCount: UInt32, + /** + * Current blockchain tip height + */blockHeight: UInt32, + /** + * The detected or specified account type + */accountType: AccountType) { + self.transactions = transactions + self.balance = balance + self.txCount = txCount + self.blockHeight = blockHeight + self.accountType = accountType } } #if compiler(>=6) -extension TrezorPrevTxOutput: Sendable {} +extension TransactionHistoryResult: Sendable {} #endif -extension TrezorPrevTxOutput: Equatable, Hashable { - public static func ==(lhs: TrezorPrevTxOutput, rhs: TrezorPrevTxOutput) -> Bool { - if lhs.amount != rhs.amount { +extension TransactionHistoryResult: Equatable, Hashable { + public static func ==(lhs: TransactionHistoryResult, rhs: TransactionHistoryResult) -> Bool { + if lhs.transactions != rhs.transactions { return false } - if lhs.scriptPubkey != rhs.scriptPubkey { + if lhs.balance != rhs.balance { + return false + } + if lhs.txCount != rhs.txCount { + return false + } + if lhs.blockHeight != rhs.blockHeight { + return false + } + if lhs.accountType != rhs.accountType { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(amount) - hasher.combine(scriptPubkey) + hasher.combine(transactions) + hasher.combine(balance) + hasher.combine(txCount) + hasher.combine(blockHeight) + hasher.combine(accountType) } } -extension TrezorPrevTxOutput: Codable {} +extension TransactionHistoryResult: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeTrezorPrevTxOutput: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorPrevTxOutput { +public struct FfiConverterTypeTransactionHistoryResult: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TransactionHistoryResult { return - try TrezorPrevTxOutput( - amount: FfiConverterUInt64.read(from: &buf), - scriptPubkey: FfiConverterString.read(from: &buf) - ) + try TransactionHistoryResult( + transactions: FfiConverterSequenceTypeHistoryTransaction.read(from: &buf), + balance: FfiConverterTypeWalletBalance.read(from: &buf), + txCount: FfiConverterUInt32.read(from: &buf), + blockHeight: FfiConverterUInt32.read(from: &buf), + accountType: FfiConverterTypeAccountType.read(from: &buf) + ) } - public static func write(_ value: TrezorPrevTxOutput, into buf: inout [UInt8]) { - FfiConverterUInt64.write(value.amount, into: &buf) - FfiConverterString.write(value.scriptPubkey, into: &buf) + public static func write(_ value: TransactionHistoryResult, into buf: inout [UInt8]) { + FfiConverterSequenceTypeHistoryTransaction.write(value.transactions, into: &buf) + FfiConverterTypeWalletBalance.write(value.balance, into: &buf) + FfiConverterUInt32.write(value.txCount, into: &buf) + FfiConverterUInt32.write(value.blockHeight, into: &buf) + FfiConverterTypeAccountType.write(value.accountType, into: &buf) } } @@ -12475,156 +12611,86 @@ public struct FfiConverterTypeTrezorPrevTxOutput: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTrezorPrevTxOutput_lift(_ buf: RustBuffer) throws -> TrezorPrevTxOutput { - return try FfiConverterTypeTrezorPrevTxOutput.lift(buf) +public func FfiConverterTypeTransactionHistoryResult_lift(_ buf: RustBuffer) throws -> TransactionHistoryResult { + return try FfiConverterTypeTransactionHistoryResult.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTrezorPrevTxOutput_lower(_ value: TrezorPrevTxOutput) -> RustBuffer { - return FfiConverterTypeTrezorPrevTxOutput.lower(value) +public func FfiConverterTypeTransactionHistoryResult_lower(_ value: TransactionHistoryResult) -> RustBuffer { + return FfiConverterTypeTransactionHistoryResult.lower(value) } /** - * Public key response from device. + * Address response from device. */ -public struct TrezorPublicKeyResponse { +public struct TrezorAddressResponse { /** - * Extended public key (xpub) + * The Bitcoin address */ - public var xpub: String + public var address: String /** - * The serialized path (e.g., "m/84'/0'/0'") + * The serialized path (e.g., "m/84'/0'/0'/0/0") */ public var path: String - /** - * Compressed public key (hex encoded) - */ - public var publicKey: String - /** - * Chain code (hex encoded) - */ - public var chainCode: String - /** - * Parent key fingerprint - */ - public var fingerprint: UInt32 - /** - * Derivation depth - */ - public var depth: UInt32 - /** - * Master root fingerprint (from the device's master seed) - */ - public var rootFingerprint: UInt32? // Default memberwise initializers are never public by default, so we // declare one manually. public init( /** - * Extended public key (xpub) - */xpub: String, - /** - * The serialized path (e.g., "m/84'/0'/0'") - */path: String, - /** - * Compressed public key (hex encoded) - */publicKey: String, - /** - * Chain code (hex encoded) - */chainCode: String, - /** - * Parent key fingerprint - */fingerprint: UInt32, - /** - * Derivation depth - */depth: UInt32, + * The Bitcoin address + */address: String, /** - * Master root fingerprint (from the device's master seed) - */rootFingerprint: UInt32?) { - self.xpub = xpub + * The serialized path (e.g., "m/84'/0'/0'/0/0") + */path: String) { + self.address = address self.path = path - self.publicKey = publicKey - self.chainCode = chainCode - self.fingerprint = fingerprint - self.depth = depth - self.rootFingerprint = rootFingerprint } } #if compiler(>=6) -extension TrezorPublicKeyResponse: Sendable {} +extension TrezorAddressResponse: Sendable {} #endif -extension TrezorPublicKeyResponse: Equatable, Hashable { - public static func ==(lhs: TrezorPublicKeyResponse, rhs: TrezorPublicKeyResponse) -> Bool { - if lhs.xpub != rhs.xpub { +extension TrezorAddressResponse: Equatable, Hashable { + public static func ==(lhs: TrezorAddressResponse, rhs: TrezorAddressResponse) -> Bool { + if lhs.address != rhs.address { return false } if lhs.path != rhs.path { return false } - if lhs.publicKey != rhs.publicKey { - return false - } - if lhs.chainCode != rhs.chainCode { - return false - } - if lhs.fingerprint != rhs.fingerprint { - return false - } - if lhs.depth != rhs.depth { - return false - } - if lhs.rootFingerprint != rhs.rootFingerprint { - return false - } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(xpub) + hasher.combine(address) hasher.combine(path) - hasher.combine(publicKey) - hasher.combine(chainCode) - hasher.combine(fingerprint) - hasher.combine(depth) - hasher.combine(rootFingerprint) } } -extension TrezorPublicKeyResponse: Codable {} +extension TrezorAddressResponse: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeTrezorPublicKeyResponse: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorPublicKeyResponse { +public struct FfiConverterTypeTrezorAddressResponse: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorAddressResponse { return - try TrezorPublicKeyResponse( - xpub: FfiConverterString.read(from: &buf), - path: FfiConverterString.read(from: &buf), - publicKey: FfiConverterString.read(from: &buf), - chainCode: FfiConverterString.read(from: &buf), - fingerprint: FfiConverterUInt32.read(from: &buf), - depth: FfiConverterUInt32.read(from: &buf), - rootFingerprint: FfiConverterOptionUInt32.read(from: &buf) + try TrezorAddressResponse( + address: FfiConverterString.read(from: &buf), + path: FfiConverterString.read(from: &buf) ) } - public static func write(_ value: TrezorPublicKeyResponse, into buf: inout [UInt8]) { - FfiConverterString.write(value.xpub, into: &buf) + public static func write(_ value: TrezorAddressResponse, into buf: inout [UInt8]) { + FfiConverterString.write(value.address, into: &buf) FfiConverterString.write(value.path, into: &buf) - FfiConverterString.write(value.publicKey, into: &buf) - FfiConverterString.write(value.chainCode, into: &buf) - FfiConverterUInt32.write(value.fingerprint, into: &buf) - FfiConverterUInt32.write(value.depth, into: &buf) - FfiConverterOptionUInt32.write(value.rootFingerprint, into: &buf) } } @@ -12632,100 +12698,128 @@ public struct FfiConverterTypeTrezorPublicKeyResponse: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTrezorPublicKeyResponse_lift(_ buf: RustBuffer) throws -> TrezorPublicKeyResponse { - return try FfiConverterTypeTrezorPublicKeyResponse.lift(buf) +public func FfiConverterTypeTrezorAddressResponse_lift(_ buf: RustBuffer) throws -> TrezorAddressResponse { + return try FfiConverterTypeTrezorAddressResponse.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTrezorPublicKeyResponse_lower(_ value: TrezorPublicKeyResponse) -> RustBuffer { - return FfiConverterTypeTrezorPublicKeyResponse.lower(value) +public func FfiConverterTypeTrezorAddressResponse_lower(_ value: TrezorAddressResponse) -> RustBuffer { + return FfiConverterTypeTrezorAddressResponse.lower(value) } /** - * Parameters for signing a message. + * Result from a high-level message call (for BLE/THP devices) */ -public struct TrezorSignMessageParams { +public struct TrezorCallMessageResult { /** - * BIP32 path for the signing key (e.g., "m/84'/0'/0'/0/0") + * Whether the call succeeded */ - public var path: String + public var success: Bool /** - * Message to sign + * Response message type */ - public var message: String + public var messageType: UInt16 /** - * Coin network (default: Bitcoin) + * Response protobuf data */ - public var coin: TrezorCoinType? + public var data: Data + /** + * Error message (empty on success) + */ + public var error: String + /** + * Structured error code (None on success or when the native error is generic) + */ + public var errorCode: TrezorTransportErrorCode? // Default memberwise initializers are never public by default, so we // declare one manually. public init( /** - * BIP32 path for the signing key (e.g., "m/84'/0'/0'/0/0") - */path: String, + * Whether the call succeeded + */success: Bool, /** - * Message to sign - */message: String, + * Response message type + */messageType: UInt16, /** - * Coin network (default: Bitcoin) - */coin: TrezorCoinType?) { - self.path = path - self.message = message - self.coin = coin + * Response protobuf data + */data: Data, + /** + * Error message (empty on success) + */error: String, + /** + * Structured error code (None on success or when the native error is generic) + */errorCode: TrezorTransportErrorCode?) { + self.success = success + self.messageType = messageType + self.data = data + self.error = error + self.errorCode = errorCode } } #if compiler(>=6) -extension TrezorSignMessageParams: Sendable {} +extension TrezorCallMessageResult: Sendable {} #endif -extension TrezorSignMessageParams: Equatable, Hashable { - public static func ==(lhs: TrezorSignMessageParams, rhs: TrezorSignMessageParams) -> Bool { - if lhs.path != rhs.path { +extension TrezorCallMessageResult: Equatable, Hashable { + public static func ==(lhs: TrezorCallMessageResult, rhs: TrezorCallMessageResult) -> Bool { + if lhs.success != rhs.success { return false } - if lhs.message != rhs.message { + if lhs.messageType != rhs.messageType { return false } - if lhs.coin != rhs.coin { + if lhs.data != rhs.data { + return false + } + if lhs.error != rhs.error { + return false + } + if lhs.errorCode != rhs.errorCode { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(path) - hasher.combine(message) - hasher.combine(coin) + hasher.combine(success) + hasher.combine(messageType) + hasher.combine(data) + hasher.combine(error) + hasher.combine(errorCode) } } -extension TrezorSignMessageParams: Codable {} +extension TrezorCallMessageResult: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeTrezorSignMessageParams: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorSignMessageParams { +public struct FfiConverterTypeTrezorCallMessageResult: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorCallMessageResult { return - try TrezorSignMessageParams( - path: FfiConverterString.read(from: &buf), - message: FfiConverterString.read(from: &buf), - coin: FfiConverterOptionTypeTrezorCoinType.read(from: &buf) + try TrezorCallMessageResult( + success: FfiConverterBool.read(from: &buf), + messageType: FfiConverterUInt16.read(from: &buf), + data: FfiConverterData.read(from: &buf), + error: FfiConverterString.read(from: &buf), + errorCode: FfiConverterOptionTypeTrezorTransportErrorCode.read(from: &buf) ) } - public static func write(_ value: TrezorSignMessageParams, into buf: inout [UInt8]) { - FfiConverterString.write(value.path, into: &buf) - FfiConverterString.write(value.message, into: &buf) - FfiConverterOptionTypeTrezorCoinType.write(value.coin, into: &buf) + public static func write(_ value: TrezorCallMessageResult, into buf: inout [UInt8]) { + FfiConverterBool.write(value.success, into: &buf) + FfiConverterUInt16.write(value.messageType, into: &buf) + FfiConverterData.write(value.data, into: &buf) + FfiConverterString.write(value.error, into: &buf) + FfiConverterOptionTypeTrezorTransportErrorCode.write(value.errorCode, into: &buf) } } @@ -12733,142 +12827,156 @@ public struct FfiConverterTypeTrezorSignMessageParams: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTrezorSignMessageParams_lift(_ buf: RustBuffer) throws -> TrezorSignMessageParams { - return try FfiConverterTypeTrezorSignMessageParams.lift(buf) +public func FfiConverterTypeTrezorCallMessageResult_lift(_ buf: RustBuffer) throws -> TrezorCallMessageResult { + return try FfiConverterTypeTrezorCallMessageResult.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTrezorSignMessageParams_lower(_ value: TrezorSignMessageParams) -> RustBuffer { - return FfiConverterTypeTrezorSignMessageParams.lower(value) +public func FfiConverterTypeTrezorCallMessageResult_lower(_ value: TrezorCallMessageResult) -> RustBuffer { + return FfiConverterTypeTrezorCallMessageResult.lower(value) } /** - * Parameters for signing a transaction. + * Device information exposed to FFI. */ -public struct TrezorSignTxParams { +public struct TrezorDeviceInfo { /** - * Transaction inputs + * Unique identifier for the device */ - public var inputs: [TrezorTxInput] + public var id: String /** - * Transaction outputs + * Transport type (USB or Bluetooth) */ - public var outputs: [TrezorTxOutput] + public var transportType: TrezorTransportType /** - * Coin network (default: Bitcoin) + * Device name (from BLE advertisement or USB descriptor) */ - public var coin: TrezorCoinType? + public var name: String? /** - * Lock time (default: 0) + * Transport-specific path (used internally for connection) */ - public var lockTime: UInt32? + public var path: String /** - * Version (default: 2) + * Device label (set by user during device setup) */ - public var version: UInt32? + public var label: String? /** - * Previous transactions (for non-SegWit input verification) + * Device model (e.g., "T2", "Safe 5", "Safe 7") */ - public var prevTxs: [TrezorPrevTx] + public var model: String? + /** + * Whether the device is in bootloader mode + */ + public var isBootloader: Bool // Default memberwise initializers are never public by default, so we // declare one manually. public init( /** - * Transaction inputs - */inputs: [TrezorTxInput], + * Unique identifier for the device + */id: String, /** - * Transaction outputs - */outputs: [TrezorTxOutput], + * Transport type (USB or Bluetooth) + */transportType: TrezorTransportType, /** - * Coin network (default: Bitcoin) - */coin: TrezorCoinType?, + * Device name (from BLE advertisement or USB descriptor) + */name: String?, /** - * Lock time (default: 0) - */lockTime: UInt32?, + * Transport-specific path (used internally for connection) + */path: String, /** - * Version (default: 2) - */version: UInt32?, + * Device label (set by user during device setup) + */label: String?, /** - * Previous transactions (for non-SegWit input verification) - */prevTxs: [TrezorPrevTx]) { - self.inputs = inputs - self.outputs = outputs - self.coin = coin - self.lockTime = lockTime - self.version = version - self.prevTxs = prevTxs + * Device model (e.g., "T2", "Safe 5", "Safe 7") + */model: String?, + /** + * Whether the device is in bootloader mode + */isBootloader: Bool) { + self.id = id + self.transportType = transportType + self.name = name + self.path = path + self.label = label + self.model = model + self.isBootloader = isBootloader } } #if compiler(>=6) -extension TrezorSignTxParams: Sendable {} +extension TrezorDeviceInfo: Sendable {} #endif -extension TrezorSignTxParams: Equatable, Hashable { - public static func ==(lhs: TrezorSignTxParams, rhs: TrezorSignTxParams) -> Bool { - if lhs.inputs != rhs.inputs { +extension TrezorDeviceInfo: Equatable, Hashable { + public static func ==(lhs: TrezorDeviceInfo, rhs: TrezorDeviceInfo) -> Bool { + if lhs.id != rhs.id { return false } - if lhs.outputs != rhs.outputs { + if lhs.transportType != rhs.transportType { return false } - if lhs.coin != rhs.coin { + if lhs.name != rhs.name { return false } - if lhs.lockTime != rhs.lockTime { + if lhs.path != rhs.path { return false } - if lhs.version != rhs.version { + if lhs.label != rhs.label { return false } - if lhs.prevTxs != rhs.prevTxs { + if lhs.model != rhs.model { + return false + } + if lhs.isBootloader != rhs.isBootloader { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(inputs) - hasher.combine(outputs) - hasher.combine(coin) - hasher.combine(lockTime) - hasher.combine(version) - hasher.combine(prevTxs) + hasher.combine(id) + hasher.combine(transportType) + hasher.combine(name) + hasher.combine(path) + hasher.combine(label) + hasher.combine(model) + hasher.combine(isBootloader) } } -extension TrezorSignTxParams: Codable {} +extension TrezorDeviceInfo: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeTrezorSignTxParams: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorSignTxParams { +public struct FfiConverterTypeTrezorDeviceInfo: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorDeviceInfo { return - try TrezorSignTxParams( - inputs: FfiConverterSequenceTypeTrezorTxInput.read(from: &buf), - outputs: FfiConverterSequenceTypeTrezorTxOutput.read(from: &buf), - coin: FfiConverterOptionTypeTrezorCoinType.read(from: &buf), - lockTime: FfiConverterOptionUInt32.read(from: &buf), - version: FfiConverterOptionUInt32.read(from: &buf), - prevTxs: FfiConverterSequenceTypeTrezorPrevTx.read(from: &buf) + try TrezorDeviceInfo( + id: FfiConverterString.read(from: &buf), + transportType: FfiConverterTypeTrezorTransportType.read(from: &buf), + name: FfiConverterOptionString.read(from: &buf), + path: FfiConverterString.read(from: &buf), + label: FfiConverterOptionString.read(from: &buf), + model: FfiConverterOptionString.read(from: &buf), + isBootloader: FfiConverterBool.read(from: &buf) ) } - public static func write(_ value: TrezorSignTxParams, into buf: inout [UInt8]) { - FfiConverterSequenceTypeTrezorTxInput.write(value.inputs, into: &buf) - FfiConverterSequenceTypeTrezorTxOutput.write(value.outputs, into: &buf) - FfiConverterOptionTypeTrezorCoinType.write(value.coin, into: &buf) - FfiConverterOptionUInt32.write(value.lockTime, into: &buf) - FfiConverterOptionUInt32.write(value.version, into: &buf) - FfiConverterSequenceTypeTrezorPrevTx.write(value.prevTxs, into: &buf) + public static func write(_ value: TrezorDeviceInfo, into buf: inout [UInt8]) { + FfiConverterString.write(value.id, into: &buf) + FfiConverterTypeTrezorTransportType.write(value.transportType, into: &buf) + FfiConverterOptionString.write(value.name, into: &buf) + FfiConverterString.write(value.path, into: &buf) + FfiConverterOptionString.write(value.label, into: &buf) + FfiConverterOptionString.write(value.model, into: &buf) + FfiConverterBool.write(value.isBootloader, into: &buf) } } @@ -12876,187 +12984,246 @@ public struct FfiConverterTypeTrezorSignTxParams: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTrezorSignTxParams_lift(_ buf: RustBuffer) throws -> TrezorSignTxParams { - return try FfiConverterTypeTrezorSignTxParams.lift(buf) +public func FfiConverterTypeTrezorDeviceInfo_lift(_ buf: RustBuffer) throws -> TrezorDeviceInfo { + return try FfiConverterTypeTrezorDeviceInfo.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTrezorSignTxParams_lower(_ value: TrezorSignTxParams) -> RustBuffer { - return FfiConverterTypeTrezorSignTxParams.lower(value) +public func FfiConverterTypeTrezorDeviceInfo_lower(_ value: TrezorDeviceInfo) -> RustBuffer { + return FfiConverterTypeTrezorDeviceInfo.lower(value) } /** - * Response from signing a message. + * Device features after initialization. */ -public struct TrezorSignedMessageResponse { +public struct TrezorFeatures { /** - * Bitcoin address that signed the message + * Vendor string */ - public var address: String + public var vendor: String? /** - * Signature (base64 encoded) + * Device model */ - public var signature: String - - // Default memberwise initializers are never public by default, so we - // declare one manually. - public init( - /** - * Bitcoin address that signed the message - */address: String, - /** - * Signature (base64 encoded) - */signature: String) { - self.address = address - self.signature = signature - } -} - -#if compiler(>=6) -extension TrezorSignedMessageResponse: Sendable {} -#endif - - -extension TrezorSignedMessageResponse: Equatable, Hashable { - public static func ==(lhs: TrezorSignedMessageResponse, rhs: TrezorSignedMessageResponse) -> Bool { - if lhs.address != rhs.address { - return false - } - if lhs.signature != rhs.signature { - return false - } - return true - } - - public func hash(into hasher: inout Hasher) { - hasher.combine(address) - hasher.combine(signature) - } -} - -extension TrezorSignedMessageResponse: Codable {} - - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeTrezorSignedMessageResponse: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorSignedMessageResponse { - return - try TrezorSignedMessageResponse( - address: FfiConverterString.read(from: &buf), - signature: FfiConverterString.read(from: &buf) - ) - } - - public static func write(_ value: TrezorSignedMessageResponse, into buf: inout [UInt8]) { - FfiConverterString.write(value.address, into: &buf) - FfiConverterString.write(value.signature, into: &buf) - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeTrezorSignedMessageResponse_lift(_ buf: RustBuffer) throws -> TrezorSignedMessageResponse { - return try FfiConverterTypeTrezorSignedMessageResponse.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeTrezorSignedMessageResponse_lower(_ value: TrezorSignedMessageResponse) -> RustBuffer { - return FfiConverterTypeTrezorSignedMessageResponse.lower(value) -} - - -/** - * Signed transaction result. - */ -public struct TrezorSignedTx { + public var model: String? /** - * Signatures for each input (hex encoded) + * Device label (set by user during device setup) */ - public var signatures: [String] + public var label: String? /** - * Serialized transaction (hex) + * Device ID (unique per device) */ - public var serializedTx: String + public var deviceId: String? /** - * Broadcast transaction ID (populated when push=true) + * Major firmware version */ - public var txid: String? - - // Default memberwise initializers are never public by default, so we + public var majorVersion: UInt32? + /** + * Minor firmware version + */ + public var minorVersion: UInt32? + /** + * Patch firmware version + */ + public var patchVersion: UInt32? + /** + * Whether PIN protection is enabled + */ + public var pinProtection: Bool? + /** + * Whether the device is currently unlocked. When PIN protection is enabled + * and this is `Some(false)`, mobile callers should back off and ask the + * user to unlock the Trezor instead of repeatedly reconnecting. + */ + public var unlocked: Bool? + /** + * Whether passphrase protection is enabled + */ + public var passphraseProtection: Bool? + /** + * Whether the device is initialized with a seed + */ + public var initialized: Bool? + /** + * Whether the device needs backup + */ + public var needsBackup: Bool? + /** + * Whether the device can accept passphrase entry on the device itself + * (`Capability_PassphraseEntry`). When false/None, use host entry only. + */ + public var passphraseEntryCapable: Bool? + + // Default memberwise initializers are never public by default, so we // declare one manually. public init( /** - * Signatures for each input (hex encoded) - */signatures: [String], + * Vendor string + */vendor: String?, /** - * Serialized transaction (hex) - */serializedTx: String, + * Device model + */model: String?, /** - * Broadcast transaction ID (populated when push=true) - */txid: String?) { - self.signatures = signatures - self.serializedTx = serializedTx - self.txid = txid + * Device label (set by user during device setup) + */label: String?, + /** + * Device ID (unique per device) + */deviceId: String?, + /** + * Major firmware version + */majorVersion: UInt32?, + /** + * Minor firmware version + */minorVersion: UInt32?, + /** + * Patch firmware version + */patchVersion: UInt32?, + /** + * Whether PIN protection is enabled + */pinProtection: Bool?, + /** + * Whether the device is currently unlocked. When PIN protection is enabled + * and this is `Some(false)`, mobile callers should back off and ask the + * user to unlock the Trezor instead of repeatedly reconnecting. + */unlocked: Bool?, + /** + * Whether passphrase protection is enabled + */passphraseProtection: Bool?, + /** + * Whether the device is initialized with a seed + */initialized: Bool?, + /** + * Whether the device needs backup + */needsBackup: Bool?, + /** + * Whether the device can accept passphrase entry on the device itself + * (`Capability_PassphraseEntry`). When false/None, use host entry only. + */passphraseEntryCapable: Bool?) { + self.vendor = vendor + self.model = model + self.label = label + self.deviceId = deviceId + self.majorVersion = majorVersion + self.minorVersion = minorVersion + self.patchVersion = patchVersion + self.pinProtection = pinProtection + self.unlocked = unlocked + self.passphraseProtection = passphraseProtection + self.initialized = initialized + self.needsBackup = needsBackup + self.passphraseEntryCapable = passphraseEntryCapable } } #if compiler(>=6) -extension TrezorSignedTx: Sendable {} +extension TrezorFeatures: Sendable {} #endif -extension TrezorSignedTx: Equatable, Hashable { - public static func ==(lhs: TrezorSignedTx, rhs: TrezorSignedTx) -> Bool { - if lhs.signatures != rhs.signatures { +extension TrezorFeatures: Equatable, Hashable { + public static func ==(lhs: TrezorFeatures, rhs: TrezorFeatures) -> Bool { + if lhs.vendor != rhs.vendor { return false } - if lhs.serializedTx != rhs.serializedTx { + if lhs.model != rhs.model { return false } - if lhs.txid != rhs.txid { + if lhs.label != rhs.label { + return false + } + if lhs.deviceId != rhs.deviceId { + return false + } + if lhs.majorVersion != rhs.majorVersion { + return false + } + if lhs.minorVersion != rhs.minorVersion { + return false + } + if lhs.patchVersion != rhs.patchVersion { + return false + } + if lhs.pinProtection != rhs.pinProtection { + return false + } + if lhs.unlocked != rhs.unlocked { + return false + } + if lhs.passphraseProtection != rhs.passphraseProtection { + return false + } + if lhs.initialized != rhs.initialized { + return false + } + if lhs.needsBackup != rhs.needsBackup { + return false + } + if lhs.passphraseEntryCapable != rhs.passphraseEntryCapable { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(signatures) - hasher.combine(serializedTx) - hasher.combine(txid) + hasher.combine(vendor) + hasher.combine(model) + hasher.combine(label) + hasher.combine(deviceId) + hasher.combine(majorVersion) + hasher.combine(minorVersion) + hasher.combine(patchVersion) + hasher.combine(pinProtection) + hasher.combine(unlocked) + hasher.combine(passphraseProtection) + hasher.combine(initialized) + hasher.combine(needsBackup) + hasher.combine(passphraseEntryCapable) } } -extension TrezorSignedTx: Codable {} +extension TrezorFeatures: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeTrezorSignedTx: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorSignedTx { +public struct FfiConverterTypeTrezorFeatures: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorFeatures { return - try TrezorSignedTx( - signatures: FfiConverterSequenceString.read(from: &buf), - serializedTx: FfiConverterString.read(from: &buf), - txid: FfiConverterOptionString.read(from: &buf) + try TrezorFeatures( + vendor: FfiConverterOptionString.read(from: &buf), + model: FfiConverterOptionString.read(from: &buf), + label: FfiConverterOptionString.read(from: &buf), + deviceId: FfiConverterOptionString.read(from: &buf), + majorVersion: FfiConverterOptionUInt32.read(from: &buf), + minorVersion: FfiConverterOptionUInt32.read(from: &buf), + patchVersion: FfiConverterOptionUInt32.read(from: &buf), + pinProtection: FfiConverterOptionBool.read(from: &buf), + unlocked: FfiConverterOptionBool.read(from: &buf), + passphraseProtection: FfiConverterOptionBool.read(from: &buf), + initialized: FfiConverterOptionBool.read(from: &buf), + needsBackup: FfiConverterOptionBool.read(from: &buf), + passphraseEntryCapable: FfiConverterOptionBool.read(from: &buf) ) } - public static func write(_ value: TrezorSignedTx, into buf: inout [UInt8]) { - FfiConverterSequenceString.write(value.signatures, into: &buf) - FfiConverterString.write(value.serializedTx, into: &buf) - FfiConverterOptionString.write(value.txid, into: &buf) + public static func write(_ value: TrezorFeatures, into buf: inout [UInt8]) { + FfiConverterOptionString.write(value.vendor, into: &buf) + FfiConverterOptionString.write(value.model, into: &buf) + FfiConverterOptionString.write(value.label, into: &buf) + FfiConverterOptionString.write(value.deviceId, into: &buf) + FfiConverterOptionUInt32.write(value.majorVersion, into: &buf) + FfiConverterOptionUInt32.write(value.minorVersion, into: &buf) + FfiConverterOptionUInt32.write(value.patchVersion, into: &buf) + FfiConverterOptionBool.write(value.pinProtection, into: &buf) + FfiConverterOptionBool.write(value.unlocked, into: &buf) + FfiConverterOptionBool.write(value.passphraseProtection, into: &buf) + FfiConverterOptionBool.write(value.initialized, into: &buf) + FfiConverterOptionBool.write(value.needsBackup, into: &buf) + FfiConverterOptionBool.write(value.passphraseEntryCapable, into: &buf) } } @@ -13064,114 +13231,114 @@ public struct FfiConverterTypeTrezorSignedTx: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTrezorSignedTx_lift(_ buf: RustBuffer) throws -> TrezorSignedTx { - return try FfiConverterTypeTrezorSignedTx.lift(buf) +public func FfiConverterTypeTrezorFeatures_lift(_ buf: RustBuffer) throws -> TrezorFeatures { + return try FfiConverterTypeTrezorFeatures.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTrezorSignedTx_lower(_ value: TrezorSignedTx) -> RustBuffer { - return FfiConverterTypeTrezorSignedTx.lower(value) +public func FfiConverterTypeTrezorFeatures_lower(_ value: TrezorFeatures) -> RustBuffer { + return FfiConverterTypeTrezorFeatures.lower(value) } /** - * Result from a transport read operation + * Parameters for getting an address from the device. */ -public struct TrezorTransportReadResult { +public struct TrezorGetAddressParams { /** - * Whether the read succeeded + * BIP32 path (e.g., "m/84'/0'/0'/0/0") */ - public var success: Bool + public var path: String /** - * Data read (empty on failure) + * Coin network (default: Bitcoin) */ - public var data: Data + public var coin: TrezorCoinType? /** - * Error message (empty on success) + * Whether to display the address on the device for confirmation */ - public var error: String + public var showOnTrezor: Bool /** - * Structured error code (None on success or when the native error is generic) + * Script type (auto-detected from path if not specified) */ - public var errorCode: TrezorTransportErrorCode? + public var scriptType: TrezorScriptType? // Default memberwise initializers are never public by default, so we // declare one manually. public init( /** - * Whether the read succeeded - */success: Bool, + * BIP32 path (e.g., "m/84'/0'/0'/0/0") + */path: String, /** - * Data read (empty on failure) - */data: Data, + * Coin network (default: Bitcoin) + */coin: TrezorCoinType?, /** - * Error message (empty on success) - */error: String, + * Whether to display the address on the device for confirmation + */showOnTrezor: Bool, /** - * Structured error code (None on success or when the native error is generic) - */errorCode: TrezorTransportErrorCode?) { - self.success = success - self.data = data - self.error = error - self.errorCode = errorCode + * Script type (auto-detected from path if not specified) + */scriptType: TrezorScriptType?) { + self.path = path + self.coin = coin + self.showOnTrezor = showOnTrezor + self.scriptType = scriptType } } #if compiler(>=6) -extension TrezorTransportReadResult: Sendable {} +extension TrezorGetAddressParams: Sendable {} #endif -extension TrezorTransportReadResult: Equatable, Hashable { - public static func ==(lhs: TrezorTransportReadResult, rhs: TrezorTransportReadResult) -> Bool { - if lhs.success != rhs.success { +extension TrezorGetAddressParams: Equatable, Hashable { + public static func ==(lhs: TrezorGetAddressParams, rhs: TrezorGetAddressParams) -> Bool { + if lhs.path != rhs.path { return false } - if lhs.data != rhs.data { + if lhs.coin != rhs.coin { return false } - if lhs.error != rhs.error { + if lhs.showOnTrezor != rhs.showOnTrezor { return false } - if lhs.errorCode != rhs.errorCode { + if lhs.scriptType != rhs.scriptType { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(success) - hasher.combine(data) - hasher.combine(error) - hasher.combine(errorCode) + hasher.combine(path) + hasher.combine(coin) + hasher.combine(showOnTrezor) + hasher.combine(scriptType) } } -extension TrezorTransportReadResult: Codable {} +extension TrezorGetAddressParams: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeTrezorTransportReadResult: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorTransportReadResult { +public struct FfiConverterTypeTrezorGetAddressParams: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorGetAddressParams { return - try TrezorTransportReadResult( - success: FfiConverterBool.read(from: &buf), - data: FfiConverterData.read(from: &buf), - error: FfiConverterString.read(from: &buf), - errorCode: FfiConverterOptionTypeTrezorTransportErrorCode.read(from: &buf) + try TrezorGetAddressParams( + path: FfiConverterString.read(from: &buf), + coin: FfiConverterOptionTypeTrezorCoinType.read(from: &buf), + showOnTrezor: FfiConverterBool.read(from: &buf), + scriptType: FfiConverterOptionTypeTrezorScriptType.read(from: &buf) ) } - public static func write(_ value: TrezorTransportReadResult, into buf: inout [UInt8]) { - FfiConverterBool.write(value.success, into: &buf) - FfiConverterData.write(value.data, into: &buf) - FfiConverterString.write(value.error, into: &buf) - FfiConverterOptionTypeTrezorTransportErrorCode.write(value.errorCode, into: &buf) + public static func write(_ value: TrezorGetAddressParams, into buf: inout [UInt8]) { + FfiConverterString.write(value.path, into: &buf) + FfiConverterOptionTypeTrezorCoinType.write(value.coin, into: &buf) + FfiConverterBool.write(value.showOnTrezor, into: &buf) + FfiConverterOptionTypeTrezorScriptType.write(value.scriptType, into: &buf) } } @@ -13179,100 +13346,100 @@ public struct FfiConverterTypeTrezorTransportReadResult: FfiConverterRustBuffer #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTrezorTransportReadResult_lift(_ buf: RustBuffer) throws -> TrezorTransportReadResult { - return try FfiConverterTypeTrezorTransportReadResult.lift(buf) +public func FfiConverterTypeTrezorGetAddressParams_lift(_ buf: RustBuffer) throws -> TrezorGetAddressParams { + return try FfiConverterTypeTrezorGetAddressParams.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTrezorTransportReadResult_lower(_ value: TrezorTransportReadResult) -> RustBuffer { - return FfiConverterTypeTrezorTransportReadResult.lower(value) +public func FfiConverterTypeTrezorGetAddressParams_lower(_ value: TrezorGetAddressParams) -> RustBuffer { + return FfiConverterTypeTrezorGetAddressParams.lower(value) } /** - * Result from a transport write or open operation + * Parameters for getting a public key from the device. */ -public struct TrezorTransportWriteResult { +public struct TrezorGetPublicKeyParams { /** - * Whether the operation succeeded + * BIP32 path (e.g., "m/84'/0'/0'") */ - public var success: Bool + public var path: String /** - * Error message (empty on success) + * Coin network (default: Bitcoin) */ - public var error: String + public var coin: TrezorCoinType? /** - * Structured error code (None on success or when the native error is generic) + * Whether to display on device for confirmation */ - public var errorCode: TrezorTransportErrorCode? + public var showOnTrezor: Bool // Default memberwise initializers are never public by default, so we // declare one manually. public init( /** - * Whether the operation succeeded - */success: Bool, + * BIP32 path (e.g., "m/84'/0'/0'") + */path: String, /** - * Error message (empty on success) - */error: String, + * Coin network (default: Bitcoin) + */coin: TrezorCoinType?, /** - * Structured error code (None on success or when the native error is generic) - */errorCode: TrezorTransportErrorCode?) { - self.success = success - self.error = error - self.errorCode = errorCode + * Whether to display on device for confirmation + */showOnTrezor: Bool) { + self.path = path + self.coin = coin + self.showOnTrezor = showOnTrezor } } #if compiler(>=6) -extension TrezorTransportWriteResult: Sendable {} +extension TrezorGetPublicKeyParams: Sendable {} #endif -extension TrezorTransportWriteResult: Equatable, Hashable { - public static func ==(lhs: TrezorTransportWriteResult, rhs: TrezorTransportWriteResult) -> Bool { - if lhs.success != rhs.success { +extension TrezorGetPublicKeyParams: Equatable, Hashable { + public static func ==(lhs: TrezorGetPublicKeyParams, rhs: TrezorGetPublicKeyParams) -> Bool { + if lhs.path != rhs.path { return false } - if lhs.error != rhs.error { + if lhs.coin != rhs.coin { return false } - if lhs.errorCode != rhs.errorCode { + if lhs.showOnTrezor != rhs.showOnTrezor { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(success) - hasher.combine(error) - hasher.combine(errorCode) + hasher.combine(path) + hasher.combine(coin) + hasher.combine(showOnTrezor) } } -extension TrezorTransportWriteResult: Codable {} +extension TrezorGetPublicKeyParams: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeTrezorTransportWriteResult: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorTransportWriteResult { +public struct FfiConverterTypeTrezorGetPublicKeyParams: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorGetPublicKeyParams { return - try TrezorTransportWriteResult( - success: FfiConverterBool.read(from: &buf), - error: FfiConverterString.read(from: &buf), - errorCode: FfiConverterOptionTypeTrezorTransportErrorCode.read(from: &buf) + try TrezorGetPublicKeyParams( + path: FfiConverterString.read(from: &buf), + coin: FfiConverterOptionTypeTrezorCoinType.read(from: &buf), + showOnTrezor: FfiConverterBool.read(from: &buf) ) } - public static func write(_ value: TrezorTransportWriteResult, into buf: inout [UInt8]) { - FfiConverterBool.write(value.success, into: &buf) - FfiConverterString.write(value.error, into: &buf) - FfiConverterOptionTypeTrezorTransportErrorCode.write(value.errorCode, into: &buf) + public static func write(_ value: TrezorGetPublicKeyParams, into buf: inout [UInt8]) { + FfiConverterString.write(value.path, into: &buf) + FfiConverterOptionTypeTrezorCoinType.write(value.coin, into: &buf) + FfiConverterBool.write(value.showOnTrezor, into: &buf) } } @@ -13280,170 +13447,128 @@ public struct FfiConverterTypeTrezorTransportWriteResult: FfiConverterRustBuffer #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTrezorTransportWriteResult_lift(_ buf: RustBuffer) throws -> TrezorTransportWriteResult { - return try FfiConverterTypeTrezorTransportWriteResult.lift(buf) +public func FfiConverterTypeTrezorGetPublicKeyParams_lift(_ buf: RustBuffer) throws -> TrezorGetPublicKeyParams { + return try FfiConverterTypeTrezorGetPublicKeyParams.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTrezorTransportWriteResult_lower(_ value: TrezorTransportWriteResult) -> RustBuffer { - return FfiConverterTypeTrezorTransportWriteResult.lower(value) +public func FfiConverterTypeTrezorGetPublicKeyParams_lower(_ value: TrezorGetPublicKeyParams) -> RustBuffer { + return FfiConverterTypeTrezorGetPublicKeyParams.lower(value) } /** - * Transaction input for signing. + * Previous transaction data (for non-SegWit input verification). */ -public struct TrezorTxInput { - /** - * Previous transaction hash (hex, 32 bytes) - */ - public var prevHash: String - /** - * Previous output index - */ - public var prevIndex: UInt32 - /** - * BIP32 derivation path (e.g., "m/84'/0'/0'/0/0") - */ - public var path: String +public struct TrezorPrevTx { /** - * Amount in satoshis + * Transaction hash (hex encoded) */ - public var amount: UInt64 + public var hash: String /** - * Script type + * Transaction version */ - public var scriptType: TrezorScriptType + public var version: UInt32 /** - * Sequence number (default: 0xFFFFFFFD for RBF) + * Lock time */ - public var sequence: UInt32? + public var lockTime: UInt32 /** - * Original transaction hash for RBF replacement (hex encoded) + * Transaction inputs */ - public var origHash: String? + public var inputs: [TrezorPrevTxInput] /** - * Original input index for RBF replacement + * Transaction outputs */ - public var origIndex: UInt32? + public var outputs: [TrezorPrevTxOutput] // Default memberwise initializers are never public by default, so we // declare one manually. public init( /** - * Previous transaction hash (hex, 32 bytes) - */prevHash: String, - /** - * Previous output index - */prevIndex: UInt32, - /** - * BIP32 derivation path (e.g., "m/84'/0'/0'/0/0") - */path: String, - /** - * Amount in satoshis - */amount: UInt64, + * Transaction hash (hex encoded) + */hash: String, /** - * Script type - */scriptType: TrezorScriptType, + * Transaction version + */version: UInt32, /** - * Sequence number (default: 0xFFFFFFFD for RBF) - */sequence: UInt32?, + * Lock time + */lockTime: UInt32, /** - * Original transaction hash for RBF replacement (hex encoded) - */origHash: String?, + * Transaction inputs + */inputs: [TrezorPrevTxInput], /** - * Original input index for RBF replacement - */origIndex: UInt32?) { - self.prevHash = prevHash - self.prevIndex = prevIndex - self.path = path - self.amount = amount - self.scriptType = scriptType - self.sequence = sequence - self.origHash = origHash - self.origIndex = origIndex + * Transaction outputs + */outputs: [TrezorPrevTxOutput]) { + self.hash = hash + self.version = version + self.lockTime = lockTime + self.inputs = inputs + self.outputs = outputs } } #if compiler(>=6) -extension TrezorTxInput: Sendable {} +extension TrezorPrevTx: Sendable {} #endif -extension TrezorTxInput: Equatable, Hashable { - public static func ==(lhs: TrezorTxInput, rhs: TrezorTxInput) -> Bool { - if lhs.prevHash != rhs.prevHash { - return false - } - if lhs.prevIndex != rhs.prevIndex { - return false - } - if lhs.path != rhs.path { - return false - } - if lhs.amount != rhs.amount { +extension TrezorPrevTx: Equatable, Hashable { + public static func ==(lhs: TrezorPrevTx, rhs: TrezorPrevTx) -> Bool { + if lhs.hash != rhs.hash { return false } - if lhs.scriptType != rhs.scriptType { + if lhs.version != rhs.version { return false } - if lhs.sequence != rhs.sequence { + if lhs.lockTime != rhs.lockTime { return false } - if lhs.origHash != rhs.origHash { + if lhs.inputs != rhs.inputs { return false } - if lhs.origIndex != rhs.origIndex { + if lhs.outputs != rhs.outputs { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(prevHash) - hasher.combine(prevIndex) - hasher.combine(path) - hasher.combine(amount) - hasher.combine(scriptType) - hasher.combine(sequence) - hasher.combine(origHash) - hasher.combine(origIndex) + hasher.combine(hash) + hasher.combine(version) + hasher.combine(lockTime) + hasher.combine(inputs) + hasher.combine(outputs) } } -extension TrezorTxInput: Codable {} +extension TrezorPrevTx: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeTrezorTxInput: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorTxInput { +public struct FfiConverterTypeTrezorPrevTx: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorPrevTx { return - try TrezorTxInput( - prevHash: FfiConverterString.read(from: &buf), - prevIndex: FfiConverterUInt32.read(from: &buf), - path: FfiConverterString.read(from: &buf), - amount: FfiConverterUInt64.read(from: &buf), - scriptType: FfiConverterTypeTrezorScriptType.read(from: &buf), - sequence: FfiConverterOptionUInt32.read(from: &buf), - origHash: FfiConverterOptionString.read(from: &buf), - origIndex: FfiConverterOptionUInt32.read(from: &buf) + try TrezorPrevTx( + hash: FfiConverterString.read(from: &buf), + version: FfiConverterUInt32.read(from: &buf), + lockTime: FfiConverterUInt32.read(from: &buf), + inputs: FfiConverterSequenceTypeTrezorPrevTxInput.read(from: &buf), + outputs: FfiConverterSequenceTypeTrezorPrevTxOutput.read(from: &buf) ) } - public static func write(_ value: TrezorTxInput, into buf: inout [UInt8]) { - FfiConverterString.write(value.prevHash, into: &buf) - FfiConverterUInt32.write(value.prevIndex, into: &buf) - FfiConverterString.write(value.path, into: &buf) - FfiConverterUInt64.write(value.amount, into: &buf) - FfiConverterTypeTrezorScriptType.write(value.scriptType, into: &buf) - FfiConverterOptionUInt32.write(value.sequence, into: &buf) - FfiConverterOptionString.write(value.origHash, into: &buf) - FfiConverterOptionUInt32.write(value.origIndex, into: &buf) + public static func write(_ value: TrezorPrevTx, into buf: inout [UInt8]) { + FfiConverterString.write(value.hash, into: &buf) + FfiConverterUInt32.write(value.version, into: &buf) + FfiConverterUInt32.write(value.lockTime, into: &buf) + FfiConverterSequenceTypeTrezorPrevTxInput.write(value.inputs, into: &buf) + FfiConverterSequenceTypeTrezorPrevTxOutput.write(value.outputs, into: &buf) } } @@ -13451,156 +13576,114 @@ public struct FfiConverterTypeTrezorTxInput: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTrezorTxInput_lift(_ buf: RustBuffer) throws -> TrezorTxInput { - return try FfiConverterTypeTrezorTxInput.lift(buf) +public func FfiConverterTypeTrezorPrevTx_lift(_ buf: RustBuffer) throws -> TrezorPrevTx { + return try FfiConverterTypeTrezorPrevTx.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTrezorTxInput_lower(_ value: TrezorTxInput) -> RustBuffer { - return FfiConverterTypeTrezorTxInput.lower(value) +public func FfiConverterTypeTrezorPrevTx_lower(_ value: TrezorPrevTx) -> RustBuffer { + return FfiConverterTypeTrezorPrevTx.lower(value) } /** - * Transaction output for signing. + * Input of a previous transaction. */ -public struct TrezorTxOutput { - /** - * Destination address (for external outputs) - */ - public var address: String? - /** - * BIP32 path (for change outputs) - */ - public var path: String? - /** - * Amount in satoshis - */ - public var amount: UInt64 +public struct TrezorPrevTxInput { /** - * Script type (for change outputs) + * Previous transaction hash (hex encoded) */ - public var scriptType: TrezorScriptType? + public var prevHash: String /** - * OP_RETURN data (hex encoded, for data outputs) + * Previous output index */ - public var opReturnData: String? + public var prevIndex: UInt32 /** - * Original transaction hash for RBF replacement (hex encoded) + * Script signature (hex encoded) */ - public var origHash: String? + public var scriptSig: String /** - * Original output index for RBF replacement + * Sequence number */ - public var origIndex: UInt32? + public var sequence: UInt32 // Default memberwise initializers are never public by default, so we // declare one manually. public init( /** - * Destination address (for external outputs) - */address: String?, - /** - * BIP32 path (for change outputs) - */path: String?, - /** - * Amount in satoshis - */amount: UInt64, - /** - * Script type (for change outputs) - */scriptType: TrezorScriptType?, + * Previous transaction hash (hex encoded) + */prevHash: String, /** - * OP_RETURN data (hex encoded, for data outputs) - */opReturnData: String?, + * Previous output index + */prevIndex: UInt32, /** - * Original transaction hash for RBF replacement (hex encoded) - */origHash: String?, + * Script signature (hex encoded) + */scriptSig: String, /** - * Original output index for RBF replacement - */origIndex: UInt32?) { - self.address = address - self.path = path - self.amount = amount - self.scriptType = scriptType - self.opReturnData = opReturnData - self.origHash = origHash - self.origIndex = origIndex + * Sequence number + */sequence: UInt32) { + self.prevHash = prevHash + self.prevIndex = prevIndex + self.scriptSig = scriptSig + self.sequence = sequence } } #if compiler(>=6) -extension TrezorTxOutput: Sendable {} +extension TrezorPrevTxInput: Sendable {} #endif -extension TrezorTxOutput: Equatable, Hashable { - public static func ==(lhs: TrezorTxOutput, rhs: TrezorTxOutput) -> Bool { - if lhs.address != rhs.address { - return false - } - if lhs.path != rhs.path { - return false - } - if lhs.amount != rhs.amount { - return false - } - if lhs.scriptType != rhs.scriptType { +extension TrezorPrevTxInput: Equatable, Hashable { + public static func ==(lhs: TrezorPrevTxInput, rhs: TrezorPrevTxInput) -> Bool { + if lhs.prevHash != rhs.prevHash { return false } - if lhs.opReturnData != rhs.opReturnData { + if lhs.prevIndex != rhs.prevIndex { return false } - if lhs.origHash != rhs.origHash { + if lhs.scriptSig != rhs.scriptSig { return false } - if lhs.origIndex != rhs.origIndex { + if lhs.sequence != rhs.sequence { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(address) - hasher.combine(path) - hasher.combine(amount) - hasher.combine(scriptType) - hasher.combine(opReturnData) - hasher.combine(origHash) - hasher.combine(origIndex) + hasher.combine(prevHash) + hasher.combine(prevIndex) + hasher.combine(scriptSig) + hasher.combine(sequence) } } -extension TrezorTxOutput: Codable {} +extension TrezorPrevTxInput: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeTrezorTxOutput: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorTxOutput { +public struct FfiConverterTypeTrezorPrevTxInput: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorPrevTxInput { return - try TrezorTxOutput( - address: FfiConverterOptionString.read(from: &buf), - path: FfiConverterOptionString.read(from: &buf), - amount: FfiConverterUInt64.read(from: &buf), - scriptType: FfiConverterOptionTypeTrezorScriptType.read(from: &buf), - opReturnData: FfiConverterOptionString.read(from: &buf), - origHash: FfiConverterOptionString.read(from: &buf), - origIndex: FfiConverterOptionUInt32.read(from: &buf) + try TrezorPrevTxInput( + prevHash: FfiConverterString.read(from: &buf), + prevIndex: FfiConverterUInt32.read(from: &buf), + scriptSig: FfiConverterString.read(from: &buf), + sequence: FfiConverterUInt32.read(from: &buf) ) } - public static func write(_ value: TrezorTxOutput, into buf: inout [UInt8]) { - FfiConverterOptionString.write(value.address, into: &buf) - FfiConverterOptionString.write(value.path, into: &buf) - FfiConverterUInt64.write(value.amount, into: &buf) - FfiConverterOptionTypeTrezorScriptType.write(value.scriptType, into: &buf) - FfiConverterOptionString.write(value.opReturnData, into: &buf) - FfiConverterOptionString.write(value.origHash, into: &buf) - FfiConverterOptionUInt32.write(value.origIndex, into: &buf) + public static func write(_ value: TrezorPrevTxInput, into buf: inout [UInt8]) { + FfiConverterString.write(value.prevHash, into: &buf) + FfiConverterUInt32.write(value.prevIndex, into: &buf) + FfiConverterString.write(value.scriptSig, into: &buf) + FfiConverterUInt32.write(value.sequence, into: &buf) } } @@ -13608,114 +13691,86 @@ public struct FfiConverterTypeTrezorTxOutput: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTrezorTxOutput_lift(_ buf: RustBuffer) throws -> TrezorTxOutput { - return try FfiConverterTypeTrezorTxOutput.lift(buf) +public func FfiConverterTypeTrezorPrevTxInput_lift(_ buf: RustBuffer) throws -> TrezorPrevTxInput { + return try FfiConverterTypeTrezorPrevTxInput.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTrezorTxOutput_lower(_ value: TrezorTxOutput) -> RustBuffer { - return FfiConverterTypeTrezorTxOutput.lower(value) +public func FfiConverterTypeTrezorPrevTxInput_lower(_ value: TrezorPrevTxInput) -> RustBuffer { + return FfiConverterTypeTrezorPrevTxInput.lower(value) } /** - * Parameters for verifying a message signature. + * Output of a previous transaction. */ -public struct TrezorVerifyMessageParams { - /** - * Bitcoin address that signed the message - */ - public var address: String - /** - * Signature (base64 encoded) - */ - public var signature: String +public struct TrezorPrevTxOutput { /** - * Original message + * Amount in satoshis */ - public var message: String + public var amount: UInt64 /** - * Coin network (default: Bitcoin) + * Script pubkey (hex encoded) */ - public var coin: TrezorCoinType? + public var scriptPubkey: String // Default memberwise initializers are never public by default, so we // declare one manually. public init( /** - * Bitcoin address that signed the message - */address: String, - /** - * Signature (base64 encoded) - */signature: String, - /** - * Original message - */message: String, + * Amount in satoshis + */amount: UInt64, /** - * Coin network (default: Bitcoin) - */coin: TrezorCoinType?) { - self.address = address - self.signature = signature - self.message = message - self.coin = coin + * Script pubkey (hex encoded) + */scriptPubkey: String) { + self.amount = amount + self.scriptPubkey = scriptPubkey } } #if compiler(>=6) -extension TrezorVerifyMessageParams: Sendable {} +extension TrezorPrevTxOutput: Sendable {} #endif -extension TrezorVerifyMessageParams: Equatable, Hashable { - public static func ==(lhs: TrezorVerifyMessageParams, rhs: TrezorVerifyMessageParams) -> Bool { - if lhs.address != rhs.address { - return false - } - if lhs.signature != rhs.signature { - return false - } - if lhs.message != rhs.message { +extension TrezorPrevTxOutput: Equatable, Hashable { + public static func ==(lhs: TrezorPrevTxOutput, rhs: TrezorPrevTxOutput) -> Bool { + if lhs.amount != rhs.amount { return false } - if lhs.coin != rhs.coin { + if lhs.scriptPubkey != rhs.scriptPubkey { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(address) - hasher.combine(signature) - hasher.combine(message) - hasher.combine(coin) + hasher.combine(amount) + hasher.combine(scriptPubkey) } } -extension TrezorVerifyMessageParams: Codable {} +extension TrezorPrevTxOutput: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeTrezorVerifyMessageParams: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorVerifyMessageParams { +public struct FfiConverterTypeTrezorPrevTxOutput: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorPrevTxOutput { return - try TrezorVerifyMessageParams( - address: FfiConverterString.read(from: &buf), - signature: FfiConverterString.read(from: &buf), - message: FfiConverterString.read(from: &buf), - coin: FfiConverterOptionTypeTrezorCoinType.read(from: &buf) + try TrezorPrevTxOutput( + amount: FfiConverterUInt64.read(from: &buf), + scriptPubkey: FfiConverterString.read(from: &buf) ) } - public static func write(_ value: TrezorVerifyMessageParams, into buf: inout [UInt8]) { - FfiConverterString.write(value.address, into: &buf) - FfiConverterString.write(value.signature, into: &buf) - FfiConverterString.write(value.message, into: &buf) - FfiConverterOptionTypeTrezorCoinType.write(value.coin, into: &buf) + public static func write(_ value: TrezorPrevTxOutput, into buf: inout [UInt8]) { + FfiConverterUInt64.write(value.amount, into: &buf) + FfiConverterString.write(value.scriptPubkey, into: &buf) } } @@ -13723,128 +13778,156 @@ public struct FfiConverterTypeTrezorVerifyMessageParams: FfiConverterRustBuffer #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTrezorVerifyMessageParams_lift(_ buf: RustBuffer) throws -> TrezorVerifyMessageParams { - return try FfiConverterTypeTrezorVerifyMessageParams.lift(buf) +public func FfiConverterTypeTrezorPrevTxOutput_lift(_ buf: RustBuffer) throws -> TrezorPrevTxOutput { + return try FfiConverterTypeTrezorPrevTxOutput.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTrezorVerifyMessageParams_lower(_ value: TrezorVerifyMessageParams) -> RustBuffer { - return FfiConverterTypeTrezorVerifyMessageParams.lower(value) +public func FfiConverterTypeTrezorPrevTxOutput_lower(_ value: TrezorPrevTxOutput) -> RustBuffer { + return FfiConverterTypeTrezorPrevTxOutput.lower(value) } /** - * A transaction input with full details. + * Public key response from device. */ -public struct TxDetailInput { +public struct TrezorPublicKeyResponse { /** - * Previous output transaction ID (hex) + * Extended public key (xpub) */ - public var txid: String + public var xpub: String /** - * Previous output index + * The serialized path (e.g., "m/84'/0'/0'") */ - public var vout: UInt32 + public var path: String /** - * Sequence number + * Compressed public key (hex encoded) */ - public var sequence: UInt32 + public var publicKey: String /** - * Script signature (hex-encoded) + * Chain code (hex encoded) */ - public var scriptSig: String + public var chainCode: String /** - * Witness stack (each element hex-encoded) + * Parent key fingerprint */ - public var witness: [String] + public var fingerprint: UInt32 + /** + * Derivation depth + */ + public var depth: UInt32 + /** + * Master root fingerprint (from the device's master seed) + */ + public var rootFingerprint: UInt32? // Default memberwise initializers are never public by default, so we // declare one manually. public init( /** - * Previous output transaction ID (hex) - */txid: String, + * Extended public key (xpub) + */xpub: String, /** - * Previous output index - */vout: UInt32, + * The serialized path (e.g., "m/84'/0'/0'") + */path: String, /** - * Sequence number - */sequence: UInt32, + * Compressed public key (hex encoded) + */publicKey: String, /** - * Script signature (hex-encoded) - */scriptSig: String, + * Chain code (hex encoded) + */chainCode: String, /** - * Witness stack (each element hex-encoded) - */witness: [String]) { - self.txid = txid - self.vout = vout - self.sequence = sequence - self.scriptSig = scriptSig - self.witness = witness + * Parent key fingerprint + */fingerprint: UInt32, + /** + * Derivation depth + */depth: UInt32, + /** + * Master root fingerprint (from the device's master seed) + */rootFingerprint: UInt32?) { + self.xpub = xpub + self.path = path + self.publicKey = publicKey + self.chainCode = chainCode + self.fingerprint = fingerprint + self.depth = depth + self.rootFingerprint = rootFingerprint } } #if compiler(>=6) -extension TxDetailInput: Sendable {} +extension TrezorPublicKeyResponse: Sendable {} #endif -extension TxDetailInput: Equatable, Hashable { - public static func ==(lhs: TxDetailInput, rhs: TxDetailInput) -> Bool { - if lhs.txid != rhs.txid { +extension TrezorPublicKeyResponse: Equatable, Hashable { + public static func ==(lhs: TrezorPublicKeyResponse, rhs: TrezorPublicKeyResponse) -> Bool { + if lhs.xpub != rhs.xpub { return false } - if lhs.vout != rhs.vout { + if lhs.path != rhs.path { return false } - if lhs.sequence != rhs.sequence { + if lhs.publicKey != rhs.publicKey { return false } - if lhs.scriptSig != rhs.scriptSig { + if lhs.chainCode != rhs.chainCode { return false } - if lhs.witness != rhs.witness { + if lhs.fingerprint != rhs.fingerprint { + return false + } + if lhs.depth != rhs.depth { + return false + } + if lhs.rootFingerprint != rhs.rootFingerprint { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(txid) - hasher.combine(vout) - hasher.combine(sequence) - hasher.combine(scriptSig) - hasher.combine(witness) + hasher.combine(xpub) + hasher.combine(path) + hasher.combine(publicKey) + hasher.combine(chainCode) + hasher.combine(fingerprint) + hasher.combine(depth) + hasher.combine(rootFingerprint) } } -extension TxDetailInput: Codable {} +extension TrezorPublicKeyResponse: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeTxDetailInput: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TxDetailInput { +public struct FfiConverterTypeTrezorPublicKeyResponse: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorPublicKeyResponse { return - try TxDetailInput( - txid: FfiConverterString.read(from: &buf), - vout: FfiConverterUInt32.read(from: &buf), - sequence: FfiConverterUInt32.read(from: &buf), - scriptSig: FfiConverterString.read(from: &buf), - witness: FfiConverterSequenceString.read(from: &buf) + try TrezorPublicKeyResponse( + xpub: FfiConverterString.read(from: &buf), + path: FfiConverterString.read(from: &buf), + publicKey: FfiConverterString.read(from: &buf), + chainCode: FfiConverterString.read(from: &buf), + fingerprint: FfiConverterUInt32.read(from: &buf), + depth: FfiConverterUInt32.read(from: &buf), + rootFingerprint: FfiConverterOptionUInt32.read(from: &buf) ) } - public static func write(_ value: TxDetailInput, into buf: inout [UInt8]) { - FfiConverterString.write(value.txid, into: &buf) - FfiConverterUInt32.write(value.vout, into: &buf) - FfiConverterUInt32.write(value.sequence, into: &buf) - FfiConverterString.write(value.scriptSig, into: &buf) - FfiConverterSequenceString.write(value.witness, into: &buf) + public static func write(_ value: TrezorPublicKeyResponse, into buf: inout [UInt8]) { + FfiConverterString.write(value.xpub, into: &buf) + FfiConverterString.write(value.path, into: &buf) + FfiConverterString.write(value.publicKey, into: &buf) + FfiConverterString.write(value.chainCode, into: &buf) + FfiConverterUInt32.write(value.fingerprint, into: &buf) + FfiConverterUInt32.write(value.depth, into: &buf) + FfiConverterOptionUInt32.write(value.rootFingerprint, into: &buf) } } @@ -13852,114 +13935,100 @@ public struct FfiConverterTypeTxDetailInput: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTxDetailInput_lift(_ buf: RustBuffer) throws -> TxDetailInput { - return try FfiConverterTypeTxDetailInput.lift(buf) +public func FfiConverterTypeTrezorPublicKeyResponse_lift(_ buf: RustBuffer) throws -> TrezorPublicKeyResponse { + return try FfiConverterTypeTrezorPublicKeyResponse.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTxDetailInput_lower(_ value: TxDetailInput) -> RustBuffer { - return FfiConverterTypeTxDetailInput.lower(value) +public func FfiConverterTypeTrezorPublicKeyResponse_lower(_ value: TrezorPublicKeyResponse) -> RustBuffer { + return FfiConverterTypeTrezorPublicKeyResponse.lower(value) } /** - * A transaction output with full details. + * Parameters for signing a message. */ -public struct TxDetailOutput { - /** - * Output value in sats - */ - public var value: UInt64 +public struct TrezorSignMessageParams { /** - * Script public key (hex-encoded) + * BIP32 path for the signing key (e.g., "m/84'/0'/0'/0/0") */ - public var scriptPubkey: String + public var path: String /** - * Decoded address (None if script is not decodable to an address) + * Message to sign */ - public var address: String? + public var message: String /** - * Whether this output belongs to the queried wallet + * Coin network (default: Bitcoin) */ - public var isMine: Bool + public var coin: TrezorCoinType? // Default memberwise initializers are never public by default, so we // declare one manually. public init( /** - * Output value in sats - */value: UInt64, - /** - * Script public key (hex-encoded) - */scriptPubkey: String, + * BIP32 path for the signing key (e.g., "m/84'/0'/0'/0/0") + */path: String, /** - * Decoded address (None if script is not decodable to an address) - */address: String?, + * Message to sign + */message: String, /** - * Whether this output belongs to the queried wallet - */isMine: Bool) { - self.value = value - self.scriptPubkey = scriptPubkey - self.address = address - self.isMine = isMine + * Coin network (default: Bitcoin) + */coin: TrezorCoinType?) { + self.path = path + self.message = message + self.coin = coin } } #if compiler(>=6) -extension TxDetailOutput: Sendable {} +extension TrezorSignMessageParams: Sendable {} #endif -extension TxDetailOutput: Equatable, Hashable { - public static func ==(lhs: TxDetailOutput, rhs: TxDetailOutput) -> Bool { - if lhs.value != rhs.value { - return false - } - if lhs.scriptPubkey != rhs.scriptPubkey { +extension TrezorSignMessageParams: Equatable, Hashable { + public static func ==(lhs: TrezorSignMessageParams, rhs: TrezorSignMessageParams) -> Bool { + if lhs.path != rhs.path { return false } - if lhs.address != rhs.address { + if lhs.message != rhs.message { return false } - if lhs.isMine != rhs.isMine { + if lhs.coin != rhs.coin { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(value) - hasher.combine(scriptPubkey) - hasher.combine(address) - hasher.combine(isMine) + hasher.combine(path) + hasher.combine(message) + hasher.combine(coin) } } -extension TxDetailOutput: Codable {} +extension TrezorSignMessageParams: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeTxDetailOutput: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TxDetailOutput { +public struct FfiConverterTypeTrezorSignMessageParams: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorSignMessageParams { return - try TxDetailOutput( - value: FfiConverterUInt64.read(from: &buf), - scriptPubkey: FfiConverterString.read(from: &buf), - address: FfiConverterOptionString.read(from: &buf), - isMine: FfiConverterBool.read(from: &buf) + try TrezorSignMessageParams( + path: FfiConverterString.read(from: &buf), + message: FfiConverterString.read(from: &buf), + coin: FfiConverterOptionTypeTrezorCoinType.read(from: &buf) ) } - public static func write(_ value: TxDetailOutput, into buf: inout [UInt8]) { - FfiConverterUInt64.write(value.value, into: &buf) - FfiConverterString.write(value.scriptPubkey, into: &buf) - FfiConverterOptionString.write(value.address, into: &buf) - FfiConverterBool.write(value.isMine, into: &buf) + public static func write(_ value: TrezorSignMessageParams, into buf: inout [UInt8]) { + FfiConverterString.write(value.path, into: &buf) + FfiConverterString.write(value.message, into: &buf) + FfiConverterOptionTypeTrezorCoinType.write(value.coin, into: &buf) } } @@ -13967,128 +14036,142 @@ public struct FfiConverterTypeTxDetailOutput: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTxDetailOutput_lift(_ buf: RustBuffer) throws -> TxDetailOutput { - return try FfiConverterTypeTxDetailOutput.lift(buf) +public func FfiConverterTypeTrezorSignMessageParams_lift(_ buf: RustBuffer) throws -> TrezorSignMessageParams { + return try FfiConverterTypeTrezorSignMessageParams.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTxDetailOutput_lower(_ value: TxDetailOutput) -> RustBuffer { - return FfiConverterTypeTxDetailOutput.lower(value) -} +public func FfiConverterTypeTrezorSignMessageParams_lower(_ value: TrezorSignMessageParams) -> RustBuffer { + return FfiConverterTypeTrezorSignMessageParams.lower(value) +} /** - * Details about a transaction input. + * Parameters for signing a transaction. */ -public struct TxInput { +public struct TrezorSignTxParams { /** - * The transaction ID of the previous output being spent. + * Transaction inputs */ - public var txid: String + public var inputs: [TrezorTxInput] /** - * The output index of the previous output being spent. + * Transaction outputs */ - public var vout: UInt32 + public var outputs: [TrezorTxOutput] /** - * The script signature (hex-encoded). + * Coin network (default: Bitcoin) */ - public var scriptsig: String + public var coin: TrezorCoinType? /** - * The witness stack (hex-encoded strings). + * Lock time (default: 0) */ - public var witness: [String] + public var lockTime: UInt32? /** - * The sequence number. + * Version (default: 2) */ - public var sequence: UInt32 + public var version: UInt32? + /** + * Previous transactions (for non-SegWit input verification) + */ + public var prevTxs: [TrezorPrevTx] // Default memberwise initializers are never public by default, so we // declare one manually. public init( /** - * The transaction ID of the previous output being spent. - */txid: String, + * Transaction inputs + */inputs: [TrezorTxInput], /** - * The output index of the previous output being spent. - */vout: UInt32, + * Transaction outputs + */outputs: [TrezorTxOutput], /** - * The script signature (hex-encoded). - */scriptsig: String, + * Coin network (default: Bitcoin) + */coin: TrezorCoinType?, /** - * The witness stack (hex-encoded strings). - */witness: [String], + * Lock time (default: 0) + */lockTime: UInt32?, /** - * The sequence number. - */sequence: UInt32) { - self.txid = txid - self.vout = vout - self.scriptsig = scriptsig - self.witness = witness - self.sequence = sequence + * Version (default: 2) + */version: UInt32?, + /** + * Previous transactions (for non-SegWit input verification) + */prevTxs: [TrezorPrevTx]) { + self.inputs = inputs + self.outputs = outputs + self.coin = coin + self.lockTime = lockTime + self.version = version + self.prevTxs = prevTxs } } #if compiler(>=6) -extension TxInput: Sendable {} +extension TrezorSignTxParams: Sendable {} #endif -extension TxInput: Equatable, Hashable { - public static func ==(lhs: TxInput, rhs: TxInput) -> Bool { - if lhs.txid != rhs.txid { +extension TrezorSignTxParams: Equatable, Hashable { + public static func ==(lhs: TrezorSignTxParams, rhs: TrezorSignTxParams) -> Bool { + if lhs.inputs != rhs.inputs { return false } - if lhs.vout != rhs.vout { + if lhs.outputs != rhs.outputs { return false } - if lhs.scriptsig != rhs.scriptsig { + if lhs.coin != rhs.coin { return false } - if lhs.witness != rhs.witness { + if lhs.lockTime != rhs.lockTime { return false } - if lhs.sequence != rhs.sequence { + if lhs.version != rhs.version { + return false + } + if lhs.prevTxs != rhs.prevTxs { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(txid) - hasher.combine(vout) - hasher.combine(scriptsig) - hasher.combine(witness) - hasher.combine(sequence) + hasher.combine(inputs) + hasher.combine(outputs) + hasher.combine(coin) + hasher.combine(lockTime) + hasher.combine(version) + hasher.combine(prevTxs) } } -extension TxInput: Codable {} +extension TrezorSignTxParams: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeTxInput: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TxInput { +public struct FfiConverterTypeTrezorSignTxParams: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorSignTxParams { return - try TxInput( - txid: FfiConverterString.read(from: &buf), - vout: FfiConverterUInt32.read(from: &buf), - scriptsig: FfiConverterString.read(from: &buf), - witness: FfiConverterSequenceString.read(from: &buf), - sequence: FfiConverterUInt32.read(from: &buf) + try TrezorSignTxParams( + inputs: FfiConverterSequenceTypeTrezorTxInput.read(from: &buf), + outputs: FfiConverterSequenceTypeTrezorTxOutput.read(from: &buf), + coin: FfiConverterOptionTypeTrezorCoinType.read(from: &buf), + lockTime: FfiConverterOptionUInt32.read(from: &buf), + version: FfiConverterOptionUInt32.read(from: &buf), + prevTxs: FfiConverterSequenceTypeTrezorPrevTx.read(from: &buf) ) } - public static func write(_ value: TxInput, into buf: inout [UInt8]) { - FfiConverterString.write(value.txid, into: &buf) - FfiConverterUInt32.write(value.vout, into: &buf) - FfiConverterString.write(value.scriptsig, into: &buf) - FfiConverterSequenceString.write(value.witness, into: &buf) - FfiConverterUInt32.write(value.sequence, into: &buf) + public static func write(_ value: TrezorSignTxParams, into buf: inout [UInt8]) { + FfiConverterSequenceTypeTrezorTxInput.write(value.inputs, into: &buf) + FfiConverterSequenceTypeTrezorTxOutput.write(value.outputs, into: &buf) + FfiConverterOptionTypeTrezorCoinType.write(value.coin, into: &buf) + FfiConverterOptionUInt32.write(value.lockTime, into: &buf) + FfiConverterOptionUInt32.write(value.version, into: &buf) + FfiConverterSequenceTypeTrezorPrevTx.write(value.prevTxs, into: &buf) } } @@ -14096,128 +14179,86 @@ public struct FfiConverterTypeTxInput: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTxInput_lift(_ buf: RustBuffer) throws -> TxInput { - return try FfiConverterTypeTxInput.lift(buf) +public func FfiConverterTypeTrezorSignTxParams_lift(_ buf: RustBuffer) throws -> TrezorSignTxParams { + return try FfiConverterTypeTrezorSignTxParams.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTxInput_lower(_ value: TxInput) -> RustBuffer { - return FfiConverterTypeTxInput.lower(value) +public func FfiConverterTypeTrezorSignTxParams_lower(_ value: TrezorSignTxParams) -> RustBuffer { + return FfiConverterTypeTrezorSignTxParams.lower(value) } /** - * Details about a transaction output. + * Response from signing a message. */ -public struct TxOutput { - /** - * The script public key (hex-encoded). - */ - public var scriptpubkey: String - /** - * The script public key type (e.g., "p2pkh", "p2sh", "p2wpkh", "p2wsh", "p2tr"). - */ - public var scriptpubkeyType: String? - /** - * The address corresponding to this script (if decodable). - */ - public var scriptpubkeyAddress: String? +public struct TrezorSignedMessageResponse { /** - * The value in satoshis. + * Bitcoin address that signed the message */ - public var value: Int64 + public var address: String /** - * The output index in the transaction. + * Signature (base64 encoded) */ - public var n: UInt32 + public var signature: String // Default memberwise initializers are never public by default, so we // declare one manually. public init( /** - * The script public key (hex-encoded). - */scriptpubkey: String, - /** - * The script public key type (e.g., "p2pkh", "p2sh", "p2wpkh", "p2wsh", "p2tr"). - */scriptpubkeyType: String?, - /** - * The address corresponding to this script (if decodable). - */scriptpubkeyAddress: String?, - /** - * The value in satoshis. - */value: Int64, + * Bitcoin address that signed the message + */address: String, /** - * The output index in the transaction. - */n: UInt32) { - self.scriptpubkey = scriptpubkey - self.scriptpubkeyType = scriptpubkeyType - self.scriptpubkeyAddress = scriptpubkeyAddress - self.value = value - self.n = n + * Signature (base64 encoded) + */signature: String) { + self.address = address + self.signature = signature } } #if compiler(>=6) -extension TxOutput: Sendable {} +extension TrezorSignedMessageResponse: Sendable {} #endif -extension TxOutput: Equatable, Hashable { - public static func ==(lhs: TxOutput, rhs: TxOutput) -> Bool { - if lhs.scriptpubkey != rhs.scriptpubkey { - return false - } - if lhs.scriptpubkeyType != rhs.scriptpubkeyType { - return false - } - if lhs.scriptpubkeyAddress != rhs.scriptpubkeyAddress { - return false - } - if lhs.value != rhs.value { +extension TrezorSignedMessageResponse: Equatable, Hashable { + public static func ==(lhs: TrezorSignedMessageResponse, rhs: TrezorSignedMessageResponse) -> Bool { + if lhs.address != rhs.address { return false } - if lhs.n != rhs.n { + if lhs.signature != rhs.signature { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(scriptpubkey) - hasher.combine(scriptpubkeyType) - hasher.combine(scriptpubkeyAddress) - hasher.combine(value) - hasher.combine(n) + hasher.combine(address) + hasher.combine(signature) } } -extension TxOutput: Codable {} +extension TrezorSignedMessageResponse: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeTxOutput: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TxOutput { +public struct FfiConverterTypeTrezorSignedMessageResponse: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorSignedMessageResponse { return - try TxOutput( - scriptpubkey: FfiConverterString.read(from: &buf), - scriptpubkeyType: FfiConverterOptionString.read(from: &buf), - scriptpubkeyAddress: FfiConverterOptionString.read(from: &buf), - value: FfiConverterInt64.read(from: &buf), - n: FfiConverterUInt32.read(from: &buf) + try TrezorSignedMessageResponse( + address: FfiConverterString.read(from: &buf), + signature: FfiConverterString.read(from: &buf) ) } - public static func write(_ value: TxOutput, into buf: inout [UInt8]) { - FfiConverterString.write(value.scriptpubkey, into: &buf) - FfiConverterOptionString.write(value.scriptpubkeyType, into: &buf) - FfiConverterOptionString.write(value.scriptpubkeyAddress, into: &buf) - FfiConverterInt64.write(value.value, into: &buf) - FfiConverterUInt32.write(value.n, into: &buf) + public static func write(_ value: TrezorSignedMessageResponse, into buf: inout [UInt8]) { + FfiConverterString.write(value.address, into: &buf) + FfiConverterString.write(value.signature, into: &buf) } } @@ -14225,100 +14266,100 @@ public struct FfiConverterTypeTxOutput: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTxOutput_lift(_ buf: RustBuffer) throws -> TxOutput { - return try FfiConverterTypeTxOutput.lift(buf) +public func FfiConverterTypeTrezorSignedMessageResponse_lift(_ buf: RustBuffer) throws -> TrezorSignedMessageResponse { + return try FfiConverterTypeTrezorSignedMessageResponse.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeTxOutput_lower(_ value: TxOutput) -> RustBuffer { - return FfiConverterTypeTxOutput.lower(value) +public func FfiConverterTypeTrezorSignedMessageResponse_lower(_ value: TrezorSignedMessageResponse) -> RustBuffer { + return FfiConverterTypeTrezorSignedMessageResponse.lower(value) } /** - * Current state after accepting a scanned UR frame. + * Signed transaction result. */ -public struct UrDecoderStatus { +public struct TrezorSignedTx { /** - * Estimated completion from 0.0 through 1.0. + * Signatures for each input (hex encoded) */ - public var progress: Double + public var signatures: [String] /** - * Fountain source-fragment count, or 1 for a single-part UR. + * Serialized transaction (hex) */ - public var fragmentCount: UInt32 + public var serializedTx: String /** - * Present once the complete message has been decoded. + * Broadcast transaction ID (populated when push=true) */ - public var payload: UrPayload? + public var txid: String? // Default memberwise initializers are never public by default, so we // declare one manually. public init( /** - * Estimated completion from 0.0 through 1.0. - */progress: Double, + * Signatures for each input (hex encoded) + */signatures: [String], /** - * Fountain source-fragment count, or 1 for a single-part UR. - */fragmentCount: UInt32, + * Serialized transaction (hex) + */serializedTx: String, /** - * Present once the complete message has been decoded. - */payload: UrPayload?) { - self.progress = progress - self.fragmentCount = fragmentCount - self.payload = payload + * Broadcast transaction ID (populated when push=true) + */txid: String?) { + self.signatures = signatures + self.serializedTx = serializedTx + self.txid = txid } } #if compiler(>=6) -extension UrDecoderStatus: Sendable {} +extension TrezorSignedTx: Sendable {} #endif -extension UrDecoderStatus: Equatable, Hashable { - public static func ==(lhs: UrDecoderStatus, rhs: UrDecoderStatus) -> Bool { - if lhs.progress != rhs.progress { +extension TrezorSignedTx: Equatable, Hashable { + public static func ==(lhs: TrezorSignedTx, rhs: TrezorSignedTx) -> Bool { + if lhs.signatures != rhs.signatures { return false } - if lhs.fragmentCount != rhs.fragmentCount { + if lhs.serializedTx != rhs.serializedTx { return false } - if lhs.payload != rhs.payload { + if lhs.txid != rhs.txid { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(progress) - hasher.combine(fragmentCount) - hasher.combine(payload) + hasher.combine(signatures) + hasher.combine(serializedTx) + hasher.combine(txid) } } -extension UrDecoderStatus: Codable {} +extension TrezorSignedTx: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeUrDecoderStatus: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> UrDecoderStatus { +public struct FfiConverterTypeTrezorSignedTx: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorSignedTx { return - try UrDecoderStatus( - progress: FfiConverterDouble.read(from: &buf), - fragmentCount: FfiConverterUInt32.read(from: &buf), - payload: FfiConverterOptionTypeUrPayload.read(from: &buf) + try TrezorSignedTx( + signatures: FfiConverterSequenceString.read(from: &buf), + serializedTx: FfiConverterString.read(from: &buf), + txid: FfiConverterOptionString.read(from: &buf) ) } - public static func write(_ value: UrDecoderStatus, into buf: inout [UInt8]) { - FfiConverterDouble.write(value.progress, into: &buf) - FfiConverterUInt32.write(value.fragmentCount, into: &buf) - FfiConverterOptionTypeUrPayload.write(value.payload, into: &buf) + public static func write(_ value: TrezorSignedTx, into buf: inout [UInt8]) { + FfiConverterSequenceString.write(value.signatures, into: &buf) + FfiConverterString.write(value.serializedTx, into: &buf) + FfiConverterOptionString.write(value.txid, into: &buf) } } @@ -14326,79 +14367,114 @@ public struct FfiConverterTypeUrDecoderStatus: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeUrDecoderStatus_lift(_ buf: RustBuffer) throws -> UrDecoderStatus { - return try FfiConverterTypeUrDecoderStatus.lift(buf) +public func FfiConverterTypeTrezorSignedTx_lift(_ buf: RustBuffer) throws -> TrezorSignedTx { + return try FfiConverterTypeTrezorSignedTx.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeUrDecoderStatus_lower(_ value: UrDecoderStatus) -> RustBuffer { - return FfiConverterTypeUrDecoderStatus.lower(value) +public func FfiConverterTypeTrezorSignedTx_lower(_ value: TrezorSignedTx) -> RustBuffer { + return FfiConverterTypeTrezorSignedTx.lower(value) } -public struct ValidationResult { - public var address: String - public var network: NetworkType - public var addressType: AddressType +/** + * Result from a transport read operation + */ +public struct TrezorTransportReadResult { + /** + * Whether the read succeeded + */ + public var success: Bool + /** + * Data read (empty on failure) + */ + public var data: Data + /** + * Error message (empty on success) + */ + public var error: String + /** + * Structured error code (None on success or when the native error is generic) + */ + public var errorCode: TrezorTransportErrorCode? // Default memberwise initializers are never public by default, so we // declare one manually. - public init(address: String, network: NetworkType, addressType: AddressType) { - self.address = address - self.network = network - self.addressType = addressType + public init( + /** + * Whether the read succeeded + */success: Bool, + /** + * Data read (empty on failure) + */data: Data, + /** + * Error message (empty on success) + */error: String, + /** + * Structured error code (None on success or when the native error is generic) + */errorCode: TrezorTransportErrorCode?) { + self.success = success + self.data = data + self.error = error + self.errorCode = errorCode } } #if compiler(>=6) -extension ValidationResult: Sendable {} +extension TrezorTransportReadResult: Sendable {} #endif -extension ValidationResult: Equatable, Hashable { - public static func ==(lhs: ValidationResult, rhs: ValidationResult) -> Bool { - if lhs.address != rhs.address { +extension TrezorTransportReadResult: Equatable, Hashable { + public static func ==(lhs: TrezorTransportReadResult, rhs: TrezorTransportReadResult) -> Bool { + if lhs.success != rhs.success { return false } - if lhs.network != rhs.network { + if lhs.data != rhs.data { return false } - if lhs.addressType != rhs.addressType { + if lhs.error != rhs.error { + return false + } + if lhs.errorCode != rhs.errorCode { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(address) - hasher.combine(network) - hasher.combine(addressType) + hasher.combine(success) + hasher.combine(data) + hasher.combine(error) + hasher.combine(errorCode) } } -extension ValidationResult: Codable {} +extension TrezorTransportReadResult: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeValidationResult: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ValidationResult { +public struct FfiConverterTypeTrezorTransportReadResult: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorTransportReadResult { return - try ValidationResult( - address: FfiConverterString.read(from: &buf), - network: FfiConverterTypeNetworkType.read(from: &buf), - addressType: FfiConverterTypeAddressType.read(from: &buf) + try TrezorTransportReadResult( + success: FfiConverterBool.read(from: &buf), + data: FfiConverterData.read(from: &buf), + error: FfiConverterString.read(from: &buf), + errorCode: FfiConverterOptionTypeTrezorTransportErrorCode.read(from: &buf) ) } - public static func write(_ value: ValidationResult, into buf: inout [UInt8]) { - FfiConverterString.write(value.address, into: &buf) - FfiConverterTypeNetworkType.write(value.network, into: &buf) - FfiConverterTypeAddressType.write(value.addressType, into: &buf) + public static func write(_ value: TrezorTransportReadResult, into buf: inout [UInt8]) { + FfiConverterBool.write(value.success, into: &buf) + FfiConverterData.write(value.data, into: &buf) + FfiConverterString.write(value.error, into: &buf) + FfiConverterOptionTypeTrezorTransportErrorCode.write(value.errorCode, into: &buf) } } @@ -14406,142 +14482,100 @@ public struct FfiConverterTypeValidationResult: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeValidationResult_lift(_ buf: RustBuffer) throws -> ValidationResult { - return try FfiConverterTypeValidationResult.lift(buf) +public func FfiConverterTypeTrezorTransportReadResult_lift(_ buf: RustBuffer) throws -> TrezorTransportReadResult { + return try FfiConverterTypeTrezorTransportReadResult.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeValidationResult_lower(_ value: ValidationResult) -> RustBuffer { - return FfiConverterTypeValidationResult.lower(value) +public func FfiConverterTypeTrezorTransportReadResult_lower(_ value: TrezorTransportReadResult) -> RustBuffer { + return FfiConverterTypeTrezorTransportReadResult.lower(value) } /** - * Balance breakdown from BDK. + * Result from a transport write or open operation */ -public struct WalletBalance { - /** - * Confirmed and spendable balance (sats) - */ - public var confirmed: UInt64 - /** - * Immature coinbase outputs (sats) - */ - public var immature: UInt64 - /** - * Unconfirmed UTXOs from trusted sources (own change) (sats) - */ - public var trustedPending: UInt64 +public struct TrezorTransportWriteResult { /** - * Unconfirmed UTXOs from external sources (sats) + * Whether the operation succeeded */ - public var untrustedPending: UInt64 + public var success: Bool /** - * Total spendable: confirmed + trusted_pending (sats) + * Error message (empty on success) */ - public var spendable: UInt64 + public var error: String /** - * Grand total: all categories (sats) + * Structured error code (None on success or when the native error is generic) */ - public var total: UInt64 + public var errorCode: TrezorTransportErrorCode? // Default memberwise initializers are never public by default, so we // declare one manually. public init( /** - * Confirmed and spendable balance (sats) - */confirmed: UInt64, - /** - * Immature coinbase outputs (sats) - */immature: UInt64, - /** - * Unconfirmed UTXOs from trusted sources (own change) (sats) - */trustedPending: UInt64, - /** - * Unconfirmed UTXOs from external sources (sats) - */untrustedPending: UInt64, + * Whether the operation succeeded + */success: Bool, /** - * Total spendable: confirmed + trusted_pending (sats) - */spendable: UInt64, + * Error message (empty on success) + */error: String, /** - * Grand total: all categories (sats) - */total: UInt64) { - self.confirmed = confirmed - self.immature = immature - self.trustedPending = trustedPending - self.untrustedPending = untrustedPending - self.spendable = spendable - self.total = total + * Structured error code (None on success or when the native error is generic) + */errorCode: TrezorTransportErrorCode?) { + self.success = success + self.error = error + self.errorCode = errorCode } } #if compiler(>=6) -extension WalletBalance: Sendable {} +extension TrezorTransportWriteResult: Sendable {} #endif -extension WalletBalance: Equatable, Hashable { - public static func ==(lhs: WalletBalance, rhs: WalletBalance) -> Bool { - if lhs.confirmed != rhs.confirmed { - return false - } - if lhs.immature != rhs.immature { - return false - } - if lhs.trustedPending != rhs.trustedPending { - return false - } - if lhs.untrustedPending != rhs.untrustedPending { +extension TrezorTransportWriteResult: Equatable, Hashable { + public static func ==(lhs: TrezorTransportWriteResult, rhs: TrezorTransportWriteResult) -> Bool { + if lhs.success != rhs.success { return false } - if lhs.spendable != rhs.spendable { + if lhs.error != rhs.error { return false } - if lhs.total != rhs.total { + if lhs.errorCode != rhs.errorCode { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(confirmed) - hasher.combine(immature) - hasher.combine(trustedPending) - hasher.combine(untrustedPending) - hasher.combine(spendable) - hasher.combine(total) + hasher.combine(success) + hasher.combine(error) + hasher.combine(errorCode) } } -extension WalletBalance: Codable {} +extension TrezorTransportWriteResult: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeWalletBalance: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> WalletBalance { +public struct FfiConverterTypeTrezorTransportWriteResult: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorTransportWriteResult { return - try WalletBalance( - confirmed: FfiConverterUInt64.read(from: &buf), - immature: FfiConverterUInt64.read(from: &buf), - trustedPending: FfiConverterUInt64.read(from: &buf), - untrustedPending: FfiConverterUInt64.read(from: &buf), - spendable: FfiConverterUInt64.read(from: &buf), - total: FfiConverterUInt64.read(from: &buf) + try TrezorTransportWriteResult( + success: FfiConverterBool.read(from: &buf), + error: FfiConverterString.read(from: &buf), + errorCode: FfiConverterOptionTypeTrezorTransportErrorCode.read(from: &buf) ) } - public static func write(_ value: WalletBalance, into buf: inout [UInt8]) { - FfiConverterUInt64.write(value.confirmed, into: &buf) - FfiConverterUInt64.write(value.immature, into: &buf) - FfiConverterUInt64.write(value.trustedPending, into: &buf) - FfiConverterUInt64.write(value.untrustedPending, into: &buf) - FfiConverterUInt64.write(value.spendable, into: &buf) - FfiConverterUInt64.write(value.total, into: &buf) + public static func write(_ value: TrezorTransportWriteResult, into buf: inout [UInt8]) { + FfiConverterBool.write(value.success, into: &buf) + FfiConverterString.write(value.error, into: &buf) + FfiConverterOptionTypeTrezorTransportErrorCode.write(value.errorCode, into: &buf) } } @@ -14549,128 +14583,170 @@ public struct FfiConverterTypeWalletBalance: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeWalletBalance_lift(_ buf: RustBuffer) throws -> WalletBalance { - return try FfiConverterTypeWalletBalance.lift(buf) +public func FfiConverterTypeTrezorTransportWriteResult_lift(_ buf: RustBuffer) throws -> TrezorTransportWriteResult { + return try FfiConverterTypeTrezorTransportWriteResult.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeWalletBalance_lower(_ value: WalletBalance) -> RustBuffer { - return FfiConverterTypeWalletBalance.lower(value) +public func FfiConverterTypeTrezorTransportWriteResult_lower(_ value: TrezorTransportWriteResult) -> RustBuffer { + return FfiConverterTypeTrezorTransportWriteResult.lower(value) } /** - * Common parameters for creating and syncing a watch-only BDK wallet. + * Transaction input for signing. */ -public struct WalletParams { +public struct TrezorTxInput { /** - * Extended public key (xpub/ypub/zpub/tpub/upub/vpub) + * Previous transaction hash (hex, 32 bytes) */ - public var extendedKey: String + public var prevHash: String /** - * Electrum server URL for wallet sync + * Previous output index */ - public var electrumUrl: String + public var prevIndex: UInt32 /** - * Root fingerprint hex (e.g. "73c5da0a"). Required for hardware wallet signing. + * BIP32 derivation path (e.g., "m/84'/0'/0'/0/0") */ - public var fingerprint: String? + public var path: String /** - * Bitcoin network (auto-detected from key prefix if not specified) + * Amount in satoshis */ - public var network: Network? + public var amount: UInt64 /** - * Override account type for ambiguous key prefixes (xpub/tpub) + * Script type */ - public var accountType: AccountType? + public var scriptType: TrezorScriptType + /** + * Sequence number (default: 0xFFFFFFFD for RBF) + */ + public var sequence: UInt32? + /** + * Original transaction hash for RBF replacement (hex encoded) + */ + public var origHash: String? + /** + * Original input index for RBF replacement + */ + public var origIndex: UInt32? // Default memberwise initializers are never public by default, so we // declare one manually. public init( /** - * Extended public key (xpub/ypub/zpub/tpub/upub/vpub) - */extendedKey: String, + * Previous transaction hash (hex, 32 bytes) + */prevHash: String, /** - * Electrum server URL for wallet sync - */electrumUrl: String, + * Previous output index + */prevIndex: UInt32, /** - * Root fingerprint hex (e.g. "73c5da0a"). Required for hardware wallet signing. - */fingerprint: String?, + * BIP32 derivation path (e.g., "m/84'/0'/0'/0/0") + */path: String, /** - * Bitcoin network (auto-detected from key prefix if not specified) - */network: Network?, + * Amount in satoshis + */amount: UInt64, /** - * Override account type for ambiguous key prefixes (xpub/tpub) - */accountType: AccountType?) { - self.extendedKey = extendedKey - self.electrumUrl = electrumUrl - self.fingerprint = fingerprint - self.network = network - self.accountType = accountType + * Script type + */scriptType: TrezorScriptType, + /** + * Sequence number (default: 0xFFFFFFFD for RBF) + */sequence: UInt32?, + /** + * Original transaction hash for RBF replacement (hex encoded) + */origHash: String?, + /** + * Original input index for RBF replacement + */origIndex: UInt32?) { + self.prevHash = prevHash + self.prevIndex = prevIndex + self.path = path + self.amount = amount + self.scriptType = scriptType + self.sequence = sequence + self.origHash = origHash + self.origIndex = origIndex } } #if compiler(>=6) -extension WalletParams: Sendable {} +extension TrezorTxInput: Sendable {} #endif -extension WalletParams: Equatable, Hashable { - public static func ==(lhs: WalletParams, rhs: WalletParams) -> Bool { - if lhs.extendedKey != rhs.extendedKey { +extension TrezorTxInput: Equatable, Hashable { + public static func ==(lhs: TrezorTxInput, rhs: TrezorTxInput) -> Bool { + if lhs.prevHash != rhs.prevHash { return false } - if lhs.electrumUrl != rhs.electrumUrl { + if lhs.prevIndex != rhs.prevIndex { return false } - if lhs.fingerprint != rhs.fingerprint { + if lhs.path != rhs.path { return false } - if lhs.network != rhs.network { + if lhs.amount != rhs.amount { return false } - if lhs.accountType != rhs.accountType { + if lhs.scriptType != rhs.scriptType { + return false + } + if lhs.sequence != rhs.sequence { + return false + } + if lhs.origHash != rhs.origHash { + return false + } + if lhs.origIndex != rhs.origIndex { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(extendedKey) - hasher.combine(electrumUrl) - hasher.combine(fingerprint) - hasher.combine(network) - hasher.combine(accountType) + hasher.combine(prevHash) + hasher.combine(prevIndex) + hasher.combine(path) + hasher.combine(amount) + hasher.combine(scriptType) + hasher.combine(sequence) + hasher.combine(origHash) + hasher.combine(origIndex) } } -extension WalletParams: Codable {} +extension TrezorTxInput: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeWalletParams: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> WalletParams { +public struct FfiConverterTypeTrezorTxInput: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorTxInput { return - try WalletParams( - extendedKey: FfiConverterString.read(from: &buf), - electrumUrl: FfiConverterString.read(from: &buf), - fingerprint: FfiConverterOptionString.read(from: &buf), - network: FfiConverterOptionTypeNetwork.read(from: &buf), - accountType: FfiConverterOptionTypeAccountType.read(from: &buf) + try TrezorTxInput( + prevHash: FfiConverterString.read(from: &buf), + prevIndex: FfiConverterUInt32.read(from: &buf), + path: FfiConverterString.read(from: &buf), + amount: FfiConverterUInt64.read(from: &buf), + scriptType: FfiConverterTypeTrezorScriptType.read(from: &buf), + sequence: FfiConverterOptionUInt32.read(from: &buf), + origHash: FfiConverterOptionString.read(from: &buf), + origIndex: FfiConverterOptionUInt32.read(from: &buf) ) } - public static func write(_ value: WalletParams, into buf: inout [UInt8]) { - FfiConverterString.write(value.extendedKey, into: &buf) - FfiConverterString.write(value.electrumUrl, into: &buf) - FfiConverterOptionString.write(value.fingerprint, into: &buf) - FfiConverterOptionTypeNetwork.write(value.network, into: &buf) - FfiConverterOptionTypeAccountType.write(value.accountType, into: &buf) + public static func write(_ value: TrezorTxInput, into buf: inout [UInt8]) { + FfiConverterString.write(value.prevHash, into: &buf) + FfiConverterUInt32.write(value.prevIndex, into: &buf) + FfiConverterString.write(value.path, into: &buf) + FfiConverterUInt64.write(value.amount, into: &buf) + FfiConverterTypeTrezorScriptType.write(value.scriptType, into: &buf) + FfiConverterOptionUInt32.write(value.sequence, into: &buf) + FfiConverterOptionString.write(value.origHash, into: &buf) + FfiConverterOptionUInt32.write(value.origIndex, into: &buf) } } @@ -14678,160 +14754,156 @@ public struct FfiConverterTypeWalletParams: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeWalletParams_lift(_ buf: RustBuffer) throws -> WalletParams { - return try FfiConverterTypeWalletParams.lift(buf) +public func FfiConverterTypeTrezorTxInput_lift(_ buf: RustBuffer) throws -> TrezorTxInput { + return try FfiConverterTypeTrezorTxInput.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeWalletParams_lower(_ value: WalletParams) -> RustBuffer { - return FfiConverterTypeWalletParams.lower(value) +public func FfiConverterTypeTrezorTxInput_lower(_ value: TrezorTxInput) -> RustBuffer { + return FfiConverterTypeTrezorTxInput.lower(value) } /** - * Parameters for starting an xpub transaction watcher. + * Transaction output for signing. */ -public struct WatcherParams { +public struct TrezorTxOutput { /** - * Caller-supplied identifier for this watcher. + * Destination address (for external outputs) */ - public var watcherId: String + public var address: String? /** - * Wallet id that scopes the activities this watcher emits. Apps may use - * one wallet id for several account watchers and merge their snapshots. + * BIP32 path (for change outputs) */ - public var walletId: String + public var path: String? /** - * Extended public key (xpub/ypub/zpub/tpub/upub/vpub). + * Amount in satoshis */ - public var extendedKey: String + public var amount: UInt64 /** - * Electrum server URL (e.g. "ssl://electrum.example.com:50002"). + * Script type (for change outputs) */ - public var electrumUrl: String + public var scriptType: TrezorScriptType? /** - * Bitcoin network override (auto-detected from key prefix if None). + * OP_RETURN data (hex encoded, for data outputs) */ - public var network: Network? + public var opReturnData: String? /** - * Account type override (auto-detected from key prefix if None). + * Original transaction hash for RBF replacement (hex encoded) */ - public var accountType: AccountType? + public var origHash: String? /** - * Number of unused addresses to monitor beyond the last used - * (defaults to `DEFAULT_GAP_LIMIT` when None). + * Original output index for RBF replacement */ - public var gapLimit: UInt32? + public var origIndex: UInt32? // Default memberwise initializers are never public by default, so we // declare one manually. public init( /** - * Caller-supplied identifier for this watcher. - */watcherId: String, + * Destination address (for external outputs) + */address: String?, /** - * Wallet id that scopes the activities this watcher emits. Apps may use - * one wallet id for several account watchers and merge their snapshots. - */walletId: String, + * BIP32 path (for change outputs) + */path: String?, /** - * Extended public key (xpub/ypub/zpub/tpub/upub/vpub). - */extendedKey: String, + * Amount in satoshis + */amount: UInt64, /** - * Electrum server URL (e.g. "ssl://electrum.example.com:50002"). - */electrumUrl: String, + * Script type (for change outputs) + */scriptType: TrezorScriptType?, /** - * Bitcoin network override (auto-detected from key prefix if None). - */network: Network?, + * OP_RETURN data (hex encoded, for data outputs) + */opReturnData: String?, /** - * Account type override (auto-detected from key prefix if None). - */accountType: AccountType?, + * Original transaction hash for RBF replacement (hex encoded) + */origHash: String?, /** - * Number of unused addresses to monitor beyond the last used - * (defaults to `DEFAULT_GAP_LIMIT` when None). - */gapLimit: UInt32?) { - self.watcherId = watcherId - self.walletId = walletId - self.extendedKey = extendedKey - self.electrumUrl = electrumUrl - self.network = network - self.accountType = accountType - self.gapLimit = gapLimit + * Original output index for RBF replacement + */origIndex: UInt32?) { + self.address = address + self.path = path + self.amount = amount + self.scriptType = scriptType + self.opReturnData = opReturnData + self.origHash = origHash + self.origIndex = origIndex } } #if compiler(>=6) -extension WatcherParams: Sendable {} +extension TrezorTxOutput: Sendable {} #endif -extension WatcherParams: Equatable, Hashable { - public static func ==(lhs: WatcherParams, rhs: WatcherParams) -> Bool { - if lhs.watcherId != rhs.watcherId { +extension TrezorTxOutput: Equatable, Hashable { + public static func ==(lhs: TrezorTxOutput, rhs: TrezorTxOutput) -> Bool { + if lhs.address != rhs.address { return false } - if lhs.walletId != rhs.walletId { + if lhs.path != rhs.path { return false } - if lhs.extendedKey != rhs.extendedKey { + if lhs.amount != rhs.amount { return false } - if lhs.electrumUrl != rhs.electrumUrl { + if lhs.scriptType != rhs.scriptType { return false } - if lhs.network != rhs.network { + if lhs.opReturnData != rhs.opReturnData { return false } - if lhs.accountType != rhs.accountType { + if lhs.origHash != rhs.origHash { return false } - if lhs.gapLimit != rhs.gapLimit { + if lhs.origIndex != rhs.origIndex { return false } return true } public func hash(into hasher: inout Hasher) { - hasher.combine(watcherId) - hasher.combine(walletId) - hasher.combine(extendedKey) - hasher.combine(electrumUrl) - hasher.combine(network) - hasher.combine(accountType) - hasher.combine(gapLimit) + hasher.combine(address) + hasher.combine(path) + hasher.combine(amount) + hasher.combine(scriptType) + hasher.combine(opReturnData) + hasher.combine(origHash) + hasher.combine(origIndex) } } -extension WatcherParams: Codable {} +extension TrezorTxOutput: Codable {} #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeWatcherParams: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> WatcherParams { +public struct FfiConverterTypeTrezorTxOutput: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorTxOutput { return - try WatcherParams( - watcherId: FfiConverterString.read(from: &buf), - walletId: FfiConverterString.read(from: &buf), - extendedKey: FfiConverterString.read(from: &buf), - electrumUrl: FfiConverterString.read(from: &buf), - network: FfiConverterOptionTypeNetwork.read(from: &buf), - accountType: FfiConverterOptionTypeAccountType.read(from: &buf), - gapLimit: FfiConverterOptionUInt32.read(from: &buf) + try TrezorTxOutput( + address: FfiConverterOptionString.read(from: &buf), + path: FfiConverterOptionString.read(from: &buf), + amount: FfiConverterUInt64.read(from: &buf), + scriptType: FfiConverterOptionTypeTrezorScriptType.read(from: &buf), + opReturnData: FfiConverterOptionString.read(from: &buf), + origHash: FfiConverterOptionString.read(from: &buf), + origIndex: FfiConverterOptionUInt32.read(from: &buf) ) } - public static func write(_ value: WatcherParams, into buf: inout [UInt8]) { - FfiConverterString.write(value.watcherId, into: &buf) - FfiConverterString.write(value.walletId, into: &buf) - FfiConverterString.write(value.extendedKey, into: &buf) - FfiConverterString.write(value.electrumUrl, into: &buf) - FfiConverterOptionTypeNetwork.write(value.network, into: &buf) - FfiConverterOptionTypeAccountType.write(value.accountType, into: &buf) - FfiConverterOptionUInt32.write(value.gapLimit, into: &buf) + public static func write(_ value: TrezorTxOutput, into buf: inout [UInt8]) { + FfiConverterOptionString.write(value.address, into: &buf) + FfiConverterOptionString.write(value.path, into: &buf) + FfiConverterUInt64.write(value.amount, into: &buf) + FfiConverterOptionTypeTrezorScriptType.write(value.scriptType, into: &buf) + FfiConverterOptionString.write(value.opReturnData, into: &buf) + FfiConverterOptionString.write(value.origHash, into: &buf) + FfiConverterOptionUInt32.write(value.origIndex, into: &buf) } } @@ -14839,182 +14911,1987 @@ public struct FfiConverterTypeWatcherParams: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeWatcherParams_lift(_ buf: RustBuffer) throws -> WatcherParams { - return try FfiConverterTypeWatcherParams.lift(buf) +public func FfiConverterTypeTrezorTxOutput_lift(_ buf: RustBuffer) throws -> TrezorTxOutput { + return try FfiConverterTypeTrezorTxOutput.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeWatcherParams_lower(_ value: WatcherParams) -> RustBuffer { - return FfiConverterTypeWatcherParams.lower(value) +public func FfiConverterTypeTrezorTxOutput_lower(_ value: TrezorTxOutput) -> RustBuffer { + return FfiConverterTypeTrezorTxOutput.lower(value) } /** - * Errors specific to account info operations (BDK/Electrum-based). + * Parameters for verifying a message signature. */ -public enum AccountInfoError: Swift.Error { - - - - /** - * The provided extended public key is invalid or cannot be parsed - */ - case InvalidExtendedKey(errorDetails: String - ) +public struct TrezorVerifyMessageParams { /** - * The provided address is invalid + * Bitcoin address that signed the message */ - case InvalidAddress(errorDetails: String - ) + public var address: String /** - * Electrum connection or query failed + * Signature (base64 encoded) */ - case ElectrumError(errorDetails: String - ) + public var signature: String /** - * BDK wallet creation or operation error + * Original message */ - case WalletError(errorDetails: String - ) + public var message: String /** - * Wallet sync with Electrum failed + * Coin network (default: Bitcoin) */ - case SyncError(errorDetails: String - ) + public var coin: TrezorCoinType? + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init( + /** + * Bitcoin address that signed the message + */address: String, + /** + * Signature (base64 encoded) + */signature: String, + /** + * Original message + */message: String, + /** + * Coin network (default: Bitcoin) + */coin: TrezorCoinType?) { + self.address = address + self.signature = signature + self.message = message + self.coin = coin + } +} + +#if compiler(>=6) +extension TrezorVerifyMessageParams: Sendable {} +#endif + + +extension TrezorVerifyMessageParams: Equatable, Hashable { + public static func ==(lhs: TrezorVerifyMessageParams, rhs: TrezorVerifyMessageParams) -> Bool { + if lhs.address != rhs.address { + return false + } + if lhs.signature != rhs.signature { + return false + } + if lhs.message != rhs.message { + return false + } + if lhs.coin != rhs.coin { + return false + } + return true + } + + public func hash(into hasher: inout Hasher) { + hasher.combine(address) + hasher.combine(signature) + hasher.combine(message) + hasher.combine(coin) + } +} + +extension TrezorVerifyMessageParams: Codable {} + + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeTrezorVerifyMessageParams: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrezorVerifyMessageParams { + return + try TrezorVerifyMessageParams( + address: FfiConverterString.read(from: &buf), + signature: FfiConverterString.read(from: &buf), + message: FfiConverterString.read(from: &buf), + coin: FfiConverterOptionTypeTrezorCoinType.read(from: &buf) + ) + } + + public static func write(_ value: TrezorVerifyMessageParams, into buf: inout [UInt8]) { + FfiConverterString.write(value.address, into: &buf) + FfiConverterString.write(value.signature, into: &buf) + FfiConverterString.write(value.message, into: &buf) + FfiConverterOptionTypeTrezorCoinType.write(value.coin, into: &buf) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeTrezorVerifyMessageParams_lift(_ buf: RustBuffer) throws -> TrezorVerifyMessageParams { + return try FfiConverterTypeTrezorVerifyMessageParams.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeTrezorVerifyMessageParams_lower(_ value: TrezorVerifyMessageParams) -> RustBuffer { + return FfiConverterTypeTrezorVerifyMessageParams.lower(value) +} + + +/** + * A transaction input with full details. + */ +public struct TxDetailInput { /** - * The key type/prefix is not recognized + * Previous output transaction ID (hex) */ - case UnsupportedKeyType(errorDetails: String - ) + public var txid: String /** - * Network mismatch between key prefix and specified network + * Previous output index */ - case NetworkMismatch(errorDetails: String - ) + public var vout: UInt32 /** - * Invalid transaction ID provided + * Sequence number */ - case InvalidTxid(errorDetails: String - ) + public var sequence: UInt32 /** - * A valid transaction ID was not found in the wallet + * Script signature (hex-encoded) */ - case TransactionNotFound(errorDetails: String - ) + public var scriptSig: String /** - * Watcher lifecycle or subscription error + * Witness stack (each element hex-encoded) */ - case WatcherError(errorDetails: String - ) -} - + public var witness: [String] -#if swift(>=5.8) -@_documentation(visibility: private) + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init( + /** + * Previous output transaction ID (hex) + */txid: String, + /** + * Previous output index + */vout: UInt32, + /** + * Sequence number + */sequence: UInt32, + /** + * Script signature (hex-encoded) + */scriptSig: String, + /** + * Witness stack (each element hex-encoded) + */witness: [String]) { + self.txid = txid + self.vout = vout + self.sequence = sequence + self.scriptSig = scriptSig + self.witness = witness + } +} + +#if compiler(>=6) +extension TxDetailInput: Sendable {} +#endif + + +extension TxDetailInput: Equatable, Hashable { + public static func ==(lhs: TxDetailInput, rhs: TxDetailInput) -> Bool { + if lhs.txid != rhs.txid { + return false + } + if lhs.vout != rhs.vout { + return false + } + if lhs.sequence != rhs.sequence { + return false + } + if lhs.scriptSig != rhs.scriptSig { + return false + } + if lhs.witness != rhs.witness { + return false + } + return true + } + + public func hash(into hasher: inout Hasher) { + hasher.combine(txid) + hasher.combine(vout) + hasher.combine(sequence) + hasher.combine(scriptSig) + hasher.combine(witness) + } +} + +extension TxDetailInput: Codable {} + + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeTxDetailInput: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TxDetailInput { + return + try TxDetailInput( + txid: FfiConverterString.read(from: &buf), + vout: FfiConverterUInt32.read(from: &buf), + sequence: FfiConverterUInt32.read(from: &buf), + scriptSig: FfiConverterString.read(from: &buf), + witness: FfiConverterSequenceString.read(from: &buf) + ) + } + + public static func write(_ value: TxDetailInput, into buf: inout [UInt8]) { + FfiConverterString.write(value.txid, into: &buf) + FfiConverterUInt32.write(value.vout, into: &buf) + FfiConverterUInt32.write(value.sequence, into: &buf) + FfiConverterString.write(value.scriptSig, into: &buf) + FfiConverterSequenceString.write(value.witness, into: &buf) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeTxDetailInput_lift(_ buf: RustBuffer) throws -> TxDetailInput { + return try FfiConverterTypeTxDetailInput.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeTxDetailInput_lower(_ value: TxDetailInput) -> RustBuffer { + return FfiConverterTypeTxDetailInput.lower(value) +} + + +/** + * A transaction output with full details. + */ +public struct TxDetailOutput { + /** + * Output value in sats + */ + public var value: UInt64 + /** + * Script public key (hex-encoded) + */ + public var scriptPubkey: String + /** + * Decoded address (None if script is not decodable to an address) + */ + public var address: String? + /** + * Whether this output belongs to the queried wallet + */ + public var isMine: Bool + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init( + /** + * Output value in sats + */value: UInt64, + /** + * Script public key (hex-encoded) + */scriptPubkey: String, + /** + * Decoded address (None if script is not decodable to an address) + */address: String?, + /** + * Whether this output belongs to the queried wallet + */isMine: Bool) { + self.value = value + self.scriptPubkey = scriptPubkey + self.address = address + self.isMine = isMine + } +} + +#if compiler(>=6) +extension TxDetailOutput: Sendable {} +#endif + + +extension TxDetailOutput: Equatable, Hashable { + public static func ==(lhs: TxDetailOutput, rhs: TxDetailOutput) -> Bool { + if lhs.value != rhs.value { + return false + } + if lhs.scriptPubkey != rhs.scriptPubkey { + return false + } + if lhs.address != rhs.address { + return false + } + if lhs.isMine != rhs.isMine { + return false + } + return true + } + + public func hash(into hasher: inout Hasher) { + hasher.combine(value) + hasher.combine(scriptPubkey) + hasher.combine(address) + hasher.combine(isMine) + } +} + +extension TxDetailOutput: Codable {} + + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeTxDetailOutput: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TxDetailOutput { + return + try TxDetailOutput( + value: FfiConverterUInt64.read(from: &buf), + scriptPubkey: FfiConverterString.read(from: &buf), + address: FfiConverterOptionString.read(from: &buf), + isMine: FfiConverterBool.read(from: &buf) + ) + } + + public static func write(_ value: TxDetailOutput, into buf: inout [UInt8]) { + FfiConverterUInt64.write(value.value, into: &buf) + FfiConverterString.write(value.scriptPubkey, into: &buf) + FfiConverterOptionString.write(value.address, into: &buf) + FfiConverterBool.write(value.isMine, into: &buf) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeTxDetailOutput_lift(_ buf: RustBuffer) throws -> TxDetailOutput { + return try FfiConverterTypeTxDetailOutput.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeTxDetailOutput_lower(_ value: TxDetailOutput) -> RustBuffer { + return FfiConverterTypeTxDetailOutput.lower(value) +} + + +/** + * Details about a transaction input. + */ +public struct TxInput { + /** + * The transaction ID of the previous output being spent. + */ + public var txid: String + /** + * The output index of the previous output being spent. + */ + public var vout: UInt32 + /** + * The script signature (hex-encoded). + */ + public var scriptsig: String + /** + * The witness stack (hex-encoded strings). + */ + public var witness: [String] + /** + * The sequence number. + */ + public var sequence: UInt32 + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init( + /** + * The transaction ID of the previous output being spent. + */txid: String, + /** + * The output index of the previous output being spent. + */vout: UInt32, + /** + * The script signature (hex-encoded). + */scriptsig: String, + /** + * The witness stack (hex-encoded strings). + */witness: [String], + /** + * The sequence number. + */sequence: UInt32) { + self.txid = txid + self.vout = vout + self.scriptsig = scriptsig + self.witness = witness + self.sequence = sequence + } +} + +#if compiler(>=6) +extension TxInput: Sendable {} +#endif + + +extension TxInput: Equatable, Hashable { + public static func ==(lhs: TxInput, rhs: TxInput) -> Bool { + if lhs.txid != rhs.txid { + return false + } + if lhs.vout != rhs.vout { + return false + } + if lhs.scriptsig != rhs.scriptsig { + return false + } + if lhs.witness != rhs.witness { + return false + } + if lhs.sequence != rhs.sequence { + return false + } + return true + } + + public func hash(into hasher: inout Hasher) { + hasher.combine(txid) + hasher.combine(vout) + hasher.combine(scriptsig) + hasher.combine(witness) + hasher.combine(sequence) + } +} + +extension TxInput: Codable {} + + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeTxInput: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TxInput { + return + try TxInput( + txid: FfiConverterString.read(from: &buf), + vout: FfiConverterUInt32.read(from: &buf), + scriptsig: FfiConverterString.read(from: &buf), + witness: FfiConverterSequenceString.read(from: &buf), + sequence: FfiConverterUInt32.read(from: &buf) + ) + } + + public static func write(_ value: TxInput, into buf: inout [UInt8]) { + FfiConverterString.write(value.txid, into: &buf) + FfiConverterUInt32.write(value.vout, into: &buf) + FfiConverterString.write(value.scriptsig, into: &buf) + FfiConverterSequenceString.write(value.witness, into: &buf) + FfiConverterUInt32.write(value.sequence, into: &buf) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeTxInput_lift(_ buf: RustBuffer) throws -> TxInput { + return try FfiConverterTypeTxInput.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeTxInput_lower(_ value: TxInput) -> RustBuffer { + return FfiConverterTypeTxInput.lower(value) +} + + +/** + * Details about a transaction output. + */ +public struct TxOutput { + /** + * The script public key (hex-encoded). + */ + public var scriptpubkey: String + /** + * The script public key type (e.g., "p2pkh", "p2sh", "p2wpkh", "p2wsh", "p2tr"). + */ + public var scriptpubkeyType: String? + /** + * The address corresponding to this script (if decodable). + */ + public var scriptpubkeyAddress: String? + /** + * The value in satoshis. + */ + public var value: Int64 + /** + * The output index in the transaction. + */ + public var n: UInt32 + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init( + /** + * The script public key (hex-encoded). + */scriptpubkey: String, + /** + * The script public key type (e.g., "p2pkh", "p2sh", "p2wpkh", "p2wsh", "p2tr"). + */scriptpubkeyType: String?, + /** + * The address corresponding to this script (if decodable). + */scriptpubkeyAddress: String?, + /** + * The value in satoshis. + */value: Int64, + /** + * The output index in the transaction. + */n: UInt32) { + self.scriptpubkey = scriptpubkey + self.scriptpubkeyType = scriptpubkeyType + self.scriptpubkeyAddress = scriptpubkeyAddress + self.value = value + self.n = n + } +} + +#if compiler(>=6) +extension TxOutput: Sendable {} +#endif + + +extension TxOutput: Equatable, Hashable { + public static func ==(lhs: TxOutput, rhs: TxOutput) -> Bool { + if lhs.scriptpubkey != rhs.scriptpubkey { + return false + } + if lhs.scriptpubkeyType != rhs.scriptpubkeyType { + return false + } + if lhs.scriptpubkeyAddress != rhs.scriptpubkeyAddress { + return false + } + if lhs.value != rhs.value { + return false + } + if lhs.n != rhs.n { + return false + } + return true + } + + public func hash(into hasher: inout Hasher) { + hasher.combine(scriptpubkey) + hasher.combine(scriptpubkeyType) + hasher.combine(scriptpubkeyAddress) + hasher.combine(value) + hasher.combine(n) + } +} + +extension TxOutput: Codable {} + + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeTxOutput: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TxOutput { + return + try TxOutput( + scriptpubkey: FfiConverterString.read(from: &buf), + scriptpubkeyType: FfiConverterOptionString.read(from: &buf), + scriptpubkeyAddress: FfiConverterOptionString.read(from: &buf), + value: FfiConverterInt64.read(from: &buf), + n: FfiConverterUInt32.read(from: &buf) + ) + } + + public static func write(_ value: TxOutput, into buf: inout [UInt8]) { + FfiConverterString.write(value.scriptpubkey, into: &buf) + FfiConverterOptionString.write(value.scriptpubkeyType, into: &buf) + FfiConverterOptionString.write(value.scriptpubkeyAddress, into: &buf) + FfiConverterInt64.write(value.value, into: &buf) + FfiConverterUInt32.write(value.n, into: &buf) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeTxOutput_lift(_ buf: RustBuffer) throws -> TxOutput { + return try FfiConverterTypeTxOutput.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeTxOutput_lower(_ value: TxOutput) -> RustBuffer { + return FfiConverterTypeTxOutput.lower(value) +} + + +/** + * Current state after accepting a scanned UR frame. + */ +public struct UrDecoderStatus { + /** + * Estimated completion from 0.0 through 1.0. + */ + public var progress: Double + /** + * Fountain source-fragment count, or 1 for a single-part UR. + */ + public var fragmentCount: UInt32 + /** + * Present once the complete message has been decoded. + */ + public var payload: UrPayload? + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init( + /** + * Estimated completion from 0.0 through 1.0. + */progress: Double, + /** + * Fountain source-fragment count, or 1 for a single-part UR. + */fragmentCount: UInt32, + /** + * Present once the complete message has been decoded. + */payload: UrPayload?) { + self.progress = progress + self.fragmentCount = fragmentCount + self.payload = payload + } +} + +#if compiler(>=6) +extension UrDecoderStatus: Sendable {} +#endif + + +extension UrDecoderStatus: Equatable, Hashable { + public static func ==(lhs: UrDecoderStatus, rhs: UrDecoderStatus) -> Bool { + if lhs.progress != rhs.progress { + return false + } + if lhs.fragmentCount != rhs.fragmentCount { + return false + } + if lhs.payload != rhs.payload { + return false + } + return true + } + + public func hash(into hasher: inout Hasher) { + hasher.combine(progress) + hasher.combine(fragmentCount) + hasher.combine(payload) + } +} + +extension UrDecoderStatus: Codable {} + + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeUrDecoderStatus: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> UrDecoderStatus { + return + try UrDecoderStatus( + progress: FfiConverterDouble.read(from: &buf), + fragmentCount: FfiConverterUInt32.read(from: &buf), + payload: FfiConverterOptionTypeUrPayload.read(from: &buf) + ) + } + + public static func write(_ value: UrDecoderStatus, into buf: inout [UInt8]) { + FfiConverterDouble.write(value.progress, into: &buf) + FfiConverterUInt32.write(value.fragmentCount, into: &buf) + FfiConverterOptionTypeUrPayload.write(value.payload, into: &buf) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeUrDecoderStatus_lift(_ buf: RustBuffer) throws -> UrDecoderStatus { + return try FfiConverterTypeUrDecoderStatus.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeUrDecoderStatus_lower(_ value: UrDecoderStatus) -> RustBuffer { + return FfiConverterTypeUrDecoderStatus.lower(value) +} + + +public struct ValidationResult { + public var address: String + public var network: NetworkType + public var addressType: AddressType + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init(address: String, network: NetworkType, addressType: AddressType) { + self.address = address + self.network = network + self.addressType = addressType + } +} + +#if compiler(>=6) +extension ValidationResult: Sendable {} +#endif + + +extension ValidationResult: Equatable, Hashable { + public static func ==(lhs: ValidationResult, rhs: ValidationResult) -> Bool { + if lhs.address != rhs.address { + return false + } + if lhs.network != rhs.network { + return false + } + if lhs.addressType != rhs.addressType { + return false + } + return true + } + + public func hash(into hasher: inout Hasher) { + hasher.combine(address) + hasher.combine(network) + hasher.combine(addressType) + } +} + +extension ValidationResult: Codable {} + + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeValidationResult: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ValidationResult { + return + try ValidationResult( + address: FfiConverterString.read(from: &buf), + network: FfiConverterTypeNetworkType.read(from: &buf), + addressType: FfiConverterTypeAddressType.read(from: &buf) + ) + } + + public static func write(_ value: ValidationResult, into buf: inout [UInt8]) { + FfiConverterString.write(value.address, into: &buf) + FfiConverterTypeNetworkType.write(value.network, into: &buf) + FfiConverterTypeAddressType.write(value.addressType, into: &buf) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeValidationResult_lift(_ buf: RustBuffer) throws -> ValidationResult { + return try FfiConverterTypeValidationResult.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeValidationResult_lower(_ value: ValidationResult) -> RustBuffer { + return FfiConverterTypeValidationResult.lower(value) +} + + +/** + * Balance breakdown from BDK. + */ +public struct WalletBalance { + /** + * Confirmed and spendable balance (sats) + */ + public var confirmed: UInt64 + /** + * Immature coinbase outputs (sats) + */ + public var immature: UInt64 + /** + * Unconfirmed UTXOs from trusted sources (own change) (sats) + */ + public var trustedPending: UInt64 + /** + * Unconfirmed UTXOs from external sources (sats) + */ + public var untrustedPending: UInt64 + /** + * Total spendable: confirmed + trusted_pending (sats) + */ + public var spendable: UInt64 + /** + * Grand total: all categories (sats) + */ + public var total: UInt64 + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init( + /** + * Confirmed and spendable balance (sats) + */confirmed: UInt64, + /** + * Immature coinbase outputs (sats) + */immature: UInt64, + /** + * Unconfirmed UTXOs from trusted sources (own change) (sats) + */trustedPending: UInt64, + /** + * Unconfirmed UTXOs from external sources (sats) + */untrustedPending: UInt64, + /** + * Total spendable: confirmed + trusted_pending (sats) + */spendable: UInt64, + /** + * Grand total: all categories (sats) + */total: UInt64) { + self.confirmed = confirmed + self.immature = immature + self.trustedPending = trustedPending + self.untrustedPending = untrustedPending + self.spendable = spendable + self.total = total + } +} + +#if compiler(>=6) +extension WalletBalance: Sendable {} +#endif + + +extension WalletBalance: Equatable, Hashable { + public static func ==(lhs: WalletBalance, rhs: WalletBalance) -> Bool { + if lhs.confirmed != rhs.confirmed { + return false + } + if lhs.immature != rhs.immature { + return false + } + if lhs.trustedPending != rhs.trustedPending { + return false + } + if lhs.untrustedPending != rhs.untrustedPending { + return false + } + if lhs.spendable != rhs.spendable { + return false + } + if lhs.total != rhs.total { + return false + } + return true + } + + public func hash(into hasher: inout Hasher) { + hasher.combine(confirmed) + hasher.combine(immature) + hasher.combine(trustedPending) + hasher.combine(untrustedPending) + hasher.combine(spendable) + hasher.combine(total) + } +} + +extension WalletBalance: Codable {} + + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeWalletBalance: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> WalletBalance { + return + try WalletBalance( + confirmed: FfiConverterUInt64.read(from: &buf), + immature: FfiConverterUInt64.read(from: &buf), + trustedPending: FfiConverterUInt64.read(from: &buf), + untrustedPending: FfiConverterUInt64.read(from: &buf), + spendable: FfiConverterUInt64.read(from: &buf), + total: FfiConverterUInt64.read(from: &buf) + ) + } + + public static func write(_ value: WalletBalance, into buf: inout [UInt8]) { + FfiConverterUInt64.write(value.confirmed, into: &buf) + FfiConverterUInt64.write(value.immature, into: &buf) + FfiConverterUInt64.write(value.trustedPending, into: &buf) + FfiConverterUInt64.write(value.untrustedPending, into: &buf) + FfiConverterUInt64.write(value.spendable, into: &buf) + FfiConverterUInt64.write(value.total, into: &buf) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeWalletBalance_lift(_ buf: RustBuffer) throws -> WalletBalance { + return try FfiConverterTypeWalletBalance.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeWalletBalance_lower(_ value: WalletBalance) -> RustBuffer { + return FfiConverterTypeWalletBalance.lower(value) +} + + +/** + * Common parameters for creating and syncing a watch-only BDK wallet. + */ +public struct WalletParams { + /** + * Extended public key (xpub/ypub/zpub/tpub/upub/vpub) + */ + public var extendedKey: String + /** + * Electrum server URL for wallet sync + */ + public var electrumUrl: String + /** + * Root fingerprint hex (e.g. "73c5da0a"). Required for hardware wallet signing. + */ + public var fingerprint: String? + /** + * Bitcoin network (auto-detected from key prefix if not specified) + */ + public var network: Network? + /** + * Override account type for ambiguous key prefixes (xpub/tpub) + */ + public var accountType: AccountType? + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init( + /** + * Extended public key (xpub/ypub/zpub/tpub/upub/vpub) + */extendedKey: String, + /** + * Electrum server URL for wallet sync + */electrumUrl: String, + /** + * Root fingerprint hex (e.g. "73c5da0a"). Required for hardware wallet signing. + */fingerprint: String?, + /** + * Bitcoin network (auto-detected from key prefix if not specified) + */network: Network?, + /** + * Override account type for ambiguous key prefixes (xpub/tpub) + */accountType: AccountType?) { + self.extendedKey = extendedKey + self.electrumUrl = electrumUrl + self.fingerprint = fingerprint + self.network = network + self.accountType = accountType + } +} + +#if compiler(>=6) +extension WalletParams: Sendable {} +#endif + + +extension WalletParams: Equatable, Hashable { + public static func ==(lhs: WalletParams, rhs: WalletParams) -> Bool { + if lhs.extendedKey != rhs.extendedKey { + return false + } + if lhs.electrumUrl != rhs.electrumUrl { + return false + } + if lhs.fingerprint != rhs.fingerprint { + return false + } + if lhs.network != rhs.network { + return false + } + if lhs.accountType != rhs.accountType { + return false + } + return true + } + + public func hash(into hasher: inout Hasher) { + hasher.combine(extendedKey) + hasher.combine(electrumUrl) + hasher.combine(fingerprint) + hasher.combine(network) + hasher.combine(accountType) + } +} + +extension WalletParams: Codable {} + + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeWalletParams: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> WalletParams { + return + try WalletParams( + extendedKey: FfiConverterString.read(from: &buf), + electrumUrl: FfiConverterString.read(from: &buf), + fingerprint: FfiConverterOptionString.read(from: &buf), + network: FfiConverterOptionTypeNetwork.read(from: &buf), + accountType: FfiConverterOptionTypeAccountType.read(from: &buf) + ) + } + + public static func write(_ value: WalletParams, into buf: inout [UInt8]) { + FfiConverterString.write(value.extendedKey, into: &buf) + FfiConverterString.write(value.electrumUrl, into: &buf) + FfiConverterOptionString.write(value.fingerprint, into: &buf) + FfiConverterOptionTypeNetwork.write(value.network, into: &buf) + FfiConverterOptionTypeAccountType.write(value.accountType, into: &buf) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeWalletParams_lift(_ buf: RustBuffer) throws -> WalletParams { + return try FfiConverterTypeWalletParams.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeWalletParams_lower(_ value: WalletParams) -> RustBuffer { + return FfiConverterTypeWalletParams.lower(value) +} + + +/** + * Parameters for starting an xpub transaction watcher. + */ +public struct WatcherParams { + /** + * Caller-supplied identifier for this watcher. + */ + public var watcherId: String + /** + * Wallet id that scopes the activities this watcher emits. Apps may use + * one wallet id for several account watchers and merge their snapshots. + */ + public var walletId: String + /** + * Extended public key (xpub/ypub/zpub/tpub/upub/vpub). + */ + public var extendedKey: String + /** + * Electrum server URL (e.g. "ssl://electrum.example.com:50002"). + */ + public var electrumUrl: String + /** + * Bitcoin network override (auto-detected from key prefix if None). + */ + public var network: Network? + /** + * Account type override (auto-detected from key prefix if None). + */ + public var accountType: AccountType? + /** + * Number of unused addresses to monitor beyond the last used + * (defaults to `DEFAULT_GAP_LIMIT` when None). + */ + public var gapLimit: UInt32? + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init( + /** + * Caller-supplied identifier for this watcher. + */watcherId: String, + /** + * Wallet id that scopes the activities this watcher emits. Apps may use + * one wallet id for several account watchers and merge their snapshots. + */walletId: String, + /** + * Extended public key (xpub/ypub/zpub/tpub/upub/vpub). + */extendedKey: String, + /** + * Electrum server URL (e.g. "ssl://electrum.example.com:50002"). + */electrumUrl: String, + /** + * Bitcoin network override (auto-detected from key prefix if None). + */network: Network?, + /** + * Account type override (auto-detected from key prefix if None). + */accountType: AccountType?, + /** + * Number of unused addresses to monitor beyond the last used + * (defaults to `DEFAULT_GAP_LIMIT` when None). + */gapLimit: UInt32?) { + self.watcherId = watcherId + self.walletId = walletId + self.extendedKey = extendedKey + self.electrumUrl = electrumUrl + self.network = network + self.accountType = accountType + self.gapLimit = gapLimit + } +} + +#if compiler(>=6) +extension WatcherParams: Sendable {} +#endif + + +extension WatcherParams: Equatable, Hashable { + public static func ==(lhs: WatcherParams, rhs: WatcherParams) -> Bool { + if lhs.watcherId != rhs.watcherId { + return false + } + if lhs.walletId != rhs.walletId { + return false + } + if lhs.extendedKey != rhs.extendedKey { + return false + } + if lhs.electrumUrl != rhs.electrumUrl { + return false + } + if lhs.network != rhs.network { + return false + } + if lhs.accountType != rhs.accountType { + return false + } + if lhs.gapLimit != rhs.gapLimit { + return false + } + return true + } + + public func hash(into hasher: inout Hasher) { + hasher.combine(watcherId) + hasher.combine(walletId) + hasher.combine(extendedKey) + hasher.combine(electrumUrl) + hasher.combine(network) + hasher.combine(accountType) + hasher.combine(gapLimit) + } +} + +extension WatcherParams: Codable {} + + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeWatcherParams: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> WatcherParams { + return + try WatcherParams( + watcherId: FfiConverterString.read(from: &buf), + walletId: FfiConverterString.read(from: &buf), + extendedKey: FfiConverterString.read(from: &buf), + electrumUrl: FfiConverterString.read(from: &buf), + network: FfiConverterOptionTypeNetwork.read(from: &buf), + accountType: FfiConverterOptionTypeAccountType.read(from: &buf), + gapLimit: FfiConverterOptionUInt32.read(from: &buf) + ) + } + + public static func write(_ value: WatcherParams, into buf: inout [UInt8]) { + FfiConverterString.write(value.watcherId, into: &buf) + FfiConverterString.write(value.walletId, into: &buf) + FfiConverterString.write(value.extendedKey, into: &buf) + FfiConverterString.write(value.electrumUrl, into: &buf) + FfiConverterOptionTypeNetwork.write(value.network, into: &buf) + FfiConverterOptionTypeAccountType.write(value.accountType, into: &buf) + FfiConverterOptionUInt32.write(value.gapLimit, into: &buf) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeWatcherParams_lift(_ buf: RustBuffer) throws -> WatcherParams { + return try FfiConverterTypeWatcherParams.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeWatcherParams_lower(_ value: WatcherParams) -> RustBuffer { + return FfiConverterTypeWatcherParams.lower(value) +} + + +/** + * Errors specific to account info operations (BDK/Electrum-based). + */ +public enum AccountInfoError: Swift.Error { + + + + /** + * The provided extended public key is invalid or cannot be parsed + */ + case InvalidExtendedKey(errorDetails: String + ) + /** + * The provided address is invalid + */ + case InvalidAddress(errorDetails: String + ) + /** + * Electrum connection or query failed + */ + case ElectrumError(errorDetails: String + ) + /** + * BDK wallet creation or operation error + */ + case WalletError(errorDetails: String + ) + /** + * Wallet sync with Electrum failed + */ + case SyncError(errorDetails: String + ) + /** + * The key type/prefix is not recognized + */ + case UnsupportedKeyType(errorDetails: String + ) + /** + * Network mismatch between key prefix and specified network + */ + case NetworkMismatch(errorDetails: String + ) + /** + * Invalid transaction ID provided + */ + case InvalidTxid(errorDetails: String + ) + /** + * A valid transaction ID was not found in the wallet + */ + case TransactionNotFound(errorDetails: String + ) + /** + * Watcher lifecycle or subscription error + */ + case WatcherError(errorDetails: String + ) +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeAccountInfoError: FfiConverterRustBuffer { + typealias SwiftType = AccountInfoError + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> AccountInfoError { + let variant: Int32 = try readInt(&buf) + switch variant { + + + + + case 1: return .InvalidExtendedKey( + errorDetails: try FfiConverterString.read(from: &buf) + ) + case 2: return .InvalidAddress( + errorDetails: try FfiConverterString.read(from: &buf) + ) + case 3: return .ElectrumError( + errorDetails: try FfiConverterString.read(from: &buf) + ) + case 4: return .WalletError( + errorDetails: try FfiConverterString.read(from: &buf) + ) + case 5: return .SyncError( + errorDetails: try FfiConverterString.read(from: &buf) + ) + case 6: return .UnsupportedKeyType( + errorDetails: try FfiConverterString.read(from: &buf) + ) + case 7: return .NetworkMismatch( + errorDetails: try FfiConverterString.read(from: &buf) + ) + case 8: return .InvalidTxid( + errorDetails: try FfiConverterString.read(from: &buf) + ) + case 9: return .TransactionNotFound( + errorDetails: try FfiConverterString.read(from: &buf) + ) + case 10: return .WatcherError( + errorDetails: try FfiConverterString.read(from: &buf) + ) + + default: throw UniffiInternalError.unexpectedEnumCase + } + } + + public static func write(_ value: AccountInfoError, into buf: inout [UInt8]) { + switch value { + + + + + + case let .InvalidExtendedKey(errorDetails): + writeInt(&buf, Int32(1)) + FfiConverterString.write(errorDetails, into: &buf) + + + case let .InvalidAddress(errorDetails): + writeInt(&buf, Int32(2)) + FfiConverterString.write(errorDetails, into: &buf) + + + case let .ElectrumError(errorDetails): + writeInt(&buf, Int32(3)) + FfiConverterString.write(errorDetails, into: &buf) + + + case let .WalletError(errorDetails): + writeInt(&buf, Int32(4)) + FfiConverterString.write(errorDetails, into: &buf) + + + case let .SyncError(errorDetails): + writeInt(&buf, Int32(5)) + FfiConverterString.write(errorDetails, into: &buf) + + + case let .UnsupportedKeyType(errorDetails): + writeInt(&buf, Int32(6)) + FfiConverterString.write(errorDetails, into: &buf) + + + case let .NetworkMismatch(errorDetails): + writeInt(&buf, Int32(7)) + FfiConverterString.write(errorDetails, into: &buf) + + + case let .InvalidTxid(errorDetails): + writeInt(&buf, Int32(8)) + FfiConverterString.write(errorDetails, into: &buf) + + + case let .TransactionNotFound(errorDetails): + writeInt(&buf, Int32(9)) + FfiConverterString.write(errorDetails, into: &buf) + + + case let .WatcherError(errorDetails): + writeInt(&buf, Int32(10)) + FfiConverterString.write(errorDetails, into: &buf) + + } + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeAccountInfoError_lift(_ buf: RustBuffer) throws -> AccountInfoError { + return try FfiConverterTypeAccountInfoError.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeAccountInfoError_lower(_ value: AccountInfoError) -> RustBuffer { + return FfiConverterTypeAccountInfoError.lower(value) +} + + +extension AccountInfoError: Equatable, Hashable {} + +extension AccountInfoError: Codable {} + + + + +extension AccountInfoError: Foundation.LocalizedError { + public var errorDescription: String? { + String(reflecting: self) + } +} + + + + +// Note that we don't yet support `indirect` for enums. +// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. +/** + * Account type classification for extended public keys. + * + * Determines the BIP standard, derivation path purpose, and script type. + */ + +public enum AccountType { + + /** + * BIP44 legacy (P2PKH) — xpub/tpub prefix + */ + case legacy + /** + * BIP49 wrapped segwit (P2SH-P2WPKH) — ypub/upub prefix + */ + case wrappedSegwit + /** + * BIP84 native segwit (P2WPKH) — zpub/vpub prefix + */ + case nativeSegwit + /** + * BIP86 taproot (P2TR) + */ + case taproot +} + + +#if compiler(>=6) +extension AccountType: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeAccountType: FfiConverterRustBuffer { + typealias SwiftType = AccountType + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> AccountType { + let variant: Int32 = try readInt(&buf) + switch variant { + + case 1: return .legacy + + case 2: return .wrappedSegwit + + case 3: return .nativeSegwit + + case 4: return .taproot + + default: throw UniffiInternalError.unexpectedEnumCase + } + } + + public static func write(_ value: AccountType, into buf: inout [UInt8]) { + switch value { + + + case .legacy: + writeInt(&buf, Int32(1)) + + + case .wrappedSegwit: + writeInt(&buf, Int32(2)) + + + case .nativeSegwit: + writeInt(&buf, Int32(3)) + + + case .taproot: + writeInt(&buf, Int32(4)) + + } + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeAccountType_lift(_ buf: RustBuffer) throws -> AccountType { + return try FfiConverterTypeAccountType.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeAccountType_lower(_ value: AccountType) -> RustBuffer { + return FfiConverterTypeAccountType.lower(value) +} + + +extension AccountType: Equatable, Hashable {} + +extension AccountType: Codable {} + + + + + + +// Note that we don't yet support `indirect` for enums. +// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. + +public enum Activity { + + case onchain(OnchainActivity + ) + case lightning(LightningActivity + ) +} + + +#if compiler(>=6) +extension Activity: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeActivity: FfiConverterRustBuffer { + typealias SwiftType = Activity + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Activity { + let variant: Int32 = try readInt(&buf) + switch variant { + + case 1: return .onchain(try FfiConverterTypeOnchainActivity.read(from: &buf) + ) + + case 2: return .lightning(try FfiConverterTypeLightningActivity.read(from: &buf) + ) + + default: throw UniffiInternalError.unexpectedEnumCase + } + } + + public static func write(_ value: Activity, into buf: inout [UInt8]) { + switch value { + + + case let .onchain(v1): + writeInt(&buf, Int32(1)) + FfiConverterTypeOnchainActivity.write(v1, into: &buf) + + + case let .lightning(v1): + writeInt(&buf, Int32(2)) + FfiConverterTypeLightningActivity.write(v1, into: &buf) + + } + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeActivity_lift(_ buf: RustBuffer) throws -> Activity { + return try FfiConverterTypeActivity.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeActivity_lower(_ value: Activity) -> RustBuffer { + return FfiConverterTypeActivity.lower(value) +} + + +extension Activity: Equatable, Hashable {} + +extension Activity: Codable {} + + + + + + + +public enum ActivityError: Swift.Error { + + + + case InvalidActivity(errorDetails: String + ) + case InitializationError(errorDetails: String + ) + case InsertError(errorDetails: String + ) + case RetrievalError(errorDetails: String + ) + case DataError(errorDetails: String + ) + case ConnectionError(errorDetails: String + ) + case SerializationError(errorDetails: String + ) +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeActivityError: FfiConverterRustBuffer { + typealias SwiftType = ActivityError + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ActivityError { + let variant: Int32 = try readInt(&buf) + switch variant { + + + + + case 1: return .InvalidActivity( + errorDetails: try FfiConverterString.read(from: &buf) + ) + case 2: return .InitializationError( + errorDetails: try FfiConverterString.read(from: &buf) + ) + case 3: return .InsertError( + errorDetails: try FfiConverterString.read(from: &buf) + ) + case 4: return .RetrievalError( + errorDetails: try FfiConverterString.read(from: &buf) + ) + case 5: return .DataError( + errorDetails: try FfiConverterString.read(from: &buf) + ) + case 6: return .ConnectionError( + errorDetails: try FfiConverterString.read(from: &buf) + ) + case 7: return .SerializationError( + errorDetails: try FfiConverterString.read(from: &buf) + ) + + default: throw UniffiInternalError.unexpectedEnumCase + } + } + + public static func write(_ value: ActivityError, into buf: inout [UInt8]) { + switch value { + + + + + + case let .InvalidActivity(errorDetails): + writeInt(&buf, Int32(1)) + FfiConverterString.write(errorDetails, into: &buf) + + + case let .InitializationError(errorDetails): + writeInt(&buf, Int32(2)) + FfiConverterString.write(errorDetails, into: &buf) + + + case let .InsertError(errorDetails): + writeInt(&buf, Int32(3)) + FfiConverterString.write(errorDetails, into: &buf) + + + case let .RetrievalError(errorDetails): + writeInt(&buf, Int32(4)) + FfiConverterString.write(errorDetails, into: &buf) + + + case let .DataError(errorDetails): + writeInt(&buf, Int32(5)) + FfiConverterString.write(errorDetails, into: &buf) + + + case let .ConnectionError(errorDetails): + writeInt(&buf, Int32(6)) + FfiConverterString.write(errorDetails, into: &buf) + + + case let .SerializationError(errorDetails): + writeInt(&buf, Int32(7)) + FfiConverterString.write(errorDetails, into: &buf) + + } + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeActivityError_lift(_ buf: RustBuffer) throws -> ActivityError { + return try FfiConverterTypeActivityError.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeActivityError_lower(_ value: ActivityError) -> RustBuffer { + return FfiConverterTypeActivityError.lower(value) +} + + +extension ActivityError: Equatable, Hashable {} + +extension ActivityError: Codable {} + + + + +extension ActivityError: Foundation.LocalizedError { + public var errorDescription: String? { + String(reflecting: self) + } +} + + + + +// Note that we don't yet support `indirect` for enums. +// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. + +public enum ActivityFilter { + + case all + case lightning + case onchain +} + + +#if compiler(>=6) +extension ActivityFilter: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeActivityFilter: FfiConverterRustBuffer { + typealias SwiftType = ActivityFilter + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ActivityFilter { + let variant: Int32 = try readInt(&buf) + switch variant { + + case 1: return .all + + case 2: return .lightning + + case 3: return .onchain + + default: throw UniffiInternalError.unexpectedEnumCase + } + } + + public static func write(_ value: ActivityFilter, into buf: inout [UInt8]) { + switch value { + + + case .all: + writeInt(&buf, Int32(1)) + + + case .lightning: + writeInt(&buf, Int32(2)) + + + case .onchain: + writeInt(&buf, Int32(3)) + + } + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeActivityFilter_lift(_ buf: RustBuffer) throws -> ActivityFilter { + return try FfiConverterTypeActivityFilter.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeActivityFilter_lower(_ value: ActivityFilter) -> RustBuffer { + return FfiConverterTypeActivityFilter.lower(value) +} + + +extension ActivityFilter: Equatable, Hashable {} + +extension ActivityFilter: Codable {} + + + + + + +// Note that we don't yet support `indirect` for enums. +// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. + +public enum ActivityType { + + case onchain + case lightning +} + + +#if compiler(>=6) +extension ActivityType: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeActivityType: FfiConverterRustBuffer { + typealias SwiftType = ActivityType + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ActivityType { + let variant: Int32 = try readInt(&buf) + switch variant { + + case 1: return .onchain + + case 2: return .lightning + + default: throw UniffiInternalError.unexpectedEnumCase + } + } + + public static func write(_ value: ActivityType, into buf: inout [UInt8]) { + switch value { + + + case .onchain: + writeInt(&buf, Int32(1)) + + + case .lightning: + writeInt(&buf, Int32(2)) + + } + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeActivityType_lift(_ buf: RustBuffer) throws -> ActivityType { + return try FfiConverterTypeActivityType.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeActivityType_lower(_ value: ActivityType) -> RustBuffer { + return FfiConverterTypeActivityType.lower(value) +} + + +extension ActivityType: Equatable, Hashable {} + +extension ActivityType: Codable {} + + + + + + + +public enum AddressError: Swift.Error { + + + + case InvalidAddress + case InvalidNetwork + case MnemonicGenerationFailed + case InvalidMnemonic + case InvalidEntropy + case AddressDerivationFailed +} + + +#if swift(>=5.8) +@_documentation(visibility: private) #endif -public struct FfiConverterTypeAccountInfoError: FfiConverterRustBuffer { - typealias SwiftType = AccountInfoError +public struct FfiConverterTypeAddressError: FfiConverterRustBuffer { + typealias SwiftType = AddressError - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> AccountInfoError { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> AddressError { let variant: Int32 = try readInt(&buf) switch variant { - case 1: return .InvalidExtendedKey( - errorDetails: try FfiConverterString.read(from: &buf) - ) - case 2: return .InvalidAddress( - errorDetails: try FfiConverterString.read(from: &buf) - ) - case 3: return .ElectrumError( - errorDetails: try FfiConverterString.read(from: &buf) - ) - case 4: return .WalletError( - errorDetails: try FfiConverterString.read(from: &buf) - ) - case 5: return .SyncError( - errorDetails: try FfiConverterString.read(from: &buf) - ) - case 6: return .UnsupportedKeyType( - errorDetails: try FfiConverterString.read(from: &buf) - ) - case 7: return .NetworkMismatch( - errorDetails: try FfiConverterString.read(from: &buf) - ) - case 8: return .InvalidTxid( - errorDetails: try FfiConverterString.read(from: &buf) - ) - case 9: return .TransactionNotFound( - errorDetails: try FfiConverterString.read(from: &buf) - ) - case 10: return .WatcherError( - errorDetails: try FfiConverterString.read(from: &buf) - ) + case 1: return .InvalidAddress + case 2: return .InvalidNetwork + case 3: return .MnemonicGenerationFailed + case 4: return .InvalidMnemonic + case 5: return .InvalidEntropy + case 6: return .AddressDerivationFailed default: throw UniffiInternalError.unexpectedEnumCase } } - public static func write(_ value: AccountInfoError, into buf: inout [UInt8]) { + public static func write(_ value: AddressError, into buf: inout [UInt8]) { switch value { - case let .InvalidExtendedKey(errorDetails): + case .InvalidAddress: writeInt(&buf, Int32(1)) - FfiConverterString.write(errorDetails, into: &buf) - - case let .InvalidAddress(errorDetails): + + case .InvalidNetwork: writeInt(&buf, Int32(2)) - FfiConverterString.write(errorDetails, into: &buf) - - case let .ElectrumError(errorDetails): + + case .MnemonicGenerationFailed: writeInt(&buf, Int32(3)) - FfiConverterString.write(errorDetails, into: &buf) - - case let .WalletError(errorDetails): - writeInt(&buf, Int32(4)) - FfiConverterString.write(errorDetails, into: &buf) - - case let .SyncError(errorDetails): - writeInt(&buf, Int32(5)) - FfiConverterString.write(errorDetails, into: &buf) - + case .InvalidMnemonic: + writeInt(&buf, Int32(4)) - case let .UnsupportedKeyType(errorDetails): - writeInt(&buf, Int32(6)) - FfiConverterString.write(errorDetails, into: &buf) - - case let .NetworkMismatch(errorDetails): - writeInt(&buf, Int32(7)) - FfiConverterString.write(errorDetails, into: &buf) - + case .InvalidEntropy: + writeInt(&buf, Int32(5)) - case let .InvalidTxid(errorDetails): - writeInt(&buf, Int32(8)) - FfiConverterString.write(errorDetails, into: &buf) - - case let .TransactionNotFound(errorDetails): - writeInt(&buf, Int32(9)) - FfiConverterString.write(errorDetails, into: &buf) - + case .AddressDerivationFailed: + writeInt(&buf, Int32(6)) - case let .WatcherError(errorDetails): - writeInt(&buf, Int32(10)) - FfiConverterString.write(errorDetails, into: &buf) - } } } @@ -15023,26 +16900,26 @@ public struct FfiConverterTypeAccountInfoError: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeAccountInfoError_lift(_ buf: RustBuffer) throws -> AccountInfoError { - return try FfiConverterTypeAccountInfoError.lift(buf) +public func FfiConverterTypeAddressError_lift(_ buf: RustBuffer) throws -> AddressError { + return try FfiConverterTypeAddressError.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeAccountInfoError_lower(_ value: AccountInfoError) -> RustBuffer { - return FfiConverterTypeAccountInfoError.lower(value) +public func FfiConverterTypeAddressError_lower(_ value: AddressError) -> RustBuffer { + return FfiConverterTypeAddressError.lower(value) } -extension AccountInfoError: Equatable, Hashable {} +extension AddressError: Equatable, Hashable {} -extension AccountInfoError: Codable {} +extension AddressError: Codable {} -extension AccountInfoError: Foundation.LocalizedError { +extension AddressError: Foundation.LocalizedError { public var errorDescription: String? { String(reflecting: self) } @@ -15053,76 +16930,159 @@ extension AccountInfoError: Foundation.LocalizedError { // Note that we don't yet support `indirect` for enums. // See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. -/** - * Account type classification for extended public keys. - * - * Determines the BIP standard, derivation path purpose, and script type. - */ -public enum AccountType { +public enum AddressType { - /** - * BIP44 legacy (P2PKH) — xpub/tpub prefix - */ - case legacy - /** - * BIP49 wrapped segwit (P2SH-P2WPKH) — ypub/upub prefix - */ - case wrappedSegwit - /** - * BIP84 native segwit (P2WPKH) — zpub/vpub prefix - */ - case nativeSegwit - /** - * BIP86 taproot (P2TR) - */ - case taproot + case p2pkh + case p2sh + case p2wpkh + case p2wsh + case p2tr + case unknown } #if compiler(>=6) -extension AccountType: Sendable {} +extension AddressType: Sendable {} #endif #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeAccountType: FfiConverterRustBuffer { - typealias SwiftType = AccountType +public struct FfiConverterTypeAddressType: FfiConverterRustBuffer { + typealias SwiftType = AddressType + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> AddressType { + let variant: Int32 = try readInt(&buf) + switch variant { + + case 1: return .p2pkh + + case 2: return .p2sh + + case 3: return .p2wpkh + + case 4: return .p2wsh + + case 5: return .p2tr + + case 6: return .unknown + + default: throw UniffiInternalError.unexpectedEnumCase + } + } + + public static func write(_ value: AddressType, into buf: inout [UInt8]) { + switch value { + + + case .p2pkh: + writeInt(&buf, Int32(1)) + + + case .p2sh: + writeInt(&buf, Int32(2)) + + + case .p2wpkh: + writeInt(&buf, Int32(3)) + + + case .p2wsh: + writeInt(&buf, Int32(4)) + + + case .p2tr: + writeInt(&buf, Int32(5)) + + + case .unknown: + writeInt(&buf, Int32(6)) + + } + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeAddressType_lift(_ buf: RustBuffer) throws -> AddressType { + return try FfiConverterTypeAddressType.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeAddressType_lower(_ value: AddressType) -> RustBuffer { + return FfiConverterTypeAddressType.lower(value) +} + + +extension AddressType: Equatable, Hashable {} + +extension AddressType: Codable {} + + + + + + +// Note that we don't yet support `indirect` for enums. +// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. + +public enum BitcoinNetworkEnum { + + case mainnet + case testnet + case signet + case regtest +} + + +#if compiler(>=6) +extension BitcoinNetworkEnum: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeBitcoinNetworkEnum: FfiConverterRustBuffer { + typealias SwiftType = BitcoinNetworkEnum - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> AccountType { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> BitcoinNetworkEnum { let variant: Int32 = try readInt(&buf) switch variant { - case 1: return .legacy + case 1: return .mainnet - case 2: return .wrappedSegwit + case 2: return .testnet - case 3: return .nativeSegwit + case 3: return .signet - case 4: return .taproot + case 4: return .regtest default: throw UniffiInternalError.unexpectedEnumCase } } - public static func write(_ value: AccountType, into buf: inout [UInt8]) { + public static func write(_ value: BitcoinNetworkEnum, into buf: inout [UInt8]) { switch value { - case .legacy: + case .mainnet: writeInt(&buf, Int32(1)) - case .wrappedSegwit: + case .testnet: writeInt(&buf, Int32(2)) - case .nativeSegwit: + case .signet: writeInt(&buf, Int32(3)) - case .taproot: + case .regtest: writeInt(&buf, Int32(4)) } @@ -15133,75 +17093,190 @@ public struct FfiConverterTypeAccountType: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeAccountType_lift(_ buf: RustBuffer) throws -> AccountType { - return try FfiConverterTypeAccountType.lift(buf) +public func FfiConverterTypeBitcoinNetworkEnum_lift(_ buf: RustBuffer) throws -> BitcoinNetworkEnum { + return try FfiConverterTypeBitcoinNetworkEnum.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeAccountType_lower(_ value: AccountType) -> RustBuffer { - return FfiConverterTypeAccountType.lower(value) +public func FfiConverterTypeBitcoinNetworkEnum_lower(_ value: BitcoinNetworkEnum) -> RustBuffer { + return FfiConverterTypeBitcoinNetworkEnum.lower(value) } -extension AccountType: Equatable, Hashable {} +extension BitcoinNetworkEnum: Equatable, Hashable {} -extension AccountType: Codable {} +extension BitcoinNetworkEnum: Codable {} -// Note that we don't yet support `indirect` for enums. -// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. -public enum Activity { +public enum BlocktankError: Swift.Error { + - case onchain(OnchainActivity + + case HttpClient(errorDetails: String ) - case lightning(LightningActivity + case BlocktankClient(errorDetails: String + ) + case InvalidBlocktank(errorDetails: String + ) + case InitializationError(errorDetails: String + ) + case InsertError(errorDetails: String + ) + case RetrievalError(errorDetails: String + ) + case DataError(errorDetails: String + ) + case ConnectionError(errorDetails: String + ) + case SerializationError(errorDetails: String + ) + case ChannelOpen(errorType: BtChannelOrderErrorType, errorDetails: String + ) + case OrderState(errorDetails: String + ) + case InvalidParameter(errorDetails: String + ) + case DatabaseError(errorDetails: String ) } -#if compiler(>=6) -extension Activity: Sendable {} -#endif - #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeActivity: FfiConverterRustBuffer { - typealias SwiftType = Activity +public struct FfiConverterTypeBlocktankError: FfiConverterRustBuffer { + typealias SwiftType = BlocktankError - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Activity { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> BlocktankError { let variant: Int32 = try readInt(&buf) switch variant { + - case 1: return .onchain(try FfiConverterTypeOnchainActivity.read(from: &buf) - ) - - case 2: return .lightning(try FfiConverterTypeLightningActivity.read(from: &buf) - ) + - default: throw UniffiInternalError.unexpectedEnumCase + case 1: return .HttpClient( + errorDetails: try FfiConverterString.read(from: &buf) + ) + case 2: return .BlocktankClient( + errorDetails: try FfiConverterString.read(from: &buf) + ) + case 3: return .InvalidBlocktank( + errorDetails: try FfiConverterString.read(from: &buf) + ) + case 4: return .InitializationError( + errorDetails: try FfiConverterString.read(from: &buf) + ) + case 5: return .InsertError( + errorDetails: try FfiConverterString.read(from: &buf) + ) + case 6: return .RetrievalError( + errorDetails: try FfiConverterString.read(from: &buf) + ) + case 7: return .DataError( + errorDetails: try FfiConverterString.read(from: &buf) + ) + case 8: return .ConnectionError( + errorDetails: try FfiConverterString.read(from: &buf) + ) + case 9: return .SerializationError( + errorDetails: try FfiConverterString.read(from: &buf) + ) + case 10: return .ChannelOpen( + errorType: try FfiConverterTypeBtChannelOrderErrorType.read(from: &buf), + errorDetails: try FfiConverterString.read(from: &buf) + ) + case 11: return .OrderState( + errorDetails: try FfiConverterString.read(from: &buf) + ) + case 12: return .InvalidParameter( + errorDetails: try FfiConverterString.read(from: &buf) + ) + case 13: return .DatabaseError( + errorDetails: try FfiConverterString.read(from: &buf) + ) + + default: throw UniffiInternalError.unexpectedEnumCase } } - public static func write(_ value: Activity, into buf: inout [UInt8]) { + public static func write(_ value: BlocktankError, into buf: inout [UInt8]) { switch value { + + + - case let .onchain(v1): + case let .HttpClient(errorDetails): writeInt(&buf, Int32(1)) - FfiConverterTypeOnchainActivity.write(v1, into: &buf) + FfiConverterString.write(errorDetails, into: &buf) - case let .lightning(v1): + case let .BlocktankClient(errorDetails): writeInt(&buf, Int32(2)) - FfiConverterTypeLightningActivity.write(v1, into: &buf) + FfiConverterString.write(errorDetails, into: &buf) + + + case let .InvalidBlocktank(errorDetails): + writeInt(&buf, Int32(3)) + FfiConverterString.write(errorDetails, into: &buf) + + + case let .InitializationError(errorDetails): + writeInt(&buf, Int32(4)) + FfiConverterString.write(errorDetails, into: &buf) + + + case let .InsertError(errorDetails): + writeInt(&buf, Int32(5)) + FfiConverterString.write(errorDetails, into: &buf) + + + case let .RetrievalError(errorDetails): + writeInt(&buf, Int32(6)) + FfiConverterString.write(errorDetails, into: &buf) + + + case let .DataError(errorDetails): + writeInt(&buf, Int32(7)) + FfiConverterString.write(errorDetails, into: &buf) + + + case let .ConnectionError(errorDetails): + writeInt(&buf, Int32(8)) + FfiConverterString.write(errorDetails, into: &buf) + + + case let .SerializationError(errorDetails): + writeInt(&buf, Int32(9)) + FfiConverterString.write(errorDetails, into: &buf) + + + case let .ChannelOpen(errorType,errorDetails): + writeInt(&buf, Int32(10)) + FfiConverterTypeBtChannelOrderErrorType.write(errorType, into: &buf) + FfiConverterString.write(errorDetails, into: &buf) + + + case let .OrderState(errorDetails): + writeInt(&buf, Int32(11)) + FfiConverterString.write(errorDetails, into: &buf) + + + case let .InvalidParameter(errorDetails): + writeInt(&buf, Int32(12)) + FfiConverterString.write(errorDetails, into: &buf) + + + case let .DatabaseError(errorDetails): + writeInt(&buf, Int32(13)) + FfiConverterString.write(errorDetails, into: &buf) } } @@ -15211,81 +17286,101 @@ public struct FfiConverterTypeActivity: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeActivity_lift(_ buf: RustBuffer) throws -> Activity { - return try FfiConverterTypeActivity.lift(buf) +public func FfiConverterTypeBlocktankError_lift(_ buf: RustBuffer) throws -> BlocktankError { + return try FfiConverterTypeBlocktankError.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeActivity_lower(_ value: Activity) -> RustBuffer { - return FfiConverterTypeActivity.lower(value) +public func FfiConverterTypeBlocktankError_lower(_ value: BlocktankError) -> RustBuffer { + return FfiConverterTypeBlocktankError.lower(value) } -extension Activity: Equatable, Hashable {} +extension BlocktankError: Equatable, Hashable {} + +extension BlocktankError: Codable {} -extension Activity: Codable {} +extension BlocktankError: Foundation.LocalizedError { + public var errorDescription: String? { + String(reflecting: self) + } +} -public enum ActivityError: Swift.Error { + +/** + * Errors surfaced by the Boltz swaps module. + */ +public enum BoltzError: Swift.Error { - case InvalidActivity(errorDetails: String - ) case InitializationError(errorDetails: String ) - case InsertError(errorDetails: String + case ConnectionError(errorDetails: String ) - case RetrievalError(errorDetails: String + case DatabaseError(errorDetails: String ) - case DataError(errorDetails: String + case ApiError(errorDetails: String ) - case ConnectionError(errorDetails: String + case SwapError(errorDetails: String + ) + case BroadcastError(errorDetails: String + ) + case InvalidInput(errorDetails: String ) case SerializationError(errorDetails: String ) + case NotFound(errorDetails: String + ) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeActivityError: FfiConverterRustBuffer { - typealias SwiftType = ActivityError +public struct FfiConverterTypeBoltzError: FfiConverterRustBuffer { + typealias SwiftType = BoltzError - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ActivityError { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> BoltzError { let variant: Int32 = try readInt(&buf) switch variant { - case 1: return .InvalidActivity( + case 1: return .InitializationError( errorDetails: try FfiConverterString.read(from: &buf) ) - case 2: return .InitializationError( + case 2: return .ConnectionError( errorDetails: try FfiConverterString.read(from: &buf) ) - case 3: return .InsertError( + case 3: return .DatabaseError( errorDetails: try FfiConverterString.read(from: &buf) ) - case 4: return .RetrievalError( + case 4: return .ApiError( errorDetails: try FfiConverterString.read(from: &buf) ) - case 5: return .DataError( + case 5: return .SwapError( + errorDetails: try FfiConverterString.read(from: &buf) + ) + case 6: return .BroadcastError( + errorDetails: try FfiConverterString.read(from: &buf) + ) + case 7: return .InvalidInput( errorDetails: try FfiConverterString.read(from: &buf) ) - case 6: return .ConnectionError( + case 8: return .SerializationError( errorDetails: try FfiConverterString.read(from: &buf) ) - case 7: return .SerializationError( + case 9: return .NotFound( errorDetails: try FfiConverterString.read(from: &buf) ) @@ -15293,47 +17388,57 @@ public struct FfiConverterTypeActivityError: FfiConverterRustBuffer { } } - public static func write(_ value: ActivityError, into buf: inout [UInt8]) { + public static func write(_ value: BoltzError, into buf: inout [UInt8]) { switch value { - case let .InvalidActivity(errorDetails): + case let .InitializationError(errorDetails): writeInt(&buf, Int32(1)) FfiConverterString.write(errorDetails, into: &buf) - case let .InitializationError(errorDetails): + case let .ConnectionError(errorDetails): writeInt(&buf, Int32(2)) FfiConverterString.write(errorDetails, into: &buf) - case let .InsertError(errorDetails): + case let .DatabaseError(errorDetails): writeInt(&buf, Int32(3)) FfiConverterString.write(errorDetails, into: &buf) - case let .RetrievalError(errorDetails): + case let .ApiError(errorDetails): writeInt(&buf, Int32(4)) FfiConverterString.write(errorDetails, into: &buf) - case let .DataError(errorDetails): + case let .SwapError(errorDetails): writeInt(&buf, Int32(5)) FfiConverterString.write(errorDetails, into: &buf) - case let .ConnectionError(errorDetails): + case let .BroadcastError(errorDetails): writeInt(&buf, Int32(6)) FfiConverterString.write(errorDetails, into: &buf) - case let .SerializationError(errorDetails): + case let .InvalidInput(errorDetails): writeInt(&buf, Int32(7)) FfiConverterString.write(errorDetails, into: &buf) + + case let .SerializationError(errorDetails): + writeInt(&buf, Int32(8)) + FfiConverterString.write(errorDetails, into: &buf) + + + case let .NotFound(errorDetails): + writeInt(&buf, Int32(9)) + FfiConverterString.write(errorDetails, into: &buf) + } } } @@ -15342,26 +17447,26 @@ public struct FfiConverterTypeActivityError: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeActivityError_lift(_ buf: RustBuffer) throws -> ActivityError { - return try FfiConverterTypeActivityError.lift(buf) +public func FfiConverterTypeBoltzError_lift(_ buf: RustBuffer) throws -> BoltzError { + return try FfiConverterTypeBoltzError.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeActivityError_lower(_ value: ActivityError) -> RustBuffer { - return FfiConverterTypeActivityError.lower(value) +public func FfiConverterTypeBoltzError_lower(_ value: BoltzError) -> RustBuffer { + return FfiConverterTypeBoltzError.lower(value) } -extension ActivityError: Equatable, Hashable {} +extension BoltzError: Equatable, Hashable {} -extension ActivityError: Codable {} +extension BoltzError: Codable {} -extension ActivityError: Foundation.LocalizedError { +extension BoltzError: Foundation.LocalizedError { public var errorDescription: String? { String(reflecting: self) } @@ -15372,223 +17477,58 @@ extension ActivityError: Foundation.LocalizedError { // Note that we don't yet support `indirect` for enums. // See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. +/** + * Bitcoin network selection for Boltz swaps. Maps to the networks Boltz + * operates on (mainnet, testnet, regtest). + */ -public enum ActivityFilter { +public enum BoltzNetwork { - case all - case lightning - case onchain + case mainnet + case testnet + case regtest } #if compiler(>=6) -extension ActivityFilter: Sendable {} +extension BoltzNetwork: Sendable {} #endif #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeActivityFilter: FfiConverterRustBuffer { - typealias SwiftType = ActivityFilter +public struct FfiConverterTypeBoltzNetwork: FfiConverterRustBuffer { + typealias SwiftType = BoltzNetwork - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ActivityFilter { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> BoltzNetwork { let variant: Int32 = try readInt(&buf) switch variant { - case 1: return .all - - case 2: return .lightning - - case 3: return .onchain - - default: throw UniffiInternalError.unexpectedEnumCase - } - } - - public static func write(_ value: ActivityFilter, into buf: inout [UInt8]) { - switch value { - - - case .all: - writeInt(&buf, Int32(1)) - - - case .lightning: - writeInt(&buf, Int32(2)) - - - case .onchain: - writeInt(&buf, Int32(3)) - - } - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeActivityFilter_lift(_ buf: RustBuffer) throws -> ActivityFilter { - return try FfiConverterTypeActivityFilter.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeActivityFilter_lower(_ value: ActivityFilter) -> RustBuffer { - return FfiConverterTypeActivityFilter.lower(value) -} - - -extension ActivityFilter: Equatable, Hashable {} - -extension ActivityFilter: Codable {} - - - - - - -// Note that we don't yet support `indirect` for enums. -// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. - -public enum ActivityType { - - case onchain - case lightning -} - - -#if compiler(>=6) -extension ActivityType: Sendable {} -#endif - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeActivityType: FfiConverterRustBuffer { - typealias SwiftType = ActivityType - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ActivityType { - let variant: Int32 = try readInt(&buf) - switch variant { + case 1: return .mainnet - case 1: return .onchain + case 2: return .testnet - case 2: return .lightning + case 3: return .regtest default: throw UniffiInternalError.unexpectedEnumCase } } - public static func write(_ value: ActivityType, into buf: inout [UInt8]) { - switch value { - - - case .onchain: - writeInt(&buf, Int32(1)) - - - case .lightning: - writeInt(&buf, Int32(2)) - - } - } -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeActivityType_lift(_ buf: RustBuffer) throws -> ActivityType { - return try FfiConverterTypeActivityType.lift(buf) -} - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public func FfiConverterTypeActivityType_lower(_ value: ActivityType) -> RustBuffer { - return FfiConverterTypeActivityType.lower(value) -} - - -extension ActivityType: Equatable, Hashable {} - -extension ActivityType: Codable {} - - - - - - - -public enum AddressError: Swift.Error { - - - - case InvalidAddress - case InvalidNetwork - case MnemonicGenerationFailed - case InvalidMnemonic - case InvalidEntropy - case AddressDerivationFailed -} - - -#if swift(>=5.8) -@_documentation(visibility: private) -#endif -public struct FfiConverterTypeAddressError: FfiConverterRustBuffer { - typealias SwiftType = AddressError - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> AddressError { - let variant: Int32 = try readInt(&buf) - switch variant { - - - - - case 1: return .InvalidAddress - case 2: return .InvalidNetwork - case 3: return .MnemonicGenerationFailed - case 4: return .InvalidMnemonic - case 5: return .InvalidEntropy - case 6: return .AddressDerivationFailed - - default: throw UniffiInternalError.unexpectedEnumCase - } - } - - public static func write(_ value: AddressError, into buf: inout [UInt8]) { + public static func write(_ value: BoltzNetwork, into buf: inout [UInt8]) { switch value { - - - - case .InvalidAddress: + case .mainnet: writeInt(&buf, Int32(1)) - case .InvalidNetwork: + case .testnet: writeInt(&buf, Int32(2)) - case .MnemonicGenerationFailed: + case .regtest: writeInt(&buf, Int32(3)) - - case .InvalidMnemonic: - writeInt(&buf, Int32(4)) - - - case .InvalidEntropy: - writeInt(&buf, Int32(5)) - - - case .AddressDerivationFailed: - writeInt(&buf, Int32(6)) - } } } @@ -15597,105 +17537,116 @@ public struct FfiConverterTypeAddressError: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeAddressError_lift(_ buf: RustBuffer) throws -> AddressError { - return try FfiConverterTypeAddressError.lift(buf) +public func FfiConverterTypeBoltzNetwork_lift(_ buf: RustBuffer) throws -> BoltzNetwork { + return try FfiConverterTypeBoltzNetwork.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeAddressError_lower(_ value: AddressError) -> RustBuffer { - return FfiConverterTypeAddressError.lower(value) +public func FfiConverterTypeBoltzNetwork_lower(_ value: BoltzNetwork) -> RustBuffer { + return FfiConverterTypeBoltzNetwork.lower(value) } -extension AddressError: Equatable, Hashable {} - -extension AddressError: Codable {} - +extension BoltzNetwork: Equatable, Hashable {} +extension BoltzNetwork: Codable {} -extension AddressError: Foundation.LocalizedError { - public var errorDescription: String? { - String(reflecting: self) - } -} // Note that we don't yet support `indirect` for enums. // See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. +/** + * Events emitted to a registered [`crate::modules::boltz::BoltzEventListener`] + * as swaps progress through their lifecycle. + */ -public enum AddressType { +public enum BoltzSwapEvent { - case p2pkh - case p2sh - case p2wpkh - case p2wsh - case p2tr - case unknown + /** + * The swap transitioned to a new status. + */ + case statusUpdate(swapId: String, status: BoltzSwapStatus + ) + /** + * A reverse swap was claimed onchain. `txid` is the claim transaction. + */ + case claimed(swapId: String, txid: String + ) + /** + * A submarine swap was refunded onchain. `txid` is the refund transaction. + */ + case refunded(swapId: String, txid: String + ) + /** + * An error occurred while processing the swap (e.g. an auto-claim failed). + */ + case error(swapId: String, message: String + ) } #if compiler(>=6) -extension AddressType: Sendable {} +extension BoltzSwapEvent: Sendable {} #endif #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeAddressType: FfiConverterRustBuffer { - typealias SwiftType = AddressType +public struct FfiConverterTypeBoltzSwapEvent: FfiConverterRustBuffer { + typealias SwiftType = BoltzSwapEvent - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> AddressType { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> BoltzSwapEvent { let variant: Int32 = try readInt(&buf) switch variant { - case 1: return .p2pkh - - case 2: return .p2sh - - case 3: return .p2wpkh + case 1: return .statusUpdate(swapId: try FfiConverterString.read(from: &buf), status: try FfiConverterTypeBoltzSwapStatus.read(from: &buf) + ) - case 4: return .p2wsh + case 2: return .claimed(swapId: try FfiConverterString.read(from: &buf), txid: try FfiConverterString.read(from: &buf) + ) - case 5: return .p2tr + case 3: return .refunded(swapId: try FfiConverterString.read(from: &buf), txid: try FfiConverterString.read(from: &buf) + ) - case 6: return .unknown + case 4: return .error(swapId: try FfiConverterString.read(from: &buf), message: try FfiConverterString.read(from: &buf) + ) default: throw UniffiInternalError.unexpectedEnumCase } } - public static func write(_ value: AddressType, into buf: inout [UInt8]) { + public static func write(_ value: BoltzSwapEvent, into buf: inout [UInt8]) { switch value { - case .p2pkh: + case let .statusUpdate(swapId,status): writeInt(&buf, Int32(1)) + FfiConverterString.write(swapId, into: &buf) + FfiConverterTypeBoltzSwapStatus.write(status, into: &buf) + - - case .p2sh: + case let .claimed(swapId,txid): writeInt(&buf, Int32(2)) + FfiConverterString.write(swapId, into: &buf) + FfiConverterString.write(txid, into: &buf) + - - case .p2wpkh: + case let .refunded(swapId,txid): writeInt(&buf, Int32(3)) + FfiConverterString.write(swapId, into: &buf) + FfiConverterString.write(txid, into: &buf) + - - case .p2wsh: + case let .error(swapId,message): writeInt(&buf, Int32(4)) - - - case .p2tr: - writeInt(&buf, Int32(5)) - - - case .unknown: - writeInt(&buf, Int32(6)) - + FfiConverterString.write(swapId, into: &buf) + FfiConverterString.write(message, into: &buf) + } } } @@ -15704,21 +17655,21 @@ public struct FfiConverterTypeAddressType: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeAddressType_lift(_ buf: RustBuffer) throws -> AddressType { - return try FfiConverterTypeAddressType.lift(buf) +public func FfiConverterTypeBoltzSwapEvent_lift(_ buf: RustBuffer) throws -> BoltzSwapEvent { + return try FfiConverterTypeBoltzSwapEvent.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeAddressType_lower(_ value: AddressType) -> RustBuffer { - return FfiConverterTypeAddressType.lower(value) +public func FfiConverterTypeBoltzSwapEvent_lower(_ value: BoltzSwapEvent) -> RustBuffer { + return FfiConverterTypeBoltzSwapEvent.lower(value) } -extension AddressType: Equatable, Hashable {} +extension BoltzSwapEvent: Equatable, Hashable {} -extension AddressType: Codable {} +extension BoltzSwapEvent: Codable {} @@ -15727,61 +17678,202 @@ extension AddressType: Codable {} // Note that we don't yet support `indirect` for enums. // See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. +/** + * Typed view of the Boltz swap lifecycle. `Unknown` carries the raw status so + * new server-side states don't break the bindings. + * + * See . + */ -public enum BitcoinNetworkEnum { +public enum BoltzSwapStatus { - case mainnet - case testnet - case signet - case regtest + /** + * `swap.created` — initial state. + */ + case swapCreated + /** + * `invoice.set` — invoice attached to a submarine swap. + */ + case invoiceSet + /** + * `transaction.mempool` — a lockup transaction is in the mempool. + */ + case transactionMempool + /** + * `transaction.confirmed` — a lockup transaction confirmed. + */ + case transactionConfirmed + /** + * `invoice.pending` — Boltz is paying the submarine swap invoice. + */ + case invoicePending + /** + * `invoice.paid` — submarine swap invoice paid by Boltz. + */ + case invoicePaid + /** + * `invoice.settled` — reverse swap invoice settled (preimage revealed). + */ + case invoiceSettled + /** + * `invoice.failedToPay` — submarine swap invoice could not be paid; refund. + */ + case invoiceFailedToPay + /** + * `invoice.expired` — reverse swap invoice expired before payment. + */ + case invoiceExpired + /** + * `transaction.claim.pending` — Boltz ready for a cooperative claim. + */ + case transactionClaimPending + /** + * `transaction.claimed` — onchain funds claimed. + */ + case transactionClaimed + /** + * `transaction.refunded` — onchain funds refunded. + */ + case transactionRefunded + /** + * `transaction.lockupFailed` — wrong amount locked; can refund. + */ + case transactionLockupFailed + /** + * `transaction.failed` — Boltz failed to lock the agreed funds. + */ + case transactionFailed + /** + * `swap.expired` — swap expired without completing. + */ + case swapExpired + /** + * Any status not yet modelled. `raw` holds the verbatim Boltz status. + */ + case unknown(raw: String + ) } #if compiler(>=6) -extension BitcoinNetworkEnum: Sendable {} +extension BoltzSwapStatus: Sendable {} #endif #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeBitcoinNetworkEnum: FfiConverterRustBuffer { - typealias SwiftType = BitcoinNetworkEnum +public struct FfiConverterTypeBoltzSwapStatus: FfiConverterRustBuffer { + typealias SwiftType = BoltzSwapStatus - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> BitcoinNetworkEnum { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> BoltzSwapStatus { let variant: Int32 = try readInt(&buf) switch variant { - case 1: return .mainnet + case 1: return .swapCreated + + case 2: return .invoiceSet + + case 3: return .transactionMempool + + case 4: return .transactionConfirmed + + case 5: return .invoicePending + + case 6: return .invoicePaid + + case 7: return .invoiceSettled + + case 8: return .invoiceFailedToPay + + case 9: return .invoiceExpired + + case 10: return .transactionClaimPending + + case 11: return .transactionClaimed + + case 12: return .transactionRefunded + + case 13: return .transactionLockupFailed + + case 14: return .transactionFailed + + case 15: return .swapExpired + + case 16: return .unknown(raw: try FfiConverterString.read(from: &buf) + ) + + default: throw UniffiInternalError.unexpectedEnumCase + } + } + + public static func write(_ value: BoltzSwapStatus, into buf: inout [UInt8]) { + switch value { + + + case .swapCreated: + writeInt(&buf, Int32(1)) + + + case .invoiceSet: + writeInt(&buf, Int32(2)) + + + case .transactionMempool: + writeInt(&buf, Int32(3)) + + + case .transactionConfirmed: + writeInt(&buf, Int32(4)) + + + case .invoicePending: + writeInt(&buf, Int32(5)) + - case 2: return .testnet + case .invoicePaid: + writeInt(&buf, Int32(6)) - case 3: return .signet - case 4: return .regtest + case .invoiceSettled: + writeInt(&buf, Int32(7)) - default: throw UniffiInternalError.unexpectedEnumCase - } - } - - public static func write(_ value: BitcoinNetworkEnum, into buf: inout [UInt8]) { - switch value { + case .invoiceFailedToPay: + writeInt(&buf, Int32(8)) - case .mainnet: - writeInt(&buf, Int32(1)) + case .invoiceExpired: + writeInt(&buf, Int32(9)) - case .testnet: - writeInt(&buf, Int32(2)) + case .transactionClaimPending: + writeInt(&buf, Int32(10)) - case .signet: - writeInt(&buf, Int32(3)) + case .transactionClaimed: + writeInt(&buf, Int32(11)) - case .regtest: - writeInt(&buf, Int32(4)) + case .transactionRefunded: + writeInt(&buf, Int32(12)) + + + case .transactionLockupFailed: + writeInt(&buf, Int32(13)) + + + case .transactionFailed: + writeInt(&buf, Int32(14)) + + + case .swapExpired: + writeInt(&buf, Int32(15)) + + + case let .unknown(raw): + writeInt(&buf, Int32(16)) + FfiConverterString.write(raw, into: &buf) + } } } @@ -15790,191 +17882,78 @@ public struct FfiConverterTypeBitcoinNetworkEnum: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeBitcoinNetworkEnum_lift(_ buf: RustBuffer) throws -> BitcoinNetworkEnum { - return try FfiConverterTypeBitcoinNetworkEnum.lift(buf) +public func FfiConverterTypeBoltzSwapStatus_lift(_ buf: RustBuffer) throws -> BoltzSwapStatus { + return try FfiConverterTypeBoltzSwapStatus.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeBitcoinNetworkEnum_lower(_ value: BitcoinNetworkEnum) -> RustBuffer { - return FfiConverterTypeBitcoinNetworkEnum.lower(value) +public func FfiConverterTypeBoltzSwapStatus_lower(_ value: BoltzSwapStatus) -> RustBuffer { + return FfiConverterTypeBoltzSwapStatus.lower(value) } -extension BitcoinNetworkEnum: Equatable, Hashable {} - -extension BitcoinNetworkEnum: Codable {} +extension BoltzSwapStatus: Equatable, Hashable {} +extension BoltzSwapStatus: Codable {} -public enum BlocktankError: Swift.Error { +// Note that we don't yet support `indirect` for enums. +// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. +/** + * The direction of a Boltz swap. + * + * - `Submarine`: onchain Bitcoin -> Lightning (the user locks onchain funds, + * Boltz pays a Lightning invoice). + * - `Reverse`: Lightning -> onchain Bitcoin (the user pays a Boltz hold + * invoice, Boltz locks onchain funds the user then claims). + */ +public enum BoltzSwapType { - - case HttpClient(errorDetails: String - ) - case BlocktankClient(errorDetails: String - ) - case InvalidBlocktank(errorDetails: String - ) - case InitializationError(errorDetails: String - ) - case InsertError(errorDetails: String - ) - case RetrievalError(errorDetails: String - ) - case DataError(errorDetails: String - ) - case ConnectionError(errorDetails: String - ) - case SerializationError(errorDetails: String - ) - case ChannelOpen(errorType: BtChannelOrderErrorType, errorDetails: String - ) - case OrderState(errorDetails: String - ) - case InvalidParameter(errorDetails: String - ) - case DatabaseError(errorDetails: String - ) + case submarine + case reverse } +#if compiler(>=6) +extension BoltzSwapType: Sendable {} +#endif + #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeBlocktankError: FfiConverterRustBuffer { - typealias SwiftType = BlocktankError +public struct FfiConverterTypeBoltzSwapType: FfiConverterRustBuffer { + typealias SwiftType = BoltzSwapType - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> BlocktankError { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> BoltzSwapType { let variant: Int32 = try readInt(&buf) switch variant { - - + case 1: return .submarine - case 1: return .HttpClient( - errorDetails: try FfiConverterString.read(from: &buf) - ) - case 2: return .BlocktankClient( - errorDetails: try FfiConverterString.read(from: &buf) - ) - case 3: return .InvalidBlocktank( - errorDetails: try FfiConverterString.read(from: &buf) - ) - case 4: return .InitializationError( - errorDetails: try FfiConverterString.read(from: &buf) - ) - case 5: return .InsertError( - errorDetails: try FfiConverterString.read(from: &buf) - ) - case 6: return .RetrievalError( - errorDetails: try FfiConverterString.read(from: &buf) - ) - case 7: return .DataError( - errorDetails: try FfiConverterString.read(from: &buf) - ) - case 8: return .ConnectionError( - errorDetails: try FfiConverterString.read(from: &buf) - ) - case 9: return .SerializationError( - errorDetails: try FfiConverterString.read(from: &buf) - ) - case 10: return .ChannelOpen( - errorType: try FfiConverterTypeBtChannelOrderErrorType.read(from: &buf), - errorDetails: try FfiConverterString.read(from: &buf) - ) - case 11: return .OrderState( - errorDetails: try FfiConverterString.read(from: &buf) - ) - case 12: return .InvalidParameter( - errorDetails: try FfiConverterString.read(from: &buf) - ) - case 13: return .DatabaseError( - errorDetails: try FfiConverterString.read(from: &buf) - ) - - default: throw UniffiInternalError.unexpectedEnumCase + case 2: return .reverse + + default: throw UniffiInternalError.unexpectedEnumCase } } - public static func write(_ value: BlocktankError, into buf: inout [UInt8]) { + public static func write(_ value: BoltzSwapType, into buf: inout [UInt8]) { switch value { - - - - case let .HttpClient(errorDetails): + case .submarine: writeInt(&buf, Int32(1)) - FfiConverterString.write(errorDetails, into: &buf) - - - case let .BlocktankClient(errorDetails): - writeInt(&buf, Int32(2)) - FfiConverterString.write(errorDetails, into: &buf) - - - case let .InvalidBlocktank(errorDetails): - writeInt(&buf, Int32(3)) - FfiConverterString.write(errorDetails, into: &buf) - - - case let .InitializationError(errorDetails): - writeInt(&buf, Int32(4)) - FfiConverterString.write(errorDetails, into: &buf) - - - case let .InsertError(errorDetails): - writeInt(&buf, Int32(5)) - FfiConverterString.write(errorDetails, into: &buf) - - - case let .RetrievalError(errorDetails): - writeInt(&buf, Int32(6)) - FfiConverterString.write(errorDetails, into: &buf) - - - case let .DataError(errorDetails): - writeInt(&buf, Int32(7)) - FfiConverterString.write(errorDetails, into: &buf) - - - case let .ConnectionError(errorDetails): - writeInt(&buf, Int32(8)) - FfiConverterString.write(errorDetails, into: &buf) - - case let .SerializationError(errorDetails): - writeInt(&buf, Int32(9)) - FfiConverterString.write(errorDetails, into: &buf) - - - case let .ChannelOpen(errorType,errorDetails): - writeInt(&buf, Int32(10)) - FfiConverterTypeBtChannelOrderErrorType.write(errorType, into: &buf) - FfiConverterString.write(errorDetails, into: &buf) - - - case let .OrderState(errorDetails): - writeInt(&buf, Int32(11)) - FfiConverterString.write(errorDetails, into: &buf) - - case let .InvalidParameter(errorDetails): - writeInt(&buf, Int32(12)) - FfiConverterString.write(errorDetails, into: &buf) - + case .reverse: + writeInt(&buf, Int32(2)) - case let .DatabaseError(errorDetails): - writeInt(&buf, Int32(13)) - FfiConverterString.write(errorDetails, into: &buf) - } } } @@ -15983,59 +17962,39 @@ public struct FfiConverterTypeBlocktankError: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeBlocktankError_lift(_ buf: RustBuffer) throws -> BlocktankError { - return try FfiConverterTypeBlocktankError.lift(buf) +public func FfiConverterTypeBoltzSwapType_lift(_ buf: RustBuffer) throws -> BoltzSwapType { + return try FfiConverterTypeBoltzSwapType.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeBlocktankError_lower(_ value: BlocktankError) -> RustBuffer { - return FfiConverterTypeBlocktankError.lower(value) +public func FfiConverterTypeBoltzSwapType_lower(_ value: BoltzSwapType) -> RustBuffer { + return FfiConverterTypeBoltzSwapType.lower(value) } -extension BlocktankError: Equatable, Hashable {} - -extension BlocktankError: Codable {} - +extension BoltzSwapType: Equatable, Hashable {} +extension BoltzSwapType: Codable {} -extension BlocktankError: Foundation.LocalizedError { - public var errorDescription: String? { - String(reflecting: self) - } -} -/** - * Errors surfaced by the Boltz swaps module. - */ -public enum BoltzError: Swift.Error { +public enum BroadcastError: Swift.Error { - case InitializationError(errorDetails: String - ) - case ConnectionError(errorDetails: String - ) - case DatabaseError(errorDetails: String - ) - case ApiError(errorDetails: String - ) - case SwapError(errorDetails: String - ) - case BroadcastError(errorDetails: String + case InvalidHex(errorDetails: String ) - case InvalidInput(errorDetails: String + case InvalidTransaction(errorDetails: String ) - case SerializationError(errorDetails: String + case ElectrumError(errorDetails: String ) - case NotFound(errorDetails: String + case TaskError(errorDetails: String ) } @@ -16043,41 +18002,26 @@ public enum BoltzError: Swift.Error { #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeBoltzError: FfiConverterRustBuffer { - typealias SwiftType = BoltzError +public struct FfiConverterTypeBroadcastError: FfiConverterRustBuffer { + typealias SwiftType = BroadcastError - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> BoltzError { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> BroadcastError { let variant: Int32 = try readInt(&buf) switch variant { - case 1: return .InitializationError( - errorDetails: try FfiConverterString.read(from: &buf) - ) - case 2: return .ConnectionError( - errorDetails: try FfiConverterString.read(from: &buf) - ) - case 3: return .DatabaseError( - errorDetails: try FfiConverterString.read(from: &buf) - ) - case 4: return .ApiError( - errorDetails: try FfiConverterString.read(from: &buf) - ) - case 5: return .SwapError( - errorDetails: try FfiConverterString.read(from: &buf) - ) - case 6: return .BroadcastError( + case 1: return .InvalidHex( errorDetails: try FfiConverterString.read(from: &buf) ) - case 7: return .InvalidInput( + case 2: return .InvalidTransaction( errorDetails: try FfiConverterString.read(from: &buf) ) - case 8: return .SerializationError( + case 3: return .ElectrumError( errorDetails: try FfiConverterString.read(from: &buf) ) - case 9: return .NotFound( + case 4: return .TaskError( errorDetails: try FfiConverterString.read(from: &buf) ) @@ -16085,57 +18029,32 @@ public struct FfiConverterTypeBoltzError: FfiConverterRustBuffer { } } - public static func write(_ value: BoltzError, into buf: inout [UInt8]) { + public static func write(_ value: BroadcastError, into buf: inout [UInt8]) { switch value { - case let .InitializationError(errorDetails): + case let .InvalidHex(errorDetails): writeInt(&buf, Int32(1)) FfiConverterString.write(errorDetails, into: &buf) - case let .ConnectionError(errorDetails): + case let .InvalidTransaction(errorDetails): writeInt(&buf, Int32(2)) FfiConverterString.write(errorDetails, into: &buf) - case let .DatabaseError(errorDetails): + case let .ElectrumError(errorDetails): writeInt(&buf, Int32(3)) FfiConverterString.write(errorDetails, into: &buf) - case let .ApiError(errorDetails): + case let .TaskError(errorDetails): writeInt(&buf, Int32(4)) FfiConverterString.write(errorDetails, into: &buf) - - case let .SwapError(errorDetails): - writeInt(&buf, Int32(5)) - FfiConverterString.write(errorDetails, into: &buf) - - - case let .BroadcastError(errorDetails): - writeInt(&buf, Int32(6)) - FfiConverterString.write(errorDetails, into: &buf) - - - case let .InvalidInput(errorDetails): - writeInt(&buf, Int32(7)) - FfiConverterString.write(errorDetails, into: &buf) - - - case let .SerializationError(errorDetails): - writeInt(&buf, Int32(8)) - FfiConverterString.write(errorDetails, into: &buf) - - - case let .NotFound(errorDetails): - writeInt(&buf, Int32(9)) - FfiConverterString.write(errorDetails, into: &buf) - } } } @@ -16144,26 +18063,26 @@ public struct FfiConverterTypeBoltzError: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeBoltzError_lift(_ buf: RustBuffer) throws -> BoltzError { - return try FfiConverterTypeBoltzError.lift(buf) +public func FfiConverterTypeBroadcastError_lift(_ buf: RustBuffer) throws -> BroadcastError { + return try FfiConverterTypeBroadcastError.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeBoltzError_lower(_ value: BoltzError) -> RustBuffer { - return FfiConverterTypeBoltzError.lower(value) +public func FfiConverterTypeBroadcastError_lower(_ value: BroadcastError) -> RustBuffer { + return FfiConverterTypeBroadcastError.lower(value) } -extension BoltzError: Equatable, Hashable {} +extension BroadcastError: Equatable, Hashable {} -extension BoltzError: Codable {} +extension BroadcastError: Codable {} -extension BoltzError: Foundation.LocalizedError { +extension BroadcastError: Foundation.LocalizedError { public var errorDescription: String? { String(reflecting: self) } @@ -16174,58 +18093,61 @@ extension BoltzError: Foundation.LocalizedError { // Note that we don't yet support `indirect` for enums. // See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. -/** - * Bitcoin network selection for Boltz swaps. Maps to the networks Boltz - * operates on (mainnet, testnet, regtest). - */ -public enum BoltzNetwork { +public enum BtBolt11InvoiceState { - case mainnet - case testnet - case regtest + case pending + case holding + case paid + case canceled } #if compiler(>=6) -extension BoltzNetwork: Sendable {} +extension BtBolt11InvoiceState: Sendable {} #endif #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeBoltzNetwork: FfiConverterRustBuffer { - typealias SwiftType = BoltzNetwork +public struct FfiConverterTypeBtBolt11InvoiceState: FfiConverterRustBuffer { + typealias SwiftType = BtBolt11InvoiceState - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> BoltzNetwork { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> BtBolt11InvoiceState { let variant: Int32 = try readInt(&buf) switch variant { - case 1: return .mainnet + case 1: return .pending - case 2: return .testnet + case 2: return .holding - case 3: return .regtest + case 3: return .paid + + case 4: return .canceled default: throw UniffiInternalError.unexpectedEnumCase } } - public static func write(_ value: BoltzNetwork, into buf: inout [UInt8]) { + public static func write(_ value: BtBolt11InvoiceState, into buf: inout [UInt8]) { switch value { - case .mainnet: + case .pending: writeInt(&buf, Int32(1)) - case .testnet: + case .holding: writeInt(&buf, Int32(2)) - case .regtest: + case .paid: writeInt(&buf, Int32(3)) + + case .canceled: + writeInt(&buf, Int32(4)) + } } } @@ -16234,21 +18156,21 @@ public struct FfiConverterTypeBoltzNetwork: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeBoltzNetwork_lift(_ buf: RustBuffer) throws -> BoltzNetwork { - return try FfiConverterTypeBoltzNetwork.lift(buf) +public func FfiConverterTypeBtBolt11InvoiceState_lift(_ buf: RustBuffer) throws -> BtBolt11InvoiceState { + return try FfiConverterTypeBtBolt11InvoiceState.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeBoltzNetwork_lower(_ value: BoltzNetwork) -> RustBuffer { - return FfiConverterTypeBoltzNetwork.lower(value) +public func FfiConverterTypeBtBolt11InvoiceState_lower(_ value: BtBolt11InvoiceState) -> RustBuffer { + return FfiConverterTypeBtBolt11InvoiceState.lower(value) } -extension BoltzNetwork: Equatable, Hashable {} +extension BtBolt11InvoiceState: Equatable, Hashable {} -extension BoltzNetwork: Codable {} +extension BtBolt11InvoiceState: Codable {} @@ -16257,93 +18179,147 @@ extension BoltzNetwork: Codable {} // Note that we don't yet support `indirect` for enums. // See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. -/** - * Events emitted to a registered [`crate::modules::boltz::BoltzEventListener`] - * as swaps progress through their lifecycle. - */ -public enum BoltzSwapEvent { +public enum BtChannelOrderErrorType { - /** - * The swap transitioned to a new status. - */ - case statusUpdate(swapId: String, status: BoltzSwapStatus - ) - /** - * A reverse swap was claimed onchain. `txid` is the claim transaction. - */ - case claimed(swapId: String, txid: String - ) - /** - * A submarine swap was refunded onchain. `txid` is the refund transaction. - */ - case refunded(swapId: String, txid: String - ) - /** - * An error occurred while processing the swap (e.g. an auto-claim failed). - */ - case error(swapId: String, message: String - ) + case wrongOrderState + case peerNotReachable + case channelRejectedByDestination + case channelRejectedByLsp + case blocktankNotReady +} + + +#if compiler(>=6) +extension BtChannelOrderErrorType: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeBtChannelOrderErrorType: FfiConverterRustBuffer { + typealias SwiftType = BtChannelOrderErrorType + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> BtChannelOrderErrorType { + let variant: Int32 = try readInt(&buf) + switch variant { + + case 1: return .wrongOrderState + + case 2: return .peerNotReachable + + case 3: return .channelRejectedByDestination + + case 4: return .channelRejectedByLsp + + case 5: return .blocktankNotReady + + default: throw UniffiInternalError.unexpectedEnumCase + } + } + + public static func write(_ value: BtChannelOrderErrorType, into buf: inout [UInt8]) { + switch value { + + + case .wrongOrderState: + writeInt(&buf, Int32(1)) + + + case .peerNotReachable: + writeInt(&buf, Int32(2)) + + + case .channelRejectedByDestination: + writeInt(&buf, Int32(3)) + + + case .channelRejectedByLsp: + writeInt(&buf, Int32(4)) + + + case .blocktankNotReady: + writeInt(&buf, Int32(5)) + + } + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeBtChannelOrderErrorType_lift(_ buf: RustBuffer) throws -> BtChannelOrderErrorType { + return try FfiConverterTypeBtChannelOrderErrorType.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeBtChannelOrderErrorType_lower(_ value: BtChannelOrderErrorType) -> RustBuffer { + return FfiConverterTypeBtChannelOrderErrorType.lower(value) +} + + +extension BtChannelOrderErrorType: Equatable, Hashable {} + +extension BtChannelOrderErrorType: Codable {} + + + + + + +// Note that we don't yet support `indirect` for enums. +// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. + +public enum BtOpenChannelState { + + case opening + case `open` + case closed } #if compiler(>=6) -extension BoltzSwapEvent: Sendable {} +extension BtOpenChannelState: Sendable {} #endif #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeBoltzSwapEvent: FfiConverterRustBuffer { - typealias SwiftType = BoltzSwapEvent +public struct FfiConverterTypeBtOpenChannelState: FfiConverterRustBuffer { + typealias SwiftType = BtOpenChannelState - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> BoltzSwapEvent { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> BtOpenChannelState { let variant: Int32 = try readInt(&buf) switch variant { - case 1: return .statusUpdate(swapId: try FfiConverterString.read(from: &buf), status: try FfiConverterTypeBoltzSwapStatus.read(from: &buf) - ) - - case 2: return .claimed(swapId: try FfiConverterString.read(from: &buf), txid: try FfiConverterString.read(from: &buf) - ) + case 1: return .opening - case 3: return .refunded(swapId: try FfiConverterString.read(from: &buf), txid: try FfiConverterString.read(from: &buf) - ) + case 2: return .`open` - case 4: return .error(swapId: try FfiConverterString.read(from: &buf), message: try FfiConverterString.read(from: &buf) - ) + case 3: return .closed default: throw UniffiInternalError.unexpectedEnumCase } } - public static func write(_ value: BoltzSwapEvent, into buf: inout [UInt8]) { + public static func write(_ value: BtOpenChannelState, into buf: inout [UInt8]) { switch value { - case let .statusUpdate(swapId,status): + case .opening: writeInt(&buf, Int32(1)) - FfiConverterString.write(swapId, into: &buf) - FfiConverterTypeBoltzSwapStatus.write(status, into: &buf) - - case let .claimed(swapId,txid): + + case .`open`: writeInt(&buf, Int32(2)) - FfiConverterString.write(swapId, into: &buf) - FfiConverterString.write(txid, into: &buf) - - case let .refunded(swapId,txid): + + case .closed: writeInt(&buf, Int32(3)) - FfiConverterString.write(swapId, into: &buf) - FfiConverterString.write(txid, into: &buf) - - case let .error(swapId,message): - writeInt(&buf, Int32(4)) - FfiConverterString.write(swapId, into: &buf) - FfiConverterString.write(message, into: &buf) - } } } @@ -16352,21 +18328,21 @@ public struct FfiConverterTypeBoltzSwapEvent: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeBoltzSwapEvent_lift(_ buf: RustBuffer) throws -> BoltzSwapEvent { - return try FfiConverterTypeBoltzSwapEvent.lift(buf) +public func FfiConverterTypeBtOpenChannelState_lift(_ buf: RustBuffer) throws -> BtOpenChannelState { + return try FfiConverterTypeBtOpenChannelState.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeBoltzSwapEvent_lower(_ value: BoltzSwapEvent) -> RustBuffer { - return FfiConverterTypeBoltzSwapEvent.lower(value) +public func FfiConverterTypeBtOpenChannelState_lower(_ value: BtOpenChannelState) -> RustBuffer { + return FfiConverterTypeBtOpenChannelState.lower(value) } -extension BoltzSwapEvent: Equatable, Hashable {} +extension BtOpenChannelState: Equatable, Hashable {} -extension BoltzSwapEvent: Codable {} +extension BtOpenChannelState: Codable {} @@ -16375,202 +18351,147 @@ extension BoltzSwapEvent: Codable {} // Note that we don't yet support `indirect` for enums. // See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. -/** - * Typed view of the Boltz swap lifecycle. `Unknown` carries the raw status so - * new server-side states don't break the bindings. - * - * See . - */ -public enum BoltzSwapStatus { +public enum BtOrderState { - /** - * `swap.created` — initial state. - */ - case swapCreated - /** - * `invoice.set` — invoice attached to a submarine swap. - */ - case invoiceSet - /** - * `transaction.mempool` — a lockup transaction is in the mempool. - */ - case transactionMempool - /** - * `transaction.confirmed` — a lockup transaction confirmed. - */ - case transactionConfirmed - /** - * `invoice.pending` — Boltz is paying the submarine swap invoice. - */ - case invoicePending - /** - * `invoice.paid` — submarine swap invoice paid by Boltz. - */ - case invoicePaid - /** - * `invoice.settled` — reverse swap invoice settled (preimage revealed). - */ - case invoiceSettled - /** - * `invoice.failedToPay` — submarine swap invoice could not be paid; refund. - */ - case invoiceFailedToPay - /** - * `invoice.expired` — reverse swap invoice expired before payment. - */ - case invoiceExpired - /** - * `transaction.claim.pending` — Boltz ready for a cooperative claim. - */ - case transactionClaimPending - /** - * `transaction.claimed` — onchain funds claimed. - */ - case transactionClaimed - /** - * `transaction.refunded` — onchain funds refunded. - */ - case transactionRefunded - /** - * `transaction.lockupFailed` — wrong amount locked; can refund. - */ - case transactionLockupFailed - /** - * `transaction.failed` — Boltz failed to lock the agreed funds. - */ - case transactionFailed - /** - * `swap.expired` — swap expired without completing. - */ - case swapExpired - /** - * Any status not yet modelled. `raw` holds the verbatim Boltz status. - */ - case unknown(raw: String - ) + case created + case expired + case `open` + case closed } #if compiler(>=6) -extension BoltzSwapStatus: Sendable {} +extension BtOrderState: Sendable {} #endif #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeBoltzSwapStatus: FfiConverterRustBuffer { - typealias SwiftType = BoltzSwapStatus +public struct FfiConverterTypeBtOrderState: FfiConverterRustBuffer { + typealias SwiftType = BtOrderState - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> BoltzSwapStatus { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> BtOrderState { let variant: Int32 = try readInt(&buf) switch variant { - case 1: return .swapCreated - - case 2: return .invoiceSet - - case 3: return .transactionMempool - - case 4: return .transactionConfirmed - - case 5: return .invoicePending - - case 6: return .invoicePaid - - case 7: return .invoiceSettled - - case 8: return .invoiceFailedToPay - - case 9: return .invoiceExpired - - case 10: return .transactionClaimPending - - case 11: return .transactionClaimed - - case 12: return .transactionRefunded - - case 13: return .transactionLockupFailed + case 1: return .created - case 14: return .transactionFailed + case 2: return .expired - case 15: return .swapExpired + case 3: return .`open` - case 16: return .unknown(raw: try FfiConverterString.read(from: &buf) - ) + case 4: return .closed default: throw UniffiInternalError.unexpectedEnumCase } } - public static func write(_ value: BoltzSwapStatus, into buf: inout [UInt8]) { + public static func write(_ value: BtOrderState, into buf: inout [UInt8]) { switch value { - case .swapCreated: + case .created: writeInt(&buf, Int32(1)) - case .invoiceSet: + case .expired: writeInt(&buf, Int32(2)) - case .transactionMempool: + case .`open`: writeInt(&buf, Int32(3)) - case .transactionConfirmed: + case .closed: writeInt(&buf, Int32(4)) + } + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeBtOrderState_lift(_ buf: RustBuffer) throws -> BtOrderState { + return try FfiConverterTypeBtOrderState.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeBtOrderState_lower(_ value: BtOrderState) -> RustBuffer { + return FfiConverterTypeBtOrderState.lower(value) +} + + +extension BtOrderState: Equatable, Hashable {} + +extension BtOrderState: Codable {} + + + + + + +// Note that we don't yet support `indirect` for enums. +// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. + +public enum BtOrderState2 { + + case created + case expired + case executed + case paid +} + + +#if compiler(>=6) +extension BtOrderState2: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeBtOrderState2: FfiConverterRustBuffer { + typealias SwiftType = BtOrderState2 + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> BtOrderState2 { + let variant: Int32 = try readInt(&buf) + switch variant { - case .invoicePending: - writeInt(&buf, Int32(5)) - - - case .invoicePaid: - writeInt(&buf, Int32(6)) - - - case .invoiceSettled: - writeInt(&buf, Int32(7)) - - - case .invoiceFailedToPay: - writeInt(&buf, Int32(8)) - - - case .invoiceExpired: - writeInt(&buf, Int32(9)) - + case 1: return .created - case .transactionClaimPending: - writeInt(&buf, Int32(10)) + case 2: return .expired + case 3: return .executed - case .transactionClaimed: - writeInt(&buf, Int32(11)) + case 4: return .paid + default: throw UniffiInternalError.unexpectedEnumCase + } + } + + public static func write(_ value: BtOrderState2, into buf: inout [UInt8]) { + switch value { - case .transactionRefunded: - writeInt(&buf, Int32(12)) + case .created: + writeInt(&buf, Int32(1)) - case .transactionLockupFailed: - writeInt(&buf, Int32(13)) + case .expired: + writeInt(&buf, Int32(2)) - case .transactionFailed: - writeInt(&buf, Int32(14)) + case .executed: + writeInt(&buf, Int32(3)) - case .swapExpired: - writeInt(&buf, Int32(15)) + case .paid: + writeInt(&buf, Int32(4)) - case let .unknown(raw): - writeInt(&buf, Int32(16)) - FfiConverterString.write(raw, into: &buf) - } } } @@ -16579,21 +18500,21 @@ public struct FfiConverterTypeBoltzSwapStatus: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeBoltzSwapStatus_lift(_ buf: RustBuffer) throws -> BoltzSwapStatus { - return try FfiConverterTypeBoltzSwapStatus.lift(buf) +public func FfiConverterTypeBtOrderState2_lift(_ buf: RustBuffer) throws -> BtOrderState2 { + return try FfiConverterTypeBtOrderState2.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeBoltzSwapStatus_lower(_ value: BoltzSwapStatus) -> RustBuffer { - return FfiConverterTypeBoltzSwapStatus.lower(value) +public func FfiConverterTypeBtOrderState2_lower(_ value: BtOrderState2) -> RustBuffer { + return FfiConverterTypeBtOrderState2.lower(value) } -extension BoltzSwapStatus: Equatable, Hashable {} +extension BtOrderState2: Equatable, Hashable {} -extension BoltzSwapStatus: Codable {} +extension BtOrderState2: Codable {} @@ -16602,55 +18523,68 @@ extension BoltzSwapStatus: Codable {} // Note that we don't yet support `indirect` for enums. // See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. -/** - * The direction of a Boltz swap. - * - * - `Submarine`: onchain Bitcoin -> Lightning (the user locks onchain funds, - * Boltz pays a Lightning invoice). - * - `Reverse`: Lightning -> onchain Bitcoin (the user pays a Boltz hold - * invoice, Boltz locks onchain funds the user then claims). - */ -public enum BoltzSwapType { +public enum BtPaymentState { - case submarine - case reverse + case created + case partiallyPaid + case paid + case refunded + case refundAvailable } #if compiler(>=6) -extension BoltzSwapType: Sendable {} +extension BtPaymentState: Sendable {} #endif #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeBoltzSwapType: FfiConverterRustBuffer { - typealias SwiftType = BoltzSwapType +public struct FfiConverterTypeBtPaymentState: FfiConverterRustBuffer { + typealias SwiftType = BtPaymentState - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> BoltzSwapType { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> BtPaymentState { let variant: Int32 = try readInt(&buf) switch variant { - case 1: return .submarine + case 1: return .created - case 2: return .reverse + case 2: return .partiallyPaid + + case 3: return .paid + + case 4: return .refunded + + case 5: return .refundAvailable default: throw UniffiInternalError.unexpectedEnumCase } } - public static func write(_ value: BoltzSwapType, into buf: inout [UInt8]) { + public static func write(_ value: BtPaymentState, into buf: inout [UInt8]) { switch value { - case .submarine: + case .created: writeInt(&buf, Int32(1)) - case .reverse: + case .partiallyPaid: writeInt(&buf, Int32(2)) + + case .paid: + writeInt(&buf, Int32(3)) + + + case .refunded: + writeInt(&buf, Int32(4)) + + + case .refundAvailable: + writeInt(&buf, Int32(5)) + } } } @@ -16659,99 +18593,91 @@ public struct FfiConverterTypeBoltzSwapType: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeBoltzSwapType_lift(_ buf: RustBuffer) throws -> BoltzSwapType { - return try FfiConverterTypeBoltzSwapType.lift(buf) +public func FfiConverterTypeBtPaymentState_lift(_ buf: RustBuffer) throws -> BtPaymentState { + return try FfiConverterTypeBtPaymentState.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeBoltzSwapType_lower(_ value: BoltzSwapType) -> RustBuffer { - return FfiConverterTypeBoltzSwapType.lower(value) +public func FfiConverterTypeBtPaymentState_lower(_ value: BtPaymentState) -> RustBuffer { + return FfiConverterTypeBtPaymentState.lower(value) } -extension BoltzSwapType: Equatable, Hashable {} - -extension BoltzSwapType: Codable {} +extension BtPaymentState: Equatable, Hashable {} +extension BtPaymentState: Codable {} -public enum BroadcastError: Swift.Error { +// Note that we don't yet support `indirect` for enums. +// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. +public enum BtPaymentState2 { - - case InvalidHex(errorDetails: String - ) - case InvalidTransaction(errorDetails: String - ) - case ElectrumError(errorDetails: String - ) - case TaskError(errorDetails: String - ) + case created + case paid + case refunded + case refundAvailable + case canceled } +#if compiler(>=6) +extension BtPaymentState2: Sendable {} +#endif + #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeBroadcastError: FfiConverterRustBuffer { - typealias SwiftType = BroadcastError +public struct FfiConverterTypeBtPaymentState2: FfiConverterRustBuffer { + typealias SwiftType = BtPaymentState2 - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> BroadcastError { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> BtPaymentState2 { let variant: Int32 = try readInt(&buf) switch variant { - - + case 1: return .created - case 1: return .InvalidHex( - errorDetails: try FfiConverterString.read(from: &buf) - ) - case 2: return .InvalidTransaction( - errorDetails: try FfiConverterString.read(from: &buf) - ) - case 3: return .ElectrumError( - errorDetails: try FfiConverterString.read(from: &buf) - ) - case 4: return .TaskError( - errorDetails: try FfiConverterString.read(from: &buf) - ) - - default: throw UniffiInternalError.unexpectedEnumCase + case 2: return .paid + + case 3: return .refunded + + case 4: return .refundAvailable + + case 5: return .canceled + + default: throw UniffiInternalError.unexpectedEnumCase } } - public static func write(_ value: BroadcastError, into buf: inout [UInt8]) { + public static func write(_ value: BtPaymentState2, into buf: inout [UInt8]) { switch value { - - - - case let .InvalidHex(errorDetails): + case .created: writeInt(&buf, Int32(1)) - FfiConverterString.write(errorDetails, into: &buf) - - case let .InvalidTransaction(errorDetails): + + case .paid: writeInt(&buf, Int32(2)) - FfiConverterString.write(errorDetails, into: &buf) - - case let .ElectrumError(errorDetails): + + case .refunded: writeInt(&buf, Int32(3)) - FfiConverterString.write(errorDetails, into: &buf) - - case let .TaskError(errorDetails): + + case .refundAvailable: writeInt(&buf, Int32(4)) - FfiConverterString.write(errorDetails, into: &buf) - + + + case .canceled: + writeInt(&buf, Int32(5)) + } } } @@ -16760,30 +18686,23 @@ public struct FfiConverterTypeBroadcastError: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeBroadcastError_lift(_ buf: RustBuffer) throws -> BroadcastError { - return try FfiConverterTypeBroadcastError.lift(buf) +public func FfiConverterTypeBtPaymentState2_lift(_ buf: RustBuffer) throws -> BtPaymentState2 { + return try FfiConverterTypeBtPaymentState2.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeBroadcastError_lower(_ value: BroadcastError) -> RustBuffer { - return FfiConverterTypeBroadcastError.lower(value) +public func FfiConverterTypeBtPaymentState2_lower(_ value: BtPaymentState2) -> RustBuffer { + return FfiConverterTypeBtPaymentState2.lower(value) } -extension BroadcastError: Equatable, Hashable {} - -extension BroadcastError: Codable {} - +extension BtPaymentState2: Equatable, Hashable {} +extension BtPaymentState2: Codable {} -extension BroadcastError: Foundation.LocalizedError { - public var errorDescription: String? { - String(reflecting: self) - } -} @@ -16791,58 +18710,58 @@ extension BroadcastError: Foundation.LocalizedError { // Note that we don't yet support `indirect` for enums. // See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. -public enum BtBolt11InvoiceState { +public enum CJitStateEnum { - case pending - case holding - case paid - case canceled + case created + case completed + case expired + case failed } #if compiler(>=6) -extension BtBolt11InvoiceState: Sendable {} +extension CJitStateEnum: Sendable {} #endif #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeBtBolt11InvoiceState: FfiConverterRustBuffer { - typealias SwiftType = BtBolt11InvoiceState +public struct FfiConverterTypeCJitStateEnum: FfiConverterRustBuffer { + typealias SwiftType = CJitStateEnum - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> BtBolt11InvoiceState { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> CJitStateEnum { let variant: Int32 = try readInt(&buf) switch variant { - case 1: return .pending + case 1: return .created - case 2: return .holding + case 2: return .completed - case 3: return .paid + case 3: return .expired - case 4: return .canceled + case 4: return .failed default: throw UniffiInternalError.unexpectedEnumCase } } - public static func write(_ value: BtBolt11InvoiceState, into buf: inout [UInt8]) { + public static func write(_ value: CJitStateEnum, into buf: inout [UInt8]) { switch value { - case .pending: + case .created: writeInt(&buf, Int32(1)) - case .holding: + case .completed: writeInt(&buf, Int32(2)) - case .paid: + case .expired: writeInt(&buf, Int32(3)) - case .canceled: + case .failed: writeInt(&buf, Int32(4)) } @@ -16853,21 +18772,21 @@ public struct FfiConverterTypeBtBolt11InvoiceState: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeBtBolt11InvoiceState_lift(_ buf: RustBuffer) throws -> BtBolt11InvoiceState { - return try FfiConverterTypeBtBolt11InvoiceState.lift(buf) +public func FfiConverterTypeCJitStateEnum_lift(_ buf: RustBuffer) throws -> CJitStateEnum { + return try FfiConverterTypeCJitStateEnum.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeBtBolt11InvoiceState_lower(_ value: BtBolt11InvoiceState) -> RustBuffer { - return FfiConverterTypeBtBolt11InvoiceState.lower(value) +public func FfiConverterTypeCJitStateEnum_lower(_ value: CJitStateEnum) -> RustBuffer { + return FfiConverterTypeCJitStateEnum.lower(value) } -extension BtBolt11InvoiceState: Equatable, Hashable {} +extension CJitStateEnum: Equatable, Hashable {} -extension BtBolt11InvoiceState: Codable {} +extension CJitStateEnum: Codable {} @@ -16876,68 +18795,66 @@ extension BtBolt11InvoiceState: Codable {} // Note that we don't yet support `indirect` for enums. // See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. +/** + * Coin selection strategy for transaction composition. + */ -public enum BtChannelOrderErrorType { +public enum CoinSelection { - case wrongOrderState - case peerNotReachable - case channelRejectedByDestination - case channelRejectedByLsp - case blocktankNotReady + /** + * Branch-and-bound (default). Minimizes change by searching for exact matches. + */ + case branchAndBound + /** + * Selects largest UTXOs first. Useful for UTXO consolidation. + */ + case largestFirst + /** + * Selects oldest UTXOs first. Maximizes coin-age spending. + */ + case oldestFirst } #if compiler(>=6) -extension BtChannelOrderErrorType: Sendable {} +extension CoinSelection: Sendable {} #endif #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeBtChannelOrderErrorType: FfiConverterRustBuffer { - typealias SwiftType = BtChannelOrderErrorType +public struct FfiConverterTypeCoinSelection: FfiConverterRustBuffer { + typealias SwiftType = CoinSelection - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> BtChannelOrderErrorType { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> CoinSelection { let variant: Int32 = try readInt(&buf) switch variant { - case 1: return .wrongOrderState - - case 2: return .peerNotReachable - - case 3: return .channelRejectedByDestination + case 1: return .branchAndBound - case 4: return .channelRejectedByLsp + case 2: return .largestFirst - case 5: return .blocktankNotReady + case 3: return .oldestFirst default: throw UniffiInternalError.unexpectedEnumCase } } - public static func write(_ value: BtChannelOrderErrorType, into buf: inout [UInt8]) { + public static func write(_ value: CoinSelection, into buf: inout [UInt8]) { switch value { - case .wrongOrderState: + case .branchAndBound: writeInt(&buf, Int32(1)) - case .peerNotReachable: + case .largestFirst: writeInt(&buf, Int32(2)) - case .channelRejectedByDestination: + case .oldestFirst: writeInt(&buf, Int32(3)) - - case .channelRejectedByLsp: - writeInt(&buf, Int32(4)) - - - case .blocktankNotReady: - writeInt(&buf, Int32(5)) - } } } @@ -16946,21 +18863,21 @@ public struct FfiConverterTypeBtChannelOrderErrorType: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeBtChannelOrderErrorType_lift(_ buf: RustBuffer) throws -> BtChannelOrderErrorType { - return try FfiConverterTypeBtChannelOrderErrorType.lift(buf) +public func FfiConverterTypeCoinSelection_lift(_ buf: RustBuffer) throws -> CoinSelection { + return try FfiConverterTypeCoinSelection.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeBtChannelOrderErrorType_lower(_ value: BtChannelOrderErrorType) -> RustBuffer { - return FfiConverterTypeBtChannelOrderErrorType.lower(value) +public func FfiConverterTypeCoinSelection_lower(_ value: CoinSelection) -> RustBuffer { + return FfiConverterTypeCoinSelection.lower(value) } -extension BtChannelOrderErrorType: Equatable, Hashable {} +extension CoinSelection: Equatable, Hashable {} -extension BtChannelOrderErrorType: Codable {} +extension CoinSelection: Codable {} @@ -16969,54 +18886,76 @@ extension BtChannelOrderErrorType: Codable {} // Note that we don't yet support `indirect` for enums. // See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. +/** + * Output specification for transaction composition. + */ -public enum BtOpenChannelState { +public enum ComposeOutput { - case opening - case `open` - case closed + /** + * Payment to a specific address with a fixed amount (satoshis) + */ + case payment(address: String, amountSats: UInt64 + ) + /** + * Send all remaining funds (after fees) to an address + */ + case sendMax(address: String + ) + /** + * OP_RETURN data output (hex-encoded payload) + */ + case opReturn(dataHex: String + ) } #if compiler(>=6) -extension BtOpenChannelState: Sendable {} +extension ComposeOutput: Sendable {} #endif #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeBtOpenChannelState: FfiConverterRustBuffer { - typealias SwiftType = BtOpenChannelState +public struct FfiConverterTypeComposeOutput: FfiConverterRustBuffer { + typealias SwiftType = ComposeOutput - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> BtOpenChannelState { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ComposeOutput { let variant: Int32 = try readInt(&buf) switch variant { - case 1: return .opening + case 1: return .payment(address: try FfiConverterString.read(from: &buf), amountSats: try FfiConverterUInt64.read(from: &buf) + ) - case 2: return .`open` + case 2: return .sendMax(address: try FfiConverterString.read(from: &buf) + ) - case 3: return .closed + case 3: return .opReturn(dataHex: try FfiConverterString.read(from: &buf) + ) default: throw UniffiInternalError.unexpectedEnumCase } } - public static func write(_ value: BtOpenChannelState, into buf: inout [UInt8]) { + public static func write(_ value: ComposeOutput, into buf: inout [UInt8]) { switch value { - case .opening: + case let .payment(address,amountSats): writeInt(&buf, Int32(1)) + FfiConverterString.write(address, into: &buf) + FfiConverterUInt64.write(amountSats, into: &buf) + - - case .`open`: + case let .sendMax(address): writeInt(&buf, Int32(2)) + FfiConverterString.write(address, into: &buf) + - - case .closed: + case let .opReturn(dataHex): writeInt(&buf, Int32(3)) - + FfiConverterString.write(dataHex, into: &buf) + } } } @@ -17025,21 +18964,21 @@ public struct FfiConverterTypeBtOpenChannelState: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeBtOpenChannelState_lift(_ buf: RustBuffer) throws -> BtOpenChannelState { - return try FfiConverterTypeBtOpenChannelState.lift(buf) +public func FfiConverterTypeComposeOutput_lift(_ buf: RustBuffer) throws -> ComposeOutput { + return try FfiConverterTypeComposeOutput.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeBtOpenChannelState_lower(_ value: BtOpenChannelState) -> RustBuffer { - return FfiConverterTypeBtOpenChannelState.lower(value) +public func FfiConverterTypeComposeOutput_lower(_ value: ComposeOutput) -> RustBuffer { + return FfiConverterTypeComposeOutput.lower(value) } -extension BtOpenChannelState: Equatable, Hashable {} +extension ComposeOutput: Equatable, Hashable {} -extension BtOpenChannelState: Codable {} +extension ComposeOutput: Codable {} @@ -17048,61 +18987,79 @@ extension BtOpenChannelState: Codable {} // Note that we don't yet support `indirect` for enums. // See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. +/** + * Result of composing a transaction at a single fee rate. + */ -public enum BtOrderState { +public enum ComposeResult { - case created - case expired - case `open` - case closed + /** + * Successfully built a signable PSBT + */ + case success( + /** + * Base64-encoded PSBT ready for signing + */psbt: String, + /** + * Total fee in satoshis + */fee: UInt64, + /** + * Target fee rate in sat/vB (actual may differ slightly due to rounding) + */feeRate: Float, + /** + * Total value spent (payments + fee, excluding change). + * Uses BDK's `sent - received` semantics, which may undercount for + * self-transfers where the destination is also owned by the wallet. + */totalSpent: UInt64 + ) + /** + * Composition failed (e.g. insufficient funds) + */ + case error(error: String + ) } #if compiler(>=6) -extension BtOrderState: Sendable {} +extension ComposeResult: Sendable {} #endif #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeBtOrderState: FfiConverterRustBuffer { - typealias SwiftType = BtOrderState +public struct FfiConverterTypeComposeResult: FfiConverterRustBuffer { + typealias SwiftType = ComposeResult - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> BtOrderState { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ComposeResult { let variant: Int32 = try readInt(&buf) switch variant { - case 1: return .created - - case 2: return .expired - - case 3: return .`open` + case 1: return .success(psbt: try FfiConverterString.read(from: &buf), fee: try FfiConverterUInt64.read(from: &buf), feeRate: try FfiConverterFloat.read(from: &buf), totalSpent: try FfiConverterUInt64.read(from: &buf) + ) - case 4: return .closed + case 2: return .error(error: try FfiConverterString.read(from: &buf) + ) default: throw UniffiInternalError.unexpectedEnumCase } } - public static func write(_ value: BtOrderState, into buf: inout [UInt8]) { + public static func write(_ value: ComposeResult, into buf: inout [UInt8]) { switch value { - case .created: + case let .success(psbt,fee,feeRate,totalSpent): writeInt(&buf, Int32(1)) + FfiConverterString.write(psbt, into: &buf) + FfiConverterUInt64.write(fee, into: &buf) + FfiConverterFloat.write(feeRate, into: &buf) + FfiConverterUInt64.write(totalSpent, into: &buf) + - - case .expired: + case let .error(error): writeInt(&buf, Int32(2)) - - - case .`open`: - writeInt(&buf, Int32(3)) - - - case .closed: - writeInt(&buf, Int32(4)) - + FfiConverterString.write(error, into: &buf) + } } } @@ -17111,84 +19068,99 @@ public struct FfiConverterTypeBtOrderState: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeBtOrderState_lift(_ buf: RustBuffer) throws -> BtOrderState { - return try FfiConverterTypeBtOrderState.lift(buf) +public func FfiConverterTypeComposeResult_lift(_ buf: RustBuffer) throws -> ComposeResult { + return try FfiConverterTypeComposeResult.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeBtOrderState_lower(_ value: BtOrderState) -> RustBuffer { - return FfiConverterTypeBtOrderState.lower(value) +public func FfiConverterTypeComposeResult_lower(_ value: ComposeResult) -> RustBuffer { + return FfiConverterTypeComposeResult.lower(value) } -extension BtOrderState: Equatable, Hashable {} +extension ComposeResult: Equatable, Hashable {} -extension BtOrderState: Codable {} +extension ComposeResult: Codable {} -// Note that we don't yet support `indirect` for enums. -// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. -public enum BtOrderState2 { - - case created - case expired - case executed - case paid -} +public enum DbError: Swift.Error { + + + case DbActivityError(errorDetails: ActivityError + ) + case DbBlocktankError(errorDetails: BlocktankError + ) + case DbBoltzError(errorDetails: BoltzError + ) + case InitializationError(errorDetails: String + ) +} -#if compiler(>=6) -extension BtOrderState2: Sendable {} -#endif #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeBtOrderState2: FfiConverterRustBuffer { - typealias SwiftType = BtOrderState2 +public struct FfiConverterTypeDbError: FfiConverterRustBuffer { + typealias SwiftType = DbError - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> BtOrderState2 { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> DbError { let variant: Int32 = try readInt(&buf) switch variant { + - case 1: return .created - - case 2: return .expired - - case 3: return .executed - - case 4: return .paid + - default: throw UniffiInternalError.unexpectedEnumCase + case 1: return .DbActivityError( + errorDetails: try FfiConverterTypeActivityError.read(from: &buf) + ) + case 2: return .DbBlocktankError( + errorDetails: try FfiConverterTypeBlocktankError.read(from: &buf) + ) + case 3: return .DbBoltzError( + errorDetails: try FfiConverterTypeBoltzError.read(from: &buf) + ) + case 4: return .InitializationError( + errorDetails: try FfiConverterString.read(from: &buf) + ) + + default: throw UniffiInternalError.unexpectedEnumCase } } - public static func write(_ value: BtOrderState2, into buf: inout [UInt8]) { + public static func write(_ value: DbError, into buf: inout [UInt8]) { switch value { + + - case .created: - writeInt(&buf, Int32(1)) + case let .DbActivityError(errorDetails): + writeInt(&buf, Int32(1)) + FfiConverterTypeActivityError.write(errorDetails, into: &buf) + - case .expired: + case let .DbBlocktankError(errorDetails): writeInt(&buf, Int32(2)) + FfiConverterTypeBlocktankError.write(errorDetails, into: &buf) + - - case .executed: + case let .DbBoltzError(errorDetails): writeInt(&buf, Int32(3)) + FfiConverterTypeBoltzError.write(errorDetails, into: &buf) + - - case .paid: + case let .InitializationError(errorDetails): writeInt(&buf, Int32(4)) - + FfiConverterString.write(errorDetails, into: &buf) + } } } @@ -17197,91 +19169,150 @@ public struct FfiConverterTypeBtOrderState2: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeBtOrderState2_lift(_ buf: RustBuffer) throws -> BtOrderState2 { - return try FfiConverterTypeBtOrderState2.lift(buf) +public func FfiConverterTypeDbError_lift(_ buf: RustBuffer) throws -> DbError { + return try FfiConverterTypeDbError.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeBtOrderState2_lower(_ value: BtOrderState2) -> RustBuffer { - return FfiConverterTypeBtOrderState2.lower(value) +public func FfiConverterTypeDbError_lower(_ value: DbError) -> RustBuffer { + return FfiConverterTypeDbError.lower(value) } -extension BtOrderState2: Equatable, Hashable {} +extension DbError: Equatable, Hashable {} -extension BtOrderState2: Codable {} +extension DbError: Codable {} +extension DbError: Foundation.LocalizedError { + public var errorDescription: String? { + String(reflecting: self) + } +} -// Note that we don't yet support `indirect` for enums. -// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. -public enum BtPaymentState { + + +public enum DecodingError: Swift.Error { + - case created - case partiallyPaid - case paid - case refunded - case refundAvailable + + case InvalidFormat + case InvalidNetwork + case InvalidAmount + case InvalidLnurlPayAmount(amountSatoshis: UInt64, min: UInt64, max: UInt64 + ) + case InvalidTimestamp + case InvalidChecksum + case InvalidResponse + case UnsupportedType + case InvalidAddress + case RequestFailed + case ClientCreationFailed + case InvoiceCreationFailed(errorMessage: String + ) } -#if compiler(>=6) -extension BtPaymentState: Sendable {} -#endif - #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeBtPaymentState: FfiConverterRustBuffer { - typealias SwiftType = BtPaymentState +public struct FfiConverterTypeDecodingError: FfiConverterRustBuffer { + typealias SwiftType = DecodingError - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> BtPaymentState { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> DecodingError { let variant: Int32 = try readInt(&buf) switch variant { + - case 1: return .created - - case 2: return .partiallyPaid - - case 3: return .paid - - case 4: return .refunded - - case 5: return .refundAvailable + - default: throw UniffiInternalError.unexpectedEnumCase + case 1: return .InvalidFormat + case 2: return .InvalidNetwork + case 3: return .InvalidAmount + case 4: return .InvalidLnurlPayAmount( + amountSatoshis: try FfiConverterUInt64.read(from: &buf), + min: try FfiConverterUInt64.read(from: &buf), + max: try FfiConverterUInt64.read(from: &buf) + ) + case 5: return .InvalidTimestamp + case 6: return .InvalidChecksum + case 7: return .InvalidResponse + case 8: return .UnsupportedType + case 9: return .InvalidAddress + case 10: return .RequestFailed + case 11: return .ClientCreationFailed + case 12: return .InvoiceCreationFailed( + errorMessage: try FfiConverterString.read(from: &buf) + ) + + default: throw UniffiInternalError.unexpectedEnumCase } } - public static func write(_ value: BtPaymentState, into buf: inout [UInt8]) { + public static func write(_ value: DecodingError, into buf: inout [UInt8]) { switch value { + + + - case .created: + case .InvalidFormat: writeInt(&buf, Int32(1)) - case .partiallyPaid: + case .InvalidNetwork: writeInt(&buf, Int32(2)) - case .paid: + case .InvalidAmount: writeInt(&buf, Int32(3)) - case .refunded: + case let .InvalidLnurlPayAmount(amountSatoshis,min,max): writeInt(&buf, Int32(4)) + FfiConverterUInt64.write(amountSatoshis, into: &buf) + FfiConverterUInt64.write(min, into: &buf) + FfiConverterUInt64.write(max, into: &buf) + - - case .refundAvailable: + case .InvalidTimestamp: writeInt(&buf, Int32(5)) + + case .InvalidChecksum: + writeInt(&buf, Int32(6)) + + + case .InvalidResponse: + writeInt(&buf, Int32(7)) + + + case .UnsupportedType: + writeInt(&buf, Int32(8)) + + + case .InvalidAddress: + writeInt(&buf, Int32(9)) + + + case .RequestFailed: + writeInt(&buf, Int32(10)) + + + case .ClientCreationFailed: + writeInt(&buf, Int32(11)) + + + case let .InvoiceCreationFailed(errorMessage): + writeInt(&buf, Int32(12)) + FfiConverterString.write(errorMessage, into: &buf) + } } } @@ -17290,91 +19321,87 @@ public struct FfiConverterTypeBtPaymentState: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeBtPaymentState_lift(_ buf: RustBuffer) throws -> BtPaymentState { - return try FfiConverterTypeBtPaymentState.lift(buf) +public func FfiConverterTypeDecodingError_lift(_ buf: RustBuffer) throws -> DecodingError { + return try FfiConverterTypeDecodingError.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeBtPaymentState_lower(_ value: BtPaymentState) -> RustBuffer { - return FfiConverterTypeBtPaymentState.lower(value) +public func FfiConverterTypeDecodingError_lower(_ value: DecodingError) -> RustBuffer { + return FfiConverterTypeDecodingError.lower(value) } -extension BtPaymentState: Equatable, Hashable {} +extension DecodingError: Equatable, Hashable {} + +extension DecodingError: Codable {} -extension BtPaymentState: Codable {} +extension DecodingError: Foundation.LocalizedError { + public var errorDescription: String? { + String(reflecting: self) + } +} + // Note that we don't yet support `indirect` for enums. // See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. +/** + * How an application exchanges data with a hardware wallet. + */ -public enum BtPaymentState2 { +public enum HardwareWalletTransport { - case created - case paid - case refunded - case refundAvailable - case canceled + case usb + case bluetooth + case qr } #if compiler(>=6) -extension BtPaymentState2: Sendable {} +extension HardwareWalletTransport: Sendable {} #endif #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeBtPaymentState2: FfiConverterRustBuffer { - typealias SwiftType = BtPaymentState2 +public struct FfiConverterTypeHardwareWalletTransport: FfiConverterRustBuffer { + typealias SwiftType = HardwareWalletTransport - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> BtPaymentState2 { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> HardwareWalletTransport { let variant: Int32 = try readInt(&buf) switch variant { - case 1: return .created - - case 2: return .paid - - case 3: return .refunded + case 1: return .usb - case 4: return .refundAvailable + case 2: return .bluetooth - case 5: return .canceled + case 3: return .qr default: throw UniffiInternalError.unexpectedEnumCase } } - public static func write(_ value: BtPaymentState2, into buf: inout [UInt8]) { + public static func write(_ value: HardwareWalletTransport, into buf: inout [UInt8]) { switch value { - case .created: + case .usb: writeInt(&buf, Int32(1)) - case .paid: + case .bluetooth: writeInt(&buf, Int32(2)) - case .refunded: + case .qr: writeInt(&buf, Int32(3)) - - case .refundAvailable: - writeInt(&buf, Int32(4)) - - - case .canceled: - writeInt(&buf, Int32(5)) - } } } @@ -17383,21 +19410,21 @@ public struct FfiConverterTypeBtPaymentState2: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeBtPaymentState2_lift(_ buf: RustBuffer) throws -> BtPaymentState2 { - return try FfiConverterTypeBtPaymentState2.lift(buf) +public func FfiConverterTypeHardwareWalletTransport_lift(_ buf: RustBuffer) throws -> HardwareWalletTransport { + return try FfiConverterTypeHardwareWalletTransport.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeBtPaymentState2_lower(_ value: BtPaymentState2) -> RustBuffer { - return FfiConverterTypeBtPaymentState2.lower(value) +public func FfiConverterTypeHardwareWalletTransport_lower(_ value: HardwareWalletTransport) -> RustBuffer { + return FfiConverterTypeHardwareWalletTransport.lower(value) } -extension BtPaymentState2: Equatable, Hashable {} +extension HardwareWalletTransport: Equatable, Hashable {} -extension BtPaymentState2: Codable {} +extension HardwareWalletTransport: Codable {} @@ -17406,61 +19433,57 @@ extension BtPaymentState2: Codable {} // Note that we don't yet support `indirect` for enums. // See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. +/** + * A hardware-wallet vendor recognized by Bitkit. + */ -public enum CJitStateEnum { +public enum HardwareWalletVendor { - case created - case completed - case expired - case failed + case trezor + case foundation + case blockstream } #if compiler(>=6) -extension CJitStateEnum: Sendable {} +extension HardwareWalletVendor: Sendable {} #endif #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeCJitStateEnum: FfiConverterRustBuffer { - typealias SwiftType = CJitStateEnum +public struct FfiConverterTypeHardwareWalletVendor: FfiConverterRustBuffer { + typealias SwiftType = HardwareWalletVendor - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> CJitStateEnum { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> HardwareWalletVendor { let variant: Int32 = try readInt(&buf) switch variant { - case 1: return .created - - case 2: return .completed + case 1: return .trezor - case 3: return .expired + case 2: return .foundation - case 4: return .failed + case 3: return .blockstream default: throw UniffiInternalError.unexpectedEnumCase } } - public static func write(_ value: CJitStateEnum, into buf: inout [UInt8]) { + public static func write(_ value: HardwareWalletVendor, into buf: inout [UInt8]) { switch value { - case .created: + case .trezor: writeInt(&buf, Int32(1)) - case .completed: + case .foundation: writeInt(&buf, Int32(2)) - case .expired: + case .blockstream: writeInt(&buf, Int32(3)) - - case .failed: - writeInt(&buf, Int32(4)) - } } } @@ -17469,21 +19492,21 @@ public struct FfiConverterTypeCJitStateEnum: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeCJitStateEnum_lift(_ buf: RustBuffer) throws -> CJitStateEnum { - return try FfiConverterTypeCJitStateEnum.lift(buf) +public func FfiConverterTypeHardwareWalletVendor_lift(_ buf: RustBuffer) throws -> HardwareWalletVendor { + return try FfiConverterTypeHardwareWalletVendor.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeCJitStateEnum_lower(_ value: CJitStateEnum) -> RustBuffer { - return FfiConverterTypeCJitStateEnum.lower(value) +public func FfiConverterTypeHardwareWalletVendor_lower(_ value: HardwareWalletVendor) -> RustBuffer { + return FfiConverterTypeHardwareWalletVendor.lower(value) } -extension CJitStateEnum: Equatable, Hashable {} +extension HardwareWalletVendor: Equatable, Hashable {} -extension CJitStateEnum: Codable {} +extension HardwareWalletVendor: Codable {} @@ -17492,66 +19515,61 @@ extension CJitStateEnum: Codable {} // Note that we don't yet support `indirect` for enums. // See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. -/** - * Coin selection strategy for transaction composition. - */ -public enum CoinSelection { +public enum JadeAddressVariant { - /** - * Branch-and-bound (default). Minimizes change by searching for exact matches. - */ - case branchAndBound - /** - * Selects largest UTXOs first. Useful for UTXO consolidation. - */ - case largestFirst - /** - * Selects oldest UTXOs first. Maximizes coin-age spending. - */ - case oldestFirst + case pkh + case wpkh + case shWpkh + case tr } #if compiler(>=6) -extension CoinSelection: Sendable {} +extension JadeAddressVariant: Sendable {} #endif #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeCoinSelection: FfiConverterRustBuffer { - typealias SwiftType = CoinSelection +public struct FfiConverterTypeJadeAddressVariant: FfiConverterRustBuffer { + typealias SwiftType = JadeAddressVariant - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> CoinSelection { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> JadeAddressVariant { let variant: Int32 = try readInt(&buf) switch variant { - case 1: return .branchAndBound + case 1: return .pkh - case 2: return .largestFirst + case 2: return .wpkh - case 3: return .oldestFirst + case 3: return .shWpkh + + case 4: return .tr default: throw UniffiInternalError.unexpectedEnumCase } } - public static func write(_ value: CoinSelection, into buf: inout [UInt8]) { + public static func write(_ value: JadeAddressVariant, into buf: inout [UInt8]) { switch value { - case .branchAndBound: + case .pkh: writeInt(&buf, Int32(1)) - case .largestFirst: + case .wpkh: writeInt(&buf, Int32(2)) - case .oldestFirst: + case .shWpkh: writeInt(&buf, Int32(3)) + + case .tr: + writeInt(&buf, Int32(4)) + } } } @@ -17560,98 +19578,262 @@ public struct FfiConverterTypeCoinSelection: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeCoinSelection_lift(_ buf: RustBuffer) throws -> CoinSelection { - return try FfiConverterTypeCoinSelection.lift(buf) +public func FfiConverterTypeJadeAddressVariant_lift(_ buf: RustBuffer) throws -> JadeAddressVariant { + return try FfiConverterTypeJadeAddressVariant.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeCoinSelection_lower(_ value: CoinSelection) -> RustBuffer { - return FfiConverterTypeCoinSelection.lower(value) +public func FfiConverterTypeJadeAddressVariant_lower(_ value: JadeAddressVariant) -> RustBuffer { + return FfiConverterTypeJadeAddressVariant.lower(value) } -extension CoinSelection: Equatable, Hashable {} +extension JadeAddressVariant: Equatable, Hashable {} -extension CoinSelection: Codable {} +extension JadeAddressVariant: Codable {} -// Note that we don't yet support `indirect` for enums. -// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. -/** - * Output specification for transaction composition. - */ -public enum ComposeOutput { +public enum JadeError: Swift.Error { + - /** - * Payment to a specific address with a fixed amount (satoshis) - */ - case payment(address: String, amountSats: UInt64 + + case TransportError(errorDetails: String ) - /** - * Send all remaining funds (after fees) to an address - */ - case sendMax(address: String + case DeviceNotFound + case DeviceDisconnected + case DeviceBusy + case NotConnected + case NotInitialized + case ConnectionError(errorDetails: String ) - /** - * OP_RETURN data output (hex-encoded payload) - */ - case opReturn(dataHex: String + case ProtocolError(errorDetails: String + ) + case Timeout + case UserCancelled + case DeviceLocked + case DeviceUninitialized + case InvalidPin + case NetworkMismatch(errorDetails: String + ) + case UnsupportedFirmware(installed: String, required: String + ) + case InvalidPath(errorDetails: String + ) + case InvalidPsbt(errorDetails: String + ) + case PsbtTooLarge(size: UInt64, max: UInt64 + ) + case FingerprintMismatch(device: String, psbt: String + ) + case NothingSigned + case AddressMismatch(expected: String, returned: String + ) + case PinServerError(errorDetails: String + ) + case DeviceError(errorDetails: String + ) + case IoError(errorDetails: String ) } -#if compiler(>=6) -extension ComposeOutput: Sendable {} -#endif - #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeComposeOutput: FfiConverterRustBuffer { - typealias SwiftType = ComposeOutput +public struct FfiConverterTypeJadeError: FfiConverterRustBuffer { + typealias SwiftType = JadeError - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ComposeOutput { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> JadeError { let variant: Int32 = try readInt(&buf) switch variant { + + + + + case 1: return .TransportError( + errorDetails: try FfiConverterString.read(from: &buf) + ) + case 2: return .DeviceNotFound + case 3: return .DeviceDisconnected + case 4: return .DeviceBusy + case 5: return .NotConnected + case 6: return .NotInitialized + case 7: return .ConnectionError( + errorDetails: try FfiConverterString.read(from: &buf) + ) + case 8: return .ProtocolError( + errorDetails: try FfiConverterString.read(from: &buf) + ) + case 9: return .Timeout + case 10: return .UserCancelled + case 11: return .DeviceLocked + case 12: return .DeviceUninitialized + case 13: return .InvalidPin + case 14: return .NetworkMismatch( + errorDetails: try FfiConverterString.read(from: &buf) + ) + case 15: return .UnsupportedFirmware( + installed: try FfiConverterString.read(from: &buf), + required: try FfiConverterString.read(from: &buf) + ) + case 16: return .InvalidPath( + errorDetails: try FfiConverterString.read(from: &buf) + ) + case 17: return .InvalidPsbt( + errorDetails: try FfiConverterString.read(from: &buf) + ) + case 18: return .PsbtTooLarge( + size: try FfiConverterUInt64.read(from: &buf), + max: try FfiConverterUInt64.read(from: &buf) + ) + case 19: return .FingerprintMismatch( + device: try FfiConverterString.read(from: &buf), + psbt: try FfiConverterString.read(from: &buf) + ) + case 20: return .NothingSigned + case 21: return .AddressMismatch( + expected: try FfiConverterString.read(from: &buf), + returned: try FfiConverterString.read(from: &buf) + ) + case 22: return .PinServerError( + errorDetails: try FfiConverterString.read(from: &buf) + ) + case 23: return .DeviceError( + errorDetails: try FfiConverterString.read(from: &buf) + ) + case 24: return .IoError( + errorDetails: try FfiConverterString.read(from: &buf) + ) + + default: throw UniffiInternalError.unexpectedEnumCase + } + } + + public static func write(_ value: JadeError, into buf: inout [UInt8]) { + switch value { + + + + + + case let .TransportError(errorDetails): + writeInt(&buf, Int32(1)) + FfiConverterString.write(errorDetails, into: &buf) + + + case .DeviceNotFound: + writeInt(&buf, Int32(2)) + + + case .DeviceDisconnected: + writeInt(&buf, Int32(3)) + + + case .DeviceBusy: + writeInt(&buf, Int32(4)) + + + case .NotConnected: + writeInt(&buf, Int32(5)) + + + case .NotInitialized: + writeInt(&buf, Int32(6)) + + + case let .ConnectionError(errorDetails): + writeInt(&buf, Int32(7)) + FfiConverterString.write(errorDetails, into: &buf) + + + case let .ProtocolError(errorDetails): + writeInt(&buf, Int32(8)) + FfiConverterString.write(errorDetails, into: &buf) + + + case .Timeout: + writeInt(&buf, Int32(9)) + + + case .UserCancelled: + writeInt(&buf, Int32(10)) + + + case .DeviceLocked: + writeInt(&buf, Int32(11)) + + + case .DeviceUninitialized: + writeInt(&buf, Int32(12)) + - case 1: return .payment(address: try FfiConverterString.read(from: &buf), amountSats: try FfiConverterUInt64.read(from: &buf) - ) + case .InvalidPin: + writeInt(&buf, Int32(13)) - case 2: return .sendMax(address: try FfiConverterString.read(from: &buf) - ) - case 3: return .opReturn(dataHex: try FfiConverterString.read(from: &buf) - ) + case let .NetworkMismatch(errorDetails): + writeInt(&buf, Int32(14)) + FfiConverterString.write(errorDetails, into: &buf) + - default: throw UniffiInternalError.unexpectedEnumCase - } - } - - public static func write(_ value: ComposeOutput, into buf: inout [UInt8]) { - switch value { + case let .UnsupportedFirmware(installed,required): + writeInt(&buf, Int32(15)) + FfiConverterString.write(installed, into: &buf) + FfiConverterString.write(required, into: &buf) + + case let .InvalidPath(errorDetails): + writeInt(&buf, Int32(16)) + FfiConverterString.write(errorDetails, into: &buf) + - case let .payment(address,amountSats): - writeInt(&buf, Int32(1)) - FfiConverterString.write(address, into: &buf) - FfiConverterUInt64.write(amountSats, into: &buf) + case let .InvalidPsbt(errorDetails): + writeInt(&buf, Int32(17)) + FfiConverterString.write(errorDetails, into: &buf) - case let .sendMax(address): - writeInt(&buf, Int32(2)) - FfiConverterString.write(address, into: &buf) + case let .PsbtTooLarge(size,max): + writeInt(&buf, Int32(18)) + FfiConverterUInt64.write(size, into: &buf) + FfiConverterUInt64.write(max, into: &buf) - case let .opReturn(dataHex): - writeInt(&buf, Int32(3)) - FfiConverterString.write(dataHex, into: &buf) + case let .FingerprintMismatch(device,psbt): + writeInt(&buf, Int32(19)) + FfiConverterString.write(device, into: &buf) + FfiConverterString.write(psbt, into: &buf) + + + case .NothingSigned: + writeInt(&buf, Int32(20)) + + + case let .AddressMismatch(expected,returned): + writeInt(&buf, Int32(21)) + FfiConverterString.write(expected, into: &buf) + FfiConverterString.write(returned, into: &buf) + + + case let .PinServerError(errorDetails): + writeInt(&buf, Int32(22)) + FfiConverterString.write(errorDetails, into: &buf) + + + case let .DeviceError(errorDetails): + writeInt(&buf, Int32(23)) + FfiConverterString.write(errorDetails, into: &buf) + + + case let .IoError(errorDetails): + writeInt(&buf, Int32(24)) + FfiConverterString.write(errorDetails, into: &buf) } } @@ -17661,102 +19843,84 @@ public struct FfiConverterTypeComposeOutput: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeComposeOutput_lift(_ buf: RustBuffer) throws -> ComposeOutput { - return try FfiConverterTypeComposeOutput.lift(buf) +public func FfiConverterTypeJadeError_lift(_ buf: RustBuffer) throws -> JadeError { + return try FfiConverterTypeJadeError.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeComposeOutput_lower(_ value: ComposeOutput) -> RustBuffer { - return FfiConverterTypeComposeOutput.lower(value) +public func FfiConverterTypeJadeError_lower(_ value: JadeError) -> RustBuffer { + return FfiConverterTypeJadeError.lower(value) } -extension ComposeOutput: Equatable, Hashable {} +extension JadeError: Equatable, Hashable {} + +extension JadeError: Codable {} -extension ComposeOutput: Codable {} +extension JadeError: Foundation.LocalizedError { + public var errorDescription: String? { + String(reflecting: self) + } +} + // Note that we don't yet support `indirect` for enums. // See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. -/** - * Result of composing a transaction at a single fee rate. - */ -public enum ComposeResult { +public enum JadeNetwork { - /** - * Successfully built a signable PSBT - */ - case success( - /** - * Base64-encoded PSBT ready for signing - */psbt: String, - /** - * Total fee in satoshis - */fee: UInt64, - /** - * Target fee rate in sat/vB (actual may differ slightly due to rounding) - */feeRate: Float, - /** - * Total value spent (payments + fee, excluding change). - * Uses BDK's `sent - received` semantics, which may undercount for - * self-transfers where the destination is also owned by the wallet. - */totalSpent: UInt64 - ) - /** - * Composition failed (e.g. insufficient funds) - */ - case error(error: String - ) + case mainnet + case testnet + case regtest } #if compiler(>=6) -extension ComposeResult: Sendable {} +extension JadeNetwork: Sendable {} #endif #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeComposeResult: FfiConverterRustBuffer { - typealias SwiftType = ComposeResult +public struct FfiConverterTypeJadeNetwork: FfiConverterRustBuffer { + typealias SwiftType = JadeNetwork - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ComposeResult { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> JadeNetwork { let variant: Int32 = try readInt(&buf) switch variant { - case 1: return .success(psbt: try FfiConverterString.read(from: &buf), fee: try FfiConverterUInt64.read(from: &buf), feeRate: try FfiConverterFloat.read(from: &buf), totalSpent: try FfiConverterUInt64.read(from: &buf) - ) + case 1: return .mainnet - case 2: return .error(error: try FfiConverterString.read(from: &buf) - ) + case 2: return .testnet + + case 3: return .regtest default: throw UniffiInternalError.unexpectedEnumCase } } - public static func write(_ value: ComposeResult, into buf: inout [UInt8]) { + public static func write(_ value: JadeNetwork, into buf: inout [UInt8]) { switch value { - case let .success(psbt,fee,feeRate,totalSpent): + case .mainnet: writeInt(&buf, Int32(1)) - FfiConverterString.write(psbt, into: &buf) - FfiConverterUInt64.write(fee, into: &buf) - FfiConverterFloat.write(feeRate, into: &buf) - FfiConverterUInt64.write(totalSpent, into: &buf) - - case let .error(error): + + case .testnet: writeInt(&buf, Int32(2)) - FfiConverterString.write(error, into: &buf) - + + + case .regtest: + writeInt(&buf, Int32(3)) + } } } @@ -17765,99 +19929,77 @@ public struct FfiConverterTypeComposeResult: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeComposeResult_lift(_ buf: RustBuffer) throws -> ComposeResult { - return try FfiConverterTypeComposeResult.lift(buf) +public func FfiConverterTypeJadeNetwork_lift(_ buf: RustBuffer) throws -> JadeNetwork { + return try FfiConverterTypeJadeNetwork.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeComposeResult_lower(_ value: ComposeResult) -> RustBuffer { - return FfiConverterTypeComposeResult.lower(value) +public func FfiConverterTypeJadeNetwork_lower(_ value: JadeNetwork) -> RustBuffer { + return FfiConverterTypeJadeNetwork.lower(value) } -extension ComposeResult: Equatable, Hashable {} - -extension ComposeResult: Codable {} +extension JadeNetwork: Equatable, Hashable {} +extension JadeNetwork: Codable {} -public enum DbError: Swift.Error { +// Note that we don't yet support `indirect` for enums. +// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. +public enum JadePingStatus { - - case DbActivityError(errorDetails: ActivityError - ) - case DbBlocktankError(errorDetails: BlocktankError - ) - case DbBoltzError(errorDetails: BoltzError - ) - case InitializationError(errorDetails: String - ) + case idle + case busy + case awaitingUserInput } +#if compiler(>=6) +extension JadePingStatus: Sendable {} +#endif + #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeDbError: FfiConverterRustBuffer { - typealias SwiftType = DbError +public struct FfiConverterTypeJadePingStatus: FfiConverterRustBuffer { + typealias SwiftType = JadePingStatus - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> DbError { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> JadePingStatus { let variant: Int32 = try readInt(&buf) switch variant { - - + case 1: return .idle - case 1: return .DbActivityError( - errorDetails: try FfiConverterTypeActivityError.read(from: &buf) - ) - case 2: return .DbBlocktankError( - errorDetails: try FfiConverterTypeBlocktankError.read(from: &buf) - ) - case 3: return .DbBoltzError( - errorDetails: try FfiConverterTypeBoltzError.read(from: &buf) - ) - case 4: return .InitializationError( - errorDetails: try FfiConverterString.read(from: &buf) - ) - - default: throw UniffiInternalError.unexpectedEnumCase + case 2: return .busy + + case 3: return .awaitingUserInput + + default: throw UniffiInternalError.unexpectedEnumCase } } - public static func write(_ value: DbError, into buf: inout [UInt8]) { + public static func write(_ value: JadePingStatus, into buf: inout [UInt8]) { switch value { - - - - case let .DbActivityError(errorDetails): + case .idle: writeInt(&buf, Int32(1)) - FfiConverterTypeActivityError.write(errorDetails, into: &buf) - - case let .DbBlocktankError(errorDetails): + + case .busy: writeInt(&buf, Int32(2)) - FfiConverterTypeBlocktankError.write(errorDetails, into: &buf) - - case let .DbBoltzError(errorDetails): + + case .awaitingUserInput: writeInt(&buf, Int32(3)) - FfiConverterTypeBoltzError.write(errorDetails, into: &buf) - - case let .InitializationError(errorDetails): - writeInt(&buf, Int32(4)) - FfiConverterString.write(errorDetails, into: &buf) - } } } @@ -17866,150 +20008,98 @@ public struct FfiConverterTypeDbError: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeDbError_lift(_ buf: RustBuffer) throws -> DbError { - return try FfiConverterTypeDbError.lift(buf) +public func FfiConverterTypeJadePingStatus_lift(_ buf: RustBuffer) throws -> JadePingStatus { + return try FfiConverterTypeJadePingStatus.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeDbError_lower(_ value: DbError) -> RustBuffer { - return FfiConverterTypeDbError.lower(value) +public func FfiConverterTypeJadePingStatus_lower(_ value: JadePingStatus) -> RustBuffer { + return FfiConverterTypeJadePingStatus.lower(value) } -extension DbError: Equatable, Hashable {} - -extension DbError: Codable {} - - +extension JadePingStatus: Equatable, Hashable {} +extension JadePingStatus: Codable {} -extension DbError: Foundation.LocalizedError { - public var errorDescription: String? { - String(reflecting: self) - } -} -public enum DecodingError: Swift.Error { +// Note that we don't yet support `indirect` for enums. +// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. +public enum JadeState { - - case InvalidFormat - case InvalidNetwork - case InvalidAmount - case InvalidLnurlPayAmount(amountSatoshis: UInt64, min: UInt64, max: UInt64 - ) - case InvalidTimestamp - case InvalidChecksum - case InvalidResponse - case UnsupportedType - case InvalidAddress - case RequestFailed - case ClientCreationFailed - case InvoiceCreationFailed(errorMessage: String - ) + case uninit + case unsaved + case locked + case ready + case temp + case unknown } +#if compiler(>=6) +extension JadeState: Sendable {} +#endif + #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeDecodingError: FfiConverterRustBuffer { - typealias SwiftType = DecodingError +public struct FfiConverterTypeJadeState: FfiConverterRustBuffer { + typealias SwiftType = JadeState - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> DecodingError { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> JadeState { let variant: Int32 = try readInt(&buf) switch variant { - - - - - case 1: return .InvalidFormat - case 2: return .InvalidNetwork - case 3: return .InvalidAmount - case 4: return .InvalidLnurlPayAmount( - amountSatoshis: try FfiConverterUInt64.read(from: &buf), - min: try FfiConverterUInt64.read(from: &buf), - max: try FfiConverterUInt64.read(from: &buf) - ) - case 5: return .InvalidTimestamp - case 6: return .InvalidChecksum - case 7: return .InvalidResponse - case 8: return .UnsupportedType - case 9: return .InvalidAddress - case 10: return .RequestFailed - case 11: return .ClientCreationFailed - case 12: return .InvoiceCreationFailed( - errorMessage: try FfiConverterString.read(from: &buf) - ) - - default: throw UniffiInternalError.unexpectedEnumCase + + case 1: return .uninit + + case 2: return .unsaved + + case 3: return .locked + + case 4: return .ready + + case 5: return .temp + + case 6: return .unknown + + default: throw UniffiInternalError.unexpectedEnumCase } } - public static func write(_ value: DecodingError, into buf: inout [UInt8]) { + public static func write(_ value: JadeState, into buf: inout [UInt8]) { switch value { - - - - case .InvalidFormat: + case .uninit: writeInt(&buf, Int32(1)) - case .InvalidNetwork: + case .unsaved: writeInt(&buf, Int32(2)) - case .InvalidAmount: + case .locked: writeInt(&buf, Int32(3)) - case let .InvalidLnurlPayAmount(amountSatoshis,min,max): + case .ready: writeInt(&buf, Int32(4)) - FfiConverterUInt64.write(amountSatoshis, into: &buf) - FfiConverterUInt64.write(min, into: &buf) - FfiConverterUInt64.write(max, into: &buf) - - case .InvalidTimestamp: + + case .temp: writeInt(&buf, Int32(5)) - case .InvalidChecksum: + case .unknown: writeInt(&buf, Int32(6)) - - case .InvalidResponse: - writeInt(&buf, Int32(7)) - - - case .UnsupportedType: - writeInt(&buf, Int32(8)) - - - case .InvalidAddress: - writeInt(&buf, Int32(9)) - - - case .RequestFailed: - writeInt(&buf, Int32(10)) - - - case .ClientCreationFailed: - writeInt(&buf, Int32(11)) - - - case let .InvoiceCreationFailed(errorMessage): - writeInt(&buf, Int32(12)) - FfiConverterString.write(errorMessage, into: &buf) - } } } @@ -18018,87 +20108,91 @@ public struct FfiConverterTypeDecodingError: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeDecodingError_lift(_ buf: RustBuffer) throws -> DecodingError { - return try FfiConverterTypeDecodingError.lift(buf) +public func FfiConverterTypeJadeState_lift(_ buf: RustBuffer) throws -> JadeState { + return try FfiConverterTypeJadeState.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeDecodingError_lower(_ value: DecodingError) -> RustBuffer { - return FfiConverterTypeDecodingError.lower(value) +public func FfiConverterTypeJadeState_lower(_ value: JadeState) -> RustBuffer { + return FfiConverterTypeJadeState.lower(value) } -extension DecodingError: Equatable, Hashable {} - -extension DecodingError: Codable {} - +extension JadeState: Equatable, Hashable {} +extension JadeState: Codable {} -extension DecodingError: Foundation.LocalizedError { - public var errorDescription: String? { - String(reflecting: self) - } -} // Note that we don't yet support `indirect` for enums. // See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. -/** - * How an application exchanges data with a hardware wallet. - */ -public enum HardwareWalletTransport { +public enum JadeTransportErrorCode { - case usb - case bluetooth - case qr + case deviceBusy + case notConnected + case disconnected + case timeout + case permissionDenied } #if compiler(>=6) -extension HardwareWalletTransport: Sendable {} +extension JadeTransportErrorCode: Sendable {} #endif #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeHardwareWalletTransport: FfiConverterRustBuffer { - typealias SwiftType = HardwareWalletTransport +public struct FfiConverterTypeJadeTransportErrorCode: FfiConverterRustBuffer { + typealias SwiftType = JadeTransportErrorCode - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> HardwareWalletTransport { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> JadeTransportErrorCode { let variant: Int32 = try readInt(&buf) switch variant { - case 1: return .usb + case 1: return .deviceBusy - case 2: return .bluetooth + case 2: return .notConnected - case 3: return .qr + case 3: return .disconnected + + case 4: return .timeout + + case 5: return .permissionDenied default: throw UniffiInternalError.unexpectedEnumCase } } - public static func write(_ value: HardwareWalletTransport, into buf: inout [UInt8]) { + public static func write(_ value: JadeTransportErrorCode, into buf: inout [UInt8]) { switch value { - case .usb: + case .deviceBusy: writeInt(&buf, Int32(1)) - case .bluetooth: + case .notConnected: writeInt(&buf, Int32(2)) - case .qr: + case .disconnected: writeInt(&buf, Int32(3)) + + case .timeout: + writeInt(&buf, Int32(4)) + + + case .permissionDenied: + writeInt(&buf, Int32(5)) + } } } @@ -18107,21 +20201,21 @@ public struct FfiConverterTypeHardwareWalletTransport: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeHardwareWalletTransport_lift(_ buf: RustBuffer) throws -> HardwareWalletTransport { - return try FfiConverterTypeHardwareWalletTransport.lift(buf) +public func FfiConverterTypeJadeTransportErrorCode_lift(_ buf: RustBuffer) throws -> JadeTransportErrorCode { + return try FfiConverterTypeJadeTransportErrorCode.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeHardwareWalletTransport_lower(_ value: HardwareWalletTransport) -> RustBuffer { - return FfiConverterTypeHardwareWalletTransport.lower(value) +public func FfiConverterTypeJadeTransportErrorCode_lower(_ value: JadeTransportErrorCode) -> RustBuffer { + return FfiConverterTypeJadeTransportErrorCode.lower(value) } -extension HardwareWalletTransport: Equatable, Hashable {} +extension JadeTransportErrorCode: Equatable, Hashable {} -extension HardwareWalletTransport: Codable {} +extension JadeTransportErrorCode: Codable {} @@ -18130,48 +20224,45 @@ extension HardwareWalletTransport: Codable {} // Note that we don't yet support `indirect` for enums. // See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. -/** - * A hardware-wallet vendor recognized by Bitkit. - */ -public enum HardwareWalletVendor { +public enum JadeTransportKind { - case trezor - case foundation + case bluetooth + case serial } #if compiler(>=6) -extension HardwareWalletVendor: Sendable {} +extension JadeTransportKind: Sendable {} #endif #if swift(>=5.8) @_documentation(visibility: private) #endif -public struct FfiConverterTypeHardwareWalletVendor: FfiConverterRustBuffer { - typealias SwiftType = HardwareWalletVendor +public struct FfiConverterTypeJadeTransportKind: FfiConverterRustBuffer { + typealias SwiftType = JadeTransportKind - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> HardwareWalletVendor { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> JadeTransportKind { let variant: Int32 = try readInt(&buf) switch variant { - case 1: return .trezor + case 1: return .bluetooth - case 2: return .foundation + case 2: return .serial default: throw UniffiInternalError.unexpectedEnumCase } } - public static func write(_ value: HardwareWalletVendor, into buf: inout [UInt8]) { + public static func write(_ value: JadeTransportKind, into buf: inout [UInt8]) { switch value { - case .trezor: + case .bluetooth: writeInt(&buf, Int32(1)) - case .foundation: + case .serial: writeInt(&buf, Int32(2)) } @@ -18182,21 +20273,21 @@ public struct FfiConverterTypeHardwareWalletVendor: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeHardwareWalletVendor_lift(_ buf: RustBuffer) throws -> HardwareWalletVendor { - return try FfiConverterTypeHardwareWalletVendor.lift(buf) +public func FfiConverterTypeJadeTransportKind_lift(_ buf: RustBuffer) throws -> JadeTransportKind { + return try FfiConverterTypeJadeTransportKind.lift(buf) } #if swift(>=5.8) @_documentation(visibility: private) #endif -public func FfiConverterTypeHardwareWalletVendor_lower(_ value: HardwareWalletVendor) -> RustBuffer { - return FfiConverterTypeHardwareWalletVendor.lower(value) +public func FfiConverterTypeJadeTransportKind_lower(_ value: JadeTransportKind) -> RustBuffer { + return FfiConverterTypeJadeTransportKind.lower(value) } -extension HardwareWalletVendor: Equatable, Hashable {} +extension JadeTransportKind: Equatable, Hashable {} -extension HardwareWalletVendor: Codable {} +extension JadeTransportKind: Codable {} @@ -21520,6 +23611,54 @@ fileprivate struct FfiConverterOptionTypeILspNode: FfiConverterRustBuffer { } } +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +fileprivate struct FfiConverterOptionTypeJadeDeviceInfo: FfiConverterRustBuffer { + typealias SwiftType = JadeDeviceInfo? + + public static func write(_ value: SwiftType, into buf: inout [UInt8]) { + guard let value = value else { + writeInt(&buf, Int8(0)) + return + } + writeInt(&buf, Int8(1)) + FfiConverterTypeJadeDeviceInfo.write(value, into: &buf) + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType { + switch try readInt(&buf) as Int8 { + case 0: return nil + case 1: return try FfiConverterTypeJadeDeviceInfo.read(from: &buf) + default: throw UniffiInternalError.unexpectedOptionalTag + } + } +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +fileprivate struct FfiConverterOptionTypeJadeVersionInfo: FfiConverterRustBuffer { + typealias SwiftType = JadeVersionInfo? + + public static func write(_ value: SwiftType, into buf: inout [UInt8]) { + guard let value = value else { + writeInt(&buf, Int8(0)) + return + } + writeInt(&buf, Int8(1)) + FfiConverterTypeJadeVersionInfo.write(value, into: &buf) + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType { + switch try readInt(&buf) as Int8 { + case 0: return nil + case 1: return try FfiConverterTypeJadeVersionInfo.read(from: &buf) + default: throw UniffiInternalError.unexpectedOptionalTag + } + } +} + #if swift(>=5.8) @_documentation(visibility: private) #endif @@ -21832,6 +23971,30 @@ fileprivate struct FfiConverterOptionTypeCoinSelection: FfiConverterRustBuffer { } } +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +fileprivate struct FfiConverterOptionTypeJadeTransportErrorCode: FfiConverterRustBuffer { + typealias SwiftType = JadeTransportErrorCode? + + public static func write(_ value: SwiftType, into buf: inout [UInt8]) { + guard let value = value else { + writeInt(&buf, Int8(0)) + return + } + writeInt(&buf, Int8(1)) + FfiConverterTypeJadeTransportErrorCode.write(value, into: &buf) + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType { + switch try readInt(&buf) as Int8 { + case 0: return nil + case 1: return try FfiConverterTypeJadeTransportErrorCode.read(from: &buf) + default: throw UniffiInternalError.unexpectedOptionalTag + } + } +} + #if swift(>=5.8) @_documentation(visibility: private) #endif @@ -22380,16 +24543,91 @@ fileprivate struct FfiConverterSequenceTypeIBtOrder: FfiConverterRustBuffer { let len = Int32(value.count) writeInt(&buf, len) for item in value { - FfiConverterTypeIBtOrder.write(item, into: &buf) + FfiConverterTypeIBtOrder.write(item, into: &buf) + } + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [IBtOrder] { + let len: Int32 = try readInt(&buf) + var seq = [IBtOrder]() + seq.reserveCapacity(Int(len)) + for _ in 0 ..< len { + seq.append(try FfiConverterTypeIBtOrder.read(from: &buf)) + } + return seq + } +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +fileprivate struct FfiConverterSequenceTypeICJitEntry: FfiConverterRustBuffer { + typealias SwiftType = [IcJitEntry] + + public static func write(_ value: [IcJitEntry], into buf: inout [UInt8]) { + let len = Int32(value.count) + writeInt(&buf, len) + for item in value { + FfiConverterTypeICJitEntry.write(item, into: &buf) + } + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [IcJitEntry] { + let len: Int32 = try readInt(&buf) + var seq = [IcJitEntry]() + seq.reserveCapacity(Int(len)) + for _ in 0 ..< len { + seq.append(try FfiConverterTypeICJitEntry.read(from: &buf)) + } + return seq + } +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +fileprivate struct FfiConverterSequenceTypeILspNode: FfiConverterRustBuffer { + typealias SwiftType = [ILspNode] + + public static func write(_ value: [ILspNode], into buf: inout [UInt8]) { + let len = Int32(value.count) + writeInt(&buf, len) + for item in value { + FfiConverterTypeILspNode.write(item, into: &buf) + } + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [ILspNode] { + let len: Int32 = try readInt(&buf) + var seq = [ILspNode]() + seq.reserveCapacity(Int(len)) + for _ in 0 ..< len { + seq.append(try FfiConverterTypeILspNode.read(from: &buf)) + } + return seq + } +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +fileprivate struct FfiConverterSequenceTypeIManualRefund: FfiConverterRustBuffer { + typealias SwiftType = [IManualRefund] + + public static func write(_ value: [IManualRefund], into buf: inout [UInt8]) { + let len = Int32(value.count) + writeInt(&buf, len) + for item in value { + FfiConverterTypeIManualRefund.write(item, into: &buf) } } - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [IBtOrder] { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [IManualRefund] { let len: Int32 = try readInt(&buf) - var seq = [IBtOrder]() + var seq = [IManualRefund]() seq.reserveCapacity(Int(len)) for _ in 0 ..< len { - seq.append(try FfiConverterTypeIBtOrder.read(from: &buf)) + seq.append(try FfiConverterTypeIManualRefund.read(from: &buf)) } return seq } @@ -22398,23 +24636,23 @@ fileprivate struct FfiConverterSequenceTypeIBtOrder: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -fileprivate struct FfiConverterSequenceTypeICJitEntry: FfiConverterRustBuffer { - typealias SwiftType = [IcJitEntry] +fileprivate struct FfiConverterSequenceTypeJadeAccount: FfiConverterRustBuffer { + typealias SwiftType = [JadeAccount] - public static func write(_ value: [IcJitEntry], into buf: inout [UInt8]) { + public static func write(_ value: [JadeAccount], into buf: inout [UInt8]) { let len = Int32(value.count) writeInt(&buf, len) for item in value { - FfiConverterTypeICJitEntry.write(item, into: &buf) + FfiConverterTypeJadeAccount.write(item, into: &buf) } } - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [IcJitEntry] { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [JadeAccount] { let len: Int32 = try readInt(&buf) - var seq = [IcJitEntry]() + var seq = [JadeAccount]() seq.reserveCapacity(Int(len)) for _ in 0 ..< len { - seq.append(try FfiConverterTypeICJitEntry.read(from: &buf)) + seq.append(try FfiConverterTypeJadeAccount.read(from: &buf)) } return seq } @@ -22423,23 +24661,23 @@ fileprivate struct FfiConverterSequenceTypeICJitEntry: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -fileprivate struct FfiConverterSequenceTypeILspNode: FfiConverterRustBuffer { - typealias SwiftType = [ILspNode] +fileprivate struct FfiConverterSequenceTypeJadeDeviceInfo: FfiConverterRustBuffer { + typealias SwiftType = [JadeDeviceInfo] - public static func write(_ value: [ILspNode], into buf: inout [UInt8]) { + public static func write(_ value: [JadeDeviceInfo], into buf: inout [UInt8]) { let len = Int32(value.count) writeInt(&buf, len) for item in value { - FfiConverterTypeILspNode.write(item, into: &buf) + FfiConverterTypeJadeDeviceInfo.write(item, into: &buf) } } - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [ILspNode] { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [JadeDeviceInfo] { let len: Int32 = try readInt(&buf) - var seq = [ILspNode]() + var seq = [JadeDeviceInfo]() seq.reserveCapacity(Int(len)) for _ in 0 ..< len { - seq.append(try FfiConverterTypeILspNode.read(from: &buf)) + seq.append(try FfiConverterTypeJadeDeviceInfo.read(from: &buf)) } return seq } @@ -22448,23 +24686,23 @@ fileprivate struct FfiConverterSequenceTypeILspNode: FfiConverterRustBuffer { #if swift(>=5.8) @_documentation(visibility: private) #endif -fileprivate struct FfiConverterSequenceTypeIManualRefund: FfiConverterRustBuffer { - typealias SwiftType = [IManualRefund] +fileprivate struct FfiConverterSequenceTypeJadeNativeDevice: FfiConverterRustBuffer { + typealias SwiftType = [JadeNativeDevice] - public static func write(_ value: [IManualRefund], into buf: inout [UInt8]) { + public static func write(_ value: [JadeNativeDevice], into buf: inout [UInt8]) { let len = Int32(value.count) writeInt(&buf, len) for item in value { - FfiConverterTypeIManualRefund.write(item, into: &buf) + FfiConverterTypeJadeNativeDevice.write(item, into: &buf) } } - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [IManualRefund] { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [JadeNativeDevice] { let len: Int32 = try readInt(&buf) - var seq = [IManualRefund]() + var seq = [JadeNativeDevice]() seq.reserveCapacity(Int(len)) for _ in 0 ..< len { - seq.append(try FfiConverterTypeIManualRefund.read(from: &buf)) + seq.append(try FfiConverterTypeJadeNativeDevice.read(from: &buf)) } return seq } @@ -22920,6 +25158,31 @@ fileprivate struct FfiConverterSequenceTypeTxOutput: FfiConverterRustBuffer { } } +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +fileprivate struct FfiConverterSequenceTypeAccountType: FfiConverterRustBuffer { + typealias SwiftType = [AccountType] + + public static func write(_ value: [AccountType], into buf: inout [UInt8]) { + let len = Int32(value.count) + writeInt(&buf, len) + for item in value { + FfiConverterTypeAccountType.write(item, into: &buf) + } + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [AccountType] { + let len: Int32 = try readInt(&buf) + var seq = [AccountType]() + seq.reserveCapacity(Int(len)) + for _ in 0 ..< len { + seq.append(try FfiConverterTypeAccountType.read(from: &buf)) + } + return seq + } +} + #if swift(>=5.8) @_documentation(visibility: private) #endif @@ -23160,975 +25423,1349 @@ public func addTags(walletId: String, activityId: String, tags: [String])throws ) } } -public func approvePubkyAuth(authUrl: String, secretKeyHex: String)async throws { +public func approvePubkyAuth(authUrl: String, secretKeyHex: String)async throws { + return + try await uniffiRustCallAsync( + rustFutureFunc: { + uniffi_bitkitcore_fn_func_approve_pubky_auth(FfiConverterString.lower(authUrl),FfiConverterString.lower(secretKeyHex) + ) + }, + pollFunc: ffi_bitkitcore_rust_future_poll_void, + completeFunc: ffi_bitkitcore_rust_future_complete_void, + freeFunc: ffi_bitkitcore_rust_future_free_void, + liftFunc: { $0 }, + errorHandler: FfiConverterTypePubkyError_lift + ) +} +public func blocktankRemoveAllCjitEntries()async throws { + return + try await uniffiRustCallAsync( + rustFutureFunc: { + uniffi_bitkitcore_fn_func_blocktank_remove_all_cjit_entries( + ) + }, + pollFunc: ffi_bitkitcore_rust_future_poll_void, + completeFunc: ffi_bitkitcore_rust_future_complete_void, + freeFunc: ffi_bitkitcore_rust_future_free_void, + liftFunc: { $0 }, + errorHandler: FfiConverterTypeBlocktankError_lift + ) +} +public func blocktankRemoveAllOrders()async throws { + return + try await uniffiRustCallAsync( + rustFutureFunc: { + uniffi_bitkitcore_fn_func_blocktank_remove_all_orders( + ) + }, + pollFunc: ffi_bitkitcore_rust_future_poll_void, + completeFunc: ffi_bitkitcore_rust_future_complete_void, + freeFunc: ffi_bitkitcore_rust_future_free_void, + liftFunc: { $0 }, + errorHandler: FfiConverterTypeBlocktankError_lift + ) +} +public func blocktankWipeAll()async throws { + return + try await uniffiRustCallAsync( + rustFutureFunc: { + uniffi_bitkitcore_fn_func_blocktank_wipe_all( + ) + }, + pollFunc: ffi_bitkitcore_rust_future_poll_void, + completeFunc: ffi_bitkitcore_rust_future_complete_void, + freeFunc: ffi_bitkitcore_rust_future_free_void, + liftFunc: { $0 }, + errorHandler: FfiConverterTypeBlocktankError_lift + ) +} +/** + * Claim a reverse swap's onchain funds to its claim address, returning the + * broadcast claim transaction id. Normally happens automatically via the + * updates stream; exposed for manual recovery. The claim key is re-derived from + * `mnemonic`. Claims are serialized per swap, so calling this while the updates + * stream is auto-claiming the same swap waits for that claim and returns its + * txid rather than broadcasting a second transaction. + */ +public func boltzClaimReverseSwap(swapId: String, mnemonic: String, bip39Passphrase: String?, feeRateSatPerVb: Double?)async throws -> String { + return + try await uniffiRustCallAsync( + rustFutureFunc: { + uniffi_bitkitcore_fn_func_boltz_claim_reverse_swap(FfiConverterString.lower(swapId),FfiConverterString.lower(mnemonic),FfiConverterOptionString.lower(bip39Passphrase),FfiConverterOptionDouble.lower(feeRateSatPerVb) + ) + }, + pollFunc: ffi_bitkitcore_rust_future_poll_rust_buffer, + completeFunc: ffi_bitkitcore_rust_future_complete_rust_buffer, + freeFunc: ffi_bitkitcore_rust_future_free_rust_buffer, + liftFunc: FfiConverterString.lift, + errorHandler: FfiConverterTypeBoltzError_lift + ) +} +/** + * Create a reverse swap (Lightning -> onchain). + * + * The caller pays the returned hold invoice from its Lightning node; + * `claim_address` is the onchain address the received funds are claimed to. + * The claim key and preimage are derived deterministically from `mnemonic` + * (only the derivation index is persisted, never the secrets) so the claim can + * be made automatically once Boltz locks the funds. `bip39_passphrase` must + * match the wallet's, or claims will derive the wrong key. + */ +public func boltzCreateReverseSwap(network: BoltzNetwork, electrumUrl: String, amountSat: UInt64, claimAddress: String, mnemonic: String, bip39Passphrase: String?)async throws -> ReverseSwapResponse { + return + try await uniffiRustCallAsync( + rustFutureFunc: { + uniffi_bitkitcore_fn_func_boltz_create_reverse_swap(FfiConverterTypeBoltzNetwork_lower(network),FfiConverterString.lower(electrumUrl),FfiConverterUInt64.lower(amountSat),FfiConverterString.lower(claimAddress),FfiConverterString.lower(mnemonic),FfiConverterOptionString.lower(bip39Passphrase) + ) + }, + pollFunc: ffi_bitkitcore_rust_future_poll_rust_buffer, + completeFunc: ffi_bitkitcore_rust_future_complete_rust_buffer, + freeFunc: ffi_bitkitcore_rust_future_free_rust_buffer, + liftFunc: FfiConverterTypeReverseSwapResponse_lift, + errorHandler: FfiConverterTypeBoltzError_lift + ) +} +/** + * Create a submarine swap (onchain -> Lightning). + * + * `invoice` is a BOLT11 invoice the caller's Lightning node generated. The + * caller funds the returned lockup address from its onchain wallet. The refund + * key is derived deterministically from `mnemonic` (only the derivation index + * is persisted, never the key), and the swap is tracked if an updates stream is + * running. `bip39_passphrase` must match the wallet's, or refunds will derive + * the wrong key. + */ +public func boltzCreateSubmarineSwap(network: BoltzNetwork, electrumUrl: String, invoice: String, mnemonic: String, bip39Passphrase: String?)async throws -> SubmarineSwapResponse { + return + try await uniffiRustCallAsync( + rustFutureFunc: { + uniffi_bitkitcore_fn_func_boltz_create_submarine_swap(FfiConverterTypeBoltzNetwork_lower(network),FfiConverterString.lower(electrumUrl),FfiConverterString.lower(invoice),FfiConverterString.lower(mnemonic),FfiConverterOptionString.lower(bip39Passphrase) + ) + }, + pollFunc: ffi_bitkitcore_rust_future_poll_rust_buffer, + completeFunc: ffi_bitkitcore_rust_future_complete_rust_buffer, + freeFunc: ffi_bitkitcore_rust_future_free_rust_buffer, + liftFunc: FfiConverterTypeSubmarineSwapResponse_lift, + errorHandler: FfiConverterTypeBoltzError_lift + ) +} +/** + * Fetch fees and limits for reverse swaps (Lightning -> onchain). + */ +public func boltzGetReverseLimits(network: BoltzNetwork)async throws -> BoltzPairInfo { + return + try await uniffiRustCallAsync( + rustFutureFunc: { + uniffi_bitkitcore_fn_func_boltz_get_reverse_limits(FfiConverterTypeBoltzNetwork_lower(network) + ) + }, + pollFunc: ffi_bitkitcore_rust_future_poll_rust_buffer, + completeFunc: ffi_bitkitcore_rust_future_complete_rust_buffer, + freeFunc: ffi_bitkitcore_rust_future_free_rust_buffer, + liftFunc: FfiConverterTypeBoltzPairInfo_lift, + errorHandler: FfiConverterTypeBoltzError_lift + ) +} +/** + * Fetch fees and limits for submarine swaps (onchain -> Lightning). + */ +public func boltzGetSubmarineLimits(network: BoltzNetwork)async throws -> BoltzPairInfo { + return + try await uniffiRustCallAsync( + rustFutureFunc: { + uniffi_bitkitcore_fn_func_boltz_get_submarine_limits(FfiConverterTypeBoltzNetwork_lower(network) + ) + }, + pollFunc: ffi_bitkitcore_rust_future_poll_rust_buffer, + completeFunc: ffi_bitkitcore_rust_future_complete_rust_buffer, + freeFunc: ffi_bitkitcore_rust_future_free_rust_buffer, + liftFunc: FfiConverterTypeBoltzPairInfo_lift, + errorHandler: FfiConverterTypeBoltzError_lift + ) +} +/** + * Fetch a single swap by id. + */ +public func boltzGetSwap(swapId: String)async throws -> BoltzSwap? { + return + try await uniffiRustCallAsync( + rustFutureFunc: { + uniffi_bitkitcore_fn_func_boltz_get_swap(FfiConverterString.lower(swapId) + ) + }, + pollFunc: ffi_bitkitcore_rust_future_poll_rust_buffer, + completeFunc: ffi_bitkitcore_rust_future_complete_rust_buffer, + freeFunc: ffi_bitkitcore_rust_future_free_rust_buffer, + liftFunc: FfiConverterOptionTypeBoltzSwap.lift, + errorHandler: FfiConverterTypeBoltzError_lift + ) +} +/** + * List swaps that have not reached a terminal state (for recovery/resume). + */ +public func boltzListPendingSwaps()async throws -> [BoltzSwap] { + return + try await uniffiRustCallAsync( + rustFutureFunc: { + uniffi_bitkitcore_fn_func_boltz_list_pending_swaps( + ) + }, + pollFunc: ffi_bitkitcore_rust_future_poll_rust_buffer, + completeFunc: ffi_bitkitcore_rust_future_complete_rust_buffer, + freeFunc: ffi_bitkitcore_rust_future_free_rust_buffer, + liftFunc: FfiConverterSequenceTypeBoltzSwap.lift, + errorHandler: FfiConverterTypeBoltzError_lift + ) +} +/** + * List every persisted swap, newest first. + */ +public func boltzListSwaps()async throws -> [BoltzSwap] { + return + try await uniffiRustCallAsync( + rustFutureFunc: { + uniffi_bitkitcore_fn_func_boltz_list_swaps( + ) + }, + pollFunc: ffi_bitkitcore_rust_future_poll_rust_buffer, + completeFunc: ffi_bitkitcore_rust_future_complete_rust_buffer, + freeFunc: ffi_bitkitcore_rust_future_free_rust_buffer, + liftFunc: FfiConverterSequenceTypeBoltzSwap.lift, + errorHandler: FfiConverterTypeBoltzError_lift + ) +} +/** + * Refund a submarine swap's locked funds to `refund_address`, returning the + * broadcast refund transaction id. Used when Boltz fails to pay the invoice or + * the swap expires. The refund key is re-derived from `mnemonic`. Refunds are + * serialized per swap, so two concurrent calls cannot both broadcast: the second + * waits for the first and returns its txid. + */ +public func boltzRefundSubmarineSwap(swapId: String, refundAddress: String, mnemonic: String, bip39Passphrase: String?, feeRateSatPerVb: Double?)async throws -> String { + return + try await uniffiRustCallAsync( + rustFutureFunc: { + uniffi_bitkitcore_fn_func_boltz_refund_submarine_swap(FfiConverterString.lower(swapId),FfiConverterString.lower(refundAddress),FfiConverterString.lower(mnemonic),FfiConverterOptionString.lower(bip39Passphrase),FfiConverterOptionDouble.lower(feeRateSatPerVb) + ) + }, + pollFunc: ffi_bitkitcore_rust_future_poll_rust_buffer, + completeFunc: ffi_bitkitcore_rust_future_complete_rust_buffer, + freeFunc: ffi_bitkitcore_rust_future_free_rust_buffer, + liftFunc: FfiConverterString.lift, + errorHandler: FfiConverterTypeBoltzError_lift + ) +} +/** + * Open a Boltz WebSocket for `network`, subscribe to all pending swaps, and + * drive their lifecycle (auto-claiming reverse swaps) until stopped. Replaces + * any previously running updates stream (only one network is tracked at a + * time). `mnemonic` is held in memory for the lifetime of the stream so + * confirmed reverse swaps can be auto-claimed; it is never persisted. Events + * are delivered to `listener`. + * + * `fee_rate_sat_per_vb` is the fee rate used for automatic claim transactions. + * Bitkit owns fee estimation and should pass its current recommended rate; when + * `None`, a conservative built-in default is used. To auto-claim at an updated + * fee rate, call this again (it restarts the stream). + * + * `accept_zero_conf` claims reverse swaps as soon as Boltz's lockup enters the + * mempool instead of waiting for its confirmation. That reveals the preimage + * against an unconfirmed lockup: if the lockup were replaced before + * confirming, the user would be debited on Lightning without receiving + * onchain funds. Pass `false` to keep the confirmation-gated default. + */ +public func boltzStartSwapUpdates(network: BoltzNetwork, listener: BoltzEventListener, mnemonic: String, bip39Passphrase: String?, feeRateSatPerVb: Double?, acceptZeroConf: Bool)async throws { return try await uniffiRustCallAsync( rustFutureFunc: { - uniffi_bitkitcore_fn_func_approve_pubky_auth(FfiConverterString.lower(authUrl),FfiConverterString.lower(secretKeyHex) + uniffi_bitkitcore_fn_func_boltz_start_swap_updates(FfiConverterTypeBoltzNetwork_lower(network),FfiConverterTypeBoltzEventListener_lower(listener),FfiConverterString.lower(mnemonic),FfiConverterOptionString.lower(bip39Passphrase),FfiConverterOptionDouble.lower(feeRateSatPerVb),FfiConverterBool.lower(acceptZeroConf) ) }, pollFunc: ffi_bitkitcore_rust_future_poll_void, completeFunc: ffi_bitkitcore_rust_future_complete_void, freeFunc: ffi_bitkitcore_rust_future_free_void, liftFunc: { $0 }, - errorHandler: FfiConverterTypePubkyError_lift + errorHandler: FfiConverterTypeBoltzError_lift ) } -public func blocktankRemoveAllCjitEntries()async throws { +/** + * Stop the running Boltz updates stream, if any. + */ +public func boltzStopSwapUpdates()async { return - try await uniffiRustCallAsync( + try! await uniffiRustCallAsync( rustFutureFunc: { - uniffi_bitkitcore_fn_func_blocktank_remove_all_cjit_entries( + uniffi_bitkitcore_fn_func_boltz_stop_swap_updates( ) }, pollFunc: ffi_bitkitcore_rust_future_poll_void, completeFunc: ffi_bitkitcore_rust_future_complete_void, freeFunc: ffi_bitkitcore_rust_future_free_void, liftFunc: { $0 }, - errorHandler: FfiConverterTypeBlocktankError_lift + errorHandler: nil + ) } -public func blocktankRemoveAllOrders()async throws { +public func broadcastSweepTransaction(psbt: String, mnemonicPhrase: String, network: Network?, bip39Passphrase: String?, electrumUrl: String)async throws -> SweepResult { return try await uniffiRustCallAsync( rustFutureFunc: { - uniffi_bitkitcore_fn_func_blocktank_remove_all_orders( + uniffi_bitkitcore_fn_func_broadcast_sweep_transaction(FfiConverterString.lower(psbt),FfiConverterString.lower(mnemonicPhrase),FfiConverterOptionTypeNetwork.lower(network),FfiConverterOptionString.lower(bip39Passphrase),FfiConverterString.lower(electrumUrl) ) }, - pollFunc: ffi_bitkitcore_rust_future_poll_void, - completeFunc: ffi_bitkitcore_rust_future_complete_void, - freeFunc: ffi_bitkitcore_rust_future_free_void, - liftFunc: { $0 }, - errorHandler: FfiConverterTypeBlocktankError_lift + pollFunc: ffi_bitkitcore_rust_future_poll_rust_buffer, + completeFunc: ffi_bitkitcore_rust_future_complete_rust_buffer, + freeFunc: ffi_bitkitcore_rust_future_free_rust_buffer, + liftFunc: FfiConverterTypeSweepResult_lift, + errorHandler: FfiConverterTypeSweepError_lift ) } -public func blocktankWipeAll()async throws { +public func calculateChannelLiquidityOptions(params: ChannelLiquidityParams) -> ChannelLiquidityOptions { + return try! FfiConverterTypeChannelLiquidityOptions_lift(try! rustCall() { + uniffi_bitkitcore_fn_func_calculate_channel_liquidity_options( + FfiConverterTypeChannelLiquidityParams_lower(params),$0 + ) +}) +} +public func cancelPubkyAuth()async throws { return try await uniffiRustCallAsync( rustFutureFunc: { - uniffi_bitkitcore_fn_func_blocktank_wipe_all( + uniffi_bitkitcore_fn_func_cancel_pubky_auth( ) }, pollFunc: ffi_bitkitcore_rust_future_poll_void, completeFunc: ffi_bitkitcore_rust_future_complete_void, freeFunc: ffi_bitkitcore_rust_future_free_void, liftFunc: { $0 }, - errorHandler: FfiConverterTypeBlocktankError_lift + errorHandler: FfiConverterTypePubkyError_lift + ) +} +public func checkSweepableBalances(mnemonicPhrase: String, network: Network?, bip39Passphrase: String?, electrumUrl: String)async throws -> SweepableBalances { + return + try await uniffiRustCallAsync( + rustFutureFunc: { + uniffi_bitkitcore_fn_func_check_sweepable_balances(FfiConverterString.lower(mnemonicPhrase),FfiConverterOptionTypeNetwork.lower(network),FfiConverterOptionString.lower(bip39Passphrase),FfiConverterString.lower(electrumUrl) + ) + }, + pollFunc: ffi_bitkitcore_rust_future_poll_rust_buffer, + completeFunc: ffi_bitkitcore_rust_future_complete_rust_buffer, + freeFunc: ffi_bitkitcore_rust_future_free_rust_buffer, + liftFunc: FfiConverterTypeSweepableBalances_lift, + errorHandler: FfiConverterTypeSweepError_lift ) } /** - * Claim a reverse swap's onchain funds to its claim address, returning the - * broadcast claim transaction id. Normally happens automatically via the - * updates stream; exposed for manual recovery. The claim key is re-derived from - * `mnemonic`. Claims are serialized per swap, so calling this while the updates - * stream is auto-claiming the same swap waits for that claim and returns its - * txid rather than broadcasting a second transaction. + * Decode closed channels from Core's canonical backup JSON. */ -public func boltzClaimReverseSwap(swapId: String, mnemonic: String, bip39Passphrase: String?, feeRateSatPerVb: Double?)async throws -> String { +public func closedChannelsFromJson(json: String)throws -> [ClosedChannelDetails] { + return try FfiConverterSequenceTypeClosedChannelDetails.lift(try rustCallWithError(FfiConverterTypeActivityError_lift) { + uniffi_bitkitcore_fn_func_closed_channels_from_json( + FfiConverterString.lower(json),$0 + ) +}) +} +/** + * Serialize closed channels to Core's canonical backup JSON. Closed channels + * are not wallet-scoped, so no wallet-id normalization is applied. + */ +public func closedChannelsToJson(channels: [ClosedChannelDetails])throws -> String { + return try FfiConverterString.lift(try rustCallWithError(FfiConverterTypeActivityError_lift) { + uniffi_bitkitcore_fn_func_closed_channels_to_json( + FfiConverterSequenceTypeClosedChannelDetails.lower(channels),$0 + ) +}) +} +public func completePubkyAuth()async throws -> String { return try await uniffiRustCallAsync( rustFutureFunc: { - uniffi_bitkitcore_fn_func_boltz_claim_reverse_swap(FfiConverterString.lower(swapId),FfiConverterString.lower(mnemonic),FfiConverterOptionString.lower(bip39Passphrase),FfiConverterOptionDouble.lower(feeRateSatPerVb) + uniffi_bitkitcore_fn_func_complete_pubky_auth( ) }, pollFunc: ffi_bitkitcore_rust_future_poll_rust_buffer, completeFunc: ffi_bitkitcore_rust_future_complete_rust_buffer, freeFunc: ffi_bitkitcore_rust_future_free_rust_buffer, liftFunc: FfiConverterString.lift, - errorHandler: FfiConverterTypeBoltzError_lift + errorHandler: FfiConverterTypePubkyError_lift + ) +} +public func createChannelRequestUrl(k1: String, callback: String, localNodeId: String, isPrivate: Bool, cancel: Bool)throws -> String { + return try FfiConverterString.lift(try rustCallWithError(FfiConverterTypeLnurlError_lift) { + uniffi_bitkitcore_fn_func_create_channel_request_url( + FfiConverterString.lower(k1), + FfiConverterString.lower(callback), + FfiConverterString.lower(localNodeId), + FfiConverterBool.lower(isPrivate), + FfiConverterBool.lower(cancel),$0 + ) +}) +} +public func createCjitEntry(channelSizeSat: UInt64, invoiceSat: UInt64, invoiceDescription: String, nodeId: String, channelExpiryWeeks: UInt32, options: CreateCjitOptions?)async throws -> IcJitEntry { + return + try await uniffiRustCallAsync( + rustFutureFunc: { + uniffi_bitkitcore_fn_func_create_cjit_entry(FfiConverterUInt64.lower(channelSizeSat),FfiConverterUInt64.lower(invoiceSat),FfiConverterString.lower(invoiceDescription),FfiConverterString.lower(nodeId),FfiConverterUInt32.lower(channelExpiryWeeks),FfiConverterOptionTypeCreateCjitOptions.lower(options) + ) + }, + pollFunc: ffi_bitkitcore_rust_future_poll_rust_buffer, + completeFunc: ffi_bitkitcore_rust_future_complete_rust_buffer, + freeFunc: ffi_bitkitcore_rust_future_free_rust_buffer, + liftFunc: FfiConverterTypeICJitEntry_lift, + errorHandler: FfiConverterTypeBlocktankError_lift + ) +} +public func createOrder(lspBalanceSat: UInt64, channelExpiryWeeks: UInt32, options: CreateOrderOptions?)async throws -> IBtOrder { + return + try await uniffiRustCallAsync( + rustFutureFunc: { + uniffi_bitkitcore_fn_func_create_order(FfiConverterUInt64.lower(lspBalanceSat),FfiConverterUInt32.lower(channelExpiryWeeks),FfiConverterOptionTypeCreateOrderOptions.lower(options) + ) + }, + pollFunc: ffi_bitkitcore_rust_future_poll_rust_buffer, + completeFunc: ffi_bitkitcore_rust_future_complete_rust_buffer, + freeFunc: ffi_bitkitcore_rust_future_free_rust_buffer, + liftFunc: FfiConverterTypeIBtOrder_lift, + errorHandler: FfiConverterTypeBlocktankError_lift + ) +} +public func createWithdrawCallbackUrl(k1: String, callback: String, paymentRequest: String)throws -> String { + return try FfiConverterString.lift(try rustCallWithError(FfiConverterTypeLnurlError_lift) { + uniffi_bitkitcore_fn_func_create_withdraw_callback_url( + FfiConverterString.lower(k1), + FfiConverterString.lower(callback), + FfiConverterString.lower(paymentRequest),$0 + ) +}) +} +public func decode(invoice: String)async throws -> Scanner { + return + try await uniffiRustCallAsync( + rustFutureFunc: { + uniffi_bitkitcore_fn_func_decode(FfiConverterString.lower(invoice) + ) + }, + pollFunc: ffi_bitkitcore_rust_future_poll_rust_buffer, + completeFunc: ffi_bitkitcore_rust_future_complete_rust_buffer, + freeFunc: ffi_bitkitcore_rust_future_free_rust_buffer, + liftFunc: FfiConverterTypeScanner_lift, + errorHandler: FfiConverterTypeDecodingError_lift ) } +public func deleteActivitiesByWalletId(walletId: String)throws -> UInt32 { + return try FfiConverterUInt32.lift(try rustCallWithError(FfiConverterTypeActivityError_lift) { + uniffi_bitkitcore_fn_func_delete_activities_by_wallet_id( + FfiConverterString.lower(walletId),$0 + ) +}) +} +public func deleteActivityById(walletId: String, activityId: String)throws -> Bool { + return try FfiConverterBool.lift(try rustCallWithError(FfiConverterTypeActivityError_lift) { + uniffi_bitkitcore_fn_func_delete_activity_by_id( + FfiConverterString.lower(walletId), + FfiConverterString.lower(activityId),$0 + ) +}) +} +public func deletePreActivityMetadata(walletId: String, paymentId: String)throws {try rustCallWithError(FfiConverterTypeActivityError_lift) { + uniffi_bitkitcore_fn_func_delete_pre_activity_metadata( + FfiConverterString.lower(walletId), + FfiConverterString.lower(paymentId),$0 + ) +} +} +public func deleteTransactionDetails(walletId: String, txId: String)throws -> Bool { + return try FfiConverterBool.lift(try rustCallWithError(FfiConverterTypeActivityError_lift) { + uniffi_bitkitcore_fn_func_delete_transaction_details( + FfiConverterString.lower(walletId), + FfiConverterString.lower(txId),$0 + ) +}) +} +public func deriveBitcoinAddress(mnemonicPhrase: String, derivationPathStr: String?, network: Network?, bip39Passphrase: String?)throws -> GetAddressResponse { + return try FfiConverterTypeGetAddressResponse_lift(try rustCallWithError(FfiConverterTypeAddressError_lift) { + uniffi_bitkitcore_fn_func_derive_bitcoin_address( + FfiConverterString.lower(mnemonicPhrase), + FfiConverterOptionString.lower(derivationPathStr), + FfiConverterOptionTypeNetwork.lower(network), + FfiConverterOptionString.lower(bip39Passphrase),$0 + ) +}) +} +public func deriveBitcoinAddresses(mnemonicPhrase: String, derivationPathStr: String?, network: Network?, bip39Passphrase: String?, isChange: Bool?, startIndex: UInt32?, count: UInt32?)throws -> GetAddressesResponse { + return try FfiConverterTypeGetAddressesResponse_lift(try rustCallWithError(FfiConverterTypeAddressError_lift) { + uniffi_bitkitcore_fn_func_derive_bitcoin_addresses( + FfiConverterString.lower(mnemonicPhrase), + FfiConverterOptionString.lower(derivationPathStr), + FfiConverterOptionTypeNetwork.lower(network), + FfiConverterOptionString.lower(bip39Passphrase), + FfiConverterOptionBool.lower(isChange), + FfiConverterOptionUInt32.lower(startIndex), + FfiConverterOptionUInt32.lower(count),$0 + ) +}) +} +public func deriveOnchainDescriptor(mnemonicPhrase: String, network: Network, bip39Passphrase: String?, accountType: AccountType, accountIndex: UInt32)throws -> String { + return try FfiConverterString.lift(try rustCallWithError(FfiConverterTypeAddressError_lift) { + uniffi_bitkitcore_fn_func_derive_onchain_descriptor( + FfiConverterString.lower(mnemonicPhrase), + FfiConverterTypeNetwork_lower(network), + FfiConverterOptionString.lower(bip39Passphrase), + FfiConverterTypeAccountType_lower(accountType), + FfiConverterUInt32.lower(accountIndex),$0 + ) +}) +} +public func derivePrivateKey(mnemonicPhrase: String, derivationPathStr: String?, network: Network?, bip39Passphrase: String?)throws -> String { + return try FfiConverterString.lift(try rustCallWithError(FfiConverterTypeAddressError_lift) { + uniffi_bitkitcore_fn_func_derive_private_key( + FfiConverterString.lower(mnemonicPhrase), + FfiConverterOptionString.lower(derivationPathStr), + FfiConverterOptionTypeNetwork.lower(network), + FfiConverterOptionString.lower(bip39Passphrase),$0 + ) +}) +} +public func derivePubkySecretKey(seed: Data)throws -> String { + return try FfiConverterString.lift(try rustCallWithError(FfiConverterTypePubkyError_lift) { + uniffi_bitkitcore_fn_func_derive_pubky_secret_key( + FfiConverterData.lower(seed),$0 + ) +}) +} /** - * Create a reverse swap (Lightning -> onchain). - * - * The caller pays the returned hold invoice from its Lightning node; - * `claim_address` is the onchain address the received funds are claimed to. - * The claim key and preimage are derived deterministically from `mnemonic` - * (only the derivation index is persisted, never the secrets) so the claim can - * be made automatically once Boltz locks the funds. `bip39_passphrase` must - * match the wallet's, or claims will derive the wrong key. + * Derive a stable, cross-platform `wallet_id` for a hardware (watch-only) wallet + * from its account extended public keys. See `derive_wallet_id` in the activity + * module for the exact derivation. Order of `xpubs` does not matter. Returns an + * error if `device_type` is blank or `xpubs` is empty / has a blank entry. */ -public func boltzCreateReverseSwap(network: BoltzNetwork, electrumUrl: String, amountSat: UInt64, claimAddress: String, mnemonic: String, bip39Passphrase: String?)async throws -> ReverseSwapResponse { +public func deriveWalletId(deviceType: String, xpubs: [String])throws -> String { + return try FfiConverterString.lift(try rustCallWithError(FfiConverterTypeActivityError_lift) { + uniffi_bitkitcore_fn_func_derive_wallet_id( + FfiConverterString.lower(deviceType), + FfiConverterSequenceString.lower(xpubs),$0 + ) +}) +} +public func entropyToMnemonic(entropy: Data)throws -> String { + return try FfiConverterString.lift(try rustCallWithError(FfiConverterTypeAddressError_lift) { + uniffi_bitkitcore_fn_func_entropy_to_mnemonic( + FfiConverterData.lower(entropy),$0 + ) +}) +} +public func estimateOrderFee(lspBalanceSat: UInt64, channelExpiryWeeks: UInt32, options: CreateOrderOptions?)async throws -> IBtEstimateFeeResponse { return try await uniffiRustCallAsync( rustFutureFunc: { - uniffi_bitkitcore_fn_func_boltz_create_reverse_swap(FfiConverterTypeBoltzNetwork_lower(network),FfiConverterString.lower(electrumUrl),FfiConverterUInt64.lower(amountSat),FfiConverterString.lower(claimAddress),FfiConverterString.lower(mnemonic),FfiConverterOptionString.lower(bip39Passphrase) + uniffi_bitkitcore_fn_func_estimate_order_fee(FfiConverterUInt64.lower(lspBalanceSat),FfiConverterUInt32.lower(channelExpiryWeeks),FfiConverterOptionTypeCreateOrderOptions.lower(options) ) }, pollFunc: ffi_bitkitcore_rust_future_poll_rust_buffer, completeFunc: ffi_bitkitcore_rust_future_complete_rust_buffer, freeFunc: ffi_bitkitcore_rust_future_free_rust_buffer, - liftFunc: FfiConverterTypeReverseSwapResponse_lift, - errorHandler: FfiConverterTypeBoltzError_lift + liftFunc: FfiConverterTypeIBtEstimateFeeResponse_lift, + errorHandler: FfiConverterTypeBlocktankError_lift ) } -/** - * Create a submarine swap (onchain -> Lightning). - * - * `invoice` is a BOLT11 invoice the caller's Lightning node generated. The - * caller funds the returned lockup address from its onchain wallet. The refund - * key is derived deterministically from `mnemonic` (only the derivation index - * is persisted, never the key), and the swap is tracked if an updates stream is - * running. `bip39_passphrase` must match the wallet's, or refunds will derive - * the wrong key. - */ -public func boltzCreateSubmarineSwap(network: BoltzNetwork, electrumUrl: String, invoice: String, mnemonic: String, bip39Passphrase: String?)async throws -> SubmarineSwapResponse { +public func estimateOrderFeeFull(lspBalanceSat: UInt64, channelExpiryWeeks: UInt32, options: CreateOrderOptions?)async throws -> IBtEstimateFeeResponse2 { return try await uniffiRustCallAsync( rustFutureFunc: { - uniffi_bitkitcore_fn_func_boltz_create_submarine_swap(FfiConverterTypeBoltzNetwork_lower(network),FfiConverterString.lower(electrumUrl),FfiConverterString.lower(invoice),FfiConverterString.lower(mnemonic),FfiConverterOptionString.lower(bip39Passphrase) + uniffi_bitkitcore_fn_func_estimate_order_fee_full(FfiConverterUInt64.lower(lspBalanceSat),FfiConverterUInt32.lower(channelExpiryWeeks),FfiConverterOptionTypeCreateOrderOptions.lower(options) ) }, pollFunc: ffi_bitkitcore_rust_future_poll_rust_buffer, completeFunc: ffi_bitkitcore_rust_future_complete_rust_buffer, freeFunc: ffi_bitkitcore_rust_future_free_rust_buffer, - liftFunc: FfiConverterTypeSubmarineSwapResponse_lift, - errorHandler: FfiConverterTypeBoltzError_lift + liftFunc: FfiConverterTypeIBtEstimateFeeResponse2_lift, + errorHandler: FfiConverterTypeBlocktankError_lift ) } -/** - * Fetch fees and limits for reverse swaps (Lightning -> onchain). - */ -public func boltzGetReverseLimits(network: BoltzNetwork)async throws -> BoltzPairInfo { +public func fetchPubkyContacts(publicKey: String)async throws -> [String] { return try await uniffiRustCallAsync( rustFutureFunc: { - uniffi_bitkitcore_fn_func_boltz_get_reverse_limits(FfiConverterTypeBoltzNetwork_lower(network) + uniffi_bitkitcore_fn_func_fetch_pubky_contacts(FfiConverterString.lower(publicKey) ) }, pollFunc: ffi_bitkitcore_rust_future_poll_rust_buffer, completeFunc: ffi_bitkitcore_rust_future_complete_rust_buffer, freeFunc: ffi_bitkitcore_rust_future_free_rust_buffer, - liftFunc: FfiConverterTypeBoltzPairInfo_lift, - errorHandler: FfiConverterTypeBoltzError_lift + liftFunc: FfiConverterSequenceString.lift, + errorHandler: FfiConverterTypePubkyError_lift ) } -/** - * Fetch fees and limits for submarine swaps (onchain -> Lightning). - */ -public func boltzGetSubmarineLimits(network: BoltzNetwork)async throws -> BoltzPairInfo { +public func fetchPubkyFile(uri: String)async throws -> Data { return try await uniffiRustCallAsync( rustFutureFunc: { - uniffi_bitkitcore_fn_func_boltz_get_submarine_limits(FfiConverterTypeBoltzNetwork_lower(network) + uniffi_bitkitcore_fn_func_fetch_pubky_file(FfiConverterString.lower(uri) ) }, pollFunc: ffi_bitkitcore_rust_future_poll_rust_buffer, completeFunc: ffi_bitkitcore_rust_future_complete_rust_buffer, freeFunc: ffi_bitkitcore_rust_future_free_rust_buffer, - liftFunc: FfiConverterTypeBoltzPairInfo_lift, - errorHandler: FfiConverterTypeBoltzError_lift + liftFunc: FfiConverterData.lift, + errorHandler: FfiConverterTypePubkyError_lift ) } -/** - * Fetch a single swap by id. - */ -public func boltzGetSwap(swapId: String)async throws -> BoltzSwap? { +public func fetchPubkyFileString(uri: String)async throws -> String { return try await uniffiRustCallAsync( rustFutureFunc: { - uniffi_bitkitcore_fn_func_boltz_get_swap(FfiConverterString.lower(swapId) + uniffi_bitkitcore_fn_func_fetch_pubky_file_string(FfiConverterString.lower(uri) ) }, pollFunc: ffi_bitkitcore_rust_future_poll_rust_buffer, completeFunc: ffi_bitkitcore_rust_future_complete_rust_buffer, freeFunc: ffi_bitkitcore_rust_future_free_rust_buffer, - liftFunc: FfiConverterOptionTypeBoltzSwap.lift, - errorHandler: FfiConverterTypeBoltzError_lift + liftFunc: FfiConverterString.lift, + errorHandler: FfiConverterTypePubkyError_lift ) } -/** - * List swaps that have not reached a terminal state (for recovery/resume). - */ -public func boltzListPendingSwaps()async throws -> [BoltzSwap] { +public func fetchPubkyProfile(publicKey: String)async throws -> PubkyProfile { return try await uniffiRustCallAsync( rustFutureFunc: { - uniffi_bitkitcore_fn_func_boltz_list_pending_swaps( + uniffi_bitkitcore_fn_func_fetch_pubky_profile(FfiConverterString.lower(publicKey) ) }, pollFunc: ffi_bitkitcore_rust_future_poll_rust_buffer, completeFunc: ffi_bitkitcore_rust_future_complete_rust_buffer, freeFunc: ffi_bitkitcore_rust_future_free_rust_buffer, - liftFunc: FfiConverterSequenceTypeBoltzSwap.lift, - errorHandler: FfiConverterTypeBoltzError_lift + liftFunc: FfiConverterTypePubkyProfile_lift, + errorHandler: FfiConverterTypePubkyError_lift ) } /** - * List every persisted swap, newest first. + * Combine and finalize a signed PSBT, then extract its broadcastable transaction. */ -public func boltzListSwaps()async throws -> [BoltzSwap] { - return - try await uniffiRustCallAsync( - rustFutureFunc: { - uniffi_bitkitcore_fn_func_boltz_list_swaps( - ) - }, - pollFunc: ffi_bitkitcore_rust_future_poll_rust_buffer, - completeFunc: ffi_bitkitcore_rust_future_complete_rust_buffer, - freeFunc: ffi_bitkitcore_rust_future_free_rust_buffer, - liftFunc: FfiConverterSequenceTypeBoltzSwap.lift, - errorHandler: FfiConverterTypeBoltzError_lift - ) +public func finalizePsbt(originalPsbt: String, signedPsbt: String)throws -> CompletedTransaction { + return try FfiConverterTypeCompletedTransaction_lift(try rustCallWithError(FfiConverterTypePsbtCompletionError_lift) { + uniffi_bitkitcore_fn_func_finalize_psbt( + FfiConverterString.lower(originalPsbt), + FfiConverterString.lower(signedPsbt),$0 + ) +}) +} +public func generateMnemonic(wordCount: WordCount?)throws -> String { + return try FfiConverterString.lift(try rustCallWithError(FfiConverterTypeAddressError_lift) { + uniffi_bitkitcore_fn_func_generate_mnemonic( + FfiConverterOptionTypeWordCount.lower(wordCount),$0 + ) +}) +} +public func getActivities(walletId: String?, filter: ActivityFilter?, txType: PaymentType?, tags: [String]?, search: String?, minDate: UInt64?, maxDate: UInt64?, limit: UInt32?, sortDirection: SortDirection?)throws -> [Activity] { + return try FfiConverterSequenceTypeActivity.lift(try rustCallWithError(FfiConverterTypeActivityError_lift) { + uniffi_bitkitcore_fn_func_get_activities( + FfiConverterOptionString.lower(walletId), + FfiConverterOptionTypeActivityFilter.lower(filter), + FfiConverterOptionTypePaymentType.lower(txType), + FfiConverterOptionSequenceString.lower(tags), + FfiConverterOptionString.lower(search), + FfiConverterOptionUInt64.lower(minDate), + FfiConverterOptionUInt64.lower(maxDate), + FfiConverterOptionUInt32.lower(limit), + FfiConverterOptionTypeSortDirection.lower(sortDirection),$0 + ) +}) +} +public func getActivitiesByTag(walletId: String?, tag: String, limit: UInt32?, sortDirection: SortDirection?)throws -> [Activity] { + return try FfiConverterSequenceTypeActivity.lift(try rustCallWithError(FfiConverterTypeActivityError_lift) { + uniffi_bitkitcore_fn_func_get_activities_by_tag( + FfiConverterOptionString.lower(walletId), + FfiConverterString.lower(tag), + FfiConverterOptionUInt32.lower(limit), + FfiConverterOptionTypeSortDirection.lower(sortDirection),$0 + ) +}) } /** - * Refund a submarine swap's locked funds to `refund_address`, returning the - * broadcast refund transaction id. Used when Boltz fails to pay the invoice or - * the swap expires. The refund key is re-derived from `mnemonic`. Refunds are - * serialized per swap, so two concurrent calls cannot both broadcast: the second - * waits for the first and returns its txid. + * Activity tags for a single wallet scope, or every scope when `wallet_id` is `None`. */ -public func boltzRefundSubmarineSwap(swapId: String, refundAddress: String, mnemonic: String, bip39Passphrase: String?, feeRateSatPerVb: Double?)async throws -> String { - return - try await uniffiRustCallAsync( - rustFutureFunc: { - uniffi_bitkitcore_fn_func_boltz_refund_submarine_swap(FfiConverterString.lower(swapId),FfiConverterString.lower(refundAddress),FfiConverterString.lower(mnemonic),FfiConverterOptionString.lower(bip39Passphrase),FfiConverterOptionDouble.lower(feeRateSatPerVb) - ) - }, - pollFunc: ffi_bitkitcore_rust_future_poll_rust_buffer, - completeFunc: ffi_bitkitcore_rust_future_complete_rust_buffer, - freeFunc: ffi_bitkitcore_rust_future_free_rust_buffer, - liftFunc: FfiConverterString.lift, - errorHandler: FfiConverterTypeBoltzError_lift - ) +public func getActivitiesTags(walletId: String?)throws -> [ActivityTags] { + return try FfiConverterSequenceTypeActivityTags.lift(try rustCallWithError(FfiConverterTypeActivityError_lift) { + uniffi_bitkitcore_fn_func_get_activities_tags( + FfiConverterOptionString.lower(walletId),$0 + ) +}) +} +public func getActivityById(walletId: String, activityId: String)throws -> Activity? { + return try FfiConverterOptionTypeActivity.lift(try rustCallWithError(FfiConverterTypeActivityError_lift) { + uniffi_bitkitcore_fn_func_get_activity_by_id( + FfiConverterString.lower(walletId), + FfiConverterString.lower(activityId),$0 + ) +}) +} +public func getActivityByTxId(walletId: String, txId: String)throws -> OnchainActivity? { + return try FfiConverterOptionTypeOnchainActivity.lift(try rustCallWithError(FfiConverterTypeActivityError_lift) { + uniffi_bitkitcore_fn_func_get_activity_by_tx_id( + FfiConverterString.lower(walletId), + FfiConverterString.lower(txId),$0 + ) +}) +} +public func getAllActivitiesTags()throws -> [ActivityTags] { + return try FfiConverterSequenceTypeActivityTags.lift(try rustCallWithError(FfiConverterTypeActivityError_lift) { + uniffi_bitkitcore_fn_func_get_all_activities_tags($0 + ) +}) +} +public func getAllClosedChannels(sortDirection: SortDirection?)throws -> [ClosedChannelDetails] { + return try FfiConverterSequenceTypeClosedChannelDetails.lift(try rustCallWithError(FfiConverterTypeActivityError_lift) { + uniffi_bitkitcore_fn_func_get_all_closed_channels( + FfiConverterOptionTypeSortDirection.lower(sortDirection),$0 + ) +}) +} +public func getAllPreActivityMetadata()throws -> [PreActivityMetadata] { + return try FfiConverterSequenceTypePreActivityMetadata.lift(try rustCallWithError(FfiConverterTypeActivityError_lift) { + uniffi_bitkitcore_fn_func_get_all_pre_activity_metadata($0 + ) +}) +} +public func getAllTransactionDetails()throws -> [TransactionDetails] { + return try FfiConverterSequenceTypeTransactionDetails.lift(try rustCallWithError(FfiConverterTypeActivityError_lift) { + uniffi_bitkitcore_fn_func_get_all_transaction_details($0 + ) +}) +} +public func getAllUniqueTags()throws -> [String] { + return try FfiConverterSequenceString.lift(try rustCallWithError(FfiConverterTypeActivityError_lift) { + uniffi_bitkitcore_fn_func_get_all_unique_tags($0 + ) +}) +} +public func getBip39Suggestions(partialWord: String, limit: UInt32) -> [String] { + return try! FfiConverterSequenceString.lift(try! rustCall() { + uniffi_bitkitcore_fn_func_get_bip39_suggestions( + FfiConverterString.lower(partialWord), + FfiConverterUInt32.lower(limit),$0 + ) +}) +} +public func getBip39Wordlist() -> [String] { + return try! FfiConverterSequenceString.lift(try! rustCall() { + uniffi_bitkitcore_fn_func_get_bip39_wordlist($0 + ) +}) } -/** - * Open a Boltz WebSocket for `network`, subscribe to all pending swaps, and - * drive their lifecycle (auto-claiming reverse swaps) until stopped. Replaces - * any previously running updates stream (only one network is tracked at a - * time). `mnemonic` is held in memory for the lifetime of the stream so - * confirmed reverse swaps can be auto-claimed; it is never persisted. Events - * are delivered to `listener`. - * - * `fee_rate_sat_per_vb` is the fee rate used for automatic claim transactions. - * Bitkit owns fee estimation and should pass its current recommended rate; when - * `None`, a conservative built-in default is used. To auto-claim at an updated - * fee rate, call this again (it restarts the stream). - * - * `accept_zero_conf` claims reverse swaps as soon as Boltz's lockup enters the - * mempool instead of waiting for its confirmation. That reveals the preimage - * against an unconfirmed lockup: if the lockup were replaced before - * confirming, the user would be debited on Lightning without receiving - * onchain funds. Pass `false` to keep the confirmation-gated default. - */ -public func boltzStartSwapUpdates(network: BoltzNetwork, listener: BoltzEventListener, mnemonic: String, bip39Passphrase: String?, feeRateSatPerVb: Double?, acceptZeroConf: Bool)async throws { +public func getCjitEntries(entryIds: [String]?, filter: CJitStateEnum?, refresh: Bool)async throws -> [IcJitEntry] { return try await uniffiRustCallAsync( rustFutureFunc: { - uniffi_bitkitcore_fn_func_boltz_start_swap_updates(FfiConverterTypeBoltzNetwork_lower(network),FfiConverterTypeBoltzEventListener_lower(listener),FfiConverterString.lower(mnemonic),FfiConverterOptionString.lower(bip39Passphrase),FfiConverterOptionDouble.lower(feeRateSatPerVb),FfiConverterBool.lower(acceptZeroConf) + uniffi_bitkitcore_fn_func_get_cjit_entries(FfiConverterOptionSequenceString.lower(entryIds),FfiConverterOptionTypeCJitStateEnum.lower(filter),FfiConverterBool.lower(refresh) ) }, - pollFunc: ffi_bitkitcore_rust_future_poll_void, - completeFunc: ffi_bitkitcore_rust_future_complete_void, - freeFunc: ffi_bitkitcore_rust_future_free_void, - liftFunc: { $0 }, - errorHandler: FfiConverterTypeBoltzError_lift + pollFunc: ffi_bitkitcore_rust_future_poll_rust_buffer, + completeFunc: ffi_bitkitcore_rust_future_complete_rust_buffer, + freeFunc: ffi_bitkitcore_rust_future_free_rust_buffer, + liftFunc: FfiConverterSequenceTypeICJitEntry.lift, + errorHandler: FfiConverterTypeBlocktankError_lift ) } +public func getClosedChannelById(channelId: String)throws -> ClosedChannelDetails? { + return try FfiConverterOptionTypeClosedChannelDetails.lift(try rustCallWithError(FfiConverterTypeActivityError_lift) { + uniffi_bitkitcore_fn_func_get_closed_channel_by_id( + FfiConverterString.lower(channelId),$0 + ) +}) +} /** - * Stop the running Boltz updates stream, if any. + * The default address gap limit used by account scanning and the xpub watcher. + * Exposed so platforms reference one source of truth instead of hardcoding 20. */ -public func boltzStopSwapUpdates()async { - return - try! await uniffiRustCallAsync( - rustFutureFunc: { - uniffi_bitkitcore_fn_func_boltz_stop_swap_updates( - ) - }, - pollFunc: ffi_bitkitcore_rust_future_poll_void, - completeFunc: ffi_bitkitcore_rust_future_complete_void, - freeFunc: ffi_bitkitcore_rust_future_free_void, - liftFunc: { $0 }, - errorHandler: nil - - ) +public func getDefaultGapLimit() -> UInt32 { + return try! FfiConverterUInt32.lift(try! rustCall() { + uniffi_bitkitcore_fn_func_get_default_gap_limit($0 + ) +}) } -public func broadcastSweepTransaction(psbt: String, mnemonicPhrase: String, network: Network?, bip39Passphrase: String?, electrumUrl: String)async throws -> SweepResult { +public func getDefaultLspBalance(params: DefaultLspBalanceParams) -> UInt64 { + return try! FfiConverterUInt64.lift(try! rustCall() { + uniffi_bitkitcore_fn_func_get_default_lsp_balance( + FfiConverterTypeDefaultLspBalanceParams_lower(params),$0 + ) +}) +} +public func getDefaultWalletId() -> String { + return try! FfiConverterString.lift(try! rustCall() { + uniffi_bitkitcore_fn_func_get_default_wallet_id($0 + ) +}) +} +public func getGift(giftId: String)async throws -> IGift { return try await uniffiRustCallAsync( rustFutureFunc: { - uniffi_bitkitcore_fn_func_broadcast_sweep_transaction(FfiConverterString.lower(psbt),FfiConverterString.lower(mnemonicPhrase),FfiConverterOptionTypeNetwork.lower(network),FfiConverterOptionString.lower(bip39Passphrase),FfiConverterString.lower(electrumUrl) + uniffi_bitkitcore_fn_func_get_gift(FfiConverterString.lower(giftId) ) }, pollFunc: ffi_bitkitcore_rust_future_poll_rust_buffer, completeFunc: ffi_bitkitcore_rust_future_complete_rust_buffer, freeFunc: ffi_bitkitcore_rust_future_free_rust_buffer, - liftFunc: FfiConverterTypeSweepResult_lift, - errorHandler: FfiConverterTypeSweepError_lift + liftFunc: FfiConverterTypeIGift_lift, + errorHandler: FfiConverterTypeBlocktankError_lift ) } -public func calculateChannelLiquidityOptions(params: ChannelLiquidityParams) -> ChannelLiquidityOptions { - return try! FfiConverterTypeChannelLiquidityOptions_lift(try! rustCall() { - uniffi_bitkitcore_fn_func_calculate_channel_liquidity_options( - FfiConverterTypeChannelLiquidityParams_lower(params),$0 - ) -}) -} -public func cancelPubkyAuth()async throws { +public func getInfo(refresh: Bool?)async throws -> IBtInfo? { return try await uniffiRustCallAsync( rustFutureFunc: { - uniffi_bitkitcore_fn_func_cancel_pubky_auth( + uniffi_bitkitcore_fn_func_get_info(FfiConverterOptionBool.lower(refresh) ) }, - pollFunc: ffi_bitkitcore_rust_future_poll_void, - completeFunc: ffi_bitkitcore_rust_future_complete_void, - freeFunc: ffi_bitkitcore_rust_future_free_void, - liftFunc: { $0 }, - errorHandler: FfiConverterTypePubkyError_lift + pollFunc: ffi_bitkitcore_rust_future_poll_rust_buffer, + completeFunc: ffi_bitkitcore_rust_future_complete_rust_buffer, + freeFunc: ffi_bitkitcore_rust_future_free_rust_buffer, + liftFunc: FfiConverterOptionTypeIBtInfo.lift, + errorHandler: FfiConverterTypeBlocktankError_lift ) } -public func checkSweepableBalances(mnemonicPhrase: String, network: Network?, bip39Passphrase: String?, electrumUrl: String)async throws -> SweepableBalances { +public func getLnurlInvoice(address: String, amountSatoshis: UInt64)async throws -> String { return try await uniffiRustCallAsync( rustFutureFunc: { - uniffi_bitkitcore_fn_func_check_sweepable_balances(FfiConverterString.lower(mnemonicPhrase),FfiConverterOptionTypeNetwork.lower(network),FfiConverterOptionString.lower(bip39Passphrase),FfiConverterString.lower(electrumUrl) + uniffi_bitkitcore_fn_func_get_lnurl_invoice(FfiConverterString.lower(address),FfiConverterUInt64.lower(amountSatoshis) ) }, pollFunc: ffi_bitkitcore_rust_future_poll_rust_buffer, completeFunc: ffi_bitkitcore_rust_future_complete_rust_buffer, freeFunc: ffi_bitkitcore_rust_future_free_rust_buffer, - liftFunc: FfiConverterTypeSweepableBalances_lift, - errorHandler: FfiConverterTypeSweepError_lift + liftFunc: FfiConverterString.lift, + errorHandler: FfiConverterTypeLnurlError_lift ) } -/** - * Decode closed channels from Core's canonical backup JSON. - */ -public func closedChannelsFromJson(json: String)throws -> [ClosedChannelDetails] { - return try FfiConverterSequenceTypeClosedChannelDetails.lift(try rustCallWithError(FfiConverterTypeActivityError_lift) { - uniffi_bitkitcore_fn_func_closed_channels_from_json( - FfiConverterString.lower(json),$0 - ) -}) -} -/** - * Serialize closed channels to Core's canonical backup JSON. Closed channels - * are not wallet-scoped, so no wallet-id normalization is applied. - */ -public func closedChannelsToJson(channels: [ClosedChannelDetails])throws -> String { - return try FfiConverterString.lift(try rustCallWithError(FfiConverterTypeActivityError_lift) { - uniffi_bitkitcore_fn_func_closed_channels_to_json( - FfiConverterSequenceTypeClosedChannelDetails.lower(channels),$0 - ) -}) -} -public func completePubkyAuth()async throws -> String { +public func getLnurlInvoiceForPayData(data: LnurlPayData, amountMsats: UInt64, comment: String?)async throws -> String { return try await uniffiRustCallAsync( rustFutureFunc: { - uniffi_bitkitcore_fn_func_complete_pubky_auth( + uniffi_bitkitcore_fn_func_get_lnurl_invoice_for_pay_data(FfiConverterTypeLnurlPayData_lower(data),FfiConverterUInt64.lower(amountMsats),FfiConverterOptionString.lower(comment) ) }, pollFunc: ffi_bitkitcore_rust_future_poll_rust_buffer, completeFunc: ffi_bitkitcore_rust_future_complete_rust_buffer, freeFunc: ffi_bitkitcore_rust_future_free_rust_buffer, liftFunc: FfiConverterString.lift, - errorHandler: FfiConverterTypePubkyError_lift + errorHandler: FfiConverterTypeLnurlError_lift ) } -public func createChannelRequestUrl(k1: String, callback: String, localNodeId: String, isPrivate: Bool, cancel: Bool)throws -> String { - return try FfiConverterString.lift(try rustCallWithError(FfiConverterTypeLnurlError_lift) { - uniffi_bitkitcore_fn_func_create_channel_request_url( - FfiConverterString.lower(k1), - FfiConverterString.lower(callback), - FfiConverterString.lower(localNodeId), - FfiConverterBool.lower(isPrivate), - FfiConverterBool.lower(cancel),$0 - ) -}) -} -public func createCjitEntry(channelSizeSat: UInt64, invoiceSat: UInt64, invoiceDescription: String, nodeId: String, channelExpiryWeeks: UInt32, options: CreateCjitOptions?)async throws -> IcJitEntry { +public func getMinZeroConfTxFee(orderId: String)async throws -> IBt0ConfMinTxFeeWindow { return try await uniffiRustCallAsync( rustFutureFunc: { - uniffi_bitkitcore_fn_func_create_cjit_entry(FfiConverterUInt64.lower(channelSizeSat),FfiConverterUInt64.lower(invoiceSat),FfiConverterString.lower(invoiceDescription),FfiConverterString.lower(nodeId),FfiConverterUInt32.lower(channelExpiryWeeks),FfiConverterOptionTypeCreateCjitOptions.lower(options) + uniffi_bitkitcore_fn_func_get_min_zero_conf_tx_fee(FfiConverterString.lower(orderId) ) }, pollFunc: ffi_bitkitcore_rust_future_poll_rust_buffer, completeFunc: ffi_bitkitcore_rust_future_complete_rust_buffer, freeFunc: ffi_bitkitcore_rust_future_free_rust_buffer, - liftFunc: FfiConverterTypeICJitEntry_lift, + liftFunc: FfiConverterTypeIBt0ConfMinTxFeeWindow_lift, errorHandler: FfiConverterTypeBlocktankError_lift ) } -public func createOrder(lspBalanceSat: UInt64, channelExpiryWeeks: UInt32, options: CreateOrderOptions?)async throws -> IBtOrder { +public func getOrders(orderIds: [String]?, filter: BtOrderState2?, refresh: Bool)async throws -> [IBtOrder] { return try await uniffiRustCallAsync( rustFutureFunc: { - uniffi_bitkitcore_fn_func_create_order(FfiConverterUInt64.lower(lspBalanceSat),FfiConverterUInt32.lower(channelExpiryWeeks),FfiConverterOptionTypeCreateOrderOptions.lower(options) + uniffi_bitkitcore_fn_func_get_orders(FfiConverterOptionSequenceString.lower(orderIds),FfiConverterOptionTypeBtOrderState2.lower(filter),FfiConverterBool.lower(refresh) ) }, pollFunc: ffi_bitkitcore_rust_future_poll_rust_buffer, completeFunc: ffi_bitkitcore_rust_future_complete_rust_buffer, freeFunc: ffi_bitkitcore_rust_future_free_rust_buffer, - liftFunc: FfiConverterTypeIBtOrder_lift, + liftFunc: FfiConverterSequenceTypeIBtOrder.lift, errorHandler: FfiConverterTypeBlocktankError_lift ) } -public func createWithdrawCallbackUrl(k1: String, callback: String, paymentRequest: String)throws -> String { - return try FfiConverterString.lift(try rustCallWithError(FfiConverterTypeLnurlError_lift) { - uniffi_bitkitcore_fn_func_create_withdraw_callback_url( - FfiConverterString.lower(k1), - FfiConverterString.lower(callback), - FfiConverterString.lower(paymentRequest),$0 - ) -}) -} -public func decode(invoice: String)async throws -> Scanner { +public func getPayment(paymentId: String)async throws -> IBtBolt11Invoice { return try await uniffiRustCallAsync( rustFutureFunc: { - uniffi_bitkitcore_fn_func_decode(FfiConverterString.lower(invoice) + uniffi_bitkitcore_fn_func_get_payment(FfiConverterString.lower(paymentId) ) }, pollFunc: ffi_bitkitcore_rust_future_poll_rust_buffer, completeFunc: ffi_bitkitcore_rust_future_complete_rust_buffer, freeFunc: ffi_bitkitcore_rust_future_free_rust_buffer, - liftFunc: FfiConverterTypeScanner_lift, - errorHandler: FfiConverterTypeDecodingError_lift + liftFunc: FfiConverterTypeIBtBolt11Invoice_lift, + errorHandler: FfiConverterTypeBlocktankError_lift ) } -public func deleteActivitiesByWalletId(walletId: String)throws -> UInt32 { - return try FfiConverterUInt32.lift(try rustCallWithError(FfiConverterTypeActivityError_lift) { - uniffi_bitkitcore_fn_func_delete_activities_by_wallet_id( - FfiConverterString.lower(walletId),$0 - ) -}) -} -public func deleteActivityById(walletId: String, activityId: String)throws -> Bool { - return try FfiConverterBool.lift(try rustCallWithError(FfiConverterTypeActivityError_lift) { - uniffi_bitkitcore_fn_func_delete_activity_by_id( - FfiConverterString.lower(walletId), - FfiConverterString.lower(activityId),$0 - ) -}) -} -public func deletePreActivityMetadata(walletId: String, paymentId: String)throws {try rustCallWithError(FfiConverterTypeActivityError_lift) { - uniffi_bitkitcore_fn_func_delete_pre_activity_metadata( - FfiConverterString.lower(walletId), - FfiConverterString.lower(paymentId),$0 - ) -} -} -public func deleteTransactionDetails(walletId: String, txId: String)throws -> Bool { - return try FfiConverterBool.lift(try rustCallWithError(FfiConverterTypeActivityError_lift) { - uniffi_bitkitcore_fn_func_delete_transaction_details( +public func getPreActivityMetadata(walletId: String, searchKey: String, searchByAddress: Bool)throws -> PreActivityMetadata? { + return try FfiConverterOptionTypePreActivityMetadata.lift(try rustCallWithError(FfiConverterTypeActivityError_lift) { + uniffi_bitkitcore_fn_func_get_pre_activity_metadata( FfiConverterString.lower(walletId), - FfiConverterString.lower(txId),$0 - ) -}) -} -public func deriveBitcoinAddress(mnemonicPhrase: String, derivationPathStr: String?, network: Network?, bip39Passphrase: String?)throws -> GetAddressResponse { - return try FfiConverterTypeGetAddressResponse_lift(try rustCallWithError(FfiConverterTypeAddressError_lift) { - uniffi_bitkitcore_fn_func_derive_bitcoin_address( - FfiConverterString.lower(mnemonicPhrase), - FfiConverterOptionString.lower(derivationPathStr), - FfiConverterOptionTypeNetwork.lower(network), - FfiConverterOptionString.lower(bip39Passphrase),$0 - ) -}) -} -public func deriveBitcoinAddresses(mnemonicPhrase: String, derivationPathStr: String?, network: Network?, bip39Passphrase: String?, isChange: Bool?, startIndex: UInt32?, count: UInt32?)throws -> GetAddressesResponse { - return try FfiConverterTypeGetAddressesResponse_lift(try rustCallWithError(FfiConverterTypeAddressError_lift) { - uniffi_bitkitcore_fn_func_derive_bitcoin_addresses( - FfiConverterString.lower(mnemonicPhrase), - FfiConverterOptionString.lower(derivationPathStr), - FfiConverterOptionTypeNetwork.lower(network), - FfiConverterOptionString.lower(bip39Passphrase), - FfiConverterOptionBool.lower(isChange), - FfiConverterOptionUInt32.lower(startIndex), - FfiConverterOptionUInt32.lower(count),$0 - ) -}) -} -public func deriveOnchainDescriptor(mnemonicPhrase: String, network: Network, bip39Passphrase: String?, accountType: AccountType, accountIndex: UInt32)throws -> String { - return try FfiConverterString.lift(try rustCallWithError(FfiConverterTypeAddressError_lift) { - uniffi_bitkitcore_fn_func_derive_onchain_descriptor( - FfiConverterString.lower(mnemonicPhrase), - FfiConverterTypeNetwork_lower(network), - FfiConverterOptionString.lower(bip39Passphrase), - FfiConverterTypeAccountType_lower(accountType), - FfiConverterUInt32.lower(accountIndex),$0 + FfiConverterString.lower(searchKey), + FfiConverterBool.lower(searchByAddress),$0 ) }) } -public func derivePrivateKey(mnemonicPhrase: String, derivationPathStr: String?, network: Network?, bip39Passphrase: String?)throws -> String { - return try FfiConverterString.lift(try rustCallWithError(FfiConverterTypeAddressError_lift) { - uniffi_bitkitcore_fn_func_derive_private_key( - FfiConverterString.lower(mnemonicPhrase), - FfiConverterOptionString.lower(derivationPathStr), - FfiConverterOptionTypeNetwork.lower(network), - FfiConverterOptionString.lower(bip39Passphrase),$0 +/** + * Pre-activity metadata for a single wallet scope, or every scope when `wallet_id` is `None`. + */ +public func getPreActivityMetadataList(walletId: String?)throws -> [PreActivityMetadata] { + return try FfiConverterSequenceTypePreActivityMetadata.lift(try rustCallWithError(FfiConverterTypeActivityError_lift) { + uniffi_bitkitcore_fn_func_get_pre_activity_metadata_list( + FfiConverterOptionString.lower(walletId),$0 ) }) } -public func derivePubkySecretKey(seed: Data)throws -> String { - return try FfiConverterString.lift(try rustCallWithError(FfiConverterTypePubkyError_lift) { - uniffi_bitkitcore_fn_func_derive_pubky_secret_key( - FfiConverterData.lower(seed),$0 +/** + * The hardware-wallet models supported by Bitkit and their available transports. + */ +public func getSupportedHardwareWallets() -> [SupportedHardwareWallet] { + return try! FfiConverterSequenceTypeSupportedHardwareWallet.lift(try! rustCall() { + uniffi_bitkitcore_fn_func_get_supported_hardware_wallets($0 ) }) } -/** - * Derive a stable, cross-platform `wallet_id` for a hardware (watch-only) wallet - * from its account extended public keys. See `derive_wallet_id` in the activity - * module for the exact derivation. Order of `xpubs` does not matter. Returns an - * error if `device_type` is blank or `xpubs` is empty / has a blank entry. - */ -public func deriveWalletId(deviceType: String, xpubs: [String])throws -> String { - return try FfiConverterString.lift(try rustCallWithError(FfiConverterTypeActivityError_lift) { - uniffi_bitkitcore_fn_func_derive_wallet_id( - FfiConverterString.lower(deviceType), - FfiConverterSequenceString.lower(xpubs),$0 +public func getTags(walletId: String, activityId: String)throws -> [String] { + return try FfiConverterSequenceString.lift(try rustCallWithError(FfiConverterTypeActivityError_lift) { + uniffi_bitkitcore_fn_func_get_tags( + FfiConverterString.lower(walletId), + FfiConverterString.lower(activityId),$0 ) }) } -public func entropyToMnemonic(entropy: Data)throws -> String { - return try FfiConverterString.lift(try rustCallWithError(FfiConverterTypeAddressError_lift) { - uniffi_bitkitcore_fn_func_entropy_to_mnemonic( - FfiConverterData.lower(entropy),$0 +public func getTransactionDetails(walletId: String, txId: String)throws -> TransactionDetails? { + return try FfiConverterOptionTypeTransactionDetails.lift(try rustCallWithError(FfiConverterTypeActivityError_lift) { + uniffi_bitkitcore_fn_func_get_transaction_details( + FfiConverterString.lower(walletId), + FfiConverterString.lower(txId),$0 ) }) } -public func estimateOrderFee(lspBalanceSat: UInt64, channelExpiryWeeks: UInt32, options: CreateOrderOptions?)async throws -> IBtEstimateFeeResponse { +public func giftOrder(clientNodeId: String, code: String)async throws -> IGift { return try await uniffiRustCallAsync( rustFutureFunc: { - uniffi_bitkitcore_fn_func_estimate_order_fee(FfiConverterUInt64.lower(lspBalanceSat),FfiConverterUInt32.lower(channelExpiryWeeks),FfiConverterOptionTypeCreateOrderOptions.lower(options) + uniffi_bitkitcore_fn_func_gift_order(FfiConverterString.lower(clientNodeId),FfiConverterString.lower(code) ) }, pollFunc: ffi_bitkitcore_rust_future_poll_rust_buffer, completeFunc: ffi_bitkitcore_rust_future_complete_rust_buffer, freeFunc: ffi_bitkitcore_rust_future_free_rust_buffer, - liftFunc: FfiConverterTypeIBtEstimateFeeResponse_lift, + liftFunc: FfiConverterTypeIGift_lift, errorHandler: FfiConverterTypeBlocktankError_lift ) } -public func estimateOrderFeeFull(lspBalanceSat: UInt64, channelExpiryWeeks: UInt32, options: CreateOrderOptions?)async throws -> IBtEstimateFeeResponse2 { +public func giftPay(invoice: String)async throws -> IGift { return try await uniffiRustCallAsync( rustFutureFunc: { - uniffi_bitkitcore_fn_func_estimate_order_fee_full(FfiConverterUInt64.lower(lspBalanceSat),FfiConverterUInt32.lower(channelExpiryWeeks),FfiConverterOptionTypeCreateOrderOptions.lower(options) + uniffi_bitkitcore_fn_func_gift_pay(FfiConverterString.lower(invoice) ) }, pollFunc: ffi_bitkitcore_rust_future_poll_rust_buffer, completeFunc: ffi_bitkitcore_rust_future_complete_rust_buffer, freeFunc: ffi_bitkitcore_rust_future_free_rust_buffer, - liftFunc: FfiConverterTypeIBtEstimateFeeResponse2_lift, + liftFunc: FfiConverterTypeIGift_lift, errorHandler: FfiConverterTypeBlocktankError_lift ) } -public func fetchPubkyContacts(publicKey: String)async throws -> [String] { +public func initDb(basePath: String)throws -> String { + return try FfiConverterString.lift(try rustCallWithError(FfiConverterTypeDbError_lift) { + uniffi_bitkitcore_fn_func_init_db( + FfiConverterString.lower(basePath),$0 + ) +}) +} +public func insertActivity(activity: Activity)throws {try rustCallWithError(FfiConverterTypeActivityError_lift) { + uniffi_bitkitcore_fn_func_insert_activity( + FfiConverterTypeActivity_lower(activity),$0 + ) +} +} +public func isAddressUsed(address: String)throws -> Bool { + return try FfiConverterBool.lift(try rustCallWithError(FfiConverterTypeActivityError_lift) { + uniffi_bitkitcore_fn_func_is_address_used( + FfiConverterString.lower(address),$0 + ) +}) +} +public func isValidBip39Word(word: String) -> Bool { + return try! FfiConverterBool.lift(try! rustCall() { + uniffi_bitkitcore_fn_func_is_valid_bip39_word( + FfiConverterString.lower(word),$0 + ) +}) +} +/** + * Map a generic account type onto Jade's descriptor variant. + */ +public func jadeAccountTypeToVariant(accountType: AccountType) -> JadeAddressVariant { + return try! FfiConverterTypeJadeAddressVariant_lift(try! rustCall() { + uniffi_bitkitcore_fn_func_jade_account_type_to_variant( + FfiConverterTypeAccountType_lower(accountType),$0 + ) +}) +} +/** + * Abort the operation in flight. + * + * Jade has no cancel message, so this closes the link. The application should + * reconnect afterwards. This is what backs a cancel button on a signing screen. + */ +public func jadeCancel()async throws { return try await uniffiRustCallAsync( rustFutureFunc: { - uniffi_bitkitcore_fn_func_fetch_pubky_contacts(FfiConverterString.lower(publicKey) + uniffi_bitkitcore_fn_func_jade_cancel( ) }, - pollFunc: ffi_bitkitcore_rust_future_poll_rust_buffer, - completeFunc: ffi_bitkitcore_rust_future_complete_rust_buffer, - freeFunc: ffi_bitkitcore_rust_future_free_rust_buffer, - liftFunc: FfiConverterSequenceString.lift, - errorHandler: FfiConverterTypePubkyError_lift + pollFunc: ffi_bitkitcore_rust_future_poll_void, + completeFunc: ffi_bitkitcore_rust_future_complete_void, + freeFunc: ffi_bitkitcore_rust_future_free_void, + liftFunc: { $0 }, + errorHandler: FfiConverterTypeJadeError_lift ) } -public func fetchPubkyFile(uri: String)async throws -> Data { +/** + * Open a device and read its firmware and state summary. + * + * The path normally comes from the last `jade_scan`, but a known Bluetooth + * address or serial path can be passed directly to reconnect without a scan. + * Any previously open connection is closed first. The returned `jade_state` + * tells the application what to do next: `Locked` means call `jade_unlock`, + * `Ready` means the device is already usable, and `Uninit` means the user must + * create or restore a wallet on the device itself. + */ +public func jadeConnect(transport: JadeTransportKind, path: String)async throws -> JadeVersionInfo { return try await uniffiRustCallAsync( rustFutureFunc: { - uniffi_bitkitcore_fn_func_fetch_pubky_file(FfiConverterString.lower(uri) + uniffi_bitkitcore_fn_func_jade_connect(FfiConverterTypeJadeTransportKind_lower(transport),FfiConverterString.lower(path) ) }, pollFunc: ffi_bitkitcore_rust_future_poll_rust_buffer, completeFunc: ffi_bitkitcore_rust_future_complete_rust_buffer, freeFunc: ffi_bitkitcore_rust_future_free_rust_buffer, - liftFunc: FfiConverterData.lift, - errorHandler: FfiConverterTypePubkyError_lift + liftFunc: FfiConverterTypeJadeVersionInfo_lift, + errorHandler: FfiConverterTypeJadeError_lift ) } -public func fetchPubkyFileString(uri: String)async throws -> String { +/** + * Close the device and clear session state. + * + * Safe to call while an operation is waiting on a confirmation: the pending + * request returns `UserCancelled` promptly rather than running out its deadline. + */ +public func jadeDisconnect()async throws { return try await uniffiRustCallAsync( rustFutureFunc: { - uniffi_bitkitcore_fn_func_fetch_pubky_file_string(FfiConverterString.lower(uri) + uniffi_bitkitcore_fn_func_jade_disconnect( + ) + }, + pollFunc: ffi_bitkitcore_rust_future_poll_void, + completeFunc: ffi_bitkitcore_rust_future_complete_void, + freeFunc: ffi_bitkitcore_rust_future_free_void, + liftFunc: { $0 }, + errorHandler: FfiConverterTypeJadeError_lift + ) +} +/** + * Fetch the account keys an import needs in one call. + * + * Shaped like `passport_parse_account_export` so applications have a single + * import path across signers. Each key is fetched under one held connection, + * which matters over Bluetooth where every round trip is slow. + */ +public func jadeGetAccountExport(network: JadeNetwork, accountIndex: UInt32, accountTypes: [AccountType])async throws -> JadeAccountExport { + return + try await uniffiRustCallAsync( + rustFutureFunc: { + uniffi_bitkitcore_fn_func_jade_get_account_export(FfiConverterTypeJadeNetwork_lower(network),FfiConverterUInt32.lower(accountIndex),FfiConverterSequenceTypeAccountType.lower(accountTypes) ) }, pollFunc: ffi_bitkitcore_rust_future_poll_rust_buffer, completeFunc: ffi_bitkitcore_rust_future_complete_rust_buffer, freeFunc: ffi_bitkitcore_rust_future_free_rust_buffer, - liftFunc: FfiConverterString.lift, - errorHandler: FfiConverterTypePubkyError_lift + liftFunc: FfiConverterTypeJadeAccountExport_lift, + errorHandler: FfiConverterTypeJadeError_lift ) } -public func fetchPubkyProfile(publicKey: String)async throws -> PubkyProfile { +public func jadeGetConnectedDevice()async -> JadeDeviceInfo? { return - try await uniffiRustCallAsync( + try! await uniffiRustCallAsync( rustFutureFunc: { - uniffi_bitkitcore_fn_func_fetch_pubky_profile(FfiConverterString.lower(publicKey) + uniffi_bitkitcore_fn_func_jade_get_connected_device( ) }, pollFunc: ffi_bitkitcore_rust_future_poll_rust_buffer, completeFunc: ffi_bitkitcore_rust_future_complete_rust_buffer, freeFunc: ffi_bitkitcore_rust_future_free_rust_buffer, - liftFunc: FfiConverterTypePubkyProfile_lift, - errorHandler: FfiConverterTypePubkyError_lift + liftFunc: FfiConverterOptionTypeJadeDeviceInfo.lift, + errorHandler: nil + ) } /** - * Combine and finalize a signed PSBT, then extract its broadcastable transaction. + * The device's master fingerprint, eight lowercase hex characters. + * + * This must be supplied as `WalletParams.fingerprint` when composing, or the + * resulting PSBT carries no BIP32 key origins and the device signs nothing. */ -public func finalizePsbt(originalPsbt: String, signedPsbt: String)throws -> CompletedTransaction { - return try FfiConverterTypeCompletedTransaction_lift(try rustCallWithError(FfiConverterTypePsbtCompletionError_lift) { - uniffi_bitkitcore_fn_func_finalize_psbt( - FfiConverterString.lower(originalPsbt), - FfiConverterString.lower(signedPsbt),$0 - ) -}) -} -public func generateMnemonic(wordCount: WordCount?)throws -> String { - return try FfiConverterString.lift(try rustCallWithError(FfiConverterTypeAddressError_lift) { - uniffi_bitkitcore_fn_func_generate_mnemonic( - FfiConverterOptionTypeWordCount.lower(wordCount),$0 - ) -}) -} -public func getActivities(walletId: String?, filter: ActivityFilter?, txType: PaymentType?, tags: [String]?, search: String?, minDate: UInt64?, maxDate: UInt64?, limit: UInt32?, sortDirection: SortDirection?)throws -> [Activity] { - return try FfiConverterSequenceTypeActivity.lift(try rustCallWithError(FfiConverterTypeActivityError_lift) { - uniffi_bitkitcore_fn_func_get_activities( - FfiConverterOptionString.lower(walletId), - FfiConverterOptionTypeActivityFilter.lower(filter), - FfiConverterOptionTypePaymentType.lower(txType), - FfiConverterOptionSequenceString.lower(tags), - FfiConverterOptionString.lower(search), - FfiConverterOptionUInt64.lower(minDate), - FfiConverterOptionUInt64.lower(maxDate), - FfiConverterOptionUInt32.lower(limit), - FfiConverterOptionTypeSortDirection.lower(sortDirection),$0 - ) -}) -} -public func getActivitiesByTag(walletId: String?, tag: String, limit: UInt32?, sortDirection: SortDirection?)throws -> [Activity] { - return try FfiConverterSequenceTypeActivity.lift(try rustCallWithError(FfiConverterTypeActivityError_lift) { - uniffi_bitkitcore_fn_func_get_activities_by_tag( - FfiConverterOptionString.lower(walletId), - FfiConverterString.lower(tag), - FfiConverterOptionUInt32.lower(limit), - FfiConverterOptionTypeSortDirection.lower(sortDirection),$0 - ) -}) +public func jadeGetMasterFingerprint(network: JadeNetwork)async throws -> String { + return + try await uniffiRustCallAsync( + rustFutureFunc: { + uniffi_bitkitcore_fn_func_jade_get_master_fingerprint(FfiConverterTypeJadeNetwork_lower(network) + ) + }, + pollFunc: ffi_bitkitcore_rust_future_poll_rust_buffer, + completeFunc: ffi_bitkitcore_rust_future_complete_rust_buffer, + freeFunc: ffi_bitkitcore_rust_future_free_rust_buffer, + liftFunc: FfiConverterString.lift, + errorHandler: FfiConverterTypeJadeError_lift + ) } /** - * Activity tags for a single wallet scope, or every scope when `wallet_id` is `None`. + * The version summary read at connect, without touching the device. */ -public func getActivitiesTags(walletId: String?)throws -> [ActivityTags] { - return try FfiConverterSequenceTypeActivityTags.lift(try rustCallWithError(FfiConverterTypeActivityError_lift) { - uniffi_bitkitcore_fn_func_get_activities_tags( - FfiConverterOptionString.lower(walletId),$0 - ) -}) -} -public func getActivityById(walletId: String, activityId: String)throws -> Activity? { - return try FfiConverterOptionTypeActivity.lift(try rustCallWithError(FfiConverterTypeActivityError_lift) { - uniffi_bitkitcore_fn_func_get_activity_by_id( - FfiConverterString.lower(walletId), - FfiConverterString.lower(activityId),$0 - ) -}) -} -public func getActivityByTxId(walletId: String, txId: String)throws -> OnchainActivity? { - return try FfiConverterOptionTypeOnchainActivity.lift(try rustCallWithError(FfiConverterTypeActivityError_lift) { - uniffi_bitkitcore_fn_func_get_activity_by_tx_id( - FfiConverterString.lower(walletId), - FfiConverterString.lower(txId),$0 - ) -}) -} -public func getAllActivitiesTags()throws -> [ActivityTags] { - return try FfiConverterSequenceTypeActivityTags.lift(try rustCallWithError(FfiConverterTypeActivityError_lift) { - uniffi_bitkitcore_fn_func_get_all_activities_tags($0 - ) -}) -} -public func getAllClosedChannels(sortDirection: SortDirection?)throws -> [ClosedChannelDetails] { - return try FfiConverterSequenceTypeClosedChannelDetails.lift(try rustCallWithError(FfiConverterTypeActivityError_lift) { - uniffi_bitkitcore_fn_func_get_all_closed_channels( - FfiConverterOptionTypeSortDirection.lower(sortDirection),$0 - ) -}) -} -public func getAllPreActivityMetadata()throws -> [PreActivityMetadata] { - return try FfiConverterSequenceTypePreActivityMetadata.lift(try rustCallWithError(FfiConverterTypeActivityError_lift) { - uniffi_bitkitcore_fn_func_get_all_pre_activity_metadata($0 - ) -}) -} -public func getAllTransactionDetails()throws -> [TransactionDetails] { - return try FfiConverterSequenceTypeTransactionDetails.lift(try rustCallWithError(FfiConverterTypeActivityError_lift) { - uniffi_bitkitcore_fn_func_get_all_transaction_details($0 - ) -}) -} -public func getAllUniqueTags()throws -> [String] { - return try FfiConverterSequenceString.lift(try rustCallWithError(FfiConverterTypeActivityError_lift) { - uniffi_bitkitcore_fn_func_get_all_unique_tags($0 - ) -}) -} -public func getBip39Suggestions(partialWord: String, limit: UInt32) -> [String] { - return try! FfiConverterSequenceString.lift(try! rustCall() { - uniffi_bitkitcore_fn_func_get_bip39_suggestions( - FfiConverterString.lower(partialWord), - FfiConverterUInt32.lower(limit),$0 - ) -}) -} -public func getBip39Wordlist() -> [String] { - return try! FfiConverterSequenceString.lift(try! rustCall() { - uniffi_bitkitcore_fn_func_get_bip39_wordlist($0 - ) -}) -} -public func getCjitEntries(entryIds: [String]?, filter: CJitStateEnum?, refresh: Bool)async throws -> [IcJitEntry] { +public func jadeGetVersionInfo()async -> JadeVersionInfo? { return - try await uniffiRustCallAsync( + try! await uniffiRustCallAsync( rustFutureFunc: { - uniffi_bitkitcore_fn_func_get_cjit_entries(FfiConverterOptionSequenceString.lower(entryIds),FfiConverterOptionTypeCJitStateEnum.lower(filter),FfiConverterBool.lower(refresh) + uniffi_bitkitcore_fn_func_jade_get_version_info( ) }, pollFunc: ffi_bitkitcore_rust_future_poll_rust_buffer, completeFunc: ffi_bitkitcore_rust_future_complete_rust_buffer, freeFunc: ffi_bitkitcore_rust_future_free_rust_buffer, - liftFunc: FfiConverterSequenceTypeICJitEntry.lift, - errorHandler: FfiConverterTypeBlocktankError_lift + liftFunc: FfiConverterOptionTypeJadeVersionInfo.lift, + errorHandler: nil + ) } -public func getClosedChannelById(channelId: String)throws -> ClosedChannelDetails? { - return try FfiConverterOptionTypeClosedChannelDetails.lift(try rustCallWithError(FfiConverterTypeActivityError_lift) { - uniffi_bitkitcore_fn_func_get_closed_channel_by_id( - FfiConverterString.lower(channelId),$0 - ) -}) -} /** - * The default address gap limit used by account scanning and the xpub watcher. - * Exposed so platforms reference one source of truth instead of hardcoding 20. + * Fetch an extended public key, echoed back with the path and fingerprint. */ -public func getDefaultGapLimit() -> UInt32 { - return try! FfiConverterUInt32.lift(try! rustCall() { - uniffi_bitkitcore_fn_func_get_default_gap_limit($0 - ) -}) -} -public func getDefaultLspBalance(params: DefaultLspBalanceParams) -> UInt64 { - return try! FfiConverterUInt64.lift(try! rustCall() { - uniffi_bitkitcore_fn_func_get_default_lsp_balance( - FfiConverterTypeDefaultLspBalanceParams_lower(params),$0 - ) -}) -} -public func getDefaultWalletId() -> String { - return try! FfiConverterString.lift(try! rustCall() { - uniffi_bitkitcore_fn_func_get_default_wallet_id($0 - ) -}) -} -public func getGift(giftId: String)async throws -> IGift { +public func jadeGetXpub(network: JadeNetwork, derivationPath: String)async throws -> JadeXpubResponse { return try await uniffiRustCallAsync( rustFutureFunc: { - uniffi_bitkitcore_fn_func_get_gift(FfiConverterString.lower(giftId) + uniffi_bitkitcore_fn_func_jade_get_xpub(FfiConverterTypeJadeNetwork_lower(network),FfiConverterString.lower(derivationPath) ) }, pollFunc: ffi_bitkitcore_rust_future_poll_rust_buffer, completeFunc: ffi_bitkitcore_rust_future_complete_rust_buffer, freeFunc: ffi_bitkitcore_rust_future_free_rust_buffer, - liftFunc: FfiConverterTypeIGift_lift, - errorHandler: FfiConverterTypeBlocktankError_lift + liftFunc: FfiConverterTypeJadeXpubResponse_lift, + errorHandler: FfiConverterTypeJadeError_lift ) } -public func getInfo(refresh: Bool?)async throws -> IBtInfo? { +public func jadeIsConnected() -> Bool { + return try! FfiConverterBool.lift(try! rustCall() { + uniffi_bitkitcore_fn_func_jade_is_connected($0 + ) +}) +} +/** + * The devices found by the last scan, without starting a new one. + */ +public func jadeListDevices()async -> [JadeDeviceInfo] { return - try await uniffiRustCallAsync( + try! await uniffiRustCallAsync( rustFutureFunc: { - uniffi_bitkitcore_fn_func_get_info(FfiConverterOptionBool.lower(refresh) + uniffi_bitkitcore_fn_func_jade_list_devices( ) }, pollFunc: ffi_bitkitcore_rust_future_poll_rust_buffer, completeFunc: ffi_bitkitcore_rust_future_complete_rust_buffer, freeFunc: ffi_bitkitcore_rust_future_free_rust_buffer, - liftFunc: FfiConverterOptionTypeIBtInfo.lift, - errorHandler: FfiConverterTypeBlocktankError_lift + liftFunc: FfiConverterSequenceTypeJadeDeviceInfo.lift, + errorHandler: nil + ) } -public func getLnurlInvoice(address: String, amountSatoshis: UInt64)async throws -> String { +/** + * Lock the device and zero its in-memory key material. + */ +public func jadeLogout()async throws { return try await uniffiRustCallAsync( rustFutureFunc: { - uniffi_bitkitcore_fn_func_get_lnurl_invoice(FfiConverterString.lower(address),FfiConverterUInt64.lower(amountSatoshis) + uniffi_bitkitcore_fn_func_jade_logout( ) }, - pollFunc: ffi_bitkitcore_rust_future_poll_rust_buffer, - completeFunc: ffi_bitkitcore_rust_future_complete_rust_buffer, - freeFunc: ffi_bitkitcore_rust_future_free_rust_buffer, - liftFunc: FfiConverterString.lift, - errorHandler: FfiConverterTypeLnurlError_lift + pollFunc: ffi_bitkitcore_rust_future_poll_void, + completeFunc: ffi_bitkitcore_rust_future_complete_void, + freeFunc: ffi_bitkitcore_rust_future_free_void, + liftFunc: { $0 }, + errorHandler: FfiConverterTypeJadeError_lift ) } -public func getLnurlInvoiceForPayData(data: LnurlPayData, amountMsats: UInt64, comment: String?)async throws -> String { +/** + * Tell the library that the native layer saw the device disconnect. + * + * Without this, an idle Bluetooth drop is invisible until the next request. + */ +public func jadeNotifyDisconnected(path: String)async { return - try await uniffiRustCallAsync( + try! await uniffiRustCallAsync( rustFutureFunc: { - uniffi_bitkitcore_fn_func_get_lnurl_invoice_for_pay_data(FfiConverterTypeLnurlPayData_lower(data),FfiConverterUInt64.lower(amountMsats),FfiConverterOptionString.lower(comment) + uniffi_bitkitcore_fn_func_jade_notify_disconnected(FfiConverterString.lower(path) ) }, - pollFunc: ffi_bitkitcore_rust_future_poll_rust_buffer, - completeFunc: ffi_bitkitcore_rust_future_complete_rust_buffer, - freeFunc: ffi_bitkitcore_rust_future_free_rust_buffer, - liftFunc: FfiConverterString.lift, - errorHandler: FfiConverterTypeLnurlError_lift + pollFunc: ffi_bitkitcore_rust_future_poll_void, + completeFunc: ffi_bitkitcore_rust_future_complete_void, + freeFunc: ffi_bitkitcore_rust_future_free_void, + liftFunc: { $0 }, + errorHandler: nil + ) } -public func getMinZeroConfTxFee(orderId: String)async throws -> IBt0ConfMinTxFeeWindow { +/** + * Check whether the device is idle, busy, or waiting on the user. + */ +public func jadePing()async throws -> JadePingStatus { return try await uniffiRustCallAsync( rustFutureFunc: { - uniffi_bitkitcore_fn_func_get_min_zero_conf_tx_fee(FfiConverterString.lower(orderId) + uniffi_bitkitcore_fn_func_jade_ping( ) }, pollFunc: ffi_bitkitcore_rust_future_poll_rust_buffer, completeFunc: ffi_bitkitcore_rust_future_complete_rust_buffer, freeFunc: ffi_bitkitcore_rust_future_free_rust_buffer, - liftFunc: FfiConverterTypeIBt0ConfMinTxFeeWindow_lift, - errorHandler: FfiConverterTypeBlocktankError_lift + liftFunc: FfiConverterTypeJadePingStatus_lift, + errorHandler: FfiConverterTypeJadeError_lift ) } -public func getOrders(orderIds: [String]?, filter: BtOrderState2?, refresh: Bool)async throws -> [IBtOrder] { +/** + * Re-read the version summary from the device. + */ +public func jadeRefreshVersionInfo()async throws -> JadeVersionInfo { return try await uniffiRustCallAsync( rustFutureFunc: { - uniffi_bitkitcore_fn_func_get_orders(FfiConverterOptionSequenceString.lower(orderIds),FfiConverterOptionTypeBtOrderState2.lower(filter),FfiConverterBool.lower(refresh) + uniffi_bitkitcore_fn_func_jade_refresh_version_info( ) }, pollFunc: ffi_bitkitcore_rust_future_poll_rust_buffer, completeFunc: ffi_bitkitcore_rust_future_complete_rust_buffer, freeFunc: ffi_bitkitcore_rust_future_free_rust_buffer, - liftFunc: FfiConverterSequenceTypeIBtOrder.lift, - errorHandler: FfiConverterTypeBlocktankError_lift + liftFunc: FfiConverterTypeJadeVersionInfo_lift, + errorHandler: FfiConverterTypeJadeError_lift ) } -public func getPayment(paymentId: String)async throws -> IBtBolt11Invoice { +/** + * Discover Jade devices. + * + * Bluetooth discovery is performed by the registered transport callback; on + * desktop and Python builds, attached USB serial units are enumerated too. + * Returns `DeviceBusy` while a connection is open, because starting a + * Bluetooth scan during an active link drops it on Android. + */ +public func jadeScan(timeoutMs: UInt32)async throws -> [JadeDeviceInfo] { return try await uniffiRustCallAsync( rustFutureFunc: { - uniffi_bitkitcore_fn_func_get_payment(FfiConverterString.lower(paymentId) + uniffi_bitkitcore_fn_func_jade_scan(FfiConverterUInt32.lower(timeoutMs) ) }, pollFunc: ffi_bitkitcore_rust_future_poll_rust_buffer, completeFunc: ffi_bitkitcore_rust_future_complete_rust_buffer, freeFunc: ffi_bitkitcore_rust_future_free_rust_buffer, - liftFunc: FfiConverterTypeIBtBolt11Invoice_lift, - errorHandler: FfiConverterTypeBlocktankError_lift + liftFunc: FfiConverterSequenceTypeJadeDeviceInfo.lift, + errorHandler: FfiConverterTypeJadeError_lift ) } -public func getPreActivityMetadata(walletId: String, searchKey: String, searchByAddress: Bool)throws -> PreActivityMetadata? { - return try FfiConverterOptionTypePreActivityMetadata.lift(try rustCallWithError(FfiConverterTypeActivityError_lift) { - uniffi_bitkitcore_fn_func_get_pre_activity_metadata( - FfiConverterString.lower(walletId), - FfiConverterString.lower(searchKey), - FfiConverterBool.lower(searchByAddress),$0 - ) -}) -} /** - * Pre-activity metadata for a single wallet scope, or every scope when `wallet_id` is `None`. + * Register the native transport. + * + * Returns `true` when this replaced a previously registered callback, which + * lets the application tell a fresh registration from a re-registration. */ -public func getPreActivityMetadataList(walletId: String?)throws -> [PreActivityMetadata] { - return try FfiConverterSequenceTypePreActivityMetadata.lift(try rustCallWithError(FfiConverterTypeActivityError_lift) { - uniffi_bitkitcore_fn_func_get_pre_activity_metadata_list( - FfiConverterOptionString.lower(walletId),$0 +public func jadeSetTransportCallback(callback: JadeTransportCallback) -> Bool { + return try! FfiConverterBool.lift(try! rustCall() { + uniffi_bitkitcore_fn_func_jade_set_transport_callback( + FfiConverterTypeJadeTransportCallback_lower(callback),$0 ) }) } /** - * The hardware-wallet models supported by Bitkit and their available transports. + * Sign a message, returning the signature with the address that verifies it. */ -public func getSupportedHardwareWallets() -> [SupportedHardwareWallet] { - return try! FfiConverterSequenceTypeSupportedHardwareWallet.lift(try! rustCall() { - uniffi_bitkitcore_fn_func_get_supported_hardware_wallets($0 - ) -}) -} -public func getTags(walletId: String, activityId: String)throws -> [String] { - return try FfiConverterSequenceString.lift(try rustCallWithError(FfiConverterTypeActivityError_lift) { - uniffi_bitkitcore_fn_func_get_tags( - FfiConverterString.lower(walletId), - FfiConverterString.lower(activityId),$0 - ) -}) -} -public func getTransactionDetails(walletId: String, txId: String)throws -> TransactionDetails? { - return try FfiConverterOptionTypeTransactionDetails.lift(try rustCallWithError(FfiConverterTypeActivityError_lift) { - uniffi_bitkitcore_fn_func_get_transaction_details( - FfiConverterString.lower(walletId), - FfiConverterString.lower(txId),$0 - ) -}) -} -public func giftOrder(clientNodeId: String, code: String)async throws -> IGift { +public func jadeSignMessage(network: JadeNetwork, derivationPath: String, message: String)async throws -> JadeSignedMessage { return try await uniffiRustCallAsync( rustFutureFunc: { - uniffi_bitkitcore_fn_func_gift_order(FfiConverterString.lower(clientNodeId),FfiConverterString.lower(code) + uniffi_bitkitcore_fn_func_jade_sign_message(FfiConverterTypeJadeNetwork_lower(network),FfiConverterString.lower(derivationPath),FfiConverterString.lower(message) ) }, pollFunc: ffi_bitkitcore_rust_future_poll_rust_buffer, completeFunc: ffi_bitkitcore_rust_future_complete_rust_buffer, freeFunc: ffi_bitkitcore_rust_future_free_rust_buffer, - liftFunc: FfiConverterTypeIGift_lift, - errorHandler: FfiConverterTypeBlocktankError_lift + liftFunc: FfiConverterTypeJadeSignedMessage_lift, + errorHandler: FfiConverterTypeJadeError_lift ) } -public func giftPay(invoice: String)async throws -> IGift { +/** + * Sign a PSBT, returning the signed PSBT base64 encoded. + * + * The reply is checked against what was sent before it is returned. Feed the + * result to `finalize_psbt` with the original PSBT, then broadcast with + * `onchain_broadcast_raw_tx`. + */ +public func jadeSignPsbt(network: JadeNetwork, psbt: String)async throws -> String { return try await uniffiRustCallAsync( rustFutureFunc: { - uniffi_bitkitcore_fn_func_gift_pay(FfiConverterString.lower(invoice) + uniffi_bitkitcore_fn_func_jade_sign_psbt(FfiConverterTypeJadeNetwork_lower(network),FfiConverterString.lower(psbt) ) }, pollFunc: ffi_bitkitcore_rust_future_poll_rust_buffer, completeFunc: ffi_bitkitcore_rust_future_complete_rust_buffer, freeFunc: ffi_bitkitcore_rust_future_free_rust_buffer, - liftFunc: FfiConverterTypeIGift_lift, - errorHandler: FfiConverterTypeBlocktankError_lift + liftFunc: FfiConverterString.lift, + errorHandler: FfiConverterTypeJadeError_lift ) } -public func initDb(basePath: String)throws -> String { - return try FfiConverterString.lift(try rustCallWithError(FfiConverterTypeDbError_lift) { - uniffi_bitkitcore_fn_func_init_db( - FfiConverterString.lower(basePath),$0 - ) -}) -} -public func insertActivity(activity: Activity)throws {try rustCallWithError(FfiConverterTypeActivityError_lift) { - uniffi_bitkitcore_fn_func_insert_activity( - FfiConverterTypeActivity_lower(activity),$0 - ) -} -} -public func isAddressUsed(address: String)throws -> Bool { - return try FfiConverterBool.lift(try rustCallWithError(FfiConverterTypeActivityError_lift) { - uniffi_bitkitcore_fn_func_is_address_used( - FfiConverterString.lower(address),$0 - ) -}) +/** + * Unlock the device for a network. + * + * Runs the blind pinserver exchange when the device asks for it, which needs + * network access. The PIN is entered on the device and never reaches the host. + */ +public func jadeUnlock(network: JadeNetwork)async throws { + return + try await uniffiRustCallAsync( + rustFutureFunc: { + uniffi_bitkitcore_fn_func_jade_unlock(FfiConverterTypeJadeNetwork_lower(network) + ) + }, + pollFunc: ffi_bitkitcore_rust_future_poll_void, + completeFunc: ffi_bitkitcore_rust_future_complete_void, + freeFunc: ffi_bitkitcore_rust_future_free_void, + liftFunc: { $0 }, + errorHandler: FfiConverterTypeJadeError_lift + ) } -public func isValidBip39Word(word: String) -> Bool { - return try! FfiConverterBool.lift(try! rustCall() { - uniffi_bitkitcore_fn_func_is_valid_bip39_word( - FfiConverterString.lower(word),$0 - ) -}) +/** + * Display an address on the device and check it against the expected one. + * + * This always prompts on the device screen, so it is a verification step + * rather than a way to fetch an address. Returns `AddressMismatch` when the + * device disagrees with `expected_address`. + */ +public func jadeVerifyAddress(network: JadeNetwork, variant: JadeAddressVariant, derivationPath: String, expectedAddress: String)async throws { + return + try await uniffiRustCallAsync( + rustFutureFunc: { + uniffi_bitkitcore_fn_func_jade_verify_address(FfiConverterTypeJadeNetwork_lower(network),FfiConverterTypeJadeAddressVariant_lower(variant),FfiConverterString.lower(derivationPath),FfiConverterString.lower(expectedAddress) + ) + }, + pollFunc: ffi_bitkitcore_rust_future_poll_void, + completeFunc: ffi_bitkitcore_rust_future_complete_void, + freeFunc: ffi_bitkitcore_rust_future_free_void, + liftFunc: { $0 }, + errorHandler: FfiConverterTypeJadeError_lift + ) } public func lnurlAuth(domain: String, k1: String, callback: String, bip32Mnemonic: String, network: Network?, bip39Passphrase: String?)async throws -> String { return @@ -25601,6 +28238,69 @@ private let initializationResult: InitializationResult = { if (uniffi_bitkitcore_checksum_func_is_valid_bip39_word() != 31846) { return InitializationResult.apiChecksumMismatch } + if (uniffi_bitkitcore_checksum_func_jade_account_type_to_variant() != 35222) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_bitkitcore_checksum_func_jade_cancel() != 64344) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_bitkitcore_checksum_func_jade_connect() != 62038) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_bitkitcore_checksum_func_jade_disconnect() != 22575) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_bitkitcore_checksum_func_jade_get_account_export() != 39143) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_bitkitcore_checksum_func_jade_get_connected_device() != 31749) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_bitkitcore_checksum_func_jade_get_master_fingerprint() != 29630) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_bitkitcore_checksum_func_jade_get_version_info() != 28653) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_bitkitcore_checksum_func_jade_get_xpub() != 51180) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_bitkitcore_checksum_func_jade_is_connected() != 16304) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_bitkitcore_checksum_func_jade_list_devices() != 31161) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_bitkitcore_checksum_func_jade_logout() != 2301) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_bitkitcore_checksum_func_jade_notify_disconnected() != 24935) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_bitkitcore_checksum_func_jade_ping() != 45620) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_bitkitcore_checksum_func_jade_refresh_version_info() != 52539) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_bitkitcore_checksum_func_jade_scan() != 445) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_bitkitcore_checksum_func_jade_set_transport_callback() != 61572) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_bitkitcore_checksum_func_jade_sign_message() != 257) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_bitkitcore_checksum_func_jade_sign_psbt() != 20865) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_bitkitcore_checksum_func_jade_unlock() != 35535) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_bitkitcore_checksum_func_jade_verify_address() != 54249) { + return InitializationResult.apiChecksumMismatch + } if (uniffi_bitkitcore_checksum_func_lnurl_auth() != 58593) { return InitializationResult.apiChecksumMismatch } @@ -25883,6 +28583,24 @@ private let initializationResult: InitializationResult = { if (uniffi_bitkitcore_checksum_method_eventlistener_on_event() != 35531) { return InitializationResult.apiChecksumMismatch } + if (uniffi_bitkitcore_checksum_method_jadetransportcallback_scan_devices() != 38147) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_bitkitcore_checksum_method_jadetransportcallback_open_device() != 21299) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_bitkitcore_checksum_method_jadetransportcallback_close_device() != 16955) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_bitkitcore_checksum_method_jadetransportcallback_write_chunk() != 12779) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_bitkitcore_checksum_method_jadetransportcallback_read_chunk() != 21790) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_bitkitcore_checksum_method_jadetransportcallback_get_chunk_size() != 29973) { + return InitializationResult.apiChecksumMismatch + } if (uniffi_bitkitcore_checksum_method_trezortransportcallback_enumerate_devices() != 18766) { return InitializationResult.apiChecksumMismatch } @@ -25934,6 +28652,7 @@ private let initializationResult: InitializationResult = { uniffiCallbackInitBoltzEventListener() uniffiCallbackInitEventListener() + uniffiCallbackInitJadeTransportCallback() uniffiCallbackInitTrezorTransportCallback() uniffiCallbackInitTrezorUiCallback() return InitializationResult.ok diff --git a/bindings/ios/bitkitcoreFFI.h b/bindings/ios/bitkitcoreFFI.h index 79b2fb2..b4dc45f 100644 --- a/bindings/ios/bitkitcoreFFI.h +++ b/bindings/ios/bitkitcoreFFI.h @@ -264,6 +264,48 @@ typedef void (*UniffiCallbackInterfaceEventListenerMethod0)(uint64_t, RustBuffer RustCallStatus *_Nonnull uniffiCallStatus ); +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_JADE_TRANSPORT_CALLBACK_METHOD0 +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_JADE_TRANSPORT_CALLBACK_METHOD0 +typedef void (*UniffiCallbackInterfaceJadeTransportCallbackMethod0)(uint64_t, uint32_t, RustBuffer* _Nonnull, + RustCallStatus *_Nonnull uniffiCallStatus + ); + +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_JADE_TRANSPORT_CALLBACK_METHOD1 +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_JADE_TRANSPORT_CALLBACK_METHOD1 +typedef void (*UniffiCallbackInterfaceJadeTransportCallbackMethod1)(uint64_t, RustBuffer, RustBuffer* _Nonnull, + RustCallStatus *_Nonnull uniffiCallStatus + ); + +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_JADE_TRANSPORT_CALLBACK_METHOD2 +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_JADE_TRANSPORT_CALLBACK_METHOD2 +typedef void (*UniffiCallbackInterfaceJadeTransportCallbackMethod2)(uint64_t, RustBuffer, RustBuffer* _Nonnull, + RustCallStatus *_Nonnull uniffiCallStatus + ); + +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_JADE_TRANSPORT_CALLBACK_METHOD3 +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_JADE_TRANSPORT_CALLBACK_METHOD3 +typedef void (*UniffiCallbackInterfaceJadeTransportCallbackMethod3)(uint64_t, RustBuffer, RustBuffer, RustBuffer* _Nonnull, + RustCallStatus *_Nonnull uniffiCallStatus + ); + +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_JADE_TRANSPORT_CALLBACK_METHOD4 +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_JADE_TRANSPORT_CALLBACK_METHOD4 +typedef void (*UniffiCallbackInterfaceJadeTransportCallbackMethod4)(uint64_t, RustBuffer, uint32_t, RustBuffer* _Nonnull, + RustCallStatus *_Nonnull uniffiCallStatus + ); + +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_JADE_TRANSPORT_CALLBACK_METHOD5 +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_JADE_TRANSPORT_CALLBACK_METHOD5 +typedef void (*UniffiCallbackInterfaceJadeTransportCallbackMethod5)(uint64_t, RustBuffer, uint32_t* _Nonnull, + RustCallStatus *_Nonnull uniffiCallStatus + ); + #endif #ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD0 #define UNIFFI_FFIDEF_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD0 @@ -371,6 +413,19 @@ typedef struct UniffiVTableCallbackInterfaceEventListener { UniffiCallbackInterfaceFree _Nonnull uniffiFree; } UniffiVTableCallbackInterfaceEventListener; +#endif +#ifndef UNIFFI_FFIDEF_V_TABLE_CALLBACK_INTERFACE_JADE_TRANSPORT_CALLBACK +#define UNIFFI_FFIDEF_V_TABLE_CALLBACK_INTERFACE_JADE_TRANSPORT_CALLBACK +typedef struct UniffiVTableCallbackInterfaceJadeTransportCallback { + UniffiCallbackInterfaceJadeTransportCallbackMethod0 _Nonnull scanDevices; + UniffiCallbackInterfaceJadeTransportCallbackMethod1 _Nonnull openDevice; + UniffiCallbackInterfaceJadeTransportCallbackMethod2 _Nonnull closeDevice; + UniffiCallbackInterfaceJadeTransportCallbackMethod3 _Nonnull writeChunk; + UniffiCallbackInterfaceJadeTransportCallbackMethod4 _Nonnull readChunk; + UniffiCallbackInterfaceJadeTransportCallbackMethod5 _Nonnull getChunkSize; + UniffiCallbackInterfaceFree _Nonnull uniffiFree; +} UniffiVTableCallbackInterfaceJadeTransportCallback; + #endif #ifndef UNIFFI_FFIDEF_V_TABLE_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK #define UNIFFI_FFIDEF_V_TABLE_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK @@ -439,6 +494,51 @@ void uniffi_bitkitcore_fn_init_callback_vtable_eventlistener(const UniffiVTableC void uniffi_bitkitcore_fn_method_eventlistener_on_event(void*_Nonnull ptr, RustBuffer watcher_id, RustBuffer event, RustCallStatus *_Nonnull out_status ); #endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_CLONE_JADETRANSPORTCALLBACK +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_CLONE_JADETRANSPORTCALLBACK +void*_Nonnull uniffi_bitkitcore_fn_clone_jadetransportcallback(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FREE_JADETRANSPORTCALLBACK +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FREE_JADETRANSPORTCALLBACK +void uniffi_bitkitcore_fn_free_jadetransportcallback(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_INIT_CALLBACK_VTABLE_JADETRANSPORTCALLBACK +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_INIT_CALLBACK_VTABLE_JADETRANSPORTCALLBACK +void uniffi_bitkitcore_fn_init_callback_vtable_jadetransportcallback(const UniffiVTableCallbackInterfaceJadeTransportCallback* _Nonnull vtable +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_JADETRANSPORTCALLBACK_SCAN_DEVICES +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_JADETRANSPORTCALLBACK_SCAN_DEVICES +RustBuffer uniffi_bitkitcore_fn_method_jadetransportcallback_scan_devices(void*_Nonnull ptr, uint32_t timeout_ms, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_JADETRANSPORTCALLBACK_OPEN_DEVICE +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_JADETRANSPORTCALLBACK_OPEN_DEVICE +RustBuffer uniffi_bitkitcore_fn_method_jadetransportcallback_open_device(void*_Nonnull ptr, RustBuffer path, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_JADETRANSPORTCALLBACK_CLOSE_DEVICE +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_JADETRANSPORTCALLBACK_CLOSE_DEVICE +RustBuffer uniffi_bitkitcore_fn_method_jadetransportcallback_close_device(void*_Nonnull ptr, RustBuffer path, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_JADETRANSPORTCALLBACK_WRITE_CHUNK +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_JADETRANSPORTCALLBACK_WRITE_CHUNK +RustBuffer uniffi_bitkitcore_fn_method_jadetransportcallback_write_chunk(void*_Nonnull ptr, RustBuffer path, RustBuffer data, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_JADETRANSPORTCALLBACK_READ_CHUNK +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_JADETRANSPORTCALLBACK_READ_CHUNK +RustBuffer uniffi_bitkitcore_fn_method_jadetransportcallback_read_chunk(void*_Nonnull ptr, RustBuffer path, uint32_t timeout_ms, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_JADETRANSPORTCALLBACK_GET_CHUNK_SIZE +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_METHOD_JADETRANSPORTCALLBACK_GET_CHUNK_SIZE +uint32_t uniffi_bitkitcore_fn_method_jadetransportcallback_get_chunk_size(void*_Nonnull ptr, RustBuffer path, RustCallStatus *_Nonnull out_status +); +#endif #ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_CLONE_TREZORTRANSPORTCALLBACK #define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_CLONE_TREZORTRANSPORTCALLBACK void*_Nonnull uniffi_bitkitcore_fn_clone_trezortransportcallback(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status @@ -1022,6 +1122,120 @@ int8_t uniffi_bitkitcore_fn_func_is_address_used(RustBuffer address, RustCallSta int8_t uniffi_bitkitcore_fn_func_is_valid_bip39_word(RustBuffer word, RustCallStatus *_Nonnull out_status ); #endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_ACCOUNT_TYPE_TO_VARIANT +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_ACCOUNT_TYPE_TO_VARIANT +RustBuffer uniffi_bitkitcore_fn_func_jade_account_type_to_variant(RustBuffer account_type, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_CANCEL +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_CANCEL +uint64_t uniffi_bitkitcore_fn_func_jade_cancel(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_CONNECT +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_CONNECT +uint64_t uniffi_bitkitcore_fn_func_jade_connect(RustBuffer transport, RustBuffer path +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_DISCONNECT +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_DISCONNECT +uint64_t uniffi_bitkitcore_fn_func_jade_disconnect(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_GET_ACCOUNT_EXPORT +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_GET_ACCOUNT_EXPORT +uint64_t uniffi_bitkitcore_fn_func_jade_get_account_export(RustBuffer network, uint32_t account_index, RustBuffer account_types +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_GET_CONNECTED_DEVICE +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_GET_CONNECTED_DEVICE +uint64_t uniffi_bitkitcore_fn_func_jade_get_connected_device(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_GET_MASTER_FINGERPRINT +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_GET_MASTER_FINGERPRINT +uint64_t uniffi_bitkitcore_fn_func_jade_get_master_fingerprint(RustBuffer network +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_GET_VERSION_INFO +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_GET_VERSION_INFO +uint64_t uniffi_bitkitcore_fn_func_jade_get_version_info(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_GET_XPUB +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_GET_XPUB +uint64_t uniffi_bitkitcore_fn_func_jade_get_xpub(RustBuffer network, RustBuffer derivation_path +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_IS_CONNECTED +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_IS_CONNECTED +int8_t uniffi_bitkitcore_fn_func_jade_is_connected(RustCallStatus *_Nonnull out_status + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_LIST_DEVICES +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_LIST_DEVICES +uint64_t uniffi_bitkitcore_fn_func_jade_list_devices(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_LOGOUT +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_LOGOUT +uint64_t uniffi_bitkitcore_fn_func_jade_logout(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_NOTIFY_DISCONNECTED +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_NOTIFY_DISCONNECTED +uint64_t uniffi_bitkitcore_fn_func_jade_notify_disconnected(RustBuffer path +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_PING +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_PING +uint64_t uniffi_bitkitcore_fn_func_jade_ping(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_REFRESH_VERSION_INFO +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_REFRESH_VERSION_INFO +uint64_t uniffi_bitkitcore_fn_func_jade_refresh_version_info(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_SCAN +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_SCAN +uint64_t uniffi_bitkitcore_fn_func_jade_scan(uint32_t timeout_ms +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_SET_TRANSPORT_CALLBACK +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_SET_TRANSPORT_CALLBACK +int8_t uniffi_bitkitcore_fn_func_jade_set_transport_callback(void*_Nonnull callback, RustCallStatus *_Nonnull out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_SIGN_MESSAGE +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_SIGN_MESSAGE +uint64_t uniffi_bitkitcore_fn_func_jade_sign_message(RustBuffer network, RustBuffer derivation_path, RustBuffer message +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_SIGN_PSBT +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_SIGN_PSBT +uint64_t uniffi_bitkitcore_fn_func_jade_sign_psbt(RustBuffer network, RustBuffer psbt +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_UNLOCK +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_UNLOCK +uint64_t uniffi_bitkitcore_fn_func_jade_unlock(RustBuffer network +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_VERIFY_ADDRESS +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_JADE_VERIFY_ADDRESS +uint64_t uniffi_bitkitcore_fn_func_jade_verify_address(RustBuffer network, RustBuffer variant, RustBuffer derivation_path, RustBuffer expected_address +); +#endif #ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_LNURL_AUTH #define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_FN_FUNC_LNURL_AUTH uint64_t uniffi_bitkitcore_fn_func_lnurl_auth(RustBuffer domain, RustBuffer k1, RustBuffer callback, RustBuffer bip32_mnemonic, RustBuffer network, RustBuffer bip39_passphrase @@ -2310,6 +2524,132 @@ uint16_t uniffi_bitkitcore_checksum_func_is_address_used(void #define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_IS_VALID_BIP39_WORD uint16_t uniffi_bitkitcore_checksum_func_is_valid_bip39_word(void +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_ACCOUNT_TYPE_TO_VARIANT +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_ACCOUNT_TYPE_TO_VARIANT +uint16_t uniffi_bitkitcore_checksum_func_jade_account_type_to_variant(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_CANCEL +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_CANCEL +uint16_t uniffi_bitkitcore_checksum_func_jade_cancel(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_CONNECT +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_CONNECT +uint16_t uniffi_bitkitcore_checksum_func_jade_connect(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_DISCONNECT +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_DISCONNECT +uint16_t uniffi_bitkitcore_checksum_func_jade_disconnect(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_GET_ACCOUNT_EXPORT +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_GET_ACCOUNT_EXPORT +uint16_t uniffi_bitkitcore_checksum_func_jade_get_account_export(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_GET_CONNECTED_DEVICE +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_GET_CONNECTED_DEVICE +uint16_t uniffi_bitkitcore_checksum_func_jade_get_connected_device(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_GET_MASTER_FINGERPRINT +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_GET_MASTER_FINGERPRINT +uint16_t uniffi_bitkitcore_checksum_func_jade_get_master_fingerprint(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_GET_VERSION_INFO +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_GET_VERSION_INFO +uint16_t uniffi_bitkitcore_checksum_func_jade_get_version_info(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_GET_XPUB +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_GET_XPUB +uint16_t uniffi_bitkitcore_checksum_func_jade_get_xpub(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_IS_CONNECTED +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_IS_CONNECTED +uint16_t uniffi_bitkitcore_checksum_func_jade_is_connected(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_LIST_DEVICES +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_LIST_DEVICES +uint16_t uniffi_bitkitcore_checksum_func_jade_list_devices(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_LOGOUT +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_LOGOUT +uint16_t uniffi_bitkitcore_checksum_func_jade_logout(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_NOTIFY_DISCONNECTED +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_NOTIFY_DISCONNECTED +uint16_t uniffi_bitkitcore_checksum_func_jade_notify_disconnected(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_PING +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_PING +uint16_t uniffi_bitkitcore_checksum_func_jade_ping(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_REFRESH_VERSION_INFO +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_REFRESH_VERSION_INFO +uint16_t uniffi_bitkitcore_checksum_func_jade_refresh_version_info(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_SCAN +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_SCAN +uint16_t uniffi_bitkitcore_checksum_func_jade_scan(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_SET_TRANSPORT_CALLBACK +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_SET_TRANSPORT_CALLBACK +uint16_t uniffi_bitkitcore_checksum_func_jade_set_transport_callback(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_SIGN_MESSAGE +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_SIGN_MESSAGE +uint16_t uniffi_bitkitcore_checksum_func_jade_sign_message(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_SIGN_PSBT +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_SIGN_PSBT +uint16_t uniffi_bitkitcore_checksum_func_jade_sign_psbt(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_UNLOCK +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_UNLOCK +uint16_t uniffi_bitkitcore_checksum_func_jade_unlock(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_VERIFY_ADDRESS +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_JADE_VERIFY_ADDRESS +uint16_t uniffi_bitkitcore_checksum_func_jade_verify_address(void + ); #endif #ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_FUNC_LNURL_AUTH @@ -2874,6 +3214,42 @@ uint16_t uniffi_bitkitcore_checksum_method_boltzeventlistener_on_event(void #define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_EVENTLISTENER_ON_EVENT uint16_t uniffi_bitkitcore_checksum_method_eventlistener_on_event(void +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_JADETRANSPORTCALLBACK_SCAN_DEVICES +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_JADETRANSPORTCALLBACK_SCAN_DEVICES +uint16_t uniffi_bitkitcore_checksum_method_jadetransportcallback_scan_devices(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_JADETRANSPORTCALLBACK_OPEN_DEVICE +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_JADETRANSPORTCALLBACK_OPEN_DEVICE +uint16_t uniffi_bitkitcore_checksum_method_jadetransportcallback_open_device(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_JADETRANSPORTCALLBACK_CLOSE_DEVICE +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_JADETRANSPORTCALLBACK_CLOSE_DEVICE +uint16_t uniffi_bitkitcore_checksum_method_jadetransportcallback_close_device(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_JADETRANSPORTCALLBACK_WRITE_CHUNK +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_JADETRANSPORTCALLBACK_WRITE_CHUNK +uint16_t uniffi_bitkitcore_checksum_method_jadetransportcallback_write_chunk(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_JADETRANSPORTCALLBACK_READ_CHUNK +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_JADETRANSPORTCALLBACK_READ_CHUNK +uint16_t uniffi_bitkitcore_checksum_method_jadetransportcallback_read_chunk(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_JADETRANSPORTCALLBACK_GET_CHUNK_SIZE +#define UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_JADETRANSPORTCALLBACK_GET_CHUNK_SIZE +uint16_t uniffi_bitkitcore_checksum_method_jadetransportcallback_get_chunk_size(void + ); #endif #ifndef UNIFFI_FFIDEF_UNIFFI_BITKITCORE_CHECKSUM_METHOD_TREZORTRANSPORTCALLBACK_ENUMERATE_DEVICES diff --git a/bindings/python/bitkitcore/bitkitcore.py b/bindings/python/bitkitcore/bitkitcore.py index 5f7e508..29a41ee 100644 --- a/bindings/python/bitkitcore/bitkitcore.py +++ b/bindings/python/bitkitcore/bitkitcore.py @@ -639,6 +639,48 @@ def _uniffi_check_api_checksums(lib): raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_bitkitcore_checksum_func_is_valid_bip39_word() != 31846: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_bitkitcore_checksum_func_jade_account_type_to_variant() != 35222: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_bitkitcore_checksum_func_jade_cancel() != 64344: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_bitkitcore_checksum_func_jade_connect() != 62038: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_bitkitcore_checksum_func_jade_disconnect() != 22575: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_bitkitcore_checksum_func_jade_get_account_export() != 39143: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_bitkitcore_checksum_func_jade_get_connected_device() != 31749: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_bitkitcore_checksum_func_jade_get_master_fingerprint() != 29630: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_bitkitcore_checksum_func_jade_get_version_info() != 28653: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_bitkitcore_checksum_func_jade_get_xpub() != 51180: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_bitkitcore_checksum_func_jade_is_connected() != 16304: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_bitkitcore_checksum_func_jade_list_devices() != 31161: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_bitkitcore_checksum_func_jade_logout() != 2301: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_bitkitcore_checksum_func_jade_notify_disconnected() != 24935: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_bitkitcore_checksum_func_jade_ping() != 45620: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_bitkitcore_checksum_func_jade_refresh_version_info() != 52539: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_bitkitcore_checksum_func_jade_scan() != 445: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_bitkitcore_checksum_func_jade_set_transport_callback() != 61572: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_bitkitcore_checksum_func_jade_sign_message() != 257: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_bitkitcore_checksum_func_jade_sign_psbt() != 20865: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_bitkitcore_checksum_func_jade_unlock() != 35535: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_bitkitcore_checksum_func_jade_verify_address() != 54249: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_bitkitcore_checksum_func_lnurl_auth() != 58593: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_bitkitcore_checksum_func_mark_activity_as_seen() != 36622: @@ -827,6 +869,18 @@ def _uniffi_check_api_checksums(lib): raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_bitkitcore_checksum_method_eventlistener_on_event() != 35531: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_bitkitcore_checksum_method_jadetransportcallback_scan_devices() != 38147: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_bitkitcore_checksum_method_jadetransportcallback_open_device() != 21299: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_bitkitcore_checksum_method_jadetransportcallback_close_device() != 16955: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_bitkitcore_checksum_method_jadetransportcallback_write_chunk() != 12779: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_bitkitcore_checksum_method_jadetransportcallback_read_chunk() != 21790: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_bitkitcore_checksum_method_jadetransportcallback_get_chunk_size() != 29973: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_bitkitcore_checksum_method_trezortransportcallback_enumerate_devices() != 18766: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_bitkitcore_checksum_method_trezortransportcallback_open_device() != 44156: @@ -971,6 +1025,24 @@ class _UniffiForeignFutureStructVoid(ctypes.Structure): _UNIFFI_CALLBACK_INTERFACE_EVENT_LISTENER_METHOD0 = ctypes.CFUNCTYPE(None,ctypes.c_uint64,_UniffiRustBuffer,_UniffiRustBuffer,ctypes.c_void_p, ctypes.POINTER(_UniffiRustCallStatus), ) +_UNIFFI_CALLBACK_INTERFACE_JADE_TRANSPORT_CALLBACK_METHOD0 = ctypes.CFUNCTYPE(None,ctypes.c_uint64,ctypes.c_uint32,ctypes.POINTER(_UniffiRustBuffer), + ctypes.POINTER(_UniffiRustCallStatus), +) +_UNIFFI_CALLBACK_INTERFACE_JADE_TRANSPORT_CALLBACK_METHOD1 = ctypes.CFUNCTYPE(None,ctypes.c_uint64,_UniffiRustBuffer,ctypes.POINTER(_UniffiRustBuffer), + ctypes.POINTER(_UniffiRustCallStatus), +) +_UNIFFI_CALLBACK_INTERFACE_JADE_TRANSPORT_CALLBACK_METHOD2 = ctypes.CFUNCTYPE(None,ctypes.c_uint64,_UniffiRustBuffer,ctypes.POINTER(_UniffiRustBuffer), + ctypes.POINTER(_UniffiRustCallStatus), +) +_UNIFFI_CALLBACK_INTERFACE_JADE_TRANSPORT_CALLBACK_METHOD3 = ctypes.CFUNCTYPE(None,ctypes.c_uint64,_UniffiRustBuffer,_UniffiRustBuffer,ctypes.POINTER(_UniffiRustBuffer), + ctypes.POINTER(_UniffiRustCallStatus), +) +_UNIFFI_CALLBACK_INTERFACE_JADE_TRANSPORT_CALLBACK_METHOD4 = ctypes.CFUNCTYPE(None,ctypes.c_uint64,_UniffiRustBuffer,ctypes.c_uint32,ctypes.POINTER(_UniffiRustBuffer), + ctypes.POINTER(_UniffiRustCallStatus), +) +_UNIFFI_CALLBACK_INTERFACE_JADE_TRANSPORT_CALLBACK_METHOD5 = ctypes.CFUNCTYPE(None,ctypes.c_uint64,_UniffiRustBuffer,ctypes.POINTER(ctypes.c_uint32), + ctypes.POINTER(_UniffiRustCallStatus), +) _UNIFFI_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD0 = ctypes.CFUNCTYPE(None,ctypes.c_uint64,ctypes.POINTER(_UniffiRustBuffer), ctypes.POINTER(_UniffiRustCallStatus), ) @@ -1020,6 +1092,16 @@ class _UniffiVTableCallbackInterfaceEventListener(ctypes.Structure): ("on_event", _UNIFFI_CALLBACK_INTERFACE_EVENT_LISTENER_METHOD0), ("uniffi_free", _UNIFFI_CALLBACK_INTERFACE_FREE), ] +class _UniffiVTableCallbackInterfaceJadeTransportCallback(ctypes.Structure): + _fields_ = [ + ("scan_devices", _UNIFFI_CALLBACK_INTERFACE_JADE_TRANSPORT_CALLBACK_METHOD0), + ("open_device", _UNIFFI_CALLBACK_INTERFACE_JADE_TRANSPORT_CALLBACK_METHOD1), + ("close_device", _UNIFFI_CALLBACK_INTERFACE_JADE_TRANSPORT_CALLBACK_METHOD2), + ("write_chunk", _UNIFFI_CALLBACK_INTERFACE_JADE_TRANSPORT_CALLBACK_METHOD3), + ("read_chunk", _UNIFFI_CALLBACK_INTERFACE_JADE_TRANSPORT_CALLBACK_METHOD4), + ("get_chunk_size", _UNIFFI_CALLBACK_INTERFACE_JADE_TRANSPORT_CALLBACK_METHOD5), + ("uniffi_free", _UNIFFI_CALLBACK_INTERFACE_FREE), + ] class _UniffiVTableCallbackInterfaceTrezorTransportCallback(ctypes.Structure): _fields_ = [ ("enumerate_devices", _UNIFFI_CALLBACK_INTERFACE_TREZOR_TRANSPORT_CALLBACK_METHOD0), @@ -1082,6 +1164,58 @@ class _UniffiVTableCallbackInterfaceTrezorUiCallback(ctypes.Structure): ctypes.POINTER(_UniffiRustCallStatus), ) _UniffiLib.uniffi_bitkitcore_fn_method_eventlistener_on_event.restype = None +_UniffiLib.uniffi_bitkitcore_fn_clone_jadetransportcallback.argtypes = ( + ctypes.c_void_p, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_bitkitcore_fn_clone_jadetransportcallback.restype = ctypes.c_void_p +_UniffiLib.uniffi_bitkitcore_fn_free_jadetransportcallback.argtypes = ( + ctypes.c_void_p, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_bitkitcore_fn_free_jadetransportcallback.restype = None +_UniffiLib.uniffi_bitkitcore_fn_init_callback_vtable_jadetransportcallback.argtypes = ( + ctypes.POINTER(_UniffiVTableCallbackInterfaceJadeTransportCallback), +) +_UniffiLib.uniffi_bitkitcore_fn_init_callback_vtable_jadetransportcallback.restype = None +_UniffiLib.uniffi_bitkitcore_fn_method_jadetransportcallback_scan_devices.argtypes = ( + ctypes.c_void_p, + ctypes.c_uint32, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_bitkitcore_fn_method_jadetransportcallback_scan_devices.restype = _UniffiRustBuffer +_UniffiLib.uniffi_bitkitcore_fn_method_jadetransportcallback_open_device.argtypes = ( + ctypes.c_void_p, + _UniffiRustBuffer, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_bitkitcore_fn_method_jadetransportcallback_open_device.restype = _UniffiRustBuffer +_UniffiLib.uniffi_bitkitcore_fn_method_jadetransportcallback_close_device.argtypes = ( + ctypes.c_void_p, + _UniffiRustBuffer, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_bitkitcore_fn_method_jadetransportcallback_close_device.restype = _UniffiRustBuffer +_UniffiLib.uniffi_bitkitcore_fn_method_jadetransportcallback_write_chunk.argtypes = ( + ctypes.c_void_p, + _UniffiRustBuffer, + _UniffiRustBuffer, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_bitkitcore_fn_method_jadetransportcallback_write_chunk.restype = _UniffiRustBuffer +_UniffiLib.uniffi_bitkitcore_fn_method_jadetransportcallback_read_chunk.argtypes = ( + ctypes.c_void_p, + _UniffiRustBuffer, + ctypes.c_uint32, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_bitkitcore_fn_method_jadetransportcallback_read_chunk.restype = _UniffiRustBuffer +_UniffiLib.uniffi_bitkitcore_fn_method_jadetransportcallback_get_chunk_size.argtypes = ( + ctypes.c_void_p, + _UniffiRustBuffer, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_bitkitcore_fn_method_jadetransportcallback_get_chunk_size.restype = ctypes.c_uint32 _UniffiLib.uniffi_bitkitcore_fn_clone_trezortransportcallback.argtypes = ( ctypes.c_void_p, ctypes.POINTER(_UniffiRustCallStatus), @@ -1702,6 +1836,94 @@ class _UniffiVTableCallbackInterfaceTrezorUiCallback(ctypes.Structure): ctypes.POINTER(_UniffiRustCallStatus), ) _UniffiLib.uniffi_bitkitcore_fn_func_is_valid_bip39_word.restype = ctypes.c_int8 +_UniffiLib.uniffi_bitkitcore_fn_func_jade_account_type_to_variant.argtypes = ( + _UniffiRustBuffer, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_bitkitcore_fn_func_jade_account_type_to_variant.restype = _UniffiRustBuffer +_UniffiLib.uniffi_bitkitcore_fn_func_jade_cancel.argtypes = ( +) +_UniffiLib.uniffi_bitkitcore_fn_func_jade_cancel.restype = ctypes.c_uint64 +_UniffiLib.uniffi_bitkitcore_fn_func_jade_connect.argtypes = ( + _UniffiRustBuffer, + _UniffiRustBuffer, +) +_UniffiLib.uniffi_bitkitcore_fn_func_jade_connect.restype = ctypes.c_uint64 +_UniffiLib.uniffi_bitkitcore_fn_func_jade_disconnect.argtypes = ( +) +_UniffiLib.uniffi_bitkitcore_fn_func_jade_disconnect.restype = ctypes.c_uint64 +_UniffiLib.uniffi_bitkitcore_fn_func_jade_get_account_export.argtypes = ( + _UniffiRustBuffer, + ctypes.c_uint32, + _UniffiRustBuffer, +) +_UniffiLib.uniffi_bitkitcore_fn_func_jade_get_account_export.restype = ctypes.c_uint64 +_UniffiLib.uniffi_bitkitcore_fn_func_jade_get_connected_device.argtypes = ( +) +_UniffiLib.uniffi_bitkitcore_fn_func_jade_get_connected_device.restype = ctypes.c_uint64 +_UniffiLib.uniffi_bitkitcore_fn_func_jade_get_master_fingerprint.argtypes = ( + _UniffiRustBuffer, +) +_UniffiLib.uniffi_bitkitcore_fn_func_jade_get_master_fingerprint.restype = ctypes.c_uint64 +_UniffiLib.uniffi_bitkitcore_fn_func_jade_get_version_info.argtypes = ( +) +_UniffiLib.uniffi_bitkitcore_fn_func_jade_get_version_info.restype = ctypes.c_uint64 +_UniffiLib.uniffi_bitkitcore_fn_func_jade_get_xpub.argtypes = ( + _UniffiRustBuffer, + _UniffiRustBuffer, +) +_UniffiLib.uniffi_bitkitcore_fn_func_jade_get_xpub.restype = ctypes.c_uint64 +_UniffiLib.uniffi_bitkitcore_fn_func_jade_is_connected.argtypes = ( + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_bitkitcore_fn_func_jade_is_connected.restype = ctypes.c_int8 +_UniffiLib.uniffi_bitkitcore_fn_func_jade_list_devices.argtypes = ( +) +_UniffiLib.uniffi_bitkitcore_fn_func_jade_list_devices.restype = ctypes.c_uint64 +_UniffiLib.uniffi_bitkitcore_fn_func_jade_logout.argtypes = ( +) +_UniffiLib.uniffi_bitkitcore_fn_func_jade_logout.restype = ctypes.c_uint64 +_UniffiLib.uniffi_bitkitcore_fn_func_jade_notify_disconnected.argtypes = ( + _UniffiRustBuffer, +) +_UniffiLib.uniffi_bitkitcore_fn_func_jade_notify_disconnected.restype = ctypes.c_uint64 +_UniffiLib.uniffi_bitkitcore_fn_func_jade_ping.argtypes = ( +) +_UniffiLib.uniffi_bitkitcore_fn_func_jade_ping.restype = ctypes.c_uint64 +_UniffiLib.uniffi_bitkitcore_fn_func_jade_refresh_version_info.argtypes = ( +) +_UniffiLib.uniffi_bitkitcore_fn_func_jade_refresh_version_info.restype = ctypes.c_uint64 +_UniffiLib.uniffi_bitkitcore_fn_func_jade_scan.argtypes = ( + ctypes.c_uint32, +) +_UniffiLib.uniffi_bitkitcore_fn_func_jade_scan.restype = ctypes.c_uint64 +_UniffiLib.uniffi_bitkitcore_fn_func_jade_set_transport_callback.argtypes = ( + ctypes.c_void_p, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_bitkitcore_fn_func_jade_set_transport_callback.restype = ctypes.c_int8 +_UniffiLib.uniffi_bitkitcore_fn_func_jade_sign_message.argtypes = ( + _UniffiRustBuffer, + _UniffiRustBuffer, + _UniffiRustBuffer, +) +_UniffiLib.uniffi_bitkitcore_fn_func_jade_sign_message.restype = ctypes.c_uint64 +_UniffiLib.uniffi_bitkitcore_fn_func_jade_sign_psbt.argtypes = ( + _UniffiRustBuffer, + _UniffiRustBuffer, +) +_UniffiLib.uniffi_bitkitcore_fn_func_jade_sign_psbt.restype = ctypes.c_uint64 +_UniffiLib.uniffi_bitkitcore_fn_func_jade_unlock.argtypes = ( + _UniffiRustBuffer, +) +_UniffiLib.uniffi_bitkitcore_fn_func_jade_unlock.restype = ctypes.c_uint64 +_UniffiLib.uniffi_bitkitcore_fn_func_jade_verify_address.argtypes = ( + _UniffiRustBuffer, + _UniffiRustBuffer, + _UniffiRustBuffer, + _UniffiRustBuffer, +) +_UniffiLib.uniffi_bitkitcore_fn_func_jade_verify_address.restype = ctypes.c_uint64 _UniffiLib.uniffi_bitkitcore_fn_func_lnurl_auth.argtypes = ( _UniffiRustBuffer, _UniffiRustBuffer, @@ -2700,6 +2922,69 @@ class _UniffiVTableCallbackInterfaceTrezorUiCallback(ctypes.Structure): _UniffiLib.uniffi_bitkitcore_checksum_func_is_valid_bip39_word.argtypes = ( ) _UniffiLib.uniffi_bitkitcore_checksum_func_is_valid_bip39_word.restype = ctypes.c_uint16 +_UniffiLib.uniffi_bitkitcore_checksum_func_jade_account_type_to_variant.argtypes = ( +) +_UniffiLib.uniffi_bitkitcore_checksum_func_jade_account_type_to_variant.restype = ctypes.c_uint16 +_UniffiLib.uniffi_bitkitcore_checksum_func_jade_cancel.argtypes = ( +) +_UniffiLib.uniffi_bitkitcore_checksum_func_jade_cancel.restype = ctypes.c_uint16 +_UniffiLib.uniffi_bitkitcore_checksum_func_jade_connect.argtypes = ( +) +_UniffiLib.uniffi_bitkitcore_checksum_func_jade_connect.restype = ctypes.c_uint16 +_UniffiLib.uniffi_bitkitcore_checksum_func_jade_disconnect.argtypes = ( +) +_UniffiLib.uniffi_bitkitcore_checksum_func_jade_disconnect.restype = ctypes.c_uint16 +_UniffiLib.uniffi_bitkitcore_checksum_func_jade_get_account_export.argtypes = ( +) +_UniffiLib.uniffi_bitkitcore_checksum_func_jade_get_account_export.restype = ctypes.c_uint16 +_UniffiLib.uniffi_bitkitcore_checksum_func_jade_get_connected_device.argtypes = ( +) +_UniffiLib.uniffi_bitkitcore_checksum_func_jade_get_connected_device.restype = ctypes.c_uint16 +_UniffiLib.uniffi_bitkitcore_checksum_func_jade_get_master_fingerprint.argtypes = ( +) +_UniffiLib.uniffi_bitkitcore_checksum_func_jade_get_master_fingerprint.restype = ctypes.c_uint16 +_UniffiLib.uniffi_bitkitcore_checksum_func_jade_get_version_info.argtypes = ( +) +_UniffiLib.uniffi_bitkitcore_checksum_func_jade_get_version_info.restype = ctypes.c_uint16 +_UniffiLib.uniffi_bitkitcore_checksum_func_jade_get_xpub.argtypes = ( +) +_UniffiLib.uniffi_bitkitcore_checksum_func_jade_get_xpub.restype = ctypes.c_uint16 +_UniffiLib.uniffi_bitkitcore_checksum_func_jade_is_connected.argtypes = ( +) +_UniffiLib.uniffi_bitkitcore_checksum_func_jade_is_connected.restype = ctypes.c_uint16 +_UniffiLib.uniffi_bitkitcore_checksum_func_jade_list_devices.argtypes = ( +) +_UniffiLib.uniffi_bitkitcore_checksum_func_jade_list_devices.restype = ctypes.c_uint16 +_UniffiLib.uniffi_bitkitcore_checksum_func_jade_logout.argtypes = ( +) +_UniffiLib.uniffi_bitkitcore_checksum_func_jade_logout.restype = ctypes.c_uint16 +_UniffiLib.uniffi_bitkitcore_checksum_func_jade_notify_disconnected.argtypes = ( +) +_UniffiLib.uniffi_bitkitcore_checksum_func_jade_notify_disconnected.restype = ctypes.c_uint16 +_UniffiLib.uniffi_bitkitcore_checksum_func_jade_ping.argtypes = ( +) +_UniffiLib.uniffi_bitkitcore_checksum_func_jade_ping.restype = ctypes.c_uint16 +_UniffiLib.uniffi_bitkitcore_checksum_func_jade_refresh_version_info.argtypes = ( +) +_UniffiLib.uniffi_bitkitcore_checksum_func_jade_refresh_version_info.restype = ctypes.c_uint16 +_UniffiLib.uniffi_bitkitcore_checksum_func_jade_scan.argtypes = ( +) +_UniffiLib.uniffi_bitkitcore_checksum_func_jade_scan.restype = ctypes.c_uint16 +_UniffiLib.uniffi_bitkitcore_checksum_func_jade_set_transport_callback.argtypes = ( +) +_UniffiLib.uniffi_bitkitcore_checksum_func_jade_set_transport_callback.restype = ctypes.c_uint16 +_UniffiLib.uniffi_bitkitcore_checksum_func_jade_sign_message.argtypes = ( +) +_UniffiLib.uniffi_bitkitcore_checksum_func_jade_sign_message.restype = ctypes.c_uint16 +_UniffiLib.uniffi_bitkitcore_checksum_func_jade_sign_psbt.argtypes = ( +) +_UniffiLib.uniffi_bitkitcore_checksum_func_jade_sign_psbt.restype = ctypes.c_uint16 +_UniffiLib.uniffi_bitkitcore_checksum_func_jade_unlock.argtypes = ( +) +_UniffiLib.uniffi_bitkitcore_checksum_func_jade_unlock.restype = ctypes.c_uint16 +_UniffiLib.uniffi_bitkitcore_checksum_func_jade_verify_address.argtypes = ( +) +_UniffiLib.uniffi_bitkitcore_checksum_func_jade_verify_address.restype = ctypes.c_uint16 _UniffiLib.uniffi_bitkitcore_checksum_func_lnurl_auth.argtypes = ( ) _UniffiLib.uniffi_bitkitcore_checksum_func_lnurl_auth.restype = ctypes.c_uint16 @@ -2982,6 +3267,24 @@ class _UniffiVTableCallbackInterfaceTrezorUiCallback(ctypes.Structure): _UniffiLib.uniffi_bitkitcore_checksum_method_eventlistener_on_event.argtypes = ( ) _UniffiLib.uniffi_bitkitcore_checksum_method_eventlistener_on_event.restype = ctypes.c_uint16 +_UniffiLib.uniffi_bitkitcore_checksum_method_jadetransportcallback_scan_devices.argtypes = ( +) +_UniffiLib.uniffi_bitkitcore_checksum_method_jadetransportcallback_scan_devices.restype = ctypes.c_uint16 +_UniffiLib.uniffi_bitkitcore_checksum_method_jadetransportcallback_open_device.argtypes = ( +) +_UniffiLib.uniffi_bitkitcore_checksum_method_jadetransportcallback_open_device.restype = ctypes.c_uint16 +_UniffiLib.uniffi_bitkitcore_checksum_method_jadetransportcallback_close_device.argtypes = ( +) +_UniffiLib.uniffi_bitkitcore_checksum_method_jadetransportcallback_close_device.restype = ctypes.c_uint16 +_UniffiLib.uniffi_bitkitcore_checksum_method_jadetransportcallback_write_chunk.argtypes = ( +) +_UniffiLib.uniffi_bitkitcore_checksum_method_jadetransportcallback_write_chunk.restype = ctypes.c_uint16 +_UniffiLib.uniffi_bitkitcore_checksum_method_jadetransportcallback_read_chunk.argtypes = ( +) +_UniffiLib.uniffi_bitkitcore_checksum_method_jadetransportcallback_read_chunk.restype = ctypes.c_uint16 +_UniffiLib.uniffi_bitkitcore_checksum_method_jadetransportcallback_get_chunk_size.argtypes = ( +) +_UniffiLib.uniffi_bitkitcore_checksum_method_jadetransportcallback_get_chunk_size.restype = ctypes.c_uint16 _UniffiLib.uniffi_bitkitcore_checksum_method_trezortransportcallback_enumerate_devices.argtypes = ( ) _UniffiLib.uniffi_bitkitcore_checksum_method_trezortransportcallback_enumerate_devices.restype = ctypes.c_uint16 @@ -3225,6 +3528,8 @@ def write(value, buf): + + class AccountAddresses: """ Grouped address lists for an account. @@ -6747,842 +7052,697 @@ def write(value, buf): _UniffiConverterString.write(value.created_at, buf) -class LegacyRnCloseRecoveryScanResult: - total_amount: "int" - """ - Total balance found in legacy RN P2WPKH close outputs (in satoshis). - """ - - outputs_count: "int" - """ - Number of P2WPKH outputs found. - """ - - def __init__(self, *, total_amount: "int", outputs_count: "int"): - self.total_amount = total_amount - self.outputs_count = outputs_count +class JadeAccount: + variant: "JadeAddressVariant" + xpub: "str" + derivation_path: "str" + def __init__(self, *, variant: "JadeAddressVariant", xpub: "str", derivation_path: "str"): + self.variant = variant + self.xpub = xpub + self.derivation_path = derivation_path def __str__(self): - return "LegacyRnCloseRecoveryScanResult(total_amount={}, outputs_count={})".format(self.total_amount, self.outputs_count) + return "JadeAccount(variant={}, xpub={}, derivation_path={})".format(self.variant, self.xpub, self.derivation_path) def __eq__(self, other): - if self.total_amount != other.total_amount: + if self.variant != other.variant: return False - if self.outputs_count != other.outputs_count: + if self.xpub != other.xpub: + return False + if self.derivation_path != other.derivation_path: return False return True -class _UniffiConverterTypeLegacyRnCloseRecoveryScanResult(_UniffiConverterRustBuffer): +class _UniffiConverterTypeJadeAccount(_UniffiConverterRustBuffer): @staticmethod def read(buf): - return LegacyRnCloseRecoveryScanResult( - total_amount=_UniffiConverterUInt64.read(buf), - outputs_count=_UniffiConverterUInt32.read(buf), + return JadeAccount( + variant=_UniffiConverterTypeJadeAddressVariant.read(buf), + xpub=_UniffiConverterString.read(buf), + derivation_path=_UniffiConverterString.read(buf), ) @staticmethod def check_lower(value): - _UniffiConverterUInt64.check_lower(value.total_amount) - _UniffiConverterUInt32.check_lower(value.outputs_count) + _UniffiConverterTypeJadeAddressVariant.check_lower(value.variant) + _UniffiConverterString.check_lower(value.xpub) + _UniffiConverterString.check_lower(value.derivation_path) @staticmethod def write(value, buf): - _UniffiConverterUInt64.write(value.total_amount, buf) - _UniffiConverterUInt32.write(value.outputs_count, buf) + _UniffiConverterTypeJadeAddressVariant.write(value.variant, buf) + _UniffiConverterString.write(value.xpub, buf) + _UniffiConverterString.write(value.derivation_path, buf) -class LegacyRnCloseRecoverySweepPreview: - tx_hex: "str" - """ - Fully signed raw sweep transaction hex. Broadcast only after user confirmation. - """ +class JadeAccountExport: + master_fingerprint: "str" + account_index: "int" + accounts: "typing.List[JadeAccount]" + def __init__(self, *, master_fingerprint: "str", account_index: "int", accounts: "typing.List[JadeAccount]"): + self.master_fingerprint = master_fingerprint + self.account_index = account_index + self.accounts = accounts - txid: "str" - """ - Transaction id of the sweep transaction. - """ + def __str__(self): + return "JadeAccountExport(master_fingerprint={}, account_index={}, accounts={})".format(self.master_fingerprint, self.account_index, self.accounts) - total_amount: "int" - """ - Total input amount in satoshis. - """ + def __eq__(self, other): + if self.master_fingerprint != other.master_fingerprint: + return False + if self.account_index != other.account_index: + return False + if self.accounts != other.accounts: + return False + return True - estimated_fee: "int" - """ - Fee in satoshis. - """ +class _UniffiConverterTypeJadeAccountExport(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + return JadeAccountExport( + master_fingerprint=_UniffiConverterString.read(buf), + account_index=_UniffiConverterUInt32.read(buf), + accounts=_UniffiConverterSequenceTypeJadeAccount.read(buf), + ) - estimated_vsize: "int" - """ - Transaction virtual size in vbytes. - """ + @staticmethod + def check_lower(value): + _UniffiConverterString.check_lower(value.master_fingerprint) + _UniffiConverterUInt32.check_lower(value.account_index) + _UniffiConverterSequenceTypeJadeAccount.check_lower(value.accounts) - outputs_count: "int" - """ - Number of recovered outputs swept. - """ + @staticmethod + def write(value, buf): + _UniffiConverterString.write(value.master_fingerprint, buf) + _UniffiConverterUInt32.write(value.account_index, buf) + _UniffiConverterSequenceTypeJadeAccount.write(value.accounts, buf) - destination_address: "str" - """ - Destination address receiving the sweep. - """ - amount_after_fees: "int" - """ - Amount sent to destination after fees. - """ - - def __init__(self, *, tx_hex: "str", txid: "str", total_amount: "int", estimated_fee: "int", estimated_vsize: "int", outputs_count: "int", destination_address: "str", amount_after_fees: "int"): - self.tx_hex = tx_hex - self.txid = txid - self.total_amount = total_amount - self.estimated_fee = estimated_fee - self.estimated_vsize = estimated_vsize - self.outputs_count = outputs_count - self.destination_address = destination_address - self.amount_after_fees = amount_after_fees +class JadeDeviceInfo: + path: "str" + transport: "JadeTransportKind" + name: "typing.Optional[str]" + serial_number: "typing.Optional[str]" + def __init__(self, *, path: "str", transport: "JadeTransportKind", name: "typing.Optional[str]", serial_number: "typing.Optional[str]"): + self.path = path + self.transport = transport + self.name = name + self.serial_number = serial_number def __str__(self): - return "LegacyRnCloseRecoverySweepPreview(tx_hex={}, txid={}, total_amount={}, estimated_fee={}, estimated_vsize={}, outputs_count={}, destination_address={}, amount_after_fees={})".format(self.tx_hex, self.txid, self.total_amount, self.estimated_fee, self.estimated_vsize, self.outputs_count, self.destination_address, self.amount_after_fees) + return "JadeDeviceInfo(path={}, transport={}, name={}, serial_number={})".format(self.path, self.transport, self.name, self.serial_number) def __eq__(self, other): - if self.tx_hex != other.tx_hex: - return False - if self.txid != other.txid: - return False - if self.total_amount != other.total_amount: - return False - if self.estimated_fee != other.estimated_fee: - return False - if self.estimated_vsize != other.estimated_vsize: + if self.path != other.path: return False - if self.outputs_count != other.outputs_count: + if self.transport != other.transport: return False - if self.destination_address != other.destination_address: + if self.name != other.name: return False - if self.amount_after_fees != other.amount_after_fees: + if self.serial_number != other.serial_number: return False return True -class _UniffiConverterTypeLegacyRnCloseRecoverySweepPreview(_UniffiConverterRustBuffer): +class _UniffiConverterTypeJadeDeviceInfo(_UniffiConverterRustBuffer): @staticmethod def read(buf): - return LegacyRnCloseRecoverySweepPreview( - tx_hex=_UniffiConverterString.read(buf), - txid=_UniffiConverterString.read(buf), - total_amount=_UniffiConverterUInt64.read(buf), - estimated_fee=_UniffiConverterUInt64.read(buf), - estimated_vsize=_UniffiConverterUInt64.read(buf), - outputs_count=_UniffiConverterUInt32.read(buf), - destination_address=_UniffiConverterString.read(buf), - amount_after_fees=_UniffiConverterUInt64.read(buf), + return JadeDeviceInfo( + path=_UniffiConverterString.read(buf), + transport=_UniffiConverterTypeJadeTransportKind.read(buf), + name=_UniffiConverterOptionalString.read(buf), + serial_number=_UniffiConverterOptionalString.read(buf), ) @staticmethod def check_lower(value): - _UniffiConverterString.check_lower(value.tx_hex) - _UniffiConverterString.check_lower(value.txid) - _UniffiConverterUInt64.check_lower(value.total_amount) - _UniffiConverterUInt64.check_lower(value.estimated_fee) - _UniffiConverterUInt64.check_lower(value.estimated_vsize) - _UniffiConverterUInt32.check_lower(value.outputs_count) - _UniffiConverterString.check_lower(value.destination_address) - _UniffiConverterUInt64.check_lower(value.amount_after_fees) + _UniffiConverterString.check_lower(value.path) + _UniffiConverterTypeJadeTransportKind.check_lower(value.transport) + _UniffiConverterOptionalString.check_lower(value.name) + _UniffiConverterOptionalString.check_lower(value.serial_number) @staticmethod def write(value, buf): - _UniffiConverterString.write(value.tx_hex, buf) - _UniffiConverterString.write(value.txid, buf) - _UniffiConverterUInt64.write(value.total_amount, buf) - _UniffiConverterUInt64.write(value.estimated_fee, buf) - _UniffiConverterUInt64.write(value.estimated_vsize, buf) - _UniffiConverterUInt32.write(value.outputs_count, buf) - _UniffiConverterString.write(value.destination_address, buf) - _UniffiConverterUInt64.write(value.amount_after_fees, buf) + _UniffiConverterString.write(value.path, buf) + _UniffiConverterTypeJadeTransportKind.write(value.transport, buf) + _UniffiConverterOptionalString.write(value.name, buf) + _UniffiConverterOptionalString.write(value.serial_number, buf) -class LightningActivity: - wallet_id: "str" - id: "str" - tx_type: "PaymentType" - status: "PaymentState" - value: "int" - fee: "typing.Optional[int]" - invoice: "str" - message: "str" - timestamp: "int" - preimage: "typing.Optional[str]" - contact: "typing.Optional[str]" - created_at: "typing.Optional[int]" - updated_at: "typing.Optional[int]" - seen_at: "typing.Optional[int]" - def __init__(self, *, wallet_id: "str", id: "str", tx_type: "PaymentType", status: "PaymentState", value: "int", fee: "typing.Optional[int]", invoice: "str", message: "str", timestamp: "int", preimage: "typing.Optional[str]", contact: "typing.Optional[str]", created_at: "typing.Optional[int]", updated_at: "typing.Optional[int]", seen_at: "typing.Optional[int]"): - self.wallet_id = wallet_id - self.id = id - self.tx_type = tx_type - self.status = status - self.value = value - self.fee = fee - self.invoice = invoice - self.message = message - self.timestamp = timestamp - self.preimage = preimage - self.contact = contact - self.created_at = created_at - self.updated_at = updated_at - self.seen_at = seen_at +class JadeNativeDevice: + """ + A device the native layer discovered. + """ + + path: "str" + """ + Transport specific address: a BLE identifier or a serial device path. + """ + + transport: "JadeTransportKind" + name: "typing.Optional[str]" + """ + Advertised or descriptor name, for example "Jade C0FFEE". + """ + + serial_number: "typing.Optional[str]" + def __init__(self, *, path: "str", transport: "JadeTransportKind", name: "typing.Optional[str]", serial_number: "typing.Optional[str]"): + self.path = path + self.transport = transport + self.name = name + self.serial_number = serial_number def __str__(self): - return "LightningActivity(wallet_id={}, id={}, tx_type={}, status={}, value={}, fee={}, invoice={}, message={}, timestamp={}, preimage={}, contact={}, created_at={}, updated_at={}, seen_at={})".format(self.wallet_id, self.id, self.tx_type, self.status, self.value, self.fee, self.invoice, self.message, self.timestamp, self.preimage, self.contact, self.created_at, self.updated_at, self.seen_at) + return "JadeNativeDevice(path={}, transport={}, name={}, serial_number={})".format(self.path, self.transport, self.name, self.serial_number) def __eq__(self, other): - if self.wallet_id != other.wallet_id: - return False - if self.id != other.id: - return False - if self.tx_type != other.tx_type: - return False - if self.status != other.status: - return False - if self.value != other.value: - return False - if self.fee != other.fee: - return False - if self.invoice != other.invoice: - return False - if self.message != other.message: - return False - if self.timestamp != other.timestamp: - return False - if self.preimage != other.preimage: - return False - if self.contact != other.contact: + if self.path != other.path: return False - if self.created_at != other.created_at: + if self.transport != other.transport: return False - if self.updated_at != other.updated_at: + if self.name != other.name: return False - if self.seen_at != other.seen_at: + if self.serial_number != other.serial_number: return False return True -class _UniffiConverterTypeLightningActivity(_UniffiConverterRustBuffer): +class _UniffiConverterTypeJadeNativeDevice(_UniffiConverterRustBuffer): @staticmethod def read(buf): - return LightningActivity( - wallet_id=_UniffiConverterString.read(buf), - id=_UniffiConverterString.read(buf), - tx_type=_UniffiConverterTypePaymentType.read(buf), - status=_UniffiConverterTypePaymentState.read(buf), - value=_UniffiConverterUInt64.read(buf), - fee=_UniffiConverterOptionalUInt64.read(buf), - invoice=_UniffiConverterString.read(buf), - message=_UniffiConverterString.read(buf), - timestamp=_UniffiConverterUInt64.read(buf), - preimage=_UniffiConverterOptionalString.read(buf), - contact=_UniffiConverterOptionalString.read(buf), - created_at=_UniffiConverterOptionalUInt64.read(buf), - updated_at=_UniffiConverterOptionalUInt64.read(buf), - seen_at=_UniffiConverterOptionalUInt64.read(buf), + return JadeNativeDevice( + path=_UniffiConverterString.read(buf), + transport=_UniffiConverterTypeJadeTransportKind.read(buf), + name=_UniffiConverterOptionalString.read(buf), + serial_number=_UniffiConverterOptionalString.read(buf), ) @staticmethod def check_lower(value): - _UniffiConverterString.check_lower(value.wallet_id) - _UniffiConverterString.check_lower(value.id) - _UniffiConverterTypePaymentType.check_lower(value.tx_type) - _UniffiConverterTypePaymentState.check_lower(value.status) - _UniffiConverterUInt64.check_lower(value.value) - _UniffiConverterOptionalUInt64.check_lower(value.fee) - _UniffiConverterString.check_lower(value.invoice) - _UniffiConverterString.check_lower(value.message) - _UniffiConverterUInt64.check_lower(value.timestamp) - _UniffiConverterOptionalString.check_lower(value.preimage) - _UniffiConverterOptionalString.check_lower(value.contact) - _UniffiConverterOptionalUInt64.check_lower(value.created_at) - _UniffiConverterOptionalUInt64.check_lower(value.updated_at) - _UniffiConverterOptionalUInt64.check_lower(value.seen_at) + _UniffiConverterString.check_lower(value.path) + _UniffiConverterTypeJadeTransportKind.check_lower(value.transport) + _UniffiConverterOptionalString.check_lower(value.name) + _UniffiConverterOptionalString.check_lower(value.serial_number) @staticmethod def write(value, buf): - _UniffiConverterString.write(value.wallet_id, buf) - _UniffiConverterString.write(value.id, buf) - _UniffiConverterTypePaymentType.write(value.tx_type, buf) - _UniffiConverterTypePaymentState.write(value.status, buf) - _UniffiConverterUInt64.write(value.value, buf) - _UniffiConverterOptionalUInt64.write(value.fee, buf) - _UniffiConverterString.write(value.invoice, buf) - _UniffiConverterString.write(value.message, buf) - _UniffiConverterUInt64.write(value.timestamp, buf) - _UniffiConverterOptionalString.write(value.preimage, buf) - _UniffiConverterOptionalString.write(value.contact, buf) - _UniffiConverterOptionalUInt64.write(value.created_at, buf) - _UniffiConverterOptionalUInt64.write(value.updated_at, buf) - _UniffiConverterOptionalUInt64.write(value.seen_at, buf) + _UniffiConverterString.write(value.path, buf) + _UniffiConverterTypeJadeTransportKind.write(value.transport, buf) + _UniffiConverterOptionalString.write(value.name, buf) + _UniffiConverterOptionalString.write(value.serial_number, buf) -class LightningInvoice: - bolt11: "str" - payment_hash: "bytes" - amount_satoshis: "int" - timestamp_seconds: "int" - expiry_seconds: "int" - is_expired: "bool" - description: "typing.Optional[str]" - network_type: "NetworkType" - payee_node_id: "typing.Optional[bytes]" - def __init__(self, *, bolt11: "str", payment_hash: "bytes", amount_satoshis: "int", timestamp_seconds: "int", expiry_seconds: "int", is_expired: "bool", description: "typing.Optional[str]", network_type: "NetworkType", payee_node_id: "typing.Optional[bytes]"): - self.bolt11 = bolt11 - self.payment_hash = payment_hash - self.amount_satoshis = amount_satoshis - self.timestamp_seconds = timestamp_seconds - self.expiry_seconds = expiry_seconds - self.is_expired = is_expired - self.description = description - self.network_type = network_type - self.payee_node_id = payee_node_id +class JadeSignedMessage: + signature: "str" + address: "str" + derivation_path: "str" + def __init__(self, *, signature: "str", address: "str", derivation_path: "str"): + self.signature = signature + self.address = address + self.derivation_path = derivation_path def __str__(self): - return "LightningInvoice(bolt11={}, payment_hash={}, amount_satoshis={}, timestamp_seconds={}, expiry_seconds={}, is_expired={}, description={}, network_type={}, payee_node_id={})".format(self.bolt11, self.payment_hash, self.amount_satoshis, self.timestamp_seconds, self.expiry_seconds, self.is_expired, self.description, self.network_type, self.payee_node_id) + return "JadeSignedMessage(signature={}, address={}, derivation_path={})".format(self.signature, self.address, self.derivation_path) def __eq__(self, other): - if self.bolt11 != other.bolt11: - return False - if self.payment_hash != other.payment_hash: - return False - if self.amount_satoshis != other.amount_satoshis: - return False - if self.timestamp_seconds != other.timestamp_seconds: - return False - if self.expiry_seconds != other.expiry_seconds: - return False - if self.is_expired != other.is_expired: - return False - if self.description != other.description: + if self.signature != other.signature: return False - if self.network_type != other.network_type: + if self.address != other.address: return False - if self.payee_node_id != other.payee_node_id: + if self.derivation_path != other.derivation_path: return False return True -class _UniffiConverterTypeLightningInvoice(_UniffiConverterRustBuffer): +class _UniffiConverterTypeJadeSignedMessage(_UniffiConverterRustBuffer): @staticmethod def read(buf): - return LightningInvoice( - bolt11=_UniffiConverterString.read(buf), - payment_hash=_UniffiConverterBytes.read(buf), - amount_satoshis=_UniffiConverterUInt64.read(buf), - timestamp_seconds=_UniffiConverterUInt64.read(buf), - expiry_seconds=_UniffiConverterUInt64.read(buf), - is_expired=_UniffiConverterBool.read(buf), - description=_UniffiConverterOptionalString.read(buf), - network_type=_UniffiConverterTypeNetworkType.read(buf), - payee_node_id=_UniffiConverterOptionalBytes.read(buf), + return JadeSignedMessage( + signature=_UniffiConverterString.read(buf), + address=_UniffiConverterString.read(buf), + derivation_path=_UniffiConverterString.read(buf), ) @staticmethod def check_lower(value): - _UniffiConverterString.check_lower(value.bolt11) - _UniffiConverterBytes.check_lower(value.payment_hash) - _UniffiConverterUInt64.check_lower(value.amount_satoshis) - _UniffiConverterUInt64.check_lower(value.timestamp_seconds) - _UniffiConverterUInt64.check_lower(value.expiry_seconds) - _UniffiConverterBool.check_lower(value.is_expired) - _UniffiConverterOptionalString.check_lower(value.description) - _UniffiConverterTypeNetworkType.check_lower(value.network_type) - _UniffiConverterOptionalBytes.check_lower(value.payee_node_id) + _UniffiConverterString.check_lower(value.signature) + _UniffiConverterString.check_lower(value.address) + _UniffiConverterString.check_lower(value.derivation_path) @staticmethod def write(value, buf): - _UniffiConverterString.write(value.bolt11, buf) - _UniffiConverterBytes.write(value.payment_hash, buf) - _UniffiConverterUInt64.write(value.amount_satoshis, buf) - _UniffiConverterUInt64.write(value.timestamp_seconds, buf) - _UniffiConverterUInt64.write(value.expiry_seconds, buf) - _UniffiConverterBool.write(value.is_expired, buf) - _UniffiConverterOptionalString.write(value.description, buf) - _UniffiConverterTypeNetworkType.write(value.network_type, buf) - _UniffiConverterOptionalBytes.write(value.payee_node_id, buf) + _UniffiConverterString.write(value.signature, buf) + _UniffiConverterString.write(value.address, buf) + _UniffiConverterString.write(value.derivation_path, buf) -class LnurlAddressData: - uri: "str" - domain: "str" - username: "str" - def __init__(self, *, uri: "str", domain: "str", username: "str"): - self.uri = uri - self.domain = domain - self.username = username +class JadeTransportReadResult: + """ + Outcome of a read. + """ + + success: "bool" + data: "bytes" + """ + Bytes read. Success with an empty vector means nothing has arrived yet, + which is the normal case while the user is deciding on the device. + """ + + error: "str" + """ + Empty on success. + """ + + error_code: "typing.Optional[JadeTransportErrorCode]" + def __init__(self, *, success: "bool", data: "bytes", error: "str", error_code: "typing.Optional[JadeTransportErrorCode]"): + self.success = success + self.data = data + self.error = error + self.error_code = error_code def __str__(self): - return "LnurlAddressData(uri={}, domain={}, username={})".format(self.uri, self.domain, self.username) + return "JadeTransportReadResult(success={}, data={}, error={}, error_code={})".format(self.success, self.data, self.error, self.error_code) def __eq__(self, other): - if self.uri != other.uri: + if self.success != other.success: return False - if self.domain != other.domain: + if self.data != other.data: return False - if self.username != other.username: + if self.error != other.error: + return False + if self.error_code != other.error_code: return False return True -class _UniffiConverterTypeLnurlAddressData(_UniffiConverterRustBuffer): +class _UniffiConverterTypeJadeTransportReadResult(_UniffiConverterRustBuffer): @staticmethod def read(buf): - return LnurlAddressData( - uri=_UniffiConverterString.read(buf), - domain=_UniffiConverterString.read(buf), - username=_UniffiConverterString.read(buf), + return JadeTransportReadResult( + success=_UniffiConverterBool.read(buf), + data=_UniffiConverterBytes.read(buf), + error=_UniffiConverterString.read(buf), + error_code=_UniffiConverterOptionalTypeJadeTransportErrorCode.read(buf), ) @staticmethod def check_lower(value): - _UniffiConverterString.check_lower(value.uri) - _UniffiConverterString.check_lower(value.domain) - _UniffiConverterString.check_lower(value.username) + _UniffiConverterBool.check_lower(value.success) + _UniffiConverterBytes.check_lower(value.data) + _UniffiConverterString.check_lower(value.error) + _UniffiConverterOptionalTypeJadeTransportErrorCode.check_lower(value.error_code) @staticmethod def write(value, buf): - _UniffiConverterString.write(value.uri, buf) - _UniffiConverterString.write(value.domain, buf) - _UniffiConverterString.write(value.username, buf) + _UniffiConverterBool.write(value.success, buf) + _UniffiConverterBytes.write(value.data, buf) + _UniffiConverterString.write(value.error, buf) + _UniffiConverterOptionalTypeJadeTransportErrorCode.write(value.error_code, buf) -class LnurlAuthData: - uri: "str" - tag: "str" - k1: "str" - domain: "str" - def __init__(self, *, uri: "str", tag: "str", k1: "str", domain: "str"): - self.uri = uri - self.tag = tag - self.k1 = k1 - self.domain = domain +class JadeTransportResult: + """ + Outcome of an operation that returns no data. + """ + + success: "bool" + error: "str" + """ + Empty on success. + """ + + error_code: "typing.Optional[JadeTransportErrorCode]" + def __init__(self, *, success: "bool", error: "str", error_code: "typing.Optional[JadeTransportErrorCode]"): + self.success = success + self.error = error + self.error_code = error_code def __str__(self): - return "LnurlAuthData(uri={}, tag={}, k1={}, domain={})".format(self.uri, self.tag, self.k1, self.domain) + return "JadeTransportResult(success={}, error={}, error_code={})".format(self.success, self.error, self.error_code) def __eq__(self, other): - if self.uri != other.uri: - return False - if self.tag != other.tag: + if self.success != other.success: return False - if self.k1 != other.k1: + if self.error != other.error: return False - if self.domain != other.domain: + if self.error_code != other.error_code: return False return True -class _UniffiConverterTypeLnurlAuthData(_UniffiConverterRustBuffer): +class _UniffiConverterTypeJadeTransportResult(_UniffiConverterRustBuffer): @staticmethod def read(buf): - return LnurlAuthData( - uri=_UniffiConverterString.read(buf), - tag=_UniffiConverterString.read(buf), - k1=_UniffiConverterString.read(buf), - domain=_UniffiConverterString.read(buf), + return JadeTransportResult( + success=_UniffiConverterBool.read(buf), + error=_UniffiConverterString.read(buf), + error_code=_UniffiConverterOptionalTypeJadeTransportErrorCode.read(buf), ) @staticmethod def check_lower(value): - _UniffiConverterString.check_lower(value.uri) - _UniffiConverterString.check_lower(value.tag) - _UniffiConverterString.check_lower(value.k1) - _UniffiConverterString.check_lower(value.domain) + _UniffiConverterBool.check_lower(value.success) + _UniffiConverterString.check_lower(value.error) + _UniffiConverterOptionalTypeJadeTransportErrorCode.check_lower(value.error_code) @staticmethod def write(value, buf): - _UniffiConverterString.write(value.uri, buf) - _UniffiConverterString.write(value.tag, buf) - _UniffiConverterString.write(value.k1, buf) - _UniffiConverterString.write(value.domain, buf) - - -class LnurlChannelData: - uri: "str" - callback: "str" - k1: "str" - tag: "str" - def __init__(self, *, uri: "str", callback: "str", k1: "str", tag: "str"): - self.uri = uri - self.callback = callback - self.k1 = k1 - self.tag = tag + _UniffiConverterBool.write(value.success, buf) + _UniffiConverterString.write(value.error, buf) + _UniffiConverterOptionalTypeJadeTransportErrorCode.write(value.error_code, buf) + + +class JadeVersionInfo: + jade_version: "str" + jade_state: "JadeState" + jade_networks: "typing.Optional[str]" + jade_has_pin: "typing.Optional[bool]" + board_type: "typing.Optional[str]" + jade_config: "typing.Optional[str]" + jade_features: "typing.Optional[str]" + idf_version: "typing.Optional[str]" + chip_features: "typing.Optional[str]" + efuse_mac: "typing.Optional[str]" + battery_status: "typing.Optional[int]" + jade_ota_max_chunk: "typing.Optional[int]" + def __init__(self, *, jade_version: "str", jade_state: "JadeState", jade_networks: "typing.Optional[str]", jade_has_pin: "typing.Optional[bool]", board_type: "typing.Optional[str]", jade_config: "typing.Optional[str]", jade_features: "typing.Optional[str]", idf_version: "typing.Optional[str]", chip_features: "typing.Optional[str]", efuse_mac: "typing.Optional[str]", battery_status: "typing.Optional[int]", jade_ota_max_chunk: "typing.Optional[int]"): + self.jade_version = jade_version + self.jade_state = jade_state + self.jade_networks = jade_networks + self.jade_has_pin = jade_has_pin + self.board_type = board_type + self.jade_config = jade_config + self.jade_features = jade_features + self.idf_version = idf_version + self.chip_features = chip_features + self.efuse_mac = efuse_mac + self.battery_status = battery_status + self.jade_ota_max_chunk = jade_ota_max_chunk def __str__(self): - return "LnurlChannelData(uri={}, callback={}, k1={}, tag={})".format(self.uri, self.callback, self.k1, self.tag) + return "JadeVersionInfo(jade_version={}, jade_state={}, jade_networks={}, jade_has_pin={}, board_type={}, jade_config={}, jade_features={}, idf_version={}, chip_features={}, efuse_mac={}, battery_status={}, jade_ota_max_chunk={})".format(self.jade_version, self.jade_state, self.jade_networks, self.jade_has_pin, self.board_type, self.jade_config, self.jade_features, self.idf_version, self.chip_features, self.efuse_mac, self.battery_status, self.jade_ota_max_chunk) def __eq__(self, other): - if self.uri != other.uri: + if self.jade_version != other.jade_version: return False - if self.callback != other.callback: + if self.jade_state != other.jade_state: return False - if self.k1 != other.k1: + if self.jade_networks != other.jade_networks: return False - if self.tag != other.tag: + if self.jade_has_pin != other.jade_has_pin: + return False + if self.board_type != other.board_type: + return False + if self.jade_config != other.jade_config: + return False + if self.jade_features != other.jade_features: + return False + if self.idf_version != other.idf_version: + return False + if self.chip_features != other.chip_features: + return False + if self.efuse_mac != other.efuse_mac: + return False + if self.battery_status != other.battery_status: + return False + if self.jade_ota_max_chunk != other.jade_ota_max_chunk: return False return True -class _UniffiConverterTypeLnurlChannelData(_UniffiConverterRustBuffer): +class _UniffiConverterTypeJadeVersionInfo(_UniffiConverterRustBuffer): @staticmethod def read(buf): - return LnurlChannelData( - uri=_UniffiConverterString.read(buf), - callback=_UniffiConverterString.read(buf), - k1=_UniffiConverterString.read(buf), - tag=_UniffiConverterString.read(buf), + return JadeVersionInfo( + jade_version=_UniffiConverterString.read(buf), + jade_state=_UniffiConverterTypeJadeState.read(buf), + jade_networks=_UniffiConverterOptionalString.read(buf), + jade_has_pin=_UniffiConverterOptionalBool.read(buf), + board_type=_UniffiConverterOptionalString.read(buf), + jade_config=_UniffiConverterOptionalString.read(buf), + jade_features=_UniffiConverterOptionalString.read(buf), + idf_version=_UniffiConverterOptionalString.read(buf), + chip_features=_UniffiConverterOptionalString.read(buf), + efuse_mac=_UniffiConverterOptionalString.read(buf), + battery_status=_UniffiConverterOptionalUInt32.read(buf), + jade_ota_max_chunk=_UniffiConverterOptionalUInt32.read(buf), ) @staticmethod def check_lower(value): - _UniffiConverterString.check_lower(value.uri) - _UniffiConverterString.check_lower(value.callback) - _UniffiConverterString.check_lower(value.k1) - _UniffiConverterString.check_lower(value.tag) + _UniffiConverterString.check_lower(value.jade_version) + _UniffiConverterTypeJadeState.check_lower(value.jade_state) + _UniffiConverterOptionalString.check_lower(value.jade_networks) + _UniffiConverterOptionalBool.check_lower(value.jade_has_pin) + _UniffiConverterOptionalString.check_lower(value.board_type) + _UniffiConverterOptionalString.check_lower(value.jade_config) + _UniffiConverterOptionalString.check_lower(value.jade_features) + _UniffiConverterOptionalString.check_lower(value.idf_version) + _UniffiConverterOptionalString.check_lower(value.chip_features) + _UniffiConverterOptionalString.check_lower(value.efuse_mac) + _UniffiConverterOptionalUInt32.check_lower(value.battery_status) + _UniffiConverterOptionalUInt32.check_lower(value.jade_ota_max_chunk) @staticmethod def write(value, buf): - _UniffiConverterString.write(value.uri, buf) - _UniffiConverterString.write(value.callback, buf) - _UniffiConverterString.write(value.k1, buf) - _UniffiConverterString.write(value.tag, buf) - - -class LnurlPayData: - uri: "str" - callback: "str" - min_sendable: "int" - max_sendable: "int" - metadata_str: "str" - comment_allowed: "typing.Optional[int]" - allows_nostr: "bool" - nostr_pubkey: "typing.Optional[bytes]" - def __init__(self, *, uri: "str", callback: "str", min_sendable: "int", max_sendable: "int", metadata_str: "str", comment_allowed: "typing.Optional[int]", allows_nostr: "bool", nostr_pubkey: "typing.Optional[bytes]"): - self.uri = uri - self.callback = callback - self.min_sendable = min_sendable - self.max_sendable = max_sendable - self.metadata_str = metadata_str - self.comment_allowed = comment_allowed - self.allows_nostr = allows_nostr - self.nostr_pubkey = nostr_pubkey + _UniffiConverterString.write(value.jade_version, buf) + _UniffiConverterTypeJadeState.write(value.jade_state, buf) + _UniffiConverterOptionalString.write(value.jade_networks, buf) + _UniffiConverterOptionalBool.write(value.jade_has_pin, buf) + _UniffiConverterOptionalString.write(value.board_type, buf) + _UniffiConverterOptionalString.write(value.jade_config, buf) + _UniffiConverterOptionalString.write(value.jade_features, buf) + _UniffiConverterOptionalString.write(value.idf_version, buf) + _UniffiConverterOptionalString.write(value.chip_features, buf) + _UniffiConverterOptionalString.write(value.efuse_mac, buf) + _UniffiConverterOptionalUInt32.write(value.battery_status, buf) + _UniffiConverterOptionalUInt32.write(value.jade_ota_max_chunk, buf) + + +class JadeXpubResponse: + xpub: "str" + derivation_path: "str" + master_fingerprint: "str" + def __init__(self, *, xpub: "str", derivation_path: "str", master_fingerprint: "str"): + self.xpub = xpub + self.derivation_path = derivation_path + self.master_fingerprint = master_fingerprint def __str__(self): - return "LnurlPayData(uri={}, callback={}, min_sendable={}, max_sendable={}, metadata_str={}, comment_allowed={}, allows_nostr={}, nostr_pubkey={})".format(self.uri, self.callback, self.min_sendable, self.max_sendable, self.metadata_str, self.comment_allowed, self.allows_nostr, self.nostr_pubkey) + return "JadeXpubResponse(xpub={}, derivation_path={}, master_fingerprint={})".format(self.xpub, self.derivation_path, self.master_fingerprint) def __eq__(self, other): - if self.uri != other.uri: - return False - if self.callback != other.callback: - return False - if self.min_sendable != other.min_sendable: - return False - if self.max_sendable != other.max_sendable: - return False - if self.metadata_str != other.metadata_str: - return False - if self.comment_allowed != other.comment_allowed: + if self.xpub != other.xpub: return False - if self.allows_nostr != other.allows_nostr: + if self.derivation_path != other.derivation_path: return False - if self.nostr_pubkey != other.nostr_pubkey: + if self.master_fingerprint != other.master_fingerprint: return False return True -class _UniffiConverterTypeLnurlPayData(_UniffiConverterRustBuffer): +class _UniffiConverterTypeJadeXpubResponse(_UniffiConverterRustBuffer): @staticmethod def read(buf): - return LnurlPayData( - uri=_UniffiConverterString.read(buf), - callback=_UniffiConverterString.read(buf), - min_sendable=_UniffiConverterUInt64.read(buf), - max_sendable=_UniffiConverterUInt64.read(buf), - metadata_str=_UniffiConverterString.read(buf), - comment_allowed=_UniffiConverterOptionalUInt32.read(buf), - allows_nostr=_UniffiConverterBool.read(buf), - nostr_pubkey=_UniffiConverterOptionalBytes.read(buf), + return JadeXpubResponse( + xpub=_UniffiConverterString.read(buf), + derivation_path=_UniffiConverterString.read(buf), + master_fingerprint=_UniffiConverterString.read(buf), ) @staticmethod def check_lower(value): - _UniffiConverterString.check_lower(value.uri) - _UniffiConverterString.check_lower(value.callback) - _UniffiConverterUInt64.check_lower(value.min_sendable) - _UniffiConverterUInt64.check_lower(value.max_sendable) - _UniffiConverterString.check_lower(value.metadata_str) - _UniffiConverterOptionalUInt32.check_lower(value.comment_allowed) - _UniffiConverterBool.check_lower(value.allows_nostr) - _UniffiConverterOptionalBytes.check_lower(value.nostr_pubkey) + _UniffiConverterString.check_lower(value.xpub) + _UniffiConverterString.check_lower(value.derivation_path) + _UniffiConverterString.check_lower(value.master_fingerprint) @staticmethod def write(value, buf): - _UniffiConverterString.write(value.uri, buf) - _UniffiConverterString.write(value.callback, buf) - _UniffiConverterUInt64.write(value.min_sendable, buf) - _UniffiConverterUInt64.write(value.max_sendable, buf) - _UniffiConverterString.write(value.metadata_str, buf) - _UniffiConverterOptionalUInt32.write(value.comment_allowed, buf) - _UniffiConverterBool.write(value.allows_nostr, buf) - _UniffiConverterOptionalBytes.write(value.nostr_pubkey, buf) + _UniffiConverterString.write(value.xpub, buf) + _UniffiConverterString.write(value.derivation_path, buf) + _UniffiConverterString.write(value.master_fingerprint, buf) -class LnurlWithdrawData: - uri: "str" - callback: "str" - k1: "str" - default_description: "str" - min_withdrawable: "typing.Optional[int]" - max_withdrawable: "int" - tag: "str" - def __init__(self, *, uri: "str", callback: "str", k1: "str", default_description: "str", min_withdrawable: "typing.Optional[int]", max_withdrawable: "int", tag: "str"): - self.uri = uri - self.callback = callback - self.k1 = k1 - self.default_description = default_description - self.min_withdrawable = min_withdrawable - self.max_withdrawable = max_withdrawable - self.tag = tag +class LegacyRnCloseRecoveryScanResult: + total_amount: "int" + """ + Total balance found in legacy RN P2WPKH close outputs (in satoshis). + """ + + outputs_count: "int" + """ + Number of P2WPKH outputs found. + """ + + def __init__(self, *, total_amount: "int", outputs_count: "int"): + self.total_amount = total_amount + self.outputs_count = outputs_count def __str__(self): - return "LnurlWithdrawData(uri={}, callback={}, k1={}, default_description={}, min_withdrawable={}, max_withdrawable={}, tag={})".format(self.uri, self.callback, self.k1, self.default_description, self.min_withdrawable, self.max_withdrawable, self.tag) + return "LegacyRnCloseRecoveryScanResult(total_amount={}, outputs_count={})".format(self.total_amount, self.outputs_count) def __eq__(self, other): - if self.uri != other.uri: + if self.total_amount != other.total_amount: return False - if self.callback != other.callback: - return False - if self.k1 != other.k1: - return False - if self.default_description != other.default_description: - return False - if self.min_withdrawable != other.min_withdrawable: - return False - if self.max_withdrawable != other.max_withdrawable: - return False - if self.tag != other.tag: + if self.outputs_count != other.outputs_count: return False return True -class _UniffiConverterTypeLnurlWithdrawData(_UniffiConverterRustBuffer): +class _UniffiConverterTypeLegacyRnCloseRecoveryScanResult(_UniffiConverterRustBuffer): @staticmethod def read(buf): - return LnurlWithdrawData( - uri=_UniffiConverterString.read(buf), - callback=_UniffiConverterString.read(buf), - k1=_UniffiConverterString.read(buf), - default_description=_UniffiConverterString.read(buf), - min_withdrawable=_UniffiConverterOptionalUInt64.read(buf), - max_withdrawable=_UniffiConverterUInt64.read(buf), - tag=_UniffiConverterString.read(buf), + return LegacyRnCloseRecoveryScanResult( + total_amount=_UniffiConverterUInt64.read(buf), + outputs_count=_UniffiConverterUInt32.read(buf), ) @staticmethod def check_lower(value): - _UniffiConverterString.check_lower(value.uri) - _UniffiConverterString.check_lower(value.callback) - _UniffiConverterString.check_lower(value.k1) - _UniffiConverterString.check_lower(value.default_description) - _UniffiConverterOptionalUInt64.check_lower(value.min_withdrawable) - _UniffiConverterUInt64.check_lower(value.max_withdrawable) - _UniffiConverterString.check_lower(value.tag) + _UniffiConverterUInt64.check_lower(value.total_amount) + _UniffiConverterUInt32.check_lower(value.outputs_count) @staticmethod def write(value, buf): - _UniffiConverterString.write(value.uri, buf) - _UniffiConverterString.write(value.callback, buf) - _UniffiConverterString.write(value.k1, buf) - _UniffiConverterString.write(value.default_description, buf) - _UniffiConverterOptionalUInt64.write(value.min_withdrawable, buf) - _UniffiConverterUInt64.write(value.max_withdrawable, buf) - _UniffiConverterString.write(value.tag, buf) + _UniffiConverterUInt64.write(value.total_amount, buf) + _UniffiConverterUInt32.write(value.outputs_count, buf) -class NativeDeviceInfo: +class LegacyRnCloseRecoverySweepPreview: + tx_hex: "str" """ - Native device information returned from enumeration + Fully signed raw sweep transaction hex. Broadcast only after user confirmation. """ - path: "str" + txid: "str" """ - Unique path/identifier for this device + Transaction id of the sweep transaction. """ - transport_type: "str" + total_amount: "int" """ - Transport type: "usb" or "bluetooth" + Total input amount in satoshis. """ - name: "typing.Optional[str]" + estimated_fee: "int" """ - Optional device name (from BLE advertisement or USB descriptor) + Fee in satoshis. """ - vendor_id: "typing.Optional[int]" + estimated_vsize: "int" """ - USB Vendor ID (for USB devices) + Transaction virtual size in vbytes. """ - product_id: "typing.Optional[int]" + outputs_count: "int" """ - USB Product ID (for USB devices) + Number of recovered outputs swept. """ - def __init__(self, *, path: "str", transport_type: "str", name: "typing.Optional[str]", vendor_id: "typing.Optional[int]", product_id: "typing.Optional[int]"): - self.path = path - self.transport_type = transport_type - self.name = name - self.vendor_id = vendor_id - self.product_id = product_id + destination_address: "str" + """ + Destination address receiving the sweep. + """ + + amount_after_fees: "int" + """ + Amount sent to destination after fees. + """ + + def __init__(self, *, tx_hex: "str", txid: "str", total_amount: "int", estimated_fee: "int", estimated_vsize: "int", outputs_count: "int", destination_address: "str", amount_after_fees: "int"): + self.tx_hex = tx_hex + self.txid = txid + self.total_amount = total_amount + self.estimated_fee = estimated_fee + self.estimated_vsize = estimated_vsize + self.outputs_count = outputs_count + self.destination_address = destination_address + self.amount_after_fees = amount_after_fees def __str__(self): - return "NativeDeviceInfo(path={}, transport_type={}, name={}, vendor_id={}, product_id={})".format(self.path, self.transport_type, self.name, self.vendor_id, self.product_id) + return "LegacyRnCloseRecoverySweepPreview(tx_hex={}, txid={}, total_amount={}, estimated_fee={}, estimated_vsize={}, outputs_count={}, destination_address={}, amount_after_fees={})".format(self.tx_hex, self.txid, self.total_amount, self.estimated_fee, self.estimated_vsize, self.outputs_count, self.destination_address, self.amount_after_fees) def __eq__(self, other): - if self.path != other.path: - return False - if self.transport_type != other.transport_type: - return False - if self.name != other.name: + if self.tx_hex != other.tx_hex: return False - if self.vendor_id != other.vendor_id: + if self.txid != other.txid: return False - if self.product_id != other.product_id: + if self.total_amount != other.total_amount: return False - return True - -class _UniffiConverterTypeNativeDeviceInfo(_UniffiConverterRustBuffer): - @staticmethod - def read(buf): - return NativeDeviceInfo( - path=_UniffiConverterString.read(buf), - transport_type=_UniffiConverterString.read(buf), - name=_UniffiConverterOptionalString.read(buf), - vendor_id=_UniffiConverterOptionalUInt16.read(buf), - product_id=_UniffiConverterOptionalUInt16.read(buf), - ) - - @staticmethod - def check_lower(value): - _UniffiConverterString.check_lower(value.path) - _UniffiConverterString.check_lower(value.transport_type) - _UniffiConverterOptionalString.check_lower(value.name) - _UniffiConverterOptionalUInt16.check_lower(value.vendor_id) - _UniffiConverterOptionalUInt16.check_lower(value.product_id) - - @staticmethod - def write(value, buf): - _UniffiConverterString.write(value.path, buf) - _UniffiConverterString.write(value.transport_type, buf) - _UniffiConverterOptionalString.write(value.name, buf) - _UniffiConverterOptionalUInt16.write(value.vendor_id, buf) - _UniffiConverterOptionalUInt16.write(value.product_id, buf) - - -class OnChainInvoice: - address: "str" - amount_satoshis: "int" - label: "typing.Optional[str]" - message: "typing.Optional[str]" - params: "typing.Optional[dict[str, str]]" - def __init__(self, *, address: "str", amount_satoshis: "int", label: "typing.Optional[str]", message: "typing.Optional[str]", params: "typing.Optional[dict[str, str]]"): - self.address = address - self.amount_satoshis = amount_satoshis - self.label = label - self.message = message - self.params = params - - def __str__(self): - return "OnChainInvoice(address={}, amount_satoshis={}, label={}, message={}, params={})".format(self.address, self.amount_satoshis, self.label, self.message, self.params) - - def __eq__(self, other): - if self.address != other.address: + if self.estimated_fee != other.estimated_fee: return False - if self.amount_satoshis != other.amount_satoshis: + if self.estimated_vsize != other.estimated_vsize: return False - if self.label != other.label: + if self.outputs_count != other.outputs_count: return False - if self.message != other.message: + if self.destination_address != other.destination_address: return False - if self.params != other.params: + if self.amount_after_fees != other.amount_after_fees: return False return True -class _UniffiConverterTypeOnChainInvoice(_UniffiConverterRustBuffer): +class _UniffiConverterTypeLegacyRnCloseRecoverySweepPreview(_UniffiConverterRustBuffer): @staticmethod def read(buf): - return OnChainInvoice( - address=_UniffiConverterString.read(buf), - amount_satoshis=_UniffiConverterUInt64.read(buf), - label=_UniffiConverterOptionalString.read(buf), - message=_UniffiConverterOptionalString.read(buf), - params=_UniffiConverterOptionalMapStringString.read(buf), + return LegacyRnCloseRecoverySweepPreview( + tx_hex=_UniffiConverterString.read(buf), + txid=_UniffiConverterString.read(buf), + total_amount=_UniffiConverterUInt64.read(buf), + estimated_fee=_UniffiConverterUInt64.read(buf), + estimated_vsize=_UniffiConverterUInt64.read(buf), + outputs_count=_UniffiConverterUInt32.read(buf), + destination_address=_UniffiConverterString.read(buf), + amount_after_fees=_UniffiConverterUInt64.read(buf), ) @staticmethod def check_lower(value): - _UniffiConverterString.check_lower(value.address) - _UniffiConverterUInt64.check_lower(value.amount_satoshis) - _UniffiConverterOptionalString.check_lower(value.label) - _UniffiConverterOptionalString.check_lower(value.message) - _UniffiConverterOptionalMapStringString.check_lower(value.params) + _UniffiConverterString.check_lower(value.tx_hex) + _UniffiConverterString.check_lower(value.txid) + _UniffiConverterUInt64.check_lower(value.total_amount) + _UniffiConverterUInt64.check_lower(value.estimated_fee) + _UniffiConverterUInt64.check_lower(value.estimated_vsize) + _UniffiConverterUInt32.check_lower(value.outputs_count) + _UniffiConverterString.check_lower(value.destination_address) + _UniffiConverterUInt64.check_lower(value.amount_after_fees) @staticmethod def write(value, buf): - _UniffiConverterString.write(value.address, buf) - _UniffiConverterUInt64.write(value.amount_satoshis, buf) - _UniffiConverterOptionalString.write(value.label, buf) - _UniffiConverterOptionalString.write(value.message, buf) - _UniffiConverterOptionalMapStringString.write(value.params, buf) + _UniffiConverterString.write(value.tx_hex, buf) + _UniffiConverterString.write(value.txid, buf) + _UniffiConverterUInt64.write(value.total_amount, buf) + _UniffiConverterUInt64.write(value.estimated_fee, buf) + _UniffiConverterUInt64.write(value.estimated_vsize, buf) + _UniffiConverterUInt32.write(value.outputs_count, buf) + _UniffiConverterString.write(value.destination_address, buf) + _UniffiConverterUInt64.write(value.amount_after_fees, buf) -class OnchainActivity: +class LightningActivity: wallet_id: "str" id: "str" tx_type: "PaymentType" - tx_id: "str" + status: "PaymentState" value: "int" - fee: "int" - fee_rate: "int" - address: "str" - confirmed: "bool" + fee: "typing.Optional[int]" + invoice: "str" + message: "str" timestamp: "int" - is_boosted: "bool" - boost_tx_ids: "typing.List[str]" - is_transfer: "bool" - does_exist: "bool" - confirm_timestamp: "typing.Optional[int]" - channel_id: "typing.Optional[str]" - transfer_tx_id: "typing.Optional[str]" + preimage: "typing.Optional[str]" contact: "typing.Optional[str]" created_at: "typing.Optional[int]" updated_at: "typing.Optional[int]" seen_at: "typing.Optional[int]" - def __init__(self, *, wallet_id: "str", id: "str", tx_type: "PaymentType", tx_id: "str", value: "int", fee: "int", fee_rate: "int", address: "str", confirmed: "bool", timestamp: "int", is_boosted: "bool", boost_tx_ids: "typing.List[str]", is_transfer: "bool", does_exist: "bool", confirm_timestamp: "typing.Optional[int]", channel_id: "typing.Optional[str]", transfer_tx_id: "typing.Optional[str]", contact: "typing.Optional[str]", created_at: "typing.Optional[int]", updated_at: "typing.Optional[int]", seen_at: "typing.Optional[int]"): + def __init__(self, *, wallet_id: "str", id: "str", tx_type: "PaymentType", status: "PaymentState", value: "int", fee: "typing.Optional[int]", invoice: "str", message: "str", timestamp: "int", preimage: "typing.Optional[str]", contact: "typing.Optional[str]", created_at: "typing.Optional[int]", updated_at: "typing.Optional[int]", seen_at: "typing.Optional[int]"): self.wallet_id = wallet_id self.id = id self.tx_type = tx_type - self.tx_id = tx_id + self.status = status self.value = value self.fee = fee - self.fee_rate = fee_rate - self.address = address - self.confirmed = confirmed + self.invoice = invoice + self.message = message self.timestamp = timestamp - self.is_boosted = is_boosted - self.boost_tx_ids = boost_tx_ids - self.is_transfer = is_transfer - self.does_exist = does_exist - self.confirm_timestamp = confirm_timestamp - self.channel_id = channel_id - self.transfer_tx_id = transfer_tx_id + self.preimage = preimage self.contact = contact self.created_at = created_at self.updated_at = updated_at self.seen_at = seen_at def __str__(self): - return "OnchainActivity(wallet_id={}, id={}, tx_type={}, tx_id={}, value={}, fee={}, fee_rate={}, address={}, confirmed={}, timestamp={}, is_boosted={}, boost_tx_ids={}, is_transfer={}, does_exist={}, confirm_timestamp={}, channel_id={}, transfer_tx_id={}, contact={}, created_at={}, updated_at={}, seen_at={})".format(self.wallet_id, self.id, self.tx_type, self.tx_id, self.value, self.fee, self.fee_rate, self.address, self.confirmed, self.timestamp, self.is_boosted, self.boost_tx_ids, self.is_transfer, self.does_exist, self.confirm_timestamp, self.channel_id, self.transfer_tx_id, self.contact, self.created_at, self.updated_at, self.seen_at) + return "LightningActivity(wallet_id={}, id={}, tx_type={}, status={}, value={}, fee={}, invoice={}, message={}, timestamp={}, preimage={}, contact={}, created_at={}, updated_at={}, seen_at={})".format(self.wallet_id, self.id, self.tx_type, self.status, self.value, self.fee, self.invoice, self.message, self.timestamp, self.preimage, self.contact, self.created_at, self.updated_at, self.seen_at) def __eq__(self, other): if self.wallet_id != other.wallet_id: @@ -7591,37 +7751,23 @@ def __eq__(self, other): return False if self.tx_type != other.tx_type: return False - if self.tx_id != other.tx_id: + if self.status != other.status: return False if self.value != other.value: return False if self.fee != other.fee: return False - if self.fee_rate != other.fee_rate: - return False - if self.address != other.address: + if self.invoice != other.invoice: return False - if self.confirmed != other.confirmed: + if self.message != other.message: return False if self.timestamp != other.timestamp: return False - if self.is_boosted != other.is_boosted: + if self.preimage != other.preimage: return False - if self.boost_tx_ids != other.boost_tx_ids: + if self.contact != other.contact: return False - if self.is_transfer != other.is_transfer: - return False - if self.does_exist != other.does_exist: - return False - if self.confirm_timestamp != other.confirm_timestamp: - return False - if self.channel_id != other.channel_id: - return False - if self.transfer_tx_id != other.transfer_tx_id: - return False - if self.contact != other.contact: - return False - if self.created_at != other.created_at: + if self.created_at != other.created_at: return False if self.updated_at != other.updated_at: return False @@ -7629,27 +7775,20 @@ def __eq__(self, other): return False return True -class _UniffiConverterTypeOnchainActivity(_UniffiConverterRustBuffer): +class _UniffiConverterTypeLightningActivity(_UniffiConverterRustBuffer): @staticmethod def read(buf): - return OnchainActivity( + return LightningActivity( wallet_id=_UniffiConverterString.read(buf), id=_UniffiConverterString.read(buf), tx_type=_UniffiConverterTypePaymentType.read(buf), - tx_id=_UniffiConverterString.read(buf), + status=_UniffiConverterTypePaymentState.read(buf), value=_UniffiConverterUInt64.read(buf), - fee=_UniffiConverterUInt64.read(buf), - fee_rate=_UniffiConverterUInt64.read(buf), - address=_UniffiConverterString.read(buf), - confirmed=_UniffiConverterBool.read(buf), + fee=_UniffiConverterOptionalUInt64.read(buf), + invoice=_UniffiConverterString.read(buf), + message=_UniffiConverterString.read(buf), timestamp=_UniffiConverterUInt64.read(buf), - is_boosted=_UniffiConverterBool.read(buf), - boost_tx_ids=_UniffiConverterSequenceString.read(buf), - is_transfer=_UniffiConverterBool.read(buf), - does_exist=_UniffiConverterBool.read(buf), - confirm_timestamp=_UniffiConverterOptionalUInt64.read(buf), - channel_id=_UniffiConverterOptionalString.read(buf), - transfer_tx_id=_UniffiConverterOptionalString.read(buf), + preimage=_UniffiConverterOptionalString.read(buf), contact=_UniffiConverterOptionalString.read(buf), created_at=_UniffiConverterOptionalUInt64.read(buf), updated_at=_UniffiConverterOptionalUInt64.read(buf), @@ -7661,20 +7800,13 @@ def check_lower(value): _UniffiConverterString.check_lower(value.wallet_id) _UniffiConverterString.check_lower(value.id) _UniffiConverterTypePaymentType.check_lower(value.tx_type) - _UniffiConverterString.check_lower(value.tx_id) + _UniffiConverterTypePaymentState.check_lower(value.status) _UniffiConverterUInt64.check_lower(value.value) - _UniffiConverterUInt64.check_lower(value.fee) - _UniffiConverterUInt64.check_lower(value.fee_rate) - _UniffiConverterString.check_lower(value.address) - _UniffiConverterBool.check_lower(value.confirmed) + _UniffiConverterOptionalUInt64.check_lower(value.fee) + _UniffiConverterString.check_lower(value.invoice) + _UniffiConverterString.check_lower(value.message) _UniffiConverterUInt64.check_lower(value.timestamp) - _UniffiConverterBool.check_lower(value.is_boosted) - _UniffiConverterSequenceString.check_lower(value.boost_tx_ids) - _UniffiConverterBool.check_lower(value.is_transfer) - _UniffiConverterBool.check_lower(value.does_exist) - _UniffiConverterOptionalUInt64.check_lower(value.confirm_timestamp) - _UniffiConverterOptionalString.check_lower(value.channel_id) - _UniffiConverterOptionalString.check_lower(value.transfer_tx_id) + _UniffiConverterOptionalString.check_lower(value.preimage) _UniffiConverterOptionalString.check_lower(value.contact) _UniffiConverterOptionalUInt64.check_lower(value.created_at) _UniffiConverterOptionalUInt64.check_lower(value.updated_at) @@ -7685,2643 +7817,2767 @@ def write(value, buf): _UniffiConverterString.write(value.wallet_id, buf) _UniffiConverterString.write(value.id, buf) _UniffiConverterTypePaymentType.write(value.tx_type, buf) - _UniffiConverterString.write(value.tx_id, buf) + _UniffiConverterTypePaymentState.write(value.status, buf) _UniffiConverterUInt64.write(value.value, buf) - _UniffiConverterUInt64.write(value.fee, buf) - _UniffiConverterUInt64.write(value.fee_rate, buf) - _UniffiConverterString.write(value.address, buf) - _UniffiConverterBool.write(value.confirmed, buf) + _UniffiConverterOptionalUInt64.write(value.fee, buf) + _UniffiConverterString.write(value.invoice, buf) + _UniffiConverterString.write(value.message, buf) _UniffiConverterUInt64.write(value.timestamp, buf) - _UniffiConverterBool.write(value.is_boosted, buf) - _UniffiConverterSequenceString.write(value.boost_tx_ids, buf) - _UniffiConverterBool.write(value.is_transfer, buf) - _UniffiConverterBool.write(value.does_exist, buf) - _UniffiConverterOptionalUInt64.write(value.confirm_timestamp, buf) - _UniffiConverterOptionalString.write(value.channel_id, buf) - _UniffiConverterOptionalString.write(value.transfer_tx_id, buf) + _UniffiConverterOptionalString.write(value.preimage, buf) _UniffiConverterOptionalString.write(value.contact, buf) _UniffiConverterOptionalUInt64.write(value.created_at, buf) _UniffiConverterOptionalUInt64.write(value.updated_at, buf) _UniffiConverterOptionalUInt64.write(value.seen_at, buf) -class PassportAccount: - """ - One single-signature account in Passport's generic JSON export. - """ - - account_type: "AccountType" - xpub: "str" - """ - Standard xpub/tpub encoding used by Passport's export. - """ - - derivation_path: "str" - """ - Account-level BIP32 path, such as `m/84'/0'/0'`. - """ - - def __init__(self, *, account_type: "AccountType", xpub: "str", derivation_path: "str"): - self.account_type = account_type - self.xpub = xpub - self.derivation_path = derivation_path +class LightningInvoice: + bolt11: "str" + payment_hash: "bytes" + amount_satoshis: "int" + timestamp_seconds: "int" + expiry_seconds: "int" + is_expired: "bool" + description: "typing.Optional[str]" + network_type: "NetworkType" + payee_node_id: "typing.Optional[bytes]" + def __init__(self, *, bolt11: "str", payment_hash: "bytes", amount_satoshis: "int", timestamp_seconds: "int", expiry_seconds: "int", is_expired: "bool", description: "typing.Optional[str]", network_type: "NetworkType", payee_node_id: "typing.Optional[bytes]"): + self.bolt11 = bolt11 + self.payment_hash = payment_hash + self.amount_satoshis = amount_satoshis + self.timestamp_seconds = timestamp_seconds + self.expiry_seconds = expiry_seconds + self.is_expired = is_expired + self.description = description + self.network_type = network_type + self.payee_node_id = payee_node_id def __str__(self): - return "PassportAccount(account_type={}, xpub={}, derivation_path={})".format(self.account_type, self.xpub, self.derivation_path) + return "LightningInvoice(bolt11={}, payment_hash={}, amount_satoshis={}, timestamp_seconds={}, expiry_seconds={}, is_expired={}, description={}, network_type={}, payee_node_id={})".format(self.bolt11, self.payment_hash, self.amount_satoshis, self.timestamp_seconds, self.expiry_seconds, self.is_expired, self.description, self.network_type, self.payee_node_id) def __eq__(self, other): - if self.account_type != other.account_type: + if self.bolt11 != other.bolt11: return False - if self.xpub != other.xpub: + if self.payment_hash != other.payment_hash: return False - if self.derivation_path != other.derivation_path: + if self.amount_satoshis != other.amount_satoshis: + return False + if self.timestamp_seconds != other.timestamp_seconds: + return False + if self.expiry_seconds != other.expiry_seconds: + return False + if self.is_expired != other.is_expired: + return False + if self.description != other.description: + return False + if self.network_type != other.network_type: + return False + if self.payee_node_id != other.payee_node_id: return False return True -class _UniffiConverterTypePassportAccount(_UniffiConverterRustBuffer): +class _UniffiConverterTypeLightningInvoice(_UniffiConverterRustBuffer): @staticmethod def read(buf): - return PassportAccount( - account_type=_UniffiConverterTypeAccountType.read(buf), - xpub=_UniffiConverterString.read(buf), - derivation_path=_UniffiConverterString.read(buf), + return LightningInvoice( + bolt11=_UniffiConverterString.read(buf), + payment_hash=_UniffiConverterBytes.read(buf), + amount_satoshis=_UniffiConverterUInt64.read(buf), + timestamp_seconds=_UniffiConverterUInt64.read(buf), + expiry_seconds=_UniffiConverterUInt64.read(buf), + is_expired=_UniffiConverterBool.read(buf), + description=_UniffiConverterOptionalString.read(buf), + network_type=_UniffiConverterTypeNetworkType.read(buf), + payee_node_id=_UniffiConverterOptionalBytes.read(buf), ) @staticmethod def check_lower(value): - _UniffiConverterTypeAccountType.check_lower(value.account_type) - _UniffiConverterString.check_lower(value.xpub) - _UniffiConverterString.check_lower(value.derivation_path) + _UniffiConverterString.check_lower(value.bolt11) + _UniffiConverterBytes.check_lower(value.payment_hash) + _UniffiConverterUInt64.check_lower(value.amount_satoshis) + _UniffiConverterUInt64.check_lower(value.timestamp_seconds) + _UniffiConverterUInt64.check_lower(value.expiry_seconds) + _UniffiConverterBool.check_lower(value.is_expired) + _UniffiConverterOptionalString.check_lower(value.description) + _UniffiConverterTypeNetworkType.check_lower(value.network_type) + _UniffiConverterOptionalBytes.check_lower(value.payee_node_id) @staticmethod def write(value, buf): - _UniffiConverterTypeAccountType.write(value.account_type, buf) - _UniffiConverterString.write(value.xpub, buf) - _UniffiConverterString.write(value.derivation_path, buf) - - -class PassportAccountExport: - """ - The single-signature accounts exported by Passport for one account index. - """ + _UniffiConverterString.write(value.bolt11, buf) + _UniffiConverterBytes.write(value.payment_hash, buf) + _UniffiConverterUInt64.write(value.amount_satoshis, buf) + _UniffiConverterUInt64.write(value.timestamp_seconds, buf) + _UniffiConverterUInt64.write(value.expiry_seconds, buf) + _UniffiConverterBool.write(value.is_expired, buf) + _UniffiConverterOptionalString.write(value.description, buf) + _UniffiConverterTypeNetworkType.write(value.network_type, buf) + _UniffiConverterOptionalBytes.write(value.payee_node_id, buf) - master_fingerprint: "str" - """ - Root fingerprint used in descriptors and PSBT key origins. - """ - account_index: "int" - accounts: "typing.List[PassportAccount]" - def __init__(self, *, master_fingerprint: "str", account_index: "int", accounts: "typing.List[PassportAccount]"): - self.master_fingerprint = master_fingerprint - self.account_index = account_index - self.accounts = accounts +class LnurlAddressData: + uri: "str" + domain: "str" + username: "str" + def __init__(self, *, uri: "str", domain: "str", username: "str"): + self.uri = uri + self.domain = domain + self.username = username def __str__(self): - return "PassportAccountExport(master_fingerprint={}, account_index={}, accounts={})".format(self.master_fingerprint, self.account_index, self.accounts) + return "LnurlAddressData(uri={}, domain={}, username={})".format(self.uri, self.domain, self.username) def __eq__(self, other): - if self.master_fingerprint != other.master_fingerprint: + if self.uri != other.uri: return False - if self.account_index != other.account_index: + if self.domain != other.domain: return False - if self.accounts != other.accounts: + if self.username != other.username: return False return True -class _UniffiConverterTypePassportAccountExport(_UniffiConverterRustBuffer): +class _UniffiConverterTypeLnurlAddressData(_UniffiConverterRustBuffer): @staticmethod def read(buf): - return PassportAccountExport( - master_fingerprint=_UniffiConverterString.read(buf), - account_index=_UniffiConverterUInt32.read(buf), - accounts=_UniffiConverterSequenceTypePassportAccount.read(buf), + return LnurlAddressData( + uri=_UniffiConverterString.read(buf), + domain=_UniffiConverterString.read(buf), + username=_UniffiConverterString.read(buf), ) @staticmethod def check_lower(value): - _UniffiConverterString.check_lower(value.master_fingerprint) - _UniffiConverterUInt32.check_lower(value.account_index) - _UniffiConverterSequenceTypePassportAccount.check_lower(value.accounts) + _UniffiConverterString.check_lower(value.uri) + _UniffiConverterString.check_lower(value.domain) + _UniffiConverterString.check_lower(value.username) @staticmethod def write(value, buf): - _UniffiConverterString.write(value.master_fingerprint, buf) - _UniffiConverterUInt32.write(value.account_index, buf) - _UniffiConverterSequenceTypePassportAccount.write(value.accounts, buf) + _UniffiConverterString.write(value.uri, buf) + _UniffiConverterString.write(value.domain, buf) + _UniffiConverterString.write(value.username, buf) -class PreActivityMetadata: - wallet_id: "str" - payment_id: "str" - tags: "typing.List[str]" - payment_hash: "typing.Optional[str]" - tx_id: "typing.Optional[str]" - address: "typing.Optional[str]" - is_receive: "bool" - fee_rate: "int" - is_transfer: "bool" - channel_id: "typing.Optional[str]" - created_at: "int" - def __init__(self, *, wallet_id: "str", payment_id: "str", tags: "typing.List[str]", payment_hash: "typing.Optional[str]", tx_id: "typing.Optional[str]", address: "typing.Optional[str]", is_receive: "bool", fee_rate: "int", is_transfer: "bool", channel_id: "typing.Optional[str]", created_at: "int"): - self.wallet_id = wallet_id - self.payment_id = payment_id - self.tags = tags - self.payment_hash = payment_hash - self.tx_id = tx_id - self.address = address - self.is_receive = is_receive - self.fee_rate = fee_rate - self.is_transfer = is_transfer - self.channel_id = channel_id - self.created_at = created_at +class LnurlAuthData: + uri: "str" + tag: "str" + k1: "str" + domain: "str" + def __init__(self, *, uri: "str", tag: "str", k1: "str", domain: "str"): + self.uri = uri + self.tag = tag + self.k1 = k1 + self.domain = domain def __str__(self): - return "PreActivityMetadata(wallet_id={}, payment_id={}, tags={}, payment_hash={}, tx_id={}, address={}, is_receive={}, fee_rate={}, is_transfer={}, channel_id={}, created_at={})".format(self.wallet_id, self.payment_id, self.tags, self.payment_hash, self.tx_id, self.address, self.is_receive, self.fee_rate, self.is_transfer, self.channel_id, self.created_at) + return "LnurlAuthData(uri={}, tag={}, k1={}, domain={})".format(self.uri, self.tag, self.k1, self.domain) def __eq__(self, other): - if self.wallet_id != other.wallet_id: - return False - if self.payment_id != other.payment_id: - return False - if self.tags != other.tags: - return False - if self.payment_hash != other.payment_hash: - return False - if self.tx_id != other.tx_id: - return False - if self.address != other.address: - return False - if self.is_receive != other.is_receive: - return False - if self.fee_rate != other.fee_rate: + if self.uri != other.uri: return False - if self.is_transfer != other.is_transfer: + if self.tag != other.tag: return False - if self.channel_id != other.channel_id: + if self.k1 != other.k1: return False - if self.created_at != other.created_at: + if self.domain != other.domain: return False return True -class _UniffiConverterTypePreActivityMetadata(_UniffiConverterRustBuffer): +class _UniffiConverterTypeLnurlAuthData(_UniffiConverterRustBuffer): @staticmethod def read(buf): - return PreActivityMetadata( - wallet_id=_UniffiConverterString.read(buf), - payment_id=_UniffiConverterString.read(buf), - tags=_UniffiConverterSequenceString.read(buf), - payment_hash=_UniffiConverterOptionalString.read(buf), - tx_id=_UniffiConverterOptionalString.read(buf), - address=_UniffiConverterOptionalString.read(buf), - is_receive=_UniffiConverterBool.read(buf), - fee_rate=_UniffiConverterUInt64.read(buf), - is_transfer=_UniffiConverterBool.read(buf), - channel_id=_UniffiConverterOptionalString.read(buf), - created_at=_UniffiConverterUInt64.read(buf), + return LnurlAuthData( + uri=_UniffiConverterString.read(buf), + tag=_UniffiConverterString.read(buf), + k1=_UniffiConverterString.read(buf), + domain=_UniffiConverterString.read(buf), ) @staticmethod def check_lower(value): - _UniffiConverterString.check_lower(value.wallet_id) - _UniffiConverterString.check_lower(value.payment_id) - _UniffiConverterSequenceString.check_lower(value.tags) - _UniffiConverterOptionalString.check_lower(value.payment_hash) - _UniffiConverterOptionalString.check_lower(value.tx_id) - _UniffiConverterOptionalString.check_lower(value.address) - _UniffiConverterBool.check_lower(value.is_receive) - _UniffiConverterUInt64.check_lower(value.fee_rate) - _UniffiConverterBool.check_lower(value.is_transfer) - _UniffiConverterOptionalString.check_lower(value.channel_id) - _UniffiConverterUInt64.check_lower(value.created_at) + _UniffiConverterString.check_lower(value.uri) + _UniffiConverterString.check_lower(value.tag) + _UniffiConverterString.check_lower(value.k1) + _UniffiConverterString.check_lower(value.domain) @staticmethod def write(value, buf): - _UniffiConverterString.write(value.wallet_id, buf) - _UniffiConverterString.write(value.payment_id, buf) - _UniffiConverterSequenceString.write(value.tags, buf) - _UniffiConverterOptionalString.write(value.payment_hash, buf) - _UniffiConverterOptionalString.write(value.tx_id, buf) - _UniffiConverterOptionalString.write(value.address, buf) - _UniffiConverterBool.write(value.is_receive, buf) - _UniffiConverterUInt64.write(value.fee_rate, buf) - _UniffiConverterBool.write(value.is_transfer, buf) - _UniffiConverterOptionalString.write(value.channel_id, buf) - _UniffiConverterUInt64.write(value.created_at, buf) + _UniffiConverterString.write(value.uri, buf) + _UniffiConverterString.write(value.tag, buf) + _UniffiConverterString.write(value.k1, buf) + _UniffiConverterString.write(value.domain, buf) -class PubkyAuth: - data: "str" - def __init__(self, *, data: "str"): - self.data = data +class LnurlChannelData: + uri: "str" + callback: "str" + k1: "str" + tag: "str" + def __init__(self, *, uri: "str", callback: "str", k1: "str", tag: "str"): + self.uri = uri + self.callback = callback + self.k1 = k1 + self.tag = tag def __str__(self): - return "PubkyAuth(data={})".format(self.data) + return "LnurlChannelData(uri={}, callback={}, k1={}, tag={})".format(self.uri, self.callback, self.k1, self.tag) def __eq__(self, other): - if self.data != other.data: + if self.uri != other.uri: + return False + if self.callback != other.callback: + return False + if self.k1 != other.k1: + return False + if self.tag != other.tag: return False return True -class _UniffiConverterTypePubkyAuth(_UniffiConverterRustBuffer): +class _UniffiConverterTypeLnurlChannelData(_UniffiConverterRustBuffer): @staticmethod def read(buf): - return PubkyAuth( - data=_UniffiConverterString.read(buf), + return LnurlChannelData( + uri=_UniffiConverterString.read(buf), + callback=_UniffiConverterString.read(buf), + k1=_UniffiConverterString.read(buf), + tag=_UniffiConverterString.read(buf), ) @staticmethod def check_lower(value): - _UniffiConverterString.check_lower(value.data) + _UniffiConverterString.check_lower(value.uri) + _UniffiConverterString.check_lower(value.callback) + _UniffiConverterString.check_lower(value.k1) + _UniffiConverterString.check_lower(value.tag) @staticmethod def write(value, buf): - _UniffiConverterString.write(value.data, buf) - - -class PubkyAuthDetails: - """ - Details extracted from a `pubkyauth://` deep-link URL. - """ - - kind: "PubkyAuthKind" - """ - Whether this is a signin or signup flow. - """ - - capabilities: "str" - """ - Requested capabilities (e.g. `"/pub/pubky.app/:rw"`). - """ - - relay: "str" - """ - Relay URL used for the auth exchange. - """ - - homeserver: "typing.Optional[str]" - """ - Homeserver public key (z32-encoded). Present only for signup flows. - """ + _UniffiConverterString.write(value.uri, buf) + _UniffiConverterString.write(value.callback, buf) + _UniffiConverterString.write(value.k1, buf) + _UniffiConverterString.write(value.tag, buf) - signup_token: "typing.Optional[str]" - """ - Signup token. Present only for signup flows. - """ - def __init__(self, *, kind: "PubkyAuthKind", capabilities: "str", relay: "str", homeserver: "typing.Optional[str]", signup_token: "typing.Optional[str]"): - self.kind = kind - self.capabilities = capabilities - self.relay = relay - self.homeserver = homeserver - self.signup_token = signup_token +class LnurlPayData: + uri: "str" + callback: "str" + min_sendable: "int" + max_sendable: "int" + metadata_str: "str" + comment_allowed: "typing.Optional[int]" + allows_nostr: "bool" + nostr_pubkey: "typing.Optional[bytes]" + def __init__(self, *, uri: "str", callback: "str", min_sendable: "int", max_sendable: "int", metadata_str: "str", comment_allowed: "typing.Optional[int]", allows_nostr: "bool", nostr_pubkey: "typing.Optional[bytes]"): + self.uri = uri + self.callback = callback + self.min_sendable = min_sendable + self.max_sendable = max_sendable + self.metadata_str = metadata_str + self.comment_allowed = comment_allowed + self.allows_nostr = allows_nostr + self.nostr_pubkey = nostr_pubkey def __str__(self): - return "PubkyAuthDetails(kind={}, capabilities={}, relay={}, homeserver={}, signup_token={})".format(self.kind, self.capabilities, self.relay, self.homeserver, self.signup_token) + return "LnurlPayData(uri={}, callback={}, min_sendable={}, max_sendable={}, metadata_str={}, comment_allowed={}, allows_nostr={}, nostr_pubkey={})".format(self.uri, self.callback, self.min_sendable, self.max_sendable, self.metadata_str, self.comment_allowed, self.allows_nostr, self.nostr_pubkey) def __eq__(self, other): - if self.kind != other.kind: + if self.uri != other.uri: return False - if self.capabilities != other.capabilities: + if self.callback != other.callback: return False - if self.relay != other.relay: + if self.min_sendable != other.min_sendable: return False - if self.homeserver != other.homeserver: + if self.max_sendable != other.max_sendable: return False - if self.signup_token != other.signup_token: + if self.metadata_str != other.metadata_str: + return False + if self.comment_allowed != other.comment_allowed: + return False + if self.allows_nostr != other.allows_nostr: + return False + if self.nostr_pubkey != other.nostr_pubkey: return False return True -class _UniffiConverterTypePubkyAuthDetails(_UniffiConverterRustBuffer): +class _UniffiConverterTypeLnurlPayData(_UniffiConverterRustBuffer): @staticmethod def read(buf): - return PubkyAuthDetails( - kind=_UniffiConverterTypePubkyAuthKind.read(buf), - capabilities=_UniffiConverterString.read(buf), - relay=_UniffiConverterString.read(buf), - homeserver=_UniffiConverterOptionalString.read(buf), - signup_token=_UniffiConverterOptionalString.read(buf), + return LnurlPayData( + uri=_UniffiConverterString.read(buf), + callback=_UniffiConverterString.read(buf), + min_sendable=_UniffiConverterUInt64.read(buf), + max_sendable=_UniffiConverterUInt64.read(buf), + metadata_str=_UniffiConverterString.read(buf), + comment_allowed=_UniffiConverterOptionalUInt32.read(buf), + allows_nostr=_UniffiConverterBool.read(buf), + nostr_pubkey=_UniffiConverterOptionalBytes.read(buf), ) @staticmethod def check_lower(value): - _UniffiConverterTypePubkyAuthKind.check_lower(value.kind) - _UniffiConverterString.check_lower(value.capabilities) - _UniffiConverterString.check_lower(value.relay) - _UniffiConverterOptionalString.check_lower(value.homeserver) - _UniffiConverterOptionalString.check_lower(value.signup_token) + _UniffiConverterString.check_lower(value.uri) + _UniffiConverterString.check_lower(value.callback) + _UniffiConverterUInt64.check_lower(value.min_sendable) + _UniffiConverterUInt64.check_lower(value.max_sendable) + _UniffiConverterString.check_lower(value.metadata_str) + _UniffiConverterOptionalUInt32.check_lower(value.comment_allowed) + _UniffiConverterBool.check_lower(value.allows_nostr) + _UniffiConverterOptionalBytes.check_lower(value.nostr_pubkey) @staticmethod def write(value, buf): - _UniffiConverterTypePubkyAuthKind.write(value.kind, buf) - _UniffiConverterString.write(value.capabilities, buf) - _UniffiConverterString.write(value.relay, buf) - _UniffiConverterOptionalString.write(value.homeserver, buf) - _UniffiConverterOptionalString.write(value.signup_token, buf) - - -class PubkyProfile: - name: "str" - bio: "typing.Optional[str]" - image: "typing.Optional[str]" - links: "typing.Optional[typing.List[PubkyProfileLink]]" - status: "typing.Optional[str]" - def __init__(self, *, name: "str", bio: "typing.Optional[str]", image: "typing.Optional[str]", links: "typing.Optional[typing.List[PubkyProfileLink]]", status: "typing.Optional[str]"): - self.name = name - self.bio = bio - self.image = image - self.links = links - self.status = status + _UniffiConverterString.write(value.uri, buf) + _UniffiConverterString.write(value.callback, buf) + _UniffiConverterUInt64.write(value.min_sendable, buf) + _UniffiConverterUInt64.write(value.max_sendable, buf) + _UniffiConverterString.write(value.metadata_str, buf) + _UniffiConverterOptionalUInt32.write(value.comment_allowed, buf) + _UniffiConverterBool.write(value.allows_nostr, buf) + _UniffiConverterOptionalBytes.write(value.nostr_pubkey, buf) - def __str__(self): - return "PubkyProfile(name={}, bio={}, image={}, links={}, status={})".format(self.name, self.bio, self.image, self.links, self.status) - def __eq__(self, other): - if self.name != other.name: - return False - if self.bio != other.bio: - return False - if self.image != other.image: - return False - if self.links != other.links: - return False - if self.status != other.status: - return False - return True - -class _UniffiConverterTypePubkyProfile(_UniffiConverterRustBuffer): - @staticmethod - def read(buf): - return PubkyProfile( - name=_UniffiConverterString.read(buf), - bio=_UniffiConverterOptionalString.read(buf), - image=_UniffiConverterOptionalString.read(buf), - links=_UniffiConverterOptionalSequenceTypePubkyProfileLink.read(buf), - status=_UniffiConverterOptionalString.read(buf), - ) - - @staticmethod - def check_lower(value): - _UniffiConverterString.check_lower(value.name) - _UniffiConverterOptionalString.check_lower(value.bio) - _UniffiConverterOptionalString.check_lower(value.image) - _UniffiConverterOptionalSequenceTypePubkyProfileLink.check_lower(value.links) - _UniffiConverterOptionalString.check_lower(value.status) - - @staticmethod - def write(value, buf): - _UniffiConverterString.write(value.name, buf) - _UniffiConverterOptionalString.write(value.bio, buf) - _UniffiConverterOptionalString.write(value.image, buf) - _UniffiConverterOptionalSequenceTypePubkyProfileLink.write(value.links, buf) - _UniffiConverterOptionalString.write(value.status, buf) - - -class PubkyProfileLink: - title: "str" - url: "str" - def __init__(self, *, title: "str", url: "str"): - self.title = title - self.url = url +class LnurlWithdrawData: + uri: "str" + callback: "str" + k1: "str" + default_description: "str" + min_withdrawable: "typing.Optional[int]" + max_withdrawable: "int" + tag: "str" + def __init__(self, *, uri: "str", callback: "str", k1: "str", default_description: "str", min_withdrawable: "typing.Optional[int]", max_withdrawable: "int", tag: "str"): + self.uri = uri + self.callback = callback + self.k1 = k1 + self.default_description = default_description + self.min_withdrawable = min_withdrawable + self.max_withdrawable = max_withdrawable + self.tag = tag def __str__(self): - return "PubkyProfileLink(title={}, url={})".format(self.title, self.url) + return "LnurlWithdrawData(uri={}, callback={}, k1={}, default_description={}, min_withdrawable={}, max_withdrawable={}, tag={})".format(self.uri, self.callback, self.k1, self.default_description, self.min_withdrawable, self.max_withdrawable, self.tag) def __eq__(self, other): - if self.title != other.title: + if self.uri != other.uri: return False - if self.url != other.url: + if self.callback != other.callback: + return False + if self.k1 != other.k1: + return False + if self.default_description != other.default_description: + return False + if self.min_withdrawable != other.min_withdrawable: + return False + if self.max_withdrawable != other.max_withdrawable: + return False + if self.tag != other.tag: return False return True -class _UniffiConverterTypePubkyProfileLink(_UniffiConverterRustBuffer): +class _UniffiConverterTypeLnurlWithdrawData(_UniffiConverterRustBuffer): @staticmethod def read(buf): - return PubkyProfileLink( - title=_UniffiConverterString.read(buf), - url=_UniffiConverterString.read(buf), + return LnurlWithdrawData( + uri=_UniffiConverterString.read(buf), + callback=_UniffiConverterString.read(buf), + k1=_UniffiConverterString.read(buf), + default_description=_UniffiConverterString.read(buf), + min_withdrawable=_UniffiConverterOptionalUInt64.read(buf), + max_withdrawable=_UniffiConverterUInt64.read(buf), + tag=_UniffiConverterString.read(buf), ) @staticmethod def check_lower(value): - _UniffiConverterString.check_lower(value.title) - _UniffiConverterString.check_lower(value.url) + _UniffiConverterString.check_lower(value.uri) + _UniffiConverterString.check_lower(value.callback) + _UniffiConverterString.check_lower(value.k1) + _UniffiConverterString.check_lower(value.default_description) + _UniffiConverterOptionalUInt64.check_lower(value.min_withdrawable) + _UniffiConverterUInt64.check_lower(value.max_withdrawable) + _UniffiConverterString.check_lower(value.tag) @staticmethod def write(value, buf): - _UniffiConverterString.write(value.title, buf) - _UniffiConverterString.write(value.url, buf) + _UniffiConverterString.write(value.uri, buf) + _UniffiConverterString.write(value.callback, buf) + _UniffiConverterString.write(value.k1, buf) + _UniffiConverterString.write(value.default_description, buf) + _UniffiConverterOptionalUInt64.write(value.min_withdrawable, buf) + _UniffiConverterUInt64.write(value.max_withdrawable, buf) + _UniffiConverterString.write(value.tag, buf) -class ReverseSwapResponse: +class NativeDeviceInfo: + """ + Native device information returned from enumeration """ - Result of creating a reverse swap (Lightning -> onchain). - The caller pays `invoice` from its Lightning node; once Boltz locks funds at - `lockup_address`, the module claims them to the provided onchain address. + path: "str" + """ + Unique path/identifier for this device """ - id: "str" - invoice: "str" + transport_type: "str" """ - Hold invoice the caller must pay via Lightning. + Transport type: "usb" or "bluetooth" """ - lockup_address: "str" + name: "typing.Optional[str]" """ - Address Boltz locks the onchain funds to. + Optional device name (from BLE advertisement or USB descriptor) """ - onchain_amount_sat: "int" + vendor_id: "typing.Optional[int]" """ - Amount in satoshis that will be received onchain (after Boltz fees). + USB Vendor ID (for USB devices) """ - timeout_block_height: "int" + product_id: "typing.Optional[int]" """ - Onchain timeout height for the swap. + USB Product ID (for USB devices) """ - def __init__(self, *, id: "str", invoice: "str", lockup_address: "str", onchain_amount_sat: "int", timeout_block_height: "int"): - self.id = id - self.invoice = invoice - self.lockup_address = lockup_address - self.onchain_amount_sat = onchain_amount_sat - self.timeout_block_height = timeout_block_height + def __init__(self, *, path: "str", transport_type: "str", name: "typing.Optional[str]", vendor_id: "typing.Optional[int]", product_id: "typing.Optional[int]"): + self.path = path + self.transport_type = transport_type + self.name = name + self.vendor_id = vendor_id + self.product_id = product_id def __str__(self): - return "ReverseSwapResponse(id={}, invoice={}, lockup_address={}, onchain_amount_sat={}, timeout_block_height={})".format(self.id, self.invoice, self.lockup_address, self.onchain_amount_sat, self.timeout_block_height) + return "NativeDeviceInfo(path={}, transport_type={}, name={}, vendor_id={}, product_id={})".format(self.path, self.transport_type, self.name, self.vendor_id, self.product_id) def __eq__(self, other): - if self.id != other.id: + if self.path != other.path: return False - if self.invoice != other.invoice: + if self.transport_type != other.transport_type: return False - if self.lockup_address != other.lockup_address: + if self.name != other.name: return False - if self.onchain_amount_sat != other.onchain_amount_sat: + if self.vendor_id != other.vendor_id: return False - if self.timeout_block_height != other.timeout_block_height: + if self.product_id != other.product_id: return False return True -class _UniffiConverterTypeReverseSwapResponse(_UniffiConverterRustBuffer): +class _UniffiConverterTypeNativeDeviceInfo(_UniffiConverterRustBuffer): @staticmethod def read(buf): - return ReverseSwapResponse( - id=_UniffiConverterString.read(buf), - invoice=_UniffiConverterString.read(buf), - lockup_address=_UniffiConverterString.read(buf), - onchain_amount_sat=_UniffiConverterUInt64.read(buf), - timeout_block_height=_UniffiConverterUInt64.read(buf), + return NativeDeviceInfo( + path=_UniffiConverterString.read(buf), + transport_type=_UniffiConverterString.read(buf), + name=_UniffiConverterOptionalString.read(buf), + vendor_id=_UniffiConverterOptionalUInt16.read(buf), + product_id=_UniffiConverterOptionalUInt16.read(buf), ) @staticmethod def check_lower(value): - _UniffiConverterString.check_lower(value.id) - _UniffiConverterString.check_lower(value.invoice) - _UniffiConverterString.check_lower(value.lockup_address) - _UniffiConverterUInt64.check_lower(value.onchain_amount_sat) - _UniffiConverterUInt64.check_lower(value.timeout_block_height) + _UniffiConverterString.check_lower(value.path) + _UniffiConverterString.check_lower(value.transport_type) + _UniffiConverterOptionalString.check_lower(value.name) + _UniffiConverterOptionalUInt16.check_lower(value.vendor_id) + _UniffiConverterOptionalUInt16.check_lower(value.product_id) @staticmethod def write(value, buf): - _UniffiConverterString.write(value.id, buf) - _UniffiConverterString.write(value.invoice, buf) - _UniffiConverterString.write(value.lockup_address, buf) - _UniffiConverterUInt64.write(value.onchain_amount_sat, buf) - _UniffiConverterUInt64.write(value.timeout_block_height, buf) - + _UniffiConverterString.write(value.path, buf) + _UniffiConverterString.write(value.transport_type, buf) + _UniffiConverterOptionalString.write(value.name, buf) + _UniffiConverterOptionalUInt16.write(value.vendor_id, buf) + _UniffiConverterOptionalUInt16.write(value.product_id, buf) -class SingleAddressInfoResult: - """ - Result from querying a single Bitcoin address. - """ +class OnChainInvoice: address: "str" - """ - The queried address - """ - - balance: "int" - """ - Total confirmed balance in satoshis - """ - - utxos: "typing.List[AccountUtxo]" - """ - UTXOs for this address - """ - - transfers: "int" - """ - Number of transactions involving this address - """ - - block_height: "int" - """ - Current blockchain tip height - """ - - def __init__(self, *, address: "str", balance: "int", utxos: "typing.List[AccountUtxo]", transfers: "int", block_height: "int"): + amount_satoshis: "int" + label: "typing.Optional[str]" + message: "typing.Optional[str]" + params: "typing.Optional[dict[str, str]]" + def __init__(self, *, address: "str", amount_satoshis: "int", label: "typing.Optional[str]", message: "typing.Optional[str]", params: "typing.Optional[dict[str, str]]"): self.address = address - self.balance = balance - self.utxos = utxos - self.transfers = transfers - self.block_height = block_height + self.amount_satoshis = amount_satoshis + self.label = label + self.message = message + self.params = params def __str__(self): - return "SingleAddressInfoResult(address={}, balance={}, utxos={}, transfers={}, block_height={})".format(self.address, self.balance, self.utxos, self.transfers, self.block_height) + return "OnChainInvoice(address={}, amount_satoshis={}, label={}, message={}, params={})".format(self.address, self.amount_satoshis, self.label, self.message, self.params) def __eq__(self, other): if self.address != other.address: return False - if self.balance != other.balance: + if self.amount_satoshis != other.amount_satoshis: return False - if self.utxos != other.utxos: + if self.label != other.label: return False - if self.transfers != other.transfers: + if self.message != other.message: return False - if self.block_height != other.block_height: + if self.params != other.params: return False return True -class _UniffiConverterTypeSingleAddressInfoResult(_UniffiConverterRustBuffer): +class _UniffiConverterTypeOnChainInvoice(_UniffiConverterRustBuffer): @staticmethod def read(buf): - return SingleAddressInfoResult( + return OnChainInvoice( address=_UniffiConverterString.read(buf), - balance=_UniffiConverterUInt64.read(buf), - utxos=_UniffiConverterSequenceTypeAccountUtxo.read(buf), - transfers=_UniffiConverterUInt32.read(buf), - block_height=_UniffiConverterUInt32.read(buf), + amount_satoshis=_UniffiConverterUInt64.read(buf), + label=_UniffiConverterOptionalString.read(buf), + message=_UniffiConverterOptionalString.read(buf), + params=_UniffiConverterOptionalMapStringString.read(buf), ) @staticmethod def check_lower(value): _UniffiConverterString.check_lower(value.address) - _UniffiConverterUInt64.check_lower(value.balance) - _UniffiConverterSequenceTypeAccountUtxo.check_lower(value.utxos) - _UniffiConverterUInt32.check_lower(value.transfers) - _UniffiConverterUInt32.check_lower(value.block_height) - - @staticmethod + _UniffiConverterUInt64.check_lower(value.amount_satoshis) + _UniffiConverterOptionalString.check_lower(value.label) + _UniffiConverterOptionalString.check_lower(value.message) + _UniffiConverterOptionalMapStringString.check_lower(value.params) + + @staticmethod def write(value, buf): _UniffiConverterString.write(value.address, buf) - _UniffiConverterUInt64.write(value.balance, buf) - _UniffiConverterSequenceTypeAccountUtxo.write(value.utxos, buf) - _UniffiConverterUInt32.write(value.transfers, buf) - _UniffiConverterUInt32.write(value.block_height, buf) - - -class SubmarineSwapResponse: - """ - Result of creating a submarine swap (onchain -> Lightning). + _UniffiConverterUInt64.write(value.amount_satoshis, buf) + _UniffiConverterOptionalString.write(value.label, buf) + _UniffiConverterOptionalString.write(value.message, buf) + _UniffiConverterOptionalMapStringString.write(value.params, buf) - The caller funds `address` with `expected_amount_sat` from its onchain - wallet; Boltz then pays the Lightning invoice supplied at creation. - """ +class OnchainActivity: + wallet_id: "str" id: "str" + tx_type: "PaymentType" + tx_id: "str" + value: "int" + fee: "int" + fee_rate: "int" address: "str" - """ - Onchain lockup address to send funds to. - """ - - bip21: "str" - """ - BIP21 URI for the lockup payment. - """ - - expected_amount_sat: "int" - """ - Exact amount in satoshis the caller must send to `address`. - """ - - accept_zero_conf: "bool" - """ - Whether Boltz will accept a zero-conf lockup. - """ - - timeout_block_height: "int" - """ - Onchain timeout height after which a refund is possible. - """ - - def __init__(self, *, id: "str", address: "str", bip21: "str", expected_amount_sat: "int", accept_zero_conf: "bool", timeout_block_height: "int"): + confirmed: "bool" + timestamp: "int" + is_boosted: "bool" + boost_tx_ids: "typing.List[str]" + is_transfer: "bool" + does_exist: "bool" + confirm_timestamp: "typing.Optional[int]" + channel_id: "typing.Optional[str]" + transfer_tx_id: "typing.Optional[str]" + contact: "typing.Optional[str]" + created_at: "typing.Optional[int]" + updated_at: "typing.Optional[int]" + seen_at: "typing.Optional[int]" + def __init__(self, *, wallet_id: "str", id: "str", tx_type: "PaymentType", tx_id: "str", value: "int", fee: "int", fee_rate: "int", address: "str", confirmed: "bool", timestamp: "int", is_boosted: "bool", boost_tx_ids: "typing.List[str]", is_transfer: "bool", does_exist: "bool", confirm_timestamp: "typing.Optional[int]", channel_id: "typing.Optional[str]", transfer_tx_id: "typing.Optional[str]", contact: "typing.Optional[str]", created_at: "typing.Optional[int]", updated_at: "typing.Optional[int]", seen_at: "typing.Optional[int]"): + self.wallet_id = wallet_id self.id = id + self.tx_type = tx_type + self.tx_id = tx_id + self.value = value + self.fee = fee + self.fee_rate = fee_rate self.address = address - self.bip21 = bip21 - self.expected_amount_sat = expected_amount_sat - self.accept_zero_conf = accept_zero_conf - self.timeout_block_height = timeout_block_height + self.confirmed = confirmed + self.timestamp = timestamp + self.is_boosted = is_boosted + self.boost_tx_ids = boost_tx_ids + self.is_transfer = is_transfer + self.does_exist = does_exist + self.confirm_timestamp = confirm_timestamp + self.channel_id = channel_id + self.transfer_tx_id = transfer_tx_id + self.contact = contact + self.created_at = created_at + self.updated_at = updated_at + self.seen_at = seen_at def __str__(self): - return "SubmarineSwapResponse(id={}, address={}, bip21={}, expected_amount_sat={}, accept_zero_conf={}, timeout_block_height={})".format(self.id, self.address, self.bip21, self.expected_amount_sat, self.accept_zero_conf, self.timeout_block_height) + return "OnchainActivity(wallet_id={}, id={}, tx_type={}, tx_id={}, value={}, fee={}, fee_rate={}, address={}, confirmed={}, timestamp={}, is_boosted={}, boost_tx_ids={}, is_transfer={}, does_exist={}, confirm_timestamp={}, channel_id={}, transfer_tx_id={}, contact={}, created_at={}, updated_at={}, seen_at={})".format(self.wallet_id, self.id, self.tx_type, self.tx_id, self.value, self.fee, self.fee_rate, self.address, self.confirmed, self.timestamp, self.is_boosted, self.boost_tx_ids, self.is_transfer, self.does_exist, self.confirm_timestamp, self.channel_id, self.transfer_tx_id, self.contact, self.created_at, self.updated_at, self.seen_at) def __eq__(self, other): + if self.wallet_id != other.wallet_id: + return False if self.id != other.id: return False + if self.tx_type != other.tx_type: + return False + if self.tx_id != other.tx_id: + return False + if self.value != other.value: + return False + if self.fee != other.fee: + return False + if self.fee_rate != other.fee_rate: + return False if self.address != other.address: return False - if self.bip21 != other.bip21: + if self.confirmed != other.confirmed: return False - if self.expected_amount_sat != other.expected_amount_sat: + if self.timestamp != other.timestamp: return False - if self.accept_zero_conf != other.accept_zero_conf: + if self.is_boosted != other.is_boosted: return False - if self.timeout_block_height != other.timeout_block_height: + if self.boost_tx_ids != other.boost_tx_ids: + return False + if self.is_transfer != other.is_transfer: + return False + if self.does_exist != other.does_exist: + return False + if self.confirm_timestamp != other.confirm_timestamp: + return False + if self.channel_id != other.channel_id: + return False + if self.transfer_tx_id != other.transfer_tx_id: + return False + if self.contact != other.contact: + return False + if self.created_at != other.created_at: + return False + if self.updated_at != other.updated_at: + return False + if self.seen_at != other.seen_at: return False return True -class _UniffiConverterTypeSubmarineSwapResponse(_UniffiConverterRustBuffer): +class _UniffiConverterTypeOnchainActivity(_UniffiConverterRustBuffer): @staticmethod def read(buf): - return SubmarineSwapResponse( + return OnchainActivity( + wallet_id=_UniffiConverterString.read(buf), id=_UniffiConverterString.read(buf), + tx_type=_UniffiConverterTypePaymentType.read(buf), + tx_id=_UniffiConverterString.read(buf), + value=_UniffiConverterUInt64.read(buf), + fee=_UniffiConverterUInt64.read(buf), + fee_rate=_UniffiConverterUInt64.read(buf), address=_UniffiConverterString.read(buf), - bip21=_UniffiConverterString.read(buf), - expected_amount_sat=_UniffiConverterUInt64.read(buf), - accept_zero_conf=_UniffiConverterBool.read(buf), - timeout_block_height=_UniffiConverterUInt64.read(buf), + confirmed=_UniffiConverterBool.read(buf), + timestamp=_UniffiConverterUInt64.read(buf), + is_boosted=_UniffiConverterBool.read(buf), + boost_tx_ids=_UniffiConverterSequenceString.read(buf), + is_transfer=_UniffiConverterBool.read(buf), + does_exist=_UniffiConverterBool.read(buf), + confirm_timestamp=_UniffiConverterOptionalUInt64.read(buf), + channel_id=_UniffiConverterOptionalString.read(buf), + transfer_tx_id=_UniffiConverterOptionalString.read(buf), + contact=_UniffiConverterOptionalString.read(buf), + created_at=_UniffiConverterOptionalUInt64.read(buf), + updated_at=_UniffiConverterOptionalUInt64.read(buf), + seen_at=_UniffiConverterOptionalUInt64.read(buf), ) @staticmethod def check_lower(value): + _UniffiConverterString.check_lower(value.wallet_id) _UniffiConverterString.check_lower(value.id) + _UniffiConverterTypePaymentType.check_lower(value.tx_type) + _UniffiConverterString.check_lower(value.tx_id) + _UniffiConverterUInt64.check_lower(value.value) + _UniffiConverterUInt64.check_lower(value.fee) + _UniffiConverterUInt64.check_lower(value.fee_rate) _UniffiConverterString.check_lower(value.address) - _UniffiConverterString.check_lower(value.bip21) - _UniffiConverterUInt64.check_lower(value.expected_amount_sat) - _UniffiConverterBool.check_lower(value.accept_zero_conf) - _UniffiConverterUInt64.check_lower(value.timeout_block_height) + _UniffiConverterBool.check_lower(value.confirmed) + _UniffiConverterUInt64.check_lower(value.timestamp) + _UniffiConverterBool.check_lower(value.is_boosted) + _UniffiConverterSequenceString.check_lower(value.boost_tx_ids) + _UniffiConverterBool.check_lower(value.is_transfer) + _UniffiConverterBool.check_lower(value.does_exist) + _UniffiConverterOptionalUInt64.check_lower(value.confirm_timestamp) + _UniffiConverterOptionalString.check_lower(value.channel_id) + _UniffiConverterOptionalString.check_lower(value.transfer_tx_id) + _UniffiConverterOptionalString.check_lower(value.contact) + _UniffiConverterOptionalUInt64.check_lower(value.created_at) + _UniffiConverterOptionalUInt64.check_lower(value.updated_at) + _UniffiConverterOptionalUInt64.check_lower(value.seen_at) @staticmethod def write(value, buf): + _UniffiConverterString.write(value.wallet_id, buf) _UniffiConverterString.write(value.id, buf) + _UniffiConverterTypePaymentType.write(value.tx_type, buf) + _UniffiConverterString.write(value.tx_id, buf) + _UniffiConverterUInt64.write(value.value, buf) + _UniffiConverterUInt64.write(value.fee, buf) + _UniffiConverterUInt64.write(value.fee_rate, buf) _UniffiConverterString.write(value.address, buf) - _UniffiConverterString.write(value.bip21, buf) - _UniffiConverterUInt64.write(value.expected_amount_sat, buf) - _UniffiConverterBool.write(value.accept_zero_conf, buf) - _UniffiConverterUInt64.write(value.timeout_block_height, buf) - - -class SupportedHardwareWallet: - """ - A hardware-wallet model Bitkit supports. - """ + _UniffiConverterBool.write(value.confirmed, buf) + _UniffiConverterUInt64.write(value.timestamp, buf) + _UniffiConverterBool.write(value.is_boosted, buf) + _UniffiConverterSequenceString.write(value.boost_tx_ids, buf) + _UniffiConverterBool.write(value.is_transfer, buf) + _UniffiConverterBool.write(value.does_exist, buf) + _UniffiConverterOptionalUInt64.write(value.confirm_timestamp, buf) + _UniffiConverterOptionalString.write(value.channel_id, buf) + _UniffiConverterOptionalString.write(value.transfer_tx_id, buf) + _UniffiConverterOptionalString.write(value.contact, buf) + _UniffiConverterOptionalUInt64.write(value.created_at, buf) + _UniffiConverterOptionalUInt64.write(value.updated_at, buf) + _UniffiConverterOptionalUInt64.write(value.seen_at, buf) - vendor: "HardwareWalletVendor" - vendor_name: "str" - """ - Human-readable manufacturer name, e.g. "Foundation". - """ - model: "str" +class PassportAccount: """ - Stable model identifier that applications can map to bundled assets. + One single-signature account in Passport's generic JSON export. """ - display_name: "str" + account_type: "AccountType" + xpub: "str" """ - Full user-facing name. + Standard xpub/tpub encoding used by Passport's export. """ - transports: "typing.List[HardwareWalletTransport]" + derivation_path: "str" """ - Transports over which the application can interact with this model. + Account-level BIP32 path, such as `m/84'/0'/0'`. """ - def __init__(self, *, vendor: "HardwareWalletVendor", vendor_name: "str", model: "str", display_name: "str", transports: "typing.List[HardwareWalletTransport]"): - self.vendor = vendor - self.vendor_name = vendor_name - self.model = model - self.display_name = display_name - self.transports = transports + def __init__(self, *, account_type: "AccountType", xpub: "str", derivation_path: "str"): + self.account_type = account_type + self.xpub = xpub + self.derivation_path = derivation_path def __str__(self): - return "SupportedHardwareWallet(vendor={}, vendor_name={}, model={}, display_name={}, transports={})".format(self.vendor, self.vendor_name, self.model, self.display_name, self.transports) + return "PassportAccount(account_type={}, xpub={}, derivation_path={})".format(self.account_type, self.xpub, self.derivation_path) def __eq__(self, other): - if self.vendor != other.vendor: - return False - if self.vendor_name != other.vendor_name: - return False - if self.model != other.model: + if self.account_type != other.account_type: return False - if self.display_name != other.display_name: + if self.xpub != other.xpub: return False - if self.transports != other.transports: + if self.derivation_path != other.derivation_path: return False return True -class _UniffiConverterTypeSupportedHardwareWallet(_UniffiConverterRustBuffer): +class _UniffiConverterTypePassportAccount(_UniffiConverterRustBuffer): @staticmethod def read(buf): - return SupportedHardwareWallet( - vendor=_UniffiConverterTypeHardwareWalletVendor.read(buf), - vendor_name=_UniffiConverterString.read(buf), - model=_UniffiConverterString.read(buf), - display_name=_UniffiConverterString.read(buf), - transports=_UniffiConverterSequenceTypeHardwareWalletTransport.read(buf), + return PassportAccount( + account_type=_UniffiConverterTypeAccountType.read(buf), + xpub=_UniffiConverterString.read(buf), + derivation_path=_UniffiConverterString.read(buf), ) @staticmethod def check_lower(value): - _UniffiConverterTypeHardwareWalletVendor.check_lower(value.vendor) - _UniffiConverterString.check_lower(value.vendor_name) - _UniffiConverterString.check_lower(value.model) - _UniffiConverterString.check_lower(value.display_name) - _UniffiConverterSequenceTypeHardwareWalletTransport.check_lower(value.transports) + _UniffiConverterTypeAccountType.check_lower(value.account_type) + _UniffiConverterString.check_lower(value.xpub) + _UniffiConverterString.check_lower(value.derivation_path) @staticmethod def write(value, buf): - _UniffiConverterTypeHardwareWalletVendor.write(value.vendor, buf) - _UniffiConverterString.write(value.vendor_name, buf) - _UniffiConverterString.write(value.model, buf) - _UniffiConverterString.write(value.display_name, buf) - _UniffiConverterSequenceTypeHardwareWalletTransport.write(value.transports, buf) + _UniffiConverterTypeAccountType.write(value.account_type, buf) + _UniffiConverterString.write(value.xpub, buf) + _UniffiConverterString.write(value.derivation_path, buf) -class SweepResult: - txid: "str" +class PassportAccountExport: """ - The transaction ID of the sweep transaction + The single-signature accounts exported by Passport for one account index. """ - amount_swept: "int" + master_fingerprint: "str" """ - The total amount swept (in satoshis) + Root fingerprint used in descriptors and PSBT key origins. """ - fee_paid: "int" - """ - The fee paid (in satoshis) - """ + account_index: "int" + accounts: "typing.List[PassportAccount]" + def __init__(self, *, master_fingerprint: "str", account_index: "int", accounts: "typing.List[PassportAccount]"): + self.master_fingerprint = master_fingerprint + self.account_index = account_index + self.accounts = accounts - utxos_swept: "int" - """ - The number of UTXOs swept - """ + def __str__(self): + return "PassportAccountExport(master_fingerprint={}, account_index={}, accounts={})".format(self.master_fingerprint, self.account_index, self.accounts) - def __init__(self, *, txid: "str", amount_swept: "int", fee_paid: "int", utxos_swept: "int"): - self.txid = txid - self.amount_swept = amount_swept - self.fee_paid = fee_paid - self.utxos_swept = utxos_swept + def __eq__(self, other): + if self.master_fingerprint != other.master_fingerprint: + return False + if self.account_index != other.account_index: + return False + if self.accounts != other.accounts: + return False + return True + +class _UniffiConverterTypePassportAccountExport(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + return PassportAccountExport( + master_fingerprint=_UniffiConverterString.read(buf), + account_index=_UniffiConverterUInt32.read(buf), + accounts=_UniffiConverterSequenceTypePassportAccount.read(buf), + ) + + @staticmethod + def check_lower(value): + _UniffiConverterString.check_lower(value.master_fingerprint) + _UniffiConverterUInt32.check_lower(value.account_index) + _UniffiConverterSequenceTypePassportAccount.check_lower(value.accounts) + + @staticmethod + def write(value, buf): + _UniffiConverterString.write(value.master_fingerprint, buf) + _UniffiConverterUInt32.write(value.account_index, buf) + _UniffiConverterSequenceTypePassportAccount.write(value.accounts, buf) + + +class PreActivityMetadata: + wallet_id: "str" + payment_id: "str" + tags: "typing.List[str]" + payment_hash: "typing.Optional[str]" + tx_id: "typing.Optional[str]" + address: "typing.Optional[str]" + is_receive: "bool" + fee_rate: "int" + is_transfer: "bool" + channel_id: "typing.Optional[str]" + created_at: "int" + def __init__(self, *, wallet_id: "str", payment_id: "str", tags: "typing.List[str]", payment_hash: "typing.Optional[str]", tx_id: "typing.Optional[str]", address: "typing.Optional[str]", is_receive: "bool", fee_rate: "int", is_transfer: "bool", channel_id: "typing.Optional[str]", created_at: "int"): + self.wallet_id = wallet_id + self.payment_id = payment_id + self.tags = tags + self.payment_hash = payment_hash + self.tx_id = tx_id + self.address = address + self.is_receive = is_receive + self.fee_rate = fee_rate + self.is_transfer = is_transfer + self.channel_id = channel_id + self.created_at = created_at def __str__(self): - return "SweepResult(txid={}, amount_swept={}, fee_paid={}, utxos_swept={})".format(self.txid, self.amount_swept, self.fee_paid, self.utxos_swept) + return "PreActivityMetadata(wallet_id={}, payment_id={}, tags={}, payment_hash={}, tx_id={}, address={}, is_receive={}, fee_rate={}, is_transfer={}, channel_id={}, created_at={})".format(self.wallet_id, self.payment_id, self.tags, self.payment_hash, self.tx_id, self.address, self.is_receive, self.fee_rate, self.is_transfer, self.channel_id, self.created_at) def __eq__(self, other): - if self.txid != other.txid: + if self.wallet_id != other.wallet_id: return False - if self.amount_swept != other.amount_swept: + if self.payment_id != other.payment_id: return False - if self.fee_paid != other.fee_paid: + if self.tags != other.tags: return False - if self.utxos_swept != other.utxos_swept: + if self.payment_hash != other.payment_hash: + return False + if self.tx_id != other.tx_id: + return False + if self.address != other.address: + return False + if self.is_receive != other.is_receive: + return False + if self.fee_rate != other.fee_rate: + return False + if self.is_transfer != other.is_transfer: + return False + if self.channel_id != other.channel_id: + return False + if self.created_at != other.created_at: return False return True -class _UniffiConverterTypeSweepResult(_UniffiConverterRustBuffer): +class _UniffiConverterTypePreActivityMetadata(_UniffiConverterRustBuffer): @staticmethod def read(buf): - return SweepResult( - txid=_UniffiConverterString.read(buf), - amount_swept=_UniffiConverterUInt64.read(buf), - fee_paid=_UniffiConverterUInt64.read(buf), - utxos_swept=_UniffiConverterUInt32.read(buf), + return PreActivityMetadata( + wallet_id=_UniffiConverterString.read(buf), + payment_id=_UniffiConverterString.read(buf), + tags=_UniffiConverterSequenceString.read(buf), + payment_hash=_UniffiConverterOptionalString.read(buf), + tx_id=_UniffiConverterOptionalString.read(buf), + address=_UniffiConverterOptionalString.read(buf), + is_receive=_UniffiConverterBool.read(buf), + fee_rate=_UniffiConverterUInt64.read(buf), + is_transfer=_UniffiConverterBool.read(buf), + channel_id=_UniffiConverterOptionalString.read(buf), + created_at=_UniffiConverterUInt64.read(buf), ) @staticmethod def check_lower(value): - _UniffiConverterString.check_lower(value.txid) - _UniffiConverterUInt64.check_lower(value.amount_swept) - _UniffiConverterUInt64.check_lower(value.fee_paid) - _UniffiConverterUInt32.check_lower(value.utxos_swept) + _UniffiConverterString.check_lower(value.wallet_id) + _UniffiConverterString.check_lower(value.payment_id) + _UniffiConverterSequenceString.check_lower(value.tags) + _UniffiConverterOptionalString.check_lower(value.payment_hash) + _UniffiConverterOptionalString.check_lower(value.tx_id) + _UniffiConverterOptionalString.check_lower(value.address) + _UniffiConverterBool.check_lower(value.is_receive) + _UniffiConverterUInt64.check_lower(value.fee_rate) + _UniffiConverterBool.check_lower(value.is_transfer) + _UniffiConverterOptionalString.check_lower(value.channel_id) + _UniffiConverterUInt64.check_lower(value.created_at) @staticmethod def write(value, buf): - _UniffiConverterString.write(value.txid, buf) - _UniffiConverterUInt64.write(value.amount_swept, buf) - _UniffiConverterUInt64.write(value.fee_paid, buf) - _UniffiConverterUInt32.write(value.utxos_swept, buf) + _UniffiConverterString.write(value.wallet_id, buf) + _UniffiConverterString.write(value.payment_id, buf) + _UniffiConverterSequenceString.write(value.tags, buf) + _UniffiConverterOptionalString.write(value.payment_hash, buf) + _UniffiConverterOptionalString.write(value.tx_id, buf) + _UniffiConverterOptionalString.write(value.address, buf) + _UniffiConverterBool.write(value.is_receive, buf) + _UniffiConverterUInt64.write(value.fee_rate, buf) + _UniffiConverterBool.write(value.is_transfer, buf) + _UniffiConverterOptionalString.write(value.channel_id, buf) + _UniffiConverterUInt64.write(value.created_at, buf) -class SweepTransactionPreview: - psbt: "str" - """ - The PSBT (Partially Signed Bitcoin Transaction) in base64 format - """ +class PubkyAuth: + data: "str" + def __init__(self, *, data: "str"): + self.data = data - total_amount: "int" + def __str__(self): + return "PubkyAuth(data={})".format(self.data) + + def __eq__(self, other): + if self.data != other.data: + return False + return True + +class _UniffiConverterTypePubkyAuth(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + return PubkyAuth( + data=_UniffiConverterString.read(buf), + ) + + @staticmethod + def check_lower(value): + _UniffiConverterString.check_lower(value.data) + + @staticmethod + def write(value, buf): + _UniffiConverterString.write(value.data, buf) + + +class PubkyAuthDetails: """ - The total amount available to sweep (in satoshis) + Details extracted from a `pubkyauth://` deep-link URL. """ - estimated_fee: "int" + kind: "PubkyAuthKind" """ - The estimated fee for the transaction (in satoshis) + Whether this is a signin or signup flow. """ - estimated_vsize: "int" + capabilities: "str" """ - The estimated virtual size of the transaction (in vbytes) + Requested capabilities (e.g. `"/pub/pubky.app/:rw"`). """ - utxos_count: "int" + relay: "str" """ - The number of UTXOs that will be swept + Relay URL used for the auth exchange. """ - destination_address: "str" + homeserver: "typing.Optional[str]" """ - The destination address + Homeserver public key (z32-encoded). Present only for signup flows. """ - amount_after_fees: "int" + signup_token: "typing.Optional[str]" """ - The amount that will be sent to destination after fees (in satoshis) + Signup token. Present only for signup flows. """ - def __init__(self, *, psbt: "str", total_amount: "int", estimated_fee: "int", estimated_vsize: "int", utxos_count: "int", destination_address: "str", amount_after_fees: "int"): - self.psbt = psbt - self.total_amount = total_amount - self.estimated_fee = estimated_fee - self.estimated_vsize = estimated_vsize - self.utxos_count = utxos_count - self.destination_address = destination_address - self.amount_after_fees = amount_after_fees + def __init__(self, *, kind: "PubkyAuthKind", capabilities: "str", relay: "str", homeserver: "typing.Optional[str]", signup_token: "typing.Optional[str]"): + self.kind = kind + self.capabilities = capabilities + self.relay = relay + self.homeserver = homeserver + self.signup_token = signup_token def __str__(self): - return "SweepTransactionPreview(psbt={}, total_amount={}, estimated_fee={}, estimated_vsize={}, utxos_count={}, destination_address={}, amount_after_fees={})".format(self.psbt, self.total_amount, self.estimated_fee, self.estimated_vsize, self.utxos_count, self.destination_address, self.amount_after_fees) + return "PubkyAuthDetails(kind={}, capabilities={}, relay={}, homeserver={}, signup_token={})".format(self.kind, self.capabilities, self.relay, self.homeserver, self.signup_token) def __eq__(self, other): - if self.psbt != other.psbt: + if self.kind != other.kind: return False - if self.total_amount != other.total_amount: + if self.capabilities != other.capabilities: return False - if self.estimated_fee != other.estimated_fee: + if self.relay != other.relay: return False - if self.estimated_vsize != other.estimated_vsize: + if self.homeserver != other.homeserver: return False - if self.utxos_count != other.utxos_count: + if self.signup_token != other.signup_token: return False - if self.destination_address != other.destination_address: + return True + +class _UniffiConverterTypePubkyAuthDetails(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + return PubkyAuthDetails( + kind=_UniffiConverterTypePubkyAuthKind.read(buf), + capabilities=_UniffiConverterString.read(buf), + relay=_UniffiConverterString.read(buf), + homeserver=_UniffiConverterOptionalString.read(buf), + signup_token=_UniffiConverterOptionalString.read(buf), + ) + + @staticmethod + def check_lower(value): + _UniffiConverterTypePubkyAuthKind.check_lower(value.kind) + _UniffiConverterString.check_lower(value.capabilities) + _UniffiConverterString.check_lower(value.relay) + _UniffiConverterOptionalString.check_lower(value.homeserver) + _UniffiConverterOptionalString.check_lower(value.signup_token) + + @staticmethod + def write(value, buf): + _UniffiConverterTypePubkyAuthKind.write(value.kind, buf) + _UniffiConverterString.write(value.capabilities, buf) + _UniffiConverterString.write(value.relay, buf) + _UniffiConverterOptionalString.write(value.homeserver, buf) + _UniffiConverterOptionalString.write(value.signup_token, buf) + + +class PubkyProfile: + name: "str" + bio: "typing.Optional[str]" + image: "typing.Optional[str]" + links: "typing.Optional[typing.List[PubkyProfileLink]]" + status: "typing.Optional[str]" + def __init__(self, *, name: "str", bio: "typing.Optional[str]", image: "typing.Optional[str]", links: "typing.Optional[typing.List[PubkyProfileLink]]", status: "typing.Optional[str]"): + self.name = name + self.bio = bio + self.image = image + self.links = links + self.status = status + + def __str__(self): + return "PubkyProfile(name={}, bio={}, image={}, links={}, status={})".format(self.name, self.bio, self.image, self.links, self.status) + + def __eq__(self, other): + if self.name != other.name: return False - if self.amount_after_fees != other.amount_after_fees: + if self.bio != other.bio: + return False + if self.image != other.image: + return False + if self.links != other.links: + return False + if self.status != other.status: return False return True -class _UniffiConverterTypeSweepTransactionPreview(_UniffiConverterRustBuffer): +class _UniffiConverterTypePubkyProfile(_UniffiConverterRustBuffer): @staticmethod def read(buf): - return SweepTransactionPreview( - psbt=_UniffiConverterString.read(buf), - total_amount=_UniffiConverterUInt64.read(buf), - estimated_fee=_UniffiConverterUInt64.read(buf), - estimated_vsize=_UniffiConverterUInt64.read(buf), - utxos_count=_UniffiConverterUInt32.read(buf), - destination_address=_UniffiConverterString.read(buf), - amount_after_fees=_UniffiConverterUInt64.read(buf), + return PubkyProfile( + name=_UniffiConverterString.read(buf), + bio=_UniffiConverterOptionalString.read(buf), + image=_UniffiConverterOptionalString.read(buf), + links=_UniffiConverterOptionalSequenceTypePubkyProfileLink.read(buf), + status=_UniffiConverterOptionalString.read(buf), ) @staticmethod def check_lower(value): - _UniffiConverterString.check_lower(value.psbt) - _UniffiConverterUInt64.check_lower(value.total_amount) - _UniffiConverterUInt64.check_lower(value.estimated_fee) - _UniffiConverterUInt64.check_lower(value.estimated_vsize) - _UniffiConverterUInt32.check_lower(value.utxos_count) - _UniffiConverterString.check_lower(value.destination_address) - _UniffiConverterUInt64.check_lower(value.amount_after_fees) + _UniffiConverterString.check_lower(value.name) + _UniffiConverterOptionalString.check_lower(value.bio) + _UniffiConverterOptionalString.check_lower(value.image) + _UniffiConverterOptionalSequenceTypePubkyProfileLink.check_lower(value.links) + _UniffiConverterOptionalString.check_lower(value.status) @staticmethod def write(value, buf): - _UniffiConverterString.write(value.psbt, buf) - _UniffiConverterUInt64.write(value.total_amount, buf) - _UniffiConverterUInt64.write(value.estimated_fee, buf) - _UniffiConverterUInt64.write(value.estimated_vsize, buf) - _UniffiConverterUInt32.write(value.utxos_count, buf) - _UniffiConverterString.write(value.destination_address, buf) - _UniffiConverterUInt64.write(value.amount_after_fees, buf) + _UniffiConverterString.write(value.name, buf) + _UniffiConverterOptionalString.write(value.bio, buf) + _UniffiConverterOptionalString.write(value.image, buf) + _UniffiConverterOptionalSequenceTypePubkyProfileLink.write(value.links, buf) + _UniffiConverterOptionalString.write(value.status, buf) -class SweepableBalances: - legacy_balance: "int" - """ - Balance in legacy (P2PKH) addresses (in satoshis) - """ +class PubkyProfileLink: + title: "str" + url: "str" + def __init__(self, *, title: "str", url: "str"): + self.title = title + self.url = url - p2sh_balance: "int" - """ - Balance in P2SH-SegWit (P2SH-P2WPKH) addresses (in satoshis) - """ + def __str__(self): + return "PubkyProfileLink(title={}, url={})".format(self.title, self.url) - taproot_balance: "int" - """ - Balance in Taproot (P2TR) addresses (in satoshis) - """ + def __eq__(self, other): + if self.title != other.title: + return False + if self.url != other.url: + return False + return True - total_balance: "int" +class _UniffiConverterTypePubkyProfileLink(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + return PubkyProfileLink( + title=_UniffiConverterString.read(buf), + url=_UniffiConverterString.read(buf), + ) + + @staticmethod + def check_lower(value): + _UniffiConverterString.check_lower(value.title) + _UniffiConverterString.check_lower(value.url) + + @staticmethod + def write(value, buf): + _UniffiConverterString.write(value.title, buf) + _UniffiConverterString.write(value.url, buf) + + +class ReverseSwapResponse: """ - Total balance across all wallet types (in satoshis) + Result of creating a reverse swap (Lightning -> onchain). + + The caller pays `invoice` from its Lightning node; once Boltz locks funds at + `lockup_address`, the module claims them to the provided onchain address. """ - legacy_utxos_count: "int" + id: "str" + invoice: "str" """ - Number of UTXOs in legacy wallet + Hold invoice the caller must pay via Lightning. """ - p2sh_utxos_count: "int" + lockup_address: "str" """ - Number of UTXOs in P2SH-SegWit wallet + Address Boltz locks the onchain funds to. """ - taproot_utxos_count: "int" + onchain_amount_sat: "int" """ - Number of UTXOs in Taproot wallet + Amount in satoshis that will be received onchain (after Boltz fees). """ - total_utxos_count: "int" + timeout_block_height: "int" """ - Total number of UTXOs across all wallet types + Onchain timeout height for the swap. """ - def __init__(self, *, legacy_balance: "int", p2sh_balance: "int", taproot_balance: "int", total_balance: "int", legacy_utxos_count: "int", p2sh_utxos_count: "int", taproot_utxos_count: "int", total_utxos_count: "int"): - self.legacy_balance = legacy_balance - self.p2sh_balance = p2sh_balance - self.taproot_balance = taproot_balance - self.total_balance = total_balance - self.legacy_utxos_count = legacy_utxos_count - self.p2sh_utxos_count = p2sh_utxos_count - self.taproot_utxos_count = taproot_utxos_count - self.total_utxos_count = total_utxos_count + def __init__(self, *, id: "str", invoice: "str", lockup_address: "str", onchain_amount_sat: "int", timeout_block_height: "int"): + self.id = id + self.invoice = invoice + self.lockup_address = lockup_address + self.onchain_amount_sat = onchain_amount_sat + self.timeout_block_height = timeout_block_height def __str__(self): - return "SweepableBalances(legacy_balance={}, p2sh_balance={}, taproot_balance={}, total_balance={}, legacy_utxos_count={}, p2sh_utxos_count={}, taproot_utxos_count={}, total_utxos_count={})".format(self.legacy_balance, self.p2sh_balance, self.taproot_balance, self.total_balance, self.legacy_utxos_count, self.p2sh_utxos_count, self.taproot_utxos_count, self.total_utxos_count) + return "ReverseSwapResponse(id={}, invoice={}, lockup_address={}, onchain_amount_sat={}, timeout_block_height={})".format(self.id, self.invoice, self.lockup_address, self.onchain_amount_sat, self.timeout_block_height) def __eq__(self, other): - if self.legacy_balance != other.legacy_balance: - return False - if self.p2sh_balance != other.p2sh_balance: - return False - if self.taproot_balance != other.taproot_balance: - return False - if self.total_balance != other.total_balance: + if self.id != other.id: return False - if self.legacy_utxos_count != other.legacy_utxos_count: + if self.invoice != other.invoice: return False - if self.p2sh_utxos_count != other.p2sh_utxos_count: + if self.lockup_address != other.lockup_address: return False - if self.taproot_utxos_count != other.taproot_utxos_count: + if self.onchain_amount_sat != other.onchain_amount_sat: return False - if self.total_utxos_count != other.total_utxos_count: + if self.timeout_block_height != other.timeout_block_height: return False return True -class _UniffiConverterTypeSweepableBalances(_UniffiConverterRustBuffer): +class _UniffiConverterTypeReverseSwapResponse(_UniffiConverterRustBuffer): @staticmethod def read(buf): - return SweepableBalances( - legacy_balance=_UniffiConverterUInt64.read(buf), - p2sh_balance=_UniffiConverterUInt64.read(buf), - taproot_balance=_UniffiConverterUInt64.read(buf), - total_balance=_UniffiConverterUInt64.read(buf), - legacy_utxos_count=_UniffiConverterUInt32.read(buf), - p2sh_utxos_count=_UniffiConverterUInt32.read(buf), - taproot_utxos_count=_UniffiConverterUInt32.read(buf), - total_utxos_count=_UniffiConverterUInt32.read(buf), + return ReverseSwapResponse( + id=_UniffiConverterString.read(buf), + invoice=_UniffiConverterString.read(buf), + lockup_address=_UniffiConverterString.read(buf), + onchain_amount_sat=_UniffiConverterUInt64.read(buf), + timeout_block_height=_UniffiConverterUInt64.read(buf), ) @staticmethod def check_lower(value): - _UniffiConverterUInt64.check_lower(value.legacy_balance) - _UniffiConverterUInt64.check_lower(value.p2sh_balance) - _UniffiConverterUInt64.check_lower(value.taproot_balance) - _UniffiConverterUInt64.check_lower(value.total_balance) - _UniffiConverterUInt32.check_lower(value.legacy_utxos_count) - _UniffiConverterUInt32.check_lower(value.p2sh_utxos_count) - _UniffiConverterUInt32.check_lower(value.taproot_utxos_count) - _UniffiConverterUInt32.check_lower(value.total_utxos_count) + _UniffiConverterString.check_lower(value.id) + _UniffiConverterString.check_lower(value.invoice) + _UniffiConverterString.check_lower(value.lockup_address) + _UniffiConverterUInt64.check_lower(value.onchain_amount_sat) + _UniffiConverterUInt64.check_lower(value.timeout_block_height) @staticmethod def write(value, buf): - _UniffiConverterUInt64.write(value.legacy_balance, buf) - _UniffiConverterUInt64.write(value.p2sh_balance, buf) - _UniffiConverterUInt64.write(value.taproot_balance, buf) - _UniffiConverterUInt64.write(value.total_balance, buf) - _UniffiConverterUInt32.write(value.legacy_utxos_count, buf) - _UniffiConverterUInt32.write(value.p2sh_utxos_count, buf) - _UniffiConverterUInt32.write(value.taproot_utxos_count, buf) - _UniffiConverterUInt32.write(value.total_utxos_count, buf) + _UniffiConverterString.write(value.id, buf) + _UniffiConverterString.write(value.invoice, buf) + _UniffiConverterString.write(value.lockup_address, buf) + _UniffiConverterUInt64.write(value.onchain_amount_sat, buf) + _UniffiConverterUInt64.write(value.timeout_block_height, buf) -class TransactionDetail: +class SingleAddressInfoResult: """ - Full details for a single transaction, including raw inputs/outputs and size metrics. + Result from querying a single Bitcoin address. """ - txid: "str" + address: "str" """ - Transaction ID (hex) + The queried address """ - received: "int" + balance: "int" """ - Amount received by the wallet (sats) + Total confirmed balance in satoshis """ - sent: "int" + utxos: "typing.List[AccountUtxo]" """ - Amount sent by the wallet (sats) — includes change sent back to self + UTXOs for this address """ - net: "int" + transfers: "int" """ - Net value from wallet's perspective: received - sent (positive = inflow, negative = outflow) + Number of transactions involving this address """ - amount: "int" + block_height: "int" """ - Display amount in sats (same semantics as HistoryTransaction.amount) + Current blockchain tip height """ - fee: "typing.Optional[int]" - """ - Transaction fee in sats (None if not available) - """ + def __init__(self, *, address: "str", balance: "int", utxos: "typing.List[AccountUtxo]", transfers: "int", block_height: "int"): + self.address = address + self.balance = balance + self.utxos = utxos + self.transfers = transfers + self.block_height = block_height - direction: "TxDirection" - """ - Transaction direction - """ + def __str__(self): + return "SingleAddressInfoResult(address={}, balance={}, utxos={}, transfers={}, block_height={})".format(self.address, self.balance, self.utxos, self.transfers, self.block_height) - block_height: "typing.Optional[int]" - """ - Block height (None if unconfirmed/mempool) - """ + def __eq__(self, other): + if self.address != other.address: + return False + if self.balance != other.balance: + return False + if self.utxos != other.utxos: + return False + if self.transfers != other.transfers: + return False + if self.block_height != other.block_height: + return False + return True - timestamp: "typing.Optional[int]" - """ - Block timestamp as unix epoch seconds (None if unconfirmed) - """ +class _UniffiConverterTypeSingleAddressInfoResult(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + return SingleAddressInfoResult( + address=_UniffiConverterString.read(buf), + balance=_UniffiConverterUInt64.read(buf), + utxos=_UniffiConverterSequenceTypeAccountUtxo.read(buf), + transfers=_UniffiConverterUInt32.read(buf), + block_height=_UniffiConverterUInt32.read(buf), + ) - confirmations: "int" - """ - Number of confirmations (0 if unconfirmed) - """ + @staticmethod + def check_lower(value): + _UniffiConverterString.check_lower(value.address) + _UniffiConverterUInt64.check_lower(value.balance) + _UniffiConverterSequenceTypeAccountUtxo.check_lower(value.utxos) + _UniffiConverterUInt32.check_lower(value.transfers) + _UniffiConverterUInt32.check_lower(value.block_height) - inputs: "typing.List[TxDetailInput]" + @staticmethod + def write(value, buf): + _UniffiConverterString.write(value.address, buf) + _UniffiConverterUInt64.write(value.balance, buf) + _UniffiConverterSequenceTypeAccountUtxo.write(value.utxos, buf) + _UniffiConverterUInt32.write(value.transfers, buf) + _UniffiConverterUInt32.write(value.block_height, buf) + + +class SubmarineSwapResponse: """ - Transaction inputs + Result of creating a submarine swap (onchain -> Lightning). + + The caller funds `address` with `expected_amount_sat` from its onchain + wallet; Boltz then pays the Lightning invoice supplied at creation. """ - outputs: "typing.List[TxDetailOutput]" + id: "str" + address: "str" """ - Transaction outputs + Onchain lockup address to send funds to. """ - size: "int" + bip21: "str" """ - Serialized transaction size in bytes + BIP21 URI for the lockup payment. """ - vsize: "int" + expected_amount_sat: "int" """ - Virtual size in vbytes (ceil(weight / 4)) + Exact amount in satoshis the caller must send to `address`. """ - weight: "int" + accept_zero_conf: "bool" """ - Transaction weight in weight units + Whether Boltz will accept a zero-conf lockup. """ - fee_rate: "typing.Optional[float]" + timeout_block_height: "int" """ - Fee rate in sat/vB (fee / vsize), None if fee is unavailable or vsize is zero + Onchain timeout height after which a refund is possible. """ - def __init__(self, *, txid: "str", received: "int", sent: "int", net: "int", amount: "int", fee: "typing.Optional[int]", direction: "TxDirection", block_height: "typing.Optional[int]", timestamp: "typing.Optional[int]", confirmations: "int", inputs: "typing.List[TxDetailInput]", outputs: "typing.List[TxDetailOutput]", size: "int", vsize: "int", weight: "int", fee_rate: "typing.Optional[float]"): - self.txid = txid - self.received = received - self.sent = sent - self.net = net - self.amount = amount - self.fee = fee - self.direction = direction - self.block_height = block_height - self.timestamp = timestamp - self.confirmations = confirmations - self.inputs = inputs - self.outputs = outputs - self.size = size - self.vsize = vsize - self.weight = weight - self.fee_rate = fee_rate + def __init__(self, *, id: "str", address: "str", bip21: "str", expected_amount_sat: "int", accept_zero_conf: "bool", timeout_block_height: "int"): + self.id = id + self.address = address + self.bip21 = bip21 + self.expected_amount_sat = expected_amount_sat + self.accept_zero_conf = accept_zero_conf + self.timeout_block_height = timeout_block_height def __str__(self): - return "TransactionDetail(txid={}, received={}, sent={}, net={}, amount={}, fee={}, direction={}, block_height={}, timestamp={}, confirmations={}, inputs={}, outputs={}, size={}, vsize={}, weight={}, fee_rate={})".format(self.txid, self.received, self.sent, self.net, self.amount, self.fee, self.direction, self.block_height, self.timestamp, self.confirmations, self.inputs, self.outputs, self.size, self.vsize, self.weight, self.fee_rate) + return "SubmarineSwapResponse(id={}, address={}, bip21={}, expected_amount_sat={}, accept_zero_conf={}, timeout_block_height={})".format(self.id, self.address, self.bip21, self.expected_amount_sat, self.accept_zero_conf, self.timeout_block_height) def __eq__(self, other): - if self.txid != other.txid: - return False - if self.received != other.received: - return False - if self.sent != other.sent: - return False - if self.net != other.net: - return False - if self.amount != other.amount: - return False - if self.fee != other.fee: - return False - if self.direction != other.direction: - return False - if self.block_height != other.block_height: - return False - if self.timestamp != other.timestamp: - return False - if self.confirmations != other.confirmations: - return False - if self.inputs != other.inputs: + if self.id != other.id: return False - if self.outputs != other.outputs: + if self.address != other.address: return False - if self.size != other.size: + if self.bip21 != other.bip21: return False - if self.vsize != other.vsize: + if self.expected_amount_sat != other.expected_amount_sat: return False - if self.weight != other.weight: + if self.accept_zero_conf != other.accept_zero_conf: return False - if self.fee_rate != other.fee_rate: + if self.timeout_block_height != other.timeout_block_height: return False return True -class _UniffiConverterTypeTransactionDetail(_UniffiConverterRustBuffer): +class _UniffiConverterTypeSubmarineSwapResponse(_UniffiConverterRustBuffer): @staticmethod def read(buf): - return TransactionDetail( - txid=_UniffiConverterString.read(buf), - received=_UniffiConverterUInt64.read(buf), - sent=_UniffiConverterUInt64.read(buf), - net=_UniffiConverterInt64.read(buf), - amount=_UniffiConverterUInt64.read(buf), - fee=_UniffiConverterOptionalUInt64.read(buf), - direction=_UniffiConverterTypeTxDirection.read(buf), - block_height=_UniffiConverterOptionalUInt32.read(buf), - timestamp=_UniffiConverterOptionalUInt64.read(buf), - confirmations=_UniffiConverterUInt32.read(buf), - inputs=_UniffiConverterSequenceTypeTxDetailInput.read(buf), - outputs=_UniffiConverterSequenceTypeTxDetailOutput.read(buf), - size=_UniffiConverterUInt32.read(buf), - vsize=_UniffiConverterUInt32.read(buf), - weight=_UniffiConverterUInt32.read(buf), - fee_rate=_UniffiConverterOptionalDouble.read(buf), + return SubmarineSwapResponse( + id=_UniffiConverterString.read(buf), + address=_UniffiConverterString.read(buf), + bip21=_UniffiConverterString.read(buf), + expected_amount_sat=_UniffiConverterUInt64.read(buf), + accept_zero_conf=_UniffiConverterBool.read(buf), + timeout_block_height=_UniffiConverterUInt64.read(buf), ) @staticmethod def check_lower(value): - _UniffiConverterString.check_lower(value.txid) - _UniffiConverterUInt64.check_lower(value.received) - _UniffiConverterUInt64.check_lower(value.sent) - _UniffiConverterInt64.check_lower(value.net) - _UniffiConverterUInt64.check_lower(value.amount) - _UniffiConverterOptionalUInt64.check_lower(value.fee) - _UniffiConverterTypeTxDirection.check_lower(value.direction) - _UniffiConverterOptionalUInt32.check_lower(value.block_height) - _UniffiConverterOptionalUInt64.check_lower(value.timestamp) - _UniffiConverterUInt32.check_lower(value.confirmations) - _UniffiConverterSequenceTypeTxDetailInput.check_lower(value.inputs) - _UniffiConverterSequenceTypeTxDetailOutput.check_lower(value.outputs) - _UniffiConverterUInt32.check_lower(value.size) - _UniffiConverterUInt32.check_lower(value.vsize) - _UniffiConverterUInt32.check_lower(value.weight) - _UniffiConverterOptionalDouble.check_lower(value.fee_rate) + _UniffiConverterString.check_lower(value.id) + _UniffiConverterString.check_lower(value.address) + _UniffiConverterString.check_lower(value.bip21) + _UniffiConverterUInt64.check_lower(value.expected_amount_sat) + _UniffiConverterBool.check_lower(value.accept_zero_conf) + _UniffiConverterUInt64.check_lower(value.timeout_block_height) @staticmethod def write(value, buf): - _UniffiConverterString.write(value.txid, buf) - _UniffiConverterUInt64.write(value.received, buf) - _UniffiConverterUInt64.write(value.sent, buf) - _UniffiConverterInt64.write(value.net, buf) - _UniffiConverterUInt64.write(value.amount, buf) - _UniffiConverterOptionalUInt64.write(value.fee, buf) - _UniffiConverterTypeTxDirection.write(value.direction, buf) - _UniffiConverterOptionalUInt32.write(value.block_height, buf) - _UniffiConverterOptionalUInt64.write(value.timestamp, buf) - _UniffiConverterUInt32.write(value.confirmations, buf) - _UniffiConverterSequenceTypeTxDetailInput.write(value.inputs, buf) - _UniffiConverterSequenceTypeTxDetailOutput.write(value.outputs, buf) - _UniffiConverterUInt32.write(value.size, buf) - _UniffiConverterUInt32.write(value.vsize, buf) - _UniffiConverterUInt32.write(value.weight, buf) - _UniffiConverterOptionalDouble.write(value.fee_rate, buf) + _UniffiConverterString.write(value.id, buf) + _UniffiConverterString.write(value.address, buf) + _UniffiConverterString.write(value.bip21, buf) + _UniffiConverterUInt64.write(value.expected_amount_sat, buf) + _UniffiConverterBool.write(value.accept_zero_conf, buf) + _UniffiConverterUInt64.write(value.timeout_block_height, buf) -class TransactionDetails: +class SupportedHardwareWallet: """ - Details about an onchain transaction. + A hardware-wallet model Bitkit supports. """ - wallet_id: "str" - tx_id: "str" + vendor: "HardwareWalletVendor" + vendor_name: "str" """ - The transaction ID. + Human-readable manufacturer name, e.g. "Foundation". """ - amount_sats: "int" + model: "str" + """ + Stable model identifier that applications can map to bundled assets. """ - The net amount in this transaction (in satoshis). - This is calculated as: (received - sent). For incoming payments, - this will be positive. For outgoing payments, this will be negative. - - Note: This amount does NOT include transaction fees. - """ - - inputs: "typing.List[TxInput]" + display_name: "str" """ - The transaction inputs with full details. + Full user-facing name. """ - outputs: "typing.List[TxOutput]" + transports: "typing.List[HardwareWalletTransport]" """ - The transaction outputs with full details. + Transports over which the application can interact with this model. """ - def __init__(self, *, wallet_id: "str", tx_id: "str", amount_sats: "int", inputs: "typing.List[TxInput]", outputs: "typing.List[TxOutput]"): - self.wallet_id = wallet_id - self.tx_id = tx_id - self.amount_sats = amount_sats - self.inputs = inputs - self.outputs = outputs + def __init__(self, *, vendor: "HardwareWalletVendor", vendor_name: "str", model: "str", display_name: "str", transports: "typing.List[HardwareWalletTransport]"): + self.vendor = vendor + self.vendor_name = vendor_name + self.model = model + self.display_name = display_name + self.transports = transports def __str__(self): - return "TransactionDetails(wallet_id={}, tx_id={}, amount_sats={}, inputs={}, outputs={})".format(self.wallet_id, self.tx_id, self.amount_sats, self.inputs, self.outputs) + return "SupportedHardwareWallet(vendor={}, vendor_name={}, model={}, display_name={}, transports={})".format(self.vendor, self.vendor_name, self.model, self.display_name, self.transports) def __eq__(self, other): - if self.wallet_id != other.wallet_id: + if self.vendor != other.vendor: return False - if self.tx_id != other.tx_id: + if self.vendor_name != other.vendor_name: return False - if self.amount_sats != other.amount_sats: + if self.model != other.model: return False - if self.inputs != other.inputs: + if self.display_name != other.display_name: return False - if self.outputs != other.outputs: + if self.transports != other.transports: return False return True -class _UniffiConverterTypeTransactionDetails(_UniffiConverterRustBuffer): +class _UniffiConverterTypeSupportedHardwareWallet(_UniffiConverterRustBuffer): @staticmethod def read(buf): - return TransactionDetails( - wallet_id=_UniffiConverterString.read(buf), - tx_id=_UniffiConverterString.read(buf), - amount_sats=_UniffiConverterInt64.read(buf), - inputs=_UniffiConverterSequenceTypeTxInput.read(buf), - outputs=_UniffiConverterSequenceTypeTxOutput.read(buf), + return SupportedHardwareWallet( + vendor=_UniffiConverterTypeHardwareWalletVendor.read(buf), + vendor_name=_UniffiConverterString.read(buf), + model=_UniffiConverterString.read(buf), + display_name=_UniffiConverterString.read(buf), + transports=_UniffiConverterSequenceTypeHardwareWalletTransport.read(buf), ) @staticmethod def check_lower(value): - _UniffiConverterString.check_lower(value.wallet_id) - _UniffiConverterString.check_lower(value.tx_id) - _UniffiConverterInt64.check_lower(value.amount_sats) - _UniffiConverterSequenceTypeTxInput.check_lower(value.inputs) - _UniffiConverterSequenceTypeTxOutput.check_lower(value.outputs) + _UniffiConverterTypeHardwareWalletVendor.check_lower(value.vendor) + _UniffiConverterString.check_lower(value.vendor_name) + _UniffiConverterString.check_lower(value.model) + _UniffiConverterString.check_lower(value.display_name) + _UniffiConverterSequenceTypeHardwareWalletTransport.check_lower(value.transports) @staticmethod def write(value, buf): - _UniffiConverterString.write(value.wallet_id, buf) - _UniffiConverterString.write(value.tx_id, buf) - _UniffiConverterInt64.write(value.amount_sats, buf) - _UniffiConverterSequenceTypeTxInput.write(value.inputs, buf) - _UniffiConverterSequenceTypeTxOutput.write(value.outputs, buf) - - -class TransactionHistoryResult: - """ - Result from querying transaction history for an xpub. - """ + _UniffiConverterTypeHardwareWalletVendor.write(value.vendor, buf) + _UniffiConverterString.write(value.vendor_name, buf) + _UniffiConverterString.write(value.model, buf) + _UniffiConverterString.write(value.display_name, buf) + _UniffiConverterSequenceTypeHardwareWalletTransport.write(value.transports, buf) - transactions: "typing.List[HistoryTransaction]" - """ - All transactions, sorted: unconfirmed first, then by timestamp descending - """ - balance: "WalletBalance" +class SweepResult: + txid: "str" """ - Balance breakdown + The transaction ID of the sweep transaction """ - tx_count: "int" + amount_swept: "int" """ - Total number of transactions + The total amount swept (in satoshis) """ - block_height: "int" + fee_paid: "int" """ - Current blockchain tip height + The fee paid (in satoshis) """ - account_type: "AccountType" + utxos_swept: "int" """ - The detected or specified account type + The number of UTXOs swept """ - def __init__(self, *, transactions: "typing.List[HistoryTransaction]", balance: "WalletBalance", tx_count: "int", block_height: "int", account_type: "AccountType"): - self.transactions = transactions - self.balance = balance - self.tx_count = tx_count - self.block_height = block_height - self.account_type = account_type + def __init__(self, *, txid: "str", amount_swept: "int", fee_paid: "int", utxos_swept: "int"): + self.txid = txid + self.amount_swept = amount_swept + self.fee_paid = fee_paid + self.utxos_swept = utxos_swept def __str__(self): - return "TransactionHistoryResult(transactions={}, balance={}, tx_count={}, block_height={}, account_type={})".format(self.transactions, self.balance, self.tx_count, self.block_height, self.account_type) + return "SweepResult(txid={}, amount_swept={}, fee_paid={}, utxos_swept={})".format(self.txid, self.amount_swept, self.fee_paid, self.utxos_swept) def __eq__(self, other): - if self.transactions != other.transactions: - return False - if self.balance != other.balance: + if self.txid != other.txid: return False - if self.tx_count != other.tx_count: + if self.amount_swept != other.amount_swept: return False - if self.block_height != other.block_height: + if self.fee_paid != other.fee_paid: return False - if self.account_type != other.account_type: + if self.utxos_swept != other.utxos_swept: return False return True -class _UniffiConverterTypeTransactionHistoryResult(_UniffiConverterRustBuffer): +class _UniffiConverterTypeSweepResult(_UniffiConverterRustBuffer): @staticmethod def read(buf): - return TransactionHistoryResult( - transactions=_UniffiConverterSequenceTypeHistoryTransaction.read(buf), - balance=_UniffiConverterTypeWalletBalance.read(buf), - tx_count=_UniffiConverterUInt32.read(buf), - block_height=_UniffiConverterUInt32.read(buf), - account_type=_UniffiConverterTypeAccountType.read(buf), + return SweepResult( + txid=_UniffiConverterString.read(buf), + amount_swept=_UniffiConverterUInt64.read(buf), + fee_paid=_UniffiConverterUInt64.read(buf), + utxos_swept=_UniffiConverterUInt32.read(buf), ) @staticmethod def check_lower(value): - _UniffiConverterSequenceTypeHistoryTransaction.check_lower(value.transactions) - _UniffiConverterTypeWalletBalance.check_lower(value.balance) - _UniffiConverterUInt32.check_lower(value.tx_count) - _UniffiConverterUInt32.check_lower(value.block_height) - _UniffiConverterTypeAccountType.check_lower(value.account_type) + _UniffiConverterString.check_lower(value.txid) + _UniffiConverterUInt64.check_lower(value.amount_swept) + _UniffiConverterUInt64.check_lower(value.fee_paid) + _UniffiConverterUInt32.check_lower(value.utxos_swept) @staticmethod def write(value, buf): - _UniffiConverterSequenceTypeHistoryTransaction.write(value.transactions, buf) - _UniffiConverterTypeWalletBalance.write(value.balance, buf) - _UniffiConverterUInt32.write(value.tx_count, buf) - _UniffiConverterUInt32.write(value.block_height, buf) - _UniffiConverterTypeAccountType.write(value.account_type, buf) + _UniffiConverterString.write(value.txid, buf) + _UniffiConverterUInt64.write(value.amount_swept, buf) + _UniffiConverterUInt64.write(value.fee_paid, buf) + _UniffiConverterUInt32.write(value.utxos_swept, buf) -class TrezorAddressResponse: +class SweepTransactionPreview: + psbt: "str" """ - Address response from device. + The PSBT (Partially Signed Bitcoin Transaction) in base64 format """ - address: "str" + total_amount: "int" """ - The Bitcoin address + The total amount available to sweep (in satoshis) """ - path: "str" + estimated_fee: "int" """ - The serialized path (e.g., "m/84'/0'/0'/0/0") + The estimated fee for the transaction (in satoshis) """ - def __init__(self, *, address: "str", path: "str"): - self.address = address - self.path = path + estimated_vsize: "int" + """ + The estimated virtual size of the transaction (in vbytes) + """ + + utxos_count: "int" + """ + The number of UTXOs that will be swept + """ + + destination_address: "str" + """ + The destination address + """ + + amount_after_fees: "int" + """ + The amount that will be sent to destination after fees (in satoshis) + """ + + def __init__(self, *, psbt: "str", total_amount: "int", estimated_fee: "int", estimated_vsize: "int", utxos_count: "int", destination_address: "str", amount_after_fees: "int"): + self.psbt = psbt + self.total_amount = total_amount + self.estimated_fee = estimated_fee + self.estimated_vsize = estimated_vsize + self.utxos_count = utxos_count + self.destination_address = destination_address + self.amount_after_fees = amount_after_fees def __str__(self): - return "TrezorAddressResponse(address={}, path={})".format(self.address, self.path) + return "SweepTransactionPreview(psbt={}, total_amount={}, estimated_fee={}, estimated_vsize={}, utxos_count={}, destination_address={}, amount_after_fees={})".format(self.psbt, self.total_amount, self.estimated_fee, self.estimated_vsize, self.utxos_count, self.destination_address, self.amount_after_fees) def __eq__(self, other): - if self.address != other.address: + if self.psbt != other.psbt: return False - if self.path != other.path: + if self.total_amount != other.total_amount: + return False + if self.estimated_fee != other.estimated_fee: + return False + if self.estimated_vsize != other.estimated_vsize: + return False + if self.utxos_count != other.utxos_count: + return False + if self.destination_address != other.destination_address: + return False + if self.amount_after_fees != other.amount_after_fees: return False return True -class _UniffiConverterTypeTrezorAddressResponse(_UniffiConverterRustBuffer): +class _UniffiConverterTypeSweepTransactionPreview(_UniffiConverterRustBuffer): @staticmethod def read(buf): - return TrezorAddressResponse( - address=_UniffiConverterString.read(buf), - path=_UniffiConverterString.read(buf), + return SweepTransactionPreview( + psbt=_UniffiConverterString.read(buf), + total_amount=_UniffiConverterUInt64.read(buf), + estimated_fee=_UniffiConverterUInt64.read(buf), + estimated_vsize=_UniffiConverterUInt64.read(buf), + utxos_count=_UniffiConverterUInt32.read(buf), + destination_address=_UniffiConverterString.read(buf), + amount_after_fees=_UniffiConverterUInt64.read(buf), ) @staticmethod def check_lower(value): - _UniffiConverterString.check_lower(value.address) - _UniffiConverterString.check_lower(value.path) + _UniffiConverterString.check_lower(value.psbt) + _UniffiConverterUInt64.check_lower(value.total_amount) + _UniffiConverterUInt64.check_lower(value.estimated_fee) + _UniffiConverterUInt64.check_lower(value.estimated_vsize) + _UniffiConverterUInt32.check_lower(value.utxos_count) + _UniffiConverterString.check_lower(value.destination_address) + _UniffiConverterUInt64.check_lower(value.amount_after_fees) @staticmethod def write(value, buf): - _UniffiConverterString.write(value.address, buf) - _UniffiConverterString.write(value.path, buf) + _UniffiConverterString.write(value.psbt, buf) + _UniffiConverterUInt64.write(value.total_amount, buf) + _UniffiConverterUInt64.write(value.estimated_fee, buf) + _UniffiConverterUInt64.write(value.estimated_vsize, buf) + _UniffiConverterUInt32.write(value.utxos_count, buf) + _UniffiConverterString.write(value.destination_address, buf) + _UniffiConverterUInt64.write(value.amount_after_fees, buf) -class TrezorCallMessageResult: +class SweepableBalances: + legacy_balance: "int" """ - Result from a high-level message call (for BLE/THP devices) + Balance in legacy (P2PKH) addresses (in satoshis) """ - success: "bool" + p2sh_balance: "int" """ - Whether the call succeeded + Balance in P2SH-SegWit (P2SH-P2WPKH) addresses (in satoshis) """ - message_type: "int" + taproot_balance: "int" """ - Response message type + Balance in Taproot (P2TR) addresses (in satoshis) """ - data: "bytes" + total_balance: "int" """ - Response protobuf data + Total balance across all wallet types (in satoshis) """ - error: "str" + legacy_utxos_count: "int" """ - Error message (empty on success) + Number of UTXOs in legacy wallet """ - error_code: "typing.Optional[TrezorTransportErrorCode]" + p2sh_utxos_count: "int" """ - Structured error code (None on success or when the native error is generic) + Number of UTXOs in P2SH-SegWit wallet """ - def __init__(self, *, success: "bool", message_type: "int", data: "bytes", error: "str", error_code: "typing.Optional[TrezorTransportErrorCode]"): - self.success = success - self.message_type = message_type - self.data = data - self.error = error - self.error_code = error_code + taproot_utxos_count: "int" + """ + Number of UTXOs in Taproot wallet + """ + + total_utxos_count: "int" + """ + Total number of UTXOs across all wallet types + """ + + def __init__(self, *, legacy_balance: "int", p2sh_balance: "int", taproot_balance: "int", total_balance: "int", legacy_utxos_count: "int", p2sh_utxos_count: "int", taproot_utxos_count: "int", total_utxos_count: "int"): + self.legacy_balance = legacy_balance + self.p2sh_balance = p2sh_balance + self.taproot_balance = taproot_balance + self.total_balance = total_balance + self.legacy_utxos_count = legacy_utxos_count + self.p2sh_utxos_count = p2sh_utxos_count + self.taproot_utxos_count = taproot_utxos_count + self.total_utxos_count = total_utxos_count def __str__(self): - return "TrezorCallMessageResult(success={}, message_type={}, data={}, error={}, error_code={})".format(self.success, self.message_type, self.data, self.error, self.error_code) + return "SweepableBalances(legacy_balance={}, p2sh_balance={}, taproot_balance={}, total_balance={}, legacy_utxos_count={}, p2sh_utxos_count={}, taproot_utxos_count={}, total_utxos_count={})".format(self.legacy_balance, self.p2sh_balance, self.taproot_balance, self.total_balance, self.legacy_utxos_count, self.p2sh_utxos_count, self.taproot_utxos_count, self.total_utxos_count) def __eq__(self, other): - if self.success != other.success: + if self.legacy_balance != other.legacy_balance: return False - if self.message_type != other.message_type: + if self.p2sh_balance != other.p2sh_balance: return False - if self.data != other.data: + if self.taproot_balance != other.taproot_balance: return False - if self.error != other.error: + if self.total_balance != other.total_balance: return False - if self.error_code != other.error_code: + if self.legacy_utxos_count != other.legacy_utxos_count: + return False + if self.p2sh_utxos_count != other.p2sh_utxos_count: + return False + if self.taproot_utxos_count != other.taproot_utxos_count: + return False + if self.total_utxos_count != other.total_utxos_count: return False return True -class _UniffiConverterTypeTrezorCallMessageResult(_UniffiConverterRustBuffer): +class _UniffiConverterTypeSweepableBalances(_UniffiConverterRustBuffer): @staticmethod def read(buf): - return TrezorCallMessageResult( - success=_UniffiConverterBool.read(buf), - message_type=_UniffiConverterUInt16.read(buf), - data=_UniffiConverterBytes.read(buf), - error=_UniffiConverterString.read(buf), - error_code=_UniffiConverterOptionalTypeTrezorTransportErrorCode.read(buf), + return SweepableBalances( + legacy_balance=_UniffiConverterUInt64.read(buf), + p2sh_balance=_UniffiConverterUInt64.read(buf), + taproot_balance=_UniffiConverterUInt64.read(buf), + total_balance=_UniffiConverterUInt64.read(buf), + legacy_utxos_count=_UniffiConverterUInt32.read(buf), + p2sh_utxos_count=_UniffiConverterUInt32.read(buf), + taproot_utxos_count=_UniffiConverterUInt32.read(buf), + total_utxos_count=_UniffiConverterUInt32.read(buf), ) @staticmethod def check_lower(value): - _UniffiConverterBool.check_lower(value.success) - _UniffiConverterUInt16.check_lower(value.message_type) - _UniffiConverterBytes.check_lower(value.data) - _UniffiConverterString.check_lower(value.error) - _UniffiConverterOptionalTypeTrezorTransportErrorCode.check_lower(value.error_code) + _UniffiConverterUInt64.check_lower(value.legacy_balance) + _UniffiConverterUInt64.check_lower(value.p2sh_balance) + _UniffiConverterUInt64.check_lower(value.taproot_balance) + _UniffiConverterUInt64.check_lower(value.total_balance) + _UniffiConverterUInt32.check_lower(value.legacy_utxos_count) + _UniffiConverterUInt32.check_lower(value.p2sh_utxos_count) + _UniffiConverterUInt32.check_lower(value.taproot_utxos_count) + _UniffiConverterUInt32.check_lower(value.total_utxos_count) @staticmethod def write(value, buf): - _UniffiConverterBool.write(value.success, buf) - _UniffiConverterUInt16.write(value.message_type, buf) - _UniffiConverterBytes.write(value.data, buf) - _UniffiConverterString.write(value.error, buf) - _UniffiConverterOptionalTypeTrezorTransportErrorCode.write(value.error_code, buf) + _UniffiConverterUInt64.write(value.legacy_balance, buf) + _UniffiConverterUInt64.write(value.p2sh_balance, buf) + _UniffiConverterUInt64.write(value.taproot_balance, buf) + _UniffiConverterUInt64.write(value.total_balance, buf) + _UniffiConverterUInt32.write(value.legacy_utxos_count, buf) + _UniffiConverterUInt32.write(value.p2sh_utxos_count, buf) + _UniffiConverterUInt32.write(value.taproot_utxos_count, buf) + _UniffiConverterUInt32.write(value.total_utxos_count, buf) -class TrezorDeviceInfo: +class TransactionDetail: """ - Device information exposed to FFI. + Full details for a single transaction, including raw inputs/outputs and size metrics. """ - id: "str" + txid: "str" """ - Unique identifier for the device + Transaction ID (hex) """ - transport_type: "TrezorTransportType" + received: "int" """ - Transport type (USB or Bluetooth) + Amount received by the wallet (sats) """ - name: "typing.Optional[str]" + sent: "int" """ - Device name (from BLE advertisement or USB descriptor) + Amount sent by the wallet (sats) — includes change sent back to self """ - path: "str" + net: "int" """ - Transport-specific path (used internally for connection) + Net value from wallet's perspective: received - sent (positive = inflow, negative = outflow) """ - label: "typing.Optional[str]" + amount: "int" """ - Device label (set by user during device setup) + Display amount in sats (same semantics as HistoryTransaction.amount) """ - model: "typing.Optional[str]" + fee: "typing.Optional[int]" """ - Device model (e.g., "T2", "Safe 5", "Safe 7") + Transaction fee in sats (None if not available) """ - is_bootloader: "bool" + direction: "TxDirection" """ - Whether the device is in bootloader mode + Transaction direction """ - def __init__(self, *, id: "str", transport_type: "TrezorTransportType", name: "typing.Optional[str]", path: "str", label: "typing.Optional[str]", model: "typing.Optional[str]", is_bootloader: "bool"): - self.id = id - self.transport_type = transport_type - self.name = name - self.path = path - self.label = label - self.model = model - self.is_bootloader = is_bootloader - - def __str__(self): - return "TrezorDeviceInfo(id={}, transport_type={}, name={}, path={}, label={}, model={}, is_bootloader={})".format(self.id, self.transport_type, self.name, self.path, self.label, self.model, self.is_bootloader) - - def __eq__(self, other): - if self.id != other.id: - return False - if self.transport_type != other.transport_type: - return False - if self.name != other.name: - return False - if self.path != other.path: - return False - if self.label != other.label: - return False - if self.model != other.model: - return False - if self.is_bootloader != other.is_bootloader: - return False - return True - -class _UniffiConverterTypeTrezorDeviceInfo(_UniffiConverterRustBuffer): - @staticmethod - def read(buf): - return TrezorDeviceInfo( - id=_UniffiConverterString.read(buf), - transport_type=_UniffiConverterTypeTrezorTransportType.read(buf), - name=_UniffiConverterOptionalString.read(buf), - path=_UniffiConverterString.read(buf), - label=_UniffiConverterOptionalString.read(buf), - model=_UniffiConverterOptionalString.read(buf), - is_bootloader=_UniffiConverterBool.read(buf), - ) - - @staticmethod - def check_lower(value): - _UniffiConverterString.check_lower(value.id) - _UniffiConverterTypeTrezorTransportType.check_lower(value.transport_type) - _UniffiConverterOptionalString.check_lower(value.name) - _UniffiConverterString.check_lower(value.path) - _UniffiConverterOptionalString.check_lower(value.label) - _UniffiConverterOptionalString.check_lower(value.model) - _UniffiConverterBool.check_lower(value.is_bootloader) - - @staticmethod - def write(value, buf): - _UniffiConverterString.write(value.id, buf) - _UniffiConverterTypeTrezorTransportType.write(value.transport_type, buf) - _UniffiConverterOptionalString.write(value.name, buf) - _UniffiConverterString.write(value.path, buf) - _UniffiConverterOptionalString.write(value.label, buf) - _UniffiConverterOptionalString.write(value.model, buf) - _UniffiConverterBool.write(value.is_bootloader, buf) - - -class TrezorFeatures: + block_height: "typing.Optional[int]" """ - Device features after initialization. + Block height (None if unconfirmed/mempool) """ - vendor: "typing.Optional[str]" + timestamp: "typing.Optional[int]" """ - Vendor string + Block timestamp as unix epoch seconds (None if unconfirmed) """ - model: "typing.Optional[str]" + confirmations: "int" """ - Device model + Number of confirmations (0 if unconfirmed) """ - label: "typing.Optional[str]" + inputs: "typing.List[TxDetailInput]" """ - Device label (set by user during device setup) + Transaction inputs """ - device_id: "typing.Optional[str]" + outputs: "typing.List[TxDetailOutput]" """ - Device ID (unique per device) + Transaction outputs """ - major_version: "typing.Optional[int]" + size: "int" """ - Major firmware version + Serialized transaction size in bytes """ - minor_version: "typing.Optional[int]" + vsize: "int" """ - Minor firmware version + Virtual size in vbytes (ceil(weight / 4)) """ - patch_version: "typing.Optional[int]" + weight: "int" """ - Patch firmware version + Transaction weight in weight units """ - pin_protection: "typing.Optional[bool]" + fee_rate: "typing.Optional[float]" """ - Whether PIN protection is enabled + Fee rate in sat/vB (fee / vsize), None if fee is unavailable or vsize is zero """ - unlocked: "typing.Optional[bool]" - """ - Whether the device is currently unlocked. When PIN protection is enabled - and this is `Some(false)`, mobile callers should back off and ask the - user to unlock the Trezor instead of repeatedly reconnecting. - """ - - passphrase_protection: "typing.Optional[bool]" - """ - Whether passphrase protection is enabled - """ - - initialized: "typing.Optional[bool]" - """ - Whether the device is initialized with a seed - """ - - needs_backup: "typing.Optional[bool]" - """ - Whether the device needs backup - """ - - passphrase_entry_capable: "typing.Optional[bool]" - """ - Whether the device can accept passphrase entry on the device itself - (`Capability_PassphraseEntry`). When false/None, use host entry only. - """ - - def __init__(self, *, vendor: "typing.Optional[str]", model: "typing.Optional[str]", label: "typing.Optional[str]", device_id: "typing.Optional[str]", major_version: "typing.Optional[int]", minor_version: "typing.Optional[int]", patch_version: "typing.Optional[int]", pin_protection: "typing.Optional[bool]", unlocked: "typing.Optional[bool]", passphrase_protection: "typing.Optional[bool]", initialized: "typing.Optional[bool]", needs_backup: "typing.Optional[bool]", passphrase_entry_capable: "typing.Optional[bool]"): - self.vendor = vendor - self.model = model - self.label = label - self.device_id = device_id - self.major_version = major_version - self.minor_version = minor_version - self.patch_version = patch_version - self.pin_protection = pin_protection - self.unlocked = unlocked - self.passphrase_protection = passphrase_protection - self.initialized = initialized - self.needs_backup = needs_backup - self.passphrase_entry_capable = passphrase_entry_capable + def __init__(self, *, txid: "str", received: "int", sent: "int", net: "int", amount: "int", fee: "typing.Optional[int]", direction: "TxDirection", block_height: "typing.Optional[int]", timestamp: "typing.Optional[int]", confirmations: "int", inputs: "typing.List[TxDetailInput]", outputs: "typing.List[TxDetailOutput]", size: "int", vsize: "int", weight: "int", fee_rate: "typing.Optional[float]"): + self.txid = txid + self.received = received + self.sent = sent + self.net = net + self.amount = amount + self.fee = fee + self.direction = direction + self.block_height = block_height + self.timestamp = timestamp + self.confirmations = confirmations + self.inputs = inputs + self.outputs = outputs + self.size = size + self.vsize = vsize + self.weight = weight + self.fee_rate = fee_rate def __str__(self): - return "TrezorFeatures(vendor={}, model={}, label={}, device_id={}, major_version={}, minor_version={}, patch_version={}, pin_protection={}, unlocked={}, passphrase_protection={}, initialized={}, needs_backup={}, passphrase_entry_capable={})".format(self.vendor, self.model, self.label, self.device_id, self.major_version, self.minor_version, self.patch_version, self.pin_protection, self.unlocked, self.passphrase_protection, self.initialized, self.needs_backup, self.passphrase_entry_capable) + return "TransactionDetail(txid={}, received={}, sent={}, net={}, amount={}, fee={}, direction={}, block_height={}, timestamp={}, confirmations={}, inputs={}, outputs={}, size={}, vsize={}, weight={}, fee_rate={})".format(self.txid, self.received, self.sent, self.net, self.amount, self.fee, self.direction, self.block_height, self.timestamp, self.confirmations, self.inputs, self.outputs, self.size, self.vsize, self.weight, self.fee_rate) def __eq__(self, other): - if self.vendor != other.vendor: + if self.txid != other.txid: return False - if self.model != other.model: + if self.received != other.received: return False - if self.label != other.label: + if self.sent != other.sent: return False - if self.device_id != other.device_id: + if self.net != other.net: return False - if self.major_version != other.major_version: + if self.amount != other.amount: return False - if self.minor_version != other.minor_version: + if self.fee != other.fee: return False - if self.patch_version != other.patch_version: + if self.direction != other.direction: return False - if self.pin_protection != other.pin_protection: + if self.block_height != other.block_height: return False - if self.unlocked != other.unlocked: + if self.timestamp != other.timestamp: return False - if self.passphrase_protection != other.passphrase_protection: + if self.confirmations != other.confirmations: return False - if self.initialized != other.initialized: + if self.inputs != other.inputs: return False - if self.needs_backup != other.needs_backup: + if self.outputs != other.outputs: return False - if self.passphrase_entry_capable != other.passphrase_entry_capable: + if self.size != other.size: + return False + if self.vsize != other.vsize: + return False + if self.weight != other.weight: + return False + if self.fee_rate != other.fee_rate: return False return True -class _UniffiConverterTypeTrezorFeatures(_UniffiConverterRustBuffer): +class _UniffiConverterTypeTransactionDetail(_UniffiConverterRustBuffer): @staticmethod def read(buf): - return TrezorFeatures( - vendor=_UniffiConverterOptionalString.read(buf), - model=_UniffiConverterOptionalString.read(buf), - label=_UniffiConverterOptionalString.read(buf), - device_id=_UniffiConverterOptionalString.read(buf), - major_version=_UniffiConverterOptionalUInt32.read(buf), - minor_version=_UniffiConverterOptionalUInt32.read(buf), - patch_version=_UniffiConverterOptionalUInt32.read(buf), - pin_protection=_UniffiConverterOptionalBool.read(buf), - unlocked=_UniffiConverterOptionalBool.read(buf), - passphrase_protection=_UniffiConverterOptionalBool.read(buf), - initialized=_UniffiConverterOptionalBool.read(buf), - needs_backup=_UniffiConverterOptionalBool.read(buf), - passphrase_entry_capable=_UniffiConverterOptionalBool.read(buf), + return TransactionDetail( + txid=_UniffiConverterString.read(buf), + received=_UniffiConverterUInt64.read(buf), + sent=_UniffiConverterUInt64.read(buf), + net=_UniffiConverterInt64.read(buf), + amount=_UniffiConverterUInt64.read(buf), + fee=_UniffiConverterOptionalUInt64.read(buf), + direction=_UniffiConverterTypeTxDirection.read(buf), + block_height=_UniffiConverterOptionalUInt32.read(buf), + timestamp=_UniffiConverterOptionalUInt64.read(buf), + confirmations=_UniffiConverterUInt32.read(buf), + inputs=_UniffiConverterSequenceTypeTxDetailInput.read(buf), + outputs=_UniffiConverterSequenceTypeTxDetailOutput.read(buf), + size=_UniffiConverterUInt32.read(buf), + vsize=_UniffiConverterUInt32.read(buf), + weight=_UniffiConverterUInt32.read(buf), + fee_rate=_UniffiConverterOptionalDouble.read(buf), ) @staticmethod def check_lower(value): - _UniffiConverterOptionalString.check_lower(value.vendor) - _UniffiConverterOptionalString.check_lower(value.model) - _UniffiConverterOptionalString.check_lower(value.label) - _UniffiConverterOptionalString.check_lower(value.device_id) - _UniffiConverterOptionalUInt32.check_lower(value.major_version) - _UniffiConverterOptionalUInt32.check_lower(value.minor_version) - _UniffiConverterOptionalUInt32.check_lower(value.patch_version) - _UniffiConverterOptionalBool.check_lower(value.pin_protection) - _UniffiConverterOptionalBool.check_lower(value.unlocked) - _UniffiConverterOptionalBool.check_lower(value.passphrase_protection) - _UniffiConverterOptionalBool.check_lower(value.initialized) - _UniffiConverterOptionalBool.check_lower(value.needs_backup) - _UniffiConverterOptionalBool.check_lower(value.passphrase_entry_capable) + _UniffiConverterString.check_lower(value.txid) + _UniffiConverterUInt64.check_lower(value.received) + _UniffiConverterUInt64.check_lower(value.sent) + _UniffiConverterInt64.check_lower(value.net) + _UniffiConverterUInt64.check_lower(value.amount) + _UniffiConverterOptionalUInt64.check_lower(value.fee) + _UniffiConverterTypeTxDirection.check_lower(value.direction) + _UniffiConverterOptionalUInt32.check_lower(value.block_height) + _UniffiConverterOptionalUInt64.check_lower(value.timestamp) + _UniffiConverterUInt32.check_lower(value.confirmations) + _UniffiConverterSequenceTypeTxDetailInput.check_lower(value.inputs) + _UniffiConverterSequenceTypeTxDetailOutput.check_lower(value.outputs) + _UniffiConverterUInt32.check_lower(value.size) + _UniffiConverterUInt32.check_lower(value.vsize) + _UniffiConverterUInt32.check_lower(value.weight) + _UniffiConverterOptionalDouble.check_lower(value.fee_rate) @staticmethod def write(value, buf): - _UniffiConverterOptionalString.write(value.vendor, buf) - _UniffiConverterOptionalString.write(value.model, buf) - _UniffiConverterOptionalString.write(value.label, buf) - _UniffiConverterOptionalString.write(value.device_id, buf) - _UniffiConverterOptionalUInt32.write(value.major_version, buf) - _UniffiConverterOptionalUInt32.write(value.minor_version, buf) - _UniffiConverterOptionalUInt32.write(value.patch_version, buf) - _UniffiConverterOptionalBool.write(value.pin_protection, buf) - _UniffiConverterOptionalBool.write(value.unlocked, buf) - _UniffiConverterOptionalBool.write(value.passphrase_protection, buf) - _UniffiConverterOptionalBool.write(value.initialized, buf) - _UniffiConverterOptionalBool.write(value.needs_backup, buf) - _UniffiConverterOptionalBool.write(value.passphrase_entry_capable, buf) + _UniffiConverterString.write(value.txid, buf) + _UniffiConverterUInt64.write(value.received, buf) + _UniffiConverterUInt64.write(value.sent, buf) + _UniffiConverterInt64.write(value.net, buf) + _UniffiConverterUInt64.write(value.amount, buf) + _UniffiConverterOptionalUInt64.write(value.fee, buf) + _UniffiConverterTypeTxDirection.write(value.direction, buf) + _UniffiConverterOptionalUInt32.write(value.block_height, buf) + _UniffiConverterOptionalUInt64.write(value.timestamp, buf) + _UniffiConverterUInt32.write(value.confirmations, buf) + _UniffiConverterSequenceTypeTxDetailInput.write(value.inputs, buf) + _UniffiConverterSequenceTypeTxDetailOutput.write(value.outputs, buf) + _UniffiConverterUInt32.write(value.size, buf) + _UniffiConverterUInt32.write(value.vsize, buf) + _UniffiConverterUInt32.write(value.weight, buf) + _UniffiConverterOptionalDouble.write(value.fee_rate, buf) -class TrezorGetAddressParams: +class TransactionDetails: """ - Parameters for getting an address from the device. + Details about an onchain transaction. """ - path: "str" + wallet_id: "str" + tx_id: "str" """ - BIP32 path (e.g., "m/84'/0'/0'/0/0") + The transaction ID. """ - coin: "typing.Optional[TrezorCoinType]" + amount_sats: "int" """ - Coin network (default: Bitcoin) + The net amount in this transaction (in satoshis). + + This is calculated as: (received - sent). For incoming payments, + this will be positive. For outgoing payments, this will be negative. + + Note: This amount does NOT include transaction fees. """ - show_on_trezor: "bool" + inputs: "typing.List[TxInput]" """ - Whether to display the address on the device for confirmation + The transaction inputs with full details. """ - script_type: "typing.Optional[TrezorScriptType]" + outputs: "typing.List[TxOutput]" """ - Script type (auto-detected from path if not specified) + The transaction outputs with full details. """ - def __init__(self, *, path: "str", coin: "typing.Optional[TrezorCoinType]", show_on_trezor: "bool", script_type: "typing.Optional[TrezorScriptType]"): - self.path = path - self.coin = coin - self.show_on_trezor = show_on_trezor - self.script_type = script_type + def __init__(self, *, wallet_id: "str", tx_id: "str", amount_sats: "int", inputs: "typing.List[TxInput]", outputs: "typing.List[TxOutput]"): + self.wallet_id = wallet_id + self.tx_id = tx_id + self.amount_sats = amount_sats + self.inputs = inputs + self.outputs = outputs def __str__(self): - return "TrezorGetAddressParams(path={}, coin={}, show_on_trezor={}, script_type={})".format(self.path, self.coin, self.show_on_trezor, self.script_type) + return "TransactionDetails(wallet_id={}, tx_id={}, amount_sats={}, inputs={}, outputs={})".format(self.wallet_id, self.tx_id, self.amount_sats, self.inputs, self.outputs) def __eq__(self, other): - if self.path != other.path: + if self.wallet_id != other.wallet_id: return False - if self.coin != other.coin: + if self.tx_id != other.tx_id: return False - if self.show_on_trezor != other.show_on_trezor: + if self.amount_sats != other.amount_sats: return False - if self.script_type != other.script_type: + if self.inputs != other.inputs: + return False + if self.outputs != other.outputs: return False return True -class _UniffiConverterTypeTrezorGetAddressParams(_UniffiConverterRustBuffer): +class _UniffiConverterTypeTransactionDetails(_UniffiConverterRustBuffer): @staticmethod def read(buf): - return TrezorGetAddressParams( - path=_UniffiConverterString.read(buf), - coin=_UniffiConverterOptionalTypeTrezorCoinType.read(buf), - show_on_trezor=_UniffiConverterBool.read(buf), - script_type=_UniffiConverterOptionalTypeTrezorScriptType.read(buf), + return TransactionDetails( + wallet_id=_UniffiConverterString.read(buf), + tx_id=_UniffiConverterString.read(buf), + amount_sats=_UniffiConverterInt64.read(buf), + inputs=_UniffiConverterSequenceTypeTxInput.read(buf), + outputs=_UniffiConverterSequenceTypeTxOutput.read(buf), ) @staticmethod def check_lower(value): - _UniffiConverterString.check_lower(value.path) - _UniffiConverterOptionalTypeTrezorCoinType.check_lower(value.coin) - _UniffiConverterBool.check_lower(value.show_on_trezor) - _UniffiConverterOptionalTypeTrezorScriptType.check_lower(value.script_type) + _UniffiConverterString.check_lower(value.wallet_id) + _UniffiConverterString.check_lower(value.tx_id) + _UniffiConverterInt64.check_lower(value.amount_sats) + _UniffiConverterSequenceTypeTxInput.check_lower(value.inputs) + _UniffiConverterSequenceTypeTxOutput.check_lower(value.outputs) @staticmethod def write(value, buf): - _UniffiConverterString.write(value.path, buf) - _UniffiConverterOptionalTypeTrezorCoinType.write(value.coin, buf) - _UniffiConverterBool.write(value.show_on_trezor, buf) - _UniffiConverterOptionalTypeTrezorScriptType.write(value.script_type, buf) + _UniffiConverterString.write(value.wallet_id, buf) + _UniffiConverterString.write(value.tx_id, buf) + _UniffiConverterInt64.write(value.amount_sats, buf) + _UniffiConverterSequenceTypeTxInput.write(value.inputs, buf) + _UniffiConverterSequenceTypeTxOutput.write(value.outputs, buf) -class TrezorGetPublicKeyParams: +class TransactionHistoryResult: """ - Parameters for getting a public key from the device. + Result from querying transaction history for an xpub. """ - path: "str" + transactions: "typing.List[HistoryTransaction]" """ - BIP32 path (e.g., "m/84'/0'/0'") + All transactions, sorted: unconfirmed first, then by timestamp descending """ - coin: "typing.Optional[TrezorCoinType]" + balance: "WalletBalance" """ - Coin network (default: Bitcoin) + Balance breakdown """ - show_on_trezor: "bool" + tx_count: "int" """ - Whether to display on device for confirmation + Total number of transactions """ - def __init__(self, *, path: "str", coin: "typing.Optional[TrezorCoinType]", show_on_trezor: "bool"): - self.path = path - self.coin = coin - self.show_on_trezor = show_on_trezor + block_height: "int" + """ + Current blockchain tip height + """ + + account_type: "AccountType" + """ + The detected or specified account type + """ + + def __init__(self, *, transactions: "typing.List[HistoryTransaction]", balance: "WalletBalance", tx_count: "int", block_height: "int", account_type: "AccountType"): + self.transactions = transactions + self.balance = balance + self.tx_count = tx_count + self.block_height = block_height + self.account_type = account_type def __str__(self): - return "TrezorGetPublicKeyParams(path={}, coin={}, show_on_trezor={})".format(self.path, self.coin, self.show_on_trezor) + return "TransactionHistoryResult(transactions={}, balance={}, tx_count={}, block_height={}, account_type={})".format(self.transactions, self.balance, self.tx_count, self.block_height, self.account_type) def __eq__(self, other): - if self.path != other.path: + if self.transactions != other.transactions: return False - if self.coin != other.coin: + if self.balance != other.balance: return False - if self.show_on_trezor != other.show_on_trezor: + if self.tx_count != other.tx_count: + return False + if self.block_height != other.block_height: + return False + if self.account_type != other.account_type: return False return True -class _UniffiConverterTypeTrezorGetPublicKeyParams(_UniffiConverterRustBuffer): +class _UniffiConverterTypeTransactionHistoryResult(_UniffiConverterRustBuffer): @staticmethod def read(buf): - return TrezorGetPublicKeyParams( - path=_UniffiConverterString.read(buf), - coin=_UniffiConverterOptionalTypeTrezorCoinType.read(buf), - show_on_trezor=_UniffiConverterBool.read(buf), + return TransactionHistoryResult( + transactions=_UniffiConverterSequenceTypeHistoryTransaction.read(buf), + balance=_UniffiConverterTypeWalletBalance.read(buf), + tx_count=_UniffiConverterUInt32.read(buf), + block_height=_UniffiConverterUInt32.read(buf), + account_type=_UniffiConverterTypeAccountType.read(buf), ) @staticmethod def check_lower(value): - _UniffiConverterString.check_lower(value.path) - _UniffiConverterOptionalTypeTrezorCoinType.check_lower(value.coin) - _UniffiConverterBool.check_lower(value.show_on_trezor) + _UniffiConverterSequenceTypeHistoryTransaction.check_lower(value.transactions) + _UniffiConverterTypeWalletBalance.check_lower(value.balance) + _UniffiConverterUInt32.check_lower(value.tx_count) + _UniffiConverterUInt32.check_lower(value.block_height) + _UniffiConverterTypeAccountType.check_lower(value.account_type) @staticmethod def write(value, buf): - _UniffiConverterString.write(value.path, buf) - _UniffiConverterOptionalTypeTrezorCoinType.write(value.coin, buf) - _UniffiConverterBool.write(value.show_on_trezor, buf) - - -class TrezorPrevTx: - """ - Previous transaction data (for non-SegWit input verification). - """ - - hash: "str" - """ - Transaction hash (hex encoded) - """ + _UniffiConverterSequenceTypeHistoryTransaction.write(value.transactions, buf) + _UniffiConverterTypeWalletBalance.write(value.balance, buf) + _UniffiConverterUInt32.write(value.tx_count, buf) + _UniffiConverterUInt32.write(value.block_height, buf) + _UniffiConverterTypeAccountType.write(value.account_type, buf) - version: "int" - """ - Transaction version - """ - lock_time: "int" +class TrezorAddressResponse: """ - Lock time + Address response from device. """ - inputs: "typing.List[TrezorPrevTxInput]" + address: "str" """ - Transaction inputs + The Bitcoin address """ - outputs: "typing.List[TrezorPrevTxOutput]" + path: "str" """ - Transaction outputs + The serialized path (e.g., "m/84'/0'/0'/0/0") """ - def __init__(self, *, hash: "str", version: "int", lock_time: "int", inputs: "typing.List[TrezorPrevTxInput]", outputs: "typing.List[TrezorPrevTxOutput]"): - self.hash = hash - self.version = version - self.lock_time = lock_time - self.inputs = inputs - self.outputs = outputs + def __init__(self, *, address: "str", path: "str"): + self.address = address + self.path = path def __str__(self): - return "TrezorPrevTx(hash={}, version={}, lock_time={}, inputs={}, outputs={})".format(self.hash, self.version, self.lock_time, self.inputs, self.outputs) + return "TrezorAddressResponse(address={}, path={})".format(self.address, self.path) def __eq__(self, other): - if self.hash != other.hash: - return False - if self.version != other.version: - return False - if self.lock_time != other.lock_time: - return False - if self.inputs != other.inputs: + if self.address != other.address: return False - if self.outputs != other.outputs: + if self.path != other.path: return False return True -class _UniffiConverterTypeTrezorPrevTx(_UniffiConverterRustBuffer): +class _UniffiConverterTypeTrezorAddressResponse(_UniffiConverterRustBuffer): @staticmethod def read(buf): - return TrezorPrevTx( - hash=_UniffiConverterString.read(buf), - version=_UniffiConverterUInt32.read(buf), - lock_time=_UniffiConverterUInt32.read(buf), - inputs=_UniffiConverterSequenceTypeTrezorPrevTxInput.read(buf), - outputs=_UniffiConverterSequenceTypeTrezorPrevTxOutput.read(buf), + return TrezorAddressResponse( + address=_UniffiConverterString.read(buf), + path=_UniffiConverterString.read(buf), ) @staticmethod def check_lower(value): - _UniffiConverterString.check_lower(value.hash) - _UniffiConverterUInt32.check_lower(value.version) - _UniffiConverterUInt32.check_lower(value.lock_time) - _UniffiConverterSequenceTypeTrezorPrevTxInput.check_lower(value.inputs) - _UniffiConverterSequenceTypeTrezorPrevTxOutput.check_lower(value.outputs) + _UniffiConverterString.check_lower(value.address) + _UniffiConverterString.check_lower(value.path) @staticmethod def write(value, buf): - _UniffiConverterString.write(value.hash, buf) - _UniffiConverterUInt32.write(value.version, buf) - _UniffiConverterUInt32.write(value.lock_time, buf) - _UniffiConverterSequenceTypeTrezorPrevTxInput.write(value.inputs, buf) - _UniffiConverterSequenceTypeTrezorPrevTxOutput.write(value.outputs, buf) + _UniffiConverterString.write(value.address, buf) + _UniffiConverterString.write(value.path, buf) -class TrezorPrevTxInput: +class TrezorCallMessageResult: """ - Input of a previous transaction. + Result from a high-level message call (for BLE/THP devices) """ - prev_hash: "str" + success: "bool" """ - Previous transaction hash (hex encoded) + Whether the call succeeded """ - prev_index: "int" + message_type: "int" """ - Previous output index + Response message type """ - script_sig: "str" + data: "bytes" """ - Script signature (hex encoded) + Response protobuf data """ - sequence: "int" + error: "str" """ - Sequence number + Error message (empty on success) """ - def __init__(self, *, prev_hash: "str", prev_index: "int", script_sig: "str", sequence: "int"): - self.prev_hash = prev_hash - self.prev_index = prev_index - self.script_sig = script_sig - self.sequence = sequence + error_code: "typing.Optional[TrezorTransportErrorCode]" + """ + Structured error code (None on success or when the native error is generic) + """ + + def __init__(self, *, success: "bool", message_type: "int", data: "bytes", error: "str", error_code: "typing.Optional[TrezorTransportErrorCode]"): + self.success = success + self.message_type = message_type + self.data = data + self.error = error + self.error_code = error_code def __str__(self): - return "TrezorPrevTxInput(prev_hash={}, prev_index={}, script_sig={}, sequence={})".format(self.prev_hash, self.prev_index, self.script_sig, self.sequence) + return "TrezorCallMessageResult(success={}, message_type={}, data={}, error={}, error_code={})".format(self.success, self.message_type, self.data, self.error, self.error_code) def __eq__(self, other): - if self.prev_hash != other.prev_hash: + if self.success != other.success: return False - if self.prev_index != other.prev_index: + if self.message_type != other.message_type: return False - if self.script_sig != other.script_sig: + if self.data != other.data: return False - if self.sequence != other.sequence: + if self.error != other.error: + return False + if self.error_code != other.error_code: return False return True -class _UniffiConverterTypeTrezorPrevTxInput(_UniffiConverterRustBuffer): +class _UniffiConverterTypeTrezorCallMessageResult(_UniffiConverterRustBuffer): @staticmethod def read(buf): - return TrezorPrevTxInput( - prev_hash=_UniffiConverterString.read(buf), - prev_index=_UniffiConverterUInt32.read(buf), - script_sig=_UniffiConverterString.read(buf), - sequence=_UniffiConverterUInt32.read(buf), + return TrezorCallMessageResult( + success=_UniffiConverterBool.read(buf), + message_type=_UniffiConverterUInt16.read(buf), + data=_UniffiConverterBytes.read(buf), + error=_UniffiConverterString.read(buf), + error_code=_UniffiConverterOptionalTypeTrezorTransportErrorCode.read(buf), ) @staticmethod def check_lower(value): - _UniffiConverterString.check_lower(value.prev_hash) - _UniffiConverterUInt32.check_lower(value.prev_index) - _UniffiConverterString.check_lower(value.script_sig) - _UniffiConverterUInt32.check_lower(value.sequence) + _UniffiConverterBool.check_lower(value.success) + _UniffiConverterUInt16.check_lower(value.message_type) + _UniffiConverterBytes.check_lower(value.data) + _UniffiConverterString.check_lower(value.error) + _UniffiConverterOptionalTypeTrezorTransportErrorCode.check_lower(value.error_code) @staticmethod def write(value, buf): - _UniffiConverterString.write(value.prev_hash, buf) - _UniffiConverterUInt32.write(value.prev_index, buf) - _UniffiConverterString.write(value.script_sig, buf) - _UniffiConverterUInt32.write(value.sequence, buf) + _UniffiConverterBool.write(value.success, buf) + _UniffiConverterUInt16.write(value.message_type, buf) + _UniffiConverterBytes.write(value.data, buf) + _UniffiConverterString.write(value.error, buf) + _UniffiConverterOptionalTypeTrezorTransportErrorCode.write(value.error_code, buf) -class TrezorPrevTxOutput: +class TrezorDeviceInfo: """ - Output of a previous transaction. + Device information exposed to FFI. """ - amount: "int" + id: "str" """ - Amount in satoshis + Unique identifier for the device """ - script_pubkey: "str" + transport_type: "TrezorTransportType" """ - Script pubkey (hex encoded) + Transport type (USB or Bluetooth) """ - def __init__(self, *, amount: "int", script_pubkey: "str"): - self.amount = amount - self.script_pubkey = script_pubkey + name: "typing.Optional[str]" + """ + Device name (from BLE advertisement or USB descriptor) + """ - def __str__(self): - return "TrezorPrevTxOutput(amount={}, script_pubkey={})".format(self.amount, self.script_pubkey) + path: "str" + """ + Transport-specific path (used internally for connection) + """ - def __eq__(self, other): - if self.amount != other.amount: - return False - if self.script_pubkey != other.script_pubkey: - return False - return True + label: "typing.Optional[str]" + """ + Device label (set by user during device setup) + """ -class _UniffiConverterTypeTrezorPrevTxOutput(_UniffiConverterRustBuffer): - @staticmethod - def read(buf): - return TrezorPrevTxOutput( - amount=_UniffiConverterUInt64.read(buf), - script_pubkey=_UniffiConverterString.read(buf), - ) + model: "typing.Optional[str]" + """ + Device model (e.g., "T2", "Safe 5", "Safe 7") + """ - @staticmethod - def check_lower(value): - _UniffiConverterUInt64.check_lower(value.amount) - _UniffiConverterString.check_lower(value.script_pubkey) - - @staticmethod - def write(value, buf): - _UniffiConverterUInt64.write(value.amount, buf) - _UniffiConverterString.write(value.script_pubkey, buf) - - -class TrezorPublicKeyResponse: - """ - Public key response from device. - """ - - xpub: "str" - """ - Extended public key (xpub) - """ - - path: "str" - """ - The serialized path (e.g., "m/84'/0'/0'") - """ - - public_key: "str" - """ - Compressed public key (hex encoded) - """ - - chain_code: "str" - """ - Chain code (hex encoded) - """ - - fingerprint: "int" - """ - Parent key fingerprint - """ - - depth: "int" - """ - Derivation depth - """ - - root_fingerprint: "typing.Optional[int]" + is_bootloader: "bool" """ - Master root fingerprint (from the device's master seed) + Whether the device is in bootloader mode """ - def __init__(self, *, xpub: "str", path: "str", public_key: "str", chain_code: "str", fingerprint: "int", depth: "int", root_fingerprint: "typing.Optional[int]"): - self.xpub = xpub + def __init__(self, *, id: "str", transport_type: "TrezorTransportType", name: "typing.Optional[str]", path: "str", label: "typing.Optional[str]", model: "typing.Optional[str]", is_bootloader: "bool"): + self.id = id + self.transport_type = transport_type + self.name = name self.path = path - self.public_key = public_key - self.chain_code = chain_code - self.fingerprint = fingerprint - self.depth = depth - self.root_fingerprint = root_fingerprint + self.label = label + self.model = model + self.is_bootloader = is_bootloader def __str__(self): - return "TrezorPublicKeyResponse(xpub={}, path={}, public_key={}, chain_code={}, fingerprint={}, depth={}, root_fingerprint={})".format(self.xpub, self.path, self.public_key, self.chain_code, self.fingerprint, self.depth, self.root_fingerprint) + return "TrezorDeviceInfo(id={}, transport_type={}, name={}, path={}, label={}, model={}, is_bootloader={})".format(self.id, self.transport_type, self.name, self.path, self.label, self.model, self.is_bootloader) def __eq__(self, other): - if self.xpub != other.xpub: + if self.id != other.id: return False - if self.path != other.path: + if self.transport_type != other.transport_type: return False - if self.public_key != other.public_key: + if self.name != other.name: return False - if self.chain_code != other.chain_code: + if self.path != other.path: return False - if self.fingerprint != other.fingerprint: + if self.label != other.label: return False - if self.depth != other.depth: + if self.model != other.model: return False - if self.root_fingerprint != other.root_fingerprint: + if self.is_bootloader != other.is_bootloader: return False return True -class _UniffiConverterTypeTrezorPublicKeyResponse(_UniffiConverterRustBuffer): +class _UniffiConverterTypeTrezorDeviceInfo(_UniffiConverterRustBuffer): @staticmethod def read(buf): - return TrezorPublicKeyResponse( - xpub=_UniffiConverterString.read(buf), + return TrezorDeviceInfo( + id=_UniffiConverterString.read(buf), + transport_type=_UniffiConverterTypeTrezorTransportType.read(buf), + name=_UniffiConverterOptionalString.read(buf), path=_UniffiConverterString.read(buf), - public_key=_UniffiConverterString.read(buf), - chain_code=_UniffiConverterString.read(buf), - fingerprint=_UniffiConverterUInt32.read(buf), - depth=_UniffiConverterUInt32.read(buf), - root_fingerprint=_UniffiConverterOptionalUInt32.read(buf), + label=_UniffiConverterOptionalString.read(buf), + model=_UniffiConverterOptionalString.read(buf), + is_bootloader=_UniffiConverterBool.read(buf), ) @staticmethod def check_lower(value): - _UniffiConverterString.check_lower(value.xpub) + _UniffiConverterString.check_lower(value.id) + _UniffiConverterTypeTrezorTransportType.check_lower(value.transport_type) + _UniffiConverterOptionalString.check_lower(value.name) _UniffiConverterString.check_lower(value.path) - _UniffiConverterString.check_lower(value.public_key) - _UniffiConverterString.check_lower(value.chain_code) - _UniffiConverterUInt32.check_lower(value.fingerprint) - _UniffiConverterUInt32.check_lower(value.depth) - _UniffiConverterOptionalUInt32.check_lower(value.root_fingerprint) + _UniffiConverterOptionalString.check_lower(value.label) + _UniffiConverterOptionalString.check_lower(value.model) + _UniffiConverterBool.check_lower(value.is_bootloader) @staticmethod def write(value, buf): - _UniffiConverterString.write(value.xpub, buf) + _UniffiConverterString.write(value.id, buf) + _UniffiConverterTypeTrezorTransportType.write(value.transport_type, buf) + _UniffiConverterOptionalString.write(value.name, buf) _UniffiConverterString.write(value.path, buf) - _UniffiConverterString.write(value.public_key, buf) - _UniffiConverterString.write(value.chain_code, buf) - _UniffiConverterUInt32.write(value.fingerprint, buf) - _UniffiConverterUInt32.write(value.depth, buf) - _UniffiConverterOptionalUInt32.write(value.root_fingerprint, buf) + _UniffiConverterOptionalString.write(value.label, buf) + _UniffiConverterOptionalString.write(value.model, buf) + _UniffiConverterBool.write(value.is_bootloader, buf) -class TrezorSignMessageParams: +class TrezorFeatures: """ - Parameters for signing a message. + Device features after initialization. """ - path: "str" + vendor: "typing.Optional[str]" """ - BIP32 path for the signing key (e.g., "m/84'/0'/0'/0/0") + Vendor string """ - message: "str" + model: "typing.Optional[str]" """ - Message to sign + Device model """ - coin: "typing.Optional[TrezorCoinType]" + label: "typing.Optional[str]" """ - Coin network (default: Bitcoin) + Device label (set by user during device setup) """ - def __init__(self, *, path: "str", message: "str", coin: "typing.Optional[TrezorCoinType]"): - self.path = path - self.message = message - self.coin = coin - - def __str__(self): - return "TrezorSignMessageParams(path={}, message={}, coin={})".format(self.path, self.message, self.coin) - - def __eq__(self, other): - if self.path != other.path: - return False - if self.message != other.message: - return False - if self.coin != other.coin: - return False - return True - -class _UniffiConverterTypeTrezorSignMessageParams(_UniffiConverterRustBuffer): - @staticmethod - def read(buf): - return TrezorSignMessageParams( - path=_UniffiConverterString.read(buf), - message=_UniffiConverterString.read(buf), - coin=_UniffiConverterOptionalTypeTrezorCoinType.read(buf), - ) - - @staticmethod - def check_lower(value): - _UniffiConverterString.check_lower(value.path) - _UniffiConverterString.check_lower(value.message) - _UniffiConverterOptionalTypeTrezorCoinType.check_lower(value.coin) + device_id: "typing.Optional[str]" + """ + Device ID (unique per device) + """ - @staticmethod - def write(value, buf): - _UniffiConverterString.write(value.path, buf) - _UniffiConverterString.write(value.message, buf) - _UniffiConverterOptionalTypeTrezorCoinType.write(value.coin, buf) + major_version: "typing.Optional[int]" + """ + Major firmware version + """ + minor_version: "typing.Optional[int]" + """ + Minor firmware version + """ -class TrezorSignTxParams: + patch_version: "typing.Optional[int]" """ - Parameters for signing a transaction. + Patch firmware version """ - inputs: "typing.List[TrezorTxInput]" + pin_protection: "typing.Optional[bool]" """ - Transaction inputs + Whether PIN protection is enabled """ - outputs: "typing.List[TrezorTxOutput]" + unlocked: "typing.Optional[bool]" """ - Transaction outputs + Whether the device is currently unlocked. When PIN protection is enabled + and this is `Some(false)`, mobile callers should back off and ask the + user to unlock the Trezor instead of repeatedly reconnecting. """ - coin: "typing.Optional[TrezorCoinType]" + passphrase_protection: "typing.Optional[bool]" """ - Coin network (default: Bitcoin) + Whether passphrase protection is enabled """ - lock_time: "typing.Optional[int]" + initialized: "typing.Optional[bool]" """ - Lock time (default: 0) + Whether the device is initialized with a seed """ - version: "typing.Optional[int]" + needs_backup: "typing.Optional[bool]" """ - Version (default: 2) + Whether the device needs backup """ - prev_txs: "typing.List[TrezorPrevTx]" + passphrase_entry_capable: "typing.Optional[bool]" """ - Previous transactions (for non-SegWit input verification) + Whether the device can accept passphrase entry on the device itself + (`Capability_PassphraseEntry`). When false/None, use host entry only. """ - def __init__(self, *, inputs: "typing.List[TrezorTxInput]", outputs: "typing.List[TrezorTxOutput]", coin: "typing.Optional[TrezorCoinType]", lock_time: "typing.Optional[int]", version: "typing.Optional[int]", prev_txs: "typing.List[TrezorPrevTx]"): - self.inputs = inputs - self.outputs = outputs - self.coin = coin - self.lock_time = lock_time - self.version = version - self.prev_txs = prev_txs + def __init__(self, *, vendor: "typing.Optional[str]", model: "typing.Optional[str]", label: "typing.Optional[str]", device_id: "typing.Optional[str]", major_version: "typing.Optional[int]", minor_version: "typing.Optional[int]", patch_version: "typing.Optional[int]", pin_protection: "typing.Optional[bool]", unlocked: "typing.Optional[bool]", passphrase_protection: "typing.Optional[bool]", initialized: "typing.Optional[bool]", needs_backup: "typing.Optional[bool]", passphrase_entry_capable: "typing.Optional[bool]"): + self.vendor = vendor + self.model = model + self.label = label + self.device_id = device_id + self.major_version = major_version + self.minor_version = minor_version + self.patch_version = patch_version + self.pin_protection = pin_protection + self.unlocked = unlocked + self.passphrase_protection = passphrase_protection + self.initialized = initialized + self.needs_backup = needs_backup + self.passphrase_entry_capable = passphrase_entry_capable def __str__(self): - return "TrezorSignTxParams(inputs={}, outputs={}, coin={}, lock_time={}, version={}, prev_txs={})".format(self.inputs, self.outputs, self.coin, self.lock_time, self.version, self.prev_txs) + return "TrezorFeatures(vendor={}, model={}, label={}, device_id={}, major_version={}, minor_version={}, patch_version={}, pin_protection={}, unlocked={}, passphrase_protection={}, initialized={}, needs_backup={}, passphrase_entry_capable={})".format(self.vendor, self.model, self.label, self.device_id, self.major_version, self.minor_version, self.patch_version, self.pin_protection, self.unlocked, self.passphrase_protection, self.initialized, self.needs_backup, self.passphrase_entry_capable) def __eq__(self, other): - if self.inputs != other.inputs: + if self.vendor != other.vendor: return False - if self.outputs != other.outputs: + if self.model != other.model: return False - if self.coin != other.coin: + if self.label != other.label: return False - if self.lock_time != other.lock_time: + if self.device_id != other.device_id: return False - if self.version != other.version: + if self.major_version != other.major_version: return False - if self.prev_txs != other.prev_txs: + if self.minor_version != other.minor_version: return False - return True - -class _UniffiConverterTypeTrezorSignTxParams(_UniffiConverterRustBuffer): - @staticmethod - def read(buf): - return TrezorSignTxParams( - inputs=_UniffiConverterSequenceTypeTrezorTxInput.read(buf), - outputs=_UniffiConverterSequenceTypeTrezorTxOutput.read(buf), - coin=_UniffiConverterOptionalTypeTrezorCoinType.read(buf), - lock_time=_UniffiConverterOptionalUInt32.read(buf), - version=_UniffiConverterOptionalUInt32.read(buf), - prev_txs=_UniffiConverterSequenceTypeTrezorPrevTx.read(buf), + if self.patch_version != other.patch_version: + return False + if self.pin_protection != other.pin_protection: + return False + if self.unlocked != other.unlocked: + return False + if self.passphrase_protection != other.passphrase_protection: + return False + if self.initialized != other.initialized: + return False + if self.needs_backup != other.needs_backup: + return False + if self.passphrase_entry_capable != other.passphrase_entry_capable: + return False + return True + +class _UniffiConverterTypeTrezorFeatures(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + return TrezorFeatures( + vendor=_UniffiConverterOptionalString.read(buf), + model=_UniffiConverterOptionalString.read(buf), + label=_UniffiConverterOptionalString.read(buf), + device_id=_UniffiConverterOptionalString.read(buf), + major_version=_UniffiConverterOptionalUInt32.read(buf), + minor_version=_UniffiConverterOptionalUInt32.read(buf), + patch_version=_UniffiConverterOptionalUInt32.read(buf), + pin_protection=_UniffiConverterOptionalBool.read(buf), + unlocked=_UniffiConverterOptionalBool.read(buf), + passphrase_protection=_UniffiConverterOptionalBool.read(buf), + initialized=_UniffiConverterOptionalBool.read(buf), + needs_backup=_UniffiConverterOptionalBool.read(buf), + passphrase_entry_capable=_UniffiConverterOptionalBool.read(buf), ) @staticmethod def check_lower(value): - _UniffiConverterSequenceTypeTrezorTxInput.check_lower(value.inputs) - _UniffiConverterSequenceTypeTrezorTxOutput.check_lower(value.outputs) - _UniffiConverterOptionalTypeTrezorCoinType.check_lower(value.coin) - _UniffiConverterOptionalUInt32.check_lower(value.lock_time) - _UniffiConverterOptionalUInt32.check_lower(value.version) - _UniffiConverterSequenceTypeTrezorPrevTx.check_lower(value.prev_txs) + _UniffiConverterOptionalString.check_lower(value.vendor) + _UniffiConverterOptionalString.check_lower(value.model) + _UniffiConverterOptionalString.check_lower(value.label) + _UniffiConverterOptionalString.check_lower(value.device_id) + _UniffiConverterOptionalUInt32.check_lower(value.major_version) + _UniffiConverterOptionalUInt32.check_lower(value.minor_version) + _UniffiConverterOptionalUInt32.check_lower(value.patch_version) + _UniffiConverterOptionalBool.check_lower(value.pin_protection) + _UniffiConverterOptionalBool.check_lower(value.unlocked) + _UniffiConverterOptionalBool.check_lower(value.passphrase_protection) + _UniffiConverterOptionalBool.check_lower(value.initialized) + _UniffiConverterOptionalBool.check_lower(value.needs_backup) + _UniffiConverterOptionalBool.check_lower(value.passphrase_entry_capable) @staticmethod def write(value, buf): - _UniffiConverterSequenceTypeTrezorTxInput.write(value.inputs, buf) - _UniffiConverterSequenceTypeTrezorTxOutput.write(value.outputs, buf) - _UniffiConverterOptionalTypeTrezorCoinType.write(value.coin, buf) - _UniffiConverterOptionalUInt32.write(value.lock_time, buf) - _UniffiConverterOptionalUInt32.write(value.version, buf) - _UniffiConverterSequenceTypeTrezorPrevTx.write(value.prev_txs, buf) + _UniffiConverterOptionalString.write(value.vendor, buf) + _UniffiConverterOptionalString.write(value.model, buf) + _UniffiConverterOptionalString.write(value.label, buf) + _UniffiConverterOptionalString.write(value.device_id, buf) + _UniffiConverterOptionalUInt32.write(value.major_version, buf) + _UniffiConverterOptionalUInt32.write(value.minor_version, buf) + _UniffiConverterOptionalUInt32.write(value.patch_version, buf) + _UniffiConverterOptionalBool.write(value.pin_protection, buf) + _UniffiConverterOptionalBool.write(value.unlocked, buf) + _UniffiConverterOptionalBool.write(value.passphrase_protection, buf) + _UniffiConverterOptionalBool.write(value.initialized, buf) + _UniffiConverterOptionalBool.write(value.needs_backup, buf) + _UniffiConverterOptionalBool.write(value.passphrase_entry_capable, buf) -class TrezorSignedMessageResponse: +class TrezorGetAddressParams: """ - Response from signing a message. + Parameters for getting an address from the device. """ - address: "str" + path: "str" """ - Bitcoin address that signed the message + BIP32 path (e.g., "m/84'/0'/0'/0/0") """ - signature: "str" + coin: "typing.Optional[TrezorCoinType]" """ - Signature (base64 encoded) + Coin network (default: Bitcoin) """ - def __init__(self, *, address: "str", signature: "str"): - self.address = address - self.signature = signature + show_on_trezor: "bool" + """ + Whether to display the address on the device for confirmation + """ + + script_type: "typing.Optional[TrezorScriptType]" + """ + Script type (auto-detected from path if not specified) + """ + + def __init__(self, *, path: "str", coin: "typing.Optional[TrezorCoinType]", show_on_trezor: "bool", script_type: "typing.Optional[TrezorScriptType]"): + self.path = path + self.coin = coin + self.show_on_trezor = show_on_trezor + self.script_type = script_type def __str__(self): - return "TrezorSignedMessageResponse(address={}, signature={})".format(self.address, self.signature) + return "TrezorGetAddressParams(path={}, coin={}, show_on_trezor={}, script_type={})".format(self.path, self.coin, self.show_on_trezor, self.script_type) def __eq__(self, other): - if self.address != other.address: + if self.path != other.path: return False - if self.signature != other.signature: + if self.coin != other.coin: + return False + if self.show_on_trezor != other.show_on_trezor: + return False + if self.script_type != other.script_type: return False return True -class _UniffiConverterTypeTrezorSignedMessageResponse(_UniffiConverterRustBuffer): +class _UniffiConverterTypeTrezorGetAddressParams(_UniffiConverterRustBuffer): @staticmethod def read(buf): - return TrezorSignedMessageResponse( - address=_UniffiConverterString.read(buf), - signature=_UniffiConverterString.read(buf), + return TrezorGetAddressParams( + path=_UniffiConverterString.read(buf), + coin=_UniffiConverterOptionalTypeTrezorCoinType.read(buf), + show_on_trezor=_UniffiConverterBool.read(buf), + script_type=_UniffiConverterOptionalTypeTrezorScriptType.read(buf), ) @staticmethod def check_lower(value): - _UniffiConverterString.check_lower(value.address) - _UniffiConverterString.check_lower(value.signature) + _UniffiConverterString.check_lower(value.path) + _UniffiConverterOptionalTypeTrezorCoinType.check_lower(value.coin) + _UniffiConverterBool.check_lower(value.show_on_trezor) + _UniffiConverterOptionalTypeTrezorScriptType.check_lower(value.script_type) @staticmethod def write(value, buf): - _UniffiConverterString.write(value.address, buf) - _UniffiConverterString.write(value.signature, buf) + _UniffiConverterString.write(value.path, buf) + _UniffiConverterOptionalTypeTrezorCoinType.write(value.coin, buf) + _UniffiConverterBool.write(value.show_on_trezor, buf) + _UniffiConverterOptionalTypeTrezorScriptType.write(value.script_type, buf) -class TrezorSignedTx: +class TrezorGetPublicKeyParams: """ - Signed transaction result. + Parameters for getting a public key from the device. """ - signatures: "typing.List[str]" + path: "str" """ - Signatures for each input (hex encoded) + BIP32 path (e.g., "m/84'/0'/0'") """ - serialized_tx: "str" + coin: "typing.Optional[TrezorCoinType]" """ - Serialized transaction (hex) + Coin network (default: Bitcoin) """ - txid: "typing.Optional[str]" + show_on_trezor: "bool" """ - Broadcast transaction ID (populated when push=true) + Whether to display on device for confirmation """ - def __init__(self, *, signatures: "typing.List[str]", serialized_tx: "str", txid: "typing.Optional[str]"): - self.signatures = signatures - self.serialized_tx = serialized_tx - self.txid = txid + def __init__(self, *, path: "str", coin: "typing.Optional[TrezorCoinType]", show_on_trezor: "bool"): + self.path = path + self.coin = coin + self.show_on_trezor = show_on_trezor def __str__(self): - return "TrezorSignedTx(signatures={}, serialized_tx={}, txid={})".format(self.signatures, self.serialized_tx, self.txid) + return "TrezorGetPublicKeyParams(path={}, coin={}, show_on_trezor={})".format(self.path, self.coin, self.show_on_trezor) def __eq__(self, other): - if self.signatures != other.signatures: + if self.path != other.path: return False - if self.serialized_tx != other.serialized_tx: + if self.coin != other.coin: return False - if self.txid != other.txid: + if self.show_on_trezor != other.show_on_trezor: return False return True -class _UniffiConverterTypeTrezorSignedTx(_UniffiConverterRustBuffer): +class _UniffiConverterTypeTrezorGetPublicKeyParams(_UniffiConverterRustBuffer): @staticmethod def read(buf): - return TrezorSignedTx( - signatures=_UniffiConverterSequenceString.read(buf), - serialized_tx=_UniffiConverterString.read(buf), - txid=_UniffiConverterOptionalString.read(buf), + return TrezorGetPublicKeyParams( + path=_UniffiConverterString.read(buf), + coin=_UniffiConverterOptionalTypeTrezorCoinType.read(buf), + show_on_trezor=_UniffiConverterBool.read(buf), ) @staticmethod def check_lower(value): - _UniffiConverterSequenceString.check_lower(value.signatures) - _UniffiConverterString.check_lower(value.serialized_tx) - _UniffiConverterOptionalString.check_lower(value.txid) + _UniffiConverterString.check_lower(value.path) + _UniffiConverterOptionalTypeTrezorCoinType.check_lower(value.coin) + _UniffiConverterBool.check_lower(value.show_on_trezor) @staticmethod def write(value, buf): - _UniffiConverterSequenceString.write(value.signatures, buf) - _UniffiConverterString.write(value.serialized_tx, buf) - _UniffiConverterOptionalString.write(value.txid, buf) + _UniffiConverterString.write(value.path, buf) + _UniffiConverterOptionalTypeTrezorCoinType.write(value.coin, buf) + _UniffiConverterBool.write(value.show_on_trezor, buf) -class TrezorTransportReadResult: +class TrezorPrevTx: """ - Result from a transport read operation + Previous transaction data (for non-SegWit input verification). """ - success: "bool" + hash: "str" """ - Whether the read succeeded + Transaction hash (hex encoded) """ - data: "bytes" + version: "int" """ - Data read (empty on failure) + Transaction version """ - error: "str" + lock_time: "int" """ - Error message (empty on success) + Lock time """ - error_code: "typing.Optional[TrezorTransportErrorCode]" + inputs: "typing.List[TrezorPrevTxInput]" """ - Structured error code (None on success or when the native error is generic) + Transaction inputs """ - def __init__(self, *, success: "bool", data: "bytes", error: "str", error_code: "typing.Optional[TrezorTransportErrorCode]"): - self.success = success - self.data = data - self.error = error - self.error_code = error_code + outputs: "typing.List[TrezorPrevTxOutput]" + """ + Transaction outputs + """ + + def __init__(self, *, hash: "str", version: "int", lock_time: "int", inputs: "typing.List[TrezorPrevTxInput]", outputs: "typing.List[TrezorPrevTxOutput]"): + self.hash = hash + self.version = version + self.lock_time = lock_time + self.inputs = inputs + self.outputs = outputs def __str__(self): - return "TrezorTransportReadResult(success={}, data={}, error={}, error_code={})".format(self.success, self.data, self.error, self.error_code) + return "TrezorPrevTx(hash={}, version={}, lock_time={}, inputs={}, outputs={})".format(self.hash, self.version, self.lock_time, self.inputs, self.outputs) def __eq__(self, other): - if self.success != other.success: + if self.hash != other.hash: return False - if self.data != other.data: + if self.version != other.version: return False - if self.error != other.error: + if self.lock_time != other.lock_time: return False - if self.error_code != other.error_code: + if self.inputs != other.inputs: + return False + if self.outputs != other.outputs: return False return True -class _UniffiConverterTypeTrezorTransportReadResult(_UniffiConverterRustBuffer): +class _UniffiConverterTypeTrezorPrevTx(_UniffiConverterRustBuffer): @staticmethod def read(buf): - return TrezorTransportReadResult( - success=_UniffiConverterBool.read(buf), - data=_UniffiConverterBytes.read(buf), - error=_UniffiConverterString.read(buf), - error_code=_UniffiConverterOptionalTypeTrezorTransportErrorCode.read(buf), + return TrezorPrevTx( + hash=_UniffiConverterString.read(buf), + version=_UniffiConverterUInt32.read(buf), + lock_time=_UniffiConverterUInt32.read(buf), + inputs=_UniffiConverterSequenceTypeTrezorPrevTxInput.read(buf), + outputs=_UniffiConverterSequenceTypeTrezorPrevTxOutput.read(buf), ) @staticmethod def check_lower(value): - _UniffiConverterBool.check_lower(value.success) - _UniffiConverterBytes.check_lower(value.data) - _UniffiConverterString.check_lower(value.error) - _UniffiConverterOptionalTypeTrezorTransportErrorCode.check_lower(value.error_code) + _UniffiConverterString.check_lower(value.hash) + _UniffiConverterUInt32.check_lower(value.version) + _UniffiConverterUInt32.check_lower(value.lock_time) + _UniffiConverterSequenceTypeTrezorPrevTxInput.check_lower(value.inputs) + _UniffiConverterSequenceTypeTrezorPrevTxOutput.check_lower(value.outputs) @staticmethod def write(value, buf): - _UniffiConverterBool.write(value.success, buf) - _UniffiConverterBytes.write(value.data, buf) - _UniffiConverterString.write(value.error, buf) - _UniffiConverterOptionalTypeTrezorTransportErrorCode.write(value.error_code, buf) + _UniffiConverterString.write(value.hash, buf) + _UniffiConverterUInt32.write(value.version, buf) + _UniffiConverterUInt32.write(value.lock_time, buf) + _UniffiConverterSequenceTypeTrezorPrevTxInput.write(value.inputs, buf) + _UniffiConverterSequenceTypeTrezorPrevTxOutput.write(value.outputs, buf) -class TrezorTransportWriteResult: +class TrezorPrevTxInput: """ - Result from a transport write or open operation + Input of a previous transaction. """ - success: "bool" + prev_hash: "str" """ - Whether the operation succeeded + Previous transaction hash (hex encoded) """ - error: "str" + prev_index: "int" """ - Error message (empty on success) + Previous output index """ - error_code: "typing.Optional[TrezorTransportErrorCode]" + script_sig: "str" """ - Structured error code (None on success or when the native error is generic) + Script signature (hex encoded) """ - def __init__(self, *, success: "bool", error: "str", error_code: "typing.Optional[TrezorTransportErrorCode]"): - self.success = success - self.error = error - self.error_code = error_code + sequence: "int" + """ + Sequence number + """ + + def __init__(self, *, prev_hash: "str", prev_index: "int", script_sig: "str", sequence: "int"): + self.prev_hash = prev_hash + self.prev_index = prev_index + self.script_sig = script_sig + self.sequence = sequence def __str__(self): - return "TrezorTransportWriteResult(success={}, error={}, error_code={})".format(self.success, self.error, self.error_code) + return "TrezorPrevTxInput(prev_hash={}, prev_index={}, script_sig={}, sequence={})".format(self.prev_hash, self.prev_index, self.script_sig, self.sequence) def __eq__(self, other): - if self.success != other.success: + if self.prev_hash != other.prev_hash: return False - if self.error != other.error: + if self.prev_index != other.prev_index: return False - if self.error_code != other.error_code: + if self.script_sig != other.script_sig: + return False + if self.sequence != other.sequence: return False return True -class _UniffiConverterTypeTrezorTransportWriteResult(_UniffiConverterRustBuffer): +class _UniffiConverterTypeTrezorPrevTxInput(_UniffiConverterRustBuffer): @staticmethod def read(buf): - return TrezorTransportWriteResult( - success=_UniffiConverterBool.read(buf), - error=_UniffiConverterString.read(buf), - error_code=_UniffiConverterOptionalTypeTrezorTransportErrorCode.read(buf), + return TrezorPrevTxInput( + prev_hash=_UniffiConverterString.read(buf), + prev_index=_UniffiConverterUInt32.read(buf), + script_sig=_UniffiConverterString.read(buf), + sequence=_UniffiConverterUInt32.read(buf), ) @staticmethod def check_lower(value): - _UniffiConverterBool.check_lower(value.success) - _UniffiConverterString.check_lower(value.error) - _UniffiConverterOptionalTypeTrezorTransportErrorCode.check_lower(value.error_code) + _UniffiConverterString.check_lower(value.prev_hash) + _UniffiConverterUInt32.check_lower(value.prev_index) + _UniffiConverterString.check_lower(value.script_sig) + _UniffiConverterUInt32.check_lower(value.sequence) @staticmethod def write(value, buf): - _UniffiConverterBool.write(value.success, buf) - _UniffiConverterString.write(value.error, buf) - _UniffiConverterOptionalTypeTrezorTransportErrorCode.write(value.error_code, buf) - - -class TrezorTxInput: - """ - Transaction input for signing. - """ - - prev_hash: "str" - """ - Previous transaction hash (hex, 32 bytes) - """ + _UniffiConverterString.write(value.prev_hash, buf) + _UniffiConverterUInt32.write(value.prev_index, buf) + _UniffiConverterString.write(value.script_sig, buf) + _UniffiConverterUInt32.write(value.sequence, buf) - prev_index: "int" - """ - Previous output index - """ - path: "str" +class TrezorPrevTxOutput: """ - BIP32 derivation path (e.g., "m/84'/0'/0'/0/0") + Output of a previous transaction. """ amount: "int" @@ -10329,216 +10585,160 @@ class TrezorTxInput: Amount in satoshis """ - script_type: "TrezorScriptType" - """ - Script type - """ - - sequence: "typing.Optional[int]" - """ - Sequence number (default: 0xFFFFFFFD for RBF) - """ - - orig_hash: "typing.Optional[str]" - """ - Original transaction hash for RBF replacement (hex encoded) - """ - - orig_index: "typing.Optional[int]" + script_pubkey: "str" """ - Original input index for RBF replacement + Script pubkey (hex encoded) """ - def __init__(self, *, prev_hash: "str", prev_index: "int", path: "str", amount: "int", script_type: "TrezorScriptType", sequence: "typing.Optional[int]", orig_hash: "typing.Optional[str]", orig_index: "typing.Optional[int]"): - self.prev_hash = prev_hash - self.prev_index = prev_index - self.path = path + def __init__(self, *, amount: "int", script_pubkey: "str"): self.amount = amount - self.script_type = script_type - self.sequence = sequence - self.orig_hash = orig_hash - self.orig_index = orig_index + self.script_pubkey = script_pubkey def __str__(self): - return "TrezorTxInput(prev_hash={}, prev_index={}, path={}, amount={}, script_type={}, sequence={}, orig_hash={}, orig_index={})".format(self.prev_hash, self.prev_index, self.path, self.amount, self.script_type, self.sequence, self.orig_hash, self.orig_index) + return "TrezorPrevTxOutput(amount={}, script_pubkey={})".format(self.amount, self.script_pubkey) def __eq__(self, other): - if self.prev_hash != other.prev_hash: - return False - if self.prev_index != other.prev_index: - return False - if self.path != other.path: - return False if self.amount != other.amount: return False - if self.script_type != other.script_type: - return False - if self.sequence != other.sequence: - return False - if self.orig_hash != other.orig_hash: - return False - if self.orig_index != other.orig_index: + if self.script_pubkey != other.script_pubkey: return False return True -class _UniffiConverterTypeTrezorTxInput(_UniffiConverterRustBuffer): +class _UniffiConverterTypeTrezorPrevTxOutput(_UniffiConverterRustBuffer): @staticmethod def read(buf): - return TrezorTxInput( - prev_hash=_UniffiConverterString.read(buf), - prev_index=_UniffiConverterUInt32.read(buf), - path=_UniffiConverterString.read(buf), + return TrezorPrevTxOutput( amount=_UniffiConverterUInt64.read(buf), - script_type=_UniffiConverterTypeTrezorScriptType.read(buf), - sequence=_UniffiConverterOptionalUInt32.read(buf), - orig_hash=_UniffiConverterOptionalString.read(buf), - orig_index=_UniffiConverterOptionalUInt32.read(buf), + script_pubkey=_UniffiConverterString.read(buf), ) @staticmethod def check_lower(value): - _UniffiConverterString.check_lower(value.prev_hash) - _UniffiConverterUInt32.check_lower(value.prev_index) - _UniffiConverterString.check_lower(value.path) _UniffiConverterUInt64.check_lower(value.amount) - _UniffiConverterTypeTrezorScriptType.check_lower(value.script_type) - _UniffiConverterOptionalUInt32.check_lower(value.sequence) - _UniffiConverterOptionalString.check_lower(value.orig_hash) - _UniffiConverterOptionalUInt32.check_lower(value.orig_index) + _UniffiConverterString.check_lower(value.script_pubkey) @staticmethod def write(value, buf): - _UniffiConverterString.write(value.prev_hash, buf) - _UniffiConverterUInt32.write(value.prev_index, buf) - _UniffiConverterString.write(value.path, buf) _UniffiConverterUInt64.write(value.amount, buf) - _UniffiConverterTypeTrezorScriptType.write(value.script_type, buf) - _UniffiConverterOptionalUInt32.write(value.sequence, buf) - _UniffiConverterOptionalString.write(value.orig_hash, buf) - _UniffiConverterOptionalUInt32.write(value.orig_index, buf) + _UniffiConverterString.write(value.script_pubkey, buf) -class TrezorTxOutput: +class TrezorPublicKeyResponse: """ - Transaction output for signing. + Public key response from device. """ - address: "typing.Optional[str]" + xpub: "str" """ - Destination address (for external outputs) + Extended public key (xpub) """ - path: "typing.Optional[str]" + path: "str" """ - BIP32 path (for change outputs) + The serialized path (e.g., "m/84'/0'/0'") """ - amount: "int" + public_key: "str" """ - Amount in satoshis + Compressed public key (hex encoded) """ - script_type: "typing.Optional[TrezorScriptType]" + chain_code: "str" """ - Script type (for change outputs) + Chain code (hex encoded) """ - op_return_data: "typing.Optional[str]" + fingerprint: "int" """ - OP_RETURN data (hex encoded, for data outputs) + Parent key fingerprint """ - orig_hash: "typing.Optional[str]" + depth: "int" """ - Original transaction hash for RBF replacement (hex encoded) + Derivation depth """ - orig_index: "typing.Optional[int]" + root_fingerprint: "typing.Optional[int]" """ - Original output index for RBF replacement + Master root fingerprint (from the device's master seed) """ - def __init__(self, *, address: "typing.Optional[str]", path: "typing.Optional[str]", amount: "int", script_type: "typing.Optional[TrezorScriptType]", op_return_data: "typing.Optional[str]", orig_hash: "typing.Optional[str]", orig_index: "typing.Optional[int]"): - self.address = address + def __init__(self, *, xpub: "str", path: "str", public_key: "str", chain_code: "str", fingerprint: "int", depth: "int", root_fingerprint: "typing.Optional[int]"): + self.xpub = xpub self.path = path - self.amount = amount - self.script_type = script_type - self.op_return_data = op_return_data - self.orig_hash = orig_hash - self.orig_index = orig_index + self.public_key = public_key + self.chain_code = chain_code + self.fingerprint = fingerprint + self.depth = depth + self.root_fingerprint = root_fingerprint def __str__(self): - return "TrezorTxOutput(address={}, path={}, amount={}, script_type={}, op_return_data={}, orig_hash={}, orig_index={})".format(self.address, self.path, self.amount, self.script_type, self.op_return_data, self.orig_hash, self.orig_index) + return "TrezorPublicKeyResponse(xpub={}, path={}, public_key={}, chain_code={}, fingerprint={}, depth={}, root_fingerprint={})".format(self.xpub, self.path, self.public_key, self.chain_code, self.fingerprint, self.depth, self.root_fingerprint) def __eq__(self, other): - if self.address != other.address: + if self.xpub != other.xpub: return False if self.path != other.path: return False - if self.amount != other.amount: + if self.public_key != other.public_key: return False - if self.script_type != other.script_type: + if self.chain_code != other.chain_code: return False - if self.op_return_data != other.op_return_data: + if self.fingerprint != other.fingerprint: return False - if self.orig_hash != other.orig_hash: + if self.depth != other.depth: return False - if self.orig_index != other.orig_index: + if self.root_fingerprint != other.root_fingerprint: return False return True -class _UniffiConverterTypeTrezorTxOutput(_UniffiConverterRustBuffer): +class _UniffiConverterTypeTrezorPublicKeyResponse(_UniffiConverterRustBuffer): @staticmethod def read(buf): - return TrezorTxOutput( - address=_UniffiConverterOptionalString.read(buf), - path=_UniffiConverterOptionalString.read(buf), - amount=_UniffiConverterUInt64.read(buf), - script_type=_UniffiConverterOptionalTypeTrezorScriptType.read(buf), - op_return_data=_UniffiConverterOptionalString.read(buf), - orig_hash=_UniffiConverterOptionalString.read(buf), - orig_index=_UniffiConverterOptionalUInt32.read(buf), + return TrezorPublicKeyResponse( + xpub=_UniffiConverterString.read(buf), + path=_UniffiConverterString.read(buf), + public_key=_UniffiConverterString.read(buf), + chain_code=_UniffiConverterString.read(buf), + fingerprint=_UniffiConverterUInt32.read(buf), + depth=_UniffiConverterUInt32.read(buf), + root_fingerprint=_UniffiConverterOptionalUInt32.read(buf), ) @staticmethod def check_lower(value): - _UniffiConverterOptionalString.check_lower(value.address) - _UniffiConverterOptionalString.check_lower(value.path) - _UniffiConverterUInt64.check_lower(value.amount) - _UniffiConverterOptionalTypeTrezorScriptType.check_lower(value.script_type) - _UniffiConverterOptionalString.check_lower(value.op_return_data) - _UniffiConverterOptionalString.check_lower(value.orig_hash) - _UniffiConverterOptionalUInt32.check_lower(value.orig_index) + _UniffiConverterString.check_lower(value.xpub) + _UniffiConverterString.check_lower(value.path) + _UniffiConverterString.check_lower(value.public_key) + _UniffiConverterString.check_lower(value.chain_code) + _UniffiConverterUInt32.check_lower(value.fingerprint) + _UniffiConverterUInt32.check_lower(value.depth) + _UniffiConverterOptionalUInt32.check_lower(value.root_fingerprint) @staticmethod def write(value, buf): - _UniffiConverterOptionalString.write(value.address, buf) - _UniffiConverterOptionalString.write(value.path, buf) - _UniffiConverterUInt64.write(value.amount, buf) - _UniffiConverterOptionalTypeTrezorScriptType.write(value.script_type, buf) - _UniffiConverterOptionalString.write(value.op_return_data, buf) - _UniffiConverterOptionalString.write(value.orig_hash, buf) - _UniffiConverterOptionalUInt32.write(value.orig_index, buf) - + _UniffiConverterString.write(value.xpub, buf) + _UniffiConverterString.write(value.path, buf) + _UniffiConverterString.write(value.public_key, buf) + _UniffiConverterString.write(value.chain_code, buf) + _UniffiConverterUInt32.write(value.fingerprint, buf) + _UniffiConverterUInt32.write(value.depth, buf) + _UniffiConverterOptionalUInt32.write(value.root_fingerprint, buf) -class TrezorVerifyMessageParams: - """ - Parameters for verifying a message signature. - """ - address: "str" +class TrezorSignMessageParams: """ - Bitcoin address that signed the message + Parameters for signing a message. """ - signature: "str" + path: "str" """ - Signature (base64 encoded) + BIP32 path for the signing key (e.g., "m/84'/0'/0'/0/0") """ message: "str" """ - Original message + Message to sign """ coin: "typing.Optional[TrezorCoinType]" @@ -10546,19 +10746,16 @@ class TrezorVerifyMessageParams: Coin network (default: Bitcoin) """ - def __init__(self, *, address: "str", signature: "str", message: "str", coin: "typing.Optional[TrezorCoinType]"): - self.address = address - self.signature = signature + def __init__(self, *, path: "str", message: "str", coin: "typing.Optional[TrezorCoinType]"): + self.path = path self.message = message self.coin = coin def __str__(self): - return "TrezorVerifyMessageParams(address={}, signature={}, message={}, coin={})".format(self.address, self.signature, self.message, self.coin) + return "TrezorSignMessageParams(path={}, message={}, coin={})".format(self.path, self.message, self.coin) def __eq__(self, other): - if self.address != other.address: - return False - if self.signature != other.signature: + if self.path != other.path: return False if self.message != other.message: return False @@ -10566,1742 +10763,1802 @@ def __eq__(self, other): return False return True -class _UniffiConverterTypeTrezorVerifyMessageParams(_UniffiConverterRustBuffer): +class _UniffiConverterTypeTrezorSignMessageParams(_UniffiConverterRustBuffer): @staticmethod def read(buf): - return TrezorVerifyMessageParams( - address=_UniffiConverterString.read(buf), - signature=_UniffiConverterString.read(buf), + return TrezorSignMessageParams( + path=_UniffiConverterString.read(buf), message=_UniffiConverterString.read(buf), coin=_UniffiConverterOptionalTypeTrezorCoinType.read(buf), ) @staticmethod def check_lower(value): - _UniffiConverterString.check_lower(value.address) - _UniffiConverterString.check_lower(value.signature) + _UniffiConverterString.check_lower(value.path) _UniffiConverterString.check_lower(value.message) _UniffiConverterOptionalTypeTrezorCoinType.check_lower(value.coin) @staticmethod def write(value, buf): - _UniffiConverterString.write(value.address, buf) - _UniffiConverterString.write(value.signature, buf) + _UniffiConverterString.write(value.path, buf) _UniffiConverterString.write(value.message, buf) _UniffiConverterOptionalTypeTrezorCoinType.write(value.coin, buf) -class TxDetailInput: +class TrezorSignTxParams: """ - A transaction input with full details. + Parameters for signing a transaction. """ - txid: "str" + inputs: "typing.List[TrezorTxInput]" """ - Previous output transaction ID (hex) + Transaction inputs """ - vout: "int" + outputs: "typing.List[TrezorTxOutput]" """ - Previous output index + Transaction outputs """ - sequence: "int" + coin: "typing.Optional[TrezorCoinType]" """ - Sequence number + Coin network (default: Bitcoin) """ - script_sig: "str" + lock_time: "typing.Optional[int]" """ - Script signature (hex-encoded) + Lock time (default: 0) """ - witness: "typing.List[str]" + version: "typing.Optional[int]" """ - Witness stack (each element hex-encoded) + Version (default: 2) """ - def __init__(self, *, txid: "str", vout: "int", sequence: "int", script_sig: "str", witness: "typing.List[str]"): - self.txid = txid - self.vout = vout - self.sequence = sequence - self.script_sig = script_sig - self.witness = witness + prev_txs: "typing.List[TrezorPrevTx]" + """ + Previous transactions (for non-SegWit input verification) + """ + + def __init__(self, *, inputs: "typing.List[TrezorTxInput]", outputs: "typing.List[TrezorTxOutput]", coin: "typing.Optional[TrezorCoinType]", lock_time: "typing.Optional[int]", version: "typing.Optional[int]", prev_txs: "typing.List[TrezorPrevTx]"): + self.inputs = inputs + self.outputs = outputs + self.coin = coin + self.lock_time = lock_time + self.version = version + self.prev_txs = prev_txs def __str__(self): - return "TxDetailInput(txid={}, vout={}, sequence={}, script_sig={}, witness={})".format(self.txid, self.vout, self.sequence, self.script_sig, self.witness) + return "TrezorSignTxParams(inputs={}, outputs={}, coin={}, lock_time={}, version={}, prev_txs={})".format(self.inputs, self.outputs, self.coin, self.lock_time, self.version, self.prev_txs) def __eq__(self, other): - if self.txid != other.txid: + if self.inputs != other.inputs: return False - if self.vout != other.vout: + if self.outputs != other.outputs: return False - if self.sequence != other.sequence: + if self.coin != other.coin: return False - if self.script_sig != other.script_sig: + if self.lock_time != other.lock_time: return False - if self.witness != other.witness: + if self.version != other.version: + return False + if self.prev_txs != other.prev_txs: return False return True -class _UniffiConverterTypeTxDetailInput(_UniffiConverterRustBuffer): +class _UniffiConverterTypeTrezorSignTxParams(_UniffiConverterRustBuffer): @staticmethod def read(buf): - return TxDetailInput( - txid=_UniffiConverterString.read(buf), - vout=_UniffiConverterUInt32.read(buf), - sequence=_UniffiConverterUInt32.read(buf), - script_sig=_UniffiConverterString.read(buf), - witness=_UniffiConverterSequenceString.read(buf), + return TrezorSignTxParams( + inputs=_UniffiConverterSequenceTypeTrezorTxInput.read(buf), + outputs=_UniffiConverterSequenceTypeTrezorTxOutput.read(buf), + coin=_UniffiConverterOptionalTypeTrezorCoinType.read(buf), + lock_time=_UniffiConverterOptionalUInt32.read(buf), + version=_UniffiConverterOptionalUInt32.read(buf), + prev_txs=_UniffiConverterSequenceTypeTrezorPrevTx.read(buf), ) @staticmethod def check_lower(value): - _UniffiConverterString.check_lower(value.txid) - _UniffiConverterUInt32.check_lower(value.vout) - _UniffiConverterUInt32.check_lower(value.sequence) - _UniffiConverterString.check_lower(value.script_sig) - _UniffiConverterSequenceString.check_lower(value.witness) + _UniffiConverterSequenceTypeTrezorTxInput.check_lower(value.inputs) + _UniffiConverterSequenceTypeTrezorTxOutput.check_lower(value.outputs) + _UniffiConverterOptionalTypeTrezorCoinType.check_lower(value.coin) + _UniffiConverterOptionalUInt32.check_lower(value.lock_time) + _UniffiConverterOptionalUInt32.check_lower(value.version) + _UniffiConverterSequenceTypeTrezorPrevTx.check_lower(value.prev_txs) @staticmethod def write(value, buf): - _UniffiConverterString.write(value.txid, buf) - _UniffiConverterUInt32.write(value.vout, buf) - _UniffiConverterUInt32.write(value.sequence, buf) - _UniffiConverterString.write(value.script_sig, buf) - _UniffiConverterSequenceString.write(value.witness, buf) - - -class TxDetailOutput: - """ - A transaction output with full details. - """ + _UniffiConverterSequenceTypeTrezorTxInput.write(value.inputs, buf) + _UniffiConverterSequenceTypeTrezorTxOutput.write(value.outputs, buf) + _UniffiConverterOptionalTypeTrezorCoinType.write(value.coin, buf) + _UniffiConverterOptionalUInt32.write(value.lock_time, buf) + _UniffiConverterOptionalUInt32.write(value.version, buf) + _UniffiConverterSequenceTypeTrezorPrevTx.write(value.prev_txs, buf) - value: "int" - """ - Output value in sats - """ - script_pubkey: "str" +class TrezorSignedMessageResponse: """ - Script public key (hex-encoded) + Response from signing a message. """ - address: "typing.Optional[str]" + address: "str" """ - Decoded address (None if script is not decodable to an address) + Bitcoin address that signed the message """ - is_mine: "bool" + signature: "str" """ - Whether this output belongs to the queried wallet + Signature (base64 encoded) """ - def __init__(self, *, value: "int", script_pubkey: "str", address: "typing.Optional[str]", is_mine: "bool"): - self.value = value - self.script_pubkey = script_pubkey + def __init__(self, *, address: "str", signature: "str"): self.address = address - self.is_mine = is_mine + self.signature = signature def __str__(self): - return "TxDetailOutput(value={}, script_pubkey={}, address={}, is_mine={})".format(self.value, self.script_pubkey, self.address, self.is_mine) + return "TrezorSignedMessageResponse(address={}, signature={})".format(self.address, self.signature) def __eq__(self, other): - if self.value != other.value: - return False - if self.script_pubkey != other.script_pubkey: - return False if self.address != other.address: return False - if self.is_mine != other.is_mine: + if self.signature != other.signature: return False return True -class _UniffiConverterTypeTxDetailOutput(_UniffiConverterRustBuffer): +class _UniffiConverterTypeTrezorSignedMessageResponse(_UniffiConverterRustBuffer): @staticmethod def read(buf): - return TxDetailOutput( - value=_UniffiConverterUInt64.read(buf), - script_pubkey=_UniffiConverterString.read(buf), - address=_UniffiConverterOptionalString.read(buf), - is_mine=_UniffiConverterBool.read(buf), + return TrezorSignedMessageResponse( + address=_UniffiConverterString.read(buf), + signature=_UniffiConverterString.read(buf), ) @staticmethod def check_lower(value): - _UniffiConverterUInt64.check_lower(value.value) - _UniffiConverterString.check_lower(value.script_pubkey) - _UniffiConverterOptionalString.check_lower(value.address) - _UniffiConverterBool.check_lower(value.is_mine) + _UniffiConverterString.check_lower(value.address) + _UniffiConverterString.check_lower(value.signature) @staticmethod def write(value, buf): - _UniffiConverterUInt64.write(value.value, buf) - _UniffiConverterString.write(value.script_pubkey, buf) - _UniffiConverterOptionalString.write(value.address, buf) - _UniffiConverterBool.write(value.is_mine, buf) - - -class TxInput: - """ - Details about a transaction input. - """ + _UniffiConverterString.write(value.address, buf) + _UniffiConverterString.write(value.signature, buf) - txid: "str" - """ - The transaction ID of the previous output being spent. - """ - vout: "int" +class TrezorSignedTx: """ - The output index of the previous output being spent. + Signed transaction result. """ - scriptsig: "str" + signatures: "typing.List[str]" """ - The script signature (hex-encoded). + Signatures for each input (hex encoded) """ - witness: "typing.List[str]" + serialized_tx: "str" """ - The witness stack (hex-encoded strings). + Serialized transaction (hex) """ - sequence: "int" + txid: "typing.Optional[str]" """ - The sequence number. + Broadcast transaction ID (populated when push=true) """ - def __init__(self, *, txid: "str", vout: "int", scriptsig: "str", witness: "typing.List[str]", sequence: "int"): + def __init__(self, *, signatures: "typing.List[str]", serialized_tx: "str", txid: "typing.Optional[str]"): + self.signatures = signatures + self.serialized_tx = serialized_tx self.txid = txid - self.vout = vout - self.scriptsig = scriptsig - self.witness = witness - self.sequence = sequence def __str__(self): - return "TxInput(txid={}, vout={}, scriptsig={}, witness={}, sequence={})".format(self.txid, self.vout, self.scriptsig, self.witness, self.sequence) + return "TrezorSignedTx(signatures={}, serialized_tx={}, txid={})".format(self.signatures, self.serialized_tx, self.txid) def __eq__(self, other): - if self.txid != other.txid: - return False - if self.vout != other.vout: + if self.signatures != other.signatures: return False - if self.scriptsig != other.scriptsig: + if self.serialized_tx != other.serialized_tx: return False - if self.witness != other.witness: - return False - if self.sequence != other.sequence: + if self.txid != other.txid: return False return True -class _UniffiConverterTypeTxInput(_UniffiConverterRustBuffer): +class _UniffiConverterTypeTrezorSignedTx(_UniffiConverterRustBuffer): @staticmethod def read(buf): - return TxInput( - txid=_UniffiConverterString.read(buf), - vout=_UniffiConverterUInt32.read(buf), - scriptsig=_UniffiConverterString.read(buf), - witness=_UniffiConverterSequenceString.read(buf), - sequence=_UniffiConverterUInt32.read(buf), + return TrezorSignedTx( + signatures=_UniffiConverterSequenceString.read(buf), + serialized_tx=_UniffiConverterString.read(buf), + txid=_UniffiConverterOptionalString.read(buf), ) @staticmethod def check_lower(value): - _UniffiConverterString.check_lower(value.txid) - _UniffiConverterUInt32.check_lower(value.vout) - _UniffiConverterString.check_lower(value.scriptsig) - _UniffiConverterSequenceString.check_lower(value.witness) - _UniffiConverterUInt32.check_lower(value.sequence) + _UniffiConverterSequenceString.check_lower(value.signatures) + _UniffiConverterString.check_lower(value.serialized_tx) + _UniffiConverterOptionalString.check_lower(value.txid) @staticmethod def write(value, buf): - _UniffiConverterString.write(value.txid, buf) - _UniffiConverterUInt32.write(value.vout, buf) - _UniffiConverterString.write(value.scriptsig, buf) - _UniffiConverterSequenceString.write(value.witness, buf) - _UniffiConverterUInt32.write(value.sequence, buf) - + _UniffiConverterSequenceString.write(value.signatures, buf) + _UniffiConverterString.write(value.serialized_tx, buf) + _UniffiConverterOptionalString.write(value.txid, buf) -class TxOutput: - """ - Details about a transaction output. - """ - scriptpubkey: "str" +class TrezorTransportReadResult: """ - The script public key (hex-encoded). + Result from a transport read operation """ - scriptpubkey_type: "typing.Optional[str]" + success: "bool" """ - The script public key type (e.g., "p2pkh", "p2sh", "p2wpkh", "p2wsh", "p2tr"). + Whether the read succeeded """ - scriptpubkey_address: "typing.Optional[str]" + data: "bytes" """ - The address corresponding to this script (if decodable). + Data read (empty on failure) """ - value: "int" + error: "str" """ - The value in satoshis. + Error message (empty on success) """ - n: "int" + error_code: "typing.Optional[TrezorTransportErrorCode]" """ - The output index in the transaction. + Structured error code (None on success or when the native error is generic) """ - def __init__(self, *, scriptpubkey: "str", scriptpubkey_type: "typing.Optional[str]", scriptpubkey_address: "typing.Optional[str]", value: "int", n: "int"): - self.scriptpubkey = scriptpubkey - self.scriptpubkey_type = scriptpubkey_type - self.scriptpubkey_address = scriptpubkey_address - self.value = value - self.n = n + def __init__(self, *, success: "bool", data: "bytes", error: "str", error_code: "typing.Optional[TrezorTransportErrorCode]"): + self.success = success + self.data = data + self.error = error + self.error_code = error_code def __str__(self): - return "TxOutput(scriptpubkey={}, scriptpubkey_type={}, scriptpubkey_address={}, value={}, n={})".format(self.scriptpubkey, self.scriptpubkey_type, self.scriptpubkey_address, self.value, self.n) + return "TrezorTransportReadResult(success={}, data={}, error={}, error_code={})".format(self.success, self.data, self.error, self.error_code) def __eq__(self, other): - if self.scriptpubkey != other.scriptpubkey: - return False - if self.scriptpubkey_type != other.scriptpubkey_type: + if self.success != other.success: return False - if self.scriptpubkey_address != other.scriptpubkey_address: + if self.data != other.data: return False - if self.value != other.value: + if self.error != other.error: return False - if self.n != other.n: + if self.error_code != other.error_code: return False return True -class _UniffiConverterTypeTxOutput(_UniffiConverterRustBuffer): +class _UniffiConverterTypeTrezorTransportReadResult(_UniffiConverterRustBuffer): @staticmethod def read(buf): - return TxOutput( - scriptpubkey=_UniffiConverterString.read(buf), - scriptpubkey_type=_UniffiConverterOptionalString.read(buf), - scriptpubkey_address=_UniffiConverterOptionalString.read(buf), - value=_UniffiConverterInt64.read(buf), - n=_UniffiConverterUInt32.read(buf), + return TrezorTransportReadResult( + success=_UniffiConverterBool.read(buf), + data=_UniffiConverterBytes.read(buf), + error=_UniffiConverterString.read(buf), + error_code=_UniffiConverterOptionalTypeTrezorTransportErrorCode.read(buf), ) @staticmethod def check_lower(value): - _UniffiConverterString.check_lower(value.scriptpubkey) - _UniffiConverterOptionalString.check_lower(value.scriptpubkey_type) - _UniffiConverterOptionalString.check_lower(value.scriptpubkey_address) - _UniffiConverterInt64.check_lower(value.value) - _UniffiConverterUInt32.check_lower(value.n) + _UniffiConverterBool.check_lower(value.success) + _UniffiConverterBytes.check_lower(value.data) + _UniffiConverterString.check_lower(value.error) + _UniffiConverterOptionalTypeTrezorTransportErrorCode.check_lower(value.error_code) @staticmethod def write(value, buf): - _UniffiConverterString.write(value.scriptpubkey, buf) - _UniffiConverterOptionalString.write(value.scriptpubkey_type, buf) - _UniffiConverterOptionalString.write(value.scriptpubkey_address, buf) - _UniffiConverterInt64.write(value.value, buf) - _UniffiConverterUInt32.write(value.n, buf) + _UniffiConverterBool.write(value.success, buf) + _UniffiConverterBytes.write(value.data, buf) + _UniffiConverterString.write(value.error, buf) + _UniffiConverterOptionalTypeTrezorTransportErrorCode.write(value.error_code, buf) -class UrDecoderStatus: +class TrezorTransportWriteResult: """ - Current state after accepting a scanned UR frame. + Result from a transport write or open operation """ - progress: "float" + success: "bool" """ - Estimated completion from 0.0 through 1.0. + Whether the operation succeeded """ - fragment_count: "int" + error: "str" """ - Fountain source-fragment count, or 1 for a single-part UR. + Error message (empty on success) """ - payload: "typing.Optional[UrPayload]" + error_code: "typing.Optional[TrezorTransportErrorCode]" """ - Present once the complete message has been decoded. + Structured error code (None on success or when the native error is generic) """ - def __init__(self, *, progress: "float", fragment_count: "int", payload: "typing.Optional[UrPayload]"): - self.progress = progress - self.fragment_count = fragment_count - self.payload = payload + def __init__(self, *, success: "bool", error: "str", error_code: "typing.Optional[TrezorTransportErrorCode]"): + self.success = success + self.error = error + self.error_code = error_code def __str__(self): - return "UrDecoderStatus(progress={}, fragment_count={}, payload={})".format(self.progress, self.fragment_count, self.payload) + return "TrezorTransportWriteResult(success={}, error={}, error_code={})".format(self.success, self.error, self.error_code) def __eq__(self, other): - if self.progress != other.progress: + if self.success != other.success: return False - if self.fragment_count != other.fragment_count: + if self.error != other.error: return False - if self.payload != other.payload: + if self.error_code != other.error_code: return False return True -class _UniffiConverterTypeUrDecoderStatus(_UniffiConverterRustBuffer): +class _UniffiConverterTypeTrezorTransportWriteResult(_UniffiConverterRustBuffer): @staticmethod def read(buf): - return UrDecoderStatus( - progress=_UniffiConverterDouble.read(buf), - fragment_count=_UniffiConverterUInt32.read(buf), - payload=_UniffiConverterOptionalTypeUrPayload.read(buf), + return TrezorTransportWriteResult( + success=_UniffiConverterBool.read(buf), + error=_UniffiConverterString.read(buf), + error_code=_UniffiConverterOptionalTypeTrezorTransportErrorCode.read(buf), ) @staticmethod def check_lower(value): - _UniffiConverterDouble.check_lower(value.progress) - _UniffiConverterUInt32.check_lower(value.fragment_count) - _UniffiConverterOptionalTypeUrPayload.check_lower(value.payload) + _UniffiConverterBool.check_lower(value.success) + _UniffiConverterString.check_lower(value.error) + _UniffiConverterOptionalTypeTrezorTransportErrorCode.check_lower(value.error_code) @staticmethod def write(value, buf): - _UniffiConverterDouble.write(value.progress, buf) - _UniffiConverterUInt32.write(value.fragment_count, buf) - _UniffiConverterOptionalTypeUrPayload.write(value.payload, buf) - - -class ValidationResult: - address: "str" - network: "NetworkType" - address_type: "AddressType" - def __init__(self, *, address: "str", network: "NetworkType", address_type: "AddressType"): - self.address = address - self.network = network - self.address_type = address_type - - def __str__(self): - return "ValidationResult(address={}, network={}, address_type={})".format(self.address, self.network, self.address_type) - - def __eq__(self, other): - if self.address != other.address: - return False - if self.network != other.network: - return False - if self.address_type != other.address_type: - return False - return True - -class _UniffiConverterTypeValidationResult(_UniffiConverterRustBuffer): - @staticmethod - def read(buf): - return ValidationResult( - address=_UniffiConverterString.read(buf), - network=_UniffiConverterTypeNetworkType.read(buf), - address_type=_UniffiConverterTypeAddressType.read(buf), - ) + _UniffiConverterBool.write(value.success, buf) + _UniffiConverterString.write(value.error, buf) + _UniffiConverterOptionalTypeTrezorTransportErrorCode.write(value.error_code, buf) - @staticmethod - def check_lower(value): - _UniffiConverterString.check_lower(value.address) - _UniffiConverterTypeNetworkType.check_lower(value.network) - _UniffiConverterTypeAddressType.check_lower(value.address_type) - @staticmethod - def write(value, buf): - _UniffiConverterString.write(value.address, buf) - _UniffiConverterTypeNetworkType.write(value.network, buf) - _UniffiConverterTypeAddressType.write(value.address_type, buf) +class TrezorTxInput: + """ + Transaction input for signing. + """ + prev_hash: "str" + """ + Previous transaction hash (hex, 32 bytes) + """ -class WalletBalance: + prev_index: "int" """ - Balance breakdown from BDK. + Previous output index """ - confirmed: "int" + path: "str" """ - Confirmed and spendable balance (sats) + BIP32 derivation path (e.g., "m/84'/0'/0'/0/0") """ - immature: "int" + amount: "int" """ - Immature coinbase outputs (sats) + Amount in satoshis """ - trusted_pending: "int" + script_type: "TrezorScriptType" """ - Unconfirmed UTXOs from trusted sources (own change) (sats) + Script type """ - untrusted_pending: "int" + sequence: "typing.Optional[int]" """ - Unconfirmed UTXOs from external sources (sats) + Sequence number (default: 0xFFFFFFFD for RBF) """ - spendable: "int" + orig_hash: "typing.Optional[str]" """ - Total spendable: confirmed + trusted_pending (sats) + Original transaction hash for RBF replacement (hex encoded) """ - total: "int" + orig_index: "typing.Optional[int]" """ - Grand total: all categories (sats) + Original input index for RBF replacement """ - def __init__(self, *, confirmed: "int", immature: "int", trusted_pending: "int", untrusted_pending: "int", spendable: "int", total: "int"): - self.confirmed = confirmed - self.immature = immature - self.trusted_pending = trusted_pending - self.untrusted_pending = untrusted_pending - self.spendable = spendable - self.total = total + def __init__(self, *, prev_hash: "str", prev_index: "int", path: "str", amount: "int", script_type: "TrezorScriptType", sequence: "typing.Optional[int]", orig_hash: "typing.Optional[str]", orig_index: "typing.Optional[int]"): + self.prev_hash = prev_hash + self.prev_index = prev_index + self.path = path + self.amount = amount + self.script_type = script_type + self.sequence = sequence + self.orig_hash = orig_hash + self.orig_index = orig_index def __str__(self): - return "WalletBalance(confirmed={}, immature={}, trusted_pending={}, untrusted_pending={}, spendable={}, total={})".format(self.confirmed, self.immature, self.trusted_pending, self.untrusted_pending, self.spendable, self.total) + return "TrezorTxInput(prev_hash={}, prev_index={}, path={}, amount={}, script_type={}, sequence={}, orig_hash={}, orig_index={})".format(self.prev_hash, self.prev_index, self.path, self.amount, self.script_type, self.sequence, self.orig_hash, self.orig_index) def __eq__(self, other): - if self.confirmed != other.confirmed: + if self.prev_hash != other.prev_hash: return False - if self.immature != other.immature: + if self.prev_index != other.prev_index: return False - if self.trusted_pending != other.trusted_pending: + if self.path != other.path: return False - if self.untrusted_pending != other.untrusted_pending: + if self.amount != other.amount: return False - if self.spendable != other.spendable: + if self.script_type != other.script_type: return False - if self.total != other.total: + if self.sequence != other.sequence: + return False + if self.orig_hash != other.orig_hash: + return False + if self.orig_index != other.orig_index: return False return True -class _UniffiConverterTypeWalletBalance(_UniffiConverterRustBuffer): +class _UniffiConverterTypeTrezorTxInput(_UniffiConverterRustBuffer): @staticmethod def read(buf): - return WalletBalance( - confirmed=_UniffiConverterUInt64.read(buf), - immature=_UniffiConverterUInt64.read(buf), - trusted_pending=_UniffiConverterUInt64.read(buf), - untrusted_pending=_UniffiConverterUInt64.read(buf), - spendable=_UniffiConverterUInt64.read(buf), - total=_UniffiConverterUInt64.read(buf), + return TrezorTxInput( + prev_hash=_UniffiConverterString.read(buf), + prev_index=_UniffiConverterUInt32.read(buf), + path=_UniffiConverterString.read(buf), + amount=_UniffiConverterUInt64.read(buf), + script_type=_UniffiConverterTypeTrezorScriptType.read(buf), + sequence=_UniffiConverterOptionalUInt32.read(buf), + orig_hash=_UniffiConverterOptionalString.read(buf), + orig_index=_UniffiConverterOptionalUInt32.read(buf), ) @staticmethod def check_lower(value): - _UniffiConverterUInt64.check_lower(value.confirmed) - _UniffiConverterUInt64.check_lower(value.immature) - _UniffiConverterUInt64.check_lower(value.trusted_pending) - _UniffiConverterUInt64.check_lower(value.untrusted_pending) - _UniffiConverterUInt64.check_lower(value.spendable) - _UniffiConverterUInt64.check_lower(value.total) + _UniffiConverterString.check_lower(value.prev_hash) + _UniffiConverterUInt32.check_lower(value.prev_index) + _UniffiConverterString.check_lower(value.path) + _UniffiConverterUInt64.check_lower(value.amount) + _UniffiConverterTypeTrezorScriptType.check_lower(value.script_type) + _UniffiConverterOptionalUInt32.check_lower(value.sequence) + _UniffiConverterOptionalString.check_lower(value.orig_hash) + _UniffiConverterOptionalUInt32.check_lower(value.orig_index) @staticmethod def write(value, buf): - _UniffiConverterUInt64.write(value.confirmed, buf) - _UniffiConverterUInt64.write(value.immature, buf) - _UniffiConverterUInt64.write(value.trusted_pending, buf) - _UniffiConverterUInt64.write(value.untrusted_pending, buf) - _UniffiConverterUInt64.write(value.spendable, buf) - _UniffiConverterUInt64.write(value.total, buf) + _UniffiConverterString.write(value.prev_hash, buf) + _UniffiConverterUInt32.write(value.prev_index, buf) + _UniffiConverterString.write(value.path, buf) + _UniffiConverterUInt64.write(value.amount, buf) + _UniffiConverterTypeTrezorScriptType.write(value.script_type, buf) + _UniffiConverterOptionalUInt32.write(value.sequence, buf) + _UniffiConverterOptionalString.write(value.orig_hash, buf) + _UniffiConverterOptionalUInt32.write(value.orig_index, buf) -class WalletParams: +class TrezorTxOutput: """ - Common parameters for creating and syncing a watch-only BDK wallet. + Transaction output for signing. """ - extended_key: "str" + address: "typing.Optional[str]" """ - Extended public key (xpub/ypub/zpub/tpub/upub/vpub) + Destination address (for external outputs) """ - electrum_url: "str" + path: "typing.Optional[str]" """ - Electrum server URL for wallet sync + BIP32 path (for change outputs) """ - fingerprint: "typing.Optional[str]" + amount: "int" """ - Root fingerprint hex (e.g. "73c5da0a"). Required for hardware wallet signing. + Amount in satoshis """ - network: "typing.Optional[Network]" + script_type: "typing.Optional[TrezorScriptType]" """ - Bitcoin network (auto-detected from key prefix if not specified) + Script type (for change outputs) """ - account_type: "typing.Optional[AccountType]" + op_return_data: "typing.Optional[str]" """ - Override account type for ambiguous key prefixes (xpub/tpub) + OP_RETURN data (hex encoded, for data outputs) """ - def __init__(self, *, extended_key: "str", electrum_url: "str", fingerprint: "typing.Optional[str]", network: "typing.Optional[Network]", account_type: "typing.Optional[AccountType]"): - self.extended_key = extended_key - self.electrum_url = electrum_url - self.fingerprint = fingerprint - self.network = network - self.account_type = account_type + orig_hash: "typing.Optional[str]" + """ + Original transaction hash for RBF replacement (hex encoded) + """ + + orig_index: "typing.Optional[int]" + """ + Original output index for RBF replacement + """ + + def __init__(self, *, address: "typing.Optional[str]", path: "typing.Optional[str]", amount: "int", script_type: "typing.Optional[TrezorScriptType]", op_return_data: "typing.Optional[str]", orig_hash: "typing.Optional[str]", orig_index: "typing.Optional[int]"): + self.address = address + self.path = path + self.amount = amount + self.script_type = script_type + self.op_return_data = op_return_data + self.orig_hash = orig_hash + self.orig_index = orig_index def __str__(self): - return "WalletParams(extended_key={}, electrum_url={}, fingerprint={}, network={}, account_type={})".format(self.extended_key, self.electrum_url, self.fingerprint, self.network, self.account_type) + return "TrezorTxOutput(address={}, path={}, amount={}, script_type={}, op_return_data={}, orig_hash={}, orig_index={})".format(self.address, self.path, self.amount, self.script_type, self.op_return_data, self.orig_hash, self.orig_index) def __eq__(self, other): - if self.extended_key != other.extended_key: + if self.address != other.address: return False - if self.electrum_url != other.electrum_url: + if self.path != other.path: return False - if self.fingerprint != other.fingerprint: + if self.amount != other.amount: return False - if self.network != other.network: + if self.script_type != other.script_type: return False - if self.account_type != other.account_type: + if self.op_return_data != other.op_return_data: + return False + if self.orig_hash != other.orig_hash: + return False + if self.orig_index != other.orig_index: return False return True -class _UniffiConverterTypeWalletParams(_UniffiConverterRustBuffer): +class _UniffiConverterTypeTrezorTxOutput(_UniffiConverterRustBuffer): @staticmethod def read(buf): - return WalletParams( - extended_key=_UniffiConverterString.read(buf), - electrum_url=_UniffiConverterString.read(buf), - fingerprint=_UniffiConverterOptionalString.read(buf), - network=_UniffiConverterOptionalTypeNetwork.read(buf), - account_type=_UniffiConverterOptionalTypeAccountType.read(buf), + return TrezorTxOutput( + address=_UniffiConverterOptionalString.read(buf), + path=_UniffiConverterOptionalString.read(buf), + amount=_UniffiConverterUInt64.read(buf), + script_type=_UniffiConverterOptionalTypeTrezorScriptType.read(buf), + op_return_data=_UniffiConverterOptionalString.read(buf), + orig_hash=_UniffiConverterOptionalString.read(buf), + orig_index=_UniffiConverterOptionalUInt32.read(buf), ) @staticmethod def check_lower(value): - _UniffiConverterString.check_lower(value.extended_key) - _UniffiConverterString.check_lower(value.electrum_url) - _UniffiConverterOptionalString.check_lower(value.fingerprint) - _UniffiConverterOptionalTypeNetwork.check_lower(value.network) - _UniffiConverterOptionalTypeAccountType.check_lower(value.account_type) + _UniffiConverterOptionalString.check_lower(value.address) + _UniffiConverterOptionalString.check_lower(value.path) + _UniffiConverterUInt64.check_lower(value.amount) + _UniffiConverterOptionalTypeTrezorScriptType.check_lower(value.script_type) + _UniffiConverterOptionalString.check_lower(value.op_return_data) + _UniffiConverterOptionalString.check_lower(value.orig_hash) + _UniffiConverterOptionalUInt32.check_lower(value.orig_index) @staticmethod def write(value, buf): - _UniffiConverterString.write(value.extended_key, buf) - _UniffiConverterString.write(value.electrum_url, buf) - _UniffiConverterOptionalString.write(value.fingerprint, buf) - _UniffiConverterOptionalTypeNetwork.write(value.network, buf) - _UniffiConverterOptionalTypeAccountType.write(value.account_type, buf) - - -class WatcherParams: - """ - Parameters for starting an xpub transaction watcher. - """ - - watcher_id: "str" - """ - Caller-supplied identifier for this watcher. - """ + _UniffiConverterOptionalString.write(value.address, buf) + _UniffiConverterOptionalString.write(value.path, buf) + _UniffiConverterUInt64.write(value.amount, buf) + _UniffiConverterOptionalTypeTrezorScriptType.write(value.script_type, buf) + _UniffiConverterOptionalString.write(value.op_return_data, buf) + _UniffiConverterOptionalString.write(value.orig_hash, buf) + _UniffiConverterOptionalUInt32.write(value.orig_index, buf) - wallet_id: "str" - """ - Wallet id that scopes the activities this watcher emits. Apps may use - one wallet id for several account watchers and merge their snapshots. - """ - extended_key: "str" +class TrezorVerifyMessageParams: """ - Extended public key (xpub/ypub/zpub/tpub/upub/vpub). + Parameters for verifying a message signature. """ - electrum_url: "str" + address: "str" """ - Electrum server URL (e.g. "ssl://electrum.example.com:50002"). + Bitcoin address that signed the message """ - network: "typing.Optional[Network]" + signature: "str" """ - Bitcoin network override (auto-detected from key prefix if None). + Signature (base64 encoded) """ - account_type: "typing.Optional[AccountType]" + message: "str" """ - Account type override (auto-detected from key prefix if None). + Original message """ - gap_limit: "typing.Optional[int]" + coin: "typing.Optional[TrezorCoinType]" """ - Number of unused addresses to monitor beyond the last used - (defaults to `DEFAULT_GAP_LIMIT` when None). + Coin network (default: Bitcoin) """ - def __init__(self, *, watcher_id: "str", wallet_id: "str", extended_key: "str", electrum_url: "str", network: "typing.Optional[Network]", account_type: "typing.Optional[AccountType]", gap_limit: "typing.Optional[int]"): - self.watcher_id = watcher_id - self.wallet_id = wallet_id - self.extended_key = extended_key - self.electrum_url = electrum_url - self.network = network - self.account_type = account_type - self.gap_limit = gap_limit + def __init__(self, *, address: "str", signature: "str", message: "str", coin: "typing.Optional[TrezorCoinType]"): + self.address = address + self.signature = signature + self.message = message + self.coin = coin def __str__(self): - return "WatcherParams(watcher_id={}, wallet_id={}, extended_key={}, electrum_url={}, network={}, account_type={}, gap_limit={})".format(self.watcher_id, self.wallet_id, self.extended_key, self.electrum_url, self.network, self.account_type, self.gap_limit) + return "TrezorVerifyMessageParams(address={}, signature={}, message={}, coin={})".format(self.address, self.signature, self.message, self.coin) def __eq__(self, other): - if self.watcher_id != other.watcher_id: - return False - if self.wallet_id != other.wallet_id: - return False - if self.extended_key != other.extended_key: - return False - if self.electrum_url != other.electrum_url: + if self.address != other.address: return False - if self.network != other.network: + if self.signature != other.signature: return False - if self.account_type != other.account_type: + if self.message != other.message: return False - if self.gap_limit != other.gap_limit: + if self.coin != other.coin: return False return True -class _UniffiConverterTypeWatcherParams(_UniffiConverterRustBuffer): +class _UniffiConverterTypeTrezorVerifyMessageParams(_UniffiConverterRustBuffer): @staticmethod def read(buf): - return WatcherParams( - watcher_id=_UniffiConverterString.read(buf), - wallet_id=_UniffiConverterString.read(buf), - extended_key=_UniffiConverterString.read(buf), - electrum_url=_UniffiConverterString.read(buf), - network=_UniffiConverterOptionalTypeNetwork.read(buf), - account_type=_UniffiConverterOptionalTypeAccountType.read(buf), - gap_limit=_UniffiConverterOptionalUInt32.read(buf), + return TrezorVerifyMessageParams( + address=_UniffiConverterString.read(buf), + signature=_UniffiConverterString.read(buf), + message=_UniffiConverterString.read(buf), + coin=_UniffiConverterOptionalTypeTrezorCoinType.read(buf), ) @staticmethod def check_lower(value): - _UniffiConverterString.check_lower(value.watcher_id) - _UniffiConverterString.check_lower(value.wallet_id) - _UniffiConverterString.check_lower(value.extended_key) - _UniffiConverterString.check_lower(value.electrum_url) - _UniffiConverterOptionalTypeNetwork.check_lower(value.network) - _UniffiConverterOptionalTypeAccountType.check_lower(value.account_type) - _UniffiConverterOptionalUInt32.check_lower(value.gap_limit) + _UniffiConverterString.check_lower(value.address) + _UniffiConverterString.check_lower(value.signature) + _UniffiConverterString.check_lower(value.message) + _UniffiConverterOptionalTypeTrezorCoinType.check_lower(value.coin) @staticmethod def write(value, buf): - _UniffiConverterString.write(value.watcher_id, buf) - _UniffiConverterString.write(value.wallet_id, buf) - _UniffiConverterString.write(value.extended_key, buf) - _UniffiConverterString.write(value.electrum_url, buf) - _UniffiConverterOptionalTypeNetwork.write(value.network, buf) - _UniffiConverterOptionalTypeAccountType.write(value.account_type, buf) - _UniffiConverterOptionalUInt32.write(value.gap_limit, buf) + _UniffiConverterString.write(value.address, buf) + _UniffiConverterString.write(value.signature, buf) + _UniffiConverterString.write(value.message, buf) + _UniffiConverterOptionalTypeTrezorCoinType.write(value.coin, buf) -# AccountInfoError -# We want to define each variant as a nested class that's also a subclass, -# which is tricky in Python. To accomplish this we're going to create each -# class separately, then manually add the child classes to the base class's -# __dict__. All of this happens in dummy class to avoid polluting the module -# namespace. -class AccountInfoError(Exception): +class TxDetailInput: """ - Errors specific to account info operations (BDK/Electrum-based). + A transaction input with full details. """ - pass + txid: "str" + """ + Previous output transaction ID (hex) + """ -_UniffiTempAccountInfoError = AccountInfoError + vout: "int" + """ + Previous output index + """ -class AccountInfoError: # type: ignore + sequence: "int" """ - Errors specific to account info operations (BDK/Electrum-based). + Sequence number """ - class InvalidExtendedKey(_UniffiTempAccountInfoError): - """ - The provided extended public key is invalid or cannot be parsed - """ + script_sig: "str" + """ + Script signature (hex-encoded) + """ - def __init__(self, error_details): - super().__init__(", ".join([ - "error_details={!r}".format(error_details), - ])) - self.error_details = error_details + witness: "typing.List[str]" + """ + Witness stack (each element hex-encoded) + """ - def __repr__(self): - return "AccountInfoError.InvalidExtendedKey({})".format(str(self)) - _UniffiTempAccountInfoError.InvalidExtendedKey = InvalidExtendedKey # type: ignore - class InvalidAddress(_UniffiTempAccountInfoError): - """ - The provided address is invalid - """ + def __init__(self, *, txid: "str", vout: "int", sequence: "int", script_sig: "str", witness: "typing.List[str]"): + self.txid = txid + self.vout = vout + self.sequence = sequence + self.script_sig = script_sig + self.witness = witness - def __init__(self, error_details): - super().__init__(", ".join([ - "error_details={!r}".format(error_details), - ])) - self.error_details = error_details + def __str__(self): + return "TxDetailInput(txid={}, vout={}, sequence={}, script_sig={}, witness={})".format(self.txid, self.vout, self.sequence, self.script_sig, self.witness) - def __repr__(self): - return "AccountInfoError.InvalidAddress({})".format(str(self)) - _UniffiTempAccountInfoError.InvalidAddress = InvalidAddress # type: ignore - class ElectrumError(_UniffiTempAccountInfoError): - """ - Electrum connection or query failed - """ + def __eq__(self, other): + if self.txid != other.txid: + return False + if self.vout != other.vout: + return False + if self.sequence != other.sequence: + return False + if self.script_sig != other.script_sig: + return False + if self.witness != other.witness: + return False + return True - def __init__(self, error_details): - super().__init__(", ".join([ - "error_details={!r}".format(error_details), - ])) - self.error_details = error_details +class _UniffiConverterTypeTxDetailInput(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + return TxDetailInput( + txid=_UniffiConverterString.read(buf), + vout=_UniffiConverterUInt32.read(buf), + sequence=_UniffiConverterUInt32.read(buf), + script_sig=_UniffiConverterString.read(buf), + witness=_UniffiConverterSequenceString.read(buf), + ) - def __repr__(self): - return "AccountInfoError.ElectrumError({})".format(str(self)) - _UniffiTempAccountInfoError.ElectrumError = ElectrumError # type: ignore - class WalletError(_UniffiTempAccountInfoError): - """ - BDK wallet creation or operation error - """ + @staticmethod + def check_lower(value): + _UniffiConverterString.check_lower(value.txid) + _UniffiConverterUInt32.check_lower(value.vout) + _UniffiConverterUInt32.check_lower(value.sequence) + _UniffiConverterString.check_lower(value.script_sig) + _UniffiConverterSequenceString.check_lower(value.witness) - def __init__(self, error_details): - super().__init__(", ".join([ - "error_details={!r}".format(error_details), - ])) - self.error_details = error_details + @staticmethod + def write(value, buf): + _UniffiConverterString.write(value.txid, buf) + _UniffiConverterUInt32.write(value.vout, buf) + _UniffiConverterUInt32.write(value.sequence, buf) + _UniffiConverterString.write(value.script_sig, buf) + _UniffiConverterSequenceString.write(value.witness, buf) - def __repr__(self): - return "AccountInfoError.WalletError({})".format(str(self)) - _UniffiTempAccountInfoError.WalletError = WalletError # type: ignore - class SyncError(_UniffiTempAccountInfoError): - """ - Wallet sync with Electrum failed - """ - def __init__(self, error_details): - super().__init__(", ".join([ - "error_details={!r}".format(error_details), - ])) - self.error_details = error_details +class TxDetailOutput: + """ + A transaction output with full details. + """ - def __repr__(self): - return "AccountInfoError.SyncError({})".format(str(self)) - _UniffiTempAccountInfoError.SyncError = SyncError # type: ignore - class UnsupportedKeyType(_UniffiTempAccountInfoError): - """ - The key type/prefix is not recognized - """ + value: "int" + """ + Output value in sats + """ - def __init__(self, error_details): - super().__init__(", ".join([ - "error_details={!r}".format(error_details), - ])) - self.error_details = error_details + script_pubkey: "str" + """ + Script public key (hex-encoded) + """ - def __repr__(self): - return "AccountInfoError.UnsupportedKeyType({})".format(str(self)) - _UniffiTempAccountInfoError.UnsupportedKeyType = UnsupportedKeyType # type: ignore - class NetworkMismatch(_UniffiTempAccountInfoError): - """ - Network mismatch between key prefix and specified network - """ + address: "typing.Optional[str]" + """ + Decoded address (None if script is not decodable to an address) + """ - def __init__(self, error_details): - super().__init__(", ".join([ - "error_details={!r}".format(error_details), - ])) - self.error_details = error_details + is_mine: "bool" + """ + Whether this output belongs to the queried wallet + """ - def __repr__(self): - return "AccountInfoError.NetworkMismatch({})".format(str(self)) - _UniffiTempAccountInfoError.NetworkMismatch = NetworkMismatch # type: ignore - class InvalidTxid(_UniffiTempAccountInfoError): - """ - Invalid transaction ID provided - """ + def __init__(self, *, value: "int", script_pubkey: "str", address: "typing.Optional[str]", is_mine: "bool"): + self.value = value + self.script_pubkey = script_pubkey + self.address = address + self.is_mine = is_mine - def __init__(self, error_details): - super().__init__(", ".join([ - "error_details={!r}".format(error_details), - ])) - self.error_details = error_details + def __str__(self): + return "TxDetailOutput(value={}, script_pubkey={}, address={}, is_mine={})".format(self.value, self.script_pubkey, self.address, self.is_mine) - def __repr__(self): - return "AccountInfoError.InvalidTxid({})".format(str(self)) - _UniffiTempAccountInfoError.InvalidTxid = InvalidTxid # type: ignore - class TransactionNotFound(_UniffiTempAccountInfoError): - """ - A valid transaction ID was not found in the wallet - """ + def __eq__(self, other): + if self.value != other.value: + return False + if self.script_pubkey != other.script_pubkey: + return False + if self.address != other.address: + return False + if self.is_mine != other.is_mine: + return False + return True - def __init__(self, error_details): - super().__init__(", ".join([ - "error_details={!r}".format(error_details), - ])) - self.error_details = error_details +class _UniffiConverterTypeTxDetailOutput(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + return TxDetailOutput( + value=_UniffiConverterUInt64.read(buf), + script_pubkey=_UniffiConverterString.read(buf), + address=_UniffiConverterOptionalString.read(buf), + is_mine=_UniffiConverterBool.read(buf), + ) - def __repr__(self): - return "AccountInfoError.TransactionNotFound({})".format(str(self)) - _UniffiTempAccountInfoError.TransactionNotFound = TransactionNotFound # type: ignore - class WatcherError(_UniffiTempAccountInfoError): - """ - Watcher lifecycle or subscription error - """ - - def __init__(self, error_details): - super().__init__(", ".join([ - "error_details={!r}".format(error_details), - ])) - self.error_details = error_details - - def __repr__(self): - return "AccountInfoError.WatcherError({})".format(str(self)) - _UniffiTempAccountInfoError.WatcherError = WatcherError # type: ignore - -AccountInfoError = _UniffiTempAccountInfoError # type: ignore -del _UniffiTempAccountInfoError - - -class _UniffiConverterTypeAccountInfoError(_UniffiConverterRustBuffer): - @staticmethod - def read(buf): - variant = buf.read_i32() - if variant == 1: - return AccountInfoError.InvalidExtendedKey( - _UniffiConverterString.read(buf), - ) - if variant == 2: - return AccountInfoError.InvalidAddress( - _UniffiConverterString.read(buf), - ) - if variant == 3: - return AccountInfoError.ElectrumError( - _UniffiConverterString.read(buf), - ) - if variant == 4: - return AccountInfoError.WalletError( - _UniffiConverterString.read(buf), - ) - if variant == 5: - return AccountInfoError.SyncError( - _UniffiConverterString.read(buf), - ) - if variant == 6: - return AccountInfoError.UnsupportedKeyType( - _UniffiConverterString.read(buf), - ) - if variant == 7: - return AccountInfoError.NetworkMismatch( - _UniffiConverterString.read(buf), - ) - if variant == 8: - return AccountInfoError.InvalidTxid( - _UniffiConverterString.read(buf), - ) - if variant == 9: - return AccountInfoError.TransactionNotFound( - _UniffiConverterString.read(buf), - ) - if variant == 10: - return AccountInfoError.WatcherError( - _UniffiConverterString.read(buf), - ) - raise InternalError("Raw enum value doesn't match any cases") - - @staticmethod - def check_lower(value): - if isinstance(value, AccountInfoError.InvalidExtendedKey): - _UniffiConverterString.check_lower(value.error_details) - return - if isinstance(value, AccountInfoError.InvalidAddress): - _UniffiConverterString.check_lower(value.error_details) - return - if isinstance(value, AccountInfoError.ElectrumError): - _UniffiConverterString.check_lower(value.error_details) - return - if isinstance(value, AccountInfoError.WalletError): - _UniffiConverterString.check_lower(value.error_details) - return - if isinstance(value, AccountInfoError.SyncError): - _UniffiConverterString.check_lower(value.error_details) - return - if isinstance(value, AccountInfoError.UnsupportedKeyType): - _UniffiConverterString.check_lower(value.error_details) - return - if isinstance(value, AccountInfoError.NetworkMismatch): - _UniffiConverterString.check_lower(value.error_details) - return - if isinstance(value, AccountInfoError.InvalidTxid): - _UniffiConverterString.check_lower(value.error_details) - return - if isinstance(value, AccountInfoError.TransactionNotFound): - _UniffiConverterString.check_lower(value.error_details) - return - if isinstance(value, AccountInfoError.WatcherError): - _UniffiConverterString.check_lower(value.error_details) - return + @staticmethod + def check_lower(value): + _UniffiConverterUInt64.check_lower(value.value) + _UniffiConverterString.check_lower(value.script_pubkey) + _UniffiConverterOptionalString.check_lower(value.address) + _UniffiConverterBool.check_lower(value.is_mine) @staticmethod def write(value, buf): - if isinstance(value, AccountInfoError.InvalidExtendedKey): - buf.write_i32(1) - _UniffiConverterString.write(value.error_details, buf) - if isinstance(value, AccountInfoError.InvalidAddress): - buf.write_i32(2) - _UniffiConverterString.write(value.error_details, buf) - if isinstance(value, AccountInfoError.ElectrumError): - buf.write_i32(3) - _UniffiConverterString.write(value.error_details, buf) - if isinstance(value, AccountInfoError.WalletError): - buf.write_i32(4) - _UniffiConverterString.write(value.error_details, buf) - if isinstance(value, AccountInfoError.SyncError): - buf.write_i32(5) - _UniffiConverterString.write(value.error_details, buf) - if isinstance(value, AccountInfoError.UnsupportedKeyType): - buf.write_i32(6) - _UniffiConverterString.write(value.error_details, buf) - if isinstance(value, AccountInfoError.NetworkMismatch): - buf.write_i32(7) - _UniffiConverterString.write(value.error_details, buf) - if isinstance(value, AccountInfoError.InvalidTxid): - buf.write_i32(8) - _UniffiConverterString.write(value.error_details, buf) - if isinstance(value, AccountInfoError.TransactionNotFound): - buf.write_i32(9) - _UniffiConverterString.write(value.error_details, buf) - if isinstance(value, AccountInfoError.WatcherError): - buf.write_i32(10) - _UniffiConverterString.write(value.error_details, buf) - - - + _UniffiConverterUInt64.write(value.value, buf) + _UniffiConverterString.write(value.script_pubkey, buf) + _UniffiConverterOptionalString.write(value.address, buf) + _UniffiConverterBool.write(value.is_mine, buf) -class AccountType(enum.Enum): +class TxInput: + """ + Details about a transaction input. """ - Account type classification for extended public keys. - Determines the BIP standard, derivation path purpose, and script type. + txid: "str" + """ + The transaction ID of the previous output being spent. """ - LEGACY = 0 + vout: "int" """ - BIP44 legacy (P2PKH) — xpub/tpub prefix + The output index of the previous output being spent. """ - - WRAPPED_SEGWIT = 1 + scriptsig: "str" """ - BIP49 wrapped segwit (P2SH-P2WPKH) — ypub/upub prefix + The script signature (hex-encoded). """ - - NATIVE_SEGWIT = 2 + witness: "typing.List[str]" """ - BIP84 native segwit (P2WPKH) — zpub/vpub prefix + The witness stack (hex-encoded strings). """ - - TAPROOT = 3 + sequence: "int" """ - BIP86 taproot (P2TR) + The sequence number. """ - + def __init__(self, *, txid: "str", vout: "int", scriptsig: "str", witness: "typing.List[str]", sequence: "int"): + self.txid = txid + self.vout = vout + self.scriptsig = scriptsig + self.witness = witness + self.sequence = sequence + def __str__(self): + return "TxInput(txid={}, vout={}, scriptsig={}, witness={}, sequence={})".format(self.txid, self.vout, self.scriptsig, self.witness, self.sequence) -class _UniffiConverterTypeAccountType(_UniffiConverterRustBuffer): + def __eq__(self, other): + if self.txid != other.txid: + return False + if self.vout != other.vout: + return False + if self.scriptsig != other.scriptsig: + return False + if self.witness != other.witness: + return False + if self.sequence != other.sequence: + return False + return True + +class _UniffiConverterTypeTxInput(_UniffiConverterRustBuffer): @staticmethod def read(buf): - variant = buf.read_i32() - if variant == 1: - return AccountType.LEGACY - if variant == 2: - return AccountType.WRAPPED_SEGWIT - if variant == 3: - return AccountType.NATIVE_SEGWIT - if variant == 4: - return AccountType.TAPROOT - raise InternalError("Raw enum value doesn't match any cases") + return TxInput( + txid=_UniffiConverterString.read(buf), + vout=_UniffiConverterUInt32.read(buf), + scriptsig=_UniffiConverterString.read(buf), + witness=_UniffiConverterSequenceString.read(buf), + sequence=_UniffiConverterUInt32.read(buf), + ) @staticmethod def check_lower(value): - if value == AccountType.LEGACY: - return - if value == AccountType.WRAPPED_SEGWIT: - return - if value == AccountType.NATIVE_SEGWIT: - return - if value == AccountType.TAPROOT: - return - raise ValueError(value) + _UniffiConverterString.check_lower(value.txid) + _UniffiConverterUInt32.check_lower(value.vout) + _UniffiConverterString.check_lower(value.scriptsig) + _UniffiConverterSequenceString.check_lower(value.witness) + _UniffiConverterUInt32.check_lower(value.sequence) @staticmethod def write(value, buf): - if value == AccountType.LEGACY: - buf.write_i32(1) - if value == AccountType.WRAPPED_SEGWIT: - buf.write_i32(2) - if value == AccountType.NATIVE_SEGWIT: - buf.write_i32(3) - if value == AccountType.TAPROOT: - buf.write_i32(4) + _UniffiConverterString.write(value.txid, buf) + _UniffiConverterUInt32.write(value.vout, buf) + _UniffiConverterString.write(value.scriptsig, buf) + _UniffiConverterSequenceString.write(value.witness, buf) + _UniffiConverterUInt32.write(value.sequence, buf) +class TxOutput: + """ + Details about a transaction output. + """ + scriptpubkey: "str" + """ + The script public key (hex-encoded). + """ + scriptpubkey_type: "typing.Optional[str]" + """ + The script public key type (e.g., "p2pkh", "p2sh", "p2wpkh", "p2wsh", "p2tr"). + """ + scriptpubkey_address: "typing.Optional[str]" + """ + The address corresponding to this script (if decodable). + """ + value: "int" + """ + The value in satoshis. + """ -class Activity: - def __init__(self): - raise RuntimeError("Activity cannot be instantiated directly") + n: "int" + """ + The output index in the transaction. + """ - # Each enum variant is a nested class of the enum itself. - class ONCHAIN: - def __init__(self, *values): - if len(values) != 1: - raise TypeError(f"Expected 1 arguments, found {len(values)}") - self._values = values + def __init__(self, *, scriptpubkey: "str", scriptpubkey_type: "typing.Optional[str]", scriptpubkey_address: "typing.Optional[str]", value: "int", n: "int"): + self.scriptpubkey = scriptpubkey + self.scriptpubkey_type = scriptpubkey_type + self.scriptpubkey_address = scriptpubkey_address + self.value = value + self.n = n - def __getitem__(self, index): - return self._values[index] + def __str__(self): + return "TxOutput(scriptpubkey={}, scriptpubkey_type={}, scriptpubkey_address={}, value={}, n={})".format(self.scriptpubkey, self.scriptpubkey_type, self.scriptpubkey_address, self.value, self.n) - def __str__(self): - return f"Activity.ONCHAIN{self._values!r}" + def __eq__(self, other): + if self.scriptpubkey != other.scriptpubkey: + return False + if self.scriptpubkey_type != other.scriptpubkey_type: + return False + if self.scriptpubkey_address != other.scriptpubkey_address: + return False + if self.value != other.value: + return False + if self.n != other.n: + return False + return True - def __eq__(self, other): - if not other.is_ONCHAIN(): - return False - return self._values == other._values - class LIGHTNING: - def __init__(self, *values): - if len(values) != 1: - raise TypeError(f"Expected 1 arguments, found {len(values)}") - self._values = values +class _UniffiConverterTypeTxOutput(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + return TxOutput( + scriptpubkey=_UniffiConverterString.read(buf), + scriptpubkey_type=_UniffiConverterOptionalString.read(buf), + scriptpubkey_address=_UniffiConverterOptionalString.read(buf), + value=_UniffiConverterInt64.read(buf), + n=_UniffiConverterUInt32.read(buf), + ) - def __getitem__(self, index): - return self._values[index] + @staticmethod + def check_lower(value): + _UniffiConverterString.check_lower(value.scriptpubkey) + _UniffiConverterOptionalString.check_lower(value.scriptpubkey_type) + _UniffiConverterOptionalString.check_lower(value.scriptpubkey_address) + _UniffiConverterInt64.check_lower(value.value) + _UniffiConverterUInt32.check_lower(value.n) - def __str__(self): - return f"Activity.LIGHTNING{self._values!r}" + @staticmethod + def write(value, buf): + _UniffiConverterString.write(value.scriptpubkey, buf) + _UniffiConverterOptionalString.write(value.scriptpubkey_type, buf) + _UniffiConverterOptionalString.write(value.scriptpubkey_address, buf) + _UniffiConverterInt64.write(value.value, buf) + _UniffiConverterUInt32.write(value.n, buf) - def __eq__(self, other): - if not other.is_LIGHTNING(): - return False - return self._values == other._values - - # For each variant, we have `is_NAME` and `is_name` methods for easily checking - # whether an instance is that variant. - def is_ONCHAIN(self) -> bool: - return isinstance(self, Activity.ONCHAIN) - def is_onchain(self) -> bool: - return isinstance(self, Activity.ONCHAIN) - def is_LIGHTNING(self) -> bool: - return isinstance(self, Activity.LIGHTNING) - def is_lightning(self) -> bool: - return isinstance(self, Activity.LIGHTNING) - +class UrDecoderStatus: + """ + Current state after accepting a scanned UR frame. + """ -# Now, a little trick - we make each nested variant class be a subclass of the main -# enum class, so that method calls and instance checks etc will work intuitively. -# We might be able to do this a little more neatly with a metaclass, but this'll do. -Activity.ONCHAIN = type("Activity.ONCHAIN", (Activity.ONCHAIN, Activity,), {}) # type: ignore -Activity.LIGHTNING = type("Activity.LIGHTNING", (Activity.LIGHTNING, Activity,), {}) # type: ignore + progress: "float" + """ + Estimated completion from 0.0 through 1.0. + """ + + fragment_count: "int" + """ + Fountain source-fragment count, or 1 for a single-part UR. + """ + payload: "typing.Optional[UrPayload]" + """ + Present once the complete message has been decoded. + """ + def __init__(self, *, progress: "float", fragment_count: "int", payload: "typing.Optional[UrPayload]"): + self.progress = progress + self.fragment_count = fragment_count + self.payload = payload + def __str__(self): + return "UrDecoderStatus(progress={}, fragment_count={}, payload={})".format(self.progress, self.fragment_count, self.payload) -class _UniffiConverterTypeActivity(_UniffiConverterRustBuffer): + def __eq__(self, other): + if self.progress != other.progress: + return False + if self.fragment_count != other.fragment_count: + return False + if self.payload != other.payload: + return False + return True + +class _UniffiConverterTypeUrDecoderStatus(_UniffiConverterRustBuffer): @staticmethod def read(buf): - variant = buf.read_i32() - if variant == 1: - return Activity.ONCHAIN( - _UniffiConverterTypeOnchainActivity.read(buf), - ) - if variant == 2: - return Activity.LIGHTNING( - _UniffiConverterTypeLightningActivity.read(buf), - ) - raise InternalError("Raw enum value doesn't match any cases") + return UrDecoderStatus( + progress=_UniffiConverterDouble.read(buf), + fragment_count=_UniffiConverterUInt32.read(buf), + payload=_UniffiConverterOptionalTypeUrPayload.read(buf), + ) @staticmethod def check_lower(value): - if value.is_ONCHAIN(): - _UniffiConverterTypeOnchainActivity.check_lower(value._values[0]) - return - if value.is_LIGHTNING(): - _UniffiConverterTypeLightningActivity.check_lower(value._values[0]) - return - raise ValueError(value) + _UniffiConverterDouble.check_lower(value.progress) + _UniffiConverterUInt32.check_lower(value.fragment_count) + _UniffiConverterOptionalTypeUrPayload.check_lower(value.payload) @staticmethod def write(value, buf): - if value.is_ONCHAIN(): - buf.write_i32(1) - _UniffiConverterTypeOnchainActivity.write(value._values[0], buf) - if value.is_LIGHTNING(): - buf.write_i32(2) - _UniffiConverterTypeLightningActivity.write(value._values[0], buf) + _UniffiConverterDouble.write(value.progress, buf) + _UniffiConverterUInt32.write(value.fragment_count, buf) + _UniffiConverterOptionalTypeUrPayload.write(value.payload, buf) +class ValidationResult: + address: "str" + network: "NetworkType" + address_type: "AddressType" + def __init__(self, *, address: "str", network: "NetworkType", address_type: "AddressType"): + self.address = address + self.network = network + self.address_type = address_type + def __str__(self): + return "ValidationResult(address={}, network={}, address_type={})".format(self.address, self.network, self.address_type) -# ActivityError -# We want to define each variant as a nested class that's also a subclass, -# which is tricky in Python. To accomplish this we're going to create each -# class separately, then manually add the child classes to the base class's -# __dict__. All of this happens in dummy class to avoid polluting the module -# namespace. -class ActivityError(Exception): - pass + def __eq__(self, other): + if self.address != other.address: + return False + if self.network != other.network: + return False + if self.address_type != other.address_type: + return False + return True -_UniffiTempActivityError = ActivityError +class _UniffiConverterTypeValidationResult(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + return ValidationResult( + address=_UniffiConverterString.read(buf), + network=_UniffiConverterTypeNetworkType.read(buf), + address_type=_UniffiConverterTypeAddressType.read(buf), + ) -class ActivityError: # type: ignore - class InvalidActivity(_UniffiTempActivityError): - def __init__(self, error_details): - super().__init__(", ".join([ - "error_details={!r}".format(error_details), - ])) - self.error_details = error_details + @staticmethod + def check_lower(value): + _UniffiConverterString.check_lower(value.address) + _UniffiConverterTypeNetworkType.check_lower(value.network) + _UniffiConverterTypeAddressType.check_lower(value.address_type) - def __repr__(self): - return "ActivityError.InvalidActivity({})".format(str(self)) - _UniffiTempActivityError.InvalidActivity = InvalidActivity # type: ignore - class InitializationError(_UniffiTempActivityError): - def __init__(self, error_details): - super().__init__(", ".join([ - "error_details={!r}".format(error_details), - ])) - self.error_details = error_details + @staticmethod + def write(value, buf): + _UniffiConverterString.write(value.address, buf) + _UniffiConverterTypeNetworkType.write(value.network, buf) + _UniffiConverterTypeAddressType.write(value.address_type, buf) - def __repr__(self): - return "ActivityError.InitializationError({})".format(str(self)) - _UniffiTempActivityError.InitializationError = InitializationError # type: ignore - class InsertError(_UniffiTempActivityError): - def __init__(self, error_details): - super().__init__(", ".join([ - "error_details={!r}".format(error_details), - ])) - self.error_details = error_details - def __repr__(self): - return "ActivityError.InsertError({})".format(str(self)) - _UniffiTempActivityError.InsertError = InsertError # type: ignore - class RetrievalError(_UniffiTempActivityError): - def __init__(self, error_details): - super().__init__(", ".join([ - "error_details={!r}".format(error_details), - ])) - self.error_details = error_details +class WalletBalance: + """ + Balance breakdown from BDK. + """ - def __repr__(self): - return "ActivityError.RetrievalError({})".format(str(self)) - _UniffiTempActivityError.RetrievalError = RetrievalError # type: ignore - class DataError(_UniffiTempActivityError): - def __init__(self, error_details): - super().__init__(", ".join([ - "error_details={!r}".format(error_details), - ])) - self.error_details = error_details + confirmed: "int" + """ + Confirmed and spendable balance (sats) + """ - def __repr__(self): - return "ActivityError.DataError({})".format(str(self)) - _UniffiTempActivityError.DataError = DataError # type: ignore - class ConnectionError(_UniffiTempActivityError): - def __init__(self, error_details): - super().__init__(", ".join([ - "error_details={!r}".format(error_details), - ])) - self.error_details = error_details + immature: "int" + """ + Immature coinbase outputs (sats) + """ - def __repr__(self): - return "ActivityError.ConnectionError({})".format(str(self)) - _UniffiTempActivityError.ConnectionError = ConnectionError # type: ignore - class SerializationError(_UniffiTempActivityError): - def __init__(self, error_details): - super().__init__(", ".join([ - "error_details={!r}".format(error_details), - ])) - self.error_details = error_details + trusted_pending: "int" + """ + Unconfirmed UTXOs from trusted sources (own change) (sats) + """ - def __repr__(self): - return "ActivityError.SerializationError({})".format(str(self)) - _UniffiTempActivityError.SerializationError = SerializationError # type: ignore + untrusted_pending: "int" + """ + Unconfirmed UTXOs from external sources (sats) + """ -ActivityError = _UniffiTempActivityError # type: ignore -del _UniffiTempActivityError + spendable: "int" + """ + Total spendable: confirmed + trusted_pending (sats) + """ + + total: "int" + """ + Grand total: all categories (sats) + """ + + def __init__(self, *, confirmed: "int", immature: "int", trusted_pending: "int", untrusted_pending: "int", spendable: "int", total: "int"): + self.confirmed = confirmed + self.immature = immature + self.trusted_pending = trusted_pending + self.untrusted_pending = untrusted_pending + self.spendable = spendable + self.total = total + def __str__(self): + return "WalletBalance(confirmed={}, immature={}, trusted_pending={}, untrusted_pending={}, spendable={}, total={})".format(self.confirmed, self.immature, self.trusted_pending, self.untrusted_pending, self.spendable, self.total) -class _UniffiConverterTypeActivityError(_UniffiConverterRustBuffer): + def __eq__(self, other): + if self.confirmed != other.confirmed: + return False + if self.immature != other.immature: + return False + if self.trusted_pending != other.trusted_pending: + return False + if self.untrusted_pending != other.untrusted_pending: + return False + if self.spendable != other.spendable: + return False + if self.total != other.total: + return False + return True + +class _UniffiConverterTypeWalletBalance(_UniffiConverterRustBuffer): @staticmethod def read(buf): - variant = buf.read_i32() - if variant == 1: - return ActivityError.InvalidActivity( - _UniffiConverterString.read(buf), - ) - if variant == 2: - return ActivityError.InitializationError( - _UniffiConverterString.read(buf), - ) - if variant == 3: - return ActivityError.InsertError( - _UniffiConverterString.read(buf), - ) - if variant == 4: - return ActivityError.RetrievalError( - _UniffiConverterString.read(buf), - ) - if variant == 5: - return ActivityError.DataError( - _UniffiConverterString.read(buf), - ) - if variant == 6: - return ActivityError.ConnectionError( - _UniffiConverterString.read(buf), - ) - if variant == 7: - return ActivityError.SerializationError( - _UniffiConverterString.read(buf), - ) - raise InternalError("Raw enum value doesn't match any cases") + return WalletBalance( + confirmed=_UniffiConverterUInt64.read(buf), + immature=_UniffiConverterUInt64.read(buf), + trusted_pending=_UniffiConverterUInt64.read(buf), + untrusted_pending=_UniffiConverterUInt64.read(buf), + spendable=_UniffiConverterUInt64.read(buf), + total=_UniffiConverterUInt64.read(buf), + ) @staticmethod def check_lower(value): - if isinstance(value, ActivityError.InvalidActivity): - _UniffiConverterString.check_lower(value.error_details) - return - if isinstance(value, ActivityError.InitializationError): - _UniffiConverterString.check_lower(value.error_details) - return - if isinstance(value, ActivityError.InsertError): - _UniffiConverterString.check_lower(value.error_details) - return - if isinstance(value, ActivityError.RetrievalError): - _UniffiConverterString.check_lower(value.error_details) - return - if isinstance(value, ActivityError.DataError): - _UniffiConverterString.check_lower(value.error_details) - return - if isinstance(value, ActivityError.ConnectionError): - _UniffiConverterString.check_lower(value.error_details) - return - if isinstance(value, ActivityError.SerializationError): - _UniffiConverterString.check_lower(value.error_details) - return + _UniffiConverterUInt64.check_lower(value.confirmed) + _UniffiConverterUInt64.check_lower(value.immature) + _UniffiConverterUInt64.check_lower(value.trusted_pending) + _UniffiConverterUInt64.check_lower(value.untrusted_pending) + _UniffiConverterUInt64.check_lower(value.spendable) + _UniffiConverterUInt64.check_lower(value.total) @staticmethod def write(value, buf): - if isinstance(value, ActivityError.InvalidActivity): - buf.write_i32(1) - _UniffiConverterString.write(value.error_details, buf) - if isinstance(value, ActivityError.InitializationError): - buf.write_i32(2) - _UniffiConverterString.write(value.error_details, buf) - if isinstance(value, ActivityError.InsertError): - buf.write_i32(3) - _UniffiConverterString.write(value.error_details, buf) - if isinstance(value, ActivityError.RetrievalError): - buf.write_i32(4) - _UniffiConverterString.write(value.error_details, buf) - if isinstance(value, ActivityError.DataError): - buf.write_i32(5) - _UniffiConverterString.write(value.error_details, buf) - if isinstance(value, ActivityError.ConnectionError): - buf.write_i32(6) - _UniffiConverterString.write(value.error_details, buf) - if isinstance(value, ActivityError.SerializationError): - buf.write_i32(7) - _UniffiConverterString.write(value.error_details, buf) + _UniffiConverterUInt64.write(value.confirmed, buf) + _UniffiConverterUInt64.write(value.immature, buf) + _UniffiConverterUInt64.write(value.trusted_pending, buf) + _UniffiConverterUInt64.write(value.untrusted_pending, buf) + _UniffiConverterUInt64.write(value.spendable, buf) + _UniffiConverterUInt64.write(value.total, buf) + +class WalletParams: + """ + Common parameters for creating and syncing a watch-only BDK wallet. + """ + extended_key: "str" + """ + Extended public key (xpub/ypub/zpub/tpub/upub/vpub) + """ + electrum_url: "str" + """ + Electrum server URL for wallet sync + """ + fingerprint: "typing.Optional[str]" + """ + Root fingerprint hex (e.g. "73c5da0a"). Required for hardware wallet signing. + """ -class ActivityFilter(enum.Enum): - ALL = 0 - - LIGHTNING = 1 - - ONCHAIN = 2 - + network: "typing.Optional[Network]" + """ + Bitcoin network (auto-detected from key prefix if not specified) + """ + account_type: "typing.Optional[AccountType]" + """ + Override account type for ambiguous key prefixes (xpub/tpub) + """ -class _UniffiConverterTypeActivityFilter(_UniffiConverterRustBuffer): + def __init__(self, *, extended_key: "str", electrum_url: "str", fingerprint: "typing.Optional[str]", network: "typing.Optional[Network]", account_type: "typing.Optional[AccountType]"): + self.extended_key = extended_key + self.electrum_url = electrum_url + self.fingerprint = fingerprint + self.network = network + self.account_type = account_type + + def __str__(self): + return "WalletParams(extended_key={}, electrum_url={}, fingerprint={}, network={}, account_type={})".format(self.extended_key, self.electrum_url, self.fingerprint, self.network, self.account_type) + + def __eq__(self, other): + if self.extended_key != other.extended_key: + return False + if self.electrum_url != other.electrum_url: + return False + if self.fingerprint != other.fingerprint: + return False + if self.network != other.network: + return False + if self.account_type != other.account_type: + return False + return True + +class _UniffiConverterTypeWalletParams(_UniffiConverterRustBuffer): @staticmethod def read(buf): - variant = buf.read_i32() - if variant == 1: - return ActivityFilter.ALL - if variant == 2: - return ActivityFilter.LIGHTNING - if variant == 3: - return ActivityFilter.ONCHAIN - raise InternalError("Raw enum value doesn't match any cases") + return WalletParams( + extended_key=_UniffiConverterString.read(buf), + electrum_url=_UniffiConverterString.read(buf), + fingerprint=_UniffiConverterOptionalString.read(buf), + network=_UniffiConverterOptionalTypeNetwork.read(buf), + account_type=_UniffiConverterOptionalTypeAccountType.read(buf), + ) @staticmethod def check_lower(value): - if value == ActivityFilter.ALL: - return - if value == ActivityFilter.LIGHTNING: - return - if value == ActivityFilter.ONCHAIN: - return - raise ValueError(value) + _UniffiConverterString.check_lower(value.extended_key) + _UniffiConverterString.check_lower(value.electrum_url) + _UniffiConverterOptionalString.check_lower(value.fingerprint) + _UniffiConverterOptionalTypeNetwork.check_lower(value.network) + _UniffiConverterOptionalTypeAccountType.check_lower(value.account_type) @staticmethod def write(value, buf): - if value == ActivityFilter.ALL: - buf.write_i32(1) - if value == ActivityFilter.LIGHTNING: - buf.write_i32(2) - if value == ActivityFilter.ONCHAIN: - buf.write_i32(3) - - + _UniffiConverterString.write(value.extended_key, buf) + _UniffiConverterString.write(value.electrum_url, buf) + _UniffiConverterOptionalString.write(value.fingerprint, buf) + _UniffiConverterOptionalTypeNetwork.write(value.network, buf) + _UniffiConverterOptionalTypeAccountType.write(value.account_type, buf) +class WatcherParams: + """ + Parameters for starting an xpub transaction watcher. + """ + watcher_id: "str" + """ + Caller-supplied identifier for this watcher. + """ + wallet_id: "str" + """ + Wallet id that scopes the activities this watcher emits. Apps may use + one wallet id for several account watchers and merge their snapshots. + """ -class ActivityType(enum.Enum): - ONCHAIN = 0 - - LIGHTNING = 1 - + extended_key: "str" + """ + Extended public key (xpub/ypub/zpub/tpub/upub/vpub). + """ + electrum_url: "str" + """ + Electrum server URL (e.g. "ssl://electrum.example.com:50002"). + """ -class _UniffiConverterTypeActivityType(_UniffiConverterRustBuffer): + network: "typing.Optional[Network]" + """ + Bitcoin network override (auto-detected from key prefix if None). + """ + + account_type: "typing.Optional[AccountType]" + """ + Account type override (auto-detected from key prefix if None). + """ + + gap_limit: "typing.Optional[int]" + """ + Number of unused addresses to monitor beyond the last used + (defaults to `DEFAULT_GAP_LIMIT` when None). + """ + + def __init__(self, *, watcher_id: "str", wallet_id: "str", extended_key: "str", electrum_url: "str", network: "typing.Optional[Network]", account_type: "typing.Optional[AccountType]", gap_limit: "typing.Optional[int]"): + self.watcher_id = watcher_id + self.wallet_id = wallet_id + self.extended_key = extended_key + self.electrum_url = electrum_url + self.network = network + self.account_type = account_type + self.gap_limit = gap_limit + + def __str__(self): + return "WatcherParams(watcher_id={}, wallet_id={}, extended_key={}, electrum_url={}, network={}, account_type={}, gap_limit={})".format(self.watcher_id, self.wallet_id, self.extended_key, self.electrum_url, self.network, self.account_type, self.gap_limit) + + def __eq__(self, other): + if self.watcher_id != other.watcher_id: + return False + if self.wallet_id != other.wallet_id: + return False + if self.extended_key != other.extended_key: + return False + if self.electrum_url != other.electrum_url: + return False + if self.network != other.network: + return False + if self.account_type != other.account_type: + return False + if self.gap_limit != other.gap_limit: + return False + return True + +class _UniffiConverterTypeWatcherParams(_UniffiConverterRustBuffer): @staticmethod def read(buf): - variant = buf.read_i32() - if variant == 1: - return ActivityType.ONCHAIN - if variant == 2: - return ActivityType.LIGHTNING - raise InternalError("Raw enum value doesn't match any cases") + return WatcherParams( + watcher_id=_UniffiConverterString.read(buf), + wallet_id=_UniffiConverterString.read(buf), + extended_key=_UniffiConverterString.read(buf), + electrum_url=_UniffiConverterString.read(buf), + network=_UniffiConverterOptionalTypeNetwork.read(buf), + account_type=_UniffiConverterOptionalTypeAccountType.read(buf), + gap_limit=_UniffiConverterOptionalUInt32.read(buf), + ) @staticmethod def check_lower(value): - if value == ActivityType.ONCHAIN: - return - if value == ActivityType.LIGHTNING: - return - raise ValueError(value) + _UniffiConverterString.check_lower(value.watcher_id) + _UniffiConverterString.check_lower(value.wallet_id) + _UniffiConverterString.check_lower(value.extended_key) + _UniffiConverterString.check_lower(value.electrum_url) + _UniffiConverterOptionalTypeNetwork.check_lower(value.network) + _UniffiConverterOptionalTypeAccountType.check_lower(value.account_type) + _UniffiConverterOptionalUInt32.check_lower(value.gap_limit) @staticmethod def write(value, buf): - if value == ActivityType.ONCHAIN: - buf.write_i32(1) - if value == ActivityType.LIGHTNING: - buf.write_i32(2) - - + _UniffiConverterString.write(value.watcher_id, buf) + _UniffiConverterString.write(value.wallet_id, buf) + _UniffiConverterString.write(value.extended_key, buf) + _UniffiConverterString.write(value.electrum_url, buf) + _UniffiConverterOptionalTypeNetwork.write(value.network, buf) + _UniffiConverterOptionalTypeAccountType.write(value.account_type, buf) + _UniffiConverterOptionalUInt32.write(value.gap_limit, buf) -# AddressError +# AccountInfoError # We want to define each variant as a nested class that's also a subclass, # which is tricky in Python. To accomplish this we're going to create each # class separately, then manually add the child classes to the base class's # __dict__. All of this happens in dummy class to avoid polluting the module # namespace. -class AddressError(Exception): +class AccountInfoError(Exception): + """ + Errors specific to account info operations (BDK/Electrum-based). + """ + pass -_UniffiTempAddressError = AddressError +_UniffiTempAccountInfoError = AccountInfoError -class AddressError: # type: ignore - class InvalidAddress(_UniffiTempAddressError): - def __init__(self): - pass +class AccountInfoError: # type: ignore + """ + Errors specific to account info operations (BDK/Electrum-based). + """ + + class InvalidExtendedKey(_UniffiTempAccountInfoError): + """ + The provided extended public key is invalid or cannot be parsed + """ + + def __init__(self, error_details): + super().__init__(", ".join([ + "error_details={!r}".format(error_details), + ])) + self.error_details = error_details def __repr__(self): - return "AddressError.InvalidAddress({})".format(str(self)) - _UniffiTempAddressError.InvalidAddress = InvalidAddress # type: ignore - class InvalidNetwork(_UniffiTempAddressError): - def __init__(self): - pass + return "AccountInfoError.InvalidExtendedKey({})".format(str(self)) + _UniffiTempAccountInfoError.InvalidExtendedKey = InvalidExtendedKey # type: ignore + class InvalidAddress(_UniffiTempAccountInfoError): + """ + The provided address is invalid + """ + + def __init__(self, error_details): + super().__init__(", ".join([ + "error_details={!r}".format(error_details), + ])) + self.error_details = error_details def __repr__(self): - return "AddressError.InvalidNetwork({})".format(str(self)) - _UniffiTempAddressError.InvalidNetwork = InvalidNetwork # type: ignore - class MnemonicGenerationFailed(_UniffiTempAddressError): - def __init__(self): - pass + return "AccountInfoError.InvalidAddress({})".format(str(self)) + _UniffiTempAccountInfoError.InvalidAddress = InvalidAddress # type: ignore + class ElectrumError(_UniffiTempAccountInfoError): + """ + Electrum connection or query failed + """ + + def __init__(self, error_details): + super().__init__(", ".join([ + "error_details={!r}".format(error_details), + ])) + self.error_details = error_details def __repr__(self): - return "AddressError.MnemonicGenerationFailed({})".format(str(self)) - _UniffiTempAddressError.MnemonicGenerationFailed = MnemonicGenerationFailed # type: ignore - class InvalidMnemonic(_UniffiTempAddressError): - def __init__(self): - pass + return "AccountInfoError.ElectrumError({})".format(str(self)) + _UniffiTempAccountInfoError.ElectrumError = ElectrumError # type: ignore + class WalletError(_UniffiTempAccountInfoError): + """ + BDK wallet creation or operation error + """ + + def __init__(self, error_details): + super().__init__(", ".join([ + "error_details={!r}".format(error_details), + ])) + self.error_details = error_details def __repr__(self): - return "AddressError.InvalidMnemonic({})".format(str(self)) - _UniffiTempAddressError.InvalidMnemonic = InvalidMnemonic # type: ignore - class InvalidEntropy(_UniffiTempAddressError): - def __init__(self): - pass + return "AccountInfoError.WalletError({})".format(str(self)) + _UniffiTempAccountInfoError.WalletError = WalletError # type: ignore + class SyncError(_UniffiTempAccountInfoError): + """ + Wallet sync with Electrum failed + """ + + def __init__(self, error_details): + super().__init__(", ".join([ + "error_details={!r}".format(error_details), + ])) + self.error_details = error_details def __repr__(self): - return "AddressError.InvalidEntropy({})".format(str(self)) - _UniffiTempAddressError.InvalidEntropy = InvalidEntropy # type: ignore - class AddressDerivationFailed(_UniffiTempAddressError): - def __init__(self): - pass + return "AccountInfoError.SyncError({})".format(str(self)) + _UniffiTempAccountInfoError.SyncError = SyncError # type: ignore + class UnsupportedKeyType(_UniffiTempAccountInfoError): + """ + The key type/prefix is not recognized + """ + + def __init__(self, error_details): + super().__init__(", ".join([ + "error_details={!r}".format(error_details), + ])) + self.error_details = error_details def __repr__(self): - return "AddressError.AddressDerivationFailed({})".format(str(self)) - _UniffiTempAddressError.AddressDerivationFailed = AddressDerivationFailed # type: ignore + return "AccountInfoError.UnsupportedKeyType({})".format(str(self)) + _UniffiTempAccountInfoError.UnsupportedKeyType = UnsupportedKeyType # type: ignore + class NetworkMismatch(_UniffiTempAccountInfoError): + """ + Network mismatch between key prefix and specified network + """ -AddressError = _UniffiTempAddressError # type: ignore -del _UniffiTempAddressError + def __init__(self, error_details): + super().__init__(", ".join([ + "error_details={!r}".format(error_details), + ])) + self.error_details = error_details + def __repr__(self): + return "AccountInfoError.NetworkMismatch({})".format(str(self)) + _UniffiTempAccountInfoError.NetworkMismatch = NetworkMismatch # type: ignore + class InvalidTxid(_UniffiTempAccountInfoError): + """ + Invalid transaction ID provided + """ -class _UniffiConverterTypeAddressError(_UniffiConverterRustBuffer): - @staticmethod - def read(buf): - variant = buf.read_i32() - if variant == 1: - return AddressError.InvalidAddress( - ) - if variant == 2: - return AddressError.InvalidNetwork( - ) - if variant == 3: - return AddressError.MnemonicGenerationFailed( - ) - if variant == 4: - return AddressError.InvalidMnemonic( - ) - if variant == 5: - return AddressError.InvalidEntropy( - ) - if variant == 6: - return AddressError.AddressDerivationFailed( - ) - raise InternalError("Raw enum value doesn't match any cases") - - @staticmethod - def check_lower(value): - if isinstance(value, AddressError.InvalidAddress): - return - if isinstance(value, AddressError.InvalidNetwork): - return - if isinstance(value, AddressError.MnemonicGenerationFailed): - return - if isinstance(value, AddressError.InvalidMnemonic): - return - if isinstance(value, AddressError.InvalidEntropy): - return - if isinstance(value, AddressError.AddressDerivationFailed): - return + def __init__(self, error_details): + super().__init__(", ".join([ + "error_details={!r}".format(error_details), + ])) + self.error_details = error_details - @staticmethod - def write(value, buf): - if isinstance(value, AddressError.InvalidAddress): - buf.write_i32(1) - if isinstance(value, AddressError.InvalidNetwork): - buf.write_i32(2) - if isinstance(value, AddressError.MnemonicGenerationFailed): - buf.write_i32(3) - if isinstance(value, AddressError.InvalidMnemonic): - buf.write_i32(4) - if isinstance(value, AddressError.InvalidEntropy): - buf.write_i32(5) - if isinstance(value, AddressError.AddressDerivationFailed): - buf.write_i32(6) + def __repr__(self): + return "AccountInfoError.InvalidTxid({})".format(str(self)) + _UniffiTempAccountInfoError.InvalidTxid = InvalidTxid # type: ignore + class TransactionNotFound(_UniffiTempAccountInfoError): + """ + A valid transaction ID was not found in the wallet + """ + def __init__(self, error_details): + super().__init__(", ".join([ + "error_details={!r}".format(error_details), + ])) + self.error_details = error_details + def __repr__(self): + return "AccountInfoError.TransactionNotFound({})".format(str(self)) + _UniffiTempAccountInfoError.TransactionNotFound = TransactionNotFound # type: ignore + class WatcherError(_UniffiTempAccountInfoError): + """ + Watcher lifecycle or subscription error + """ + def __init__(self, error_details): + super().__init__(", ".join([ + "error_details={!r}".format(error_details), + ])) + self.error_details = error_details + def __repr__(self): + return "AccountInfoError.WatcherError({})".format(str(self)) + _UniffiTempAccountInfoError.WatcherError = WatcherError # type: ignore -class AddressType(enum.Enum): - P2PKH = 0 - - P2SH = 1 - - P2WPKH = 2 - - P2WSH = 3 - - P2TR = 4 - - UNKNOWN = 5 - +AccountInfoError = _UniffiTempAccountInfoError # type: ignore +del _UniffiTempAccountInfoError -class _UniffiConverterTypeAddressType(_UniffiConverterRustBuffer): +class _UniffiConverterTypeAccountInfoError(_UniffiConverterRustBuffer): @staticmethod def read(buf): variant = buf.read_i32() if variant == 1: - return AddressType.P2PKH + return AccountInfoError.InvalidExtendedKey( + _UniffiConverterString.read(buf), + ) if variant == 2: - return AddressType.P2SH + return AccountInfoError.InvalidAddress( + _UniffiConverterString.read(buf), + ) if variant == 3: - return AddressType.P2WPKH + return AccountInfoError.ElectrumError( + _UniffiConverterString.read(buf), + ) if variant == 4: - return AddressType.P2WSH + return AccountInfoError.WalletError( + _UniffiConverterString.read(buf), + ) if variant == 5: - return AddressType.P2TR + return AccountInfoError.SyncError( + _UniffiConverterString.read(buf), + ) if variant == 6: - return AddressType.UNKNOWN + return AccountInfoError.UnsupportedKeyType( + _UniffiConverterString.read(buf), + ) + if variant == 7: + return AccountInfoError.NetworkMismatch( + _UniffiConverterString.read(buf), + ) + if variant == 8: + return AccountInfoError.InvalidTxid( + _UniffiConverterString.read(buf), + ) + if variant == 9: + return AccountInfoError.TransactionNotFound( + _UniffiConverterString.read(buf), + ) + if variant == 10: + return AccountInfoError.WatcherError( + _UniffiConverterString.read(buf), + ) raise InternalError("Raw enum value doesn't match any cases") @staticmethod def check_lower(value): - if value == AddressType.P2PKH: + if isinstance(value, AccountInfoError.InvalidExtendedKey): + _UniffiConverterString.check_lower(value.error_details) return - if value == AddressType.P2SH: + if isinstance(value, AccountInfoError.InvalidAddress): + _UniffiConverterString.check_lower(value.error_details) return - if value == AddressType.P2WPKH: + if isinstance(value, AccountInfoError.ElectrumError): + _UniffiConverterString.check_lower(value.error_details) return - if value == AddressType.P2WSH: + if isinstance(value, AccountInfoError.WalletError): + _UniffiConverterString.check_lower(value.error_details) return - if value == AddressType.P2TR: + if isinstance(value, AccountInfoError.SyncError): + _UniffiConverterString.check_lower(value.error_details) return - if value == AddressType.UNKNOWN: + if isinstance(value, AccountInfoError.UnsupportedKeyType): + _UniffiConverterString.check_lower(value.error_details) + return + if isinstance(value, AccountInfoError.NetworkMismatch): + _UniffiConverterString.check_lower(value.error_details) + return + if isinstance(value, AccountInfoError.InvalidTxid): + _UniffiConverterString.check_lower(value.error_details) + return + if isinstance(value, AccountInfoError.TransactionNotFound): + _UniffiConverterString.check_lower(value.error_details) + return + if isinstance(value, AccountInfoError.WatcherError): + _UniffiConverterString.check_lower(value.error_details) return - raise ValueError(value) @staticmethod def write(value, buf): - if value == AddressType.P2PKH: + if isinstance(value, AccountInfoError.InvalidExtendedKey): buf.write_i32(1) - if value == AddressType.P2SH: + _UniffiConverterString.write(value.error_details, buf) + if isinstance(value, AccountInfoError.InvalidAddress): buf.write_i32(2) - if value == AddressType.P2WPKH: + _UniffiConverterString.write(value.error_details, buf) + if isinstance(value, AccountInfoError.ElectrumError): buf.write_i32(3) - if value == AddressType.P2WSH: + _UniffiConverterString.write(value.error_details, buf) + if isinstance(value, AccountInfoError.WalletError): buf.write_i32(4) - if value == AddressType.P2TR: + _UniffiConverterString.write(value.error_details, buf) + if isinstance(value, AccountInfoError.SyncError): buf.write_i32(5) - if value == AddressType.UNKNOWN: + _UniffiConverterString.write(value.error_details, buf) + if isinstance(value, AccountInfoError.UnsupportedKeyType): buf.write_i32(6) + _UniffiConverterString.write(value.error_details, buf) + if isinstance(value, AccountInfoError.NetworkMismatch): + buf.write_i32(7) + _UniffiConverterString.write(value.error_details, buf) + if isinstance(value, AccountInfoError.InvalidTxid): + buf.write_i32(8) + _UniffiConverterString.write(value.error_details, buf) + if isinstance(value, AccountInfoError.TransactionNotFound): + buf.write_i32(9) + _UniffiConverterString.write(value.error_details, buf) + if isinstance(value, AccountInfoError.WatcherError): + buf.write_i32(10) + _UniffiConverterString.write(value.error_details, buf) + +class AccountType(enum.Enum): + """ + Account type classification for extended public keys. + Determines the BIP standard, derivation path purpose, and script type. + """ + LEGACY = 0 + """ + BIP44 legacy (P2PKH) — xpub/tpub prefix + """ -class BitcoinNetworkEnum(enum.Enum): - MAINNET = 0 - TESTNET = 1 + WRAPPED_SEGWIT = 1 + """ + BIP49 wrapped segwit (P2SH-P2WPKH) — ypub/upub prefix + """ + - SIGNET = 2 + NATIVE_SEGWIT = 2 + """ + BIP84 native segwit (P2WPKH) — zpub/vpub prefix + """ + - REGTEST = 3 + TAPROOT = 3 + """ + BIP86 taproot (P2TR) + """ + -class _UniffiConverterTypeBitcoinNetworkEnum(_UniffiConverterRustBuffer): +class _UniffiConverterTypeAccountType(_UniffiConverterRustBuffer): @staticmethod def read(buf): variant = buf.read_i32() if variant == 1: - return BitcoinNetworkEnum.MAINNET + return AccountType.LEGACY if variant == 2: - return BitcoinNetworkEnum.TESTNET + return AccountType.WRAPPED_SEGWIT if variant == 3: - return BitcoinNetworkEnum.SIGNET + return AccountType.NATIVE_SEGWIT if variant == 4: - return BitcoinNetworkEnum.REGTEST + return AccountType.TAPROOT raise InternalError("Raw enum value doesn't match any cases") @staticmethod def check_lower(value): - if value == BitcoinNetworkEnum.MAINNET: + if value == AccountType.LEGACY: return - if value == BitcoinNetworkEnum.TESTNET: + if value == AccountType.WRAPPED_SEGWIT: return - if value == BitcoinNetworkEnum.SIGNET: + if value == AccountType.NATIVE_SEGWIT: return - if value == BitcoinNetworkEnum.REGTEST: + if value == AccountType.TAPROOT: return raise ValueError(value) @staticmethod def write(value, buf): - if value == BitcoinNetworkEnum.MAINNET: + if value == AccountType.LEGACY: buf.write_i32(1) - if value == BitcoinNetworkEnum.TESTNET: + if value == AccountType.WRAPPED_SEGWIT: buf.write_i32(2) - if value == BitcoinNetworkEnum.SIGNET: + if value == AccountType.NATIVE_SEGWIT: buf.write_i32(3) - if value == BitcoinNetworkEnum.REGTEST: + if value == AccountType.TAPROOT: buf.write_i32(4) -# BlocktankError -# We want to define each variant as a nested class that's also a subclass, -# which is tricky in Python. To accomplish this we're going to create each -# class separately, then manually add the child classes to the base class's -# __dict__. All of this happens in dummy class to avoid polluting the module -# namespace. -class BlocktankError(Exception): - pass -_UniffiTempBlocktankError = BlocktankError -class BlocktankError: # type: ignore - class HttpClient(_UniffiTempBlocktankError): - def __init__(self, error_details): - super().__init__(", ".join([ - "error_details={!r}".format(error_details), - ])) - self.error_details = error_details - def __repr__(self): - return "BlocktankError.HttpClient({})".format(str(self)) - _UniffiTempBlocktankError.HttpClient = HttpClient # type: ignore - class BlocktankClient(_UniffiTempBlocktankError): - def __init__(self, error_details): - super().__init__(", ".join([ - "error_details={!r}".format(error_details), - ])) - self.error_details = error_details +class Activity: + def __init__(self): + raise RuntimeError("Activity cannot be instantiated directly") - def __repr__(self): - return "BlocktankError.BlocktankClient({})".format(str(self)) - _UniffiTempBlocktankError.BlocktankClient = BlocktankClient # type: ignore - class InvalidBlocktank(_UniffiTempBlocktankError): - def __init__(self, error_details): - super().__init__(", ".join([ - "error_details={!r}".format(error_details), - ])) - self.error_details = error_details + # Each enum variant is a nested class of the enum itself. + class ONCHAIN: + def __init__(self, *values): + if len(values) != 1: + raise TypeError(f"Expected 1 arguments, found {len(values)}") + self._values = values - def __repr__(self): - return "BlocktankError.InvalidBlocktank({})".format(str(self)) - _UniffiTempBlocktankError.InvalidBlocktank = InvalidBlocktank # type: ignore - class InitializationError(_UniffiTempBlocktankError): - def __init__(self, error_details): - super().__init__(", ".join([ - "error_details={!r}".format(error_details), - ])) - self.error_details = error_details + def __getitem__(self, index): + return self._values[index] - def __repr__(self): - return "BlocktankError.InitializationError({})".format(str(self)) - _UniffiTempBlocktankError.InitializationError = InitializationError # type: ignore - class InsertError(_UniffiTempBlocktankError): - def __init__(self, error_details): - super().__init__(", ".join([ - "error_details={!r}".format(error_details), - ])) - self.error_details = error_details + def __str__(self): + return f"Activity.ONCHAIN{self._values!r}" - def __repr__(self): - return "BlocktankError.InsertError({})".format(str(self)) - _UniffiTempBlocktankError.InsertError = InsertError # type: ignore - class RetrievalError(_UniffiTempBlocktankError): - def __init__(self, error_details): - super().__init__(", ".join([ - "error_details={!r}".format(error_details), - ])) - self.error_details = error_details + def __eq__(self, other): + if not other.is_ONCHAIN(): + return False + return self._values == other._values + class LIGHTNING: + def __init__(self, *values): + if len(values) != 1: + raise TypeError(f"Expected 1 arguments, found {len(values)}") + self._values = values - def __repr__(self): - return "BlocktankError.RetrievalError({})".format(str(self)) - _UniffiTempBlocktankError.RetrievalError = RetrievalError # type: ignore - class DataError(_UniffiTempBlocktankError): + def __getitem__(self, index): + return self._values[index] + + def __str__(self): + return f"Activity.LIGHTNING{self._values!r}" + + def __eq__(self, other): + if not other.is_LIGHTNING(): + return False + return self._values == other._values + + + # For each variant, we have `is_NAME` and `is_name` methods for easily checking + # whether an instance is that variant. + def is_ONCHAIN(self) -> bool: + return isinstance(self, Activity.ONCHAIN) + def is_onchain(self) -> bool: + return isinstance(self, Activity.ONCHAIN) + def is_LIGHTNING(self) -> bool: + return isinstance(self, Activity.LIGHTNING) + def is_lightning(self) -> bool: + return isinstance(self, Activity.LIGHTNING) + + +# Now, a little trick - we make each nested variant class be a subclass of the main +# enum class, so that method calls and instance checks etc will work intuitively. +# We might be able to do this a little more neatly with a metaclass, but this'll do. +Activity.ONCHAIN = type("Activity.ONCHAIN", (Activity.ONCHAIN, Activity,), {}) # type: ignore +Activity.LIGHTNING = type("Activity.LIGHTNING", (Activity.LIGHTNING, Activity,), {}) # type: ignore + + + + +class _UniffiConverterTypeActivity(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + variant = buf.read_i32() + if variant == 1: + return Activity.ONCHAIN( + _UniffiConverterTypeOnchainActivity.read(buf), + ) + if variant == 2: + return Activity.LIGHTNING( + _UniffiConverterTypeLightningActivity.read(buf), + ) + raise InternalError("Raw enum value doesn't match any cases") + + @staticmethod + def check_lower(value): + if value.is_ONCHAIN(): + _UniffiConverterTypeOnchainActivity.check_lower(value._values[0]) + return + if value.is_LIGHTNING(): + _UniffiConverterTypeLightningActivity.check_lower(value._values[0]) + return + raise ValueError(value) + + @staticmethod + def write(value, buf): + if value.is_ONCHAIN(): + buf.write_i32(1) + _UniffiConverterTypeOnchainActivity.write(value._values[0], buf) + if value.is_LIGHTNING(): + buf.write_i32(2) + _UniffiConverterTypeLightningActivity.write(value._values[0], buf) + + + + +# ActivityError +# We want to define each variant as a nested class that's also a subclass, +# which is tricky in Python. To accomplish this we're going to create each +# class separately, then manually add the child classes to the base class's +# __dict__. All of this happens in dummy class to avoid polluting the module +# namespace. +class ActivityError(Exception): + pass + +_UniffiTempActivityError = ActivityError + +class ActivityError: # type: ignore + class InvalidActivity(_UniffiTempActivityError): def __init__(self, error_details): super().__init__(", ".join([ "error_details={!r}".format(error_details), @@ -12309,9 +12566,9 @@ def __init__(self, error_details): self.error_details = error_details def __repr__(self): - return "BlocktankError.DataError({})".format(str(self)) - _UniffiTempBlocktankError.DataError = DataError # type: ignore - class ConnectionError(_UniffiTempBlocktankError): + return "ActivityError.InvalidActivity({})".format(str(self)) + _UniffiTempActivityError.InvalidActivity = InvalidActivity # type: ignore + class InitializationError(_UniffiTempActivityError): def __init__(self, error_details): super().__init__(", ".join([ "error_details={!r}".format(error_details), @@ -12319,9 +12576,9 @@ def __init__(self, error_details): self.error_details = error_details def __repr__(self): - return "BlocktankError.ConnectionError({})".format(str(self)) - _UniffiTempBlocktankError.ConnectionError = ConnectionError # type: ignore - class SerializationError(_UniffiTempBlocktankError): + return "ActivityError.InitializationError({})".format(str(self)) + _UniffiTempActivityError.InitializationError = InitializationError # type: ignore + class InsertError(_UniffiTempActivityError): def __init__(self, error_details): super().__init__(", ".join([ "error_details={!r}".format(error_details), @@ -12329,21 +12586,19 @@ def __init__(self, error_details): self.error_details = error_details def __repr__(self): - return "BlocktankError.SerializationError({})".format(str(self)) - _UniffiTempBlocktankError.SerializationError = SerializationError # type: ignore - class ChannelOpen(_UniffiTempBlocktankError): - def __init__(self, error_type, error_details): + return "ActivityError.InsertError({})".format(str(self)) + _UniffiTempActivityError.InsertError = InsertError # type: ignore + class RetrievalError(_UniffiTempActivityError): + def __init__(self, error_details): super().__init__(", ".join([ - "error_type={!r}".format(error_type), "error_details={!r}".format(error_details), ])) - self.error_type = error_type self.error_details = error_details def __repr__(self): - return "BlocktankError.ChannelOpen({})".format(str(self)) - _UniffiTempBlocktankError.ChannelOpen = ChannelOpen # type: ignore - class OrderState(_UniffiTempBlocktankError): + return "ActivityError.RetrievalError({})".format(str(self)) + _UniffiTempActivityError.RetrievalError = RetrievalError # type: ignore + class DataError(_UniffiTempActivityError): def __init__(self, error_details): super().__init__(", ".join([ "error_details={!r}".format(error_details), @@ -12351,9 +12606,9 @@ def __init__(self, error_details): self.error_details = error_details def __repr__(self): - return "BlocktankError.OrderState({})".format(str(self)) - _UniffiTempBlocktankError.OrderState = OrderState # type: ignore - class InvalidParameter(_UniffiTempBlocktankError): + return "ActivityError.DataError({})".format(str(self)) + _UniffiTempActivityError.DataError = DataError # type: ignore + class ConnectionError(_UniffiTempActivityError): def __init__(self, error_details): super().__init__(", ".join([ "error_details={!r}".format(error_details), @@ -12361,9 +12616,9 @@ def __init__(self, error_details): self.error_details = error_details def __repr__(self): - return "BlocktankError.InvalidParameter({})".format(str(self)) - _UniffiTempBlocktankError.InvalidParameter = InvalidParameter # type: ignore - class DatabaseError(_UniffiTempBlocktankError): + return "ActivityError.ConnectionError({})".format(str(self)) + _UniffiTempActivityError.ConnectionError = ConnectionError # type: ignore + class SerializationError(_UniffiTempActivityError): def __init__(self, error_details): super().__init__(", ".join([ "error_details={!r}".format(error_details), @@ -12371,424 +12626,360 @@ def __init__(self, error_details): self.error_details = error_details def __repr__(self): - return "BlocktankError.DatabaseError({})".format(str(self)) - _UniffiTempBlocktankError.DatabaseError = DatabaseError # type: ignore + return "ActivityError.SerializationError({})".format(str(self)) + _UniffiTempActivityError.SerializationError = SerializationError # type: ignore -BlocktankError = _UniffiTempBlocktankError # type: ignore -del _UniffiTempBlocktankError +ActivityError = _UniffiTempActivityError # type: ignore +del _UniffiTempActivityError -class _UniffiConverterTypeBlocktankError(_UniffiConverterRustBuffer): +class _UniffiConverterTypeActivityError(_UniffiConverterRustBuffer): @staticmethod def read(buf): variant = buf.read_i32() if variant == 1: - return BlocktankError.HttpClient( + return ActivityError.InvalidActivity( _UniffiConverterString.read(buf), ) if variant == 2: - return BlocktankError.BlocktankClient( + return ActivityError.InitializationError( _UniffiConverterString.read(buf), ) if variant == 3: - return BlocktankError.InvalidBlocktank( + return ActivityError.InsertError( _UniffiConverterString.read(buf), ) if variant == 4: - return BlocktankError.InitializationError( + return ActivityError.RetrievalError( _UniffiConverterString.read(buf), ) if variant == 5: - return BlocktankError.InsertError( + return ActivityError.DataError( _UniffiConverterString.read(buf), ) if variant == 6: - return BlocktankError.RetrievalError( + return ActivityError.ConnectionError( _UniffiConverterString.read(buf), ) if variant == 7: - return BlocktankError.DataError( - _UniffiConverterString.read(buf), - ) - if variant == 8: - return BlocktankError.ConnectionError( - _UniffiConverterString.read(buf), - ) - if variant == 9: - return BlocktankError.SerializationError( - _UniffiConverterString.read(buf), - ) - if variant == 10: - return BlocktankError.ChannelOpen( - _UniffiConverterTypeBtChannelOrderErrorType.read(buf), - _UniffiConverterString.read(buf), - ) - if variant == 11: - return BlocktankError.OrderState( - _UniffiConverterString.read(buf), - ) - if variant == 12: - return BlocktankError.InvalidParameter( - _UniffiConverterString.read(buf), - ) - if variant == 13: - return BlocktankError.DatabaseError( + return ActivityError.SerializationError( _UniffiConverterString.read(buf), ) raise InternalError("Raw enum value doesn't match any cases") @staticmethod def check_lower(value): - if isinstance(value, BlocktankError.HttpClient): + if isinstance(value, ActivityError.InvalidActivity): _UniffiConverterString.check_lower(value.error_details) return - if isinstance(value, BlocktankError.BlocktankClient): + if isinstance(value, ActivityError.InitializationError): _UniffiConverterString.check_lower(value.error_details) return - if isinstance(value, BlocktankError.InvalidBlocktank): + if isinstance(value, ActivityError.InsertError): _UniffiConverterString.check_lower(value.error_details) return - if isinstance(value, BlocktankError.InitializationError): - _UniffiConverterString.check_lower(value.error_details) - return - if isinstance(value, BlocktankError.InsertError): - _UniffiConverterString.check_lower(value.error_details) - return - if isinstance(value, BlocktankError.RetrievalError): - _UniffiConverterString.check_lower(value.error_details) - return - if isinstance(value, BlocktankError.DataError): - _UniffiConverterString.check_lower(value.error_details) - return - if isinstance(value, BlocktankError.ConnectionError): - _UniffiConverterString.check_lower(value.error_details) - return - if isinstance(value, BlocktankError.SerializationError): - _UniffiConverterString.check_lower(value.error_details) - return - if isinstance(value, BlocktankError.ChannelOpen): - _UniffiConverterTypeBtChannelOrderErrorType.check_lower(value.error_type) + if isinstance(value, ActivityError.RetrievalError): _UniffiConverterString.check_lower(value.error_details) return - if isinstance(value, BlocktankError.OrderState): + if isinstance(value, ActivityError.DataError): _UniffiConverterString.check_lower(value.error_details) return - if isinstance(value, BlocktankError.InvalidParameter): + if isinstance(value, ActivityError.ConnectionError): _UniffiConverterString.check_lower(value.error_details) return - if isinstance(value, BlocktankError.DatabaseError): + if isinstance(value, ActivityError.SerializationError): _UniffiConverterString.check_lower(value.error_details) return @staticmethod def write(value, buf): - if isinstance(value, BlocktankError.HttpClient): + if isinstance(value, ActivityError.InvalidActivity): buf.write_i32(1) _UniffiConverterString.write(value.error_details, buf) - if isinstance(value, BlocktankError.BlocktankClient): + if isinstance(value, ActivityError.InitializationError): buf.write_i32(2) _UniffiConverterString.write(value.error_details, buf) - if isinstance(value, BlocktankError.InvalidBlocktank): + if isinstance(value, ActivityError.InsertError): buf.write_i32(3) _UniffiConverterString.write(value.error_details, buf) - if isinstance(value, BlocktankError.InitializationError): + if isinstance(value, ActivityError.RetrievalError): buf.write_i32(4) _UniffiConverterString.write(value.error_details, buf) - if isinstance(value, BlocktankError.InsertError): + if isinstance(value, ActivityError.DataError): buf.write_i32(5) _UniffiConverterString.write(value.error_details, buf) - if isinstance(value, BlocktankError.RetrievalError): + if isinstance(value, ActivityError.ConnectionError): buf.write_i32(6) _UniffiConverterString.write(value.error_details, buf) - if isinstance(value, BlocktankError.DataError): + if isinstance(value, ActivityError.SerializationError): buf.write_i32(7) _UniffiConverterString.write(value.error_details, buf) - if isinstance(value, BlocktankError.ConnectionError): - buf.write_i32(8) - _UniffiConverterString.write(value.error_details, buf) - if isinstance(value, BlocktankError.SerializationError): - buf.write_i32(9) - _UniffiConverterString.write(value.error_details, buf) - if isinstance(value, BlocktankError.ChannelOpen): - buf.write_i32(10) - _UniffiConverterTypeBtChannelOrderErrorType.write(value.error_type, buf) - _UniffiConverterString.write(value.error_details, buf) - if isinstance(value, BlocktankError.OrderState): - buf.write_i32(11) - _UniffiConverterString.write(value.error_details, buf) - if isinstance(value, BlocktankError.InvalidParameter): - buf.write_i32(12) - _UniffiConverterString.write(value.error_details, buf) - if isinstance(value, BlocktankError.DatabaseError): - buf.write_i32(13) - _UniffiConverterString.write(value.error_details, buf) -# BoltzError -# We want to define each variant as a nested class that's also a subclass, -# which is tricky in Python. To accomplish this we're going to create each -# class separately, then manually add the child classes to the base class's -# __dict__. All of this happens in dummy class to avoid polluting the module -# namespace. -class BoltzError(Exception): - """ - Errors surfaced by the Boltz swaps module. - """ - pass -_UniffiTempBoltzError = BoltzError -class BoltzError: # type: ignore - """ - Errors surfaced by the Boltz swaps module. - """ +class ActivityFilter(enum.Enum): + ALL = 0 + + LIGHTNING = 1 + + ONCHAIN = 2 + - class InitializationError(_UniffiTempBoltzError): - def __init__(self, error_details): - super().__init__(", ".join([ - "error_details={!r}".format(error_details), - ])) - self.error_details = error_details - def __repr__(self): - return "BoltzError.InitializationError({})".format(str(self)) - _UniffiTempBoltzError.InitializationError = InitializationError # type: ignore - class ConnectionError(_UniffiTempBoltzError): - def __init__(self, error_details): - super().__init__(", ".join([ - "error_details={!r}".format(error_details), - ])) - self.error_details = error_details +class _UniffiConverterTypeActivityFilter(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + variant = buf.read_i32() + if variant == 1: + return ActivityFilter.ALL + if variant == 2: + return ActivityFilter.LIGHTNING + if variant == 3: + return ActivityFilter.ONCHAIN + raise InternalError("Raw enum value doesn't match any cases") - def __repr__(self): - return "BoltzError.ConnectionError({})".format(str(self)) - _UniffiTempBoltzError.ConnectionError = ConnectionError # type: ignore - class DatabaseError(_UniffiTempBoltzError): - def __init__(self, error_details): - super().__init__(", ".join([ - "error_details={!r}".format(error_details), - ])) - self.error_details = error_details + @staticmethod + def check_lower(value): + if value == ActivityFilter.ALL: + return + if value == ActivityFilter.LIGHTNING: + return + if value == ActivityFilter.ONCHAIN: + return + raise ValueError(value) - def __repr__(self): - return "BoltzError.DatabaseError({})".format(str(self)) - _UniffiTempBoltzError.DatabaseError = DatabaseError # type: ignore - class ApiError(_UniffiTempBoltzError): - def __init__(self, error_details): - super().__init__(", ".join([ - "error_details={!r}".format(error_details), - ])) - self.error_details = error_details + @staticmethod + def write(value, buf): + if value == ActivityFilter.ALL: + buf.write_i32(1) + if value == ActivityFilter.LIGHTNING: + buf.write_i32(2) + if value == ActivityFilter.ONCHAIN: + buf.write_i32(3) - def __repr__(self): - return "BoltzError.ApiError({})".format(str(self)) - _UniffiTempBoltzError.ApiError = ApiError # type: ignore - class SwapError(_UniffiTempBoltzError): - def __init__(self, error_details): - super().__init__(", ".join([ - "error_details={!r}".format(error_details), - ])) - self.error_details = error_details - def __repr__(self): - return "BoltzError.SwapError({})".format(str(self)) - _UniffiTempBoltzError.SwapError = SwapError # type: ignore - class BroadcastError(_UniffiTempBoltzError): - def __init__(self, error_details): - super().__init__(", ".join([ - "error_details={!r}".format(error_details), - ])) - self.error_details = error_details - def __repr__(self): - return "BoltzError.BroadcastError({})".format(str(self)) - _UniffiTempBoltzError.BroadcastError = BroadcastError # type: ignore - class InvalidInput(_UniffiTempBoltzError): - def __init__(self, error_details): - super().__init__(", ".join([ - "error_details={!r}".format(error_details), - ])) - self.error_details = error_details - def __repr__(self): - return "BoltzError.InvalidInput({})".format(str(self)) - _UniffiTempBoltzError.InvalidInput = InvalidInput # type: ignore - class SerializationError(_UniffiTempBoltzError): - def __init__(self, error_details): - super().__init__(", ".join([ - "error_details={!r}".format(error_details), - ])) - self.error_details = error_details - def __repr__(self): - return "BoltzError.SerializationError({})".format(str(self)) - _UniffiTempBoltzError.SerializationError = SerializationError # type: ignore - class NotFound(_UniffiTempBoltzError): - def __init__(self, error_details): - super().__init__(", ".join([ - "error_details={!r}".format(error_details), - ])) - self.error_details = error_details - def __repr__(self): - return "BoltzError.NotFound({})".format(str(self)) - _UniffiTempBoltzError.NotFound = NotFound # type: ignore -BoltzError = _UniffiTempBoltzError # type: ignore -del _UniffiTempBoltzError +class ActivityType(enum.Enum): + ONCHAIN = 0 + + LIGHTNING = 1 + -class _UniffiConverterTypeBoltzError(_UniffiConverterRustBuffer): +class _UniffiConverterTypeActivityType(_UniffiConverterRustBuffer): @staticmethod def read(buf): variant = buf.read_i32() if variant == 1: - return BoltzError.InitializationError( - _UniffiConverterString.read(buf), - ) + return ActivityType.ONCHAIN if variant == 2: - return BoltzError.ConnectionError( - _UniffiConverterString.read(buf), - ) - if variant == 3: - return BoltzError.DatabaseError( - _UniffiConverterString.read(buf), - ) - if variant == 4: - return BoltzError.ApiError( - _UniffiConverterString.read(buf), - ) - if variant == 5: - return BoltzError.SwapError( - _UniffiConverterString.read(buf), - ) - if variant == 6: - return BoltzError.BroadcastError( - _UniffiConverterString.read(buf), - ) - if variant == 7: - return BoltzError.InvalidInput( - _UniffiConverterString.read(buf), - ) - if variant == 8: - return BoltzError.SerializationError( - _UniffiConverterString.read(buf), - ) - if variant == 9: - return BoltzError.NotFound( - _UniffiConverterString.read(buf), - ) + return ActivityType.LIGHTNING raise InternalError("Raw enum value doesn't match any cases") @staticmethod def check_lower(value): - if isinstance(value, BoltzError.InitializationError): - _UniffiConverterString.check_lower(value.error_details) - return - if isinstance(value, BoltzError.ConnectionError): - _UniffiConverterString.check_lower(value.error_details) - return - if isinstance(value, BoltzError.DatabaseError): - _UniffiConverterString.check_lower(value.error_details) - return - if isinstance(value, BoltzError.ApiError): - _UniffiConverterString.check_lower(value.error_details) - return - if isinstance(value, BoltzError.SwapError): - _UniffiConverterString.check_lower(value.error_details) + if value == ActivityType.ONCHAIN: return - if isinstance(value, BoltzError.BroadcastError): - _UniffiConverterString.check_lower(value.error_details) + if value == ActivityType.LIGHTNING: return - if isinstance(value, BoltzError.InvalidInput): - _UniffiConverterString.check_lower(value.error_details) + raise ValueError(value) + + @staticmethod + def write(value, buf): + if value == ActivityType.ONCHAIN: + buf.write_i32(1) + if value == ActivityType.LIGHTNING: + buf.write_i32(2) + + + + +# AddressError +# We want to define each variant as a nested class that's also a subclass, +# which is tricky in Python. To accomplish this we're going to create each +# class separately, then manually add the child classes to the base class's +# __dict__. All of this happens in dummy class to avoid polluting the module +# namespace. +class AddressError(Exception): + pass + +_UniffiTempAddressError = AddressError + +class AddressError: # type: ignore + class InvalidAddress(_UniffiTempAddressError): + def __init__(self): + pass + + def __repr__(self): + return "AddressError.InvalidAddress({})".format(str(self)) + _UniffiTempAddressError.InvalidAddress = InvalidAddress # type: ignore + class InvalidNetwork(_UniffiTempAddressError): + def __init__(self): + pass + + def __repr__(self): + return "AddressError.InvalidNetwork({})".format(str(self)) + _UniffiTempAddressError.InvalidNetwork = InvalidNetwork # type: ignore + class MnemonicGenerationFailed(_UniffiTempAddressError): + def __init__(self): + pass + + def __repr__(self): + return "AddressError.MnemonicGenerationFailed({})".format(str(self)) + _UniffiTempAddressError.MnemonicGenerationFailed = MnemonicGenerationFailed # type: ignore + class InvalidMnemonic(_UniffiTempAddressError): + def __init__(self): + pass + + def __repr__(self): + return "AddressError.InvalidMnemonic({})".format(str(self)) + _UniffiTempAddressError.InvalidMnemonic = InvalidMnemonic # type: ignore + class InvalidEntropy(_UniffiTempAddressError): + def __init__(self): + pass + + def __repr__(self): + return "AddressError.InvalidEntropy({})".format(str(self)) + _UniffiTempAddressError.InvalidEntropy = InvalidEntropy # type: ignore + class AddressDerivationFailed(_UniffiTempAddressError): + def __init__(self): + pass + + def __repr__(self): + return "AddressError.AddressDerivationFailed({})".format(str(self)) + _UniffiTempAddressError.AddressDerivationFailed = AddressDerivationFailed # type: ignore + +AddressError = _UniffiTempAddressError # type: ignore +del _UniffiTempAddressError + + +class _UniffiConverterTypeAddressError(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + variant = buf.read_i32() + if variant == 1: + return AddressError.InvalidAddress( + ) + if variant == 2: + return AddressError.InvalidNetwork( + ) + if variant == 3: + return AddressError.MnemonicGenerationFailed( + ) + if variant == 4: + return AddressError.InvalidMnemonic( + ) + if variant == 5: + return AddressError.InvalidEntropy( + ) + if variant == 6: + return AddressError.AddressDerivationFailed( + ) + raise InternalError("Raw enum value doesn't match any cases") + + @staticmethod + def check_lower(value): + if isinstance(value, AddressError.InvalidAddress): return - if isinstance(value, BoltzError.SerializationError): - _UniffiConverterString.check_lower(value.error_details) + if isinstance(value, AddressError.InvalidNetwork): return - if isinstance(value, BoltzError.NotFound): - _UniffiConverterString.check_lower(value.error_details) + if isinstance(value, AddressError.MnemonicGenerationFailed): + return + if isinstance(value, AddressError.InvalidMnemonic): + return + if isinstance(value, AddressError.InvalidEntropy): + return + if isinstance(value, AddressError.AddressDerivationFailed): return @staticmethod def write(value, buf): - if isinstance(value, BoltzError.InitializationError): + if isinstance(value, AddressError.InvalidAddress): buf.write_i32(1) - _UniffiConverterString.write(value.error_details, buf) - if isinstance(value, BoltzError.ConnectionError): + if isinstance(value, AddressError.InvalidNetwork): buf.write_i32(2) - _UniffiConverterString.write(value.error_details, buf) - if isinstance(value, BoltzError.DatabaseError): + if isinstance(value, AddressError.MnemonicGenerationFailed): buf.write_i32(3) - _UniffiConverterString.write(value.error_details, buf) - if isinstance(value, BoltzError.ApiError): + if isinstance(value, AddressError.InvalidMnemonic): buf.write_i32(4) - _UniffiConverterString.write(value.error_details, buf) - if isinstance(value, BoltzError.SwapError): + if isinstance(value, AddressError.InvalidEntropy): buf.write_i32(5) - _UniffiConverterString.write(value.error_details, buf) - if isinstance(value, BoltzError.BroadcastError): + if isinstance(value, AddressError.AddressDerivationFailed): buf.write_i32(6) - _UniffiConverterString.write(value.error_details, buf) - if isinstance(value, BoltzError.InvalidInput): - buf.write_i32(7) - _UniffiConverterString.write(value.error_details, buf) - if isinstance(value, BoltzError.SerializationError): - buf.write_i32(8) - _UniffiConverterString.write(value.error_details, buf) - if isinstance(value, BoltzError.NotFound): - buf.write_i32(9) - _UniffiConverterString.write(value.error_details, buf) - -class BoltzNetwork(enum.Enum): - """ - Bitcoin network selection for Boltz swaps. Maps to the networks Boltz - operates on (mainnet, testnet, regtest). - """ - MAINNET = 0 +class AddressType(enum.Enum): + P2PKH = 0 - TESTNET = 1 + P2SH = 1 - REGTEST = 2 + P2WPKH = 2 + + P2WSH = 3 + + P2TR = 4 + + UNKNOWN = 5 -class _UniffiConverterTypeBoltzNetwork(_UniffiConverterRustBuffer): +class _UniffiConverterTypeAddressType(_UniffiConverterRustBuffer): @staticmethod def read(buf): variant = buf.read_i32() if variant == 1: - return BoltzNetwork.MAINNET + return AddressType.P2PKH if variant == 2: - return BoltzNetwork.TESTNET + return AddressType.P2SH if variant == 3: - return BoltzNetwork.REGTEST + return AddressType.P2WPKH + if variant == 4: + return AddressType.P2WSH + if variant == 5: + return AddressType.P2TR + if variant == 6: + return AddressType.UNKNOWN raise InternalError("Raw enum value doesn't match any cases") @staticmethod def check_lower(value): - if value == BoltzNetwork.MAINNET: + if value == AddressType.P2PKH: return - if value == BoltzNetwork.TESTNET: + if value == AddressType.P2SH: return - if value == BoltzNetwork.REGTEST: + if value == AddressType.P2WPKH: + return + if value == AddressType.P2WSH: + return + if value == AddressType.P2TR: + return + if value == AddressType.UNKNOWN: return raise ValueError(value) @staticmethod def write(value, buf): - if value == BoltzNetwork.MAINNET: + if value == AddressType.P2PKH: buf.write_i32(1) - if value == BoltzNetwork.TESTNET: + if value == AddressType.P2SH: buf.write_i32(2) - if value == BoltzNetwork.REGTEST: + if value == AddressType.P2WPKH: buf.write_i32(3) + if value == AddressType.P2WSH: + buf.write_i32(4) + if value == AddressType.P2TR: + buf.write_i32(5) + if value == AddressType.UNKNOWN: + buf.write_i32(6) @@ -12796,346 +12987,964 @@ def write(value, buf): -class BoltzSwapEvent: - """ - Events emitted to a registered [`crate::modules::boltz::BoltzEventListener`] - as swaps progress through their lifecycle. - """ +class BitcoinNetworkEnum(enum.Enum): + MAINNET = 0 + + TESTNET = 1 + + SIGNET = 2 + + REGTEST = 3 + - def __init__(self): - raise RuntimeError("BoltzSwapEvent cannot be instantiated directly") - # Each enum variant is a nested class of the enum itself. - class STATUS_UPDATE: - """ - The swap transitioned to a new status. - """ +class _UniffiConverterTypeBitcoinNetworkEnum(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + variant = buf.read_i32() + if variant == 1: + return BitcoinNetworkEnum.MAINNET + if variant == 2: + return BitcoinNetworkEnum.TESTNET + if variant == 3: + return BitcoinNetworkEnum.SIGNET + if variant == 4: + return BitcoinNetworkEnum.REGTEST + raise InternalError("Raw enum value doesn't match any cases") - swap_id: "str" - status: "BoltzSwapStatus" + @staticmethod + def check_lower(value): + if value == BitcoinNetworkEnum.MAINNET: + return + if value == BitcoinNetworkEnum.TESTNET: + return + if value == BitcoinNetworkEnum.SIGNET: + return + if value == BitcoinNetworkEnum.REGTEST: + return + raise ValueError(value) - def __init__(self,swap_id: "str", status: "BoltzSwapStatus"): - self.swap_id = swap_id - self.status = status + @staticmethod + def write(value, buf): + if value == BitcoinNetworkEnum.MAINNET: + buf.write_i32(1) + if value == BitcoinNetworkEnum.TESTNET: + buf.write_i32(2) + if value == BitcoinNetworkEnum.SIGNET: + buf.write_i32(3) + if value == BitcoinNetworkEnum.REGTEST: + buf.write_i32(4) - def __str__(self): - return "BoltzSwapEvent.STATUS_UPDATE(swap_id={}, status={})".format(self.swap_id, self.status) - def __eq__(self, other): - if not other.is_STATUS_UPDATE(): - return False - if self.swap_id != other.swap_id: - return False - if self.status != other.status: - return False - return True - - class CLAIMED: - """ - A reverse swap was claimed onchain. `txid` is the claim transaction. - """ - swap_id: "str" - txid: "str" - def __init__(self,swap_id: "str", txid: "str"): - self.swap_id = swap_id - self.txid = txid +# BlocktankError +# We want to define each variant as a nested class that's also a subclass, +# which is tricky in Python. To accomplish this we're going to create each +# class separately, then manually add the child classes to the base class's +# __dict__. All of this happens in dummy class to avoid polluting the module +# namespace. +class BlocktankError(Exception): + pass - def __str__(self): - return "BoltzSwapEvent.CLAIMED(swap_id={}, txid={})".format(self.swap_id, self.txid) +_UniffiTempBlocktankError = BlocktankError - def __eq__(self, other): - if not other.is_CLAIMED(): - return False - if self.swap_id != other.swap_id: - return False - if self.txid != other.txid: - return False - return True - - class REFUNDED: - """ - A submarine swap was refunded onchain. `txid` is the refund transaction. - """ +class BlocktankError: # type: ignore + class HttpClient(_UniffiTempBlocktankError): + def __init__(self, error_details): + super().__init__(", ".join([ + "error_details={!r}".format(error_details), + ])) + self.error_details = error_details - swap_id: "str" - txid: "str" + def __repr__(self): + return "BlocktankError.HttpClient({})".format(str(self)) + _UniffiTempBlocktankError.HttpClient = HttpClient # type: ignore + class BlocktankClient(_UniffiTempBlocktankError): + def __init__(self, error_details): + super().__init__(", ".join([ + "error_details={!r}".format(error_details), + ])) + self.error_details = error_details - def __init__(self,swap_id: "str", txid: "str"): - self.swap_id = swap_id - self.txid = txid + def __repr__(self): + return "BlocktankError.BlocktankClient({})".format(str(self)) + _UniffiTempBlocktankError.BlocktankClient = BlocktankClient # type: ignore + class InvalidBlocktank(_UniffiTempBlocktankError): + def __init__(self, error_details): + super().__init__(", ".join([ + "error_details={!r}".format(error_details), + ])) + self.error_details = error_details - def __str__(self): - return "BoltzSwapEvent.REFUNDED(swap_id={}, txid={})".format(self.swap_id, self.txid) + def __repr__(self): + return "BlocktankError.InvalidBlocktank({})".format(str(self)) + _UniffiTempBlocktankError.InvalidBlocktank = InvalidBlocktank # type: ignore + class InitializationError(_UniffiTempBlocktankError): + def __init__(self, error_details): + super().__init__(", ".join([ + "error_details={!r}".format(error_details), + ])) + self.error_details = error_details - def __eq__(self, other): - if not other.is_REFUNDED(): - return False - if self.swap_id != other.swap_id: - return False - if self.txid != other.txid: - return False - return True - - class ERROR: - """ - An error occurred while processing the swap (e.g. an auto-claim failed). - """ + def __repr__(self): + return "BlocktankError.InitializationError({})".format(str(self)) + _UniffiTempBlocktankError.InitializationError = InitializationError # type: ignore + class InsertError(_UniffiTempBlocktankError): + def __init__(self, error_details): + super().__init__(", ".join([ + "error_details={!r}".format(error_details), + ])) + self.error_details = error_details - swap_id: "str" - message: "str" + def __repr__(self): + return "BlocktankError.InsertError({})".format(str(self)) + _UniffiTempBlocktankError.InsertError = InsertError # type: ignore + class RetrievalError(_UniffiTempBlocktankError): + def __init__(self, error_details): + super().__init__(", ".join([ + "error_details={!r}".format(error_details), + ])) + self.error_details = error_details - def __init__(self,swap_id: "str", message: "str"): - self.swap_id = swap_id - self.message = message + def __repr__(self): + return "BlocktankError.RetrievalError({})".format(str(self)) + _UniffiTempBlocktankError.RetrievalError = RetrievalError # type: ignore + class DataError(_UniffiTempBlocktankError): + def __init__(self, error_details): + super().__init__(", ".join([ + "error_details={!r}".format(error_details), + ])) + self.error_details = error_details - def __str__(self): - return "BoltzSwapEvent.ERROR(swap_id={}, message={})".format(self.swap_id, self.message) + def __repr__(self): + return "BlocktankError.DataError({})".format(str(self)) + _UniffiTempBlocktankError.DataError = DataError # type: ignore + class ConnectionError(_UniffiTempBlocktankError): + def __init__(self, error_details): + super().__init__(", ".join([ + "error_details={!r}".format(error_details), + ])) + self.error_details = error_details - def __eq__(self, other): - if not other.is_ERROR(): - return False - if self.swap_id != other.swap_id: - return False - if self.message != other.message: - return False - return True - - + def __repr__(self): + return "BlocktankError.ConnectionError({})".format(str(self)) + _UniffiTempBlocktankError.ConnectionError = ConnectionError # type: ignore + class SerializationError(_UniffiTempBlocktankError): + def __init__(self, error_details): + super().__init__(", ".join([ + "error_details={!r}".format(error_details), + ])) + self.error_details = error_details - # For each variant, we have `is_NAME` and `is_name` methods for easily checking - # whether an instance is that variant. - def is_STATUS_UPDATE(self) -> bool: - return isinstance(self, BoltzSwapEvent.STATUS_UPDATE) - def is_status_update(self) -> bool: - return isinstance(self, BoltzSwapEvent.STATUS_UPDATE) - def is_CLAIMED(self) -> bool: - return isinstance(self, BoltzSwapEvent.CLAIMED) - def is_claimed(self) -> bool: - return isinstance(self, BoltzSwapEvent.CLAIMED) - def is_REFUNDED(self) -> bool: - return isinstance(self, BoltzSwapEvent.REFUNDED) - def is_refunded(self) -> bool: - return isinstance(self, BoltzSwapEvent.REFUNDED) - def is_ERROR(self) -> bool: - return isinstance(self, BoltzSwapEvent.ERROR) - def is_error(self) -> bool: - return isinstance(self, BoltzSwapEvent.ERROR) - + def __repr__(self): + return "BlocktankError.SerializationError({})".format(str(self)) + _UniffiTempBlocktankError.SerializationError = SerializationError # type: ignore + class ChannelOpen(_UniffiTempBlocktankError): + def __init__(self, error_type, error_details): + super().__init__(", ".join([ + "error_type={!r}".format(error_type), + "error_details={!r}".format(error_details), + ])) + self.error_type = error_type + self.error_details = error_details -# Now, a little trick - we make each nested variant class be a subclass of the main -# enum class, so that method calls and instance checks etc will work intuitively. -# We might be able to do this a little more neatly with a metaclass, but this'll do. -BoltzSwapEvent.STATUS_UPDATE = type("BoltzSwapEvent.STATUS_UPDATE", (BoltzSwapEvent.STATUS_UPDATE, BoltzSwapEvent,), {}) # type: ignore -BoltzSwapEvent.CLAIMED = type("BoltzSwapEvent.CLAIMED", (BoltzSwapEvent.CLAIMED, BoltzSwapEvent,), {}) # type: ignore -BoltzSwapEvent.REFUNDED = type("BoltzSwapEvent.REFUNDED", (BoltzSwapEvent.REFUNDED, BoltzSwapEvent,), {}) # type: ignore -BoltzSwapEvent.ERROR = type("BoltzSwapEvent.ERROR", (BoltzSwapEvent.ERROR, BoltzSwapEvent,), {}) # type: ignore + def __repr__(self): + return "BlocktankError.ChannelOpen({})".format(str(self)) + _UniffiTempBlocktankError.ChannelOpen = ChannelOpen # type: ignore + class OrderState(_UniffiTempBlocktankError): + def __init__(self, error_details): + super().__init__(", ".join([ + "error_details={!r}".format(error_details), + ])) + self.error_details = error_details + + def __repr__(self): + return "BlocktankError.OrderState({})".format(str(self)) + _UniffiTempBlocktankError.OrderState = OrderState # type: ignore + class InvalidParameter(_UniffiTempBlocktankError): + def __init__(self, error_details): + super().__init__(", ".join([ + "error_details={!r}".format(error_details), + ])) + self.error_details = error_details + + def __repr__(self): + return "BlocktankError.InvalidParameter({})".format(str(self)) + _UniffiTempBlocktankError.InvalidParameter = InvalidParameter # type: ignore + class DatabaseError(_UniffiTempBlocktankError): + def __init__(self, error_details): + super().__init__(", ".join([ + "error_details={!r}".format(error_details), + ])) + self.error_details = error_details + def __repr__(self): + return "BlocktankError.DatabaseError({})".format(str(self)) + _UniffiTempBlocktankError.DatabaseError = DatabaseError # type: ignore +BlocktankError = _UniffiTempBlocktankError # type: ignore +del _UniffiTempBlocktankError -class _UniffiConverterTypeBoltzSwapEvent(_UniffiConverterRustBuffer): +class _UniffiConverterTypeBlocktankError(_UniffiConverterRustBuffer): @staticmethod def read(buf): variant = buf.read_i32() if variant == 1: - return BoltzSwapEvent.STATUS_UPDATE( + return BlocktankError.HttpClient( _UniffiConverterString.read(buf), - _UniffiConverterTypeBoltzSwapStatus.read(buf), ) if variant == 2: - return BoltzSwapEvent.CLAIMED( - _UniffiConverterString.read(buf), + return BlocktankError.BlocktankClient( _UniffiConverterString.read(buf), ) if variant == 3: - return BoltzSwapEvent.REFUNDED( - _UniffiConverterString.read(buf), + return BlocktankError.InvalidBlocktank( _UniffiConverterString.read(buf), ) if variant == 4: - return BoltzSwapEvent.ERROR( + return BlocktankError.InitializationError( _UniffiConverterString.read(buf), + ) + if variant == 5: + return BlocktankError.InsertError( _UniffiConverterString.read(buf), ) - raise InternalError("Raw enum value doesn't match any cases") - - @staticmethod - def check_lower(value): - if value.is_STATUS_UPDATE(): - _UniffiConverterString.check_lower(value.swap_id) - _UniffiConverterTypeBoltzSwapStatus.check_lower(value.status) - return - if value.is_CLAIMED(): - _UniffiConverterString.check_lower(value.swap_id) - _UniffiConverterString.check_lower(value.txid) + if variant == 6: + return BlocktankError.RetrievalError( + _UniffiConverterString.read(buf), + ) + if variant == 7: + return BlocktankError.DataError( + _UniffiConverterString.read(buf), + ) + if variant == 8: + return BlocktankError.ConnectionError( + _UniffiConverterString.read(buf), + ) + if variant == 9: + return BlocktankError.SerializationError( + _UniffiConverterString.read(buf), + ) + if variant == 10: + return BlocktankError.ChannelOpen( + _UniffiConverterTypeBtChannelOrderErrorType.read(buf), + _UniffiConverterString.read(buf), + ) + if variant == 11: + return BlocktankError.OrderState( + _UniffiConverterString.read(buf), + ) + if variant == 12: + return BlocktankError.InvalidParameter( + _UniffiConverterString.read(buf), + ) + if variant == 13: + return BlocktankError.DatabaseError( + _UniffiConverterString.read(buf), + ) + raise InternalError("Raw enum value doesn't match any cases") + + @staticmethod + def check_lower(value): + if isinstance(value, BlocktankError.HttpClient): + _UniffiConverterString.check_lower(value.error_details) return - if value.is_REFUNDED(): - _UniffiConverterString.check_lower(value.swap_id) - _UniffiConverterString.check_lower(value.txid) + if isinstance(value, BlocktankError.BlocktankClient): + _UniffiConverterString.check_lower(value.error_details) return - if value.is_ERROR(): - _UniffiConverterString.check_lower(value.swap_id) - _UniffiConverterString.check_lower(value.message) + if isinstance(value, BlocktankError.InvalidBlocktank): + _UniffiConverterString.check_lower(value.error_details) + return + if isinstance(value, BlocktankError.InitializationError): + _UniffiConverterString.check_lower(value.error_details) + return + if isinstance(value, BlocktankError.InsertError): + _UniffiConverterString.check_lower(value.error_details) + return + if isinstance(value, BlocktankError.RetrievalError): + _UniffiConverterString.check_lower(value.error_details) + return + if isinstance(value, BlocktankError.DataError): + _UniffiConverterString.check_lower(value.error_details) + return + if isinstance(value, BlocktankError.ConnectionError): + _UniffiConverterString.check_lower(value.error_details) + return + if isinstance(value, BlocktankError.SerializationError): + _UniffiConverterString.check_lower(value.error_details) + return + if isinstance(value, BlocktankError.ChannelOpen): + _UniffiConverterTypeBtChannelOrderErrorType.check_lower(value.error_type) + _UniffiConverterString.check_lower(value.error_details) + return + if isinstance(value, BlocktankError.OrderState): + _UniffiConverterString.check_lower(value.error_details) + return + if isinstance(value, BlocktankError.InvalidParameter): + _UniffiConverterString.check_lower(value.error_details) + return + if isinstance(value, BlocktankError.DatabaseError): + _UniffiConverterString.check_lower(value.error_details) return - raise ValueError(value) @staticmethod def write(value, buf): - if value.is_STATUS_UPDATE(): + if isinstance(value, BlocktankError.HttpClient): buf.write_i32(1) - _UniffiConverterString.write(value.swap_id, buf) - _UniffiConverterTypeBoltzSwapStatus.write(value.status, buf) - if value.is_CLAIMED(): + _UniffiConverterString.write(value.error_details, buf) + if isinstance(value, BlocktankError.BlocktankClient): buf.write_i32(2) - _UniffiConverterString.write(value.swap_id, buf) - _UniffiConverterString.write(value.txid, buf) - if value.is_REFUNDED(): + _UniffiConverterString.write(value.error_details, buf) + if isinstance(value, BlocktankError.InvalidBlocktank): buf.write_i32(3) - _UniffiConverterString.write(value.swap_id, buf) - _UniffiConverterString.write(value.txid, buf) - if value.is_ERROR(): + _UniffiConverterString.write(value.error_details, buf) + if isinstance(value, BlocktankError.InitializationError): buf.write_i32(4) - _UniffiConverterString.write(value.swap_id, buf) - _UniffiConverterString.write(value.message, buf) - - + _UniffiConverterString.write(value.error_details, buf) + if isinstance(value, BlocktankError.InsertError): + buf.write_i32(5) + _UniffiConverterString.write(value.error_details, buf) + if isinstance(value, BlocktankError.RetrievalError): + buf.write_i32(6) + _UniffiConverterString.write(value.error_details, buf) + if isinstance(value, BlocktankError.DataError): + buf.write_i32(7) + _UniffiConverterString.write(value.error_details, buf) + if isinstance(value, BlocktankError.ConnectionError): + buf.write_i32(8) + _UniffiConverterString.write(value.error_details, buf) + if isinstance(value, BlocktankError.SerializationError): + buf.write_i32(9) + _UniffiConverterString.write(value.error_details, buf) + if isinstance(value, BlocktankError.ChannelOpen): + buf.write_i32(10) + _UniffiConverterTypeBtChannelOrderErrorType.write(value.error_type, buf) + _UniffiConverterString.write(value.error_details, buf) + if isinstance(value, BlocktankError.OrderState): + buf.write_i32(11) + _UniffiConverterString.write(value.error_details, buf) + if isinstance(value, BlocktankError.InvalidParameter): + buf.write_i32(12) + _UniffiConverterString.write(value.error_details, buf) + if isinstance(value, BlocktankError.DatabaseError): + buf.write_i32(13) + _UniffiConverterString.write(value.error_details, buf) +# BoltzError +# We want to define each variant as a nested class that's also a subclass, +# which is tricky in Python. To accomplish this we're going to create each +# class separately, then manually add the child classes to the base class's +# __dict__. All of this happens in dummy class to avoid polluting the module +# namespace. +class BoltzError(Exception): + """ + Errors surfaced by the Boltz swaps module. + """ + pass +_UniffiTempBoltzError = BoltzError -class BoltzSwapStatus: +class BoltzError: # type: ignore """ - Typed view of the Boltz swap lifecycle. `Unknown` carries the raw status so - new server-side states don't break the bindings. - - See . + Errors surfaced by the Boltz swaps module. """ - def __init__(self): - raise RuntimeError("BoltzSwapStatus cannot be instantiated directly") + class InitializationError(_UniffiTempBoltzError): + def __init__(self, error_details): + super().__init__(", ".join([ + "error_details={!r}".format(error_details), + ])) + self.error_details = error_details - # Each enum variant is a nested class of the enum itself. - class SWAP_CREATED: - """ - `swap.created` — initial state. - """ + def __repr__(self): + return "BoltzError.InitializationError({})".format(str(self)) + _UniffiTempBoltzError.InitializationError = InitializationError # type: ignore + class ConnectionError(_UniffiTempBoltzError): + def __init__(self, error_details): + super().__init__(", ".join([ + "error_details={!r}".format(error_details), + ])) + self.error_details = error_details + def __repr__(self): + return "BoltzError.ConnectionError({})".format(str(self)) + _UniffiTempBoltzError.ConnectionError = ConnectionError # type: ignore + class DatabaseError(_UniffiTempBoltzError): + def __init__(self, error_details): + super().__init__(", ".join([ + "error_details={!r}".format(error_details), + ])) + self.error_details = error_details - def __init__(self,): - pass + def __repr__(self): + return "BoltzError.DatabaseError({})".format(str(self)) + _UniffiTempBoltzError.DatabaseError = DatabaseError # type: ignore + class ApiError(_UniffiTempBoltzError): + def __init__(self, error_details): + super().__init__(", ".join([ + "error_details={!r}".format(error_details), + ])) + self.error_details = error_details - def __str__(self): - return "BoltzSwapStatus.SWAP_CREATED()".format() + def __repr__(self): + return "BoltzError.ApiError({})".format(str(self)) + _UniffiTempBoltzError.ApiError = ApiError # type: ignore + class SwapError(_UniffiTempBoltzError): + def __init__(self, error_details): + super().__init__(", ".join([ + "error_details={!r}".format(error_details), + ])) + self.error_details = error_details - def __eq__(self, other): - if not other.is_SWAP_CREATED(): - return False - return True - - class INVOICE_SET: - """ - `invoice.set` — invoice attached to a submarine swap. - """ + def __repr__(self): + return "BoltzError.SwapError({})".format(str(self)) + _UniffiTempBoltzError.SwapError = SwapError # type: ignore + class BroadcastError(_UniffiTempBoltzError): + def __init__(self, error_details): + super().__init__(", ".join([ + "error_details={!r}".format(error_details), + ])) + self.error_details = error_details + def __repr__(self): + return "BoltzError.BroadcastError({})".format(str(self)) + _UniffiTempBoltzError.BroadcastError = BroadcastError # type: ignore + class InvalidInput(_UniffiTempBoltzError): + def __init__(self, error_details): + super().__init__(", ".join([ + "error_details={!r}".format(error_details), + ])) + self.error_details = error_details - def __init__(self,): - pass + def __repr__(self): + return "BoltzError.InvalidInput({})".format(str(self)) + _UniffiTempBoltzError.InvalidInput = InvalidInput # type: ignore + class SerializationError(_UniffiTempBoltzError): + def __init__(self, error_details): + super().__init__(", ".join([ + "error_details={!r}".format(error_details), + ])) + self.error_details = error_details - def __str__(self): - return "BoltzSwapStatus.INVOICE_SET()".format() + def __repr__(self): + return "BoltzError.SerializationError({})".format(str(self)) + _UniffiTempBoltzError.SerializationError = SerializationError # type: ignore + class NotFound(_UniffiTempBoltzError): + def __init__(self, error_details): + super().__init__(", ".join([ + "error_details={!r}".format(error_details), + ])) + self.error_details = error_details - def __eq__(self, other): - if not other.is_INVOICE_SET(): - return False - return True - - class TRANSACTION_MEMPOOL: - """ - `transaction.mempool` — a lockup transaction is in the mempool. - """ + def __repr__(self): + return "BoltzError.NotFound({})".format(str(self)) + _UniffiTempBoltzError.NotFound = NotFound # type: ignore +BoltzError = _UniffiTempBoltzError # type: ignore +del _UniffiTempBoltzError - def __init__(self,): - pass - def __str__(self): - return "BoltzSwapStatus.TRANSACTION_MEMPOOL()".format() +class _UniffiConverterTypeBoltzError(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + variant = buf.read_i32() + if variant == 1: + return BoltzError.InitializationError( + _UniffiConverterString.read(buf), + ) + if variant == 2: + return BoltzError.ConnectionError( + _UniffiConverterString.read(buf), + ) + if variant == 3: + return BoltzError.DatabaseError( + _UniffiConverterString.read(buf), + ) + if variant == 4: + return BoltzError.ApiError( + _UniffiConverterString.read(buf), + ) + if variant == 5: + return BoltzError.SwapError( + _UniffiConverterString.read(buf), + ) + if variant == 6: + return BoltzError.BroadcastError( + _UniffiConverterString.read(buf), + ) + if variant == 7: + return BoltzError.InvalidInput( + _UniffiConverterString.read(buf), + ) + if variant == 8: + return BoltzError.SerializationError( + _UniffiConverterString.read(buf), + ) + if variant == 9: + return BoltzError.NotFound( + _UniffiConverterString.read(buf), + ) + raise InternalError("Raw enum value doesn't match any cases") - def __eq__(self, other): - if not other.is_TRANSACTION_MEMPOOL(): - return False - return True + @staticmethod + def check_lower(value): + if isinstance(value, BoltzError.InitializationError): + _UniffiConverterString.check_lower(value.error_details) + return + if isinstance(value, BoltzError.ConnectionError): + _UniffiConverterString.check_lower(value.error_details) + return + if isinstance(value, BoltzError.DatabaseError): + _UniffiConverterString.check_lower(value.error_details) + return + if isinstance(value, BoltzError.ApiError): + _UniffiConverterString.check_lower(value.error_details) + return + if isinstance(value, BoltzError.SwapError): + _UniffiConverterString.check_lower(value.error_details) + return + if isinstance(value, BoltzError.BroadcastError): + _UniffiConverterString.check_lower(value.error_details) + return + if isinstance(value, BoltzError.InvalidInput): + _UniffiConverterString.check_lower(value.error_details) + return + if isinstance(value, BoltzError.SerializationError): + _UniffiConverterString.check_lower(value.error_details) + return + if isinstance(value, BoltzError.NotFound): + _UniffiConverterString.check_lower(value.error_details) + return + + @staticmethod + def write(value, buf): + if isinstance(value, BoltzError.InitializationError): + buf.write_i32(1) + _UniffiConverterString.write(value.error_details, buf) + if isinstance(value, BoltzError.ConnectionError): + buf.write_i32(2) + _UniffiConverterString.write(value.error_details, buf) + if isinstance(value, BoltzError.DatabaseError): + buf.write_i32(3) + _UniffiConverterString.write(value.error_details, buf) + if isinstance(value, BoltzError.ApiError): + buf.write_i32(4) + _UniffiConverterString.write(value.error_details, buf) + if isinstance(value, BoltzError.SwapError): + buf.write_i32(5) + _UniffiConverterString.write(value.error_details, buf) + if isinstance(value, BoltzError.BroadcastError): + buf.write_i32(6) + _UniffiConverterString.write(value.error_details, buf) + if isinstance(value, BoltzError.InvalidInput): + buf.write_i32(7) + _UniffiConverterString.write(value.error_details, buf) + if isinstance(value, BoltzError.SerializationError): + buf.write_i32(8) + _UniffiConverterString.write(value.error_details, buf) + if isinstance(value, BoltzError.NotFound): + buf.write_i32(9) + _UniffiConverterString.write(value.error_details, buf) + + + + + +class BoltzNetwork(enum.Enum): + """ + Bitcoin network selection for Boltz swaps. Maps to the networks Boltz + operates on (mainnet, testnet, regtest). + """ + + MAINNET = 0 - class TRANSACTION_CONFIRMED: + TESTNET = 1 + + REGTEST = 2 + + + +class _UniffiConverterTypeBoltzNetwork(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + variant = buf.read_i32() + if variant == 1: + return BoltzNetwork.MAINNET + if variant == 2: + return BoltzNetwork.TESTNET + if variant == 3: + return BoltzNetwork.REGTEST + raise InternalError("Raw enum value doesn't match any cases") + + @staticmethod + def check_lower(value): + if value == BoltzNetwork.MAINNET: + return + if value == BoltzNetwork.TESTNET: + return + if value == BoltzNetwork.REGTEST: + return + raise ValueError(value) + + @staticmethod + def write(value, buf): + if value == BoltzNetwork.MAINNET: + buf.write_i32(1) + if value == BoltzNetwork.TESTNET: + buf.write_i32(2) + if value == BoltzNetwork.REGTEST: + buf.write_i32(3) + + + + + + + +class BoltzSwapEvent: + """ + Events emitted to a registered [`crate::modules::boltz::BoltzEventListener`] + as swaps progress through their lifecycle. + """ + + def __init__(self): + raise RuntimeError("BoltzSwapEvent cannot be instantiated directly") + + # Each enum variant is a nested class of the enum itself. + class STATUS_UPDATE: """ - `transaction.confirmed` — a lockup transaction confirmed. + The swap transitioned to a new status. """ + swap_id: "str" + status: "BoltzSwapStatus" - def __init__(self,): - pass + def __init__(self,swap_id: "str", status: "BoltzSwapStatus"): + self.swap_id = swap_id + self.status = status def __str__(self): - return "BoltzSwapStatus.TRANSACTION_CONFIRMED()".format() + return "BoltzSwapEvent.STATUS_UPDATE(swap_id={}, status={})".format(self.swap_id, self.status) def __eq__(self, other): - if not other.is_TRANSACTION_CONFIRMED(): + if not other.is_STATUS_UPDATE(): + return False + if self.swap_id != other.swap_id: + return False + if self.status != other.status: return False return True - class INVOICE_PENDING: + class CLAIMED: """ - `invoice.pending` — Boltz is paying the submarine swap invoice. + A reverse swap was claimed onchain. `txid` is the claim transaction. """ + swap_id: "str" + txid: "str" - def __init__(self,): - pass + def __init__(self,swap_id: "str", txid: "str"): + self.swap_id = swap_id + self.txid = txid def __str__(self): - return "BoltzSwapStatus.INVOICE_PENDING()".format() + return "BoltzSwapEvent.CLAIMED(swap_id={}, txid={})".format(self.swap_id, self.txid) def __eq__(self, other): - if not other.is_INVOICE_PENDING(): + if not other.is_CLAIMED(): + return False + if self.swap_id != other.swap_id: + return False + if self.txid != other.txid: return False return True - class INVOICE_PAID: + class REFUNDED: """ - `invoice.paid` — submarine swap invoice paid by Boltz. + A submarine swap was refunded onchain. `txid` is the refund transaction. """ + swap_id: "str" + txid: "str" - def __init__(self,): - pass + def __init__(self,swap_id: "str", txid: "str"): + self.swap_id = swap_id + self.txid = txid def __str__(self): - return "BoltzSwapStatus.INVOICE_PAID()".format() + return "BoltzSwapEvent.REFUNDED(swap_id={}, txid={})".format(self.swap_id, self.txid) def __eq__(self, other): - if not other.is_INVOICE_PAID(): + if not other.is_REFUNDED(): + return False + if self.swap_id != other.swap_id: + return False + if self.txid != other.txid: return False return True - class INVOICE_SETTLED: + class ERROR: """ - `invoice.settled` — reverse swap invoice settled (preimage revealed). + An error occurred while processing the swap (e.g. an auto-claim failed). """ + swap_id: "str" + message: "str" - def __init__(self,): - pass + def __init__(self,swap_id: "str", message: "str"): + self.swap_id = swap_id + self.message = message def __str__(self): - return "BoltzSwapStatus.INVOICE_SETTLED()".format() + return "BoltzSwapEvent.ERROR(swap_id={}, message={})".format(self.swap_id, self.message) def __eq__(self, other): - if not other.is_INVOICE_SETTLED(): + if not other.is_ERROR(): return False - return True + if self.swap_id != other.swap_id: + return False + if self.message != other.message: + return False + return True + + + + # For each variant, we have `is_NAME` and `is_name` methods for easily checking + # whether an instance is that variant. + def is_STATUS_UPDATE(self) -> bool: + return isinstance(self, BoltzSwapEvent.STATUS_UPDATE) + def is_status_update(self) -> bool: + return isinstance(self, BoltzSwapEvent.STATUS_UPDATE) + def is_CLAIMED(self) -> bool: + return isinstance(self, BoltzSwapEvent.CLAIMED) + def is_claimed(self) -> bool: + return isinstance(self, BoltzSwapEvent.CLAIMED) + def is_REFUNDED(self) -> bool: + return isinstance(self, BoltzSwapEvent.REFUNDED) + def is_refunded(self) -> bool: + return isinstance(self, BoltzSwapEvent.REFUNDED) + def is_ERROR(self) -> bool: + return isinstance(self, BoltzSwapEvent.ERROR) + def is_error(self) -> bool: + return isinstance(self, BoltzSwapEvent.ERROR) + + +# Now, a little trick - we make each nested variant class be a subclass of the main +# enum class, so that method calls and instance checks etc will work intuitively. +# We might be able to do this a little more neatly with a metaclass, but this'll do. +BoltzSwapEvent.STATUS_UPDATE = type("BoltzSwapEvent.STATUS_UPDATE", (BoltzSwapEvent.STATUS_UPDATE, BoltzSwapEvent,), {}) # type: ignore +BoltzSwapEvent.CLAIMED = type("BoltzSwapEvent.CLAIMED", (BoltzSwapEvent.CLAIMED, BoltzSwapEvent,), {}) # type: ignore +BoltzSwapEvent.REFUNDED = type("BoltzSwapEvent.REFUNDED", (BoltzSwapEvent.REFUNDED, BoltzSwapEvent,), {}) # type: ignore +BoltzSwapEvent.ERROR = type("BoltzSwapEvent.ERROR", (BoltzSwapEvent.ERROR, BoltzSwapEvent,), {}) # type: ignore + + + + +class _UniffiConverterTypeBoltzSwapEvent(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + variant = buf.read_i32() + if variant == 1: + return BoltzSwapEvent.STATUS_UPDATE( + _UniffiConverterString.read(buf), + _UniffiConverterTypeBoltzSwapStatus.read(buf), + ) + if variant == 2: + return BoltzSwapEvent.CLAIMED( + _UniffiConverterString.read(buf), + _UniffiConverterString.read(buf), + ) + if variant == 3: + return BoltzSwapEvent.REFUNDED( + _UniffiConverterString.read(buf), + _UniffiConverterString.read(buf), + ) + if variant == 4: + return BoltzSwapEvent.ERROR( + _UniffiConverterString.read(buf), + _UniffiConverterString.read(buf), + ) + raise InternalError("Raw enum value doesn't match any cases") + + @staticmethod + def check_lower(value): + if value.is_STATUS_UPDATE(): + _UniffiConverterString.check_lower(value.swap_id) + _UniffiConverterTypeBoltzSwapStatus.check_lower(value.status) + return + if value.is_CLAIMED(): + _UniffiConverterString.check_lower(value.swap_id) + _UniffiConverterString.check_lower(value.txid) + return + if value.is_REFUNDED(): + _UniffiConverterString.check_lower(value.swap_id) + _UniffiConverterString.check_lower(value.txid) + return + if value.is_ERROR(): + _UniffiConverterString.check_lower(value.swap_id) + _UniffiConverterString.check_lower(value.message) + return + raise ValueError(value) + + @staticmethod + def write(value, buf): + if value.is_STATUS_UPDATE(): + buf.write_i32(1) + _UniffiConverterString.write(value.swap_id, buf) + _UniffiConverterTypeBoltzSwapStatus.write(value.status, buf) + if value.is_CLAIMED(): + buf.write_i32(2) + _UniffiConverterString.write(value.swap_id, buf) + _UniffiConverterString.write(value.txid, buf) + if value.is_REFUNDED(): + buf.write_i32(3) + _UniffiConverterString.write(value.swap_id, buf) + _UniffiConverterString.write(value.txid, buf) + if value.is_ERROR(): + buf.write_i32(4) + _UniffiConverterString.write(value.swap_id, buf) + _UniffiConverterString.write(value.message, buf) + + + + + + + +class BoltzSwapStatus: + """ + Typed view of the Boltz swap lifecycle. `Unknown` carries the raw status so + new server-side states don't break the bindings. + + See . + """ + + def __init__(self): + raise RuntimeError("BoltzSwapStatus cannot be instantiated directly") + + # Each enum variant is a nested class of the enum itself. + class SWAP_CREATED: + """ + `swap.created` — initial state. + """ + + + def __init__(self,): + pass + + def __str__(self): + return "BoltzSwapStatus.SWAP_CREATED()".format() + + def __eq__(self, other): + if not other.is_SWAP_CREATED(): + return False + return True + + class INVOICE_SET: + """ + `invoice.set` — invoice attached to a submarine swap. + """ + + + def __init__(self,): + pass + + def __str__(self): + return "BoltzSwapStatus.INVOICE_SET()".format() + + def __eq__(self, other): + if not other.is_INVOICE_SET(): + return False + return True + + class TRANSACTION_MEMPOOL: + """ + `transaction.mempool` — a lockup transaction is in the mempool. + """ + + + def __init__(self,): + pass + + def __str__(self): + return "BoltzSwapStatus.TRANSACTION_MEMPOOL()".format() + + def __eq__(self, other): + if not other.is_TRANSACTION_MEMPOOL(): + return False + return True + + class TRANSACTION_CONFIRMED: + """ + `transaction.confirmed` — a lockup transaction confirmed. + """ + + + def __init__(self,): + pass + + def __str__(self): + return "BoltzSwapStatus.TRANSACTION_CONFIRMED()".format() + + def __eq__(self, other): + if not other.is_TRANSACTION_CONFIRMED(): + return False + return True + + class INVOICE_PENDING: + """ + `invoice.pending` — Boltz is paying the submarine swap invoice. + """ + + + def __init__(self,): + pass + + def __str__(self): + return "BoltzSwapStatus.INVOICE_PENDING()".format() + + def __eq__(self, other): + if not other.is_INVOICE_PENDING(): + return False + return True + + class INVOICE_PAID: + """ + `invoice.paid` — submarine swap invoice paid by Boltz. + """ + + + def __init__(self,): + pass + + def __str__(self): + return "BoltzSwapStatus.INVOICE_PAID()".format() + + def __eq__(self, other): + if not other.is_INVOICE_PAID(): + return False + return True + + class INVOICE_SETTLED: + """ + `invoice.settled` — reverse swap invoice settled (preimage revealed). + """ + + + def __init__(self,): + pass + + def __str__(self): + return "BoltzSwapStatus.INVOICE_SETTLED()".format() + + def __eq__(self, other): + if not other.is_INVOICE_SETTLED(): + return False + return True class INVOICE_FAILED_TO_PAY: """ @@ -14879,6 +15688,8 @@ class HardwareWalletVendor(enum.Enum): FOUNDATION = 1 + BLOCKSTREAM = 2 + class _UniffiConverterTypeHardwareWalletVendor(_UniffiConverterRustBuffer): @@ -14889,6 +15700,8 @@ def read(buf): return HardwareWalletVendor.TREZOR if variant == 2: return HardwareWalletVendor.FOUNDATION + if variant == 3: + return HardwareWalletVendor.BLOCKSTREAM raise InternalError("Raw enum value doesn't match any cases") @staticmethod @@ -14897,6 +15710,8 @@ def check_lower(value): return if value == HardwareWalletVendor.FOUNDATION: return + if value == HardwareWalletVendor.BLOCKSTREAM: + return raise ValueError(value) @staticmethod @@ -14905,65 +15720,134 @@ def write(value, buf): buf.write_i32(1) if value == HardwareWalletVendor.FOUNDATION: buf.write_i32(2) + if value == HardwareWalletVendor.BLOCKSTREAM: + buf.write_i32(3) -# LnurlError -# We want to define each variant as a nested class that's also a subclass, -# which is tricky in Python. To accomplish this we're going to create each -# class separately, then manually add the child classes to the base class's -# __dict__. All of this happens in dummy class to avoid polluting the module -# namespace. -class LnurlError(Exception): - pass -_UniffiTempLnurlError = LnurlError -class LnurlError: # type: ignore - class InvalidAddress(_UniffiTempLnurlError): - def __init__(self): + +class JadeAddressVariant(enum.Enum): + PKH = 0 + + WPKH = 1 + + SH_WPKH = 2 + + TR = 3 + + + +class _UniffiConverterTypeJadeAddressVariant(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + variant = buf.read_i32() + if variant == 1: + return JadeAddressVariant.PKH + if variant == 2: + return JadeAddressVariant.WPKH + if variant == 3: + return JadeAddressVariant.SH_WPKH + if variant == 4: + return JadeAddressVariant.TR + raise InternalError("Raw enum value doesn't match any cases") + + @staticmethod + def check_lower(value): + if value == JadeAddressVariant.PKH: + return + if value == JadeAddressVariant.WPKH: + return + if value == JadeAddressVariant.SH_WPKH: + return + if value == JadeAddressVariant.TR: + return + raise ValueError(value) + + @staticmethod + def write(value, buf): + if value == JadeAddressVariant.PKH: + buf.write_i32(1) + if value == JadeAddressVariant.WPKH: + buf.write_i32(2) + if value == JadeAddressVariant.SH_WPKH: + buf.write_i32(3) + if value == JadeAddressVariant.TR: + buf.write_i32(4) + + + + +# JadeError +# We want to define each variant as a nested class that's also a subclass, +# which is tricky in Python. To accomplish this we're going to create each +# class separately, then manually add the child classes to the base class's +# __dict__. All of this happens in dummy class to avoid polluting the module +# namespace. +class JadeError(Exception): + pass + +_UniffiTempJadeError = JadeError + +class JadeError: # type: ignore + class TransportError(_UniffiTempJadeError): + def __init__(self, error_details): + super().__init__(", ".join([ + "error_details={!r}".format(error_details), + ])) + self.error_details = error_details + + def __repr__(self): + return "JadeError.TransportError({})".format(str(self)) + _UniffiTempJadeError.TransportError = TransportError # type: ignore + class DeviceNotFound(_UniffiTempJadeError): + def __init__(self): pass def __repr__(self): - return "LnurlError.InvalidAddress({})".format(str(self)) - _UniffiTempLnurlError.InvalidAddress = InvalidAddress # type: ignore - class ClientCreationFailed(_UniffiTempLnurlError): + return "JadeError.DeviceNotFound({})".format(str(self)) + _UniffiTempJadeError.DeviceNotFound = DeviceNotFound # type: ignore + class DeviceDisconnected(_UniffiTempJadeError): def __init__(self): pass def __repr__(self): - return "LnurlError.ClientCreationFailed({})".format(str(self)) - _UniffiTempLnurlError.ClientCreationFailed = ClientCreationFailed # type: ignore - class RequestFailed(_UniffiTempLnurlError): + return "JadeError.DeviceDisconnected({})".format(str(self)) + _UniffiTempJadeError.DeviceDisconnected = DeviceDisconnected # type: ignore + class DeviceBusy(_UniffiTempJadeError): def __init__(self): pass def __repr__(self): - return "LnurlError.RequestFailed({})".format(str(self)) - _UniffiTempLnurlError.RequestFailed = RequestFailed # type: ignore - class InvalidResponse(_UniffiTempLnurlError): + return "JadeError.DeviceBusy({})".format(str(self)) + _UniffiTempJadeError.DeviceBusy = DeviceBusy # type: ignore + class NotConnected(_UniffiTempJadeError): def __init__(self): pass def __repr__(self): - return "LnurlError.InvalidResponse({})".format(str(self)) - _UniffiTempLnurlError.InvalidResponse = InvalidResponse # type: ignore - class InvalidAmount(_UniffiTempLnurlError): - def __init__(self, amount_satoshis, min, max): + return "JadeError.NotConnected({})".format(str(self)) + _UniffiTempJadeError.NotConnected = NotConnected # type: ignore + class NotInitialized(_UniffiTempJadeError): + def __init__(self): + pass + + def __repr__(self): + return "JadeError.NotInitialized({})".format(str(self)) + _UniffiTempJadeError.NotInitialized = NotInitialized # type: ignore + class ConnectionError(_UniffiTempJadeError): + def __init__(self, error_details): super().__init__(", ".join([ - "amount_satoshis={!r}".format(amount_satoshis), - "min={!r}".format(min), - "max={!r}".format(max), + "error_details={!r}".format(error_details), ])) - self.amount_satoshis = amount_satoshis - self.min = min - self.max = max + self.error_details = error_details def __repr__(self): - return "LnurlError.InvalidAmount({})".format(str(self)) - _UniffiTempLnurlError.InvalidAmount = InvalidAmount # type: ignore - class InvoiceCreationFailed(_UniffiTempLnurlError): + return "JadeError.ConnectionError({})".format(str(self)) + _UniffiTempJadeError.ConnectionError = ConnectionError # type: ignore + class ProtocolError(_UniffiTempJadeError): def __init__(self, error_details): super().__init__(", ".join([ "error_details={!r}".format(error_details), @@ -14971,169 +15855,437 @@ def __init__(self, error_details): self.error_details = error_details def __repr__(self): - return "LnurlError.InvoiceCreationFailed({})".format(str(self)) - _UniffiTempLnurlError.InvoiceCreationFailed = InvoiceCreationFailed # type: ignore - class AmountMismatch(_UniffiTempLnurlError): - def __init__(self, requested_msats, invoice_msats): + return "JadeError.ProtocolError({})".format(str(self)) + _UniffiTempJadeError.ProtocolError = ProtocolError # type: ignore + class Timeout(_UniffiTempJadeError): + def __init__(self): + pass + + def __repr__(self): + return "JadeError.Timeout({})".format(str(self)) + _UniffiTempJadeError.Timeout = Timeout # type: ignore + class UserCancelled(_UniffiTempJadeError): + def __init__(self): + pass + + def __repr__(self): + return "JadeError.UserCancelled({})".format(str(self)) + _UniffiTempJadeError.UserCancelled = UserCancelled # type: ignore + class DeviceLocked(_UniffiTempJadeError): + def __init__(self): + pass + + def __repr__(self): + return "JadeError.DeviceLocked({})".format(str(self)) + _UniffiTempJadeError.DeviceLocked = DeviceLocked # type: ignore + class DeviceUninitialized(_UniffiTempJadeError): + def __init__(self): + pass + + def __repr__(self): + return "JadeError.DeviceUninitialized({})".format(str(self)) + _UniffiTempJadeError.DeviceUninitialized = DeviceUninitialized # type: ignore + class InvalidPin(_UniffiTempJadeError): + def __init__(self): + pass + + def __repr__(self): + return "JadeError.InvalidPin({})".format(str(self)) + _UniffiTempJadeError.InvalidPin = InvalidPin # type: ignore + class NetworkMismatch(_UniffiTempJadeError): + def __init__(self, error_details): super().__init__(", ".join([ - "requested_msats={!r}".format(requested_msats), - "invoice_msats={!r}".format(invoice_msats), + "error_details={!r}".format(error_details), ])) - self.requested_msats = requested_msats - self.invoice_msats = invoice_msats + self.error_details = error_details def __repr__(self): - return "LnurlError.AmountMismatch({})".format(str(self)) - _UniffiTempLnurlError.AmountMismatch = AmountMismatch # type: ignore - class AuthenticationFailed(_UniffiTempLnurlError): + return "JadeError.NetworkMismatch({})".format(str(self)) + _UniffiTempJadeError.NetworkMismatch = NetworkMismatch # type: ignore + class UnsupportedFirmware(_UniffiTempJadeError): + def __init__(self, installed, required): + super().__init__(", ".join([ + "installed={!r}".format(installed), + "required={!r}".format(required), + ])) + self.installed = installed + self.required = required + + def __repr__(self): + return "JadeError.UnsupportedFirmware({})".format(str(self)) + _UniffiTempJadeError.UnsupportedFirmware = UnsupportedFirmware # type: ignore + class InvalidPath(_UniffiTempJadeError): + def __init__(self, error_details): + super().__init__(", ".join([ + "error_details={!r}".format(error_details), + ])) + self.error_details = error_details + + def __repr__(self): + return "JadeError.InvalidPath({})".format(str(self)) + _UniffiTempJadeError.InvalidPath = InvalidPath # type: ignore + class InvalidPsbt(_UniffiTempJadeError): + def __init__(self, error_details): + super().__init__(", ".join([ + "error_details={!r}".format(error_details), + ])) + self.error_details = error_details + + def __repr__(self): + return "JadeError.InvalidPsbt({})".format(str(self)) + _UniffiTempJadeError.InvalidPsbt = InvalidPsbt # type: ignore + class PsbtTooLarge(_UniffiTempJadeError): + def __init__(self, size, max): + super().__init__(", ".join([ + "size={!r}".format(size), + "max={!r}".format(max), + ])) + self.size = size + self.max = max + + def __repr__(self): + return "JadeError.PsbtTooLarge({})".format(str(self)) + _UniffiTempJadeError.PsbtTooLarge = PsbtTooLarge # type: ignore + class FingerprintMismatch(_UniffiTempJadeError): + def __init__(self, device, psbt): + super().__init__(", ".join([ + "device={!r}".format(device), + "psbt={!r}".format(psbt), + ])) + self.device = device + self.psbt = psbt + + def __repr__(self): + return "JadeError.FingerprintMismatch({})".format(str(self)) + _UniffiTempJadeError.FingerprintMismatch = FingerprintMismatch # type: ignore + class NothingSigned(_UniffiTempJadeError): def __init__(self): pass def __repr__(self): - return "LnurlError.AuthenticationFailed({})".format(str(self)) - _UniffiTempLnurlError.AuthenticationFailed = AuthenticationFailed # type: ignore + return "JadeError.NothingSigned({})".format(str(self)) + _UniffiTempJadeError.NothingSigned = NothingSigned # type: ignore + class AddressMismatch(_UniffiTempJadeError): + def __init__(self, expected, returned): + super().__init__(", ".join([ + "expected={!r}".format(expected), + "returned={!r}".format(returned), + ])) + self.expected = expected + self.returned = returned -LnurlError = _UniffiTempLnurlError # type: ignore -del _UniffiTempLnurlError + def __repr__(self): + return "JadeError.AddressMismatch({})".format(str(self)) + _UniffiTempJadeError.AddressMismatch = AddressMismatch # type: ignore + class PinServerError(_UniffiTempJadeError): + def __init__(self, error_details): + super().__init__(", ".join([ + "error_details={!r}".format(error_details), + ])) + self.error_details = error_details + + def __repr__(self): + return "JadeError.PinServerError({})".format(str(self)) + _UniffiTempJadeError.PinServerError = PinServerError # type: ignore + class DeviceError(_UniffiTempJadeError): + def __init__(self, error_details): + super().__init__(", ".join([ + "error_details={!r}".format(error_details), + ])) + self.error_details = error_details + def __repr__(self): + return "JadeError.DeviceError({})".format(str(self)) + _UniffiTempJadeError.DeviceError = DeviceError # type: ignore + class IoError(_UniffiTempJadeError): + def __init__(self, error_details): + super().__init__(", ".join([ + "error_details={!r}".format(error_details), + ])) + self.error_details = error_details -class _UniffiConverterTypeLnurlError(_UniffiConverterRustBuffer): + def __repr__(self): + return "JadeError.IoError({})".format(str(self)) + _UniffiTempJadeError.IoError = IoError # type: ignore + +JadeError = _UniffiTempJadeError # type: ignore +del _UniffiTempJadeError + + +class _UniffiConverterTypeJadeError(_UniffiConverterRustBuffer): @staticmethod def read(buf): variant = buf.read_i32() if variant == 1: - return LnurlError.InvalidAddress( + return JadeError.TransportError( + _UniffiConverterString.read(buf), ) if variant == 2: - return LnurlError.ClientCreationFailed( + return JadeError.DeviceNotFound( ) if variant == 3: - return LnurlError.RequestFailed( + return JadeError.DeviceDisconnected( ) if variant == 4: - return LnurlError.InvalidResponse( + return JadeError.DeviceBusy( ) if variant == 5: - return LnurlError.InvalidAmount( - _UniffiConverterUInt64.read(buf), - _UniffiConverterUInt64.read(buf), - _UniffiConverterUInt64.read(buf), + return JadeError.NotConnected( ) if variant == 6: - return LnurlError.InvoiceCreationFailed( - _UniffiConverterString.read(buf), + return JadeError.NotInitialized( ) if variant == 7: - return LnurlError.AmountMismatch( + return JadeError.ConnectionError( + _UniffiConverterString.read(buf), + ) + if variant == 8: + return JadeError.ProtocolError( + _UniffiConverterString.read(buf), + ) + if variant == 9: + return JadeError.Timeout( + ) + if variant == 10: + return JadeError.UserCancelled( + ) + if variant == 11: + return JadeError.DeviceLocked( + ) + if variant == 12: + return JadeError.DeviceUninitialized( + ) + if variant == 13: + return JadeError.InvalidPin( + ) + if variant == 14: + return JadeError.NetworkMismatch( + _UniffiConverterString.read(buf), + ) + if variant == 15: + return JadeError.UnsupportedFirmware( + _UniffiConverterString.read(buf), + _UniffiConverterString.read(buf), + ) + if variant == 16: + return JadeError.InvalidPath( + _UniffiConverterString.read(buf), + ) + if variant == 17: + return JadeError.InvalidPsbt( + _UniffiConverterString.read(buf), + ) + if variant == 18: + return JadeError.PsbtTooLarge( _UniffiConverterUInt64.read(buf), _UniffiConverterUInt64.read(buf), ) - if variant == 8: - return LnurlError.AuthenticationFailed( + if variant == 19: + return JadeError.FingerprintMismatch( + _UniffiConverterString.read(buf), + _UniffiConverterString.read(buf), + ) + if variant == 20: + return JadeError.NothingSigned( + ) + if variant == 21: + return JadeError.AddressMismatch( + _UniffiConverterString.read(buf), + _UniffiConverterString.read(buf), + ) + if variant == 22: + return JadeError.PinServerError( + _UniffiConverterString.read(buf), + ) + if variant == 23: + return JadeError.DeviceError( + _UniffiConverterString.read(buf), + ) + if variant == 24: + return JadeError.IoError( + _UniffiConverterString.read(buf), ) raise InternalError("Raw enum value doesn't match any cases") @staticmethod def check_lower(value): - if isinstance(value, LnurlError.InvalidAddress): + if isinstance(value, JadeError.TransportError): + _UniffiConverterString.check_lower(value.error_details) return - if isinstance(value, LnurlError.ClientCreationFailed): + if isinstance(value, JadeError.DeviceNotFound): return - if isinstance(value, LnurlError.RequestFailed): + if isinstance(value, JadeError.DeviceDisconnected): return - if isinstance(value, LnurlError.InvalidResponse): + if isinstance(value, JadeError.DeviceBusy): return - if isinstance(value, LnurlError.InvalidAmount): - _UniffiConverterUInt64.check_lower(value.amount_satoshis) - _UniffiConverterUInt64.check_lower(value.min) - _UniffiConverterUInt64.check_lower(value.max) + if isinstance(value, JadeError.NotConnected): return - if isinstance(value, LnurlError.InvoiceCreationFailed): + if isinstance(value, JadeError.NotInitialized): + return + if isinstance(value, JadeError.ConnectionError): _UniffiConverterString.check_lower(value.error_details) return - if isinstance(value, LnurlError.AmountMismatch): - _UniffiConverterUInt64.check_lower(value.requested_msats) - _UniffiConverterUInt64.check_lower(value.invoice_msats) + if isinstance(value, JadeError.ProtocolError): + _UniffiConverterString.check_lower(value.error_details) return - if isinstance(value, LnurlError.AuthenticationFailed): + if isinstance(value, JadeError.Timeout): return - - @staticmethod - def write(value, buf): - if isinstance(value, LnurlError.InvalidAddress): - buf.write_i32(1) - if isinstance(value, LnurlError.ClientCreationFailed): - buf.write_i32(2) - if isinstance(value, LnurlError.RequestFailed): - buf.write_i32(3) - if isinstance(value, LnurlError.InvalidResponse): + if isinstance(value, JadeError.UserCancelled): + return + if isinstance(value, JadeError.DeviceLocked): + return + if isinstance(value, JadeError.DeviceUninitialized): + return + if isinstance(value, JadeError.InvalidPin): + return + if isinstance(value, JadeError.NetworkMismatch): + _UniffiConverterString.check_lower(value.error_details) + return + if isinstance(value, JadeError.UnsupportedFirmware): + _UniffiConverterString.check_lower(value.installed) + _UniffiConverterString.check_lower(value.required) + return + if isinstance(value, JadeError.InvalidPath): + _UniffiConverterString.check_lower(value.error_details) + return + if isinstance(value, JadeError.InvalidPsbt): + _UniffiConverterString.check_lower(value.error_details) + return + if isinstance(value, JadeError.PsbtTooLarge): + _UniffiConverterUInt64.check_lower(value.size) + _UniffiConverterUInt64.check_lower(value.max) + return + if isinstance(value, JadeError.FingerprintMismatch): + _UniffiConverterString.check_lower(value.device) + _UniffiConverterString.check_lower(value.psbt) + return + if isinstance(value, JadeError.NothingSigned): + return + if isinstance(value, JadeError.AddressMismatch): + _UniffiConverterString.check_lower(value.expected) + _UniffiConverterString.check_lower(value.returned) + return + if isinstance(value, JadeError.PinServerError): + _UniffiConverterString.check_lower(value.error_details) + return + if isinstance(value, JadeError.DeviceError): + _UniffiConverterString.check_lower(value.error_details) + return + if isinstance(value, JadeError.IoError): + _UniffiConverterString.check_lower(value.error_details) + return + + @staticmethod + def write(value, buf): + if isinstance(value, JadeError.TransportError): + buf.write_i32(1) + _UniffiConverterString.write(value.error_details, buf) + if isinstance(value, JadeError.DeviceNotFound): + buf.write_i32(2) + if isinstance(value, JadeError.DeviceDisconnected): + buf.write_i32(3) + if isinstance(value, JadeError.DeviceBusy): buf.write_i32(4) - if isinstance(value, LnurlError.InvalidAmount): + if isinstance(value, JadeError.NotConnected): buf.write_i32(5) - _UniffiConverterUInt64.write(value.amount_satoshis, buf) - _UniffiConverterUInt64.write(value.min, buf) - _UniffiConverterUInt64.write(value.max, buf) - if isinstance(value, LnurlError.InvoiceCreationFailed): + if isinstance(value, JadeError.NotInitialized): buf.write_i32(6) - _UniffiConverterString.write(value.error_details, buf) - if isinstance(value, LnurlError.AmountMismatch): + if isinstance(value, JadeError.ConnectionError): buf.write_i32(7) - _UniffiConverterUInt64.write(value.requested_msats, buf) - _UniffiConverterUInt64.write(value.invoice_msats, buf) - if isinstance(value, LnurlError.AuthenticationFailed): + _UniffiConverterString.write(value.error_details, buf) + if isinstance(value, JadeError.ProtocolError): buf.write_i32(8) + _UniffiConverterString.write(value.error_details, buf) + if isinstance(value, JadeError.Timeout): + buf.write_i32(9) + if isinstance(value, JadeError.UserCancelled): + buf.write_i32(10) + if isinstance(value, JadeError.DeviceLocked): + buf.write_i32(11) + if isinstance(value, JadeError.DeviceUninitialized): + buf.write_i32(12) + if isinstance(value, JadeError.InvalidPin): + buf.write_i32(13) + if isinstance(value, JadeError.NetworkMismatch): + buf.write_i32(14) + _UniffiConverterString.write(value.error_details, buf) + if isinstance(value, JadeError.UnsupportedFirmware): + buf.write_i32(15) + _UniffiConverterString.write(value.installed, buf) + _UniffiConverterString.write(value.required, buf) + if isinstance(value, JadeError.InvalidPath): + buf.write_i32(16) + _UniffiConverterString.write(value.error_details, buf) + if isinstance(value, JadeError.InvalidPsbt): + buf.write_i32(17) + _UniffiConverterString.write(value.error_details, buf) + if isinstance(value, JadeError.PsbtTooLarge): + buf.write_i32(18) + _UniffiConverterUInt64.write(value.size, buf) + _UniffiConverterUInt64.write(value.max, buf) + if isinstance(value, JadeError.FingerprintMismatch): + buf.write_i32(19) + _UniffiConverterString.write(value.device, buf) + _UniffiConverterString.write(value.psbt, buf) + if isinstance(value, JadeError.NothingSigned): + buf.write_i32(20) + if isinstance(value, JadeError.AddressMismatch): + buf.write_i32(21) + _UniffiConverterString.write(value.expected, buf) + _UniffiConverterString.write(value.returned, buf) + if isinstance(value, JadeError.PinServerError): + buf.write_i32(22) + _UniffiConverterString.write(value.error_details, buf) + if isinstance(value, JadeError.DeviceError): + buf.write_i32(23) + _UniffiConverterString.write(value.error_details, buf) + if isinstance(value, JadeError.IoError): + buf.write_i32(24) + _UniffiConverterString.write(value.error_details, buf) -class ManualRefundStateEnum(enum.Enum): - CREATED = 0 - - APPROVED = 1 +class JadeNetwork(enum.Enum): + MAINNET = 0 - REJECTED = 2 + TESTNET = 1 - SENT = 3 + REGTEST = 2 -class _UniffiConverterTypeManualRefundStateEnum(_UniffiConverterRustBuffer): +class _UniffiConverterTypeJadeNetwork(_UniffiConverterRustBuffer): @staticmethod def read(buf): variant = buf.read_i32() if variant == 1: - return ManualRefundStateEnum.CREATED + return JadeNetwork.MAINNET if variant == 2: - return ManualRefundStateEnum.APPROVED + return JadeNetwork.TESTNET if variant == 3: - return ManualRefundStateEnum.REJECTED - if variant == 4: - return ManualRefundStateEnum.SENT + return JadeNetwork.REGTEST raise InternalError("Raw enum value doesn't match any cases") @staticmethod def check_lower(value): - if value == ManualRefundStateEnum.CREATED: - return - if value == ManualRefundStateEnum.APPROVED: + if value == JadeNetwork.MAINNET: return - if value == ManualRefundStateEnum.REJECTED: + if value == JadeNetwork.TESTNET: return - if value == ManualRefundStateEnum.SENT: + if value == JadeNetwork.REGTEST: return raise ValueError(value) @staticmethod def write(value, buf): - if value == ManualRefundStateEnum.CREATED: + if value == JadeNetwork.MAINNET: buf.write_i32(1) - if value == ManualRefundStateEnum.APPROVED: + if value == JadeNetwork.TESTNET: buf.write_i32(2) - if value == ManualRefundStateEnum.REJECTED: + if value == JadeNetwork.REGTEST: buf.write_i32(3) - if value == ManualRefundStateEnum.SENT: - buf.write_i32(4) @@ -15141,81 +16293,115 @@ def write(value, buf): -class Network(enum.Enum): - BITCOIN = 0 - """ - Mainnet Bitcoin. - """ - +class JadePingStatus(enum.Enum): + IDLE = 0 - TESTNET = 1 - """ - Bitcoin's testnet network. - """ - + BUSY = 1 - TESTNET4 = 2 - """ - Bitcoin's testnet4 network. - """ - + AWAITING_USER_INPUT = 2 - SIGNET = 3 - """ - Bitcoin's signet network. - """ - - REGTEST = 4 - """ - Bitcoin's regtest network. - """ +class _UniffiConverterTypeJadePingStatus(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + variant = buf.read_i32() + if variant == 1: + return JadePingStatus.IDLE + if variant == 2: + return JadePingStatus.BUSY + if variant == 3: + return JadePingStatus.AWAITING_USER_INPUT + raise InternalError("Raw enum value doesn't match any cases") + + @staticmethod + def check_lower(value): + if value == JadePingStatus.IDLE: + return + if value == JadePingStatus.BUSY: + return + if value == JadePingStatus.AWAITING_USER_INPUT: + return + raise ValueError(value) + + @staticmethod + def write(value, buf): + if value == JadePingStatus.IDLE: + buf.write_i32(1) + if value == JadePingStatus.BUSY: + buf.write_i32(2) + if value == JadePingStatus.AWAITING_USER_INPUT: + buf.write_i32(3) + + + + + + + +class JadeState(enum.Enum): + UNINIT = 0 + + UNSAVED = 1 + + LOCKED = 2 + + READY = 3 + + TEMP = 4 + + UNKNOWN = 5 -class _UniffiConverterTypeNetwork(_UniffiConverterRustBuffer): +class _UniffiConverterTypeJadeState(_UniffiConverterRustBuffer): @staticmethod def read(buf): variant = buf.read_i32() if variant == 1: - return Network.BITCOIN + return JadeState.UNINIT if variant == 2: - return Network.TESTNET + return JadeState.UNSAVED if variant == 3: - return Network.TESTNET4 + return JadeState.LOCKED if variant == 4: - return Network.SIGNET + return JadeState.READY if variant == 5: - return Network.REGTEST + return JadeState.TEMP + if variant == 6: + return JadeState.UNKNOWN raise InternalError("Raw enum value doesn't match any cases") @staticmethod def check_lower(value): - if value == Network.BITCOIN: + if value == JadeState.UNINIT: return - if value == Network.TESTNET: + if value == JadeState.UNSAVED: return - if value == Network.TESTNET4: + if value == JadeState.LOCKED: return - if value == Network.SIGNET: + if value == JadeState.READY: return - if value == Network.REGTEST: + if value == JadeState.TEMP: + return + if value == JadeState.UNKNOWN: return raise ValueError(value) @staticmethod def write(value, buf): - if value == Network.BITCOIN: + if value == JadeState.UNINIT: buf.write_i32(1) - if value == Network.TESTNET: + if value == JadeState.UNSAVED: buf.write_i32(2) - if value == Network.TESTNET4: + if value == JadeState.LOCKED: buf.write_i32(3) - if value == Network.SIGNET: + if value == JadeState.READY: buf.write_i32(4) - if value == Network.REGTEST: + if value == JadeState.TEMP: buf.write_i32(5) + if value == JadeState.UNKNOWN: + buf.write_i32(6) @@ -15223,308 +16409,328 @@ def write(value, buf): -class NetworkType(enum.Enum): - BITCOIN = 0 +class JadeTransportErrorCode(enum.Enum): + DEVICE_BUSY = 0 - TESTNET = 1 + NOT_CONNECTED = 1 - REGTEST = 2 + DISCONNECTED = 2 - SIGNET = 3 + TIMEOUT = 3 + + PERMISSION_DENIED = 4 -class _UniffiConverterTypeNetworkType(_UniffiConverterRustBuffer): +class _UniffiConverterTypeJadeTransportErrorCode(_UniffiConverterRustBuffer): @staticmethod def read(buf): variant = buf.read_i32() if variant == 1: - return NetworkType.BITCOIN + return JadeTransportErrorCode.DEVICE_BUSY if variant == 2: - return NetworkType.TESTNET + return JadeTransportErrorCode.NOT_CONNECTED if variant == 3: - return NetworkType.REGTEST + return JadeTransportErrorCode.DISCONNECTED if variant == 4: - return NetworkType.SIGNET + return JadeTransportErrorCode.TIMEOUT + if variant == 5: + return JadeTransportErrorCode.PERMISSION_DENIED raise InternalError("Raw enum value doesn't match any cases") @staticmethod def check_lower(value): - if value == NetworkType.BITCOIN: + if value == JadeTransportErrorCode.DEVICE_BUSY: return - if value == NetworkType.TESTNET: + if value == JadeTransportErrorCode.NOT_CONNECTED: return - if value == NetworkType.REGTEST: + if value == JadeTransportErrorCode.DISCONNECTED: return - if value == NetworkType.SIGNET: + if value == JadeTransportErrorCode.TIMEOUT: + return + if value == JadeTransportErrorCode.PERMISSION_DENIED: return raise ValueError(value) @staticmethod def write(value, buf): - if value == NetworkType.BITCOIN: + if value == JadeTransportErrorCode.DEVICE_BUSY: buf.write_i32(1) - if value == NetworkType.TESTNET: + if value == JadeTransportErrorCode.NOT_CONNECTED: buf.write_i32(2) - if value == NetworkType.REGTEST: + if value == JadeTransportErrorCode.DISCONNECTED: buf.write_i32(3) - if value == NetworkType.SIGNET: + if value == JadeTransportErrorCode.TIMEOUT: buf.write_i32(4) + if value == JadeTransportErrorCode.PERMISSION_DENIED: + buf.write_i32(5) -# OnchainError -# We want to define each variant as a nested class that's also a subclass, -# which is tricky in Python. To accomplish this we're going to create each -# class separately, then manually add the child classes to the base class's -# __dict__. All of this happens in dummy class to avoid polluting the module -# namespace. -class OnchainError(Exception): - pass - -_UniffiTempOnchainError = OnchainError -class OnchainError: # type: ignore - class InvalidExtendedPublicKey(_UniffiTempOnchainError): - def __init__(self, error_details): - super().__init__(", ".join([ - "error_details={!r}".format(error_details), - ])) - self.error_details = error_details - def __repr__(self): - return "OnchainError.InvalidExtendedPublicKey({})".format(str(self)) - _UniffiTempOnchainError.InvalidExtendedPublicKey = InvalidExtendedPublicKey # type: ignore -OnchainError = _UniffiTempOnchainError # type: ignore -del _UniffiTempOnchainError +class JadeTransportKind(enum.Enum): + BLUETOOTH = 0 + + SERIAL = 1 + -class _UniffiConverterTypeOnchainError(_UniffiConverterRustBuffer): +class _UniffiConverterTypeJadeTransportKind(_UniffiConverterRustBuffer): @staticmethod def read(buf): variant = buf.read_i32() if variant == 1: - return OnchainError.InvalidExtendedPublicKey( - _UniffiConverterString.read(buf), - ) + return JadeTransportKind.BLUETOOTH + if variant == 2: + return JadeTransportKind.SERIAL raise InternalError("Raw enum value doesn't match any cases") @staticmethod def check_lower(value): - if isinstance(value, OnchainError.InvalidExtendedPublicKey): - _UniffiConverterString.check_lower(value.error_details) + if value == JadeTransportKind.BLUETOOTH: + return + if value == JadeTransportKind.SERIAL: return + raise ValueError(value) @staticmethod def write(value, buf): - if isinstance(value, OnchainError.InvalidExtendedPublicKey): + if value == JadeTransportKind.BLUETOOTH: buf.write_i32(1) - _UniffiConverterString.write(value.error_details, buf) - - + if value == JadeTransportKind.SERIAL: + buf.write_i32(2) -class PassphraseResponse: - def __init__(self): - raise RuntimeError("PassphraseResponse cannot be instantiated directly") - # Each enum variant is a nested class of the enum itself. - class CANCEL: - """ - User cancelled — aborts the pending operation. - """ +# LnurlError +# We want to define each variant as a nested class that's also a subclass, +# which is tricky in Python. To accomplish this we're going to create each +# class separately, then manually add the child classes to the base class's +# __dict__. All of this happens in dummy class to avoid polluting the module +# namespace. +class LnurlError(Exception): + pass +_UniffiTempLnurlError = LnurlError - def __init__(self,): +class LnurlError: # type: ignore + class InvalidAddress(_UniffiTempLnurlError): + def __init__(self): pass - def __str__(self): - return "PassphraseResponse.CANCEL()".format() + def __repr__(self): + return "LnurlError.InvalidAddress({})".format(str(self)) + _UniffiTempLnurlError.InvalidAddress = InvalidAddress # type: ignore + class ClientCreationFailed(_UniffiTempLnurlError): + def __init__(self): + pass - def __eq__(self, other): - if not other.is_CANCEL(): - return False - return True - - class STANDARD: - """ - Standard wallet — no passphrase, equivalent to `Some("")` on the device. - """ - - - def __init__(self,): + def __repr__(self): + return "LnurlError.ClientCreationFailed({})".format(str(self)) + _UniffiTempLnurlError.ClientCreationFailed = ClientCreationFailed # type: ignore + class RequestFailed(_UniffiTempLnurlError): + def __init__(self): pass - def __str__(self): - return "PassphraseResponse.STANDARD()".format() - - def __eq__(self, other): - if not other.is_STANDARD(): - return False - return True - - class HIDDEN: - """ - Hidden wallet — derived from the passphrase entered on the host. - """ - - value: "str" - - def __init__(self,value: "str"): - self.value = value - - def __str__(self): - return "PassphraseResponse.HIDDEN(value={})".format(self.value) - - def __eq__(self, other): - if not other.is_HIDDEN(): - return False - if self.value != other.value: - return False - return True - - class ON_DEVICE: - """ - Enter the passphrase on the Trezor device itself instead of on the host. - """ - - - def __init__(self,): + def __repr__(self): + return "LnurlError.RequestFailed({})".format(str(self)) + _UniffiTempLnurlError.RequestFailed = RequestFailed # type: ignore + class InvalidResponse(_UniffiTempLnurlError): + def __init__(self): pass - def __str__(self): - return "PassphraseResponse.ON_DEVICE()".format() + def __repr__(self): + return "LnurlError.InvalidResponse({})".format(str(self)) + _UniffiTempLnurlError.InvalidResponse = InvalidResponse # type: ignore + class InvalidAmount(_UniffiTempLnurlError): + def __init__(self, amount_satoshis, min, max): + super().__init__(", ".join([ + "amount_satoshis={!r}".format(amount_satoshis), + "min={!r}".format(min), + "max={!r}".format(max), + ])) + self.amount_satoshis = amount_satoshis + self.min = min + self.max = max - def __eq__(self, other): - if not other.is_ON_DEVICE(): - return False - return True - - + def __repr__(self): + return "LnurlError.InvalidAmount({})".format(str(self)) + _UniffiTempLnurlError.InvalidAmount = InvalidAmount # type: ignore + class InvoiceCreationFailed(_UniffiTempLnurlError): + def __init__(self, error_details): + super().__init__(", ".join([ + "error_details={!r}".format(error_details), + ])) + self.error_details = error_details - # For each variant, we have `is_NAME` and `is_name` methods for easily checking - # whether an instance is that variant. - def is_CANCEL(self) -> bool: - return isinstance(self, PassphraseResponse.CANCEL) - def is_cancel(self) -> bool: - return isinstance(self, PassphraseResponse.CANCEL) - def is_STANDARD(self) -> bool: - return isinstance(self, PassphraseResponse.STANDARD) - def is_standard(self) -> bool: - return isinstance(self, PassphraseResponse.STANDARD) - def is_HIDDEN(self) -> bool: - return isinstance(self, PassphraseResponse.HIDDEN) - def is_hidden(self) -> bool: - return isinstance(self, PassphraseResponse.HIDDEN) - def is_ON_DEVICE(self) -> bool: - return isinstance(self, PassphraseResponse.ON_DEVICE) - def is_on_device(self) -> bool: - return isinstance(self, PassphraseResponse.ON_DEVICE) - + def __repr__(self): + return "LnurlError.InvoiceCreationFailed({})".format(str(self)) + _UniffiTempLnurlError.InvoiceCreationFailed = InvoiceCreationFailed # type: ignore + class AmountMismatch(_UniffiTempLnurlError): + def __init__(self, requested_msats, invoice_msats): + super().__init__(", ".join([ + "requested_msats={!r}".format(requested_msats), + "invoice_msats={!r}".format(invoice_msats), + ])) + self.requested_msats = requested_msats + self.invoice_msats = invoice_msats -# Now, a little trick - we make each nested variant class be a subclass of the main -# enum class, so that method calls and instance checks etc will work intuitively. -# We might be able to do this a little more neatly with a metaclass, but this'll do. -PassphraseResponse.CANCEL = type("PassphraseResponse.CANCEL", (PassphraseResponse.CANCEL, PassphraseResponse,), {}) # type: ignore -PassphraseResponse.STANDARD = type("PassphraseResponse.STANDARD", (PassphraseResponse.STANDARD, PassphraseResponse,), {}) # type: ignore -PassphraseResponse.HIDDEN = type("PassphraseResponse.HIDDEN", (PassphraseResponse.HIDDEN, PassphraseResponse,), {}) # type: ignore -PassphraseResponse.ON_DEVICE = type("PassphraseResponse.ON_DEVICE", (PassphraseResponse.ON_DEVICE, PassphraseResponse,), {}) # type: ignore + def __repr__(self): + return "LnurlError.AmountMismatch({})".format(str(self)) + _UniffiTempLnurlError.AmountMismatch = AmountMismatch # type: ignore + class AuthenticationFailed(_UniffiTempLnurlError): + def __init__(self): + pass + def __repr__(self): + return "LnurlError.AuthenticationFailed({})".format(str(self)) + _UniffiTempLnurlError.AuthenticationFailed = AuthenticationFailed # type: ignore +LnurlError = _UniffiTempLnurlError # type: ignore +del _UniffiTempLnurlError -class _UniffiConverterTypePassphraseResponse(_UniffiConverterRustBuffer): +class _UniffiConverterTypeLnurlError(_UniffiConverterRustBuffer): @staticmethod def read(buf): variant = buf.read_i32() if variant == 1: - return PassphraseResponse.CANCEL( + return LnurlError.InvalidAddress( ) if variant == 2: - return PassphraseResponse.STANDARD( + return LnurlError.ClientCreationFailed( ) if variant == 3: - return PassphraseResponse.HIDDEN( - _UniffiConverterString.read(buf), + return LnurlError.RequestFailed( ) if variant == 4: - return PassphraseResponse.ON_DEVICE( + return LnurlError.InvalidResponse( + ) + if variant == 5: + return LnurlError.InvalidAmount( + _UniffiConverterUInt64.read(buf), + _UniffiConverterUInt64.read(buf), + _UniffiConverterUInt64.read(buf), + ) + if variant == 6: + return LnurlError.InvoiceCreationFailed( + _UniffiConverterString.read(buf), + ) + if variant == 7: + return LnurlError.AmountMismatch( + _UniffiConverterUInt64.read(buf), + _UniffiConverterUInt64.read(buf), + ) + if variant == 8: + return LnurlError.AuthenticationFailed( ) raise InternalError("Raw enum value doesn't match any cases") @staticmethod def check_lower(value): - if value.is_CANCEL(): + if isinstance(value, LnurlError.InvalidAddress): return - if value.is_STANDARD(): + if isinstance(value, LnurlError.ClientCreationFailed): return - if value.is_HIDDEN(): - _UniffiConverterString.check_lower(value.value) + if isinstance(value, LnurlError.RequestFailed): return - if value.is_ON_DEVICE(): + if isinstance(value, LnurlError.InvalidResponse): + return + if isinstance(value, LnurlError.InvalidAmount): + _UniffiConverterUInt64.check_lower(value.amount_satoshis) + _UniffiConverterUInt64.check_lower(value.min) + _UniffiConverterUInt64.check_lower(value.max) + return + if isinstance(value, LnurlError.InvoiceCreationFailed): + _UniffiConverterString.check_lower(value.error_details) + return + if isinstance(value, LnurlError.AmountMismatch): + _UniffiConverterUInt64.check_lower(value.requested_msats) + _UniffiConverterUInt64.check_lower(value.invoice_msats) + return + if isinstance(value, LnurlError.AuthenticationFailed): return - raise ValueError(value) @staticmethod def write(value, buf): - if value.is_CANCEL(): + if isinstance(value, LnurlError.InvalidAddress): buf.write_i32(1) - if value.is_STANDARD(): + if isinstance(value, LnurlError.ClientCreationFailed): buf.write_i32(2) - if value.is_HIDDEN(): + if isinstance(value, LnurlError.RequestFailed): buf.write_i32(3) - _UniffiConverterString.write(value.value, buf) - if value.is_ON_DEVICE(): + if isinstance(value, LnurlError.InvalidResponse): buf.write_i32(4) + if isinstance(value, LnurlError.InvalidAmount): + buf.write_i32(5) + _UniffiConverterUInt64.write(value.amount_satoshis, buf) + _UniffiConverterUInt64.write(value.min, buf) + _UniffiConverterUInt64.write(value.max, buf) + if isinstance(value, LnurlError.InvoiceCreationFailed): + buf.write_i32(6) + _UniffiConverterString.write(value.error_details, buf) + if isinstance(value, LnurlError.AmountMismatch): + buf.write_i32(7) + _UniffiConverterUInt64.write(value.requested_msats, buf) + _UniffiConverterUInt64.write(value.invoice_msats, buf) + if isinstance(value, LnurlError.AuthenticationFailed): + buf.write_i32(8) - - -class PaymentState(enum.Enum): - PENDING = 0 +class ManualRefundStateEnum(enum.Enum): + CREATED = 0 - SUCCEEDED = 1 + APPROVED = 1 - FAILED = 2 + REJECTED = 2 + + SENT = 3 -class _UniffiConverterTypePaymentState(_UniffiConverterRustBuffer): +class _UniffiConverterTypeManualRefundStateEnum(_UniffiConverterRustBuffer): @staticmethod def read(buf): variant = buf.read_i32() if variant == 1: - return PaymentState.PENDING + return ManualRefundStateEnum.CREATED if variant == 2: - return PaymentState.SUCCEEDED + return ManualRefundStateEnum.APPROVED if variant == 3: - return PaymentState.FAILED + return ManualRefundStateEnum.REJECTED + if variant == 4: + return ManualRefundStateEnum.SENT raise InternalError("Raw enum value doesn't match any cases") @staticmethod def check_lower(value): - if value == PaymentState.PENDING: + if value == ManualRefundStateEnum.CREATED: return - if value == PaymentState.SUCCEEDED: + if value == ManualRefundStateEnum.APPROVED: return - if value == PaymentState.FAILED: + if value == ManualRefundStateEnum.REJECTED: + return + if value == ManualRefundStateEnum.SENT: return raise ValueError(value) @staticmethod def write(value, buf): - if value == PaymentState.PENDING: + if value == ManualRefundStateEnum.CREATED: buf.write_i32(1) - if value == PaymentState.SUCCEEDED: + if value == ManualRefundStateEnum.APPROVED: buf.write_i32(2) - if value == PaymentState.FAILED: + if value == ManualRefundStateEnum.REJECTED: buf.write_i32(3) + if value == ManualRefundStateEnum.SENT: + buf.write_i32(4) @@ -15532,986 +16738,1377 @@ def write(value, buf): -class PaymentType(enum.Enum): - SENT = 0 +class Network(enum.Enum): + BITCOIN = 0 + """ + Mainnet Bitcoin. + """ + - RECEIVED = 1 + TESTNET = 1 + """ + Bitcoin's testnet network. + """ + + TESTNET4 = 2 + """ + Bitcoin's testnet4 network. + """ + + SIGNET = 3 + """ + Bitcoin's signet network. + """ -class _UniffiConverterTypePaymentType(_UniffiConverterRustBuffer): + + REGTEST = 4 + """ + Bitcoin's regtest network. + """ + + + + +class _UniffiConverterTypeNetwork(_UniffiConverterRustBuffer): @staticmethod def read(buf): variant = buf.read_i32() if variant == 1: - return PaymentType.SENT + return Network.BITCOIN if variant == 2: - return PaymentType.RECEIVED + return Network.TESTNET + if variant == 3: + return Network.TESTNET4 + if variant == 4: + return Network.SIGNET + if variant == 5: + return Network.REGTEST raise InternalError("Raw enum value doesn't match any cases") @staticmethod def check_lower(value): - if value == PaymentType.SENT: + if value == Network.BITCOIN: return - if value == PaymentType.RECEIVED: + if value == Network.TESTNET: + return + if value == Network.TESTNET4: + return + if value == Network.SIGNET: + return + if value == Network.REGTEST: return raise ValueError(value) @staticmethod def write(value, buf): - if value == PaymentType.SENT: + if value == Network.BITCOIN: buf.write_i32(1) - if value == PaymentType.RECEIVED: + if value == Network.TESTNET: buf.write_i32(2) + if value == Network.TESTNET4: + buf.write_i32(3) + if value == Network.SIGNET: + buf.write_i32(4) + if value == Network.REGTEST: + buf.write_i32(5) -# PsbtCompletionError -# We want to define each variant as a nested class that's also a subclass, -# which is tricky in Python. To accomplish this we're going to create each -# class separately, then manually add the child classes to the base class's -# __dict__. All of this happens in dummy class to avoid polluting the module -# namespace. -class PsbtCompletionError(Exception): - pass - -_UniffiTempPsbtCompletionError = PsbtCompletionError - -class PsbtCompletionError: # type: ignore - class InvalidPsbt(_UniffiTempPsbtCompletionError): - def __init__(self, reason): - super().__init__(", ".join([ - "reason={!r}".format(reason), - ])) - self.reason = reason - - def __repr__(self): - return "PsbtCompletionError.InvalidPsbt({})".format(str(self)) - _UniffiTempPsbtCompletionError.InvalidPsbt = InvalidPsbt # type: ignore - class CombineFailed(_UniffiTempPsbtCompletionError): - def __init__(self, reason): - super().__init__(", ".join([ - "reason={!r}".format(reason), - ])) - self.reason = reason - - def __repr__(self): - return "PsbtCompletionError.CombineFailed({})".format(str(self)) - _UniffiTempPsbtCompletionError.CombineFailed = CombineFailed # type: ignore - class FinalizationFailed(_UniffiTempPsbtCompletionError): - def __init__(self, reason): - super().__init__(", ".join([ - "reason={!r}".format(reason), - ])) - self.reason = reason - - def __repr__(self): - return "PsbtCompletionError.FinalizationFailed({})".format(str(self)) - _UniffiTempPsbtCompletionError.FinalizationFailed = FinalizationFailed # type: ignore - class VerificationFailed(_UniffiTempPsbtCompletionError): - def __init__(self, reason): - super().__init__(", ".join([ - "reason={!r}".format(reason), - ])) - self.reason = reason - def __repr__(self): - return "PsbtCompletionError.VerificationFailed({})".format(str(self)) - _UniffiTempPsbtCompletionError.VerificationFailed = VerificationFailed # type: ignore - class ExtractionFailed(_UniffiTempPsbtCompletionError): - def __init__(self, reason): - super().__init__(", ".join([ - "reason={!r}".format(reason), - ])) - self.reason = reason - def __repr__(self): - return "PsbtCompletionError.ExtractionFailed({})".format(str(self)) - _UniffiTempPsbtCompletionError.ExtractionFailed = ExtractionFailed # type: ignore -PsbtCompletionError = _UniffiTempPsbtCompletionError # type: ignore -del _UniffiTempPsbtCompletionError +class NetworkType(enum.Enum): + BITCOIN = 0 + + TESTNET = 1 + + REGTEST = 2 + + SIGNET = 3 + -class _UniffiConverterTypePsbtCompletionError(_UniffiConverterRustBuffer): +class _UniffiConverterTypeNetworkType(_UniffiConverterRustBuffer): @staticmethod def read(buf): variant = buf.read_i32() if variant == 1: - return PsbtCompletionError.InvalidPsbt( - _UniffiConverterString.read(buf), - ) + return NetworkType.BITCOIN if variant == 2: - return PsbtCompletionError.CombineFailed( - _UniffiConverterString.read(buf), - ) + return NetworkType.TESTNET if variant == 3: - return PsbtCompletionError.FinalizationFailed( - _UniffiConverterString.read(buf), - ) + return NetworkType.REGTEST if variant == 4: - return PsbtCompletionError.VerificationFailed( - _UniffiConverterString.read(buf), - ) - if variant == 5: - return PsbtCompletionError.ExtractionFailed( - _UniffiConverterString.read(buf), - ) + return NetworkType.SIGNET raise InternalError("Raw enum value doesn't match any cases") @staticmethod def check_lower(value): - if isinstance(value, PsbtCompletionError.InvalidPsbt): - _UniffiConverterString.check_lower(value.reason) - return - if isinstance(value, PsbtCompletionError.CombineFailed): - _UniffiConverterString.check_lower(value.reason) + if value == NetworkType.BITCOIN: return - if isinstance(value, PsbtCompletionError.FinalizationFailed): - _UniffiConverterString.check_lower(value.reason) + if value == NetworkType.TESTNET: return - if isinstance(value, PsbtCompletionError.VerificationFailed): - _UniffiConverterString.check_lower(value.reason) + if value == NetworkType.REGTEST: return - if isinstance(value, PsbtCompletionError.ExtractionFailed): - _UniffiConverterString.check_lower(value.reason) + if value == NetworkType.SIGNET: return + raise ValueError(value) @staticmethod def write(value, buf): - if isinstance(value, PsbtCompletionError.InvalidPsbt): + if value == NetworkType.BITCOIN: buf.write_i32(1) - _UniffiConverterString.write(value.reason, buf) - if isinstance(value, PsbtCompletionError.CombineFailed): + if value == NetworkType.TESTNET: buf.write_i32(2) - _UniffiConverterString.write(value.reason, buf) - if isinstance(value, PsbtCompletionError.FinalizationFailed): + if value == NetworkType.REGTEST: buf.write_i32(3) - _UniffiConverterString.write(value.reason, buf) - if isinstance(value, PsbtCompletionError.VerificationFailed): + if value == NetworkType.SIGNET: buf.write_i32(4) - _UniffiConverterString.write(value.reason, buf) - if isinstance(value, PsbtCompletionError.ExtractionFailed): - buf.write_i32(5) - _UniffiConverterString.write(value.reason, buf) +# OnchainError +# We want to define each variant as a nested class that's also a subclass, +# which is tricky in Python. To accomplish this we're going to create each +# class separately, then manually add the child classes to the base class's +# __dict__. All of this happens in dummy class to avoid polluting the module +# namespace. +class OnchainError(Exception): + pass -class PubkyAuthKind(enum.Enum): - """ - The type of a `pubkyauth://` deep-link flow. - """ +_UniffiTempOnchainError = OnchainError - SIGNIN = 0 - - SIGNUP = 1 - +class OnchainError: # type: ignore + class InvalidExtendedPublicKey(_UniffiTempOnchainError): + def __init__(self, error_details): + super().__init__(", ".join([ + "error_details={!r}".format(error_details), + ])) + self.error_details = error_details + def __repr__(self): + return "OnchainError.InvalidExtendedPublicKey({})".format(str(self)) + _UniffiTempOnchainError.InvalidExtendedPublicKey = InvalidExtendedPublicKey # type: ignore -class _UniffiConverterTypePubkyAuthKind(_UniffiConverterRustBuffer): +OnchainError = _UniffiTempOnchainError # type: ignore +del _UniffiTempOnchainError + + +class _UniffiConverterTypeOnchainError(_UniffiConverterRustBuffer): @staticmethod def read(buf): variant = buf.read_i32() if variant == 1: - return PubkyAuthKind.SIGNIN - if variant == 2: - return PubkyAuthKind.SIGNUP + return OnchainError.InvalidExtendedPublicKey( + _UniffiConverterString.read(buf), + ) raise InternalError("Raw enum value doesn't match any cases") @staticmethod def check_lower(value): - if value == PubkyAuthKind.SIGNIN: - return - if value == PubkyAuthKind.SIGNUP: + if isinstance(value, OnchainError.InvalidExtendedPublicKey): + _UniffiConverterString.check_lower(value.error_details) return - raise ValueError(value) @staticmethod def write(value, buf): - if value == PubkyAuthKind.SIGNIN: + if isinstance(value, OnchainError.InvalidExtendedPublicKey): buf.write_i32(1) - if value == PubkyAuthKind.SIGNUP: - buf.write_i32(2) + _UniffiConverterString.write(value.error_details, buf) -# PubkyError -# We want to define each variant as a nested class that's also a subclass, -# which is tricky in Python. To accomplish this we're going to create each -# class separately, then manually add the child classes to the base class's -# __dict__. All of this happens in dummy class to avoid polluting the module -# namespace. -class PubkyError(Exception): - pass -_UniffiTempPubkyError = PubkyError +class PassphraseResponse: + def __init__(self): + raise RuntimeError("PassphraseResponse cannot be instantiated directly") -class PubkyError: # type: ignore - class InvalidCapabilities(_UniffiTempPubkyError): - def __init__(self, reason): - super().__init__(", ".join([ - "reason={!r}".format(reason), - ])) - self.reason = reason + # Each enum variant is a nested class of the enum itself. + class CANCEL: + """ + User cancelled — aborts the pending operation. + """ - def __repr__(self): - return "PubkyError.InvalidCapabilities({})".format(str(self)) - _UniffiTempPubkyError.InvalidCapabilities = InvalidCapabilities # type: ignore - class AuthFailed(_UniffiTempPubkyError): - def __init__(self, reason): - super().__init__(", ".join([ - "reason={!r}".format(reason), - ])) - self.reason = reason - def __repr__(self): - return "PubkyError.AuthFailed({})".format(str(self)) - _UniffiTempPubkyError.AuthFailed = AuthFailed # type: ignore - class NoActiveFlow(_UniffiTempPubkyError): - def __init__(self): + def __init__(self,): pass - def __repr__(self): - return "PubkyError.NoActiveFlow({})".format(str(self)) - _UniffiTempPubkyError.NoActiveFlow = NoActiveFlow # type: ignore - class ResolutionFailed(_UniffiTempPubkyError): - def __init__(self, reason): - super().__init__(", ".join([ - "reason={!r}".format(reason), - ])) - self.reason = reason + def __str__(self): + return "PassphraseResponse.CANCEL()".format() - def __repr__(self): - return "PubkyError.ResolutionFailed({})".format(str(self)) - _UniffiTempPubkyError.ResolutionFailed = ResolutionFailed # type: ignore - class FetchFailed(_UniffiTempPubkyError): - def __init__(self, reason): - super().__init__(", ".join([ - "reason={!r}".format(reason), - ])) - self.reason = reason + def __eq__(self, other): + if not other.is_CANCEL(): + return False + return True + + class STANDARD: + """ + Standard wallet — no passphrase, equivalent to `Some("")` on the device. + """ - def __repr__(self): - return "PubkyError.FetchFailed({})".format(str(self)) - _UniffiTempPubkyError.FetchFailed = FetchFailed # type: ignore - class ProfileNotFound(_UniffiTempPubkyError): - def __init__(self): + + def __init__(self,): pass - def __repr__(self): - return "PubkyError.ProfileNotFound({})".format(str(self)) - _UniffiTempPubkyError.ProfileNotFound = ProfileNotFound # type: ignore - class ProfileParseFailed(_UniffiTempPubkyError): - def __init__(self, reason): - super().__init__(", ".join([ - "reason={!r}".format(reason), - ])) - self.reason = reason + def __str__(self): + return "PassphraseResponse.STANDARD()".format() - def __repr__(self): - return "PubkyError.ProfileParseFailed({})".format(str(self)) - _UniffiTempPubkyError.ProfileParseFailed = ProfileParseFailed # type: ignore - class KeyError(_UniffiTempPubkyError): - def __init__(self, reason): - super().__init__(", ".join([ - "reason={!r}".format(reason), - ])) - self.reason = reason + def __eq__(self, other): + if not other.is_STANDARD(): + return False + return True + + class HIDDEN: + """ + Hidden wallet — derived from the passphrase entered on the host. + """ - def __repr__(self): - return "PubkyError.KeyError({})".format(str(self)) - _UniffiTempPubkyError.KeyError = KeyError # type: ignore - class WriteFailed(_UniffiTempPubkyError): - def __init__(self, reason): - super().__init__(", ".join([ - "reason={!r}".format(reason), - ])) - self.reason = reason + value: "str" - def __repr__(self): - return "PubkyError.WriteFailed({})".format(str(self)) - _UniffiTempPubkyError.WriteFailed = WriteFailed # type: ignore + def __init__(self,value: "str"): + self.value = value -PubkyError = _UniffiTempPubkyError # type: ignore -del _UniffiTempPubkyError + def __str__(self): + return "PassphraseResponse.HIDDEN(value={})".format(self.value) + + def __eq__(self, other): + if not other.is_HIDDEN(): + return False + if self.value != other.value: + return False + return True + + class ON_DEVICE: + """ + Enter the passphrase on the Trezor device itself instead of on the host. + """ -class _UniffiConverterTypePubkyError(_UniffiConverterRustBuffer): + def __init__(self,): + pass + + def __str__(self): + return "PassphraseResponse.ON_DEVICE()".format() + + def __eq__(self, other): + if not other.is_ON_DEVICE(): + return False + return True + + + + # For each variant, we have `is_NAME` and `is_name` methods for easily checking + # whether an instance is that variant. + def is_CANCEL(self) -> bool: + return isinstance(self, PassphraseResponse.CANCEL) + def is_cancel(self) -> bool: + return isinstance(self, PassphraseResponse.CANCEL) + def is_STANDARD(self) -> bool: + return isinstance(self, PassphraseResponse.STANDARD) + def is_standard(self) -> bool: + return isinstance(self, PassphraseResponse.STANDARD) + def is_HIDDEN(self) -> bool: + return isinstance(self, PassphraseResponse.HIDDEN) + def is_hidden(self) -> bool: + return isinstance(self, PassphraseResponse.HIDDEN) + def is_ON_DEVICE(self) -> bool: + return isinstance(self, PassphraseResponse.ON_DEVICE) + def is_on_device(self) -> bool: + return isinstance(self, PassphraseResponse.ON_DEVICE) + + +# Now, a little trick - we make each nested variant class be a subclass of the main +# enum class, so that method calls and instance checks etc will work intuitively. +# We might be able to do this a little more neatly with a metaclass, but this'll do. +PassphraseResponse.CANCEL = type("PassphraseResponse.CANCEL", (PassphraseResponse.CANCEL, PassphraseResponse,), {}) # type: ignore +PassphraseResponse.STANDARD = type("PassphraseResponse.STANDARD", (PassphraseResponse.STANDARD, PassphraseResponse,), {}) # type: ignore +PassphraseResponse.HIDDEN = type("PassphraseResponse.HIDDEN", (PassphraseResponse.HIDDEN, PassphraseResponse,), {}) # type: ignore +PassphraseResponse.ON_DEVICE = type("PassphraseResponse.ON_DEVICE", (PassphraseResponse.ON_DEVICE, PassphraseResponse,), {}) # type: ignore + + + + +class _UniffiConverterTypePassphraseResponse(_UniffiConverterRustBuffer): @staticmethod def read(buf): variant = buf.read_i32() if variant == 1: - return PubkyError.InvalidCapabilities( - _UniffiConverterString.read(buf), + return PassphraseResponse.CANCEL( ) if variant == 2: - return PubkyError.AuthFailed( - _UniffiConverterString.read(buf), + return PassphraseResponse.STANDARD( ) if variant == 3: - return PubkyError.NoActiveFlow( - ) - if variant == 4: - return PubkyError.ResolutionFailed( - _UniffiConverterString.read(buf), - ) - if variant == 5: - return PubkyError.FetchFailed( - _UniffiConverterString.read(buf), - ) - if variant == 6: - return PubkyError.ProfileNotFound( - ) - if variant == 7: - return PubkyError.ProfileParseFailed( - _UniffiConverterString.read(buf), - ) - if variant == 8: - return PubkyError.KeyError( + return PassphraseResponse.HIDDEN( _UniffiConverterString.read(buf), ) - if variant == 9: - return PubkyError.WriteFailed( - _UniffiConverterString.read(buf), + if variant == 4: + return PassphraseResponse.ON_DEVICE( ) raise InternalError("Raw enum value doesn't match any cases") @staticmethod def check_lower(value): - if isinstance(value, PubkyError.InvalidCapabilities): - _UniffiConverterString.check_lower(value.reason) - return - if isinstance(value, PubkyError.AuthFailed): - _UniffiConverterString.check_lower(value.reason) - return - if isinstance(value, PubkyError.NoActiveFlow): - return - if isinstance(value, PubkyError.ResolutionFailed): - _UniffiConverterString.check_lower(value.reason) - return - if isinstance(value, PubkyError.FetchFailed): - _UniffiConverterString.check_lower(value.reason) - return - if isinstance(value, PubkyError.ProfileNotFound): + if value.is_CANCEL(): return - if isinstance(value, PubkyError.ProfileParseFailed): - _UniffiConverterString.check_lower(value.reason) + if value.is_STANDARD(): return - if isinstance(value, PubkyError.KeyError): - _UniffiConverterString.check_lower(value.reason) + if value.is_HIDDEN(): + _UniffiConverterString.check_lower(value.value) return - if isinstance(value, PubkyError.WriteFailed): - _UniffiConverterString.check_lower(value.reason) + if value.is_ON_DEVICE(): return + raise ValueError(value) @staticmethod def write(value, buf): - if isinstance(value, PubkyError.InvalidCapabilities): + if value.is_CANCEL(): buf.write_i32(1) - _UniffiConverterString.write(value.reason, buf) - if isinstance(value, PubkyError.AuthFailed): + if value.is_STANDARD(): buf.write_i32(2) - _UniffiConverterString.write(value.reason, buf) - if isinstance(value, PubkyError.NoActiveFlow): + if value.is_HIDDEN(): buf.write_i32(3) - if isinstance(value, PubkyError.ResolutionFailed): + _UniffiConverterString.write(value.value, buf) + if value.is_ON_DEVICE(): buf.write_i32(4) - _UniffiConverterString.write(value.reason, buf) - if isinstance(value, PubkyError.FetchFailed): - buf.write_i32(5) - _UniffiConverterString.write(value.reason, buf) - if isinstance(value, PubkyError.ProfileNotFound): - buf.write_i32(6) - if isinstance(value, PubkyError.ProfileParseFailed): - buf.write_i32(7) - _UniffiConverterString.write(value.reason, buf) - if isinstance(value, PubkyError.KeyError): - buf.write_i32(8) - _UniffiConverterString.write(value.reason, buf) - if isinstance(value, PubkyError.WriteFailed): - buf.write_i32(9) - _UniffiConverterString.write(value.reason, buf) -class Scanner: - def __init__(self): - raise RuntimeError("Scanner cannot be instantiated directly") - # Each enum variant is a nested class of the enum itself. - class ON_CHAIN: - invoice: "OnChainInvoice" - def __init__(self,invoice: "OnChainInvoice"): - self.invoice = invoice +class PaymentState(enum.Enum): + PENDING = 0 + + SUCCEEDED = 1 + + FAILED = 2 + - def __str__(self): - return "Scanner.ON_CHAIN(invoice={})".format(self.invoice) - def __eq__(self, other): - if not other.is_ON_CHAIN(): - return False - if self.invoice != other.invoice: - return False - return True - - class LIGHTNING: - invoice: "LightningInvoice" +class _UniffiConverterTypePaymentState(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + variant = buf.read_i32() + if variant == 1: + return PaymentState.PENDING + if variant == 2: + return PaymentState.SUCCEEDED + if variant == 3: + return PaymentState.FAILED + raise InternalError("Raw enum value doesn't match any cases") - def __init__(self,invoice: "LightningInvoice"): - self.invoice = invoice + @staticmethod + def check_lower(value): + if value == PaymentState.PENDING: + return + if value == PaymentState.SUCCEEDED: + return + if value == PaymentState.FAILED: + return + raise ValueError(value) - def __str__(self): - return "Scanner.LIGHTNING(invoice={})".format(self.invoice) + @staticmethod + def write(value, buf): + if value == PaymentState.PENDING: + buf.write_i32(1) + if value == PaymentState.SUCCEEDED: + buf.write_i32(2) + if value == PaymentState.FAILED: + buf.write_i32(3) - def __eq__(self, other): - if not other.is_LIGHTNING(): - return False - if self.invoice != other.invoice: - return False - return True - - class PUBKY_AUTH: - data: "str" - def __init__(self,data: "str"): - self.data = data - def __str__(self): - return "Scanner.PUBKY_AUTH(data={})".format(self.data) - def __eq__(self, other): - if not other.is_PUBKY_AUTH(): - return False - if self.data != other.data: - return False - return True - - class LNURL_CHANNEL: - data: "LnurlChannelData" - def __init__(self,data: "LnurlChannelData"): - self.data = data - def __str__(self): - return "Scanner.LNURL_CHANNEL(data={})".format(self.data) - def __eq__(self, other): - if not other.is_LNURL_CHANNEL(): - return False - if self.data != other.data: - return False - return True +class PaymentType(enum.Enum): + SENT = 0 + + RECEIVED = 1 - class LNURL_AUTH: - data: "LnurlAuthData" - - def __init__(self,data: "LnurlAuthData"): - self.data = data - def __str__(self): - return "Scanner.LNURL_AUTH(data={})".format(self.data) - def __eq__(self, other): - if not other.is_LNURL_AUTH(): - return False - if self.data != other.data: - return False - return True - - class LNURL_WITHDRAW: - data: "LnurlWithdrawData" +class _UniffiConverterTypePaymentType(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + variant = buf.read_i32() + if variant == 1: + return PaymentType.SENT + if variant == 2: + return PaymentType.RECEIVED + raise InternalError("Raw enum value doesn't match any cases") - def __init__(self,data: "LnurlWithdrawData"): - self.data = data + @staticmethod + def check_lower(value): + if value == PaymentType.SENT: + return + if value == PaymentType.RECEIVED: + return + raise ValueError(value) - def __str__(self): - return "Scanner.LNURL_WITHDRAW(data={})".format(self.data) + @staticmethod + def write(value, buf): + if value == PaymentType.SENT: + buf.write_i32(1) + if value == PaymentType.RECEIVED: + buf.write_i32(2) - def __eq__(self, other): - if not other.is_LNURL_WITHDRAW(): - return False - if self.data != other.data: - return False - return True - - class LNURL_ADDRESS: - data: "LnurlAddressData" - def __init__(self,data: "LnurlAddressData"): - self.data = data - def __str__(self): - return "Scanner.LNURL_ADDRESS(data={})".format(self.data) - def __eq__(self, other): - if not other.is_LNURL_ADDRESS(): - return False - if self.data != other.data: - return False - return True - - class LNURL_PAY: - data: "LnurlPayData" +# PsbtCompletionError +# We want to define each variant as a nested class that's also a subclass, +# which is tricky in Python. To accomplish this we're going to create each +# class separately, then manually add the child classes to the base class's +# __dict__. All of this happens in dummy class to avoid polluting the module +# namespace. +class PsbtCompletionError(Exception): + pass - def __init__(self,data: "LnurlPayData"): - self.data = data +_UniffiTempPsbtCompletionError = PsbtCompletionError - def __str__(self): - return "Scanner.LNURL_PAY(data={})".format(self.data) +class PsbtCompletionError: # type: ignore + class InvalidPsbt(_UniffiTempPsbtCompletionError): + def __init__(self, reason): + super().__init__(", ".join([ + "reason={!r}".format(reason), + ])) + self.reason = reason - def __eq__(self, other): - if not other.is_LNURL_PAY(): - return False - if self.data != other.data: - return False - return True - - class NODE_ID: - url: "str" - network: "NetworkType" + def __repr__(self): + return "PsbtCompletionError.InvalidPsbt({})".format(str(self)) + _UniffiTempPsbtCompletionError.InvalidPsbt = InvalidPsbt # type: ignore + class CombineFailed(_UniffiTempPsbtCompletionError): + def __init__(self, reason): + super().__init__(", ".join([ + "reason={!r}".format(reason), + ])) + self.reason = reason - def __init__(self,url: "str", network: "NetworkType"): - self.url = url - self.network = network + def __repr__(self): + return "PsbtCompletionError.CombineFailed({})".format(str(self)) + _UniffiTempPsbtCompletionError.CombineFailed = CombineFailed # type: ignore + class FinalizationFailed(_UniffiTempPsbtCompletionError): + def __init__(self, reason): + super().__init__(", ".join([ + "reason={!r}".format(reason), + ])) + self.reason = reason - def __str__(self): - return "Scanner.NODE_ID(url={}, network={})".format(self.url, self.network) + def __repr__(self): + return "PsbtCompletionError.FinalizationFailed({})".format(str(self)) + _UniffiTempPsbtCompletionError.FinalizationFailed = FinalizationFailed # type: ignore + class VerificationFailed(_UniffiTempPsbtCompletionError): + def __init__(self, reason): + super().__init__(", ".join([ + "reason={!r}".format(reason), + ])) + self.reason = reason - def __eq__(self, other): - if not other.is_NODE_ID(): - return False - if self.url != other.url: - return False - if self.network != other.network: - return False - return True - - class GIFT: - code: "str" - amount: "int" + def __repr__(self): + return "PsbtCompletionError.VerificationFailed({})".format(str(self)) + _UniffiTempPsbtCompletionError.VerificationFailed = VerificationFailed # type: ignore + class ExtractionFailed(_UniffiTempPsbtCompletionError): + def __init__(self, reason): + super().__init__(", ".join([ + "reason={!r}".format(reason), + ])) + self.reason = reason - def __init__(self,code: "str", amount: "int"): - self.code = code - self.amount = amount + def __repr__(self): + return "PsbtCompletionError.ExtractionFailed({})".format(str(self)) + _UniffiTempPsbtCompletionError.ExtractionFailed = ExtractionFailed # type: ignore - def __str__(self): - return "Scanner.GIFT(code={}, amount={})".format(self.code, self.amount) +PsbtCompletionError = _UniffiTempPsbtCompletionError # type: ignore +del _UniffiTempPsbtCompletionError - def __eq__(self, other): - if not other.is_GIFT(): - return False - if self.code != other.code: - return False - if self.amount != other.amount: - return False - return True - - - # For each variant, we have `is_NAME` and `is_name` methods for easily checking - # whether an instance is that variant. - def is_ON_CHAIN(self) -> bool: - return isinstance(self, Scanner.ON_CHAIN) - def is_on_chain(self) -> bool: - return isinstance(self, Scanner.ON_CHAIN) - def is_LIGHTNING(self) -> bool: - return isinstance(self, Scanner.LIGHTNING) - def is_lightning(self) -> bool: - return isinstance(self, Scanner.LIGHTNING) - def is_PUBKY_AUTH(self) -> bool: - return isinstance(self, Scanner.PUBKY_AUTH) - def is_pubky_auth(self) -> bool: - return isinstance(self, Scanner.PUBKY_AUTH) - def is_LNURL_CHANNEL(self) -> bool: - return isinstance(self, Scanner.LNURL_CHANNEL) - def is_lnurl_channel(self) -> bool: - return isinstance(self, Scanner.LNURL_CHANNEL) - def is_LNURL_AUTH(self) -> bool: - return isinstance(self, Scanner.LNURL_AUTH) - def is_lnurl_auth(self) -> bool: - return isinstance(self, Scanner.LNURL_AUTH) - def is_LNURL_WITHDRAW(self) -> bool: - return isinstance(self, Scanner.LNURL_WITHDRAW) - def is_lnurl_withdraw(self) -> bool: - return isinstance(self, Scanner.LNURL_WITHDRAW) - def is_LNURL_ADDRESS(self) -> bool: - return isinstance(self, Scanner.LNURL_ADDRESS) - def is_lnurl_address(self) -> bool: - return isinstance(self, Scanner.LNURL_ADDRESS) - def is_LNURL_PAY(self) -> bool: - return isinstance(self, Scanner.LNURL_PAY) - def is_lnurl_pay(self) -> bool: - return isinstance(self, Scanner.LNURL_PAY) - def is_NODE_ID(self) -> bool: - return isinstance(self, Scanner.NODE_ID) - def is_node_id(self) -> bool: - return isinstance(self, Scanner.NODE_ID) - def is_GIFT(self) -> bool: - return isinstance(self, Scanner.GIFT) - def is_gift(self) -> bool: - return isinstance(self, Scanner.GIFT) - - -# Now, a little trick - we make each nested variant class be a subclass of the main -# enum class, so that method calls and instance checks etc will work intuitively. -# We might be able to do this a little more neatly with a metaclass, but this'll do. -Scanner.ON_CHAIN = type("Scanner.ON_CHAIN", (Scanner.ON_CHAIN, Scanner,), {}) # type: ignore -Scanner.LIGHTNING = type("Scanner.LIGHTNING", (Scanner.LIGHTNING, Scanner,), {}) # type: ignore -Scanner.PUBKY_AUTH = type("Scanner.PUBKY_AUTH", (Scanner.PUBKY_AUTH, Scanner,), {}) # type: ignore -Scanner.LNURL_CHANNEL = type("Scanner.LNURL_CHANNEL", (Scanner.LNURL_CHANNEL, Scanner,), {}) # type: ignore -Scanner.LNURL_AUTH = type("Scanner.LNURL_AUTH", (Scanner.LNURL_AUTH, Scanner,), {}) # type: ignore -Scanner.LNURL_WITHDRAW = type("Scanner.LNURL_WITHDRAW", (Scanner.LNURL_WITHDRAW, Scanner,), {}) # type: ignore -Scanner.LNURL_ADDRESS = type("Scanner.LNURL_ADDRESS", (Scanner.LNURL_ADDRESS, Scanner,), {}) # type: ignore -Scanner.LNURL_PAY = type("Scanner.LNURL_PAY", (Scanner.LNURL_PAY, Scanner,), {}) # type: ignore -Scanner.NODE_ID = type("Scanner.NODE_ID", (Scanner.NODE_ID, Scanner,), {}) # type: ignore -Scanner.GIFT = type("Scanner.GIFT", (Scanner.GIFT, Scanner,), {}) # type: ignore - - - - -class _UniffiConverterTypeScanner(_UniffiConverterRustBuffer): +class _UniffiConverterTypePsbtCompletionError(_UniffiConverterRustBuffer): @staticmethod def read(buf): variant = buf.read_i32() if variant == 1: - return Scanner.ON_CHAIN( - _UniffiConverterTypeOnChainInvoice.read(buf), + return PsbtCompletionError.InvalidPsbt( + _UniffiConverterString.read(buf), ) if variant == 2: - return Scanner.LIGHTNING( - _UniffiConverterTypeLightningInvoice.read(buf), + return PsbtCompletionError.CombineFailed( + _UniffiConverterString.read(buf), ) if variant == 3: - return Scanner.PUBKY_AUTH( + return PsbtCompletionError.FinalizationFailed( _UniffiConverterString.read(buf), ) if variant == 4: - return Scanner.LNURL_CHANNEL( - _UniffiConverterTypeLnurlChannelData.read(buf), - ) - if variant == 5: - return Scanner.LNURL_AUTH( - _UniffiConverterTypeLnurlAuthData.read(buf), - ) - if variant == 6: - return Scanner.LNURL_WITHDRAW( - _UniffiConverterTypeLnurlWithdrawData.read(buf), - ) - if variant == 7: - return Scanner.LNURL_ADDRESS( - _UniffiConverterTypeLnurlAddressData.read(buf), - ) - if variant == 8: - return Scanner.LNURL_PAY( - _UniffiConverterTypeLnurlPayData.read(buf), - ) - if variant == 9: - return Scanner.NODE_ID( + return PsbtCompletionError.VerificationFailed( _UniffiConverterString.read(buf), - _UniffiConverterTypeNetworkType.read(buf), ) - if variant == 10: - return Scanner.GIFT( + if variant == 5: + return PsbtCompletionError.ExtractionFailed( _UniffiConverterString.read(buf), - _UniffiConverterUInt64.read(buf), ) raise InternalError("Raw enum value doesn't match any cases") @staticmethod def check_lower(value): - if value.is_ON_CHAIN(): - _UniffiConverterTypeOnChainInvoice.check_lower(value.invoice) - return - if value.is_LIGHTNING(): - _UniffiConverterTypeLightningInvoice.check_lower(value.invoice) - return - if value.is_PUBKY_AUTH(): - _UniffiConverterString.check_lower(value.data) - return - if value.is_LNURL_CHANNEL(): - _UniffiConverterTypeLnurlChannelData.check_lower(value.data) - return - if value.is_LNURL_AUTH(): - _UniffiConverterTypeLnurlAuthData.check_lower(value.data) - return - if value.is_LNURL_WITHDRAW(): - _UniffiConverterTypeLnurlWithdrawData.check_lower(value.data) + if isinstance(value, PsbtCompletionError.InvalidPsbt): + _UniffiConverterString.check_lower(value.reason) return - if value.is_LNURL_ADDRESS(): - _UniffiConverterTypeLnurlAddressData.check_lower(value.data) + if isinstance(value, PsbtCompletionError.CombineFailed): + _UniffiConverterString.check_lower(value.reason) return - if value.is_LNURL_PAY(): - _UniffiConverterTypeLnurlPayData.check_lower(value.data) + if isinstance(value, PsbtCompletionError.FinalizationFailed): + _UniffiConverterString.check_lower(value.reason) return - if value.is_NODE_ID(): - _UniffiConverterString.check_lower(value.url) - _UniffiConverterTypeNetworkType.check_lower(value.network) + if isinstance(value, PsbtCompletionError.VerificationFailed): + _UniffiConverterString.check_lower(value.reason) return - if value.is_GIFT(): - _UniffiConverterString.check_lower(value.code) - _UniffiConverterUInt64.check_lower(value.amount) + if isinstance(value, PsbtCompletionError.ExtractionFailed): + _UniffiConverterString.check_lower(value.reason) return - raise ValueError(value) @staticmethod def write(value, buf): - if value.is_ON_CHAIN(): + if isinstance(value, PsbtCompletionError.InvalidPsbt): buf.write_i32(1) - _UniffiConverterTypeOnChainInvoice.write(value.invoice, buf) - if value.is_LIGHTNING(): + _UniffiConverterString.write(value.reason, buf) + if isinstance(value, PsbtCompletionError.CombineFailed): buf.write_i32(2) - _UniffiConverterTypeLightningInvoice.write(value.invoice, buf) - if value.is_PUBKY_AUTH(): + _UniffiConverterString.write(value.reason, buf) + if isinstance(value, PsbtCompletionError.FinalizationFailed): buf.write_i32(3) - _UniffiConverterString.write(value.data, buf) - if value.is_LNURL_CHANNEL(): + _UniffiConverterString.write(value.reason, buf) + if isinstance(value, PsbtCompletionError.VerificationFailed): buf.write_i32(4) - _UniffiConverterTypeLnurlChannelData.write(value.data, buf) - if value.is_LNURL_AUTH(): + _UniffiConverterString.write(value.reason, buf) + if isinstance(value, PsbtCompletionError.ExtractionFailed): buf.write_i32(5) - _UniffiConverterTypeLnurlAuthData.write(value.data, buf) - if value.is_LNURL_WITHDRAW(): - buf.write_i32(6) - _UniffiConverterTypeLnurlWithdrawData.write(value.data, buf) - if value.is_LNURL_ADDRESS(): - buf.write_i32(7) - _UniffiConverterTypeLnurlAddressData.write(value.data, buf) - if value.is_LNURL_PAY(): - buf.write_i32(8) - _UniffiConverterTypeLnurlPayData.write(value.data, buf) - if value.is_NODE_ID(): - buf.write_i32(9) - _UniffiConverterString.write(value.url, buf) - _UniffiConverterTypeNetworkType.write(value.network, buf) - if value.is_GIFT(): - buf.write_i32(10) - _UniffiConverterString.write(value.code, buf) - _UniffiConverterUInt64.write(value.amount, buf) - + _UniffiConverterString.write(value.reason, buf) +class PubkyAuthKind(enum.Enum): + """ + The type of a `pubkyauth://` deep-link flow. + """ -class SortDirection(enum.Enum): - ASC = 0 + SIGNIN = 0 - DESC = 1 + SIGNUP = 1 -class _UniffiConverterTypeSortDirection(_UniffiConverterRustBuffer): +class _UniffiConverterTypePubkyAuthKind(_UniffiConverterRustBuffer): @staticmethod def read(buf): variant = buf.read_i32() if variant == 1: - return SortDirection.ASC + return PubkyAuthKind.SIGNIN if variant == 2: - return SortDirection.DESC + return PubkyAuthKind.SIGNUP raise InternalError("Raw enum value doesn't match any cases") @staticmethod def check_lower(value): - if value == SortDirection.ASC: + if value == PubkyAuthKind.SIGNIN: return - if value == SortDirection.DESC: + if value == PubkyAuthKind.SIGNUP: return raise ValueError(value) @staticmethod def write(value, buf): - if value == SortDirection.ASC: + if value == PubkyAuthKind.SIGNIN: buf.write_i32(1) - if value == SortDirection.DESC: + if value == PubkyAuthKind.SIGNUP: buf.write_i32(2) -# SweepError +# PubkyError # We want to define each variant as a nested class that's also a subclass, # which is tricky in Python. To accomplish this we're going to create each # class separately, then manually add the child classes to the base class's # __dict__. All of this happens in dummy class to avoid polluting the module # namespace. -class SweepError(Exception): +class PubkyError(Exception): pass -_UniffiTempSweepError = SweepError +_UniffiTempPubkyError = PubkyError -class SweepError: # type: ignore - class SweepFailed(_UniffiTempSweepError): - def __init__(self, *values): - if len(values) != 1: - raise TypeError(f"Expected 1 arguments, found {len(values)}") - if not isinstance(values[0], str): - raise TypeError(f"unexpected type for tuple element 0 - expected 'str', got '{type(values[0])}'") - super().__init__(", ".join(map(repr, values))) - self._values = values +class PubkyError: # type: ignore + class InvalidCapabilities(_UniffiTempPubkyError): + def __init__(self, reason): + super().__init__(", ".join([ + "reason={!r}".format(reason), + ])) + self.reason = reason - def __getitem__(self, index): - return self._values[index] + def __repr__(self): + return "PubkyError.InvalidCapabilities({})".format(str(self)) + _UniffiTempPubkyError.InvalidCapabilities = InvalidCapabilities # type: ignore + class AuthFailed(_UniffiTempPubkyError): + def __init__(self, reason): + super().__init__(", ".join([ + "reason={!r}".format(reason), + ])) + self.reason = reason def __repr__(self): - return "SweepError.SweepFailed({})".format(str(self)) - _UniffiTempSweepError.SweepFailed = SweepFailed # type: ignore - class NoUtxosFound(_UniffiTempSweepError): + return "PubkyError.AuthFailed({})".format(str(self)) + _UniffiTempPubkyError.AuthFailed = AuthFailed # type: ignore + class NoActiveFlow(_UniffiTempPubkyError): def __init__(self): pass def __repr__(self): - return "SweepError.NoUtxosFound({})".format(str(self)) - _UniffiTempSweepError.NoUtxosFound = NoUtxosFound # type: ignore - class InvalidMnemonic(_UniffiTempSweepError): + return "PubkyError.NoActiveFlow({})".format(str(self)) + _UniffiTempPubkyError.NoActiveFlow = NoActiveFlow # type: ignore + class ResolutionFailed(_UniffiTempPubkyError): + def __init__(self, reason): + super().__init__(", ".join([ + "reason={!r}".format(reason), + ])) + self.reason = reason + + def __repr__(self): + return "PubkyError.ResolutionFailed({})".format(str(self)) + _UniffiTempPubkyError.ResolutionFailed = ResolutionFailed # type: ignore + class FetchFailed(_UniffiTempPubkyError): + def __init__(self, reason): + super().__init__(", ".join([ + "reason={!r}".format(reason), + ])) + self.reason = reason + + def __repr__(self): + return "PubkyError.FetchFailed({})".format(str(self)) + _UniffiTempPubkyError.FetchFailed = FetchFailed # type: ignore + class ProfileNotFound(_UniffiTempPubkyError): def __init__(self): pass def __repr__(self): - return "SweepError.InvalidMnemonic({})".format(str(self)) - _UniffiTempSweepError.InvalidMnemonic = InvalidMnemonic # type: ignore - -SweepError = _UniffiTempSweepError # type: ignore -del _UniffiTempSweepError + return "PubkyError.ProfileNotFound({})".format(str(self)) + _UniffiTempPubkyError.ProfileNotFound = ProfileNotFound # type: ignore + class ProfileParseFailed(_UniffiTempPubkyError): + def __init__(self, reason): + super().__init__(", ".join([ + "reason={!r}".format(reason), + ])) + self.reason = reason + + def __repr__(self): + return "PubkyError.ProfileParseFailed({})".format(str(self)) + _UniffiTempPubkyError.ProfileParseFailed = ProfileParseFailed # type: ignore + class KeyError(_UniffiTempPubkyError): + def __init__(self, reason): + super().__init__(", ".join([ + "reason={!r}".format(reason), + ])) + self.reason = reason + def __repr__(self): + return "PubkyError.KeyError({})".format(str(self)) + _UniffiTempPubkyError.KeyError = KeyError # type: ignore + class WriteFailed(_UniffiTempPubkyError): + def __init__(self, reason): + super().__init__(", ".join([ + "reason={!r}".format(reason), + ])) + self.reason = reason -class _UniffiConverterTypeSweepError(_UniffiConverterRustBuffer): + def __repr__(self): + return "PubkyError.WriteFailed({})".format(str(self)) + _UniffiTempPubkyError.WriteFailed = WriteFailed # type: ignore + +PubkyError = _UniffiTempPubkyError # type: ignore +del _UniffiTempPubkyError + + +class _UniffiConverterTypePubkyError(_UniffiConverterRustBuffer): @staticmethod def read(buf): variant = buf.read_i32() if variant == 1: - return SweepError.SweepFailed( + return PubkyError.InvalidCapabilities( _UniffiConverterString.read(buf), ) if variant == 2: - return SweepError.NoUtxosFound( + return PubkyError.AuthFailed( + _UniffiConverterString.read(buf), ) if variant == 3: - return SweepError.InvalidMnemonic( + return PubkyError.NoActiveFlow( + ) + if variant == 4: + return PubkyError.ResolutionFailed( + _UniffiConverterString.read(buf), + ) + if variant == 5: + return PubkyError.FetchFailed( + _UniffiConverterString.read(buf), + ) + if variant == 6: + return PubkyError.ProfileNotFound( + ) + if variant == 7: + return PubkyError.ProfileParseFailed( + _UniffiConverterString.read(buf), + ) + if variant == 8: + return PubkyError.KeyError( + _UniffiConverterString.read(buf), + ) + if variant == 9: + return PubkyError.WriteFailed( + _UniffiConverterString.read(buf), ) raise InternalError("Raw enum value doesn't match any cases") @staticmethod def check_lower(value): - if isinstance(value, SweepError.SweepFailed): - _UniffiConverterString.check_lower(value._values[0]) + if isinstance(value, PubkyError.InvalidCapabilities): + _UniffiConverterString.check_lower(value.reason) return - if isinstance(value, SweepError.NoUtxosFound): + if isinstance(value, PubkyError.AuthFailed): + _UniffiConverterString.check_lower(value.reason) return - if isinstance(value, SweepError.InvalidMnemonic): + if isinstance(value, PubkyError.NoActiveFlow): + return + if isinstance(value, PubkyError.ResolutionFailed): + _UniffiConverterString.check_lower(value.reason) + return + if isinstance(value, PubkyError.FetchFailed): + _UniffiConverterString.check_lower(value.reason) + return + if isinstance(value, PubkyError.ProfileNotFound): + return + if isinstance(value, PubkyError.ProfileParseFailed): + _UniffiConverterString.check_lower(value.reason) + return + if isinstance(value, PubkyError.KeyError): + _UniffiConverterString.check_lower(value.reason) + return + if isinstance(value, PubkyError.WriteFailed): + _UniffiConverterString.check_lower(value.reason) return @staticmethod def write(value, buf): - if isinstance(value, SweepError.SweepFailed): + if isinstance(value, PubkyError.InvalidCapabilities): buf.write_i32(1) - _UniffiConverterString.write(value._values[0], buf) - if isinstance(value, SweepError.NoUtxosFound): + _UniffiConverterString.write(value.reason, buf) + if isinstance(value, PubkyError.AuthFailed): buf.write_i32(2) - if isinstance(value, SweepError.InvalidMnemonic): + _UniffiConverterString.write(value.reason, buf) + if isinstance(value, PubkyError.NoActiveFlow): buf.write_i32(3) + if isinstance(value, PubkyError.ResolutionFailed): + buf.write_i32(4) + _UniffiConverterString.write(value.reason, buf) + if isinstance(value, PubkyError.FetchFailed): + buf.write_i32(5) + _UniffiConverterString.write(value.reason, buf) + if isinstance(value, PubkyError.ProfileNotFound): + buf.write_i32(6) + if isinstance(value, PubkyError.ProfileParseFailed): + buf.write_i32(7) + _UniffiConverterString.write(value.reason, buf) + if isinstance(value, PubkyError.KeyError): + buf.write_i32(8) + _UniffiConverterString.write(value.reason, buf) + if isinstance(value, PubkyError.WriteFailed): + buf.write_i32(9) + _UniffiConverterString.write(value.reason, buf) -class TrezorCoinType(enum.Enum): - """ - Bitcoin network / coin type for Trezor operations. - """ - - BITCOIN = 0 - """ - Bitcoin mainnet - """ +class Scanner: + def __init__(self): + raise RuntimeError("Scanner cannot be instantiated directly") - - TESTNET = 1 - """ - Bitcoin testnet - """ + # Each enum variant is a nested class of the enum itself. + class ON_CHAIN: + invoice: "OnChainInvoice" - - SIGNET = 2 - """ - Bitcoin signet (treated as testnet by the device) - """ + def __init__(self,invoice: "OnChainInvoice"): + self.invoice = invoice - - REGTEST = 3 - """ - Bitcoin regtest - """ + def __str__(self): + return "Scanner.ON_CHAIN(invoice={})".format(self.invoice) + def __eq__(self, other): + if not other.is_ON_CHAIN(): + return False + if self.invoice != other.invoice: + return False + return True + class LIGHTNING: + invoice: "LightningInvoice" + def __init__(self,invoice: "LightningInvoice"): + self.invoice = invoice -class _UniffiConverterTypeTrezorCoinType(_UniffiConverterRustBuffer): - @staticmethod - def read(buf): - variant = buf.read_i32() - if variant == 1: - return TrezorCoinType.BITCOIN - if variant == 2: - return TrezorCoinType.TESTNET - if variant == 3: - return TrezorCoinType.SIGNET - if variant == 4: - return TrezorCoinType.REGTEST - raise InternalError("Raw enum value doesn't match any cases") + def __str__(self): + return "Scanner.LIGHTNING(invoice={})".format(self.invoice) - @staticmethod - def check_lower(value): - if value == TrezorCoinType.BITCOIN: - return - if value == TrezorCoinType.TESTNET: - return - if value == TrezorCoinType.SIGNET: - return - if value == TrezorCoinType.REGTEST: - return - raise ValueError(value) + def __eq__(self, other): + if not other.is_LIGHTNING(): + return False + if self.invoice != other.invoice: + return False + return True + + class PUBKY_AUTH: + data: "str" - @staticmethod - def write(value, buf): - if value == TrezorCoinType.BITCOIN: - buf.write_i32(1) - if value == TrezorCoinType.TESTNET: - buf.write_i32(2) - if value == TrezorCoinType.SIGNET: - buf.write_i32(3) - if value == TrezorCoinType.REGTEST: - buf.write_i32(4) + def __init__(self,data: "str"): + self.data = data + def __str__(self): + return "Scanner.PUBKY_AUTH(data={})".format(self.data) + def __eq__(self, other): + if not other.is_PUBKY_AUTH(): + return False + if self.data != other.data: + return False + return True + + class LNURL_CHANNEL: + data: "LnurlChannelData" + def __init__(self,data: "LnurlChannelData"): + self.data = data -# TrezorError -# We want to define each variant as a nested class that's also a subclass, -# which is tricky in Python. To accomplish this we're going to create each -# class separately, then manually add the child classes to the base class's -# __dict__. All of this happens in dummy class to avoid polluting the module -# namespace. -class TrezorError(Exception): - """ - Trezor-related errors exposed via FFI. - """ + def __str__(self): + return "Scanner.LNURL_CHANNEL(data={})".format(self.data) - pass + def __eq__(self, other): + if not other.is_LNURL_CHANNEL(): + return False + if self.data != other.data: + return False + return True + + class LNURL_AUTH: + data: "LnurlAuthData" -_UniffiTempTrezorError = TrezorError + def __init__(self,data: "LnurlAuthData"): + self.data = data -class TrezorError: # type: ignore - """ - Trezor-related errors exposed via FFI. - """ + def __str__(self): + return "Scanner.LNURL_AUTH(data={})".format(self.data) + + def __eq__(self, other): + if not other.is_LNURL_AUTH(): + return False + if self.data != other.data: + return False + return True + + class LNURL_WITHDRAW: + data: "LnurlWithdrawData" + + def __init__(self,data: "LnurlWithdrawData"): + self.data = data + + def __str__(self): + return "Scanner.LNURL_WITHDRAW(data={})".format(self.data) + + def __eq__(self, other): + if not other.is_LNURL_WITHDRAW(): + return False + if self.data != other.data: + return False + return True + + class LNURL_ADDRESS: + data: "LnurlAddressData" + + def __init__(self,data: "LnurlAddressData"): + self.data = data + + def __str__(self): + return "Scanner.LNURL_ADDRESS(data={})".format(self.data) + + def __eq__(self, other): + if not other.is_LNURL_ADDRESS(): + return False + if self.data != other.data: + return False + return True + + class LNURL_PAY: + data: "LnurlPayData" + + def __init__(self,data: "LnurlPayData"): + self.data = data + + def __str__(self): + return "Scanner.LNURL_PAY(data={})".format(self.data) + + def __eq__(self, other): + if not other.is_LNURL_PAY(): + return False + if self.data != other.data: + return False + return True + + class NODE_ID: + url: "str" + network: "NetworkType" + + def __init__(self,url: "str", network: "NetworkType"): + self.url = url + self.network = network + + def __str__(self): + return "Scanner.NODE_ID(url={}, network={})".format(self.url, self.network) + + def __eq__(self, other): + if not other.is_NODE_ID(): + return False + if self.url != other.url: + return False + if self.network != other.network: + return False + return True + + class GIFT: + code: "str" + amount: "int" + + def __init__(self,code: "str", amount: "int"): + self.code = code + self.amount = amount + + def __str__(self): + return "Scanner.GIFT(code={}, amount={})".format(self.code, self.amount) + + def __eq__(self, other): + if not other.is_GIFT(): + return False + if self.code != other.code: + return False + if self.amount != other.amount: + return False + return True + + + + # For each variant, we have `is_NAME` and `is_name` methods for easily checking + # whether an instance is that variant. + def is_ON_CHAIN(self) -> bool: + return isinstance(self, Scanner.ON_CHAIN) + def is_on_chain(self) -> bool: + return isinstance(self, Scanner.ON_CHAIN) + def is_LIGHTNING(self) -> bool: + return isinstance(self, Scanner.LIGHTNING) + def is_lightning(self) -> bool: + return isinstance(self, Scanner.LIGHTNING) + def is_PUBKY_AUTH(self) -> bool: + return isinstance(self, Scanner.PUBKY_AUTH) + def is_pubky_auth(self) -> bool: + return isinstance(self, Scanner.PUBKY_AUTH) + def is_LNURL_CHANNEL(self) -> bool: + return isinstance(self, Scanner.LNURL_CHANNEL) + def is_lnurl_channel(self) -> bool: + return isinstance(self, Scanner.LNURL_CHANNEL) + def is_LNURL_AUTH(self) -> bool: + return isinstance(self, Scanner.LNURL_AUTH) + def is_lnurl_auth(self) -> bool: + return isinstance(self, Scanner.LNURL_AUTH) + def is_LNURL_WITHDRAW(self) -> bool: + return isinstance(self, Scanner.LNURL_WITHDRAW) + def is_lnurl_withdraw(self) -> bool: + return isinstance(self, Scanner.LNURL_WITHDRAW) + def is_LNURL_ADDRESS(self) -> bool: + return isinstance(self, Scanner.LNURL_ADDRESS) + def is_lnurl_address(self) -> bool: + return isinstance(self, Scanner.LNURL_ADDRESS) + def is_LNURL_PAY(self) -> bool: + return isinstance(self, Scanner.LNURL_PAY) + def is_lnurl_pay(self) -> bool: + return isinstance(self, Scanner.LNURL_PAY) + def is_NODE_ID(self) -> bool: + return isinstance(self, Scanner.NODE_ID) + def is_node_id(self) -> bool: + return isinstance(self, Scanner.NODE_ID) + def is_GIFT(self) -> bool: + return isinstance(self, Scanner.GIFT) + def is_gift(self) -> bool: + return isinstance(self, Scanner.GIFT) + + +# Now, a little trick - we make each nested variant class be a subclass of the main +# enum class, so that method calls and instance checks etc will work intuitively. +# We might be able to do this a little more neatly with a metaclass, but this'll do. +Scanner.ON_CHAIN = type("Scanner.ON_CHAIN", (Scanner.ON_CHAIN, Scanner,), {}) # type: ignore +Scanner.LIGHTNING = type("Scanner.LIGHTNING", (Scanner.LIGHTNING, Scanner,), {}) # type: ignore +Scanner.PUBKY_AUTH = type("Scanner.PUBKY_AUTH", (Scanner.PUBKY_AUTH, Scanner,), {}) # type: ignore +Scanner.LNURL_CHANNEL = type("Scanner.LNURL_CHANNEL", (Scanner.LNURL_CHANNEL, Scanner,), {}) # type: ignore +Scanner.LNURL_AUTH = type("Scanner.LNURL_AUTH", (Scanner.LNURL_AUTH, Scanner,), {}) # type: ignore +Scanner.LNURL_WITHDRAW = type("Scanner.LNURL_WITHDRAW", (Scanner.LNURL_WITHDRAW, Scanner,), {}) # type: ignore +Scanner.LNURL_ADDRESS = type("Scanner.LNURL_ADDRESS", (Scanner.LNURL_ADDRESS, Scanner,), {}) # type: ignore +Scanner.LNURL_PAY = type("Scanner.LNURL_PAY", (Scanner.LNURL_PAY, Scanner,), {}) # type: ignore +Scanner.NODE_ID = type("Scanner.NODE_ID", (Scanner.NODE_ID, Scanner,), {}) # type: ignore +Scanner.GIFT = type("Scanner.GIFT", (Scanner.GIFT, Scanner,), {}) # type: ignore + + + + +class _UniffiConverterTypeScanner(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + variant = buf.read_i32() + if variant == 1: + return Scanner.ON_CHAIN( + _UniffiConverterTypeOnChainInvoice.read(buf), + ) + if variant == 2: + return Scanner.LIGHTNING( + _UniffiConverterTypeLightningInvoice.read(buf), + ) + if variant == 3: + return Scanner.PUBKY_AUTH( + _UniffiConverterString.read(buf), + ) + if variant == 4: + return Scanner.LNURL_CHANNEL( + _UniffiConverterTypeLnurlChannelData.read(buf), + ) + if variant == 5: + return Scanner.LNURL_AUTH( + _UniffiConverterTypeLnurlAuthData.read(buf), + ) + if variant == 6: + return Scanner.LNURL_WITHDRAW( + _UniffiConverterTypeLnurlWithdrawData.read(buf), + ) + if variant == 7: + return Scanner.LNURL_ADDRESS( + _UniffiConverterTypeLnurlAddressData.read(buf), + ) + if variant == 8: + return Scanner.LNURL_PAY( + _UniffiConverterTypeLnurlPayData.read(buf), + ) + if variant == 9: + return Scanner.NODE_ID( + _UniffiConverterString.read(buf), + _UniffiConverterTypeNetworkType.read(buf), + ) + if variant == 10: + return Scanner.GIFT( + _UniffiConverterString.read(buf), + _UniffiConverterUInt64.read(buf), + ) + raise InternalError("Raw enum value doesn't match any cases") + + @staticmethod + def check_lower(value): + if value.is_ON_CHAIN(): + _UniffiConverterTypeOnChainInvoice.check_lower(value.invoice) + return + if value.is_LIGHTNING(): + _UniffiConverterTypeLightningInvoice.check_lower(value.invoice) + return + if value.is_PUBKY_AUTH(): + _UniffiConverterString.check_lower(value.data) + return + if value.is_LNURL_CHANNEL(): + _UniffiConverterTypeLnurlChannelData.check_lower(value.data) + return + if value.is_LNURL_AUTH(): + _UniffiConverterTypeLnurlAuthData.check_lower(value.data) + return + if value.is_LNURL_WITHDRAW(): + _UniffiConverterTypeLnurlWithdrawData.check_lower(value.data) + return + if value.is_LNURL_ADDRESS(): + _UniffiConverterTypeLnurlAddressData.check_lower(value.data) + return + if value.is_LNURL_PAY(): + _UniffiConverterTypeLnurlPayData.check_lower(value.data) + return + if value.is_NODE_ID(): + _UniffiConverterString.check_lower(value.url) + _UniffiConverterTypeNetworkType.check_lower(value.network) + return + if value.is_GIFT(): + _UniffiConverterString.check_lower(value.code) + _UniffiConverterUInt64.check_lower(value.amount) + return + raise ValueError(value) + + @staticmethod + def write(value, buf): + if value.is_ON_CHAIN(): + buf.write_i32(1) + _UniffiConverterTypeOnChainInvoice.write(value.invoice, buf) + if value.is_LIGHTNING(): + buf.write_i32(2) + _UniffiConverterTypeLightningInvoice.write(value.invoice, buf) + if value.is_PUBKY_AUTH(): + buf.write_i32(3) + _UniffiConverterString.write(value.data, buf) + if value.is_LNURL_CHANNEL(): + buf.write_i32(4) + _UniffiConverterTypeLnurlChannelData.write(value.data, buf) + if value.is_LNURL_AUTH(): + buf.write_i32(5) + _UniffiConverterTypeLnurlAuthData.write(value.data, buf) + if value.is_LNURL_WITHDRAW(): + buf.write_i32(6) + _UniffiConverterTypeLnurlWithdrawData.write(value.data, buf) + if value.is_LNURL_ADDRESS(): + buf.write_i32(7) + _UniffiConverterTypeLnurlAddressData.write(value.data, buf) + if value.is_LNURL_PAY(): + buf.write_i32(8) + _UniffiConverterTypeLnurlPayData.write(value.data, buf) + if value.is_NODE_ID(): + buf.write_i32(9) + _UniffiConverterString.write(value.url, buf) + _UniffiConverterTypeNetworkType.write(value.network, buf) + if value.is_GIFT(): + buf.write_i32(10) + _UniffiConverterString.write(value.code, buf) + _UniffiConverterUInt64.write(value.amount, buf) + + + + + + + +class SortDirection(enum.Enum): + ASC = 0 + + DESC = 1 + + + +class _UniffiConverterTypeSortDirection(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + variant = buf.read_i32() + if variant == 1: + return SortDirection.ASC + if variant == 2: + return SortDirection.DESC + raise InternalError("Raw enum value doesn't match any cases") + + @staticmethod + def check_lower(value): + if value == SortDirection.ASC: + return + if value == SortDirection.DESC: + return + raise ValueError(value) + + @staticmethod + def write(value, buf): + if value == SortDirection.ASC: + buf.write_i32(1) + if value == SortDirection.DESC: + buf.write_i32(2) + + + + +# SweepError +# We want to define each variant as a nested class that's also a subclass, +# which is tricky in Python. To accomplish this we're going to create each +# class separately, then manually add the child classes to the base class's +# __dict__. All of this happens in dummy class to avoid polluting the module +# namespace. +class SweepError(Exception): + pass + +_UniffiTempSweepError = SweepError + +class SweepError: # type: ignore + class SweepFailed(_UniffiTempSweepError): + def __init__(self, *values): + if len(values) != 1: + raise TypeError(f"Expected 1 arguments, found {len(values)}") + if not isinstance(values[0], str): + raise TypeError(f"unexpected type for tuple element 0 - expected 'str', got '{type(values[0])}'") + super().__init__(", ".join(map(repr, values))) + self._values = values + + def __getitem__(self, index): + return self._values[index] + + def __repr__(self): + return "SweepError.SweepFailed({})".format(str(self)) + _UniffiTempSweepError.SweepFailed = SweepFailed # type: ignore + class NoUtxosFound(_UniffiTempSweepError): + def __init__(self): + pass + + def __repr__(self): + return "SweepError.NoUtxosFound({})".format(str(self)) + _UniffiTempSweepError.NoUtxosFound = NoUtxosFound # type: ignore + class InvalidMnemonic(_UniffiTempSweepError): + def __init__(self): + pass + + def __repr__(self): + return "SweepError.InvalidMnemonic({})".format(str(self)) + _UniffiTempSweepError.InvalidMnemonic = InvalidMnemonic # type: ignore + +SweepError = _UniffiTempSweepError # type: ignore +del _UniffiTempSweepError + + +class _UniffiConverterTypeSweepError(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + variant = buf.read_i32() + if variant == 1: + return SweepError.SweepFailed( + _UniffiConverterString.read(buf), + ) + if variant == 2: + return SweepError.NoUtxosFound( + ) + if variant == 3: + return SweepError.InvalidMnemonic( + ) + raise InternalError("Raw enum value doesn't match any cases") + + @staticmethod + def check_lower(value): + if isinstance(value, SweepError.SweepFailed): + _UniffiConverterString.check_lower(value._values[0]) + return + if isinstance(value, SweepError.NoUtxosFound): + return + if isinstance(value, SweepError.InvalidMnemonic): + return + + @staticmethod + def write(value, buf): + if isinstance(value, SweepError.SweepFailed): + buf.write_i32(1) + _UniffiConverterString.write(value._values[0], buf) + if isinstance(value, SweepError.NoUtxosFound): + buf.write_i32(2) + if isinstance(value, SweepError.InvalidMnemonic): + buf.write_i32(3) + + + + + +class TrezorCoinType(enum.Enum): + """ + Bitcoin network / coin type for Trezor operations. + """ + + BITCOIN = 0 + """ + Bitcoin mainnet + """ + + + TESTNET = 1 + """ + Bitcoin testnet + """ + + + SIGNET = 2 + """ + Bitcoin signet (treated as testnet by the device) + """ + + + REGTEST = 3 + """ + Bitcoin regtest + """ + + + + +class _UniffiConverterTypeTrezorCoinType(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + variant = buf.read_i32() + if variant == 1: + return TrezorCoinType.BITCOIN + if variant == 2: + return TrezorCoinType.TESTNET + if variant == 3: + return TrezorCoinType.SIGNET + if variant == 4: + return TrezorCoinType.REGTEST + raise InternalError("Raw enum value doesn't match any cases") + + @staticmethod + def check_lower(value): + if value == TrezorCoinType.BITCOIN: + return + if value == TrezorCoinType.TESTNET: + return + if value == TrezorCoinType.SIGNET: + return + if value == TrezorCoinType.REGTEST: + return + raise ValueError(value) + + @staticmethod + def write(value, buf): + if value == TrezorCoinType.BITCOIN: + buf.write_i32(1) + if value == TrezorCoinType.TESTNET: + buf.write_i32(2) + if value == TrezorCoinType.SIGNET: + buf.write_i32(3) + if value == TrezorCoinType.REGTEST: + buf.write_i32(4) + + + + +# TrezorError +# We want to define each variant as a nested class that's also a subclass, +# which is tricky in Python. To accomplish this we're going to create each +# class separately, then manually add the child classes to the base class's +# __dict__. All of this happens in dummy class to avoid polluting the module +# namespace. +class TrezorError(Exception): + """ + Trezor-related errors exposed via FFI. + """ + + pass + +_UniffiTempTrezorError = TrezorError + +class TrezorError: # type: ignore + """ + Trezor-related errors exposed via FFI. + """ class TransportError(_UniffiTempTrezorError): """ @@ -16970,175 +18567,520 @@ class TrezorScriptType(enum.Enum): P2PKH (legacy) """ - - SPEND_P2SH_WITNESS = 1 - """ - P2SH-P2WPKH (nested SegWit) - """ + + SPEND_P2SH_WITNESS = 1 + """ + P2SH-P2WPKH (nested SegWit) + """ + + + SPEND_WITNESS = 2 + """ + P2WPKH (native SegWit) + """ + + + SPEND_TAPROOT = 3 + """ + P2TR (Taproot) + """ + + + SPEND_MULTISIG = 4 + """ + P2SH multisig + """ + + + EXTERNAL = 5 + """ + External/watch-only input (not signed by device) + """ + + + + +class _UniffiConverterTypeTrezorScriptType(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + variant = buf.read_i32() + if variant == 1: + return TrezorScriptType.SPEND_ADDRESS + if variant == 2: + return TrezorScriptType.SPEND_P2SH_WITNESS + if variant == 3: + return TrezorScriptType.SPEND_WITNESS + if variant == 4: + return TrezorScriptType.SPEND_TAPROOT + if variant == 5: + return TrezorScriptType.SPEND_MULTISIG + if variant == 6: + return TrezorScriptType.EXTERNAL + raise InternalError("Raw enum value doesn't match any cases") + + @staticmethod + def check_lower(value): + if value == TrezorScriptType.SPEND_ADDRESS: + return + if value == TrezorScriptType.SPEND_P2SH_WITNESS: + return + if value == TrezorScriptType.SPEND_WITNESS: + return + if value == TrezorScriptType.SPEND_TAPROOT: + return + if value == TrezorScriptType.SPEND_MULTISIG: + return + if value == TrezorScriptType.EXTERNAL: + return + raise ValueError(value) + + @staticmethod + def write(value, buf): + if value == TrezorScriptType.SPEND_ADDRESS: + buf.write_i32(1) + if value == TrezorScriptType.SPEND_P2SH_WITNESS: + buf.write_i32(2) + if value == TrezorScriptType.SPEND_WITNESS: + buf.write_i32(3) + if value == TrezorScriptType.SPEND_TAPROOT: + buf.write_i32(4) + if value == TrezorScriptType.SPEND_MULTISIG: + buf.write_i32(5) + if value == TrezorScriptType.EXTERNAL: + buf.write_i32(6) + + + + + + + +class TrezorTransportErrorCode(enum.Enum): + """ + Structured transport error code returned by native callback operations. + """ + + DEVICE_BUSY = 0 + """ + Device is busy and the caller should back off before retrying. + """ + + + + +class _UniffiConverterTypeTrezorTransportErrorCode(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + variant = buf.read_i32() + if variant == 1: + return TrezorTransportErrorCode.DEVICE_BUSY + raise InternalError("Raw enum value doesn't match any cases") + + @staticmethod + def check_lower(value): + if value == TrezorTransportErrorCode.DEVICE_BUSY: + return + raise ValueError(value) + + @staticmethod + def write(value, buf): + if value == TrezorTransportErrorCode.DEVICE_BUSY: + buf.write_i32(1) + + + + + + + +class TrezorTransportType(enum.Enum): + """ + Transport type for Trezor devices. + """ + + USB = 0 + """ + USB connection + """ + + + BLUETOOTH = 1 + """ + Bluetooth connection + """ + + + + +class _UniffiConverterTypeTrezorTransportType(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + variant = buf.read_i32() + if variant == 1: + return TrezorTransportType.USB + if variant == 2: + return TrezorTransportType.BLUETOOTH + raise InternalError("Raw enum value doesn't match any cases") + + @staticmethod + def check_lower(value): + if value == TrezorTransportType.USB: + return + if value == TrezorTransportType.BLUETOOTH: + return + raise ValueError(value) + + @staticmethod + def write(value, buf): + if value == TrezorTransportType.USB: + buf.write_i32(1) + if value == TrezorTransportType.BLUETOOTH: + buf.write_i32(2) + + + + + + + +class TxDirection(enum.Enum): + """ + Transaction direction from the wallet's perspective. + """ + + SENT = 0 + """ + Wallet sent funds to an external address + """ + + + RECEIVED = 1 + """ + Wallet received funds from an external source + """ + + + SELF_TRANSFER = 2 + """ + Wallet sent funds to itself (e.g. consolidation, change-only) + """ + + + + +class _UniffiConverterTypeTxDirection(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + variant = buf.read_i32() + if variant == 1: + return TxDirection.SENT + if variant == 2: + return TxDirection.RECEIVED + if variant == 3: + return TxDirection.SELF_TRANSFER + raise InternalError("Raw enum value doesn't match any cases") + + @staticmethod + def check_lower(value): + if value == TxDirection.SENT: + return + if value == TxDirection.RECEIVED: + return + if value == TxDirection.SELF_TRANSFER: + return + raise ValueError(value) + + @staticmethod + def write(value, buf): + if value == TxDirection.SENT: + buf.write_i32(1) + if value == TxDirection.RECEIVED: + buf.write_i32(2) + if value == TxDirection.SELF_TRANSFER: + buf.write_i32(3) + + + + +# UrError +# We want to define each variant as a nested class that's also a subclass, +# which is tricky in Python. To accomplish this we're going to create each +# class separately, then manually add the child classes to the base class's +# __dict__. All of this happens in dummy class to avoid polluting the module +# namespace. +class UrError(Exception): + pass + +_UniffiTempUrError = UrError + +class UrError: # type: ignore + class InvalidUr(_UniffiTempUrError): + def __init__(self, reason): + super().__init__(", ".join([ + "reason={!r}".format(reason), + ])) + self.reason = reason + + def __repr__(self): + return "UrError.InvalidUr({})".format(str(self)) + _UniffiTempUrError.InvalidUr = InvalidUr # type: ignore + class TooLarge(_UniffiTempUrError): + def __init__(self, reason): + super().__init__(", ".join([ + "reason={!r}".format(reason), + ])) + self.reason = reason - - SPEND_WITNESS = 2 - """ - P2WPKH (native SegWit) - """ + def __repr__(self): + return "UrError.TooLarge({})".format(str(self)) + _UniffiTempUrError.TooLarge = TooLarge # type: ignore + class InvalidPayload(_UniffiTempUrError): + def __init__(self, reason): + super().__init__(", ".join([ + "reason={!r}".format(reason), + ])) + self.reason = reason - - SPEND_TAPROOT = 3 - """ - P2TR (Taproot) - """ + def __repr__(self): + return "UrError.InvalidPayload({})".format(str(self)) + _UniffiTempUrError.InvalidPayload = InvalidPayload # type: ignore + class InvalidPsbt(_UniffiTempUrError): + def __init__(self, reason): + super().__init__(", ".join([ + "reason={!r}".format(reason), + ])) + self.reason = reason - - SPEND_MULTISIG = 4 - """ - P2SH multisig - """ + def __repr__(self): + return "UrError.InvalidPsbt({})".format(str(self)) + _UniffiTempUrError.InvalidPsbt = InvalidPsbt # type: ignore + class InvalidPassportExport(_UniffiTempUrError): + def __init__(self, reason): + super().__init__(", ".join([ + "reason={!r}".format(reason), + ])) + self.reason = reason - - EXTERNAL = 5 - """ - External/watch-only input (not signed by device) - """ + def __repr__(self): + return "UrError.InvalidPassportExport({})".format(str(self)) + _UniffiTempUrError.InvalidPassportExport = InvalidPassportExport # type: ignore - +UrError = _UniffiTempUrError # type: ignore +del _UniffiTempUrError -class _UniffiConverterTypeTrezorScriptType(_UniffiConverterRustBuffer): +class _UniffiConverterTypeUrError(_UniffiConverterRustBuffer): @staticmethod def read(buf): variant = buf.read_i32() if variant == 1: - return TrezorScriptType.SPEND_ADDRESS + return UrError.InvalidUr( + _UniffiConverterString.read(buf), + ) if variant == 2: - return TrezorScriptType.SPEND_P2SH_WITNESS + return UrError.TooLarge( + _UniffiConverterString.read(buf), + ) if variant == 3: - return TrezorScriptType.SPEND_WITNESS + return UrError.InvalidPayload( + _UniffiConverterString.read(buf), + ) if variant == 4: - return TrezorScriptType.SPEND_TAPROOT + return UrError.InvalidPsbt( + _UniffiConverterString.read(buf), + ) if variant == 5: - return TrezorScriptType.SPEND_MULTISIG - if variant == 6: - return TrezorScriptType.EXTERNAL + return UrError.InvalidPassportExport( + _UniffiConverterString.read(buf), + ) raise InternalError("Raw enum value doesn't match any cases") @staticmethod def check_lower(value): - if value == TrezorScriptType.SPEND_ADDRESS: - return - if value == TrezorScriptType.SPEND_P2SH_WITNESS: + if isinstance(value, UrError.InvalidUr): + _UniffiConverterString.check_lower(value.reason) return - if value == TrezorScriptType.SPEND_WITNESS: + if isinstance(value, UrError.TooLarge): + _UniffiConverterString.check_lower(value.reason) return - if value == TrezorScriptType.SPEND_TAPROOT: + if isinstance(value, UrError.InvalidPayload): + _UniffiConverterString.check_lower(value.reason) return - if value == TrezorScriptType.SPEND_MULTISIG: + if isinstance(value, UrError.InvalidPsbt): + _UniffiConverterString.check_lower(value.reason) return - if value == TrezorScriptType.EXTERNAL: + if isinstance(value, UrError.InvalidPassportExport): + _UniffiConverterString.check_lower(value.reason) return - raise ValueError(value) @staticmethod def write(value, buf): - if value == TrezorScriptType.SPEND_ADDRESS: + if isinstance(value, UrError.InvalidUr): buf.write_i32(1) - if value == TrezorScriptType.SPEND_P2SH_WITNESS: + _UniffiConverterString.write(value.reason, buf) + if isinstance(value, UrError.TooLarge): buf.write_i32(2) - if value == TrezorScriptType.SPEND_WITNESS: + _UniffiConverterString.write(value.reason, buf) + if isinstance(value, UrError.InvalidPayload): buf.write_i32(3) - if value == TrezorScriptType.SPEND_TAPROOT: + _UniffiConverterString.write(value.reason, buf) + if isinstance(value, UrError.InvalidPsbt): buf.write_i32(4) - if value == TrezorScriptType.SPEND_MULTISIG: + _UniffiConverterString.write(value.reason, buf) + if isinstance(value, UrError.InvalidPassportExport): buf.write_i32(5) - if value == TrezorScriptType.EXTERNAL: - buf.write_i32(6) - - - + _UniffiConverterString.write(value.reason, buf) -class TrezorTransportErrorCode(enum.Enum): - """ - Structured transport error code returned by native callback operations. - """ - DEVICE_BUSY = 0 +class UrPayload: """ - Device is busy and the caller should back off before retrying. + A completely decoded UR payload. """ - + def __init__(self): + raise RuntimeError("UrPayload cannot be instantiated directly") + # Each enum variant is a nested class of the enum itself. + class BYTES: + """ + The byte string wrapped by a `bytes` registry item. + """ -class _UniffiConverterTypeTrezorTransportErrorCode(_UniffiConverterRustBuffer): - @staticmethod - def read(buf): - variant = buf.read_i32() - if variant == 1: - return TrezorTransportErrorCode.DEVICE_BUSY - raise InternalError("Raw enum value doesn't match any cases") + data: "bytes" - @staticmethod - def check_lower(value): - if value == TrezorTransportErrorCode.DEVICE_BUSY: - return - raise ValueError(value) + def __init__(self,data: "bytes"): + self.data = data - @staticmethod - def write(value, buf): - if value == TrezorTransportErrorCode.DEVICE_BUSY: - buf.write_i32(1) + def __str__(self): + return "UrPayload.BYTES(data={})".format(self.data) + def __eq__(self, other): + if not other.is_BYTES(): + return False + if self.data != other.data: + return False + return True + + class CRYPTO_PSBT: + """ + A `crypto-psbt` registry item, returned in Bitkit's usual base64 form. + """ + psbt: "str" + def __init__(self,psbt: "str"): + self.psbt = psbt + def __str__(self): + return "UrPayload.CRYPTO_PSBT(psbt={})".format(self.psbt) + def __eq__(self, other): + if not other.is_CRYPTO_PSBT(): + return False + if self.psbt != other.psbt: + return False + return True + + class CBOR: + """ + An uninterpreted UR registry item. + """ + ur_type: "str" + cbor: "bytes" -class TrezorTransportType(enum.Enum): - """ - Transport type for Trezor devices. - """ + def __init__(self,ur_type: "str", cbor: "bytes"): + self.ur_type = ur_type + self.cbor = cbor - USB = 0 - """ - USB connection - """ + def __str__(self): + return "UrPayload.CBOR(ur_type={}, cbor={})".format(self.ur_type, self.cbor) + def __eq__(self, other): + if not other.is_CBOR(): + return False + if self.ur_type != other.ur_type: + return False + if self.cbor != other.cbor: + return False + return True + - BLUETOOTH = 1 - """ - Bluetooth connection - """ + # For each variant, we have `is_NAME` and `is_name` methods for easily checking + # whether an instance is that variant. + def is_BYTES(self) -> bool: + return isinstance(self, UrPayload.BYTES) + def is_bytes(self) -> bool: + return isinstance(self, UrPayload.BYTES) + def is_CRYPTO_PSBT(self) -> bool: + return isinstance(self, UrPayload.CRYPTO_PSBT) + def is_crypto_psbt(self) -> bool: + return isinstance(self, UrPayload.CRYPTO_PSBT) + def is_CBOR(self) -> bool: + return isinstance(self, UrPayload.CBOR) + def is_cbor(self) -> bool: + return isinstance(self, UrPayload.CBOR) +# Now, a little trick - we make each nested variant class be a subclass of the main +# enum class, so that method calls and instance checks etc will work intuitively. +# We might be able to do this a little more neatly with a metaclass, but this'll do. +UrPayload.BYTES = type("UrPayload.BYTES", (UrPayload.BYTES, UrPayload,), {}) # type: ignore +UrPayload.CRYPTO_PSBT = type("UrPayload.CRYPTO_PSBT", (UrPayload.CRYPTO_PSBT, UrPayload,), {}) # type: ignore +UrPayload.CBOR = type("UrPayload.CBOR", (UrPayload.CBOR, UrPayload,), {}) # type: ignore -class _UniffiConverterTypeTrezorTransportType(_UniffiConverterRustBuffer): + + + +class _UniffiConverterTypeUrPayload(_UniffiConverterRustBuffer): @staticmethod def read(buf): variant = buf.read_i32() if variant == 1: - return TrezorTransportType.USB + return UrPayload.BYTES( + _UniffiConverterBytes.read(buf), + ) if variant == 2: - return TrezorTransportType.BLUETOOTH + return UrPayload.CRYPTO_PSBT( + _UniffiConverterString.read(buf), + ) + if variant == 3: + return UrPayload.CBOR( + _UniffiConverterString.read(buf), + _UniffiConverterBytes.read(buf), + ) raise InternalError("Raw enum value doesn't match any cases") @staticmethod def check_lower(value): - if value == TrezorTransportType.USB: + if value.is_BYTES(): + _UniffiConverterBytes.check_lower(value.data) return - if value == TrezorTransportType.BLUETOOTH: + if value.is_CRYPTO_PSBT(): + _UniffiConverterString.check_lower(value.psbt) + return + if value.is_CBOR(): + _UniffiConverterString.check_lower(value.ur_type) + _UniffiConverterBytes.check_lower(value.cbor) return raise ValueError(value) @staticmethod def write(value, buf): - if value == TrezorTransportType.USB: + if value.is_BYTES(): buf.write_i32(1) - if value == TrezorTransportType.BLUETOOTH: + _UniffiConverterBytes.write(value.data, buf) + if value.is_CRYPTO_PSBT(): buf.write_i32(2) + _UniffiConverterString.write(value.psbt, buf) + if value.is_CBOR(): + buf.write_i32(3) + _UniffiConverterString.write(value.ur_type, buf) + _UniffiConverterBytes.write(value.cbor, buf) @@ -17146,268 +19088,261 @@ def write(value, buf): -class TxDirection(enum.Enum): - """ - Transaction direction from the wallet's perspective. - """ - - SENT = 0 - """ - Wallet sent funds to an external address +class WalletSelection: """ + Which wallet a connection should open. - - RECEIVED = 1 - """ - Wallet received funds from an external source + Passed to `trezor_connect` and consumed at connect time — the passphrase is + a one-shot input, not retained anywhere afterwards. On THP devices (Safe + 5/7) it is bound to the session at `ThpCreateNewSession`; on legacy devices + the mid-operation `PassphraseRequest` is answered from the UI callback + instead (see [`TrezorUiCallback`]). """ - - SELF_TRANSFER = 2 - """ - Wallet sent funds to itself (e.g. consolidation, change-only) - """ + def __init__(self): + raise RuntimeError("WalletSelection cannot be instantiated directly") - + # Each enum variant is a nested class of the enum itself. + class STANDARD: + """ + The standard wallet — no passphrase. + """ -class _UniffiConverterTypeTxDirection(_UniffiConverterRustBuffer): - @staticmethod - def read(buf): - variant = buf.read_i32() - if variant == 1: - return TxDirection.SENT - if variant == 2: - return TxDirection.RECEIVED - if variant == 3: - return TxDirection.SELF_TRANSFER - raise InternalError("Raw enum value doesn't match any cases") + def __init__(self,): + pass - @staticmethod - def check_lower(value): - if value == TxDirection.SENT: - return - if value == TxDirection.RECEIVED: - return - if value == TxDirection.SELF_TRANSFER: - return - raise ValueError(value) + def __str__(self): + return "WalletSelection.STANDARD()".format() - @staticmethod - def write(value, buf): - if value == TxDirection.SENT: - buf.write_i32(1) - if value == TxDirection.RECEIVED: - buf.write_i32(2) - if value == TxDirection.SELF_TRANSFER: - buf.write_i32(3) + def __eq__(self, other): + if not other.is_STANDARD(): + return False + return True + + class HIDDEN: + """ + A hidden wallet whose passphrase is entered on the host. + """ + passphrase: "str" + def __init__(self,passphrase: "str"): + self.passphrase = passphrase + def __str__(self): + return "WalletSelection.HIDDEN(passphrase={})".format(self.passphrase) -# UrError -# We want to define each variant as a nested class that's also a subclass, -# which is tricky in Python. To accomplish this we're going to create each -# class separately, then manually add the child classes to the base class's -# __dict__. All of this happens in dummy class to avoid polluting the module -# namespace. -class UrError(Exception): - pass + def __eq__(self, other): + if not other.is_HIDDEN(): + return False + if self.passphrase != other.passphrase: + return False + return True + + class ON_DEVICE: + """ + A hidden wallet whose passphrase is entered on the Trezor itself. + """ -_UniffiTempUrError = UrError -class UrError: # type: ignore - class InvalidUr(_UniffiTempUrError): - def __init__(self, reason): - super().__init__(", ".join([ - "reason={!r}".format(reason), - ])) - self.reason = reason + def __init__(self,): + pass - def __repr__(self): - return "UrError.InvalidUr({})".format(str(self)) - _UniffiTempUrError.InvalidUr = InvalidUr # type: ignore - class TooLarge(_UniffiTempUrError): - def __init__(self, reason): - super().__init__(", ".join([ - "reason={!r}".format(reason), - ])) - self.reason = reason + def __str__(self): + return "WalletSelection.ON_DEVICE()".format() - def __repr__(self): - return "UrError.TooLarge({})".format(str(self)) - _UniffiTempUrError.TooLarge = TooLarge # type: ignore - class InvalidPayload(_UniffiTempUrError): - def __init__(self, reason): - super().__init__(", ".join([ - "reason={!r}".format(reason), - ])) - self.reason = reason + def __eq__(self, other): + if not other.is_ON_DEVICE(): + return False + return True + + - def __repr__(self): - return "UrError.InvalidPayload({})".format(str(self)) - _UniffiTempUrError.InvalidPayload = InvalidPayload # type: ignore - class InvalidPsbt(_UniffiTempUrError): - def __init__(self, reason): - super().__init__(", ".join([ - "reason={!r}".format(reason), - ])) - self.reason = reason + # For each variant, we have `is_NAME` and `is_name` methods for easily checking + # whether an instance is that variant. + def is_STANDARD(self) -> bool: + return isinstance(self, WalletSelection.STANDARD) + def is_standard(self) -> bool: + return isinstance(self, WalletSelection.STANDARD) + def is_HIDDEN(self) -> bool: + return isinstance(self, WalletSelection.HIDDEN) + def is_hidden(self) -> bool: + return isinstance(self, WalletSelection.HIDDEN) + def is_ON_DEVICE(self) -> bool: + return isinstance(self, WalletSelection.ON_DEVICE) + def is_on_device(self) -> bool: + return isinstance(self, WalletSelection.ON_DEVICE) + - def __repr__(self): - return "UrError.InvalidPsbt({})".format(str(self)) - _UniffiTempUrError.InvalidPsbt = InvalidPsbt # type: ignore - class InvalidPassportExport(_UniffiTempUrError): - def __init__(self, reason): - super().__init__(", ".join([ - "reason={!r}".format(reason), - ])) - self.reason = reason +# Now, a little trick - we make each nested variant class be a subclass of the main +# enum class, so that method calls and instance checks etc will work intuitively. +# We might be able to do this a little more neatly with a metaclass, but this'll do. +WalletSelection.STANDARD = type("WalletSelection.STANDARD", (WalletSelection.STANDARD, WalletSelection,), {}) # type: ignore +WalletSelection.HIDDEN = type("WalletSelection.HIDDEN", (WalletSelection.HIDDEN, WalletSelection,), {}) # type: ignore +WalletSelection.ON_DEVICE = type("WalletSelection.ON_DEVICE", (WalletSelection.ON_DEVICE, WalletSelection,), {}) # type: ignore - def __repr__(self): - return "UrError.InvalidPassportExport({})".format(str(self)) - _UniffiTempUrError.InvalidPassportExport = InvalidPassportExport # type: ignore -UrError = _UniffiTempUrError # type: ignore -del _UniffiTempUrError -class _UniffiConverterTypeUrError(_UniffiConverterRustBuffer): +class _UniffiConverterTypeWalletSelection(_UniffiConverterRustBuffer): @staticmethod def read(buf): variant = buf.read_i32() if variant == 1: - return UrError.InvalidUr( - _UniffiConverterString.read(buf), + return WalletSelection.STANDARD( ) if variant == 2: - return UrError.TooLarge( + return WalletSelection.HIDDEN( _UniffiConverterString.read(buf), ) if variant == 3: - return UrError.InvalidPayload( - _UniffiConverterString.read(buf), - ) - if variant == 4: - return UrError.InvalidPsbt( - _UniffiConverterString.read(buf), - ) - if variant == 5: - return UrError.InvalidPassportExport( - _UniffiConverterString.read(buf), + return WalletSelection.ON_DEVICE( ) raise InternalError("Raw enum value doesn't match any cases") @staticmethod def check_lower(value): - if isinstance(value, UrError.InvalidUr): - _UniffiConverterString.check_lower(value.reason) - return - if isinstance(value, UrError.TooLarge): - _UniffiConverterString.check_lower(value.reason) - return - if isinstance(value, UrError.InvalidPayload): - _UniffiConverterString.check_lower(value.reason) + if value.is_STANDARD(): return - if isinstance(value, UrError.InvalidPsbt): - _UniffiConverterString.check_lower(value.reason) + if value.is_HIDDEN(): + _UniffiConverterString.check_lower(value.passphrase) return - if isinstance(value, UrError.InvalidPassportExport): - _UniffiConverterString.check_lower(value.reason) + if value.is_ON_DEVICE(): return + raise ValueError(value) @staticmethod def write(value, buf): - if isinstance(value, UrError.InvalidUr): + if value.is_STANDARD(): buf.write_i32(1) - _UniffiConverterString.write(value.reason, buf) - if isinstance(value, UrError.TooLarge): - buf.write_i32(2) - _UniffiConverterString.write(value.reason, buf) - if isinstance(value, UrError.InvalidPayload): - buf.write_i32(3) - _UniffiConverterString.write(value.reason, buf) - if isinstance(value, UrError.InvalidPsbt): - buf.write_i32(4) - _UniffiConverterString.write(value.reason, buf) - if isinstance(value, UrError.InvalidPassportExport): - buf.write_i32(5) - _UniffiConverterString.write(value.reason, buf) + if value.is_HIDDEN(): + buf.write_i32(2) + _UniffiConverterString.write(value.passphrase, buf) + if value.is_ON_DEVICE(): + buf.write_i32(3) -class UrPayload: + + +class WatcherEvent: """ - A completely decoded UR payload. + Events emitted by the onchain xpub watcher. """ def __init__(self): - raise RuntimeError("UrPayload cannot be instantiated directly") + raise RuntimeError("WatcherEvent cannot be instantiated directly") # Each enum variant is a nested class of the enum itself. - class BYTES: + class TRANSACTIONS_CHANGED: """ - The byte string wrapped by a `bytes` registry item. + Transaction activity changed — contains full updated state. + + `activities` and `transaction_details` are persistence-ready: they carry + the watcher's `wallet_id`, real decoded addresses, fees from the watched + wallet's perspective, and DB-valid timestamps, so the app can store them + directly through the normal Core activity APIs (e.g. `upsert_activity` / + `upsert_transaction_details`). The two vecs are parallel by `tx_id`. + `next_unused_external_address` is the synchronized wallet's current + external receive address. """ - data: "bytes" + activities: "typing.List[Activity]" + transaction_details: "typing.List[TransactionDetails]" + balance: "WalletBalance" + tx_count: "int" + block_height: "int" + account_type: "AccountType" + next_unused_external_address: "AddressInfo" - def __init__(self,data: "bytes"): - self.data = data + def __init__(self,activities: "typing.List[Activity]", transaction_details: "typing.List[TransactionDetails]", balance: "WalletBalance", tx_count: "int", block_height: "int", account_type: "AccountType", next_unused_external_address: "AddressInfo"): + self.activities = activities + self.transaction_details = transaction_details + self.balance = balance + self.tx_count = tx_count + self.block_height = block_height + self.account_type = account_type + self.next_unused_external_address = next_unused_external_address def __str__(self): - return "UrPayload.BYTES(data={})".format(self.data) + return "WatcherEvent.TRANSACTIONS_CHANGED(activities={}, transaction_details={}, balance={}, tx_count={}, block_height={}, account_type={}, next_unused_external_address={})".format(self.activities, self.transaction_details, self.balance, self.tx_count, self.block_height, self.account_type, self.next_unused_external_address) def __eq__(self, other): - if not other.is_BYTES(): + if not other.is_TRANSACTIONS_CHANGED(): return False - if self.data != other.data: + if self.activities != other.activities: + return False + if self.transaction_details != other.transaction_details: + return False + if self.balance != other.balance: + return False + if self.tx_count != other.tx_count: + return False + if self.block_height != other.block_height: + return False + if self.account_type != other.account_type: + return False + if self.next_unused_external_address != other.next_unused_external_address: return False return True - class CRYPTO_PSBT: + class ERROR: """ - A `crypto-psbt` registry item, returned in Bitkit's usual base64 form. + An error occurred in the watcher loop. """ - psbt: "str" + message: "str" - def __init__(self,psbt: "str"): - self.psbt = psbt + def __init__(self,message: "str"): + self.message = message def __str__(self): - return "UrPayload.CRYPTO_PSBT(psbt={})".format(self.psbt) + return "WatcherEvent.ERROR(message={})".format(self.message) def __eq__(self, other): - if not other.is_CRYPTO_PSBT(): + if not other.is_ERROR(): return False - if self.psbt != other.psbt: + if self.message != other.message: return False return True - class CBOR: + class DISCONNECTED: """ - An uninterpreted UR registry item. + Connection to the Electrum server was lost. """ - ur_type: "str" - cbor: "bytes" + message: "str" - def __init__(self,ur_type: "str", cbor: "bytes"): - self.ur_type = ur_type - self.cbor = cbor + def __init__(self,message: "str"): + self.message = message def __str__(self): - return "UrPayload.CBOR(ur_type={}, cbor={})".format(self.ur_type, self.cbor) + return "WatcherEvent.DISCONNECTED(message={})".format(self.message) def __eq__(self, other): - if not other.is_CBOR(): + if not other.is_DISCONNECTED(): return False - if self.ur_type != other.ur_type: + if self.message != other.message: return False - if self.cbor != other.cbor: + return True + + class RECONNECTED: + """ + Connection to the Electrum server was restored. + """ + + + def __init__(self,): + pass + + def __str__(self): + return "WatcherEvent.RECONNECTED()".format() + + def __eq__(self, other): + if not other.is_RECONNECTED(): return False return True @@ -17415,532 +19350,626 @@ def __eq__(self, other): # For each variant, we have `is_NAME` and `is_name` methods for easily checking # whether an instance is that variant. - def is_BYTES(self) -> bool: - return isinstance(self, UrPayload.BYTES) - def is_bytes(self) -> bool: - return isinstance(self, UrPayload.BYTES) - def is_CRYPTO_PSBT(self) -> bool: - return isinstance(self, UrPayload.CRYPTO_PSBT) - def is_crypto_psbt(self) -> bool: - return isinstance(self, UrPayload.CRYPTO_PSBT) - def is_CBOR(self) -> bool: - return isinstance(self, UrPayload.CBOR) - def is_cbor(self) -> bool: - return isinstance(self, UrPayload.CBOR) + def is_TRANSACTIONS_CHANGED(self) -> bool: + return isinstance(self, WatcherEvent.TRANSACTIONS_CHANGED) + def is_transactions_changed(self) -> bool: + return isinstance(self, WatcherEvent.TRANSACTIONS_CHANGED) + def is_ERROR(self) -> bool: + return isinstance(self, WatcherEvent.ERROR) + def is_error(self) -> bool: + return isinstance(self, WatcherEvent.ERROR) + def is_DISCONNECTED(self) -> bool: + return isinstance(self, WatcherEvent.DISCONNECTED) + def is_disconnected(self) -> bool: + return isinstance(self, WatcherEvent.DISCONNECTED) + def is_RECONNECTED(self) -> bool: + return isinstance(self, WatcherEvent.RECONNECTED) + def is_reconnected(self) -> bool: + return isinstance(self, WatcherEvent.RECONNECTED) # Now, a little trick - we make each nested variant class be a subclass of the main # enum class, so that method calls and instance checks etc will work intuitively. # We might be able to do this a little more neatly with a metaclass, but this'll do. -UrPayload.BYTES = type("UrPayload.BYTES", (UrPayload.BYTES, UrPayload,), {}) # type: ignore -UrPayload.CRYPTO_PSBT = type("UrPayload.CRYPTO_PSBT", (UrPayload.CRYPTO_PSBT, UrPayload,), {}) # type: ignore -UrPayload.CBOR = type("UrPayload.CBOR", (UrPayload.CBOR, UrPayload,), {}) # type: ignore +WatcherEvent.TRANSACTIONS_CHANGED = type("WatcherEvent.TRANSACTIONS_CHANGED", (WatcherEvent.TRANSACTIONS_CHANGED, WatcherEvent,), {}) # type: ignore +WatcherEvent.ERROR = type("WatcherEvent.ERROR", (WatcherEvent.ERROR, WatcherEvent,), {}) # type: ignore +WatcherEvent.DISCONNECTED = type("WatcherEvent.DISCONNECTED", (WatcherEvent.DISCONNECTED, WatcherEvent,), {}) # type: ignore +WatcherEvent.RECONNECTED = type("WatcherEvent.RECONNECTED", (WatcherEvent.RECONNECTED, WatcherEvent,), {}) # type: ignore -class _UniffiConverterTypeUrPayload(_UniffiConverterRustBuffer): +class _UniffiConverterTypeWatcherEvent(_UniffiConverterRustBuffer): @staticmethod def read(buf): variant = buf.read_i32() if variant == 1: - return UrPayload.BYTES( - _UniffiConverterBytes.read(buf), + return WatcherEvent.TRANSACTIONS_CHANGED( + _UniffiConverterSequenceTypeActivity.read(buf), + _UniffiConverterSequenceTypeTransactionDetails.read(buf), + _UniffiConverterTypeWalletBalance.read(buf), + _UniffiConverterUInt32.read(buf), + _UniffiConverterUInt32.read(buf), + _UniffiConverterTypeAccountType.read(buf), + _UniffiConverterTypeAddressInfo.read(buf), + ) + if variant == 2: + return WatcherEvent.ERROR( + _UniffiConverterString.read(buf), + ) + if variant == 3: + return WatcherEvent.DISCONNECTED( + _UniffiConverterString.read(buf), + ) + if variant == 4: + return WatcherEvent.RECONNECTED( ) + raise InternalError("Raw enum value doesn't match any cases") + + @staticmethod + def check_lower(value): + if value.is_TRANSACTIONS_CHANGED(): + _UniffiConverterSequenceTypeActivity.check_lower(value.activities) + _UniffiConverterSequenceTypeTransactionDetails.check_lower(value.transaction_details) + _UniffiConverterTypeWalletBalance.check_lower(value.balance) + _UniffiConverterUInt32.check_lower(value.tx_count) + _UniffiConverterUInt32.check_lower(value.block_height) + _UniffiConverterTypeAccountType.check_lower(value.account_type) + _UniffiConverterTypeAddressInfo.check_lower(value.next_unused_external_address) + return + if value.is_ERROR(): + _UniffiConverterString.check_lower(value.message) + return + if value.is_DISCONNECTED(): + _UniffiConverterString.check_lower(value.message) + return + if value.is_RECONNECTED(): + return + raise ValueError(value) + + @staticmethod + def write(value, buf): + if value.is_TRANSACTIONS_CHANGED(): + buf.write_i32(1) + _UniffiConverterSequenceTypeActivity.write(value.activities, buf) + _UniffiConverterSequenceTypeTransactionDetails.write(value.transaction_details, buf) + _UniffiConverterTypeWalletBalance.write(value.balance, buf) + _UniffiConverterUInt32.write(value.tx_count, buf) + _UniffiConverterUInt32.write(value.block_height, buf) + _UniffiConverterTypeAccountType.write(value.account_type, buf) + _UniffiConverterTypeAddressInfo.write(value.next_unused_external_address, buf) + if value.is_ERROR(): + buf.write_i32(2) + _UniffiConverterString.write(value.message, buf) + if value.is_DISCONNECTED(): + buf.write_i32(3) + _UniffiConverterString.write(value.message, buf) + if value.is_RECONNECTED(): + buf.write_i32(4) + + + + + + + +class WordCount(enum.Enum): + WORDS12 = 12 + """ + 12-word mnemonic (128 bits of entropy) + """ + + + WORDS15 = 15 + """ + 15-word mnemonic (160 bits of entropy) + """ + + + WORDS18 = 18 + """ + 18-word mnemonic (192 bits of entropy) + """ + + + WORDS21 = 21 + """ + 21-word mnemonic (224 bits of entropy) + """ + + + WORDS24 = 24 + """ + 24-word mnemonic (256 bits of entropy) + """ + + + + +class _UniffiConverterTypeWordCount(_UniffiConverterRustBuffer): + @staticmethod + def read(buf): + variant = buf.read_i32() + if variant == 1: + return WordCount.WORDS12 if variant == 2: - return UrPayload.CRYPTO_PSBT( - _UniffiConverterString.read(buf), - ) + return WordCount.WORDS15 if variant == 3: - return UrPayload.CBOR( - _UniffiConverterString.read(buf), - _UniffiConverterBytes.read(buf), - ) + return WordCount.WORDS18 + if variant == 4: + return WordCount.WORDS21 + if variant == 5: + return WordCount.WORDS24 raise InternalError("Raw enum value doesn't match any cases") @staticmethod def check_lower(value): - if value.is_BYTES(): - _UniffiConverterBytes.check_lower(value.data) + if value == WordCount.WORDS12: return - if value.is_CRYPTO_PSBT(): - _UniffiConverterString.check_lower(value.psbt) + if value == WordCount.WORDS15: return - if value.is_CBOR(): - _UniffiConverterString.check_lower(value.ur_type) - _UniffiConverterBytes.check_lower(value.cbor) + if value == WordCount.WORDS18: + return + if value == WordCount.WORDS21: + return + if value == WordCount.WORDS24: return raise ValueError(value) @staticmethod def write(value, buf): - if value.is_BYTES(): + if value == WordCount.WORDS12: buf.write_i32(1) - _UniffiConverterBytes.write(value.data, buf) - if value.is_CRYPTO_PSBT(): + if value == WordCount.WORDS15: buf.write_i32(2) - _UniffiConverterString.write(value.psbt, buf) - if value.is_CBOR(): + if value == WordCount.WORDS18: buf.write_i32(3) - _UniffiConverterString.write(value.ur_type, buf) - _UniffiConverterBytes.write(value.cbor, buf) + if value == WordCount.WORDS21: + buf.write_i32(4) + if value == WordCount.WORDS24: + buf.write_i32(5) +class _UniffiConverterOptionalUInt16(_UniffiConverterRustBuffer): + @classmethod + def check_lower(cls, value): + if value is not None: + _UniffiConverterUInt16.check_lower(value) + @classmethod + def write(cls, value, buf): + if value is None: + buf.write_u8(0) + return -class WalletSelection: - """ - Which wallet a connection should open. + buf.write_u8(1) + _UniffiConverterUInt16.write(value, buf) - Passed to `trezor_connect` and consumed at connect time — the passphrase is - a one-shot input, not retained anywhere afterwards. On THP devices (Safe - 5/7) it is bound to the session at `ThpCreateNewSession`; on legacy devices - the mid-operation `PassphraseRequest` is answered from the UI callback - instead (see [`TrezorUiCallback`]). - """ + @classmethod + def read(cls, buf): + flag = buf.read_u8() + if flag == 0: + return None + elif flag == 1: + return _UniffiConverterUInt16.read(buf) + else: + raise InternalError("Unexpected flag byte for optional type") - def __init__(self): - raise RuntimeError("WalletSelection cannot be instantiated directly") - # Each enum variant is a nested class of the enum itself. - class STANDARD: - """ - The standard wallet — no passphrase. - """ +class _UniffiConverterOptionalUInt32(_UniffiConverterRustBuffer): + @classmethod + def check_lower(cls, value): + if value is not None: + _UniffiConverterUInt32.check_lower(value) - def __init__(self,): - pass + @classmethod + def write(cls, value, buf): + if value is None: + buf.write_u8(0) + return - def __str__(self): - return "WalletSelection.STANDARD()".format() + buf.write_u8(1) + _UniffiConverterUInt32.write(value, buf) - def __eq__(self, other): - if not other.is_STANDARD(): - return False - return True - - class HIDDEN: - """ - A hidden wallet whose passphrase is entered on the host. - """ + @classmethod + def read(cls, buf): + flag = buf.read_u8() + if flag == 0: + return None + elif flag == 1: + return _UniffiConverterUInt32.read(buf) + else: + raise InternalError("Unexpected flag byte for optional type") - passphrase: "str" - def __init__(self,passphrase: "str"): - self.passphrase = passphrase - def __str__(self): - return "WalletSelection.HIDDEN(passphrase={})".format(self.passphrase) +class _UniffiConverterOptionalUInt64(_UniffiConverterRustBuffer): + @classmethod + def check_lower(cls, value): + if value is not None: + _UniffiConverterUInt64.check_lower(value) - def __eq__(self, other): - if not other.is_HIDDEN(): - return False - if self.passphrase != other.passphrase: - return False - return True - - class ON_DEVICE: - """ - A hidden wallet whose passphrase is entered on the Trezor itself. - """ + @classmethod + def write(cls, value, buf): + if value is None: + buf.write_u8(0) + return + buf.write_u8(1) + _UniffiConverterUInt64.write(value, buf) - def __init__(self,): - pass + @classmethod + def read(cls, buf): + flag = buf.read_u8() + if flag == 0: + return None + elif flag == 1: + return _UniffiConverterUInt64.read(buf) + else: + raise InternalError("Unexpected flag byte for optional type") - def __str__(self): - return "WalletSelection.ON_DEVICE()".format() - def __eq__(self, other): - if not other.is_ON_DEVICE(): - return False - return True - - - # For each variant, we have `is_NAME` and `is_name` methods for easily checking - # whether an instance is that variant. - def is_STANDARD(self) -> bool: - return isinstance(self, WalletSelection.STANDARD) - def is_standard(self) -> bool: - return isinstance(self, WalletSelection.STANDARD) - def is_HIDDEN(self) -> bool: - return isinstance(self, WalletSelection.HIDDEN) - def is_hidden(self) -> bool: - return isinstance(self, WalletSelection.HIDDEN) - def is_ON_DEVICE(self) -> bool: - return isinstance(self, WalletSelection.ON_DEVICE) - def is_on_device(self) -> bool: - return isinstance(self, WalletSelection.ON_DEVICE) - +class _UniffiConverterOptionalDouble(_UniffiConverterRustBuffer): + @classmethod + def check_lower(cls, value): + if value is not None: + _UniffiConverterDouble.check_lower(value) -# Now, a little trick - we make each nested variant class be a subclass of the main -# enum class, so that method calls and instance checks etc will work intuitively. -# We might be able to do this a little more neatly with a metaclass, but this'll do. -WalletSelection.STANDARD = type("WalletSelection.STANDARD", (WalletSelection.STANDARD, WalletSelection,), {}) # type: ignore -WalletSelection.HIDDEN = type("WalletSelection.HIDDEN", (WalletSelection.HIDDEN, WalletSelection,), {}) # type: ignore -WalletSelection.ON_DEVICE = type("WalletSelection.ON_DEVICE", (WalletSelection.ON_DEVICE, WalletSelection,), {}) # type: ignore + @classmethod + def write(cls, value, buf): + if value is None: + buf.write_u8(0) + return + + buf.write_u8(1) + _UniffiConverterDouble.write(value, buf) + @classmethod + def read(cls, buf): + flag = buf.read_u8() + if flag == 0: + return None + elif flag == 1: + return _UniffiConverterDouble.read(buf) + else: + raise InternalError("Unexpected flag byte for optional type") -class _UniffiConverterTypeWalletSelection(_UniffiConverterRustBuffer): - @staticmethod - def read(buf): - variant = buf.read_i32() - if variant == 1: - return WalletSelection.STANDARD( - ) - if variant == 2: - return WalletSelection.HIDDEN( - _UniffiConverterString.read(buf), - ) - if variant == 3: - return WalletSelection.ON_DEVICE( - ) - raise InternalError("Raw enum value doesn't match any cases") +class _UniffiConverterOptionalBool(_UniffiConverterRustBuffer): + @classmethod + def check_lower(cls, value): + if value is not None: + _UniffiConverterBool.check_lower(value) - @staticmethod - def check_lower(value): - if value.is_STANDARD(): + @classmethod + def write(cls, value, buf): + if value is None: + buf.write_u8(0) return - if value.is_HIDDEN(): - _UniffiConverterString.check_lower(value.passphrase) + + buf.write_u8(1) + _UniffiConverterBool.write(value, buf) + + @classmethod + def read(cls, buf): + flag = buf.read_u8() + if flag == 0: + return None + elif flag == 1: + return _UniffiConverterBool.read(buf) + else: + raise InternalError("Unexpected flag byte for optional type") + + + +class _UniffiConverterOptionalString(_UniffiConverterRustBuffer): + @classmethod + def check_lower(cls, value): + if value is not None: + _UniffiConverterString.check_lower(value) + + @classmethod + def write(cls, value, buf): + if value is None: + buf.write_u8(0) return - if value.is_ON_DEVICE(): + + buf.write_u8(1) + _UniffiConverterString.write(value, buf) + + @classmethod + def read(cls, buf): + flag = buf.read_u8() + if flag == 0: + return None + elif flag == 1: + return _UniffiConverterString.read(buf) + else: + raise InternalError("Unexpected flag byte for optional type") + + + +class _UniffiConverterOptionalBytes(_UniffiConverterRustBuffer): + @classmethod + def check_lower(cls, value): + if value is not None: + _UniffiConverterBytes.check_lower(value) + + @classmethod + def write(cls, value, buf): + if value is None: + buf.write_u8(0) return - raise ValueError(value) - @staticmethod - def write(value, buf): - if value.is_STANDARD(): - buf.write_i32(1) - if value.is_HIDDEN(): - buf.write_i32(2) - _UniffiConverterString.write(value.passphrase, buf) - if value.is_ON_DEVICE(): - buf.write_i32(3) + buf.write_u8(1) + _UniffiConverterBytes.write(value, buf) + @classmethod + def read(cls, buf): + flag = buf.read_u8() + if flag == 0: + return None + elif flag == 1: + return _UniffiConverterBytes.read(buf) + else: + raise InternalError("Unexpected flag byte for optional type") +class _UniffiConverterOptionalTypeBoltzSwap(_UniffiConverterRustBuffer): + @classmethod + def check_lower(cls, value): + if value is not None: + _UniffiConverterTypeBoltzSwap.check_lower(value) + @classmethod + def write(cls, value, buf): + if value is None: + buf.write_u8(0) + return + buf.write_u8(1) + _UniffiConverterTypeBoltzSwap.write(value, buf) -class WatcherEvent: - """ - Events emitted by the onchain xpub watcher. - """ + @classmethod + def read(cls, buf): + flag = buf.read_u8() + if flag == 0: + return None + elif flag == 1: + return _UniffiConverterTypeBoltzSwap.read(buf) + else: + raise InternalError("Unexpected flag byte for optional type") - def __init__(self): - raise RuntimeError("WatcherEvent cannot be instantiated directly") - # Each enum variant is a nested class of the enum itself. - class TRANSACTIONS_CHANGED: - """ - Transaction activity changed — contains full updated state. - `activities` and `transaction_details` are persistence-ready: they carry - the watcher's `wallet_id`, real decoded addresses, fees from the watched - wallet's perspective, and DB-valid timestamps, so the app can store them - directly through the normal Core activity APIs (e.g. `upsert_activity` / - `upsert_transaction_details`). The two vecs are parallel by `tx_id`. - `next_unused_external_address` is the synchronized wallet's current - external receive address. - """ +class _UniffiConverterOptionalTypeClosedChannelDetails(_UniffiConverterRustBuffer): + @classmethod + def check_lower(cls, value): + if value is not None: + _UniffiConverterTypeClosedChannelDetails.check_lower(value) - activities: "typing.List[Activity]" - transaction_details: "typing.List[TransactionDetails]" - balance: "WalletBalance" - tx_count: "int" - block_height: "int" - account_type: "AccountType" - next_unused_external_address: "AddressInfo" + @classmethod + def write(cls, value, buf): + if value is None: + buf.write_u8(0) + return - def __init__(self,activities: "typing.List[Activity]", transaction_details: "typing.List[TransactionDetails]", balance: "WalletBalance", tx_count: "int", block_height: "int", account_type: "AccountType", next_unused_external_address: "AddressInfo"): - self.activities = activities - self.transaction_details = transaction_details - self.balance = balance - self.tx_count = tx_count - self.block_height = block_height - self.account_type = account_type - self.next_unused_external_address = next_unused_external_address + buf.write_u8(1) + _UniffiConverterTypeClosedChannelDetails.write(value, buf) - def __str__(self): - return "WatcherEvent.TRANSACTIONS_CHANGED(activities={}, transaction_details={}, balance={}, tx_count={}, block_height={}, account_type={}, next_unused_external_address={})".format(self.activities, self.transaction_details, self.balance, self.tx_count, self.block_height, self.account_type, self.next_unused_external_address) + @classmethod + def read(cls, buf): + flag = buf.read_u8() + if flag == 0: + return None + elif flag == 1: + return _UniffiConverterTypeClosedChannelDetails.read(buf) + else: + raise InternalError("Unexpected flag byte for optional type") - def __eq__(self, other): - if not other.is_TRANSACTIONS_CHANGED(): - return False - if self.activities != other.activities: - return False - if self.transaction_details != other.transaction_details: - return False - if self.balance != other.balance: - return False - if self.tx_count != other.tx_count: - return False - if self.block_height != other.block_height: - return False - if self.account_type != other.account_type: - return False - if self.next_unused_external_address != other.next_unused_external_address: - return False - return True - - class ERROR: - """ - An error occurred in the watcher loop. - """ - message: "str" - def __init__(self,message: "str"): - self.message = message +class _UniffiConverterOptionalTypeCreateCjitOptions(_UniffiConverterRustBuffer): + @classmethod + def check_lower(cls, value): + if value is not None: + _UniffiConverterTypeCreateCjitOptions.check_lower(value) - def __str__(self): - return "WatcherEvent.ERROR(message={})".format(self.message) + @classmethod + def write(cls, value, buf): + if value is None: + buf.write_u8(0) + return - def __eq__(self, other): - if not other.is_ERROR(): - return False - if self.message != other.message: - return False - return True - - class DISCONNECTED: - """ - Connection to the Electrum server was lost. - """ + buf.write_u8(1) + _UniffiConverterTypeCreateCjitOptions.write(value, buf) - message: "str" + @classmethod + def read(cls, buf): + flag = buf.read_u8() + if flag == 0: + return None + elif flag == 1: + return _UniffiConverterTypeCreateCjitOptions.read(buf) + else: + raise InternalError("Unexpected flag byte for optional type") - def __init__(self,message: "str"): - self.message = message - def __str__(self): - return "WatcherEvent.DISCONNECTED(message={})".format(self.message) - def __eq__(self, other): - if not other.is_DISCONNECTED(): - return False - if self.message != other.message: - return False - return True - - class RECONNECTED: - """ - Connection to the Electrum server was restored. - """ +class _UniffiConverterOptionalTypeCreateOrderOptions(_UniffiConverterRustBuffer): + @classmethod + def check_lower(cls, value): + if value is not None: + _UniffiConverterTypeCreateOrderOptions.check_lower(value) + @classmethod + def write(cls, value, buf): + if value is None: + buf.write_u8(0) + return - def __init__(self,): - pass + buf.write_u8(1) + _UniffiConverterTypeCreateOrderOptions.write(value, buf) - def __str__(self): - return "WatcherEvent.RECONNECTED()".format() + @classmethod + def read(cls, buf): + flag = buf.read_u8() + if flag == 0: + return None + elif flag == 1: + return _UniffiConverterTypeCreateOrderOptions.read(buf) + else: + raise InternalError("Unexpected flag byte for optional type") - def __eq__(self, other): - if not other.is_RECONNECTED(): - return False - return True - - - # For each variant, we have `is_NAME` and `is_name` methods for easily checking - # whether an instance is that variant. - def is_TRANSACTIONS_CHANGED(self) -> bool: - return isinstance(self, WatcherEvent.TRANSACTIONS_CHANGED) - def is_transactions_changed(self) -> bool: - return isinstance(self, WatcherEvent.TRANSACTIONS_CHANGED) - def is_ERROR(self) -> bool: - return isinstance(self, WatcherEvent.ERROR) - def is_error(self) -> bool: - return isinstance(self, WatcherEvent.ERROR) - def is_DISCONNECTED(self) -> bool: - return isinstance(self, WatcherEvent.DISCONNECTED) - def is_disconnected(self) -> bool: - return isinstance(self, WatcherEvent.DISCONNECTED) - def is_RECONNECTED(self) -> bool: - return isinstance(self, WatcherEvent.RECONNECTED) - def is_reconnected(self) -> bool: - return isinstance(self, WatcherEvent.RECONNECTED) - -# Now, a little trick - we make each nested variant class be a subclass of the main -# enum class, so that method calls and instance checks etc will work intuitively. -# We might be able to do this a little more neatly with a metaclass, but this'll do. -WatcherEvent.TRANSACTIONS_CHANGED = type("WatcherEvent.TRANSACTIONS_CHANGED", (WatcherEvent.TRANSACTIONS_CHANGED, WatcherEvent,), {}) # type: ignore -WatcherEvent.ERROR = type("WatcherEvent.ERROR", (WatcherEvent.ERROR, WatcherEvent,), {}) # type: ignore -WatcherEvent.DISCONNECTED = type("WatcherEvent.DISCONNECTED", (WatcherEvent.DISCONNECTED, WatcherEvent,), {}) # type: ignore -WatcherEvent.RECONNECTED = type("WatcherEvent.RECONNECTED", (WatcherEvent.RECONNECTED, WatcherEvent,), {}) # type: ignore +class _UniffiConverterOptionalTypeIBtBolt11Invoice(_UniffiConverterRustBuffer): + @classmethod + def check_lower(cls, value): + if value is not None: + _UniffiConverterTypeIBtBolt11Invoice.check_lower(value) + + @classmethod + def write(cls, value, buf): + if value is None: + buf.write_u8(0) + return + buf.write_u8(1) + _UniffiConverterTypeIBtBolt11Invoice.write(value, buf) + @classmethod + def read(cls, buf): + flag = buf.read_u8() + if flag == 0: + return None + elif flag == 1: + return _UniffiConverterTypeIBtBolt11Invoice.read(buf) + else: + raise InternalError("Unexpected flag byte for optional type") -class _UniffiConverterTypeWatcherEvent(_UniffiConverterRustBuffer): - @staticmethod - def read(buf): - variant = buf.read_i32() - if variant == 1: - return WatcherEvent.TRANSACTIONS_CHANGED( - _UniffiConverterSequenceTypeActivity.read(buf), - _UniffiConverterSequenceTypeTransactionDetails.read(buf), - _UniffiConverterTypeWalletBalance.read(buf), - _UniffiConverterUInt32.read(buf), - _UniffiConverterUInt32.read(buf), - _UniffiConverterTypeAccountType.read(buf), - _UniffiConverterTypeAddressInfo.read(buf), - ) - if variant == 2: - return WatcherEvent.ERROR( - _UniffiConverterString.read(buf), - ) - if variant == 3: - return WatcherEvent.DISCONNECTED( - _UniffiConverterString.read(buf), - ) - if variant == 4: - return WatcherEvent.RECONNECTED( - ) - raise InternalError("Raw enum value doesn't match any cases") - @staticmethod - def check_lower(value): - if value.is_TRANSACTIONS_CHANGED(): - _UniffiConverterSequenceTypeActivity.check_lower(value.activities) - _UniffiConverterSequenceTypeTransactionDetails.check_lower(value.transaction_details) - _UniffiConverterTypeWalletBalance.check_lower(value.balance) - _UniffiConverterUInt32.check_lower(value.tx_count) - _UniffiConverterUInt32.check_lower(value.block_height) - _UniffiConverterTypeAccountType.check_lower(value.account_type) - _UniffiConverterTypeAddressInfo.check_lower(value.next_unused_external_address) - return - if value.is_ERROR(): - _UniffiConverterString.check_lower(value.message) - return - if value.is_DISCONNECTED(): - _UniffiConverterString.check_lower(value.message) - return - if value.is_RECONNECTED(): +class _UniffiConverterOptionalTypeIBtChannel(_UniffiConverterRustBuffer): + @classmethod + def check_lower(cls, value): + if value is not None: + _UniffiConverterTypeIBtChannel.check_lower(value) + + @classmethod + def write(cls, value, buf): + if value is None: + buf.write_u8(0) return - raise ValueError(value) - @staticmethod - def write(value, buf): - if value.is_TRANSACTIONS_CHANGED(): - buf.write_i32(1) - _UniffiConverterSequenceTypeActivity.write(value.activities, buf) - _UniffiConverterSequenceTypeTransactionDetails.write(value.transaction_details, buf) - _UniffiConverterTypeWalletBalance.write(value.balance, buf) - _UniffiConverterUInt32.write(value.tx_count, buf) - _UniffiConverterUInt32.write(value.block_height, buf) - _UniffiConverterTypeAccountType.write(value.account_type, buf) - _UniffiConverterTypeAddressInfo.write(value.next_unused_external_address, buf) - if value.is_ERROR(): - buf.write_i32(2) - _UniffiConverterString.write(value.message, buf) - if value.is_DISCONNECTED(): - buf.write_i32(3) - _UniffiConverterString.write(value.message, buf) - if value.is_RECONNECTED(): - buf.write_i32(4) + buf.write_u8(1) + _UniffiConverterTypeIBtChannel.write(value, buf) + @classmethod + def read(cls, buf): + flag = buf.read_u8() + if flag == 0: + return None + elif flag == 1: + return _UniffiConverterTypeIBtChannel.read(buf) + else: + raise InternalError("Unexpected flag byte for optional type") +class _UniffiConverterOptionalTypeIBtChannelClose(_UniffiConverterRustBuffer): + @classmethod + def check_lower(cls, value): + if value is not None: + _UniffiConverterTypeIBtChannelClose.check_lower(value) + @classmethod + def write(cls, value, buf): + if value is None: + buf.write_u8(0) + return + buf.write_u8(1) + _UniffiConverterTypeIBtChannelClose.write(value, buf) -class WordCount(enum.Enum): - WORDS12 = 12 - """ - 12-word mnemonic (128 bits of entropy) - """ + @classmethod + def read(cls, buf): + flag = buf.read_u8() + if flag == 0: + return None + elif flag == 1: + return _UniffiConverterTypeIBtChannelClose.read(buf) + else: + raise InternalError("Unexpected flag byte for optional type") - - WORDS15 = 15 - """ - 15-word mnemonic (160 bits of entropy) - """ - - WORDS18 = 18 - """ - 18-word mnemonic (192 bits of entropy) - """ - - WORDS21 = 21 - """ - 21-word mnemonic (224 bits of entropy) - """ +class _UniffiConverterOptionalTypeIBtInfo(_UniffiConverterRustBuffer): + @classmethod + def check_lower(cls, value): + if value is not None: + _UniffiConverterTypeIBtInfo.check_lower(value) - - WORDS24 = 24 - """ - 24-word mnemonic (256 bits of entropy) - """ + @classmethod + def write(cls, value, buf): + if value is None: + buf.write_u8(0) + return - + buf.write_u8(1) + _UniffiConverterTypeIBtInfo.write(value, buf) + @classmethod + def read(cls, buf): + flag = buf.read_u8() + if flag == 0: + return None + elif flag == 1: + return _UniffiConverterTypeIBtInfo.read(buf) + else: + raise InternalError("Unexpected flag byte for optional type") -class _UniffiConverterTypeWordCount(_UniffiConverterRustBuffer): - @staticmethod - def read(buf): - variant = buf.read_i32() - if variant == 1: - return WordCount.WORDS12 - if variant == 2: - return WordCount.WORDS15 - if variant == 3: - return WordCount.WORDS18 - if variant == 4: - return WordCount.WORDS21 - if variant == 5: - return WordCount.WORDS24 - raise InternalError("Raw enum value doesn't match any cases") - @staticmethod - def check_lower(value): - if value == WordCount.WORDS12: - return - if value == WordCount.WORDS15: - return - if value == WordCount.WORDS18: - return - if value == WordCount.WORDS21: - return - if value == WordCount.WORDS24: - return - raise ValueError(value) - @staticmethod - def write(value, buf): - if value == WordCount.WORDS12: - buf.write_i32(1) - if value == WordCount.WORDS15: - buf.write_i32(2) - if value == WordCount.WORDS18: - buf.write_i32(3) - if value == WordCount.WORDS21: - buf.write_i32(4) - if value == WordCount.WORDS24: - buf.write_i32(5) +class _UniffiConverterOptionalTypeIBtOnchainTransactions(_UniffiConverterRustBuffer): + @classmethod + def check_lower(cls, value): + if value is not None: + _UniffiConverterTypeIBtOnchainTransactions.check_lower(value) + @classmethod + def write(cls, value, buf): + if value is None: + buf.write_u8(0) + return + + buf.write_u8(1) + _UniffiConverterTypeIBtOnchainTransactions.write(value, buf) + @classmethod + def read(cls, buf): + flag = buf.read_u8() + if flag == 0: + return None + elif flag == 1: + return _UniffiConverterTypeIBtOnchainTransactions.read(buf) + else: + raise InternalError("Unexpected flag byte for optional type") -class _UniffiConverterOptionalUInt16(_UniffiConverterRustBuffer): +class _UniffiConverterOptionalTypeIBtPayment(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): if value is not None: - _UniffiConverterUInt16.check_lower(value) + _UniffiConverterTypeIBtPayment.check_lower(value) @classmethod def write(cls, value, buf): @@ -17949,7 +19978,7 @@ def write(cls, value, buf): return buf.write_u8(1) - _UniffiConverterUInt16.write(value, buf) + _UniffiConverterTypeIBtPayment.write(value, buf) @classmethod def read(cls, buf): @@ -17957,17 +19986,17 @@ def read(cls, buf): if flag == 0: return None elif flag == 1: - return _UniffiConverterUInt16.read(buf) + return _UniffiConverterTypeIBtPayment.read(buf) else: raise InternalError("Unexpected flag byte for optional type") -class _UniffiConverterOptionalUInt32(_UniffiConverterRustBuffer): +class _UniffiConverterOptionalTypeIDiscount(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): if value is not None: - _UniffiConverterUInt32.check_lower(value) + _UniffiConverterTypeIDiscount.check_lower(value) @classmethod def write(cls, value, buf): @@ -17976,7 +20005,7 @@ def write(cls, value, buf): return buf.write_u8(1) - _UniffiConverterUInt32.write(value, buf) + _UniffiConverterTypeIDiscount.write(value, buf) @classmethod def read(cls, buf): @@ -17984,17 +20013,17 @@ def read(cls, buf): if flag == 0: return None elif flag == 1: - return _UniffiConverterUInt32.read(buf) + return _UniffiConverterTypeIDiscount.read(buf) else: raise InternalError("Unexpected flag byte for optional type") -class _UniffiConverterOptionalUInt64(_UniffiConverterRustBuffer): +class _UniffiConverterOptionalTypeIGiftBolt11Invoice(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): if value is not None: - _UniffiConverterUInt64.check_lower(value) + _UniffiConverterTypeIGiftBolt11Invoice.check_lower(value) @classmethod def write(cls, value, buf): @@ -18003,7 +20032,7 @@ def write(cls, value, buf): return buf.write_u8(1) - _UniffiConverterUInt64.write(value, buf) + _UniffiConverterTypeIGiftBolt11Invoice.write(value, buf) @classmethod def read(cls, buf): @@ -18011,17 +20040,17 @@ def read(cls, buf): if flag == 0: return None elif flag == 1: - return _UniffiConverterUInt64.read(buf) + return _UniffiConverterTypeIGiftBolt11Invoice.read(buf) else: raise InternalError("Unexpected flag byte for optional type") -class _UniffiConverterOptionalDouble(_UniffiConverterRustBuffer): +class _UniffiConverterOptionalTypeIGiftBtcAddress(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): if value is not None: - _UniffiConverterDouble.check_lower(value) + _UniffiConverterTypeIGiftBtcAddress.check_lower(value) @classmethod def write(cls, value, buf): @@ -18030,7 +20059,7 @@ def write(cls, value, buf): return buf.write_u8(1) - _UniffiConverterDouble.write(value, buf) + _UniffiConverterTypeIGiftBtcAddress.write(value, buf) @classmethod def read(cls, buf): @@ -18038,17 +20067,17 @@ def read(cls, buf): if flag == 0: return None elif flag == 1: - return _UniffiConverterDouble.read(buf) + return _UniffiConverterTypeIGiftBtcAddress.read(buf) else: raise InternalError("Unexpected flag byte for optional type") -class _UniffiConverterOptionalBool(_UniffiConverterRustBuffer): +class _UniffiConverterOptionalTypeIGiftCode(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): if value is not None: - _UniffiConverterBool.check_lower(value) + _UniffiConverterTypeIGiftCode.check_lower(value) @classmethod def write(cls, value, buf): @@ -18057,7 +20086,7 @@ def write(cls, value, buf): return buf.write_u8(1) - _UniffiConverterBool.write(value, buf) + _UniffiConverterTypeIGiftCode.write(value, buf) @classmethod def read(cls, buf): @@ -18065,17 +20094,17 @@ def read(cls, buf): if flag == 0: return None elif flag == 1: - return _UniffiConverterBool.read(buf) + return _UniffiConverterTypeIGiftCode.read(buf) else: raise InternalError("Unexpected flag byte for optional type") -class _UniffiConverterOptionalString(_UniffiConverterRustBuffer): +class _UniffiConverterOptionalTypeIGiftLspNode(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): if value is not None: - _UniffiConverterString.check_lower(value) + _UniffiConverterTypeIGiftLspNode.check_lower(value) @classmethod def write(cls, value, buf): @@ -18084,7 +20113,7 @@ def write(cls, value, buf): return buf.write_u8(1) - _UniffiConverterString.write(value, buf) + _UniffiConverterTypeIGiftLspNode.write(value, buf) @classmethod def read(cls, buf): @@ -18092,17 +20121,17 @@ def read(cls, buf): if flag == 0: return None elif flag == 1: - return _UniffiConverterString.read(buf) + return _UniffiConverterTypeIGiftLspNode.read(buf) else: raise InternalError("Unexpected flag byte for optional type") -class _UniffiConverterOptionalBytes(_UniffiConverterRustBuffer): +class _UniffiConverterOptionalTypeIGiftOrder(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): if value is not None: - _UniffiConverterBytes.check_lower(value) + _UniffiConverterTypeIGiftOrder.check_lower(value) @classmethod def write(cls, value, buf): @@ -18111,7 +20140,7 @@ def write(cls, value, buf): return buf.write_u8(1) - _UniffiConverterBytes.write(value, buf) + _UniffiConverterTypeIGiftOrder.write(value, buf) @classmethod def read(cls, buf): @@ -18119,17 +20148,17 @@ def read(cls, buf): if flag == 0: return None elif flag == 1: - return _UniffiConverterBytes.read(buf) + return _UniffiConverterTypeIGiftOrder.read(buf) else: raise InternalError("Unexpected flag byte for optional type") -class _UniffiConverterOptionalTypeBoltzSwap(_UniffiConverterRustBuffer): +class _UniffiConverterOptionalTypeIGiftPayment(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): if value is not None: - _UniffiConverterTypeBoltzSwap.check_lower(value) + _UniffiConverterTypeIGiftPayment.check_lower(value) @classmethod def write(cls, value, buf): @@ -18138,7 +20167,7 @@ def write(cls, value, buf): return buf.write_u8(1) - _UniffiConverterTypeBoltzSwap.write(value, buf) + _UniffiConverterTypeIGiftPayment.write(value, buf) @classmethod def read(cls, buf): @@ -18146,17 +20175,17 @@ def read(cls, buf): if flag == 0: return None elif flag == 1: - return _UniffiConverterTypeBoltzSwap.read(buf) + return _UniffiConverterTypeIGiftPayment.read(buf) else: raise InternalError("Unexpected flag byte for optional type") -class _UniffiConverterOptionalTypeClosedChannelDetails(_UniffiConverterRustBuffer): +class _UniffiConverterOptionalTypeILspNode(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): if value is not None: - _UniffiConverterTypeClosedChannelDetails.check_lower(value) + _UniffiConverterTypeILspNode.check_lower(value) @classmethod def write(cls, value, buf): @@ -18165,7 +20194,7 @@ def write(cls, value, buf): return buf.write_u8(1) - _UniffiConverterTypeClosedChannelDetails.write(value, buf) + _UniffiConverterTypeILspNode.write(value, buf) @classmethod def read(cls, buf): @@ -18173,17 +20202,17 @@ def read(cls, buf): if flag == 0: return None elif flag == 1: - return _UniffiConverterTypeClosedChannelDetails.read(buf) + return _UniffiConverterTypeILspNode.read(buf) else: raise InternalError("Unexpected flag byte for optional type") -class _UniffiConverterOptionalTypeCreateCjitOptions(_UniffiConverterRustBuffer): +class _UniffiConverterOptionalTypeJadeDeviceInfo(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): if value is not None: - _UniffiConverterTypeCreateCjitOptions.check_lower(value) + _UniffiConverterTypeJadeDeviceInfo.check_lower(value) @classmethod def write(cls, value, buf): @@ -18192,7 +20221,7 @@ def write(cls, value, buf): return buf.write_u8(1) - _UniffiConverterTypeCreateCjitOptions.write(value, buf) + _UniffiConverterTypeJadeDeviceInfo.write(value, buf) @classmethod def read(cls, buf): @@ -18200,17 +20229,17 @@ def read(cls, buf): if flag == 0: return None elif flag == 1: - return _UniffiConverterTypeCreateCjitOptions.read(buf) + return _UniffiConverterTypeJadeDeviceInfo.read(buf) else: raise InternalError("Unexpected flag byte for optional type") -class _UniffiConverterOptionalTypeCreateOrderOptions(_UniffiConverterRustBuffer): +class _UniffiConverterOptionalTypeJadeVersionInfo(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): if value is not None: - _UniffiConverterTypeCreateOrderOptions.check_lower(value) + _UniffiConverterTypeJadeVersionInfo.check_lower(value) @classmethod def write(cls, value, buf): @@ -18219,7 +20248,7 @@ def write(cls, value, buf): return buf.write_u8(1) - _UniffiConverterTypeCreateOrderOptions.write(value, buf) + _UniffiConverterTypeJadeVersionInfo.write(value, buf) @classmethod def read(cls, buf): @@ -18227,17 +20256,17 @@ def read(cls, buf): if flag == 0: return None elif flag == 1: - return _UniffiConverterTypeCreateOrderOptions.read(buf) + return _UniffiConverterTypeJadeVersionInfo.read(buf) else: raise InternalError("Unexpected flag byte for optional type") -class _UniffiConverterOptionalTypeIBtBolt11Invoice(_UniffiConverterRustBuffer): +class _UniffiConverterOptionalTypeOnchainActivity(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): if value is not None: - _UniffiConverterTypeIBtBolt11Invoice.check_lower(value) + _UniffiConverterTypeOnchainActivity.check_lower(value) @classmethod def write(cls, value, buf): @@ -18246,7 +20275,7 @@ def write(cls, value, buf): return buf.write_u8(1) - _UniffiConverterTypeIBtBolt11Invoice.write(value, buf) + _UniffiConverterTypeOnchainActivity.write(value, buf) @classmethod def read(cls, buf): @@ -18254,17 +20283,17 @@ def read(cls, buf): if flag == 0: return None elif flag == 1: - return _UniffiConverterTypeIBtBolt11Invoice.read(buf) + return _UniffiConverterTypeOnchainActivity.read(buf) else: raise InternalError("Unexpected flag byte for optional type") -class _UniffiConverterOptionalTypeIBtChannel(_UniffiConverterRustBuffer): +class _UniffiConverterOptionalTypePreActivityMetadata(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): if value is not None: - _UniffiConverterTypeIBtChannel.check_lower(value) + _UniffiConverterTypePreActivityMetadata.check_lower(value) @classmethod def write(cls, value, buf): @@ -18273,7 +20302,7 @@ def write(cls, value, buf): return buf.write_u8(1) - _UniffiConverterTypeIBtChannel.write(value, buf) + _UniffiConverterTypePreActivityMetadata.write(value, buf) @classmethod def read(cls, buf): @@ -18281,17 +20310,17 @@ def read(cls, buf): if flag == 0: return None elif flag == 1: - return _UniffiConverterTypeIBtChannel.read(buf) + return _UniffiConverterTypePreActivityMetadata.read(buf) else: raise InternalError("Unexpected flag byte for optional type") -class _UniffiConverterOptionalTypeIBtChannelClose(_UniffiConverterRustBuffer): +class _UniffiConverterOptionalTypeTransactionDetails(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): if value is not None: - _UniffiConverterTypeIBtChannelClose.check_lower(value) + _UniffiConverterTypeTransactionDetails.check_lower(value) @classmethod def write(cls, value, buf): @@ -18300,7 +20329,7 @@ def write(cls, value, buf): return buf.write_u8(1) - _UniffiConverterTypeIBtChannelClose.write(value, buf) + _UniffiConverterTypeTransactionDetails.write(value, buf) @classmethod def read(cls, buf): @@ -18308,17 +20337,17 @@ def read(cls, buf): if flag == 0: return None elif flag == 1: - return _UniffiConverterTypeIBtChannelClose.read(buf) + return _UniffiConverterTypeTransactionDetails.read(buf) else: raise InternalError("Unexpected flag byte for optional type") -class _UniffiConverterOptionalTypeIBtInfo(_UniffiConverterRustBuffer): +class _UniffiConverterOptionalTypeTrezorCallMessageResult(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): if value is not None: - _UniffiConverterTypeIBtInfo.check_lower(value) + _UniffiConverterTypeTrezorCallMessageResult.check_lower(value) @classmethod def write(cls, value, buf): @@ -18327,7 +20356,7 @@ def write(cls, value, buf): return buf.write_u8(1) - _UniffiConverterTypeIBtInfo.write(value, buf) + _UniffiConverterTypeTrezorCallMessageResult.write(value, buf) @classmethod def read(cls, buf): @@ -18335,17 +20364,17 @@ def read(cls, buf): if flag == 0: return None elif flag == 1: - return _UniffiConverterTypeIBtInfo.read(buf) + return _UniffiConverterTypeTrezorCallMessageResult.read(buf) else: raise InternalError("Unexpected flag byte for optional type") -class _UniffiConverterOptionalTypeIBtOnchainTransactions(_UniffiConverterRustBuffer): +class _UniffiConverterOptionalTypeTrezorDeviceInfo(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): if value is not None: - _UniffiConverterTypeIBtOnchainTransactions.check_lower(value) + _UniffiConverterTypeTrezorDeviceInfo.check_lower(value) @classmethod def write(cls, value, buf): @@ -18354,7 +20383,7 @@ def write(cls, value, buf): return buf.write_u8(1) - _UniffiConverterTypeIBtOnchainTransactions.write(value, buf) + _UniffiConverterTypeTrezorDeviceInfo.write(value, buf) @classmethod def read(cls, buf): @@ -18362,17 +20391,17 @@ def read(cls, buf): if flag == 0: return None elif flag == 1: - return _UniffiConverterTypeIBtOnchainTransactions.read(buf) + return _UniffiConverterTypeTrezorDeviceInfo.read(buf) else: raise InternalError("Unexpected flag byte for optional type") -class _UniffiConverterOptionalTypeIBtPayment(_UniffiConverterRustBuffer): +class _UniffiConverterOptionalTypeTrezorFeatures(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): if value is not None: - _UniffiConverterTypeIBtPayment.check_lower(value) + _UniffiConverterTypeTrezorFeatures.check_lower(value) @classmethod def write(cls, value, buf): @@ -18381,7 +20410,7 @@ def write(cls, value, buf): return buf.write_u8(1) - _UniffiConverterTypeIBtPayment.write(value, buf) + _UniffiConverterTypeTrezorFeatures.write(value, buf) @classmethod def read(cls, buf): @@ -18389,17 +20418,17 @@ def read(cls, buf): if flag == 0: return None elif flag == 1: - return _UniffiConverterTypeIBtPayment.read(buf) + return _UniffiConverterTypeTrezorFeatures.read(buf) else: raise InternalError("Unexpected flag byte for optional type") -class _UniffiConverterOptionalTypeIDiscount(_UniffiConverterRustBuffer): +class _UniffiConverterOptionalTypeAccountType(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): if value is not None: - _UniffiConverterTypeIDiscount.check_lower(value) + _UniffiConverterTypeAccountType.check_lower(value) @classmethod def write(cls, value, buf): @@ -18408,7 +20437,7 @@ def write(cls, value, buf): return buf.write_u8(1) - _UniffiConverterTypeIDiscount.write(value, buf) + _UniffiConverterTypeAccountType.write(value, buf) @classmethod def read(cls, buf): @@ -18416,17 +20445,17 @@ def read(cls, buf): if flag == 0: return None elif flag == 1: - return _UniffiConverterTypeIDiscount.read(buf) + return _UniffiConverterTypeAccountType.read(buf) else: raise InternalError("Unexpected flag byte for optional type") -class _UniffiConverterOptionalTypeIGiftBolt11Invoice(_UniffiConverterRustBuffer): +class _UniffiConverterOptionalTypeActivity(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): if value is not None: - _UniffiConverterTypeIGiftBolt11Invoice.check_lower(value) + _UniffiConverterTypeActivity.check_lower(value) @classmethod def write(cls, value, buf): @@ -18435,7 +20464,7 @@ def write(cls, value, buf): return buf.write_u8(1) - _UniffiConverterTypeIGiftBolt11Invoice.write(value, buf) + _UniffiConverterTypeActivity.write(value, buf) @classmethod def read(cls, buf): @@ -18443,17 +20472,17 @@ def read(cls, buf): if flag == 0: return None elif flag == 1: - return _UniffiConverterTypeIGiftBolt11Invoice.read(buf) + return _UniffiConverterTypeActivity.read(buf) else: raise InternalError("Unexpected flag byte for optional type") -class _UniffiConverterOptionalTypeIGiftBtcAddress(_UniffiConverterRustBuffer): +class _UniffiConverterOptionalTypeActivityFilter(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): if value is not None: - _UniffiConverterTypeIGiftBtcAddress.check_lower(value) + _UniffiConverterTypeActivityFilter.check_lower(value) @classmethod def write(cls, value, buf): @@ -18462,7 +20491,7 @@ def write(cls, value, buf): return buf.write_u8(1) - _UniffiConverterTypeIGiftBtcAddress.write(value, buf) + _UniffiConverterTypeActivityFilter.write(value, buf) @classmethod def read(cls, buf): @@ -18470,17 +20499,17 @@ def read(cls, buf): if flag == 0: return None elif flag == 1: - return _UniffiConverterTypeIGiftBtcAddress.read(buf) + return _UniffiConverterTypeActivityFilter.read(buf) else: raise InternalError("Unexpected flag byte for optional type") -class _UniffiConverterOptionalTypeIGiftCode(_UniffiConverterRustBuffer): +class _UniffiConverterOptionalTypeBtOrderState2(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): if value is not None: - _UniffiConverterTypeIGiftCode.check_lower(value) + _UniffiConverterTypeBtOrderState2.check_lower(value) @classmethod def write(cls, value, buf): @@ -18489,7 +20518,7 @@ def write(cls, value, buf): return buf.write_u8(1) - _UniffiConverterTypeIGiftCode.write(value, buf) + _UniffiConverterTypeBtOrderState2.write(value, buf) @classmethod def read(cls, buf): @@ -18497,17 +20526,17 @@ def read(cls, buf): if flag == 0: return None elif flag == 1: - return _UniffiConverterTypeIGiftCode.read(buf) + return _UniffiConverterTypeBtOrderState2.read(buf) else: raise InternalError("Unexpected flag byte for optional type") -class _UniffiConverterOptionalTypeIGiftLspNode(_UniffiConverterRustBuffer): +class _UniffiConverterOptionalTypeBtPaymentState2(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): if value is not None: - _UniffiConverterTypeIGiftLspNode.check_lower(value) + _UniffiConverterTypeBtPaymentState2.check_lower(value) @classmethod def write(cls, value, buf): @@ -18516,7 +20545,7 @@ def write(cls, value, buf): return buf.write_u8(1) - _UniffiConverterTypeIGiftLspNode.write(value, buf) + _UniffiConverterTypeBtPaymentState2.write(value, buf) @classmethod def read(cls, buf): @@ -18524,17 +20553,17 @@ def read(cls, buf): if flag == 0: return None elif flag == 1: - return _UniffiConverterTypeIGiftLspNode.read(buf) + return _UniffiConverterTypeBtPaymentState2.read(buf) else: raise InternalError("Unexpected flag byte for optional type") -class _UniffiConverterOptionalTypeIGiftOrder(_UniffiConverterRustBuffer): +class _UniffiConverterOptionalTypeCJitStateEnum(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): if value is not None: - _UniffiConverterTypeIGiftOrder.check_lower(value) + _UniffiConverterTypeCJitStateEnum.check_lower(value) @classmethod def write(cls, value, buf): @@ -18543,7 +20572,7 @@ def write(cls, value, buf): return buf.write_u8(1) - _UniffiConverterTypeIGiftOrder.write(value, buf) + _UniffiConverterTypeCJitStateEnum.write(value, buf) @classmethod def read(cls, buf): @@ -18551,17 +20580,17 @@ def read(cls, buf): if flag == 0: return None elif flag == 1: - return _UniffiConverterTypeIGiftOrder.read(buf) + return _UniffiConverterTypeCJitStateEnum.read(buf) else: raise InternalError("Unexpected flag byte for optional type") -class _UniffiConverterOptionalTypeIGiftPayment(_UniffiConverterRustBuffer): +class _UniffiConverterOptionalTypeCoinSelection(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): if value is not None: - _UniffiConverterTypeIGiftPayment.check_lower(value) + _UniffiConverterTypeCoinSelection.check_lower(value) @classmethod def write(cls, value, buf): @@ -18570,7 +20599,7 @@ def write(cls, value, buf): return buf.write_u8(1) - _UniffiConverterTypeIGiftPayment.write(value, buf) + _UniffiConverterTypeCoinSelection.write(value, buf) @classmethod def read(cls, buf): @@ -18578,17 +20607,17 @@ def read(cls, buf): if flag == 0: return None elif flag == 1: - return _UniffiConverterTypeIGiftPayment.read(buf) + return _UniffiConverterTypeCoinSelection.read(buf) else: raise InternalError("Unexpected flag byte for optional type") -class _UniffiConverterOptionalTypeILspNode(_UniffiConverterRustBuffer): +class _UniffiConverterOptionalTypeJadeTransportErrorCode(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): if value is not None: - _UniffiConverterTypeILspNode.check_lower(value) + _UniffiConverterTypeJadeTransportErrorCode.check_lower(value) @classmethod def write(cls, value, buf): @@ -18597,7 +20626,7 @@ def write(cls, value, buf): return buf.write_u8(1) - _UniffiConverterTypeILspNode.write(value, buf) + _UniffiConverterTypeJadeTransportErrorCode.write(value, buf) @classmethod def read(cls, buf): @@ -18605,17 +20634,17 @@ def read(cls, buf): if flag == 0: return None elif flag == 1: - return _UniffiConverterTypeILspNode.read(buf) + return _UniffiConverterTypeJadeTransportErrorCode.read(buf) else: raise InternalError("Unexpected flag byte for optional type") -class _UniffiConverterOptionalTypeOnchainActivity(_UniffiConverterRustBuffer): +class _UniffiConverterOptionalTypeNetwork(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): if value is not None: - _UniffiConverterTypeOnchainActivity.check_lower(value) + _UniffiConverterTypeNetwork.check_lower(value) @classmethod def write(cls, value, buf): @@ -18624,7 +20653,7 @@ def write(cls, value, buf): return buf.write_u8(1) - _UniffiConverterTypeOnchainActivity.write(value, buf) + _UniffiConverterTypeNetwork.write(value, buf) @classmethod def read(cls, buf): @@ -18632,17 +20661,17 @@ def read(cls, buf): if flag == 0: return None elif flag == 1: - return _UniffiConverterTypeOnchainActivity.read(buf) + return _UniffiConverterTypeNetwork.read(buf) else: raise InternalError("Unexpected flag byte for optional type") -class _UniffiConverterOptionalTypePreActivityMetadata(_UniffiConverterRustBuffer): +class _UniffiConverterOptionalTypePaymentType(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): if value is not None: - _UniffiConverterTypePreActivityMetadata.check_lower(value) + _UniffiConverterTypePaymentType.check_lower(value) @classmethod def write(cls, value, buf): @@ -18651,7 +20680,7 @@ def write(cls, value, buf): return buf.write_u8(1) - _UniffiConverterTypePreActivityMetadata.write(value, buf) + _UniffiConverterTypePaymentType.write(value, buf) @classmethod def read(cls, buf): @@ -18659,17 +20688,17 @@ def read(cls, buf): if flag == 0: return None elif flag == 1: - return _UniffiConverterTypePreActivityMetadata.read(buf) + return _UniffiConverterTypePaymentType.read(buf) else: raise InternalError("Unexpected flag byte for optional type") -class _UniffiConverterOptionalTypeTransactionDetails(_UniffiConverterRustBuffer): +class _UniffiConverterOptionalTypeSortDirection(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): if value is not None: - _UniffiConverterTypeTransactionDetails.check_lower(value) + _UniffiConverterTypeSortDirection.check_lower(value) @classmethod def write(cls, value, buf): @@ -18678,7 +20707,7 @@ def write(cls, value, buf): return buf.write_u8(1) - _UniffiConverterTypeTransactionDetails.write(value, buf) + _UniffiConverterTypeSortDirection.write(value, buf) @classmethod def read(cls, buf): @@ -18686,17 +20715,17 @@ def read(cls, buf): if flag == 0: return None elif flag == 1: - return _UniffiConverterTypeTransactionDetails.read(buf) + return _UniffiConverterTypeSortDirection.read(buf) else: raise InternalError("Unexpected flag byte for optional type") -class _UniffiConverterOptionalTypeTrezorCallMessageResult(_UniffiConverterRustBuffer): +class _UniffiConverterOptionalTypeTrezorCoinType(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): if value is not None: - _UniffiConverterTypeTrezorCallMessageResult.check_lower(value) + _UniffiConverterTypeTrezorCoinType.check_lower(value) @classmethod def write(cls, value, buf): @@ -18705,7 +20734,7 @@ def write(cls, value, buf): return buf.write_u8(1) - _UniffiConverterTypeTrezorCallMessageResult.write(value, buf) + _UniffiConverterTypeTrezorCoinType.write(value, buf) @classmethod def read(cls, buf): @@ -18713,17 +20742,17 @@ def read(cls, buf): if flag == 0: return None elif flag == 1: - return _UniffiConverterTypeTrezorCallMessageResult.read(buf) + return _UniffiConverterTypeTrezorCoinType.read(buf) else: raise InternalError("Unexpected flag byte for optional type") -class _UniffiConverterOptionalTypeTrezorDeviceInfo(_UniffiConverterRustBuffer): +class _UniffiConverterOptionalTypeTrezorScriptType(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): if value is not None: - _UniffiConverterTypeTrezorDeviceInfo.check_lower(value) + _UniffiConverterTypeTrezorScriptType.check_lower(value) @classmethod def write(cls, value, buf): @@ -18732,7 +20761,7 @@ def write(cls, value, buf): return buf.write_u8(1) - _UniffiConverterTypeTrezorDeviceInfo.write(value, buf) + _UniffiConverterTypeTrezorScriptType.write(value, buf) @classmethod def read(cls, buf): @@ -18740,17 +20769,17 @@ def read(cls, buf): if flag == 0: return None elif flag == 1: - return _UniffiConverterTypeTrezorDeviceInfo.read(buf) + return _UniffiConverterTypeTrezorScriptType.read(buf) else: raise InternalError("Unexpected flag byte for optional type") -class _UniffiConverterOptionalTypeTrezorFeatures(_UniffiConverterRustBuffer): +class _UniffiConverterOptionalTypeTrezorTransportErrorCode(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): if value is not None: - _UniffiConverterTypeTrezorFeatures.check_lower(value) + _UniffiConverterTypeTrezorTransportErrorCode.check_lower(value) @classmethod def write(cls, value, buf): @@ -18759,7 +20788,7 @@ def write(cls, value, buf): return buf.write_u8(1) - _UniffiConverterTypeTrezorFeatures.write(value, buf) + _UniffiConverterTypeTrezorTransportErrorCode.write(value, buf) @classmethod def read(cls, buf): @@ -18767,17 +20796,17 @@ def read(cls, buf): if flag == 0: return None elif flag == 1: - return _UniffiConverterTypeTrezorFeatures.read(buf) + return _UniffiConverterTypeTrezorTransportErrorCode.read(buf) else: raise InternalError("Unexpected flag byte for optional type") -class _UniffiConverterOptionalTypeAccountType(_UniffiConverterRustBuffer): +class _UniffiConverterOptionalTypeUrPayload(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): if value is not None: - _UniffiConverterTypeAccountType.check_lower(value) + _UniffiConverterTypeUrPayload.check_lower(value) @classmethod def write(cls, value, buf): @@ -18786,7 +20815,7 @@ def write(cls, value, buf): return buf.write_u8(1) - _UniffiConverterTypeAccountType.write(value, buf) + _UniffiConverterTypeUrPayload.write(value, buf) @classmethod def read(cls, buf): @@ -18794,17 +20823,17 @@ def read(cls, buf): if flag == 0: return None elif flag == 1: - return _UniffiConverterTypeAccountType.read(buf) + return _UniffiConverterTypeUrPayload.read(buf) else: raise InternalError("Unexpected flag byte for optional type") -class _UniffiConverterOptionalTypeActivity(_UniffiConverterRustBuffer): +class _UniffiConverterOptionalTypeWordCount(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): if value is not None: - _UniffiConverterTypeActivity.check_lower(value) + _UniffiConverterTypeWordCount.check_lower(value) @classmethod def write(cls, value, buf): @@ -18813,7 +20842,7 @@ def write(cls, value, buf): return buf.write_u8(1) - _UniffiConverterTypeActivity.write(value, buf) + _UniffiConverterTypeWordCount.write(value, buf) @classmethod def read(cls, buf): @@ -18821,17 +20850,17 @@ def read(cls, buf): if flag == 0: return None elif flag == 1: - return _UniffiConverterTypeActivity.read(buf) + return _UniffiConverterTypeWordCount.read(buf) else: raise InternalError("Unexpected flag byte for optional type") -class _UniffiConverterOptionalTypeActivityFilter(_UniffiConverterRustBuffer): +class _UniffiConverterOptionalSequenceString(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): if value is not None: - _UniffiConverterTypeActivityFilter.check_lower(value) + _UniffiConverterSequenceString.check_lower(value) @classmethod def write(cls, value, buf): @@ -18840,7 +20869,7 @@ def write(cls, value, buf): return buf.write_u8(1) - _UniffiConverterTypeActivityFilter.write(value, buf) + _UniffiConverterSequenceString.write(value, buf) @classmethod def read(cls, buf): @@ -18848,17 +20877,17 @@ def read(cls, buf): if flag == 0: return None elif flag == 1: - return _UniffiConverterTypeActivityFilter.read(buf) + return _UniffiConverterSequenceString.read(buf) else: raise InternalError("Unexpected flag byte for optional type") -class _UniffiConverterOptionalTypeBtOrderState2(_UniffiConverterRustBuffer): +class _UniffiConverterOptionalSequenceTypeIManualRefund(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): if value is not None: - _UniffiConverterTypeBtOrderState2.check_lower(value) + _UniffiConverterSequenceTypeIManualRefund.check_lower(value) @classmethod def write(cls, value, buf): @@ -18867,7 +20896,7 @@ def write(cls, value, buf): return buf.write_u8(1) - _UniffiConverterTypeBtOrderState2.write(value, buf) + _UniffiConverterSequenceTypeIManualRefund.write(value, buf) @classmethod def read(cls, buf): @@ -18875,17 +20904,17 @@ def read(cls, buf): if flag == 0: return None elif flag == 1: - return _UniffiConverterTypeBtOrderState2.read(buf) + return _UniffiConverterSequenceTypeIManualRefund.read(buf) else: raise InternalError("Unexpected flag byte for optional type") -class _UniffiConverterOptionalTypeBtPaymentState2(_UniffiConverterRustBuffer): +class _UniffiConverterOptionalSequenceTypePubkyProfileLink(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): if value is not None: - _UniffiConverterTypeBtPaymentState2.check_lower(value) + _UniffiConverterSequenceTypePubkyProfileLink.check_lower(value) @classmethod def write(cls, value, buf): @@ -18894,7 +20923,7 @@ def write(cls, value, buf): return buf.write_u8(1) - _UniffiConverterTypeBtPaymentState2.write(value, buf) + _UniffiConverterSequenceTypePubkyProfileLink.write(value, buf) @classmethod def read(cls, buf): @@ -18902,17 +20931,17 @@ def read(cls, buf): if flag == 0: return None elif flag == 1: - return _UniffiConverterTypeBtPaymentState2.read(buf) + return _UniffiConverterSequenceTypePubkyProfileLink.read(buf) else: raise InternalError("Unexpected flag byte for optional type") -class _UniffiConverterOptionalTypeCJitStateEnum(_UniffiConverterRustBuffer): +class _UniffiConverterOptionalMapStringString(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): if value is not None: - _UniffiConverterTypeCJitStateEnum.check_lower(value) + _UniffiConverterMapStringString.check_lower(value) @classmethod def write(cls, value, buf): @@ -18921,7 +20950,7 @@ def write(cls, value, buf): return buf.write_u8(1) - _UniffiConverterTypeCJitStateEnum.write(value, buf) + _UniffiConverterMapStringString.write(value, buf) @classmethod def read(cls, buf): @@ -18929,375 +20958,474 @@ def read(cls, buf): if flag == 0: return None elif flag == 1: - return _UniffiConverterTypeCJitStateEnum.read(buf) + return _UniffiConverterMapStringString.read(buf) else: raise InternalError("Unexpected flag byte for optional type") -class _UniffiConverterOptionalTypeCoinSelection(_UniffiConverterRustBuffer): +class _UniffiConverterSequenceFloat(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): - if value is not None: - _UniffiConverterTypeCoinSelection.check_lower(value) + for item in value: + _UniffiConverterFloat.check_lower(item) @classmethod def write(cls, value, buf): - if value is None: - buf.write_u8(0) - return + items = len(value) + buf.write_i32(items) + for item in value: + _UniffiConverterFloat.write(item, buf) - buf.write_u8(1) - _UniffiConverterTypeCoinSelection.write(value, buf) + @classmethod + def read(cls, buf): + count = buf.read_i32() + if count < 0: + raise InternalError("Unexpected negative sequence length") + + return [ + _UniffiConverterFloat.read(buf) for i in range(count) + ] + + + +class _UniffiConverterSequenceString(_UniffiConverterRustBuffer): + @classmethod + def check_lower(cls, value): + for item in value: + _UniffiConverterString.check_lower(item) + + @classmethod + def write(cls, value, buf): + items = len(value) + buf.write_i32(items) + for item in value: + _UniffiConverterString.write(item, buf) @classmethod def read(cls, buf): - flag = buf.read_u8() - if flag == 0: - return None - elif flag == 1: - return _UniffiConverterTypeCoinSelection.read(buf) - else: - raise InternalError("Unexpected flag byte for optional type") + count = buf.read_i32() + if count < 0: + raise InternalError("Unexpected negative sequence length") + + return [ + _UniffiConverterString.read(buf) for i in range(count) + ] -class _UniffiConverterOptionalTypeNetwork(_UniffiConverterRustBuffer): +class _UniffiConverterSequenceTypeAccountUtxo(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): - if value is not None: - _UniffiConverterTypeNetwork.check_lower(value) + for item in value: + _UniffiConverterTypeAccountUtxo.check_lower(item) @classmethod def write(cls, value, buf): - if value is None: - buf.write_u8(0) - return + items = len(value) + buf.write_i32(items) + for item in value: + _UniffiConverterTypeAccountUtxo.write(item, buf) - buf.write_u8(1) - _UniffiConverterTypeNetwork.write(value, buf) + @classmethod + def read(cls, buf): + count = buf.read_i32() + if count < 0: + raise InternalError("Unexpected negative sequence length") + + return [ + _UniffiConverterTypeAccountUtxo.read(buf) for i in range(count) + ] + + + +class _UniffiConverterSequenceTypeActivityTags(_UniffiConverterRustBuffer): + @classmethod + def check_lower(cls, value): + for item in value: + _UniffiConverterTypeActivityTags.check_lower(item) + + @classmethod + def write(cls, value, buf): + items = len(value) + buf.write_i32(items) + for item in value: + _UniffiConverterTypeActivityTags.write(item, buf) @classmethod def read(cls, buf): - flag = buf.read_u8() - if flag == 0: - return None - elif flag == 1: - return _UniffiConverterTypeNetwork.read(buf) - else: - raise InternalError("Unexpected flag byte for optional type") + count = buf.read_i32() + if count < 0: + raise InternalError("Unexpected negative sequence length") + + return [ + _UniffiConverterTypeActivityTags.read(buf) for i in range(count) + ] -class _UniffiConverterOptionalTypePaymentType(_UniffiConverterRustBuffer): +class _UniffiConverterSequenceTypeAddressInfo(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): - if value is not None: - _UniffiConverterTypePaymentType.check_lower(value) + for item in value: + _UniffiConverterTypeAddressInfo.check_lower(item) @classmethod def write(cls, value, buf): - if value is None: - buf.write_u8(0) - return + items = len(value) + buf.write_i32(items) + for item in value: + _UniffiConverterTypeAddressInfo.write(item, buf) + + @classmethod + def read(cls, buf): + count = buf.read_i32() + if count < 0: + raise InternalError("Unexpected negative sequence length") + + return [ + _UniffiConverterTypeAddressInfo.read(buf) for i in range(count) + ] - buf.write_u8(1) - _UniffiConverterTypePaymentType.write(value, buf) + + +class _UniffiConverterSequenceTypeBoltzSwap(_UniffiConverterRustBuffer): + @classmethod + def check_lower(cls, value): + for item in value: + _UniffiConverterTypeBoltzSwap.check_lower(item) + + @classmethod + def write(cls, value, buf): + items = len(value) + buf.write_i32(items) + for item in value: + _UniffiConverterTypeBoltzSwap.write(item, buf) @classmethod def read(cls, buf): - flag = buf.read_u8() - if flag == 0: - return None - elif flag == 1: - return _UniffiConverterTypePaymentType.read(buf) - else: - raise InternalError("Unexpected flag byte for optional type") + count = buf.read_i32() + if count < 0: + raise InternalError("Unexpected negative sequence length") + return [ + _UniffiConverterTypeBoltzSwap.read(buf) for i in range(count) + ] -class _UniffiConverterOptionalTypeSortDirection(_UniffiConverterRustBuffer): + +class _UniffiConverterSequenceTypeClosedChannelDetails(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): - if value is not None: - _UniffiConverterTypeSortDirection.check_lower(value) + for item in value: + _UniffiConverterTypeClosedChannelDetails.check_lower(item) @classmethod def write(cls, value, buf): - if value is None: - buf.write_u8(0) - return + items = len(value) + buf.write_i32(items) + for item in value: + _UniffiConverterTypeClosedChannelDetails.write(item, buf) - buf.write_u8(1) - _UniffiConverterTypeSortDirection.write(value, buf) + @classmethod + def read(cls, buf): + count = buf.read_i32() + if count < 0: + raise InternalError("Unexpected negative sequence length") + + return [ + _UniffiConverterTypeClosedChannelDetails.read(buf) for i in range(count) + ] + + + +class _UniffiConverterSequenceTypeGetAddressResponse(_UniffiConverterRustBuffer): + @classmethod + def check_lower(cls, value): + for item in value: + _UniffiConverterTypeGetAddressResponse.check_lower(item) + + @classmethod + def write(cls, value, buf): + items = len(value) + buf.write_i32(items) + for item in value: + _UniffiConverterTypeGetAddressResponse.write(item, buf) @classmethod def read(cls, buf): - flag = buf.read_u8() - if flag == 0: - return None - elif flag == 1: - return _UniffiConverterTypeSortDirection.read(buf) - else: - raise InternalError("Unexpected flag byte for optional type") + count = buf.read_i32() + if count < 0: + raise InternalError("Unexpected negative sequence length") + + return [ + _UniffiConverterTypeGetAddressResponse.read(buf) for i in range(count) + ] -class _UniffiConverterOptionalTypeTrezorCoinType(_UniffiConverterRustBuffer): +class _UniffiConverterSequenceTypeHistoryTransaction(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): - if value is not None: - _UniffiConverterTypeTrezorCoinType.check_lower(value) + for item in value: + _UniffiConverterTypeHistoryTransaction.check_lower(item) @classmethod def write(cls, value, buf): - if value is None: - buf.write_u8(0) - return + items = len(value) + buf.write_i32(items) + for item in value: + _UniffiConverterTypeHistoryTransaction.write(item, buf) + + @classmethod + def read(cls, buf): + count = buf.read_i32() + if count < 0: + raise InternalError("Unexpected negative sequence length") + + return [ + _UniffiConverterTypeHistoryTransaction.read(buf) for i in range(count) + ] + + + +class _UniffiConverterSequenceTypeIBtOnchainTransaction(_UniffiConverterRustBuffer): + @classmethod + def check_lower(cls, value): + for item in value: + _UniffiConverterTypeIBtOnchainTransaction.check_lower(item) - buf.write_u8(1) - _UniffiConverterTypeTrezorCoinType.write(value, buf) + @classmethod + def write(cls, value, buf): + items = len(value) + buf.write_i32(items) + for item in value: + _UniffiConverterTypeIBtOnchainTransaction.write(item, buf) @classmethod def read(cls, buf): - flag = buf.read_u8() - if flag == 0: - return None - elif flag == 1: - return _UniffiConverterTypeTrezorCoinType.read(buf) - else: - raise InternalError("Unexpected flag byte for optional type") + count = buf.read_i32() + if count < 0: + raise InternalError("Unexpected negative sequence length") + + return [ + _UniffiConverterTypeIBtOnchainTransaction.read(buf) for i in range(count) + ] -class _UniffiConverterOptionalTypeTrezorScriptType(_UniffiConverterRustBuffer): +class _UniffiConverterSequenceTypeIBtOrder(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): - if value is not None: - _UniffiConverterTypeTrezorScriptType.check_lower(value) + for item in value: + _UniffiConverterTypeIBtOrder.check_lower(item) @classmethod def write(cls, value, buf): - if value is None: - buf.write_u8(0) - return - - buf.write_u8(1) - _UniffiConverterTypeTrezorScriptType.write(value, buf) + items = len(value) + buf.write_i32(items) + for item in value: + _UniffiConverterTypeIBtOrder.write(item, buf) @classmethod def read(cls, buf): - flag = buf.read_u8() - if flag == 0: - return None - elif flag == 1: - return _UniffiConverterTypeTrezorScriptType.read(buf) - else: - raise InternalError("Unexpected flag byte for optional type") + count = buf.read_i32() + if count < 0: + raise InternalError("Unexpected negative sequence length") + return [ + _UniffiConverterTypeIBtOrder.read(buf) for i in range(count) + ] -class _UniffiConverterOptionalTypeTrezorTransportErrorCode(_UniffiConverterRustBuffer): + +class _UniffiConverterSequenceTypeILspNode(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): - if value is not None: - _UniffiConverterTypeTrezorTransportErrorCode.check_lower(value) + for item in value: + _UniffiConverterTypeILspNode.check_lower(item) @classmethod def write(cls, value, buf): - if value is None: - buf.write_u8(0) - return - - buf.write_u8(1) - _UniffiConverterTypeTrezorTransportErrorCode.write(value, buf) + items = len(value) + buf.write_i32(items) + for item in value: + _UniffiConverterTypeILspNode.write(item, buf) @classmethod def read(cls, buf): - flag = buf.read_u8() - if flag == 0: - return None - elif flag == 1: - return _UniffiConverterTypeTrezorTransportErrorCode.read(buf) - else: - raise InternalError("Unexpected flag byte for optional type") + count = buf.read_i32() + if count < 0: + raise InternalError("Unexpected negative sequence length") + + return [ + _UniffiConverterTypeILspNode.read(buf) for i in range(count) + ] -class _UniffiConverterOptionalTypeUrPayload(_UniffiConverterRustBuffer): +class _UniffiConverterSequenceTypeIManualRefund(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): - if value is not None: - _UniffiConverterTypeUrPayload.check_lower(value) + for item in value: + _UniffiConverterTypeIManualRefund.check_lower(item) @classmethod def write(cls, value, buf): - if value is None: - buf.write_u8(0) - return - - buf.write_u8(1) - _UniffiConverterTypeUrPayload.write(value, buf) + items = len(value) + buf.write_i32(items) + for item in value: + _UniffiConverterTypeIManualRefund.write(item, buf) @classmethod def read(cls, buf): - flag = buf.read_u8() - if flag == 0: - return None - elif flag == 1: - return _UniffiConverterTypeUrPayload.read(buf) - else: - raise InternalError("Unexpected flag byte for optional type") + count = buf.read_i32() + if count < 0: + raise InternalError("Unexpected negative sequence length") + return [ + _UniffiConverterTypeIManualRefund.read(buf) for i in range(count) + ] -class _UniffiConverterOptionalTypeWordCount(_UniffiConverterRustBuffer): + +class _UniffiConverterSequenceTypeIcJitEntry(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): - if value is not None: - _UniffiConverterTypeWordCount.check_lower(value) + for item in value: + _UniffiConverterTypeIcJitEntry.check_lower(item) @classmethod def write(cls, value, buf): - if value is None: - buf.write_u8(0) - return - - buf.write_u8(1) - _UniffiConverterTypeWordCount.write(value, buf) + items = len(value) + buf.write_i32(items) + for item in value: + _UniffiConverterTypeIcJitEntry.write(item, buf) @classmethod def read(cls, buf): - flag = buf.read_u8() - if flag == 0: - return None - elif flag == 1: - return _UniffiConverterTypeWordCount.read(buf) - else: - raise InternalError("Unexpected flag byte for optional type") + count = buf.read_i32() + if count < 0: + raise InternalError("Unexpected negative sequence length") + + return [ + _UniffiConverterTypeIcJitEntry.read(buf) for i in range(count) + ] -class _UniffiConverterOptionalSequenceString(_UniffiConverterRustBuffer): +class _UniffiConverterSequenceTypeJadeAccount(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): - if value is not None: - _UniffiConverterSequenceString.check_lower(value) + for item in value: + _UniffiConverterTypeJadeAccount.check_lower(item) @classmethod def write(cls, value, buf): - if value is None: - buf.write_u8(0) - return - - buf.write_u8(1) - _UniffiConverterSequenceString.write(value, buf) + items = len(value) + buf.write_i32(items) + for item in value: + _UniffiConverterTypeJadeAccount.write(item, buf) @classmethod def read(cls, buf): - flag = buf.read_u8() - if flag == 0: - return None - elif flag == 1: - return _UniffiConverterSequenceString.read(buf) - else: - raise InternalError("Unexpected flag byte for optional type") + count = buf.read_i32() + if count < 0: + raise InternalError("Unexpected negative sequence length") + return [ + _UniffiConverterTypeJadeAccount.read(buf) for i in range(count) + ] -class _UniffiConverterOptionalSequenceTypeIManualRefund(_UniffiConverterRustBuffer): + +class _UniffiConverterSequenceTypeJadeDeviceInfo(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): - if value is not None: - _UniffiConverterSequenceTypeIManualRefund.check_lower(value) + for item in value: + _UniffiConverterTypeJadeDeviceInfo.check_lower(item) @classmethod def write(cls, value, buf): - if value is None: - buf.write_u8(0) - return - - buf.write_u8(1) - _UniffiConverterSequenceTypeIManualRefund.write(value, buf) + items = len(value) + buf.write_i32(items) + for item in value: + _UniffiConverterTypeJadeDeviceInfo.write(item, buf) @classmethod def read(cls, buf): - flag = buf.read_u8() - if flag == 0: - return None - elif flag == 1: - return _UniffiConverterSequenceTypeIManualRefund.read(buf) - else: - raise InternalError("Unexpected flag byte for optional type") + count = buf.read_i32() + if count < 0: + raise InternalError("Unexpected negative sequence length") + + return [ + _UniffiConverterTypeJadeDeviceInfo.read(buf) for i in range(count) + ] -class _UniffiConverterOptionalSequenceTypePubkyProfileLink(_UniffiConverterRustBuffer): +class _UniffiConverterSequenceTypeJadeNativeDevice(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): - if value is not None: - _UniffiConverterSequenceTypePubkyProfileLink.check_lower(value) + for item in value: + _UniffiConverterTypeJadeNativeDevice.check_lower(item) @classmethod def write(cls, value, buf): - if value is None: - buf.write_u8(0) - return - - buf.write_u8(1) - _UniffiConverterSequenceTypePubkyProfileLink.write(value, buf) + items = len(value) + buf.write_i32(items) + for item in value: + _UniffiConverterTypeJadeNativeDevice.write(item, buf) @classmethod def read(cls, buf): - flag = buf.read_u8() - if flag == 0: - return None - elif flag == 1: - return _UniffiConverterSequenceTypePubkyProfileLink.read(buf) - else: - raise InternalError("Unexpected flag byte for optional type") + count = buf.read_i32() + if count < 0: + raise InternalError("Unexpected negative sequence length") + return [ + _UniffiConverterTypeJadeNativeDevice.read(buf) for i in range(count) + ] -class _UniffiConverterOptionalMapStringString(_UniffiConverterRustBuffer): + +class _UniffiConverterSequenceTypeLightningActivity(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): - if value is not None: - _UniffiConverterMapStringString.check_lower(value) + for item in value: + _UniffiConverterTypeLightningActivity.check_lower(item) @classmethod def write(cls, value, buf): - if value is None: - buf.write_u8(0) - return - - buf.write_u8(1) - _UniffiConverterMapStringString.write(value, buf) + items = len(value) + buf.write_i32(items) + for item in value: + _UniffiConverterTypeLightningActivity.write(item, buf) @classmethod def read(cls, buf): - flag = buf.read_u8() - if flag == 0: - return None - elif flag == 1: - return _UniffiConverterMapStringString.read(buf) - else: - raise InternalError("Unexpected flag byte for optional type") + count = buf.read_i32() + if count < 0: + raise InternalError("Unexpected negative sequence length") + + return [ + _UniffiConverterTypeLightningActivity.read(buf) for i in range(count) + ] -class _UniffiConverterSequenceFloat(_UniffiConverterRustBuffer): +class _UniffiConverterSequenceTypeNativeDeviceInfo(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): for item in value: - _UniffiConverterFloat.check_lower(item) + _UniffiConverterTypeNativeDeviceInfo.check_lower(item) @classmethod def write(cls, value, buf): items = len(value) buf.write_i32(items) for item in value: - _UniffiConverterFloat.write(item, buf) + _UniffiConverterTypeNativeDeviceInfo.write(item, buf) @classmethod def read(cls, buf): @@ -19306,23 +21434,23 @@ def read(cls, buf): raise InternalError("Unexpected negative sequence length") return [ - _UniffiConverterFloat.read(buf) for i in range(count) + _UniffiConverterTypeNativeDeviceInfo.read(buf) for i in range(count) ] -class _UniffiConverterSequenceString(_UniffiConverterRustBuffer): +class _UniffiConverterSequenceTypeOnchainActivity(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): for item in value: - _UniffiConverterString.check_lower(item) + _UniffiConverterTypeOnchainActivity.check_lower(item) @classmethod def write(cls, value, buf): items = len(value) buf.write_i32(items) for item in value: - _UniffiConverterString.write(item, buf) + _UniffiConverterTypeOnchainActivity.write(item, buf) @classmethod def read(cls, buf): @@ -19331,23 +21459,23 @@ def read(cls, buf): raise InternalError("Unexpected negative sequence length") return [ - _UniffiConverterString.read(buf) for i in range(count) + _UniffiConverterTypeOnchainActivity.read(buf) for i in range(count) ] -class _UniffiConverterSequenceTypeAccountUtxo(_UniffiConverterRustBuffer): +class _UniffiConverterSequenceTypePassportAccount(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): for item in value: - _UniffiConverterTypeAccountUtxo.check_lower(item) + _UniffiConverterTypePassportAccount.check_lower(item) @classmethod def write(cls, value, buf): items = len(value) buf.write_i32(items) for item in value: - _UniffiConverterTypeAccountUtxo.write(item, buf) + _UniffiConverterTypePassportAccount.write(item, buf) @classmethod def read(cls, buf): @@ -19356,23 +21484,23 @@ def read(cls, buf): raise InternalError("Unexpected negative sequence length") return [ - _UniffiConverterTypeAccountUtxo.read(buf) for i in range(count) + _UniffiConverterTypePassportAccount.read(buf) for i in range(count) ] -class _UniffiConverterSequenceTypeActivityTags(_UniffiConverterRustBuffer): +class _UniffiConverterSequenceTypePreActivityMetadata(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): for item in value: - _UniffiConverterTypeActivityTags.check_lower(item) + _UniffiConverterTypePreActivityMetadata.check_lower(item) @classmethod def write(cls, value, buf): items = len(value) buf.write_i32(items) for item in value: - _UniffiConverterTypeActivityTags.write(item, buf) + _UniffiConverterTypePreActivityMetadata.write(item, buf) @classmethod def read(cls, buf): @@ -19381,23 +21509,23 @@ def read(cls, buf): raise InternalError("Unexpected negative sequence length") return [ - _UniffiConverterTypeActivityTags.read(buf) for i in range(count) + _UniffiConverterTypePreActivityMetadata.read(buf) for i in range(count) ] -class _UniffiConverterSequenceTypeAddressInfo(_UniffiConverterRustBuffer): +class _UniffiConverterSequenceTypePubkyProfileLink(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): for item in value: - _UniffiConverterTypeAddressInfo.check_lower(item) + _UniffiConverterTypePubkyProfileLink.check_lower(item) @classmethod def write(cls, value, buf): items = len(value) buf.write_i32(items) for item in value: - _UniffiConverterTypeAddressInfo.write(item, buf) + _UniffiConverterTypePubkyProfileLink.write(item, buf) @classmethod def read(cls, buf): @@ -19406,23 +21534,23 @@ def read(cls, buf): raise InternalError("Unexpected negative sequence length") return [ - _UniffiConverterTypeAddressInfo.read(buf) for i in range(count) + _UniffiConverterTypePubkyProfileLink.read(buf) for i in range(count) ] -class _UniffiConverterSequenceTypeBoltzSwap(_UniffiConverterRustBuffer): +class _UniffiConverterSequenceTypeSupportedHardwareWallet(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): for item in value: - _UniffiConverterTypeBoltzSwap.check_lower(item) + _UniffiConverterTypeSupportedHardwareWallet.check_lower(item) @classmethod def write(cls, value, buf): items = len(value) buf.write_i32(items) for item in value: - _UniffiConverterTypeBoltzSwap.write(item, buf) + _UniffiConverterTypeSupportedHardwareWallet.write(item, buf) @classmethod def read(cls, buf): @@ -19431,23 +21559,23 @@ def read(cls, buf): raise InternalError("Unexpected negative sequence length") return [ - _UniffiConverterTypeBoltzSwap.read(buf) for i in range(count) + _UniffiConverterTypeSupportedHardwareWallet.read(buf) for i in range(count) ] -class _UniffiConverterSequenceTypeClosedChannelDetails(_UniffiConverterRustBuffer): +class _UniffiConverterSequenceTypeTransactionDetails(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): for item in value: - _UniffiConverterTypeClosedChannelDetails.check_lower(item) + _UniffiConverterTypeTransactionDetails.check_lower(item) @classmethod def write(cls, value, buf): items = len(value) buf.write_i32(items) for item in value: - _UniffiConverterTypeClosedChannelDetails.write(item, buf) + _UniffiConverterTypeTransactionDetails.write(item, buf) @classmethod def read(cls, buf): @@ -19456,23 +21584,23 @@ def read(cls, buf): raise InternalError("Unexpected negative sequence length") return [ - _UniffiConverterTypeClosedChannelDetails.read(buf) for i in range(count) + _UniffiConverterTypeTransactionDetails.read(buf) for i in range(count) ] -class _UniffiConverterSequenceTypeGetAddressResponse(_UniffiConverterRustBuffer): +class _UniffiConverterSequenceTypeTrezorDeviceInfo(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): for item in value: - _UniffiConverterTypeGetAddressResponse.check_lower(item) + _UniffiConverterTypeTrezorDeviceInfo.check_lower(item) @classmethod def write(cls, value, buf): items = len(value) buf.write_i32(items) for item in value: - _UniffiConverterTypeGetAddressResponse.write(item, buf) + _UniffiConverterTypeTrezorDeviceInfo.write(item, buf) @classmethod def read(cls, buf): @@ -19481,23 +21609,23 @@ def read(cls, buf): raise InternalError("Unexpected negative sequence length") return [ - _UniffiConverterTypeGetAddressResponse.read(buf) for i in range(count) + _UniffiConverterTypeTrezorDeviceInfo.read(buf) for i in range(count) ] -class _UniffiConverterSequenceTypeHistoryTransaction(_UniffiConverterRustBuffer): +class _UniffiConverterSequenceTypeTrezorPrevTx(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): for item in value: - _UniffiConverterTypeHistoryTransaction.check_lower(item) + _UniffiConverterTypeTrezorPrevTx.check_lower(item) @classmethod def write(cls, value, buf): items = len(value) buf.write_i32(items) for item in value: - _UniffiConverterTypeHistoryTransaction.write(item, buf) + _UniffiConverterTypeTrezorPrevTx.write(item, buf) @classmethod def read(cls, buf): @@ -19506,23 +21634,23 @@ def read(cls, buf): raise InternalError("Unexpected negative sequence length") return [ - _UniffiConverterTypeHistoryTransaction.read(buf) for i in range(count) + _UniffiConverterTypeTrezorPrevTx.read(buf) for i in range(count) ] -class _UniffiConverterSequenceTypeIBtOnchainTransaction(_UniffiConverterRustBuffer): +class _UniffiConverterSequenceTypeTrezorPrevTxInput(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): for item in value: - _UniffiConverterTypeIBtOnchainTransaction.check_lower(item) + _UniffiConverterTypeTrezorPrevTxInput.check_lower(item) @classmethod def write(cls, value, buf): items = len(value) buf.write_i32(items) for item in value: - _UniffiConverterTypeIBtOnchainTransaction.write(item, buf) + _UniffiConverterTypeTrezorPrevTxInput.write(item, buf) @classmethod def read(cls, buf): @@ -19531,23 +21659,23 @@ def read(cls, buf): raise InternalError("Unexpected negative sequence length") return [ - _UniffiConverterTypeIBtOnchainTransaction.read(buf) for i in range(count) + _UniffiConverterTypeTrezorPrevTxInput.read(buf) for i in range(count) ] -class _UniffiConverterSequenceTypeIBtOrder(_UniffiConverterRustBuffer): +class _UniffiConverterSequenceTypeTrezorPrevTxOutput(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): for item in value: - _UniffiConverterTypeIBtOrder.check_lower(item) + _UniffiConverterTypeTrezorPrevTxOutput.check_lower(item) @classmethod def write(cls, value, buf): items = len(value) buf.write_i32(items) for item in value: - _UniffiConverterTypeIBtOrder.write(item, buf) + _UniffiConverterTypeTrezorPrevTxOutput.write(item, buf) @classmethod def read(cls, buf): @@ -19556,23 +21684,23 @@ def read(cls, buf): raise InternalError("Unexpected negative sequence length") return [ - _UniffiConverterTypeIBtOrder.read(buf) for i in range(count) + _UniffiConverterTypeTrezorPrevTxOutput.read(buf) for i in range(count) ] -class _UniffiConverterSequenceTypeILspNode(_UniffiConverterRustBuffer): +class _UniffiConverterSequenceTypeTrezorTxInput(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): for item in value: - _UniffiConverterTypeILspNode.check_lower(item) + _UniffiConverterTypeTrezorTxInput.check_lower(item) @classmethod def write(cls, value, buf): items = len(value) buf.write_i32(items) for item in value: - _UniffiConverterTypeILspNode.write(item, buf) + _UniffiConverterTypeTrezorTxInput.write(item, buf) @classmethod def read(cls, buf): @@ -19581,23 +21709,23 @@ def read(cls, buf): raise InternalError("Unexpected negative sequence length") return [ - _UniffiConverterTypeILspNode.read(buf) for i in range(count) + _UniffiConverterTypeTrezorTxInput.read(buf) for i in range(count) ] -class _UniffiConverterSequenceTypeIManualRefund(_UniffiConverterRustBuffer): +class _UniffiConverterSequenceTypeTrezorTxOutput(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): for item in value: - _UniffiConverterTypeIManualRefund.check_lower(item) + _UniffiConverterTypeTrezorTxOutput.check_lower(item) @classmethod def write(cls, value, buf): items = len(value) buf.write_i32(items) for item in value: - _UniffiConverterTypeIManualRefund.write(item, buf) + _UniffiConverterTypeTrezorTxOutput.write(item, buf) @classmethod def read(cls, buf): @@ -19606,23 +21734,23 @@ def read(cls, buf): raise InternalError("Unexpected negative sequence length") return [ - _UniffiConverterTypeIManualRefund.read(buf) for i in range(count) + _UniffiConverterTypeTrezorTxOutput.read(buf) for i in range(count) ] -class _UniffiConverterSequenceTypeIcJitEntry(_UniffiConverterRustBuffer): +class _UniffiConverterSequenceTypeTxDetailInput(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): for item in value: - _UniffiConverterTypeIcJitEntry.check_lower(item) + _UniffiConverterTypeTxDetailInput.check_lower(item) @classmethod def write(cls, value, buf): items = len(value) buf.write_i32(items) for item in value: - _UniffiConverterTypeIcJitEntry.write(item, buf) + _UniffiConverterTypeTxDetailInput.write(item, buf) @classmethod def read(cls, buf): @@ -19631,23 +21759,23 @@ def read(cls, buf): raise InternalError("Unexpected negative sequence length") return [ - _UniffiConverterTypeIcJitEntry.read(buf) for i in range(count) + _UniffiConverterTypeTxDetailInput.read(buf) for i in range(count) ] -class _UniffiConverterSequenceTypeLightningActivity(_UniffiConverterRustBuffer): +class _UniffiConverterSequenceTypeTxDetailOutput(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): for item in value: - _UniffiConverterTypeLightningActivity.check_lower(item) + _UniffiConverterTypeTxDetailOutput.check_lower(item) @classmethod def write(cls, value, buf): items = len(value) buf.write_i32(items) for item in value: - _UniffiConverterTypeLightningActivity.write(item, buf) + _UniffiConverterTypeTxDetailOutput.write(item, buf) @classmethod def read(cls, buf): @@ -19656,23 +21784,23 @@ def read(cls, buf): raise InternalError("Unexpected negative sequence length") return [ - _UniffiConverterTypeLightningActivity.read(buf) for i in range(count) + _UniffiConverterTypeTxDetailOutput.read(buf) for i in range(count) ] -class _UniffiConverterSequenceTypeNativeDeviceInfo(_UniffiConverterRustBuffer): +class _UniffiConverterSequenceTypeTxInput(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): for item in value: - _UniffiConverterTypeNativeDeviceInfo.check_lower(item) + _UniffiConverterTypeTxInput.check_lower(item) @classmethod def write(cls, value, buf): items = len(value) buf.write_i32(items) for item in value: - _UniffiConverterTypeNativeDeviceInfo.write(item, buf) + _UniffiConverterTypeTxInput.write(item, buf) @classmethod def read(cls, buf): @@ -19681,23 +21809,23 @@ def read(cls, buf): raise InternalError("Unexpected negative sequence length") return [ - _UniffiConverterTypeNativeDeviceInfo.read(buf) for i in range(count) + _UniffiConverterTypeTxInput.read(buf) for i in range(count) ] -class _UniffiConverterSequenceTypeOnchainActivity(_UniffiConverterRustBuffer): +class _UniffiConverterSequenceTypeTxOutput(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): for item in value: - _UniffiConverterTypeOnchainActivity.check_lower(item) + _UniffiConverterTypeTxOutput.check_lower(item) @classmethod def write(cls, value, buf): items = len(value) buf.write_i32(items) for item in value: - _UniffiConverterTypeOnchainActivity.write(item, buf) + _UniffiConverterTypeTxOutput.write(item, buf) @classmethod def read(cls, buf): @@ -19706,23 +21834,23 @@ def read(cls, buf): raise InternalError("Unexpected negative sequence length") return [ - _UniffiConverterTypeOnchainActivity.read(buf) for i in range(count) + _UniffiConverterTypeTxOutput.read(buf) for i in range(count) ] -class _UniffiConverterSequenceTypePassportAccount(_UniffiConverterRustBuffer): +class _UniffiConverterSequenceTypeAccountType(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): for item in value: - _UniffiConverterTypePassportAccount.check_lower(item) + _UniffiConverterTypeAccountType.check_lower(item) @classmethod def write(cls, value, buf): items = len(value) buf.write_i32(items) for item in value: - _UniffiConverterTypePassportAccount.write(item, buf) + _UniffiConverterTypeAccountType.write(item, buf) @classmethod def read(cls, buf): @@ -19731,23 +21859,23 @@ def read(cls, buf): raise InternalError("Unexpected negative sequence length") return [ - _UniffiConverterTypePassportAccount.read(buf) for i in range(count) + _UniffiConverterTypeAccountType.read(buf) for i in range(count) ] -class _UniffiConverterSequenceTypePreActivityMetadata(_UniffiConverterRustBuffer): +class _UniffiConverterSequenceTypeActivity(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): for item in value: - _UniffiConverterTypePreActivityMetadata.check_lower(item) + _UniffiConverterTypeActivity.check_lower(item) @classmethod def write(cls, value, buf): items = len(value) buf.write_i32(items) for item in value: - _UniffiConverterTypePreActivityMetadata.write(item, buf) + _UniffiConverterTypeActivity.write(item, buf) @classmethod def read(cls, buf): @@ -19756,23 +21884,23 @@ def read(cls, buf): raise InternalError("Unexpected negative sequence length") return [ - _UniffiConverterTypePreActivityMetadata.read(buf) for i in range(count) + _UniffiConverterTypeActivity.read(buf) for i in range(count) ] -class _UniffiConverterSequenceTypePubkyProfileLink(_UniffiConverterRustBuffer): +class _UniffiConverterSequenceTypeComposeOutput(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): for item in value: - _UniffiConverterTypePubkyProfileLink.check_lower(item) + _UniffiConverterTypeComposeOutput.check_lower(item) @classmethod def write(cls, value, buf): items = len(value) buf.write_i32(items) for item in value: - _UniffiConverterTypePubkyProfileLink.write(item, buf) + _UniffiConverterTypeComposeOutput.write(item, buf) @classmethod def read(cls, buf): @@ -19781,23 +21909,23 @@ def read(cls, buf): raise InternalError("Unexpected negative sequence length") return [ - _UniffiConverterTypePubkyProfileLink.read(buf) for i in range(count) + _UniffiConverterTypeComposeOutput.read(buf) for i in range(count) ] -class _UniffiConverterSequenceTypeSupportedHardwareWallet(_UniffiConverterRustBuffer): +class _UniffiConverterSequenceTypeComposeResult(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): for item in value: - _UniffiConverterTypeSupportedHardwareWallet.check_lower(item) + _UniffiConverterTypeComposeResult.check_lower(item) @classmethod def write(cls, value, buf): items = len(value) buf.write_i32(items) for item in value: - _UniffiConverterTypeSupportedHardwareWallet.write(item, buf) + _UniffiConverterTypeComposeResult.write(item, buf) @classmethod def read(cls, buf): @@ -19806,23 +21934,23 @@ def read(cls, buf): raise InternalError("Unexpected negative sequence length") return [ - _UniffiConverterTypeSupportedHardwareWallet.read(buf) for i in range(count) + _UniffiConverterTypeComposeResult.read(buf) for i in range(count) ] -class _UniffiConverterSequenceTypeTransactionDetails(_UniffiConverterRustBuffer): +class _UniffiConverterSequenceTypeHardwareWalletTransport(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): for item in value: - _UniffiConverterTypeTransactionDetails.check_lower(item) + _UniffiConverterTypeHardwareWalletTransport.check_lower(item) @classmethod def write(cls, value, buf): items = len(value) buf.write_i32(items) for item in value: - _UniffiConverterTypeTransactionDetails.write(item, buf) + _UniffiConverterTypeHardwareWalletTransport.write(item, buf) @classmethod def read(cls, buf): @@ -19831,431 +21959,509 @@ def read(cls, buf): raise InternalError("Unexpected negative sequence length") return [ - _UniffiConverterTypeTransactionDetails.read(buf) for i in range(count) + _UniffiConverterTypeHardwareWalletTransport.read(buf) for i in range(count) ] -class _UniffiConverterSequenceTypeTrezorDeviceInfo(_UniffiConverterRustBuffer): +class _UniffiConverterMapStringString(_UniffiConverterRustBuffer): @classmethod - def check_lower(cls, value): - for item in value: - _UniffiConverterTypeTrezorDeviceInfo.check_lower(item) + def check_lower(cls, items): + for (key, value) in items.items(): + _UniffiConverterString.check_lower(key) + _UniffiConverterString.check_lower(value) @classmethod - def write(cls, value, buf): - items = len(value) - buf.write_i32(items) - for item in value: - _UniffiConverterTypeTrezorDeviceInfo.write(item, buf) + def write(cls, items, buf): + buf.write_i32(len(items)) + for (key, value) in items.items(): + _UniffiConverterString.write(key, buf) + _UniffiConverterString.write(value, buf) @classmethod def read(cls, buf): count = buf.read_i32() if count < 0: - raise InternalError("Unexpected negative sequence length") + raise InternalError("Unexpected negative map size") - return [ - _UniffiConverterTypeTrezorDeviceInfo.read(buf) for i in range(count) - ] + # It would be nice to use a dict comprehension, + # but in Python 3.7 and before the evaluation order is not according to spec, + # so we we're reading the value before the key. + # This loop makes the order explicit: first reading the key, then the value. + d = {} + for i in range(count): + key = _UniffiConverterString.read(buf) + val = _UniffiConverterString.read(buf) + d[key] = val + return d + +# objects. +class BoltzEventListenerProtocol(typing.Protocol): + """ + Callback interface for receiving Boltz swap lifecycle events. + + Implement this in Swift/Kotlin/Python and register it via + `boltz_start_swap_updates` to receive typed notifications as swaps progress. + Reverse swaps are claimed automatically; the [`BoltzSwapEvent::Claimed`] + event reports the resulting transaction id. + """ + def on_event(self, event: "BoltzSwapEvent"): + raise NotImplementedError +# BoltzEventListener is a foreign trait so treated like a callback interface, where the +# primary use-case is the trait being implemented locally. +# It is a base-class local implementations might subclass. -class _UniffiConverterSequenceTypeTrezorPrevTx(_UniffiConverterRustBuffer): - @classmethod - def check_lower(cls, value): - for item in value: - _UniffiConverterTypeTrezorPrevTx.check_lower(item) +class BoltzEventListener(): + """ + Callback interface for receiving Boltz swap lifecycle events. + + Implement this in Swift/Kotlin/Python and register it via + `boltz_start_swap_updates` to receive typed notifications as swaps progress. + Reverse swaps are claimed automatically; the [`BoltzSwapEvent::Claimed`] + event reports the resulting transaction id. + """ + + def on_event(self, event: "BoltzSwapEvent"): + raise NotImplementedError +# `BoltzEventListenerImpl` is the implementation for a Rust implemented version. +class BoltzEventListenerImpl(): + """ + Callback interface for receiving Boltz swap lifecycle events. + + Implement this in Swift/Kotlin/Python and register it via + `boltz_start_swap_updates` to receive typed notifications as swaps progress. + Reverse swaps are claimed automatically; the [`BoltzSwapEvent::Claimed`] + event reports the resulting transaction id. + """ + + _pointer: ctypes.c_void_p + + def __init__(self, *args, **kwargs): + raise ValueError("This class has no default constructor") + + def __del__(self): + # In case of partial initialization of instances. + pointer = getattr(self, "_pointer", None) + if pointer is not None: + _uniffi_rust_call(_UniffiLib.uniffi_bitkitcore_fn_free_boltzeventlistener, pointer) + + def _uniffi_clone_pointer(self): + return _uniffi_rust_call(_UniffiLib.uniffi_bitkitcore_fn_clone_boltzeventlistener, self._pointer) + # Used by alternative constructors or any methods which return this type. @classmethod - def write(cls, value, buf): - items = len(value) - buf.write_i32(items) - for item in value: - _UniffiConverterTypeTrezorPrevTx.write(item, buf) + def _make_instance_(cls, pointer): + # Lightly yucky way to bypass the usual __init__ logic + # and just create a new instance with the required pointer. + inst = cls.__new__(cls) + inst._pointer = pointer + return inst - @classmethod - def read(cls, buf): - count = buf.read_i32() - if count < 0: - raise InternalError("Unexpected negative sequence length") - return [ - _UniffiConverterTypeTrezorPrevTx.read(buf) for i in range(count) - ] + def on_event(self, event: "BoltzSwapEvent") -> None: + _UniffiConverterTypeBoltzSwapEvent.check_lower(event) + + _uniffi_rust_call(_UniffiLib.uniffi_bitkitcore_fn_method_boltzeventlistener_on_event,self._uniffi_clone_pointer(), + _UniffiConverterTypeBoltzSwapEvent.lower(event)) -class _UniffiConverterSequenceTypeTrezorPrevTxInput(_UniffiConverterRustBuffer): - @classmethod - def check_lower(cls, value): - for item in value: - _UniffiConverterTypeTrezorPrevTxInput.check_lower(item) - @classmethod - def write(cls, value, buf): - items = len(value) - buf.write_i32(items) - for item in value: - _UniffiConverterTypeTrezorPrevTxInput.write(item, buf) - @classmethod - def read(cls, buf): - count = buf.read_i32() - if count < 0: - raise InternalError("Unexpected negative sequence length") - return [ - _UniffiConverterTypeTrezorPrevTxInput.read(buf) for i in range(count) - ] +# Put all the bits inside a class to keep the top-level namespace clean +class _UniffiTraitImplBoltzEventListener: + # For each method, generate a callback function to pass to Rust + @_UNIFFI_CALLBACK_INTERFACE_BOLTZ_EVENT_LISTENER_METHOD0 + def on_event( + uniffi_handle, + event, + uniffi_out_return, + uniffi_call_status_ptr, + ): + uniffi_obj = _UniffiConverterTypeBoltzEventListener._handle_map.get(uniffi_handle) + def make_call(): + args = (_UniffiConverterTypeBoltzSwapEvent.lift(event), ) + method = uniffi_obj.on_event + return method(*args) + + write_return_value = lambda v: None + _uniffi_trait_interface_call( + uniffi_call_status_ptr.contents, + make_call, + write_return_value, + ) -class _UniffiConverterSequenceTypeTrezorPrevTxOutput(_UniffiConverterRustBuffer): - @classmethod - def check_lower(cls, value): - for item in value: - _UniffiConverterTypeTrezorPrevTxOutput.check_lower(item) + @_UNIFFI_CALLBACK_INTERFACE_FREE + def _uniffi_free(uniffi_handle): + _UniffiConverterTypeBoltzEventListener._handle_map.remove(uniffi_handle) - @classmethod - def write(cls, value, buf): - items = len(value) - buf.write_i32(items) - for item in value: - _UniffiConverterTypeTrezorPrevTxOutput.write(item, buf) + # Generate the FFI VTable. This has a field for each callback interface method. + _uniffi_vtable = _UniffiVTableCallbackInterfaceBoltzEventListener( + on_event, + _uniffi_free + ) + # Send Rust a pointer to the VTable. Note: this means we need to keep the struct alive forever, + # or else bad things will happen when Rust tries to access it. + _UniffiLib.uniffi_bitkitcore_fn_init_callback_vtable_boltzeventlistener(ctypes.byref(_uniffi_vtable)) - @classmethod - def read(cls, buf): - count = buf.read_i32() - if count < 0: - raise InternalError("Unexpected negative sequence length") - return [ - _UniffiConverterTypeTrezorPrevTxOutput.read(buf) for i in range(count) - ] +class _UniffiConverterTypeBoltzEventListener: + _handle_map = _UniffiHandleMap() + @staticmethod + def lift(value: int): + return BoltzEventListenerImpl._make_instance_(value) -class _UniffiConverterSequenceTypeTrezorTxInput(_UniffiConverterRustBuffer): - @classmethod - def check_lower(cls, value): - for item in value: - _UniffiConverterTypeTrezorTxInput.check_lower(item) + @staticmethod + def check_lower(value: BoltzEventListener): + pass - @classmethod - def write(cls, value, buf): - items = len(value) - buf.write_i32(items) - for item in value: - _UniffiConverterTypeTrezorTxInput.write(item, buf) + @staticmethod + def lower(value: BoltzEventListenerProtocol): + return _UniffiConverterTypeBoltzEventListener._handle_map.insert(value) @classmethod - def read(cls, buf): - count = buf.read_i32() - if count < 0: - raise InternalError("Unexpected negative sequence length") + def read(cls, buf: _UniffiRustBuffer): + ptr = buf.read_u64() + if ptr == 0: + raise InternalError("Raw pointer value was null") + return cls.lift(ptr) - return [ - _UniffiConverterTypeTrezorTxInput.read(buf) for i in range(count) - ] + @classmethod + def write(cls, value: BoltzEventListenerProtocol, buf: _UniffiRustBuffer): + buf.write_u64(cls.lower(value)) +class EventListenerProtocol(typing.Protocol): + """ + Callback interface for receiving watcher events. + Implement this trait in Swift/Kotlin/Python to receive typed notifications + from xpub watchers. + """ + def on_event(self, watcher_id: "str",event: "WatcherEvent"): + """ + Called when a watcher event occurs. -class _UniffiConverterSequenceTypeTrezorTxOutput(_UniffiConverterRustBuffer): - @classmethod - def check_lower(cls, value): - for item in value: - _UniffiConverterTypeTrezorTxOutput.check_lower(item) + `watcher_id` identifies which watcher produced the event. + `event` is a typed enum — no JSON parsing needed. + """ - @classmethod - def write(cls, value, buf): - items = len(value) - buf.write_i32(items) - for item in value: - _UniffiConverterTypeTrezorTxOutput.write(item, buf) + raise NotImplementedError +# EventListener is a foreign trait so treated like a callback interface, where the +# primary use-case is the trait being implemented locally. +# It is a base-class local implementations might subclass. - @classmethod - def read(cls, buf): - count = buf.read_i32() - if count < 0: - raise InternalError("Unexpected negative sequence length") - return [ - _UniffiConverterTypeTrezorTxOutput.read(buf) for i in range(count) - ] +class EventListener(): + """ + Callback interface for receiving watcher events. + Implement this trait in Swift/Kotlin/Python to receive typed notifications + from xpub watchers. + """ + def on_event(self, watcher_id: "str",event: "WatcherEvent"): + """ + Called when a watcher event occurs. -class _UniffiConverterSequenceTypeTxDetailInput(_UniffiConverterRustBuffer): - @classmethod - def check_lower(cls, value): - for item in value: - _UniffiConverterTypeTxDetailInput.check_lower(item) + `watcher_id` identifies which watcher produced the event. + `event` is a typed enum — no JSON parsing needed. + """ - @classmethod - def write(cls, value, buf): - items = len(value) - buf.write_i32(items) - for item in value: - _UniffiConverterTypeTxDetailInput.write(item, buf) + raise NotImplementedError +# `EventListenerImpl` is the implementation for a Rust implemented version. +class EventListenerImpl(): + """ + Callback interface for receiving watcher events. - @classmethod - def read(cls, buf): - count = buf.read_i32() - if count < 0: - raise InternalError("Unexpected negative sequence length") + Implement this trait in Swift/Kotlin/Python to receive typed notifications + from xpub watchers. + """ - return [ - _UniffiConverterTypeTxDetailInput.read(buf) for i in range(count) - ] + _pointer: ctypes.c_void_p + + def __init__(self, *args, **kwargs): + raise ValueError("This class has no default constructor") + def __del__(self): + # In case of partial initialization of instances. + pointer = getattr(self, "_pointer", None) + if pointer is not None: + _uniffi_rust_call(_UniffiLib.uniffi_bitkitcore_fn_free_eventlistener, pointer) + def _uniffi_clone_pointer(self): + return _uniffi_rust_call(_UniffiLib.uniffi_bitkitcore_fn_clone_eventlistener, self._pointer) -class _UniffiConverterSequenceTypeTxDetailOutput(_UniffiConverterRustBuffer): + # Used by alternative constructors or any methods which return this type. @classmethod - def check_lower(cls, value): - for item in value: - _UniffiConverterTypeTxDetailOutput.check_lower(item) + def _make_instance_(cls, pointer): + # Lightly yucky way to bypass the usual __init__ logic + # and just create a new instance with the required pointer. + inst = cls.__new__(cls) + inst._pointer = pointer + return inst - @classmethod - def write(cls, value, buf): - items = len(value) - buf.write_i32(items) - for item in value: - _UniffiConverterTypeTxDetailOutput.write(item, buf) - @classmethod - def read(cls, buf): - count = buf.read_i32() - if count < 0: - raise InternalError("Unexpected negative sequence length") + def on_event(self, watcher_id: "str",event: "WatcherEvent") -> None: + """ + Called when a watcher event occurs. + + `watcher_id` identifies which watcher produced the event. + `event` is a typed enum — no JSON parsing needed. + """ + + _UniffiConverterString.check_lower(watcher_id) + + _UniffiConverterTypeWatcherEvent.check_lower(event) + + _uniffi_rust_call(_UniffiLib.uniffi_bitkitcore_fn_method_eventlistener_on_event,self._uniffi_clone_pointer(), + _UniffiConverterString.lower(watcher_id), + _UniffiConverterTypeWatcherEvent.lower(event)) - return [ - _UniffiConverterTypeTxDetailOutput.read(buf) for i in range(count) - ] -class _UniffiConverterSequenceTypeTxInput(_UniffiConverterRustBuffer): - @classmethod - def check_lower(cls, value): - for item in value: - _UniffiConverterTypeTxInput.check_lower(item) - @classmethod - def write(cls, value, buf): - items = len(value) - buf.write_i32(items) - for item in value: - _UniffiConverterTypeTxInput.write(item, buf) - @classmethod - def read(cls, buf): - count = buf.read_i32() - if count < 0: - raise InternalError("Unexpected negative sequence length") +# Put all the bits inside a class to keep the top-level namespace clean +class _UniffiTraitImplEventListener: + # For each method, generate a callback function to pass to Rust - return [ - _UniffiConverterTypeTxInput.read(buf) for i in range(count) - ] + @_UNIFFI_CALLBACK_INTERFACE_EVENT_LISTENER_METHOD0 + def on_event( + uniffi_handle, + watcher_id, + event, + uniffi_out_return, + uniffi_call_status_ptr, + ): + uniffi_obj = _UniffiConverterTypeEventListener._handle_map.get(uniffi_handle) + def make_call(): + args = (_UniffiConverterString.lift(watcher_id), _UniffiConverterTypeWatcherEvent.lift(event), ) + method = uniffi_obj.on_event + return method(*args) + + write_return_value = lambda v: None + _uniffi_trait_interface_call( + uniffi_call_status_ptr.contents, + make_call, + write_return_value, + ) + @_UNIFFI_CALLBACK_INTERFACE_FREE + def _uniffi_free(uniffi_handle): + _UniffiConverterTypeEventListener._handle_map.remove(uniffi_handle) -class _UniffiConverterSequenceTypeTxOutput(_UniffiConverterRustBuffer): - @classmethod - def check_lower(cls, value): - for item in value: - _UniffiConverterTypeTxOutput.check_lower(item) + # Generate the FFI VTable. This has a field for each callback interface method. + _uniffi_vtable = _UniffiVTableCallbackInterfaceEventListener( + on_event, + _uniffi_free + ) + # Send Rust a pointer to the VTable. Note: this means we need to keep the struct alive forever, + # or else bad things will happen when Rust tries to access it. + _UniffiLib.uniffi_bitkitcore_fn_init_callback_vtable_eventlistener(ctypes.byref(_uniffi_vtable)) - @classmethod - def write(cls, value, buf): - items = len(value) - buf.write_i32(items) - for item in value: - _UniffiConverterTypeTxOutput.write(item, buf) - @classmethod - def read(cls, buf): - count = buf.read_i32() - if count < 0: - raise InternalError("Unexpected negative sequence length") - return [ - _UniffiConverterTypeTxOutput.read(buf) for i in range(count) - ] +class _UniffiConverterTypeEventListener: + _handle_map = _UniffiHandleMap() + @staticmethod + def lift(value: int): + return EventListenerImpl._make_instance_(value) + @staticmethod + def check_lower(value: EventListener): + pass -class _UniffiConverterSequenceTypeActivity(_UniffiConverterRustBuffer): - @classmethod - def check_lower(cls, value): - for item in value: - _UniffiConverterTypeActivity.check_lower(item) + @staticmethod + def lower(value: EventListenerProtocol): + return _UniffiConverterTypeEventListener._handle_map.insert(value) @classmethod - def write(cls, value, buf): - items = len(value) - buf.write_i32(items) - for item in value: - _UniffiConverterTypeActivity.write(item, buf) + def read(cls, buf: _UniffiRustBuffer): + ptr = buf.read_u64() + if ptr == 0: + raise InternalError("Raw pointer value was null") + return cls.lift(ptr) @classmethod - def read(cls, buf): - count = buf.read_i32() - if count < 0: - raise InternalError("Unexpected negative sequence length") + def write(cls, value: EventListenerProtocol, buf: _UniffiRustBuffer): + buf.write_u64(cls.lower(value)) +class JadeTransportCallbackProtocol(typing.Protocol): + """ + Native transport for Jade. - return [ - _UniffiConverterTypeActivity.read(buf) for i in range(count) - ] + # Bluetooth contract + Jade advertises the Nordic UART Service: + - service `6e400001-b5a3-f393-e0a9-e50e24dcca9e` + - write `6e400002-b5a3-f393-e0a9-e50e24dcca9e` (host to Jade) + - notify `6e400003-b5a3-f393-e0a9-e50e24dcca9e` (Jade to host) -class _UniffiConverterSequenceTypeComposeOutput(_UniffiConverterRustBuffer): - @classmethod - def check_lower(cls, value): - for item in value: - _UniffiConverterTypeComposeOutput.check_lower(item) + Devices advertise as "Jade" or "Jade ". - @classmethod - def write(cls, value, buf): - items = len(value) - buf.write_i32(items) - for item in value: - _UniffiConverterTypeComposeOutput.write(item, buf) + Three requirements that are easy to miss and break signing on real hardware: - @classmethod - def read(cls, buf): - count = buf.read_i32() - if count < 0: - raise InternalError("Unexpected negative sequence length") + 1. **Write with response.** Write-without-response silently drops chunks on + the ESP32 GATT stack. + 2. **Do not pause between chunks.** Firmware discards a partially received + message after two seconds of silence, three on Jade v1, and answers with + an unattributed error. A 30 KB PSBT is roughly 60 writes, so any UI thread + stall in the middle of a send breaks the operation. + 3. **`read_chunk` must return promptly.** Honour `timeout_ms`, which this + crate keeps short. The long per-operation deadline is enforced in Rust so + the user can cancel. + """ - return [ - _UniffiConverterTypeComposeOutput.read(buf) for i in range(count) - ] + def scan_devices(self, timeout_ms: "int"): + """ + Discover devices, blocking up to `timeout_ms`. + """ + raise NotImplementedError + def open_device(self, path: "str"): + """ + Open a connection and enable notifications. + """ + raise NotImplementedError + def close_device(self, path: "str"): + """ + Close the connection and release the device. + """ -class _UniffiConverterSequenceTypeComposeResult(_UniffiConverterRustBuffer): - @classmethod - def check_lower(cls, value): - for item in value: - _UniffiConverterTypeComposeResult.check_lower(item) + raise NotImplementedError + def write_chunk(self, path: "str",data: "bytes"): + """ + Write one chunk, no larger than `get_chunk_size`. + """ - @classmethod - def write(cls, value, buf): - items = len(value) - buf.write_i32(items) - for item in value: - _UniffiConverterTypeComposeResult.write(item, buf) + raise NotImplementedError + def read_chunk(self, path: "str",timeout_ms: "int"): + """ + Read whatever has arrived, waiting at most `timeout_ms`. - @classmethod - def read(cls, buf): - count = buf.read_i32() - if count < 0: - raise InternalError("Unexpected negative sequence length") + Returning success with an empty vector is normal and means "nothing yet". + """ - return [ - _UniffiConverterTypeComposeResult.read(buf) for i in range(count) - ] + raise NotImplementedError + def get_chunk_size(self, path: "str"): + """ + Maximum bytes per write. + For Bluetooth this is `min(negotiated_mtu - 3, 509)`. The value is + clamped into a usable range, so an unnegotiated `0` is not fatal. + """ + raise NotImplementedError +# JadeTransportCallback is a foreign trait so treated like a callback interface, where the +# primary use-case is the trait being implemented locally. +# It is a base-class local implementations might subclass. -class _UniffiConverterSequenceTypeHardwareWalletTransport(_UniffiConverterRustBuffer): - @classmethod - def check_lower(cls, value): - for item in value: - _UniffiConverterTypeHardwareWalletTransport.check_lower(item) - @classmethod - def write(cls, value, buf): - items = len(value) - buf.write_i32(items) - for item in value: - _UniffiConverterTypeHardwareWalletTransport.write(item, buf) +class JadeTransportCallback(): + """ + Native transport for Jade. - @classmethod - def read(cls, buf): - count = buf.read_i32() - if count < 0: - raise InternalError("Unexpected negative sequence length") + # Bluetooth contract - return [ - _UniffiConverterTypeHardwareWalletTransport.read(buf) for i in range(count) - ] + Jade advertises the Nordic UART Service: + - service `6e400001-b5a3-f393-e0a9-e50e24dcca9e` + - write `6e400002-b5a3-f393-e0a9-e50e24dcca9e` (host to Jade) + - notify `6e400003-b5a3-f393-e0a9-e50e24dcca9e` (Jade to host) + Devices advertise as "Jade" or "Jade ". -class _UniffiConverterMapStringString(_UniffiConverterRustBuffer): - @classmethod - def check_lower(cls, items): - for (key, value) in items.items(): - _UniffiConverterString.check_lower(key) - _UniffiConverterString.check_lower(value) + Three requirements that are easy to miss and break signing on real hardware: - @classmethod - def write(cls, items, buf): - buf.write_i32(len(items)) - for (key, value) in items.items(): - _UniffiConverterString.write(key, buf) - _UniffiConverterString.write(value, buf) + 1. **Write with response.** Write-without-response silently drops chunks on + the ESP32 GATT stack. + 2. **Do not pause between chunks.** Firmware discards a partially received + message after two seconds of silence, three on Jade v1, and answers with + an unattributed error. A 30 KB PSBT is roughly 60 writes, so any UI thread + stall in the middle of a send breaks the operation. + 3. **`read_chunk` must return promptly.** Honour `timeout_ms`, which this + crate keeps short. The long per-operation deadline is enforced in Rust so + the user can cancel. + """ - @classmethod - def read(cls, buf): - count = buf.read_i32() - if count < 0: - raise InternalError("Unexpected negative map size") + def scan_devices(self, timeout_ms: "int"): + """ + Discover devices, blocking up to `timeout_ms`. + """ - # It would be nice to use a dict comprehension, - # but in Python 3.7 and before the evaluation order is not according to spec, - # so we we're reading the value before the key. - # This loop makes the order explicit: first reading the key, then the value. - d = {} - for i in range(count): - key = _UniffiConverterString.read(buf) - val = _UniffiConverterString.read(buf) - d[key] = val - return d + raise NotImplementedError + def open_device(self, path: "str"): + """ + Open a connection and enable notifications. + """ -# objects. -class BoltzEventListenerProtocol(typing.Protocol): - """ - Callback interface for receiving Boltz swap lifecycle events. + raise NotImplementedError + def close_device(self, path: "str"): + """ + Close the connection and release the device. + """ - Implement this in Swift/Kotlin/Python and register it via - `boltz_start_swap_updates` to receive typed notifications as swaps progress. - Reverse swaps are claimed automatically; the [`BoltzSwapEvent::Claimed`] - event reports the resulting transaction id. - """ + raise NotImplementedError + def write_chunk(self, path: "str",data: "bytes"): + """ + Write one chunk, no larger than `get_chunk_size`. + """ - def on_event(self, event: "BoltzSwapEvent"): raise NotImplementedError -# BoltzEventListener is a foreign trait so treated like a callback interface, where the -# primary use-case is the trait being implemented locally. -# It is a base-class local implementations might subclass. + def read_chunk(self, path: "str",timeout_ms: "int"): + """ + Read whatever has arrived, waiting at most `timeout_ms`. + + Returning success with an empty vector is normal and means "nothing yet". + """ + + raise NotImplementedError + def get_chunk_size(self, path: "str"): + """ + Maximum bytes per write. + For Bluetooth this is `min(negotiated_mtu - 3, 509)`. The value is + clamped into a usable range, so an unnegotiated `0` is not fatal. + """ -class BoltzEventListener(): + raise NotImplementedError +# `JadeTransportCallbackImpl` is the implementation for a Rust implemented version. +class JadeTransportCallbackImpl(): """ - Callback interface for receiving Boltz swap lifecycle events. + Native transport for Jade. - Implement this in Swift/Kotlin/Python and register it via - `boltz_start_swap_updates` to receive typed notifications as swaps progress. - Reverse swaps are claimed automatically; the [`BoltzSwapEvent::Claimed`] - event reports the resulting transaction id. - """ + # Bluetooth contract - def on_event(self, event: "BoltzSwapEvent"): - raise NotImplementedError -# `BoltzEventListenerImpl` is the implementation for a Rust implemented version. -class BoltzEventListenerImpl(): - """ - Callback interface for receiving Boltz swap lifecycle events. + Jade advertises the Nordic UART Service: - Implement this in Swift/Kotlin/Python and register it via - `boltz_start_swap_updates` to receive typed notifications as swaps progress. - Reverse swaps are claimed automatically; the [`BoltzSwapEvent::Claimed`] - event reports the resulting transaction id. + - service `6e400001-b5a3-f393-e0a9-e50e24dcca9e` + - write `6e400002-b5a3-f393-e0a9-e50e24dcca9e` (host to Jade) + - notify `6e400003-b5a3-f393-e0a9-e50e24dcca9e` (Jade to host) + + Devices advertise as "Jade" or "Jade ". + + Three requirements that are easy to miss and break signing on real hardware: + + 1. **Write with response.** Write-without-response silently drops chunks on + the ESP32 GATT stack. + 2. **Do not pause between chunks.** Firmware discards a partially received + message after two seconds of silence, three on Jade v1, and answers with + an unattributed error. A 30 KB PSBT is roughly 60 writes, so any UI thread + stall in the middle of a send breaks the operation. + 3. **`read_chunk` must return promptly.** Honour `timeout_ms`, which this + crate keeps short. The long per-operation deadline is enforced in Rust so + the user can cancel. """ _pointer: ctypes.c_void_p @@ -20267,10 +22473,10 @@ def __del__(self): # In case of partial initialization of instances. pointer = getattr(self, "_pointer", None) if pointer is not None: - _uniffi_rust_call(_UniffiLib.uniffi_bitkitcore_fn_free_boltzeventlistener, pointer) + _uniffi_rust_call(_UniffiLib.uniffi_bitkitcore_fn_free_jadetransportcallback, pointer) def _uniffi_clone_pointer(self): - return _uniffi_rust_call(_UniffiLib.uniffi_bitkitcore_fn_clone_boltzeventlistener, self._pointer) + return _uniffi_rust_call(_UniffiLib.uniffi_bitkitcore_fn_clone_jadetransportcallback, self._pointer) # Used by alternative constructors or any methods which return this type. @classmethod @@ -20282,195 +22488,245 @@ def _make_instance_(cls, pointer): return inst - def on_event(self, event: "BoltzSwapEvent") -> None: - _UniffiConverterTypeBoltzSwapEvent.check_lower(event) + def scan_devices(self, timeout_ms: "int") -> "typing.List[JadeNativeDevice]": + """ + Discover devices, blocking up to `timeout_ms`. + """ + + _UniffiConverterUInt32.check_lower(timeout_ms) - _uniffi_rust_call(_UniffiLib.uniffi_bitkitcore_fn_method_boltzeventlistener_on_event,self._uniffi_clone_pointer(), - _UniffiConverterTypeBoltzSwapEvent.lower(event)) + return _UniffiConverterSequenceTypeJadeNativeDevice.lift( + _uniffi_rust_call(_UniffiLib.uniffi_bitkitcore_fn_method_jadetransportcallback_scan_devices,self._uniffi_clone_pointer(), + _UniffiConverterUInt32.lower(timeout_ms)) + ) + def open_device(self, path: "str") -> "JadeTransportResult": + """ + Open a connection and enable notifications. + """ + + _UniffiConverterString.check_lower(path) + + return _UniffiConverterTypeJadeTransportResult.lift( + _uniffi_rust_call(_UniffiLib.uniffi_bitkitcore_fn_method_jadetransportcallback_open_device,self._uniffi_clone_pointer(), + _UniffiConverterString.lower(path)) + ) + + -# Put all the bits inside a class to keep the top-level namespace clean -class _UniffiTraitImplBoltzEventListener: - # For each method, generate a callback function to pass to Rust - @_UNIFFI_CALLBACK_INTERFACE_BOLTZ_EVENT_LISTENER_METHOD0 - def on_event( - uniffi_handle, - event, - uniffi_out_return, - uniffi_call_status_ptr, - ): - uniffi_obj = _UniffiConverterTypeBoltzEventListener._handle_map.get(uniffi_handle) - def make_call(): - args = (_UniffiConverterTypeBoltzSwapEvent.lift(event), ) - method = uniffi_obj.on_event - return method(*args) + def close_device(self, path: "str") -> "JadeTransportResult": + """ + Close the connection and release the device. + """ + + _UniffiConverterString.check_lower(path) - write_return_value = lambda v: None - _uniffi_trait_interface_call( - uniffi_call_status_ptr.contents, - make_call, - write_return_value, + return _UniffiConverterTypeJadeTransportResult.lift( + _uniffi_rust_call(_UniffiLib.uniffi_bitkitcore_fn_method_jadetransportcallback_close_device,self._uniffi_clone_pointer(), + _UniffiConverterString.lower(path)) ) - @_UNIFFI_CALLBACK_INTERFACE_FREE - def _uniffi_free(uniffi_handle): - _UniffiConverterTypeBoltzEventListener._handle_map.remove(uniffi_handle) - - # Generate the FFI VTable. This has a field for each callback interface method. - _uniffi_vtable = _UniffiVTableCallbackInterfaceBoltzEventListener( - on_event, - _uniffi_free - ) - # Send Rust a pointer to the VTable. Note: this means we need to keep the struct alive forever, - # or else bad things will happen when Rust tries to access it. - _UniffiLib.uniffi_bitkitcore_fn_init_callback_vtable_boltzeventlistener(ctypes.byref(_uniffi_vtable)) -class _UniffiConverterTypeBoltzEventListener: - _handle_map = _UniffiHandleMap() - @staticmethod - def lift(value: int): - return BoltzEventListenerImpl._make_instance_(value) + def write_chunk(self, path: "str",data: "bytes") -> "JadeTransportResult": + """ + Write one chunk, no larger than `get_chunk_size`. + """ - @staticmethod - def check_lower(value: BoltzEventListener): - pass + _UniffiConverterString.check_lower(path) + + _UniffiConverterBytes.check_lower(data) + + return _UniffiConverterTypeJadeTransportResult.lift( + _uniffi_rust_call(_UniffiLib.uniffi_bitkitcore_fn_method_jadetransportcallback_write_chunk,self._uniffi_clone_pointer(), + _UniffiConverterString.lower(path), + _UniffiConverterBytes.lower(data)) + ) - @staticmethod - def lower(value: BoltzEventListenerProtocol): - return _UniffiConverterTypeBoltzEventListener._handle_map.insert(value) - @classmethod - def read(cls, buf: _UniffiRustBuffer): - ptr = buf.read_u64() - if ptr == 0: - raise InternalError("Raw pointer value was null") - return cls.lift(ptr) - @classmethod - def write(cls, value: BoltzEventListenerProtocol, buf: _UniffiRustBuffer): - buf.write_u64(cls.lower(value)) -class EventListenerProtocol(typing.Protocol): - """ - Callback interface for receiving watcher events. - Implement this trait in Swift/Kotlin/Python to receive typed notifications - from xpub watchers. - """ - def on_event(self, watcher_id: "str",event: "WatcherEvent"): + def read_chunk(self, path: "str",timeout_ms: "int") -> "JadeTransportReadResult": """ - Called when a watcher event occurs. + Read whatever has arrived, waiting at most `timeout_ms`. - `watcher_id` identifies which watcher produced the event. - `event` is a typed enum — no JSON parsing needed. + Returning success with an empty vector is normal and means "nothing yet". """ - raise NotImplementedError -# EventListener is a foreign trait so treated like a callback interface, where the -# primary use-case is the trait being implemented locally. -# It is a base-class local implementations might subclass. + _UniffiConverterString.check_lower(path) + + _UniffiConverterUInt32.check_lower(timeout_ms) + + return _UniffiConverterTypeJadeTransportReadResult.lift( + _uniffi_rust_call(_UniffiLib.uniffi_bitkitcore_fn_method_jadetransportcallback_read_chunk,self._uniffi_clone_pointer(), + _UniffiConverterString.lower(path), + _UniffiConverterUInt32.lower(timeout_ms)) + ) -class EventListener(): - """ - Callback interface for receiving watcher events. - Implement this trait in Swift/Kotlin/Python to receive typed notifications - from xpub watchers. - """ - def on_event(self, watcher_id: "str",event: "WatcherEvent"): + + def get_chunk_size(self, path: "str") -> "int": """ - Called when a watcher event occurs. + Maximum bytes per write. - `watcher_id` identifies which watcher produced the event. - `event` is a typed enum — no JSON parsing needed. + For Bluetooth this is `min(negotiated_mtu - 3, 509)`. The value is + clamped into a usable range, so an unnegotiated `0` is not fatal. """ - raise NotImplementedError -# `EventListenerImpl` is the implementation for a Rust implemented version. -class EventListenerImpl(): - """ - Callback interface for receiving watcher events. + _UniffiConverterString.check_lower(path) + + return _UniffiConverterUInt32.lift( + _uniffi_rust_call(_UniffiLib.uniffi_bitkitcore_fn_method_jadetransportcallback_get_chunk_size,self._uniffi_clone_pointer(), + _UniffiConverterString.lower(path)) + ) - Implement this trait in Swift/Kotlin/Python to receive typed notifications - from xpub watchers. - """ - _pointer: ctypes.c_void_p - - def __init__(self, *args, **kwargs): - raise ValueError("This class has no default constructor") - def __del__(self): - # In case of partial initialization of instances. - pointer = getattr(self, "_pointer", None) - if pointer is not None: - _uniffi_rust_call(_UniffiLib.uniffi_bitkitcore_fn_free_eventlistener, pointer) - def _uniffi_clone_pointer(self): - return _uniffi_rust_call(_UniffiLib.uniffi_bitkitcore_fn_clone_eventlistener, self._pointer) - # Used by alternative constructors or any methods which return this type. - @classmethod - def _make_instance_(cls, pointer): - # Lightly yucky way to bypass the usual __init__ logic - # and just create a new instance with the required pointer. - inst = cls.__new__(cls) - inst._pointer = pointer - return inst +# Put all the bits inside a class to keep the top-level namespace clean +class _UniffiTraitImplJadeTransportCallback: + # For each method, generate a callback function to pass to Rust + @_UNIFFI_CALLBACK_INTERFACE_JADE_TRANSPORT_CALLBACK_METHOD0 + def scan_devices( + uniffi_handle, + timeout_ms, + uniffi_out_return, + uniffi_call_status_ptr, + ): + uniffi_obj = _UniffiConverterTypeJadeTransportCallback._handle_map.get(uniffi_handle) + def make_call(): + args = (_UniffiConverterUInt32.lift(timeout_ms), ) + method = uniffi_obj.scan_devices + return method(*args) - def on_event(self, watcher_id: "str",event: "WatcherEvent") -> None: - """ - Called when a watcher event occurs. + + def write_return_value(v): + uniffi_out_return[0] = _UniffiConverterSequenceTypeJadeNativeDevice.lower(v) + _uniffi_trait_interface_call( + uniffi_call_status_ptr.contents, + make_call, + write_return_value, + ) - `watcher_id` identifies which watcher produced the event. - `event` is a typed enum — no JSON parsing needed. - """ + @_UNIFFI_CALLBACK_INTERFACE_JADE_TRANSPORT_CALLBACK_METHOD1 + def open_device( + uniffi_handle, + path, + uniffi_out_return, + uniffi_call_status_ptr, + ): + uniffi_obj = _UniffiConverterTypeJadeTransportCallback._handle_map.get(uniffi_handle) + def make_call(): + args = (_UniffiConverterString.lift(path), ) + method = uniffi_obj.open_device + return method(*args) - _UniffiConverterString.check_lower(watcher_id) - - _UniffiConverterTypeWatcherEvent.check_lower(event) - _uniffi_rust_call(_UniffiLib.uniffi_bitkitcore_fn_method_eventlistener_on_event,self._uniffi_clone_pointer(), - _UniffiConverterString.lower(watcher_id), - _UniffiConverterTypeWatcherEvent.lower(event)) + def write_return_value(v): + uniffi_out_return[0] = _UniffiConverterTypeJadeTransportResult.lower(v) + _uniffi_trait_interface_call( + uniffi_call_status_ptr.contents, + make_call, + write_return_value, + ) + @_UNIFFI_CALLBACK_INTERFACE_JADE_TRANSPORT_CALLBACK_METHOD2 + def close_device( + uniffi_handle, + path, + uniffi_out_return, + uniffi_call_status_ptr, + ): + uniffi_obj = _UniffiConverterTypeJadeTransportCallback._handle_map.get(uniffi_handle) + def make_call(): + args = (_UniffiConverterString.lift(path), ) + method = uniffi_obj.close_device + return method(*args) + + def write_return_value(v): + uniffi_out_return[0] = _UniffiConverterTypeJadeTransportResult.lower(v) + _uniffi_trait_interface_call( + uniffi_call_status_ptr.contents, + make_call, + write_return_value, + ) + @_UNIFFI_CALLBACK_INTERFACE_JADE_TRANSPORT_CALLBACK_METHOD3 + def write_chunk( + uniffi_handle, + path, + data, + uniffi_out_return, + uniffi_call_status_ptr, + ): + uniffi_obj = _UniffiConverterTypeJadeTransportCallback._handle_map.get(uniffi_handle) + def make_call(): + args = (_UniffiConverterString.lift(path), _UniffiConverterBytes.lift(data), ) + method = uniffi_obj.write_chunk + return method(*args) + + def write_return_value(v): + uniffi_out_return[0] = _UniffiConverterTypeJadeTransportResult.lower(v) + _uniffi_trait_interface_call( + uniffi_call_status_ptr.contents, + make_call, + write_return_value, + ) + @_UNIFFI_CALLBACK_INTERFACE_JADE_TRANSPORT_CALLBACK_METHOD4 + def read_chunk( + uniffi_handle, + path, + timeout_ms, + uniffi_out_return, + uniffi_call_status_ptr, + ): + uniffi_obj = _UniffiConverterTypeJadeTransportCallback._handle_map.get(uniffi_handle) + def make_call(): + args = (_UniffiConverterString.lift(path), _UniffiConverterUInt32.lift(timeout_ms), ) + method = uniffi_obj.read_chunk + return method(*args) -# Put all the bits inside a class to keep the top-level namespace clean -class _UniffiTraitImplEventListener: - # For each method, generate a callback function to pass to Rust + + def write_return_value(v): + uniffi_out_return[0] = _UniffiConverterTypeJadeTransportReadResult.lower(v) + _uniffi_trait_interface_call( + uniffi_call_status_ptr.contents, + make_call, + write_return_value, + ) - @_UNIFFI_CALLBACK_INTERFACE_EVENT_LISTENER_METHOD0 - def on_event( + @_UNIFFI_CALLBACK_INTERFACE_JADE_TRANSPORT_CALLBACK_METHOD5 + def get_chunk_size( uniffi_handle, - watcher_id, - event, + path, uniffi_out_return, uniffi_call_status_ptr, ): - uniffi_obj = _UniffiConverterTypeEventListener._handle_map.get(uniffi_handle) + uniffi_obj = _UniffiConverterTypeJadeTransportCallback._handle_map.get(uniffi_handle) def make_call(): - args = (_UniffiConverterString.lift(watcher_id), _UniffiConverterTypeWatcherEvent.lift(event), ) - method = uniffi_obj.on_event + args = (_UniffiConverterString.lift(path), ) + method = uniffi_obj.get_chunk_size return method(*args) - write_return_value = lambda v: None + def write_return_value(v): + uniffi_out_return[0] = _UniffiConverterUInt32.lower(v) _uniffi_trait_interface_call( uniffi_call_status_ptr.contents, make_call, @@ -20479,33 +22735,38 @@ def make_call(): @_UNIFFI_CALLBACK_INTERFACE_FREE def _uniffi_free(uniffi_handle): - _UniffiConverterTypeEventListener._handle_map.remove(uniffi_handle) + _UniffiConverterTypeJadeTransportCallback._handle_map.remove(uniffi_handle) # Generate the FFI VTable. This has a field for each callback interface method. - _uniffi_vtable = _UniffiVTableCallbackInterfaceEventListener( - on_event, + _uniffi_vtable = _UniffiVTableCallbackInterfaceJadeTransportCallback( + scan_devices, + open_device, + close_device, + write_chunk, + read_chunk, + get_chunk_size, _uniffi_free ) # Send Rust a pointer to the VTable. Note: this means we need to keep the struct alive forever, # or else bad things will happen when Rust tries to access it. - _UniffiLib.uniffi_bitkitcore_fn_init_callback_vtable_eventlistener(ctypes.byref(_uniffi_vtable)) + _UniffiLib.uniffi_bitkitcore_fn_init_callback_vtable_jadetransportcallback(ctypes.byref(_uniffi_vtable)) -class _UniffiConverterTypeEventListener: +class _UniffiConverterTypeJadeTransportCallback: _handle_map = _UniffiHandleMap() @staticmethod def lift(value: int): - return EventListenerImpl._make_instance_(value) + return JadeTransportCallbackImpl._make_instance_(value) @staticmethod - def check_lower(value: EventListener): + def check_lower(value: JadeTransportCallback): pass @staticmethod - def lower(value: EventListenerProtocol): - return _UniffiConverterTypeEventListener._handle_map.insert(value) + def lower(value: JadeTransportCallbackProtocol): + return _UniffiConverterTypeJadeTransportCallback._handle_map.insert(value) @classmethod def read(cls, buf: _UniffiRustBuffer): @@ -20515,7 +22776,7 @@ def read(cls, buf: _UniffiRustBuffer): return cls.lift(ptr) @classmethod - def write(cls, value: EventListenerProtocol, buf: _UniffiRustBuffer): + def write(cls, value: JadeTransportCallbackProtocol, buf: _UniffiRustBuffer): buf.write_u64(cls.lower(value)) class TrezorTransportCallbackProtocol(typing.Protocol): """ @@ -21339,24 +23600,249 @@ def _uniffi_free(uniffi_handle): ) # Send Rust a pointer to the VTable. Note: this means we need to keep the struct alive forever, # or else bad things will happen when Rust tries to access it. - _UniffiLib.uniffi_bitkitcore_fn_init_callback_vtable_trezortransportcallback(ctypes.byref(_uniffi_vtable)) + _UniffiLib.uniffi_bitkitcore_fn_init_callback_vtable_trezortransportcallback(ctypes.byref(_uniffi_vtable)) + + + +class _UniffiConverterTypeTrezorTransportCallback: + _handle_map = _UniffiHandleMap() + + @staticmethod + def lift(value: int): + return TrezorTransportCallbackImpl._make_instance_(value) + + @staticmethod + def check_lower(value: TrezorTransportCallback): + pass + + @staticmethod + def lower(value: TrezorTransportCallbackProtocol): + return _UniffiConverterTypeTrezorTransportCallback._handle_map.insert(value) + + @classmethod + def read(cls, buf: _UniffiRustBuffer): + ptr = buf.read_u64() + if ptr == 0: + raise InternalError("Raw pointer value was null") + return cls.lift(ptr) + + @classmethod + def write(cls, value: TrezorTransportCallbackProtocol, buf: _UniffiRustBuffer): + buf.write_u64(cls.lower(value)) +class TrezorUiCallbackProtocol(typing.Protocol): + """ + Callback interface for handling PIN and passphrase requests from the Trezor device. + + The native layer (iOS/Android) should implement this to show PIN/passphrase + input UI when the device requests it during operations like signing. + """ + + def on_pin_request(self, ): + """ + Called when the device requests a PIN. + + Show a PIN matrix UI and return the matrix-encoded PIN string. + Return empty string to cancel. + """ + + raise NotImplementedError + def on_passphrase_request(self, on_device: "bool"): + """ + Called when the device requests a passphrase. + + If `on_device` is true, the device is asking for the passphrase to be + entered on the Trezor itself — return `PassphraseResponse::OnDevice`. + + If `on_device` is false, show a passphrase input UI and return + `Standard` (no passphrase), `Hidden { value }` (host-entered passphrase), + `OnDevice` (defer entry to the Trezor), or `Cancel`. + """ + + raise NotImplementedError +# TrezorUiCallback is a foreign trait so treated like a callback interface, where the +# primary use-case is the trait being implemented locally. +# It is a base-class local implementations might subclass. + + +class TrezorUiCallback(): + """ + Callback interface for handling PIN and passphrase requests from the Trezor device. + + The native layer (iOS/Android) should implement this to show PIN/passphrase + input UI when the device requests it during operations like signing. + """ + + def on_pin_request(self, ): + """ + Called when the device requests a PIN. + + Show a PIN matrix UI and return the matrix-encoded PIN string. + Return empty string to cancel. + """ + + raise NotImplementedError + def on_passphrase_request(self, on_device: "bool"): + """ + Called when the device requests a passphrase. + + If `on_device` is true, the device is asking for the passphrase to be + entered on the Trezor itself — return `PassphraseResponse::OnDevice`. + + If `on_device` is false, show a passphrase input UI and return + `Standard` (no passphrase), `Hidden { value }` (host-entered passphrase), + `OnDevice` (defer entry to the Trezor), or `Cancel`. + """ + + raise NotImplementedError +# `TrezorUiCallbackImpl` is the implementation for a Rust implemented version. +class TrezorUiCallbackImpl(): + """ + Callback interface for handling PIN and passphrase requests from the Trezor device. + + The native layer (iOS/Android) should implement this to show PIN/passphrase + input UI when the device requests it during operations like signing. + """ + + _pointer: ctypes.c_void_p + + def __init__(self, *args, **kwargs): + raise ValueError("This class has no default constructor") + + def __del__(self): + # In case of partial initialization of instances. + pointer = getattr(self, "_pointer", None) + if pointer is not None: + _uniffi_rust_call(_UniffiLib.uniffi_bitkitcore_fn_free_trezoruicallback, pointer) + + def _uniffi_clone_pointer(self): + return _uniffi_rust_call(_UniffiLib.uniffi_bitkitcore_fn_clone_trezoruicallback, self._pointer) + + # Used by alternative constructors or any methods which return this type. + @classmethod + def _make_instance_(cls, pointer): + # Lightly yucky way to bypass the usual __init__ logic + # and just create a new instance with the required pointer. + inst = cls.__new__(cls) + inst._pointer = pointer + return inst + + + def on_pin_request(self, ) -> "str": + """ + Called when the device requests a PIN. + + Show a PIN matrix UI and return the matrix-encoded PIN string. + Return empty string to cancel. + """ + + return _UniffiConverterString.lift( + _uniffi_rust_call(_UniffiLib.uniffi_bitkitcore_fn_method_trezoruicallback_on_pin_request,self._uniffi_clone_pointer(),) + ) + + + + + + def on_passphrase_request(self, on_device: "bool") -> "PassphraseResponse": + """ + Called when the device requests a passphrase. + + If `on_device` is true, the device is asking for the passphrase to be + entered on the Trezor itself — return `PassphraseResponse::OnDevice`. + + If `on_device` is false, show a passphrase input UI and return + `Standard` (no passphrase), `Hidden { value }` (host-entered passphrase), + `OnDevice` (defer entry to the Trezor), or `Cancel`. + """ + + _UniffiConverterBool.check_lower(on_device) + + return _UniffiConverterTypePassphraseResponse.lift( + _uniffi_rust_call(_UniffiLib.uniffi_bitkitcore_fn_method_trezoruicallback_on_passphrase_request,self._uniffi_clone_pointer(), + _UniffiConverterBool.lower(on_device)) + ) + + + + + +# Put all the bits inside a class to keep the top-level namespace clean +class _UniffiTraitImplTrezorUiCallback: + # For each method, generate a callback function to pass to Rust + + @_UNIFFI_CALLBACK_INTERFACE_TREZOR_UI_CALLBACK_METHOD0 + def on_pin_request( + uniffi_handle, + uniffi_out_return, + uniffi_call_status_ptr, + ): + uniffi_obj = _UniffiConverterTypeTrezorUiCallback._handle_map.get(uniffi_handle) + def make_call(): + args = () + method = uniffi_obj.on_pin_request + return method(*args) + + + def write_return_value(v): + uniffi_out_return[0] = _UniffiConverterString.lower(v) + _uniffi_trait_interface_call( + uniffi_call_status_ptr.contents, + make_call, + write_return_value, + ) + + @_UNIFFI_CALLBACK_INTERFACE_TREZOR_UI_CALLBACK_METHOD1 + def on_passphrase_request( + uniffi_handle, + on_device, + uniffi_out_return, + uniffi_call_status_ptr, + ): + uniffi_obj = _UniffiConverterTypeTrezorUiCallback._handle_map.get(uniffi_handle) + def make_call(): + args = (_UniffiConverterBool.lift(on_device), ) + method = uniffi_obj.on_passphrase_request + return method(*args) + + + def write_return_value(v): + uniffi_out_return[0] = _UniffiConverterTypePassphraseResponse.lower(v) + _uniffi_trait_interface_call( + uniffi_call_status_ptr.contents, + make_call, + write_return_value, + ) + + @_UNIFFI_CALLBACK_INTERFACE_FREE + def _uniffi_free(uniffi_handle): + _UniffiConverterTypeTrezorUiCallback._handle_map.remove(uniffi_handle) + + # Generate the FFI VTable. This has a field for each callback interface method. + _uniffi_vtable = _UniffiVTableCallbackInterfaceTrezorUiCallback( + on_pin_request, + on_passphrase_request, + _uniffi_free + ) + # Send Rust a pointer to the VTable. Note: this means we need to keep the struct alive forever, + # or else bad things will happen when Rust tries to access it. + _UniffiLib.uniffi_bitkitcore_fn_init_callback_vtable_trezoruicallback(ctypes.byref(_uniffi_vtable)) -class _UniffiConverterTypeTrezorTransportCallback: +class _UniffiConverterTypeTrezorUiCallback: _handle_map = _UniffiHandleMap() @staticmethod def lift(value: int): - return TrezorTransportCallbackImpl._make_instance_(value) + return TrezorUiCallbackImpl._make_instance_(value) @staticmethod - def check_lower(value: TrezorTransportCallback): + def check_lower(value: TrezorUiCallback): pass @staticmethod - def lower(value: TrezorTransportCallbackProtocol): - return _UniffiConverterTypeTrezorTransportCallback._handle_map.insert(value) + def lower(value: TrezorUiCallbackProtocol): + return _UniffiConverterTypeTrezorUiCallback._handle_map.insert(value) @classmethod def read(cls, buf: _UniffiRustBuffer): @@ -21366,1788 +23852,2020 @@ def read(cls, buf: _UniffiRustBuffer): return cls.lift(ptr) @classmethod - def write(cls, value: TrezorTransportCallbackProtocol, buf: _UniffiRustBuffer): + def write(cls, value: TrezorUiCallbackProtocol, buf: _UniffiRustBuffer): buf.write_u64(cls.lower(value)) -class TrezorUiCallbackProtocol(typing.Protocol): +class UrDecoderProtocol(typing.Protocol): """ - Callback interface for handling PIN and passphrase requests from the Trezor device. - - The native layer (iOS/Android) should implement this to show PIN/passphrase - input UI when the device requests it during operations like signing. + Stateful decoder for single-part and animated multipart UR QR scans. """ - def on_pin_request(self, ): + def receive(self, frame: "str"): + """ + Adds one UR fragment and returns the current decoding status. """ - Called when the device requests a PIN. - Show a PIN matrix UI and return the matrix-encoded PIN string. - Return empty string to cancel. + raise NotImplementedError + def reset(self, ): + """ + Clear all frames so the decoder can receive another message. """ raise NotImplementedError - def on_passphrase_request(self, on_device: "bool"): +# UrDecoder is a Rust-only trait - it's a wrapper around a Rust implementation. +class UrDecoder(): + """ + Stateful decoder for single-part and animated multipart UR QR scans. + """ + + _pointer: ctypes.c_void_p + def __init__(self, ): + self._pointer = _uniffi_rust_call(_UniffiLib.uniffi_bitkitcore_fn_constructor_urdecoder_new,) + + def __del__(self): + # In case of partial initialization of instances. + pointer = getattr(self, "_pointer", None) + if pointer is not None: + _uniffi_rust_call(_UniffiLib.uniffi_bitkitcore_fn_free_urdecoder, pointer) + + def _uniffi_clone_pointer(self): + return _uniffi_rust_call(_UniffiLib.uniffi_bitkitcore_fn_clone_urdecoder, self._pointer) + + # Used by alternative constructors or any methods which return this type. + @classmethod + def _make_instance_(cls, pointer): + # Lightly yucky way to bypass the usual __init__ logic + # and just create a new instance with the required pointer. + inst = cls.__new__(cls) + inst._pointer = pointer + return inst + + + def receive(self, frame: "str") -> "UrDecoderStatus": + """ + Adds one UR fragment and returns the current decoding status. """ - Called when the device requests a passphrase. - If `on_device` is true, the device is asking for the passphrase to be - entered on the Trezor itself — return `PassphraseResponse::OnDevice`. + _UniffiConverterString.check_lower(frame) + + return _UniffiConverterTypeUrDecoderStatus.lift( + _uniffi_rust_call_with_error(_UniffiConverterTypeUrError,_UniffiLib.uniffi_bitkitcore_fn_method_urdecoder_receive,self._uniffi_clone_pointer(), + _UniffiConverterString.lower(frame)) + ) - If `on_device` is false, show a passphrase input UI and return - `Standard` (no passphrase), `Hidden { value }` (host-entered passphrase), - `OnDevice` (defer entry to the Trezor), or `Cancel`. + + + + + def reset(self, ) -> None: + """ + Clear all frames so the decoder can receive another message. """ - raise NotImplementedError -# TrezorUiCallback is a foreign trait so treated like a callback interface, where the -# primary use-case is the trait being implemented locally. -# It is a base-class local implementations might subclass. + _uniffi_rust_call(_UniffiLib.uniffi_bitkitcore_fn_method_urdecoder_reset,self._uniffi_clone_pointer(),) -class TrezorUiCallback(): - """ - Callback interface for handling PIN and passphrase requests from the Trezor device. - The native layer (iOS/Android) should implement this to show PIN/passphrase - input UI when the device requests it during operations like signing. + + + + +class _UniffiConverterTypeUrDecoder: + + @staticmethod + def lift(value: int): + return UrDecoder._make_instance_(value) + + @staticmethod + def check_lower(value: UrDecoder): + if not isinstance(value, UrDecoder): + raise TypeError("Expected UrDecoder instance, {} found".format(type(value).__name__)) + + @staticmethod + def lower(value: UrDecoderProtocol): + if not isinstance(value, UrDecoder): + raise TypeError("Expected UrDecoder instance, {} found".format(type(value).__name__)) + return value._uniffi_clone_pointer() + + @classmethod + def read(cls, buf: _UniffiRustBuffer): + ptr = buf.read_u64() + if ptr == 0: + raise InternalError("Raw pointer value was null") + return cls.lift(ptr) + + @classmethod + def write(cls, value: UrDecoderProtocol, buf: _UniffiRustBuffer): + buf.write_u64(cls.lower(value)) + +# Async support# RustFuturePoll values +_UNIFFI_RUST_FUTURE_POLL_READY = 0 +_UNIFFI_RUST_FUTURE_POLL_MAYBE_READY = 1 + +# Stores futures for _uniffi_continuation_callback +_UniffiContinuationHandleMap = _UniffiHandleMap() + +_UNIFFI_GLOBAL_EVENT_LOOP = None + +""" +Set the event loop to use for async functions + +This is needed if some async functions run outside of the eventloop, for example: + - A non-eventloop thread is spawned, maybe from `EventLoop.run_in_executor` or maybe from the + Rust code spawning its own thread. + - The Rust code calls an async callback method from a sync callback function, using something + like `pollster` to block on the async call. + +In this case, we need an event loop to run the Python async function, but there's no eventloop set +for the thread. Use `uniffi_set_event_loop` to force an eventloop to be used in this case. +""" +def uniffi_set_event_loop(eventloop: asyncio.BaseEventLoop): + global _UNIFFI_GLOBAL_EVENT_LOOP + _UNIFFI_GLOBAL_EVENT_LOOP = eventloop + +def _uniffi_get_event_loop(): + if _UNIFFI_GLOBAL_EVENT_LOOP is not None: + return _UNIFFI_GLOBAL_EVENT_LOOP + else: + return asyncio.get_running_loop() + +# Continuation callback for async functions +# lift the return value or error and resolve the future, causing the async function to resume. +@_UNIFFI_RUST_FUTURE_CONTINUATION_CALLBACK +def _uniffi_continuation_callback(future_ptr, poll_code): + (eventloop, future) = _UniffiContinuationHandleMap.remove(future_ptr) + eventloop.call_soon_threadsafe(_uniffi_set_future_result, future, poll_code) + +def _uniffi_set_future_result(future, poll_code): + if not future.cancelled(): + future.set_result(poll_code) + +async def _uniffi_rust_call_async(rust_future, ffi_poll, ffi_complete, ffi_free, lift_func, error_ffi_converter): + try: + eventloop = _uniffi_get_event_loop() + + # Loop and poll until we see a _UNIFFI_RUST_FUTURE_POLL_READY value + while True: + future = eventloop.create_future() + ffi_poll( + rust_future, + _uniffi_continuation_callback, + _UniffiContinuationHandleMap.insert((eventloop, future)), + ) + poll_code = await future + if poll_code == _UNIFFI_RUST_FUTURE_POLL_READY: + break + + return lift_func( + _uniffi_rust_call_with_error(error_ffi_converter, ffi_complete, rust_future) + ) + finally: + ffi_free(rust_future) + +def activities_from_json(json: "str") -> "typing.List[Activity]": + """ + Decode activities from Core's canonical backup JSON, defaulting a + missing/empty wallet id to [`DEFAULT_WALLET_ID`]. """ - def on_pin_request(self, ): - """ - Called when the device requests a PIN. + _UniffiConverterString.check_lower(json) + + return _UniffiConverterSequenceTypeActivity.lift(_uniffi_rust_call_with_error(_UniffiConverterTypeActivityError,_UniffiLib.uniffi_bitkitcore_fn_func_activities_from_json, + _UniffiConverterString.lower(json))) - Show a PIN matrix UI and return the matrix-encoded PIN string. - Return empty string to cancel. - """ - raise NotImplementedError - def on_passphrase_request(self, on_device: "bool"): - """ - Called when the device requests a passphrase. +def activities_to_json(activities: "typing.List[Activity]") -> "str": + """ + Serialize activities to Core's canonical backup JSON. + """ - If `on_device` is true, the device is asking for the passphrase to be - entered on the Trezor itself — return `PassphraseResponse::OnDevice`. + _UniffiConverterSequenceTypeActivity.check_lower(activities) + + return _UniffiConverterString.lift(_uniffi_rust_call_with_error(_UniffiConverterTypeActivityError,_UniffiLib.uniffi_bitkitcore_fn_func_activities_to_json, + _UniffiConverterSequenceTypeActivity.lower(activities))) - If `on_device` is false, show a passphrase input UI and return - `Standard` (no passphrase), `Hidden { value }` (host-entered passphrase), - `OnDevice` (defer entry to the Trezor), or `Cancel`. - """ - raise NotImplementedError -# `TrezorUiCallbackImpl` is the implementation for a Rust implemented version. -class TrezorUiCallbackImpl(): +def activity_tags_from_json(json: "str") -> "typing.List[ActivityTags]": + """ + Decode activity tags from Core's canonical backup JSON, defaulting a + missing/empty wallet id to [`DEFAULT_WALLET_ID`]. """ - Callback interface for handling PIN and passphrase requests from the Trezor device. - The native layer (iOS/Android) should implement this to show PIN/passphrase - input UI when the device requests it during operations like signing. + _UniffiConverterString.check_lower(json) + + return _UniffiConverterSequenceTypeActivityTags.lift(_uniffi_rust_call_with_error(_UniffiConverterTypeActivityError,_UniffiLib.uniffi_bitkitcore_fn_func_activity_tags_from_json, + _UniffiConverterString.lower(json))) + + +def activity_tags_to_json(tags: "typing.List[ActivityTags]") -> "str": + """ + Serialize activity tags to Core's canonical backup JSON. """ - _pointer: ctypes.c_void_p + _UniffiConverterSequenceTypeActivityTags.check_lower(tags) - def __init__(self, *args, **kwargs): - raise ValueError("This class has no default constructor") + return _UniffiConverterString.lift(_uniffi_rust_call_with_error(_UniffiConverterTypeActivityError,_UniffiLib.uniffi_bitkitcore_fn_func_activity_tags_to_json, + _UniffiConverterSequenceTypeActivityTags.lower(tags))) - def __del__(self): - # In case of partial initialization of instances. - pointer = getattr(self, "_pointer", None) - if pointer is not None: - _uniffi_rust_call(_UniffiLib.uniffi_bitkitcore_fn_free_trezoruicallback, pointer) - def _uniffi_clone_pointer(self): - return _uniffi_rust_call(_UniffiLib.uniffi_bitkitcore_fn_clone_trezoruicallback, self._pointer) +def activity_wipe_all() -> None: + _uniffi_rust_call_with_error(_UniffiConverterTypeActivityError,_UniffiLib.uniffi_bitkitcore_fn_func_activity_wipe_all,) - # Used by alternative constructors or any methods which return this type. - @classmethod - def _make_instance_(cls, pointer): - # Lightly yucky way to bypass the usual __init__ logic - # and just create a new instance with the required pointer. - inst = cls.__new__(cls) - inst._pointer = pointer - return inst +def add_pre_activity_metadata(pre_activity_metadata: "PreActivityMetadata") -> None: + _UniffiConverterTypePreActivityMetadata.check_lower(pre_activity_metadata) + + _uniffi_rust_call_with_error(_UniffiConverterTypeActivityError,_UniffiLib.uniffi_bitkitcore_fn_func_add_pre_activity_metadata, + _UniffiConverterTypePreActivityMetadata.lower(pre_activity_metadata)) - def on_pin_request(self, ) -> "str": - """ - Called when the device requests a PIN. - Show a PIN matrix UI and return the matrix-encoded PIN string. - Return empty string to cancel. - """ +def add_pre_activity_metadata_tags(wallet_id: "str",payment_id: "str",tags: "typing.List[str]") -> None: + _UniffiConverterString.check_lower(wallet_id) + + _UniffiConverterString.check_lower(payment_id) + + _UniffiConverterSequenceString.check_lower(tags) + + _uniffi_rust_call_with_error(_UniffiConverterTypeActivityError,_UniffiLib.uniffi_bitkitcore_fn_func_add_pre_activity_metadata_tags, + _UniffiConverterString.lower(wallet_id), + _UniffiConverterString.lower(payment_id), + _UniffiConverterSequenceString.lower(tags)) - return _UniffiConverterString.lift( - _uniffi_rust_call(_UniffiLib.uniffi_bitkitcore_fn_method_trezoruicallback_on_pin_request,self._uniffi_clone_pointer(),) - ) +def add_tags(wallet_id: "str",activity_id: "str",tags: "typing.List[str]") -> None: + _UniffiConverterString.check_lower(wallet_id) + + _UniffiConverterString.check_lower(activity_id) + + _UniffiConverterSequenceString.check_lower(tags) + + _uniffi_rust_call_with_error(_UniffiConverterTypeActivityError,_UniffiLib.uniffi_bitkitcore_fn_func_add_tags, + _UniffiConverterString.lower(wallet_id), + _UniffiConverterString.lower(activity_id), + _UniffiConverterSequenceString.lower(tags)) + +async def approve_pubky_auth(auth_url: "str",secret_key_hex: "str") -> None: + _UniffiConverterString.check_lower(auth_url) + + _UniffiConverterString.check_lower(secret_key_hex) + + return await _uniffi_rust_call_async( + _UniffiLib.uniffi_bitkitcore_fn_func_approve_pubky_auth( + _UniffiConverterString.lower(auth_url), + _UniffiConverterString.lower(secret_key_hex)), + _UniffiLib.ffi_bitkitcore_rust_future_poll_void, + _UniffiLib.ffi_bitkitcore_rust_future_complete_void, + _UniffiLib.ffi_bitkitcore_rust_future_free_void, + # lift function + lambda val: None, + + + # Error FFI converter +_UniffiConverterTypePubkyError, + ) +async def blocktank_remove_all_cjit_entries() -> None: + return await _uniffi_rust_call_async( + _UniffiLib.uniffi_bitkitcore_fn_func_blocktank_remove_all_cjit_entries(), + _UniffiLib.ffi_bitkitcore_rust_future_poll_void, + _UniffiLib.ffi_bitkitcore_rust_future_complete_void, + _UniffiLib.ffi_bitkitcore_rust_future_free_void, + # lift function + lambda val: None, + + + # Error FFI converter +_UniffiConverterTypeBlocktankError, - def on_passphrase_request(self, on_device: "bool") -> "PassphraseResponse": - """ - Called when the device requests a passphrase. + ) +async def blocktank_remove_all_orders() -> None: - If `on_device` is true, the device is asking for the passphrase to be - entered on the Trezor itself — return `PassphraseResponse::OnDevice`. + return await _uniffi_rust_call_async( + _UniffiLib.uniffi_bitkitcore_fn_func_blocktank_remove_all_orders(), + _UniffiLib.ffi_bitkitcore_rust_future_poll_void, + _UniffiLib.ffi_bitkitcore_rust_future_complete_void, + _UniffiLib.ffi_bitkitcore_rust_future_free_void, + # lift function + lambda val: None, + + + # Error FFI converter +_UniffiConverterTypeBlocktankError, - If `on_device` is false, show a passphrase input UI and return - `Standard` (no passphrase), `Hidden { value }` (host-entered passphrase), - `OnDevice` (defer entry to the Trezor), or `Cancel`. - """ + ) +async def blocktank_wipe_all() -> None: - _UniffiConverterBool.check_lower(on_device) + return await _uniffi_rust_call_async( + _UniffiLib.uniffi_bitkitcore_fn_func_blocktank_wipe_all(), + _UniffiLib.ffi_bitkitcore_rust_future_poll_void, + _UniffiLib.ffi_bitkitcore_rust_future_complete_void, + _UniffiLib.ffi_bitkitcore_rust_future_free_void, + # lift function + lambda val: None, - return _UniffiConverterTypePassphraseResponse.lift( - _uniffi_rust_call(_UniffiLib.uniffi_bitkitcore_fn_method_trezoruicallback_on_passphrase_request,self._uniffi_clone_pointer(), - _UniffiConverterBool.lower(on_device)) - ) + + # Error FFI converter +_UniffiConverterTypeBlocktankError, + ) +async def boltz_claim_reverse_swap(swap_id: "str",mnemonic: "str",bip39_passphrase: "typing.Optional[str]",fee_rate_sat_per_vb: "typing.Optional[float]") -> "str": + """ + Claim a reverse swap's onchain funds to its claim address, returning the + broadcast claim transaction id. Normally happens automatically via the + updates stream; exposed for manual recovery. The claim key is re-derived from + `mnemonic`. Claims are serialized per swap, so calling this while the updates + stream is auto-claiming the same swap waits for that claim and returns its + txid rather than broadcasting a second transaction. + """ + _UniffiConverterString.check_lower(swap_id) + + _UniffiConverterString.check_lower(mnemonic) + + _UniffiConverterOptionalString.check_lower(bip39_passphrase) + + _UniffiConverterOptionalDouble.check_lower(fee_rate_sat_per_vb) + + return await _uniffi_rust_call_async( + _UniffiLib.uniffi_bitkitcore_fn_func_boltz_claim_reverse_swap( + _UniffiConverterString.lower(swap_id), + _UniffiConverterString.lower(mnemonic), + _UniffiConverterOptionalString.lower(bip39_passphrase), + _UniffiConverterOptionalDouble.lower(fee_rate_sat_per_vb)), + _UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer, + _UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer, + _UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer, + # lift function + _UniffiConverterString.lift, + + # Error FFI converter +_UniffiConverterTypeBoltzError, + ) +async def boltz_create_reverse_swap(network: "BoltzNetwork",electrum_url: "str",amount_sat: "int",claim_address: "str",mnemonic: "str",bip39_passphrase: "typing.Optional[str]") -> "ReverseSwapResponse": -# Put all the bits inside a class to keep the top-level namespace clean -class _UniffiTraitImplTrezorUiCallback: - # For each method, generate a callback function to pass to Rust + """ + Create a reverse swap (Lightning -> onchain). - @_UNIFFI_CALLBACK_INTERFACE_TREZOR_UI_CALLBACK_METHOD0 - def on_pin_request( - uniffi_handle, - uniffi_out_return, - uniffi_call_status_ptr, - ): - uniffi_obj = _UniffiConverterTypeTrezorUiCallback._handle_map.get(uniffi_handle) - def make_call(): - args = () - method = uniffi_obj.on_pin_request - return method(*args) + The caller pays the returned hold invoice from its Lightning node; + `claim_address` is the onchain address the received funds are claimed to. + The claim key and preimage are derived deterministically from `mnemonic` + (only the derivation index is persisted, never the secrets) so the claim can + be made automatically once Boltz locks the funds. `bip39_passphrase` must + match the wallet's, or claims will derive the wrong key. + """ + _UniffiConverterTypeBoltzNetwork.check_lower(network) + + _UniffiConverterString.check_lower(electrum_url) + + _UniffiConverterUInt64.check_lower(amount_sat) + + _UniffiConverterString.check_lower(claim_address) + + _UniffiConverterString.check_lower(mnemonic) + + _UniffiConverterOptionalString.check_lower(bip39_passphrase) + + return await _uniffi_rust_call_async( + _UniffiLib.uniffi_bitkitcore_fn_func_boltz_create_reverse_swap( + _UniffiConverterTypeBoltzNetwork.lower(network), + _UniffiConverterString.lower(electrum_url), + _UniffiConverterUInt64.lower(amount_sat), + _UniffiConverterString.lower(claim_address), + _UniffiConverterString.lower(mnemonic), + _UniffiConverterOptionalString.lower(bip39_passphrase)), + _UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer, + _UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer, + _UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer, + # lift function + _UniffiConverterTypeReverseSwapResponse.lift, - def write_return_value(v): - uniffi_out_return[0] = _UniffiConverterString.lower(v) - _uniffi_trait_interface_call( - uniffi_call_status_ptr.contents, - make_call, - write_return_value, - ) + # Error FFI converter +_UniffiConverterTypeBoltzError, - @_UNIFFI_CALLBACK_INTERFACE_TREZOR_UI_CALLBACK_METHOD1 - def on_passphrase_request( - uniffi_handle, - on_device, - uniffi_out_return, - uniffi_call_status_ptr, - ): - uniffi_obj = _UniffiConverterTypeTrezorUiCallback._handle_map.get(uniffi_handle) - def make_call(): - args = (_UniffiConverterBool.lift(on_device), ) - method = uniffi_obj.on_passphrase_request - return method(*args) + ) +async def boltz_create_submarine_swap(network: "BoltzNetwork",electrum_url: "str",invoice: "str",mnemonic: "str",bip39_passphrase: "typing.Optional[str]") -> "SubmarineSwapResponse": + + """ + Create a submarine swap (onchain -> Lightning). + + `invoice` is a BOLT11 invoice the caller's Lightning node generated. The + caller funds the returned lockup address from its onchain wallet. The refund + key is derived deterministically from `mnemonic` (only the derivation index + is persisted, never the key), and the swap is tracked if an updates stream is + running. `bip39_passphrase` must match the wallet's, or refunds will derive + the wrong key. + """ + _UniffiConverterTypeBoltzNetwork.check_lower(network) + + _UniffiConverterString.check_lower(electrum_url) + + _UniffiConverterString.check_lower(invoice) + + _UniffiConverterString.check_lower(mnemonic) + + _UniffiConverterOptionalString.check_lower(bip39_passphrase) + + return await _uniffi_rust_call_async( + _UniffiLib.uniffi_bitkitcore_fn_func_boltz_create_submarine_swap( + _UniffiConverterTypeBoltzNetwork.lower(network), + _UniffiConverterString.lower(electrum_url), + _UniffiConverterString.lower(invoice), + _UniffiConverterString.lower(mnemonic), + _UniffiConverterOptionalString.lower(bip39_passphrase)), + _UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer, + _UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer, + _UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer, + # lift function + _UniffiConverterTypeSubmarineSwapResponse.lift, - def write_return_value(v): - uniffi_out_return[0] = _UniffiConverterTypePassphraseResponse.lower(v) - _uniffi_trait_interface_call( - uniffi_call_status_ptr.contents, - make_call, - write_return_value, - ) - - @_UNIFFI_CALLBACK_INTERFACE_FREE - def _uniffi_free(uniffi_handle): - _UniffiConverterTypeTrezorUiCallback._handle_map.remove(uniffi_handle) + # Error FFI converter +_UniffiConverterTypeBoltzError, - # Generate the FFI VTable. This has a field for each callback interface method. - _uniffi_vtable = _UniffiVTableCallbackInterfaceTrezorUiCallback( - on_pin_request, - on_passphrase_request, - _uniffi_free ) - # Send Rust a pointer to the VTable. Note: this means we need to keep the struct alive forever, - # or else bad things will happen when Rust tries to access it. - _UniffiLib.uniffi_bitkitcore_fn_init_callback_vtable_trezoruicallback(ctypes.byref(_uniffi_vtable)) - +async def boltz_get_reverse_limits(network: "BoltzNetwork") -> "BoltzPairInfo": + """ + Fetch fees and limits for reverse swaps (Lightning -> onchain). + """ -class _UniffiConverterTypeTrezorUiCallback: - _handle_map = _UniffiHandleMap() + _UniffiConverterTypeBoltzNetwork.check_lower(network) + + return await _uniffi_rust_call_async( + _UniffiLib.uniffi_bitkitcore_fn_func_boltz_get_reverse_limits( + _UniffiConverterTypeBoltzNetwork.lower(network)), + _UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer, + _UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer, + _UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer, + # lift function + _UniffiConverterTypeBoltzPairInfo.lift, + + # Error FFI converter +_UniffiConverterTypeBoltzError, - @staticmethod - def lift(value: int): - return TrezorUiCallbackImpl._make_instance_(value) + ) +async def boltz_get_submarine_limits(network: "BoltzNetwork") -> "BoltzPairInfo": - @staticmethod - def check_lower(value: TrezorUiCallback): - pass + """ + Fetch fees and limits for submarine swaps (onchain -> Lightning). + """ - @staticmethod - def lower(value: TrezorUiCallbackProtocol): - return _UniffiConverterTypeTrezorUiCallback._handle_map.insert(value) + _UniffiConverterTypeBoltzNetwork.check_lower(network) + + return await _uniffi_rust_call_async( + _UniffiLib.uniffi_bitkitcore_fn_func_boltz_get_submarine_limits( + _UniffiConverterTypeBoltzNetwork.lower(network)), + _UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer, + _UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer, + _UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer, + # lift function + _UniffiConverterTypeBoltzPairInfo.lift, + + # Error FFI converter +_UniffiConverterTypeBoltzError, - @classmethod - def read(cls, buf: _UniffiRustBuffer): - ptr = buf.read_u64() - if ptr == 0: - raise InternalError("Raw pointer value was null") - return cls.lift(ptr) + ) +async def boltz_get_swap(swap_id: "str") -> "typing.Optional[BoltzSwap]": - @classmethod - def write(cls, value: TrezorUiCallbackProtocol, buf: _UniffiRustBuffer): - buf.write_u64(cls.lower(value)) -class UrDecoderProtocol(typing.Protocol): """ - Stateful decoder for single-part and animated multipart UR QR scans. + Fetch a single swap by id. """ - def receive(self, frame: "str"): - """ - Adds one UR fragment and returns the current decoding status. - """ + _UniffiConverterString.check_lower(swap_id) + + return await _uniffi_rust_call_async( + _UniffiLib.uniffi_bitkitcore_fn_func_boltz_get_swap( + _UniffiConverterString.lower(swap_id)), + _UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer, + _UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer, + _UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer, + # lift function + _UniffiConverterOptionalTypeBoltzSwap.lift, + + # Error FFI converter +_UniffiConverterTypeBoltzError, - raise NotImplementedError - def reset(self, ): - """ - Clear all frames so the decoder can receive another message. - """ + ) +async def boltz_list_pending_swaps() -> "typing.List[BoltzSwap]": - raise NotImplementedError -# UrDecoder is a Rust-only trait - it's a wrapper around a Rust implementation. -class UrDecoder(): """ - Stateful decoder for single-part and animated multipart UR QR scans. + List swaps that have not reached a terminal state (for recovery/resume). """ - _pointer: ctypes.c_void_p - def __init__(self, ): - self._pointer = _uniffi_rust_call(_UniffiLib.uniffi_bitkitcore_fn_constructor_urdecoder_new,) + return await _uniffi_rust_call_async( + _UniffiLib.uniffi_bitkitcore_fn_func_boltz_list_pending_swaps(), + _UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer, + _UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer, + _UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer, + # lift function + _UniffiConverterSequenceTypeBoltzSwap.lift, + + # Error FFI converter +_UniffiConverterTypeBoltzError, - def __del__(self): - # In case of partial initialization of instances. - pointer = getattr(self, "_pointer", None) - if pointer is not None: - _uniffi_rust_call(_UniffiLib.uniffi_bitkitcore_fn_free_urdecoder, pointer) + ) +async def boltz_list_swaps() -> "typing.List[BoltzSwap]": - def _uniffi_clone_pointer(self): - return _uniffi_rust_call(_UniffiLib.uniffi_bitkitcore_fn_clone_urdecoder, self._pointer) + """ + List every persisted swap, newest first. + """ - # Used by alternative constructors or any methods which return this type. - @classmethod - def _make_instance_(cls, pointer): - # Lightly yucky way to bypass the usual __init__ logic - # and just create a new instance with the required pointer. - inst = cls.__new__(cls) - inst._pointer = pointer - return inst + return await _uniffi_rust_call_async( + _UniffiLib.uniffi_bitkitcore_fn_func_boltz_list_swaps(), + _UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer, + _UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer, + _UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer, + # lift function + _UniffiConverterSequenceTypeBoltzSwap.lift, + + # Error FFI converter +_UniffiConverterTypeBoltzError, + ) +async def boltz_refund_submarine_swap(swap_id: "str",refund_address: "str",mnemonic: "str",bip39_passphrase: "typing.Optional[str]",fee_rate_sat_per_vb: "typing.Optional[float]") -> "str": - def receive(self, frame: "str") -> "UrDecoderStatus": - """ - Adds one UR fragment and returns the current decoding status. - """ + """ + Refund a submarine swap's locked funds to `refund_address`, returning the + broadcast refund transaction id. Used when Boltz fails to pay the invoice or + the swap expires. The refund key is re-derived from `mnemonic`. Refunds are + serialized per swap, so two concurrent calls cannot both broadcast: the second + waits for the first and returns its txid. + """ - _UniffiConverterString.check_lower(frame) + _UniffiConverterString.check_lower(swap_id) + + _UniffiConverterString.check_lower(refund_address) + + _UniffiConverterString.check_lower(mnemonic) + + _UniffiConverterOptionalString.check_lower(bip39_passphrase) + + _UniffiConverterOptionalDouble.check_lower(fee_rate_sat_per_vb) + + return await _uniffi_rust_call_async( + _UniffiLib.uniffi_bitkitcore_fn_func_boltz_refund_submarine_swap( + _UniffiConverterString.lower(swap_id), + _UniffiConverterString.lower(refund_address), + _UniffiConverterString.lower(mnemonic), + _UniffiConverterOptionalString.lower(bip39_passphrase), + _UniffiConverterOptionalDouble.lower(fee_rate_sat_per_vb)), + _UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer, + _UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer, + _UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer, + # lift function + _UniffiConverterString.lift, - return _UniffiConverterTypeUrDecoderStatus.lift( - _uniffi_rust_call_with_error(_UniffiConverterTypeUrError,_UniffiLib.uniffi_bitkitcore_fn_method_urdecoder_receive,self._uniffi_clone_pointer(), - _UniffiConverterString.lower(frame)) - ) + # Error FFI converter +_UniffiConverterTypeBoltzError, + ) +async def boltz_start_swap_updates(network: "BoltzNetwork",listener: "BoltzEventListener",mnemonic: "str",bip39_passphrase: "typing.Optional[str]",fee_rate_sat_per_vb: "typing.Optional[float]",accept_zero_conf: "bool") -> None: + """ + Open a Boltz WebSocket for `network`, subscribe to all pending swaps, and + drive their lifecycle (auto-claiming reverse swaps) until stopped. Replaces + any previously running updates stream (only one network is tracked at a + time). `mnemonic` is held in memory for the lifetime of the stream so + confirmed reverse swaps can be auto-claimed; it is never persisted. Events + are delivered to `listener`. + `fee_rate_sat_per_vb` is the fee rate used for automatic claim transactions. + Bitkit owns fee estimation and should pass its current recommended rate; when + `None`, a conservative built-in default is used. To auto-claim at an updated + fee rate, call this again (it restarts the stream). + `accept_zero_conf` claims reverse swaps as soon as Boltz's lockup enters the + mempool instead of waiting for its confirmation. That reveals the preimage + against an unconfirmed lockup: if the lockup were replaced before + confirming, the user would be debited on Lightning without receiving + onchain funds. Pass `false` to keep the confirmation-gated default. + """ - def reset(self, ) -> None: - """ - Clear all frames so the decoder can receive another message. - """ + _UniffiConverterTypeBoltzNetwork.check_lower(network) + + _UniffiConverterTypeBoltzEventListener.check_lower(listener) + + _UniffiConverterString.check_lower(mnemonic) + + _UniffiConverterOptionalString.check_lower(bip39_passphrase) + + _UniffiConverterOptionalDouble.check_lower(fee_rate_sat_per_vb) + + _UniffiConverterBool.check_lower(accept_zero_conf) + + return await _uniffi_rust_call_async( + _UniffiLib.uniffi_bitkitcore_fn_func_boltz_start_swap_updates( + _UniffiConverterTypeBoltzNetwork.lower(network), + _UniffiConverterTypeBoltzEventListener.lower(listener), + _UniffiConverterString.lower(mnemonic), + _UniffiConverterOptionalString.lower(bip39_passphrase), + _UniffiConverterOptionalDouble.lower(fee_rate_sat_per_vb), + _UniffiConverterBool.lower(accept_zero_conf)), + _UniffiLib.ffi_bitkitcore_rust_future_poll_void, + _UniffiLib.ffi_bitkitcore_rust_future_complete_void, + _UniffiLib.ffi_bitkitcore_rust_future_free_void, + # lift function + lambda val: None, + + + # Error FFI converter +_UniffiConverterTypeBoltzError, + + ) +async def boltz_stop_swap_updates() -> None: - _uniffi_rust_call(_UniffiLib.uniffi_bitkitcore_fn_method_urdecoder_reset,self._uniffi_clone_pointer(),) + """ + Stop the running Boltz updates stream, if any. + """ + return await _uniffi_rust_call_async( + _UniffiLib.uniffi_bitkitcore_fn_func_boltz_stop_swap_updates(), + _UniffiLib.ffi_bitkitcore_rust_future_poll_void, + _UniffiLib.ffi_bitkitcore_rust_future_complete_void, + _UniffiLib.ffi_bitkitcore_rust_future_free_void, + # lift function + lambda val: None, + + + # Error FFI converter + None, + ) +async def broadcast_sweep_transaction(psbt: "str",mnemonic_phrase: "str",network: "typing.Optional[Network]",bip39_passphrase: "typing.Optional[str]",electrum_url: "str") -> "SweepResult": + _UniffiConverterString.check_lower(psbt) + + _UniffiConverterString.check_lower(mnemonic_phrase) + + _UniffiConverterOptionalTypeNetwork.check_lower(network) + + _UniffiConverterOptionalString.check_lower(bip39_passphrase) + + _UniffiConverterString.check_lower(electrum_url) + + return await _uniffi_rust_call_async( + _UniffiLib.uniffi_bitkitcore_fn_func_broadcast_sweep_transaction( + _UniffiConverterString.lower(psbt), + _UniffiConverterString.lower(mnemonic_phrase), + _UniffiConverterOptionalTypeNetwork.lower(network), + _UniffiConverterOptionalString.lower(bip39_passphrase), + _UniffiConverterString.lower(electrum_url)), + _UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer, + _UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer, + _UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer, + # lift function + _UniffiConverterTypeSweepResult.lift, + + # Error FFI converter +_UniffiConverterTypeSweepError, + ) +def calculate_channel_liquidity_options(params: "ChannelLiquidityParams") -> "ChannelLiquidityOptions": + _UniffiConverterTypeChannelLiquidityParams.check_lower(params) + + return _UniffiConverterTypeChannelLiquidityOptions.lift(_uniffi_rust_call(_UniffiLib.uniffi_bitkitcore_fn_func_calculate_channel_liquidity_options, + _UniffiConverterTypeChannelLiquidityParams.lower(params))) -class _UniffiConverterTypeUrDecoder: +async def cancel_pubky_auth() -> None: - @staticmethod - def lift(value: int): - return UrDecoder._make_instance_(value) + return await _uniffi_rust_call_async( + _UniffiLib.uniffi_bitkitcore_fn_func_cancel_pubky_auth(), + _UniffiLib.ffi_bitkitcore_rust_future_poll_void, + _UniffiLib.ffi_bitkitcore_rust_future_complete_void, + _UniffiLib.ffi_bitkitcore_rust_future_free_void, + # lift function + lambda val: None, + + + # Error FFI converter +_UniffiConverterTypePubkyError, - @staticmethod - def check_lower(value: UrDecoder): - if not isinstance(value, UrDecoder): - raise TypeError("Expected UrDecoder instance, {} found".format(type(value).__name__)) + ) +async def check_sweepable_balances(mnemonic_phrase: "str",network: "typing.Optional[Network]",bip39_passphrase: "typing.Optional[str]",electrum_url: "str") -> "SweepableBalances": - @staticmethod - def lower(value: UrDecoderProtocol): - if not isinstance(value, UrDecoder): - raise TypeError("Expected UrDecoder instance, {} found".format(type(value).__name__)) - return value._uniffi_clone_pointer() + _UniffiConverterString.check_lower(mnemonic_phrase) + + _UniffiConverterOptionalTypeNetwork.check_lower(network) + + _UniffiConverterOptionalString.check_lower(bip39_passphrase) + + _UniffiConverterString.check_lower(electrum_url) + + return await _uniffi_rust_call_async( + _UniffiLib.uniffi_bitkitcore_fn_func_check_sweepable_balances( + _UniffiConverterString.lower(mnemonic_phrase), + _UniffiConverterOptionalTypeNetwork.lower(network), + _UniffiConverterOptionalString.lower(bip39_passphrase), + _UniffiConverterString.lower(electrum_url)), + _UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer, + _UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer, + _UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer, + # lift function + _UniffiConverterTypeSweepableBalances.lift, + + # Error FFI converter +_UniffiConverterTypeSweepError, - @classmethod - def read(cls, buf: _UniffiRustBuffer): - ptr = buf.read_u64() - if ptr == 0: - raise InternalError("Raw pointer value was null") - return cls.lift(ptr) + ) - @classmethod - def write(cls, value: UrDecoderProtocol, buf: _UniffiRustBuffer): - buf.write_u64(cls.lower(value)) +def closed_channels_from_json(json: "str") -> "typing.List[ClosedChannelDetails]": + """ + Decode closed channels from Core's canonical backup JSON. + """ -# Async support# RustFuturePoll values -_UNIFFI_RUST_FUTURE_POLL_READY = 0 -_UNIFFI_RUST_FUTURE_POLL_MAYBE_READY = 1 + _UniffiConverterString.check_lower(json) + + return _UniffiConverterSequenceTypeClosedChannelDetails.lift(_uniffi_rust_call_with_error(_UniffiConverterTypeActivityError,_UniffiLib.uniffi_bitkitcore_fn_func_closed_channels_from_json, + _UniffiConverterString.lower(json))) -# Stores futures for _uniffi_continuation_callback -_UniffiContinuationHandleMap = _UniffiHandleMap() -_UNIFFI_GLOBAL_EVENT_LOOP = None +def closed_channels_to_json(channels: "typing.List[ClosedChannelDetails]") -> "str": + """ + Serialize closed channels to Core's canonical backup JSON. Closed channels + are not wallet-scoped, so no wallet-id normalization is applied. + """ -""" -Set the event loop to use for async functions + _UniffiConverterSequenceTypeClosedChannelDetails.check_lower(channels) + + return _UniffiConverterString.lift(_uniffi_rust_call_with_error(_UniffiConverterTypeActivityError,_UniffiLib.uniffi_bitkitcore_fn_func_closed_channels_to_json, + _UniffiConverterSequenceTypeClosedChannelDetails.lower(channels))) -This is needed if some async functions run outside of the eventloop, for example: - - A non-eventloop thread is spawned, maybe from `EventLoop.run_in_executor` or maybe from the - Rust code spawning its own thread. - - The Rust code calls an async callback method from a sync callback function, using something - like `pollster` to block on the async call. +async def complete_pubky_auth() -> "str": -In this case, we need an event loop to run the Python async function, but there's no eventloop set -for the thread. Use `uniffi_set_event_loop` to force an eventloop to be used in this case. -""" -def uniffi_set_event_loop(eventloop: asyncio.BaseEventLoop): - global _UNIFFI_GLOBAL_EVENT_LOOP - _UNIFFI_GLOBAL_EVENT_LOOP = eventloop + return await _uniffi_rust_call_async( + _UniffiLib.uniffi_bitkitcore_fn_func_complete_pubky_auth(), + _UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer, + _UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer, + _UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer, + # lift function + _UniffiConverterString.lift, + + # Error FFI converter +_UniffiConverterTypePubkyError, -def _uniffi_get_event_loop(): - if _UNIFFI_GLOBAL_EVENT_LOOP is not None: - return _UNIFFI_GLOBAL_EVENT_LOOP - else: - return asyncio.get_running_loop() + ) -# Continuation callback for async functions -# lift the return value or error and resolve the future, causing the async function to resume. -@_UNIFFI_RUST_FUTURE_CONTINUATION_CALLBACK -def _uniffi_continuation_callback(future_ptr, poll_code): - (eventloop, future) = _UniffiContinuationHandleMap.remove(future_ptr) - eventloop.call_soon_threadsafe(_uniffi_set_future_result, future, poll_code) +def create_channel_request_url(k1: "str",callback: "str",local_node_id: "str",is_private: "bool",cancel: "bool") -> "str": + _UniffiConverterString.check_lower(k1) + + _UniffiConverterString.check_lower(callback) + + _UniffiConverterString.check_lower(local_node_id) + + _UniffiConverterBool.check_lower(is_private) + + _UniffiConverterBool.check_lower(cancel) + + return _UniffiConverterString.lift(_uniffi_rust_call_with_error(_UniffiConverterTypeLnurlError,_UniffiLib.uniffi_bitkitcore_fn_func_create_channel_request_url, + _UniffiConverterString.lower(k1), + _UniffiConverterString.lower(callback), + _UniffiConverterString.lower(local_node_id), + _UniffiConverterBool.lower(is_private), + _UniffiConverterBool.lower(cancel))) -def _uniffi_set_future_result(future, poll_code): - if not future.cancelled(): - future.set_result(poll_code) +async def create_cjit_entry(channel_size_sat: "int",invoice_sat: "int",invoice_description: "str",node_id: "str",channel_expiry_weeks: "int",options: "typing.Optional[CreateCjitOptions]") -> "IcJitEntry": -async def _uniffi_rust_call_async(rust_future, ffi_poll, ffi_complete, ffi_free, lift_func, error_ffi_converter): - try: - eventloop = _uniffi_get_event_loop() + _UniffiConverterUInt64.check_lower(channel_size_sat) + + _UniffiConverterUInt64.check_lower(invoice_sat) + + _UniffiConverterString.check_lower(invoice_description) + + _UniffiConverterString.check_lower(node_id) + + _UniffiConverterUInt32.check_lower(channel_expiry_weeks) + + _UniffiConverterOptionalTypeCreateCjitOptions.check_lower(options) + + return await _uniffi_rust_call_async( + _UniffiLib.uniffi_bitkitcore_fn_func_create_cjit_entry( + _UniffiConverterUInt64.lower(channel_size_sat), + _UniffiConverterUInt64.lower(invoice_sat), + _UniffiConverterString.lower(invoice_description), + _UniffiConverterString.lower(node_id), + _UniffiConverterUInt32.lower(channel_expiry_weeks), + _UniffiConverterOptionalTypeCreateCjitOptions.lower(options)), + _UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer, + _UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer, + _UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer, + # lift function + _UniffiConverterTypeIcJitEntry.lift, + + # Error FFI converter +_UniffiConverterTypeBlocktankError, - # Loop and poll until we see a _UNIFFI_RUST_FUTURE_POLL_READY value - while True: - future = eventloop.create_future() - ffi_poll( - rust_future, - _uniffi_continuation_callback, - _UniffiContinuationHandleMap.insert((eventloop, future)), - ) - poll_code = await future - if poll_code == _UNIFFI_RUST_FUTURE_POLL_READY: - break + ) +async def create_order(lsp_balance_sat: "int",channel_expiry_weeks: "int",options: "typing.Optional[CreateOrderOptions]") -> "IBtOrder": - return lift_func( - _uniffi_rust_call_with_error(error_ffi_converter, ffi_complete, rust_future) - ) - finally: - ffi_free(rust_future) + _UniffiConverterUInt64.check_lower(lsp_balance_sat) + + _UniffiConverterUInt32.check_lower(channel_expiry_weeks) + + _UniffiConverterOptionalTypeCreateOrderOptions.check_lower(options) + + return await _uniffi_rust_call_async( + _UniffiLib.uniffi_bitkitcore_fn_func_create_order( + _UniffiConverterUInt64.lower(lsp_balance_sat), + _UniffiConverterUInt32.lower(channel_expiry_weeks), + _UniffiConverterOptionalTypeCreateOrderOptions.lower(options)), + _UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer, + _UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer, + _UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer, + # lift function + _UniffiConverterTypeIBtOrder.lift, + + # Error FFI converter +_UniffiConverterTypeBlocktankError, -def activities_from_json(json: "str") -> "typing.List[Activity]": - """ - Decode activities from Core's canonical backup JSON, defaulting a - missing/empty wallet id to [`DEFAULT_WALLET_ID`]. - """ + ) - _UniffiConverterString.check_lower(json) +def create_withdraw_callback_url(k1: "str",callback: "str",payment_request: "str") -> "str": + _UniffiConverterString.check_lower(k1) - return _UniffiConverterSequenceTypeActivity.lift(_uniffi_rust_call_with_error(_UniffiConverterTypeActivityError,_UniffiLib.uniffi_bitkitcore_fn_func_activities_from_json, - _UniffiConverterString.lower(json))) - - -def activities_to_json(activities: "typing.List[Activity]") -> "str": - """ - Serialize activities to Core's canonical backup JSON. - """ - - _UniffiConverterSequenceTypeActivity.check_lower(activities) + _UniffiConverterString.check_lower(callback) - return _UniffiConverterString.lift(_uniffi_rust_call_with_error(_UniffiConverterTypeActivityError,_UniffiLib.uniffi_bitkitcore_fn_func_activities_to_json, - _UniffiConverterSequenceTypeActivity.lower(activities))) - - -def activity_tags_from_json(json: "str") -> "typing.List[ActivityTags]": - """ - Decode activity tags from Core's canonical backup JSON, defaulting a - missing/empty wallet id to [`DEFAULT_WALLET_ID`]. - """ - - _UniffiConverterString.check_lower(json) + _UniffiConverterString.check_lower(payment_request) - return _UniffiConverterSequenceTypeActivityTags.lift(_uniffi_rust_call_with_error(_UniffiConverterTypeActivityError,_UniffiLib.uniffi_bitkitcore_fn_func_activity_tags_from_json, - _UniffiConverterString.lower(json))) - + return _UniffiConverterString.lift(_uniffi_rust_call_with_error(_UniffiConverterTypeLnurlError,_UniffiLib.uniffi_bitkitcore_fn_func_create_withdraw_callback_url, + _UniffiConverterString.lower(k1), + _UniffiConverterString.lower(callback), + _UniffiConverterString.lower(payment_request))) -def activity_tags_to_json(tags: "typing.List[ActivityTags]") -> "str": - """ - Serialize activity tags to Core's canonical backup JSON. - """ +async def decode(invoice: "str") -> "Scanner": - _UniffiConverterSequenceTypeActivityTags.check_lower(tags) + _UniffiConverterString.check_lower(invoice) - return _UniffiConverterString.lift(_uniffi_rust_call_with_error(_UniffiConverterTypeActivityError,_UniffiLib.uniffi_bitkitcore_fn_func_activity_tags_to_json, - _UniffiConverterSequenceTypeActivityTags.lower(tags))) + return await _uniffi_rust_call_async( + _UniffiLib.uniffi_bitkitcore_fn_func_decode( + _UniffiConverterString.lower(invoice)), + _UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer, + _UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer, + _UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer, + # lift function + _UniffiConverterTypeScanner.lift, + + # Error FFI converter +_UniffiConverterTypeDecodingError, + ) -def activity_wipe_all() -> None: - _uniffi_rust_call_with_error(_UniffiConverterTypeActivityError,_UniffiLib.uniffi_bitkitcore_fn_func_activity_wipe_all,) +def delete_activities_by_wallet_id(wallet_id: "str") -> "int": + _UniffiConverterString.check_lower(wallet_id) + + return _UniffiConverterUInt32.lift(_uniffi_rust_call_with_error(_UniffiConverterTypeActivityError,_UniffiLib.uniffi_bitkitcore_fn_func_delete_activities_by_wallet_id, + _UniffiConverterString.lower(wallet_id))) -def add_pre_activity_metadata(pre_activity_metadata: "PreActivityMetadata") -> None: - _UniffiConverterTypePreActivityMetadata.check_lower(pre_activity_metadata) +def delete_activity_by_id(wallet_id: "str",activity_id: "str") -> "bool": + _UniffiConverterString.check_lower(wallet_id) - _uniffi_rust_call_with_error(_UniffiConverterTypeActivityError,_UniffiLib.uniffi_bitkitcore_fn_func_add_pre_activity_metadata, - _UniffiConverterTypePreActivityMetadata.lower(pre_activity_metadata)) + _UniffiConverterString.check_lower(activity_id) + + return _UniffiConverterBool.lift(_uniffi_rust_call_with_error(_UniffiConverterTypeActivityError,_UniffiLib.uniffi_bitkitcore_fn_func_delete_activity_by_id, + _UniffiConverterString.lower(wallet_id), + _UniffiConverterString.lower(activity_id))) -def add_pre_activity_metadata_tags(wallet_id: "str",payment_id: "str",tags: "typing.List[str]") -> None: +def delete_pre_activity_metadata(wallet_id: "str",payment_id: "str") -> None: _UniffiConverterString.check_lower(wallet_id) _UniffiConverterString.check_lower(payment_id) - _UniffiConverterSequenceString.check_lower(tags) - - _uniffi_rust_call_with_error(_UniffiConverterTypeActivityError,_UniffiLib.uniffi_bitkitcore_fn_func_add_pre_activity_metadata_tags, + _uniffi_rust_call_with_error(_UniffiConverterTypeActivityError,_UniffiLib.uniffi_bitkitcore_fn_func_delete_pre_activity_metadata, _UniffiConverterString.lower(wallet_id), - _UniffiConverterString.lower(payment_id), - _UniffiConverterSequenceString.lower(tags)) + _UniffiConverterString.lower(payment_id)) -def add_tags(wallet_id: "str",activity_id: "str",tags: "typing.List[str]") -> None: +def delete_transaction_details(wallet_id: "str",tx_id: "str") -> "bool": _UniffiConverterString.check_lower(wallet_id) - _UniffiConverterString.check_lower(activity_id) - - _UniffiConverterSequenceString.check_lower(tags) + _UniffiConverterString.check_lower(tx_id) - _uniffi_rust_call_with_error(_UniffiConverterTypeActivityError,_UniffiLib.uniffi_bitkitcore_fn_func_add_tags, + return _UniffiConverterBool.lift(_uniffi_rust_call_with_error(_UniffiConverterTypeActivityError,_UniffiLib.uniffi_bitkitcore_fn_func_delete_transaction_details, _UniffiConverterString.lower(wallet_id), - _UniffiConverterString.lower(activity_id), - _UniffiConverterSequenceString.lower(tags)) + _UniffiConverterString.lower(tx_id))) -async def approve_pubky_auth(auth_url: "str",secret_key_hex: "str") -> None: - _UniffiConverterString.check_lower(auth_url) +def derive_bitcoin_address(mnemonic_phrase: "str",derivation_path_str: "typing.Optional[str]",network: "typing.Optional[Network]",bip39_passphrase: "typing.Optional[str]") -> "GetAddressResponse": + _UniffiConverterString.check_lower(mnemonic_phrase) - _UniffiConverterString.check_lower(secret_key_hex) + _UniffiConverterOptionalString.check_lower(derivation_path_str) - return await _uniffi_rust_call_async( - _UniffiLib.uniffi_bitkitcore_fn_func_approve_pubky_auth( - _UniffiConverterString.lower(auth_url), - _UniffiConverterString.lower(secret_key_hex)), - _UniffiLib.ffi_bitkitcore_rust_future_poll_void, - _UniffiLib.ffi_bitkitcore_rust_future_complete_void, - _UniffiLib.ffi_bitkitcore_rust_future_free_void, - # lift function - lambda val: None, - - - # Error FFI converter -_UniffiConverterTypePubkyError, - - ) -async def blocktank_remove_all_cjit_entries() -> None: - - return await _uniffi_rust_call_async( - _UniffiLib.uniffi_bitkitcore_fn_func_blocktank_remove_all_cjit_entries(), - _UniffiLib.ffi_bitkitcore_rust_future_poll_void, - _UniffiLib.ffi_bitkitcore_rust_future_complete_void, - _UniffiLib.ffi_bitkitcore_rust_future_free_void, - # lift function - lambda val: None, - - - # Error FFI converter -_UniffiConverterTypeBlocktankError, - - ) -async def blocktank_remove_all_orders() -> None: - - return await _uniffi_rust_call_async( - _UniffiLib.uniffi_bitkitcore_fn_func_blocktank_remove_all_orders(), - _UniffiLib.ffi_bitkitcore_rust_future_poll_void, - _UniffiLib.ffi_bitkitcore_rust_future_complete_void, - _UniffiLib.ffi_bitkitcore_rust_future_free_void, - # lift function - lambda val: None, - - - # Error FFI converter -_UniffiConverterTypeBlocktankError, - - ) -async def blocktank_wipe_all() -> None: + _UniffiConverterOptionalTypeNetwork.check_lower(network) + + _UniffiConverterOptionalString.check_lower(bip39_passphrase) + + return _UniffiConverterTypeGetAddressResponse.lift(_uniffi_rust_call_with_error(_UniffiConverterTypeAddressError,_UniffiLib.uniffi_bitkitcore_fn_func_derive_bitcoin_address, + _UniffiConverterString.lower(mnemonic_phrase), + _UniffiConverterOptionalString.lower(derivation_path_str), + _UniffiConverterOptionalTypeNetwork.lower(network), + _UniffiConverterOptionalString.lower(bip39_passphrase))) - return await _uniffi_rust_call_async( - _UniffiLib.uniffi_bitkitcore_fn_func_blocktank_wipe_all(), - _UniffiLib.ffi_bitkitcore_rust_future_poll_void, - _UniffiLib.ffi_bitkitcore_rust_future_complete_void, - _UniffiLib.ffi_bitkitcore_rust_future_free_void, - # lift function - lambda val: None, - - - # Error FFI converter -_UniffiConverterTypeBlocktankError, - ) -async def boltz_claim_reverse_swap(swap_id: "str",mnemonic: "str",bip39_passphrase: "typing.Optional[str]",fee_rate_sat_per_vb: "typing.Optional[float]") -> "str": +def derive_bitcoin_addresses(mnemonic_phrase: "str",derivation_path_str: "typing.Optional[str]",network: "typing.Optional[Network]",bip39_passphrase: "typing.Optional[str]",is_change: "typing.Optional[bool]",start_index: "typing.Optional[int]",count: "typing.Optional[int]") -> "GetAddressesResponse": + _UniffiConverterString.check_lower(mnemonic_phrase) + + _UniffiConverterOptionalString.check_lower(derivation_path_str) + + _UniffiConverterOptionalTypeNetwork.check_lower(network) + + _UniffiConverterOptionalString.check_lower(bip39_passphrase) + + _UniffiConverterOptionalBool.check_lower(is_change) + + _UniffiConverterOptionalUInt32.check_lower(start_index) + + _UniffiConverterOptionalUInt32.check_lower(count) + + return _UniffiConverterTypeGetAddressesResponse.lift(_uniffi_rust_call_with_error(_UniffiConverterTypeAddressError,_UniffiLib.uniffi_bitkitcore_fn_func_derive_bitcoin_addresses, + _UniffiConverterString.lower(mnemonic_phrase), + _UniffiConverterOptionalString.lower(derivation_path_str), + _UniffiConverterOptionalTypeNetwork.lower(network), + _UniffiConverterOptionalString.lower(bip39_passphrase), + _UniffiConverterOptionalBool.lower(is_change), + _UniffiConverterOptionalUInt32.lower(start_index), + _UniffiConverterOptionalUInt32.lower(count))) - """ - Claim a reverse swap's onchain funds to its claim address, returning the - broadcast claim transaction id. Normally happens automatically via the - updates stream; exposed for manual recovery. The claim key is re-derived from - `mnemonic`. Claims are serialized per swap, so calling this while the updates - stream is auto-claiming the same swap waits for that claim and returns its - txid rather than broadcasting a second transaction. - """ - _UniffiConverterString.check_lower(swap_id) +def derive_onchain_descriptor(mnemonic_phrase: "str",network: "Network",bip39_passphrase: "typing.Optional[str]",account_type: "AccountType",account_index: "int") -> "str": + _UniffiConverterString.check_lower(mnemonic_phrase) - _UniffiConverterString.check_lower(mnemonic) + _UniffiConverterTypeNetwork.check_lower(network) _UniffiConverterOptionalString.check_lower(bip39_passphrase) - _UniffiConverterOptionalDouble.check_lower(fee_rate_sat_per_vb) + _UniffiConverterTypeAccountType.check_lower(account_type) - return await _uniffi_rust_call_async( - _UniffiLib.uniffi_bitkitcore_fn_func_boltz_claim_reverse_swap( - _UniffiConverterString.lower(swap_id), - _UniffiConverterString.lower(mnemonic), + _UniffiConverterUInt32.check_lower(account_index) + + return _UniffiConverterString.lift(_uniffi_rust_call_with_error(_UniffiConverterTypeAddressError,_UniffiLib.uniffi_bitkitcore_fn_func_derive_onchain_descriptor, + _UniffiConverterString.lower(mnemonic_phrase), + _UniffiConverterTypeNetwork.lower(network), _UniffiConverterOptionalString.lower(bip39_passphrase), - _UniffiConverterOptionalDouble.lower(fee_rate_sat_per_vb)), - _UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer, - _UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer, - _UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer, - # lift function - _UniffiConverterString.lift, - - # Error FFI converter -_UniffiConverterTypeBoltzError, + _UniffiConverterTypeAccountType.lower(account_type), + _UniffiConverterUInt32.lower(account_index))) - ) -async def boltz_create_reverse_swap(network: "BoltzNetwork",electrum_url: "str",amount_sat: "int",claim_address: "str",mnemonic: "str",bip39_passphrase: "typing.Optional[str]") -> "ReverseSwapResponse": - """ - Create a reverse swap (Lightning -> onchain). +def derive_private_key(mnemonic_phrase: "str",derivation_path_str: "typing.Optional[str]",network: "typing.Optional[Network]",bip39_passphrase: "typing.Optional[str]") -> "str": + _UniffiConverterString.check_lower(mnemonic_phrase) + + _UniffiConverterOptionalString.check_lower(derivation_path_str) + + _UniffiConverterOptionalTypeNetwork.check_lower(network) + + _UniffiConverterOptionalString.check_lower(bip39_passphrase) + + return _UniffiConverterString.lift(_uniffi_rust_call_with_error(_UniffiConverterTypeAddressError,_UniffiLib.uniffi_bitkitcore_fn_func_derive_private_key, + _UniffiConverterString.lower(mnemonic_phrase), + _UniffiConverterOptionalString.lower(derivation_path_str), + _UniffiConverterOptionalTypeNetwork.lower(network), + _UniffiConverterOptionalString.lower(bip39_passphrase))) + + +def derive_pubky_secret_key(seed: "bytes") -> "str": + _UniffiConverterBytes.check_lower(seed) + + return _UniffiConverterString.lift(_uniffi_rust_call_with_error(_UniffiConverterTypePubkyError,_UniffiLib.uniffi_bitkitcore_fn_func_derive_pubky_secret_key, + _UniffiConverterBytes.lower(seed))) + - The caller pays the returned hold invoice from its Lightning node; - `claim_address` is the onchain address the received funds are claimed to. - The claim key and preimage are derived deterministically from `mnemonic` - (only the derivation index is persisted, never the secrets) so the claim can - be made automatically once Boltz locks the funds. `bip39_passphrase` must - match the wallet's, or claims will derive the wrong key. +def derive_wallet_id(device_type: "str",xpubs: "typing.List[str]") -> "str": + """ + Derive a stable, cross-platform `wallet_id` for a hardware (watch-only) wallet + from its account extended public keys. See `derive_wallet_id` in the activity + module for the exact derivation. Order of `xpubs` does not matter. Returns an + error if `device_type` is blank or `xpubs` is empty / has a blank entry. """ - _UniffiConverterTypeBoltzNetwork.check_lower(network) + _UniffiConverterString.check_lower(device_type) - _UniffiConverterString.check_lower(electrum_url) + _UniffiConverterSequenceString.check_lower(xpubs) - _UniffiConverterUInt64.check_lower(amount_sat) + return _UniffiConverterString.lift(_uniffi_rust_call_with_error(_UniffiConverterTypeActivityError,_UniffiLib.uniffi_bitkitcore_fn_func_derive_wallet_id, + _UniffiConverterString.lower(device_type), + _UniffiConverterSequenceString.lower(xpubs))) + + +def entropy_to_mnemonic(entropy: "bytes") -> "str": + _UniffiConverterBytes.check_lower(entropy) - _UniffiConverterString.check_lower(claim_address) + return _UniffiConverterString.lift(_uniffi_rust_call_with_error(_UniffiConverterTypeAddressError,_UniffiLib.uniffi_bitkitcore_fn_func_entropy_to_mnemonic, + _UniffiConverterBytes.lower(entropy))) + +async def estimate_order_fee(lsp_balance_sat: "int",channel_expiry_weeks: "int",options: "typing.Optional[CreateOrderOptions]") -> "IBtEstimateFeeResponse": + + _UniffiConverterUInt64.check_lower(lsp_balance_sat) - _UniffiConverterString.check_lower(mnemonic) + _UniffiConverterUInt32.check_lower(channel_expiry_weeks) - _UniffiConverterOptionalString.check_lower(bip39_passphrase) + _UniffiConverterOptionalTypeCreateOrderOptions.check_lower(options) return await _uniffi_rust_call_async( - _UniffiLib.uniffi_bitkitcore_fn_func_boltz_create_reverse_swap( - _UniffiConverterTypeBoltzNetwork.lower(network), - _UniffiConverterString.lower(electrum_url), - _UniffiConverterUInt64.lower(amount_sat), - _UniffiConverterString.lower(claim_address), - _UniffiConverterString.lower(mnemonic), - _UniffiConverterOptionalString.lower(bip39_passphrase)), + _UniffiLib.uniffi_bitkitcore_fn_func_estimate_order_fee( + _UniffiConverterUInt64.lower(lsp_balance_sat), + _UniffiConverterUInt32.lower(channel_expiry_weeks), + _UniffiConverterOptionalTypeCreateOrderOptions.lower(options)), _UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer, _UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer, _UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer, # lift function - _UniffiConverterTypeReverseSwapResponse.lift, + _UniffiConverterTypeIBtEstimateFeeResponse.lift, # Error FFI converter -_UniffiConverterTypeBoltzError, +_UniffiConverterTypeBlocktankError, ) -async def boltz_create_submarine_swap(network: "BoltzNetwork",electrum_url: "str",invoice: "str",mnemonic: "str",bip39_passphrase: "typing.Optional[str]") -> "SubmarineSwapResponse": - - """ - Create a submarine swap (onchain -> Lightning). - - `invoice` is a BOLT11 invoice the caller's Lightning node generated. The - caller funds the returned lockup address from its onchain wallet. The refund - key is derived deterministically from `mnemonic` (only the derivation index - is persisted, never the key), and the swap is tracked if an updates stream is - running. `bip39_passphrase` must match the wallet's, or refunds will derive - the wrong key. - """ +async def estimate_order_fee_full(lsp_balance_sat: "int",channel_expiry_weeks: "int",options: "typing.Optional[CreateOrderOptions]") -> "IBtEstimateFeeResponse2": - _UniffiConverterTypeBoltzNetwork.check_lower(network) - - _UniffiConverterString.check_lower(electrum_url) - - _UniffiConverterString.check_lower(invoice) + _UniffiConverterUInt64.check_lower(lsp_balance_sat) - _UniffiConverterString.check_lower(mnemonic) + _UniffiConverterUInt32.check_lower(channel_expiry_weeks) - _UniffiConverterOptionalString.check_lower(bip39_passphrase) + _UniffiConverterOptionalTypeCreateOrderOptions.check_lower(options) return await _uniffi_rust_call_async( - _UniffiLib.uniffi_bitkitcore_fn_func_boltz_create_submarine_swap( - _UniffiConverterTypeBoltzNetwork.lower(network), - _UniffiConverterString.lower(electrum_url), - _UniffiConverterString.lower(invoice), - _UniffiConverterString.lower(mnemonic), - _UniffiConverterOptionalString.lower(bip39_passphrase)), + _UniffiLib.uniffi_bitkitcore_fn_func_estimate_order_fee_full( + _UniffiConverterUInt64.lower(lsp_balance_sat), + _UniffiConverterUInt32.lower(channel_expiry_weeks), + _UniffiConverterOptionalTypeCreateOrderOptions.lower(options)), _UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer, _UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer, _UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer, # lift function - _UniffiConverterTypeSubmarineSwapResponse.lift, + _UniffiConverterTypeIBtEstimateFeeResponse2.lift, # Error FFI converter -_UniffiConverterTypeBoltzError, +_UniffiConverterTypeBlocktankError, ) -async def boltz_get_reverse_limits(network: "BoltzNetwork") -> "BoltzPairInfo": - - """ - Fetch fees and limits for reverse swaps (Lightning -> onchain). - """ +async def fetch_pubky_contacts(public_key: "str") -> "typing.List[str]": - _UniffiConverterTypeBoltzNetwork.check_lower(network) + _UniffiConverterString.check_lower(public_key) return await _uniffi_rust_call_async( - _UniffiLib.uniffi_bitkitcore_fn_func_boltz_get_reverse_limits( - _UniffiConverterTypeBoltzNetwork.lower(network)), + _UniffiLib.uniffi_bitkitcore_fn_func_fetch_pubky_contacts( + _UniffiConverterString.lower(public_key)), _UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer, _UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer, _UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer, # lift function - _UniffiConverterTypeBoltzPairInfo.lift, + _UniffiConverterSequenceString.lift, # Error FFI converter -_UniffiConverterTypeBoltzError, +_UniffiConverterTypePubkyError, ) -async def boltz_get_submarine_limits(network: "BoltzNetwork") -> "BoltzPairInfo": - - """ - Fetch fees and limits for submarine swaps (onchain -> Lightning). - """ +async def fetch_pubky_file(uri: "str") -> "bytes": - _UniffiConverterTypeBoltzNetwork.check_lower(network) + _UniffiConverterString.check_lower(uri) return await _uniffi_rust_call_async( - _UniffiLib.uniffi_bitkitcore_fn_func_boltz_get_submarine_limits( - _UniffiConverterTypeBoltzNetwork.lower(network)), + _UniffiLib.uniffi_bitkitcore_fn_func_fetch_pubky_file( + _UniffiConverterString.lower(uri)), _UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer, _UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer, _UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer, # lift function - _UniffiConverterTypeBoltzPairInfo.lift, + _UniffiConverterBytes.lift, # Error FFI converter -_UniffiConverterTypeBoltzError, +_UniffiConverterTypePubkyError, ) -async def boltz_get_swap(swap_id: "str") -> "typing.Optional[BoltzSwap]": - - """ - Fetch a single swap by id. - """ +async def fetch_pubky_file_string(uri: "str") -> "str": - _UniffiConverterString.check_lower(swap_id) + _UniffiConverterString.check_lower(uri) return await _uniffi_rust_call_async( - _UniffiLib.uniffi_bitkitcore_fn_func_boltz_get_swap( - _UniffiConverterString.lower(swap_id)), + _UniffiLib.uniffi_bitkitcore_fn_func_fetch_pubky_file_string( + _UniffiConverterString.lower(uri)), _UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer, _UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer, _UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer, # lift function - _UniffiConverterOptionalTypeBoltzSwap.lift, + _UniffiConverterString.lift, # Error FFI converter -_UniffiConverterTypeBoltzError, +_UniffiConverterTypePubkyError, ) -async def boltz_list_pending_swaps() -> "typing.List[BoltzSwap]": - - """ - List swaps that have not reached a terminal state (for recovery/resume). - """ +async def fetch_pubky_profile(public_key: "str") -> "PubkyProfile": + _UniffiConverterString.check_lower(public_key) + return await _uniffi_rust_call_async( - _UniffiLib.uniffi_bitkitcore_fn_func_boltz_list_pending_swaps(), + _UniffiLib.uniffi_bitkitcore_fn_func_fetch_pubky_profile( + _UniffiConverterString.lower(public_key)), _UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer, _UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer, _UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer, # lift function - _UniffiConverterSequenceTypeBoltzSwap.lift, + _UniffiConverterTypePubkyProfile.lift, # Error FFI converter -_UniffiConverterTypeBoltzError, +_UniffiConverterTypePubkyError, ) -async def boltz_list_swaps() -> "typing.List[BoltzSwap]": +def finalize_psbt(original_psbt: "str",signed_psbt: "str") -> "CompletedTransaction": """ - List every persisted swap, newest first. + Combine and finalize a signed PSBT, then extract its broadcastable transaction. """ - return await _uniffi_rust_call_async( - _UniffiLib.uniffi_bitkitcore_fn_func_boltz_list_swaps(), - _UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer, - _UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer, - _UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer, - # lift function - _UniffiConverterSequenceTypeBoltzSwap.lift, - - # Error FFI converter -_UniffiConverterTypeBoltzError, + _UniffiConverterString.check_lower(original_psbt) + + _UniffiConverterString.check_lower(signed_psbt) + + return _UniffiConverterTypeCompletedTransaction.lift(_uniffi_rust_call_with_error(_UniffiConverterTypePsbtCompletionError,_UniffiLib.uniffi_bitkitcore_fn_func_finalize_psbt, + _UniffiConverterString.lower(original_psbt), + _UniffiConverterString.lower(signed_psbt))) - ) -async def boltz_refund_submarine_swap(swap_id: "str",refund_address: "str",mnemonic: "str",bip39_passphrase: "typing.Optional[str]",fee_rate_sat_per_vb: "typing.Optional[float]") -> "str": - """ - Refund a submarine swap's locked funds to `refund_address`, returning the - broadcast refund transaction id. Used when Boltz fails to pay the invoice or - the swap expires. The refund key is re-derived from `mnemonic`. Refunds are - serialized per swap, so two concurrent calls cannot both broadcast: the second - waits for the first and returns its txid. - """ +def generate_mnemonic(word_count: "typing.Optional[WordCount]") -> "str": + _UniffiConverterOptionalTypeWordCount.check_lower(word_count) + + return _UniffiConverterString.lift(_uniffi_rust_call_with_error(_UniffiConverterTypeAddressError,_UniffiLib.uniffi_bitkitcore_fn_func_generate_mnemonic, + _UniffiConverterOptionalTypeWordCount.lower(word_count))) - _UniffiConverterString.check_lower(swap_id) + +def get_activities(wallet_id: "typing.Optional[str]",filter: "typing.Optional[ActivityFilter]",tx_type: "typing.Optional[PaymentType]",tags: "typing.Optional[typing.List[str]]",search: "typing.Optional[str]",min_date: "typing.Optional[int]",max_date: "typing.Optional[int]",limit: "typing.Optional[int]",sort_direction: "typing.Optional[SortDirection]") -> "typing.List[Activity]": + _UniffiConverterOptionalString.check_lower(wallet_id) - _UniffiConverterString.check_lower(refund_address) + _UniffiConverterOptionalTypeActivityFilter.check_lower(filter) - _UniffiConverterString.check_lower(mnemonic) + _UniffiConverterOptionalTypePaymentType.check_lower(tx_type) - _UniffiConverterOptionalString.check_lower(bip39_passphrase) + _UniffiConverterOptionalSequenceString.check_lower(tags) - _UniffiConverterOptionalDouble.check_lower(fee_rate_sat_per_vb) + _UniffiConverterOptionalString.check_lower(search) - return await _uniffi_rust_call_async( - _UniffiLib.uniffi_bitkitcore_fn_func_boltz_refund_submarine_swap( - _UniffiConverterString.lower(swap_id), - _UniffiConverterString.lower(refund_address), - _UniffiConverterString.lower(mnemonic), - _UniffiConverterOptionalString.lower(bip39_passphrase), - _UniffiConverterOptionalDouble.lower(fee_rate_sat_per_vb)), - _UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer, - _UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer, - _UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer, - # lift function - _UniffiConverterString.lift, - - # Error FFI converter -_UniffiConverterTypeBoltzError, - - ) -async def boltz_start_swap_updates(network: "BoltzNetwork",listener: "BoltzEventListener",mnemonic: "str",bip39_passphrase: "typing.Optional[str]",fee_rate_sat_per_vb: "typing.Optional[float]",accept_zero_conf: "bool") -> None: - - """ - Open a Boltz WebSocket for `network`, subscribe to all pending swaps, and - drive their lifecycle (auto-claiming reverse swaps) until stopped. Replaces - any previously running updates stream (only one network is tracked at a - time). `mnemonic` is held in memory for the lifetime of the stream so - confirmed reverse swaps can be auto-claimed; it is never persisted. Events - are delivered to `listener`. - - `fee_rate_sat_per_vb` is the fee rate used for automatic claim transactions. - Bitkit owns fee estimation and should pass its current recommended rate; when - `None`, a conservative built-in default is used. To auto-claim at an updated - fee rate, call this again (it restarts the stream). - - `accept_zero_conf` claims reverse swaps as soon as Boltz's lockup enters the - mempool instead of waiting for its confirmation. That reveals the preimage - against an unconfirmed lockup: if the lockup were replaced before - confirming, the user would be debited on Lightning without receiving - onchain funds. Pass `false` to keep the confirmation-gated default. - """ - - _UniffiConverterTypeBoltzNetwork.check_lower(network) + _UniffiConverterOptionalUInt64.check_lower(min_date) - _UniffiConverterTypeBoltzEventListener.check_lower(listener) + _UniffiConverterOptionalUInt64.check_lower(max_date) - _UniffiConverterString.check_lower(mnemonic) + _UniffiConverterOptionalUInt32.check_lower(limit) + + _UniffiConverterOptionalTypeSortDirection.check_lower(sort_direction) + + return _UniffiConverterSequenceTypeActivity.lift(_uniffi_rust_call_with_error(_UniffiConverterTypeActivityError,_UniffiLib.uniffi_bitkitcore_fn_func_get_activities, + _UniffiConverterOptionalString.lower(wallet_id), + _UniffiConverterOptionalTypeActivityFilter.lower(filter), + _UniffiConverterOptionalTypePaymentType.lower(tx_type), + _UniffiConverterOptionalSequenceString.lower(tags), + _UniffiConverterOptionalString.lower(search), + _UniffiConverterOptionalUInt64.lower(min_date), + _UniffiConverterOptionalUInt64.lower(max_date), + _UniffiConverterOptionalUInt32.lower(limit), + _UniffiConverterOptionalTypeSortDirection.lower(sort_direction))) + + +def get_activities_by_tag(wallet_id: "typing.Optional[str]",tag: "str",limit: "typing.Optional[int]",sort_direction: "typing.Optional[SortDirection]") -> "typing.List[Activity]": + _UniffiConverterOptionalString.check_lower(wallet_id) - _UniffiConverterOptionalString.check_lower(bip39_passphrase) + _UniffiConverterString.check_lower(tag) - _UniffiConverterOptionalDouble.check_lower(fee_rate_sat_per_vb) + _UniffiConverterOptionalUInt32.check_lower(limit) - _UniffiConverterBool.check_lower(accept_zero_conf) + _UniffiConverterOptionalTypeSortDirection.check_lower(sort_direction) - return await _uniffi_rust_call_async( - _UniffiLib.uniffi_bitkitcore_fn_func_boltz_start_swap_updates( - _UniffiConverterTypeBoltzNetwork.lower(network), - _UniffiConverterTypeBoltzEventListener.lower(listener), - _UniffiConverterString.lower(mnemonic), - _UniffiConverterOptionalString.lower(bip39_passphrase), - _UniffiConverterOptionalDouble.lower(fee_rate_sat_per_vb), - _UniffiConverterBool.lower(accept_zero_conf)), - _UniffiLib.ffi_bitkitcore_rust_future_poll_void, - _UniffiLib.ffi_bitkitcore_rust_future_complete_void, - _UniffiLib.ffi_bitkitcore_rust_future_free_void, - # lift function - lambda val: None, - - - # Error FFI converter -_UniffiConverterTypeBoltzError, + return _UniffiConverterSequenceTypeActivity.lift(_uniffi_rust_call_with_error(_UniffiConverterTypeActivityError,_UniffiLib.uniffi_bitkitcore_fn_func_get_activities_by_tag, + _UniffiConverterOptionalString.lower(wallet_id), + _UniffiConverterString.lower(tag), + _UniffiConverterOptionalUInt32.lower(limit), + _UniffiConverterOptionalTypeSortDirection.lower(sort_direction))) - ) -async def boltz_stop_swap_updates() -> None: +def get_activities_tags(wallet_id: "typing.Optional[str]") -> "typing.List[ActivityTags]": """ - Stop the running Boltz updates stream, if any. + Activity tags for a single wallet scope, or every scope when `wallet_id` is `None`. """ - return await _uniffi_rust_call_async( - _UniffiLib.uniffi_bitkitcore_fn_func_boltz_stop_swap_updates(), - _UniffiLib.ffi_bitkitcore_rust_future_poll_void, - _UniffiLib.ffi_bitkitcore_rust_future_complete_void, - _UniffiLib.ffi_bitkitcore_rust_future_free_void, - # lift function - lambda val: None, - - - # Error FFI converter - - None, + _UniffiConverterOptionalString.check_lower(wallet_id) + + return _UniffiConverterSequenceTypeActivityTags.lift(_uniffi_rust_call_with_error(_UniffiConverterTypeActivityError,_UniffiLib.uniffi_bitkitcore_fn_func_get_activities_tags, + _UniffiConverterOptionalString.lower(wallet_id))) - ) -async def broadcast_sweep_transaction(psbt: "str",mnemonic_phrase: "str",network: "typing.Optional[Network]",bip39_passphrase: "typing.Optional[str]",electrum_url: "str") -> "SweepResult": - _UniffiConverterString.check_lower(psbt) - - _UniffiConverterString.check_lower(mnemonic_phrase) +def get_activity_by_id(wallet_id: "str",activity_id: "str") -> "typing.Optional[Activity]": + _UniffiConverterString.check_lower(wallet_id) - _UniffiConverterOptionalTypeNetwork.check_lower(network) + _UniffiConverterString.check_lower(activity_id) - _UniffiConverterOptionalString.check_lower(bip39_passphrase) + return _UniffiConverterOptionalTypeActivity.lift(_uniffi_rust_call_with_error(_UniffiConverterTypeActivityError,_UniffiLib.uniffi_bitkitcore_fn_func_get_activity_by_id, + _UniffiConverterString.lower(wallet_id), + _UniffiConverterString.lower(activity_id))) + + +def get_activity_by_tx_id(wallet_id: "str",tx_id: "str") -> "typing.Optional[OnchainActivity]": + _UniffiConverterString.check_lower(wallet_id) - _UniffiConverterString.check_lower(electrum_url) + _UniffiConverterString.check_lower(tx_id) - return await _uniffi_rust_call_async( - _UniffiLib.uniffi_bitkitcore_fn_func_broadcast_sweep_transaction( - _UniffiConverterString.lower(psbt), - _UniffiConverterString.lower(mnemonic_phrase), - _UniffiConverterOptionalTypeNetwork.lower(network), - _UniffiConverterOptionalString.lower(bip39_passphrase), - _UniffiConverterString.lower(electrum_url)), - _UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer, - _UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer, - _UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer, - # lift function - _UniffiConverterTypeSweepResult.lift, - - # Error FFI converter -_UniffiConverterTypeSweepError, + return _UniffiConverterOptionalTypeOnchainActivity.lift(_uniffi_rust_call_with_error(_UniffiConverterTypeActivityError,_UniffiLib.uniffi_bitkitcore_fn_func_get_activity_by_tx_id, + _UniffiConverterString.lower(wallet_id), + _UniffiConverterString.lower(tx_id))) - ) -def calculate_channel_liquidity_options(params: "ChannelLiquidityParams") -> "ChannelLiquidityOptions": - _UniffiConverterTypeChannelLiquidityParams.check_lower(params) +def get_all_activities_tags() -> "typing.List[ActivityTags]": + return _UniffiConverterSequenceTypeActivityTags.lift(_uniffi_rust_call_with_error(_UniffiConverterTypeActivityError,_UniffiLib.uniffi_bitkitcore_fn_func_get_all_activities_tags,)) + + +def get_all_closed_channels(sort_direction: "typing.Optional[SortDirection]") -> "typing.List[ClosedChannelDetails]": + _UniffiConverterOptionalTypeSortDirection.check_lower(sort_direction) - return _UniffiConverterTypeChannelLiquidityOptions.lift(_uniffi_rust_call(_UniffiLib.uniffi_bitkitcore_fn_func_calculate_channel_liquidity_options, - _UniffiConverterTypeChannelLiquidityParams.lower(params))) + return _UniffiConverterSequenceTypeClosedChannelDetails.lift(_uniffi_rust_call_with_error(_UniffiConverterTypeActivityError,_UniffiLib.uniffi_bitkitcore_fn_func_get_all_closed_channels, + _UniffiConverterOptionalTypeSortDirection.lower(sort_direction))) -async def cancel_pubky_auth() -> None: - return await _uniffi_rust_call_async( - _UniffiLib.uniffi_bitkitcore_fn_func_cancel_pubky_auth(), - _UniffiLib.ffi_bitkitcore_rust_future_poll_void, - _UniffiLib.ffi_bitkitcore_rust_future_complete_void, - _UniffiLib.ffi_bitkitcore_rust_future_free_void, - # lift function - lambda val: None, - - - # Error FFI converter -_UniffiConverterTypePubkyError, +def get_all_pre_activity_metadata() -> "typing.List[PreActivityMetadata]": + return _UniffiConverterSequenceTypePreActivityMetadata.lift(_uniffi_rust_call_with_error(_UniffiConverterTypeActivityError,_UniffiLib.uniffi_bitkitcore_fn_func_get_all_pre_activity_metadata,)) - ) -async def check_sweepable_balances(mnemonic_phrase: "str",network: "typing.Optional[Network]",bip39_passphrase: "typing.Optional[str]",electrum_url: "str") -> "SweepableBalances": - _UniffiConverterString.check_lower(mnemonic_phrase) +def get_all_transaction_details() -> "typing.List[TransactionDetails]": + return _UniffiConverterSequenceTypeTransactionDetails.lift(_uniffi_rust_call_with_error(_UniffiConverterTypeActivityError,_UniffiLib.uniffi_bitkitcore_fn_func_get_all_transaction_details,)) + + +def get_all_unique_tags() -> "typing.List[str]": + return _UniffiConverterSequenceString.lift(_uniffi_rust_call_with_error(_UniffiConverterTypeActivityError,_UniffiLib.uniffi_bitkitcore_fn_func_get_all_unique_tags,)) + + +def get_bip39_suggestions(partial_word: "str",limit: "int") -> "typing.List[str]": + _UniffiConverterString.check_lower(partial_word) - _UniffiConverterOptionalTypeNetwork.check_lower(network) + _UniffiConverterUInt32.check_lower(limit) - _UniffiConverterOptionalString.check_lower(bip39_passphrase) + return _UniffiConverterSequenceString.lift(_uniffi_rust_call(_UniffiLib.uniffi_bitkitcore_fn_func_get_bip39_suggestions, + _UniffiConverterString.lower(partial_word), + _UniffiConverterUInt32.lower(limit))) + + +def get_bip39_wordlist() -> "typing.List[str]": + return _UniffiConverterSequenceString.lift(_uniffi_rust_call(_UniffiLib.uniffi_bitkitcore_fn_func_get_bip39_wordlist,)) + +async def get_cjit_entries(entry_ids: "typing.Optional[typing.List[str]]",filter: "typing.Optional[CJitStateEnum]",refresh: "bool") -> "typing.List[IcJitEntry]": + + _UniffiConverterOptionalSequenceString.check_lower(entry_ids) - _UniffiConverterString.check_lower(electrum_url) + _UniffiConverterOptionalTypeCJitStateEnum.check_lower(filter) + + _UniffiConverterBool.check_lower(refresh) return await _uniffi_rust_call_async( - _UniffiLib.uniffi_bitkitcore_fn_func_check_sweepable_balances( - _UniffiConverterString.lower(mnemonic_phrase), - _UniffiConverterOptionalTypeNetwork.lower(network), - _UniffiConverterOptionalString.lower(bip39_passphrase), - _UniffiConverterString.lower(electrum_url)), + _UniffiLib.uniffi_bitkitcore_fn_func_get_cjit_entries( + _UniffiConverterOptionalSequenceString.lower(entry_ids), + _UniffiConverterOptionalTypeCJitStateEnum.lower(filter), + _UniffiConverterBool.lower(refresh)), _UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer, _UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer, _UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer, # lift function - _UniffiConverterTypeSweepableBalances.lift, + _UniffiConverterSequenceTypeIcJitEntry.lift, # Error FFI converter -_UniffiConverterTypeSweepError, +_UniffiConverterTypeBlocktankError, ) -def closed_channels_from_json(json: "str") -> "typing.List[ClosedChannelDetails]": - """ - Decode closed channels from Core's canonical backup JSON. - """ - - _UniffiConverterString.check_lower(json) +def get_closed_channel_by_id(channel_id: "str") -> "typing.Optional[ClosedChannelDetails]": + _UniffiConverterString.check_lower(channel_id) - return _UniffiConverterSequenceTypeClosedChannelDetails.lift(_uniffi_rust_call_with_error(_UniffiConverterTypeActivityError,_UniffiLib.uniffi_bitkitcore_fn_func_closed_channels_from_json, - _UniffiConverterString.lower(json))) + return _UniffiConverterOptionalTypeClosedChannelDetails.lift(_uniffi_rust_call_with_error(_UniffiConverterTypeActivityError,_UniffiLib.uniffi_bitkitcore_fn_func_get_closed_channel_by_id, + _UniffiConverterString.lower(channel_id))) -def closed_channels_to_json(channels: "typing.List[ClosedChannelDetails]") -> "str": +def get_default_gap_limit() -> "int": """ - Serialize closed channels to Core's canonical backup JSON. Closed channels - are not wallet-scoped, so no wallet-id normalization is applied. + The default address gap limit used by account scanning and the xpub watcher. + Exposed so platforms reference one source of truth instead of hardcoding 20. """ - _UniffiConverterSequenceTypeClosedChannelDetails.check_lower(channels) + return _UniffiConverterUInt32.lift(_uniffi_rust_call(_UniffiLib.uniffi_bitkitcore_fn_func_get_default_gap_limit,)) + + +def get_default_lsp_balance(params: "DefaultLspBalanceParams") -> "int": + _UniffiConverterTypeDefaultLspBalanceParams.check_lower(params) - return _UniffiConverterString.lift(_uniffi_rust_call_with_error(_UniffiConverterTypeActivityError,_UniffiLib.uniffi_bitkitcore_fn_func_closed_channels_to_json, - _UniffiConverterSequenceTypeClosedChannelDetails.lower(channels))) + return _UniffiConverterUInt64.lift(_uniffi_rust_call(_UniffiLib.uniffi_bitkitcore_fn_func_get_default_lsp_balance, + _UniffiConverterTypeDefaultLspBalanceParams.lower(params))) -async def complete_pubky_auth() -> "str": +def get_default_wallet_id() -> "str": + return _UniffiConverterString.lift(_uniffi_rust_call(_UniffiLib.uniffi_bitkitcore_fn_func_get_default_wallet_id,)) + +async def get_gift(gift_id: "str") -> "IGift": + + _UniffiConverterString.check_lower(gift_id) + return await _uniffi_rust_call_async( - _UniffiLib.uniffi_bitkitcore_fn_func_complete_pubky_auth(), + _UniffiLib.uniffi_bitkitcore_fn_func_get_gift( + _UniffiConverterString.lower(gift_id)), _UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer, _UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer, _UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer, # lift function - _UniffiConverterString.lift, + _UniffiConverterTypeIGift.lift, # Error FFI converter -_UniffiConverterTypePubkyError, +_UniffiConverterTypeBlocktankError, ) +async def get_info(refresh: "typing.Optional[bool]") -> "typing.Optional[IBtInfo]": -def create_channel_request_url(k1: "str",callback: "str",local_node_id: "str",is_private: "bool",cancel: "bool") -> "str": - _UniffiConverterString.check_lower(k1) - - _UniffiConverterString.check_lower(callback) - - _UniffiConverterString.check_lower(local_node_id) - - _UniffiConverterBool.check_lower(is_private) - - _UniffiConverterBool.check_lower(cancel) + _UniffiConverterOptionalBool.check_lower(refresh) - return _UniffiConverterString.lift(_uniffi_rust_call_with_error(_UniffiConverterTypeLnurlError,_UniffiLib.uniffi_bitkitcore_fn_func_create_channel_request_url, - _UniffiConverterString.lower(k1), - _UniffiConverterString.lower(callback), - _UniffiConverterString.lower(local_node_id), - _UniffiConverterBool.lower(is_private), - _UniffiConverterBool.lower(cancel))) + return await _uniffi_rust_call_async( + _UniffiLib.uniffi_bitkitcore_fn_func_get_info( + _UniffiConverterOptionalBool.lower(refresh)), + _UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer, + _UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer, + _UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer, + # lift function + _UniffiConverterOptionalTypeIBtInfo.lift, + + # Error FFI converter +_UniffiConverterTypeBlocktankError, -async def create_cjit_entry(channel_size_sat: "int",invoice_sat: "int",invoice_description: "str",node_id: "str",channel_expiry_weeks: "int",options: "typing.Optional[CreateCjitOptions]") -> "IcJitEntry": + ) +async def get_lnurl_invoice(address: "str",amount_satoshis: "int") -> "str": - _UniffiConverterUInt64.check_lower(channel_size_sat) - - _UniffiConverterUInt64.check_lower(invoice_sat) - - _UniffiConverterString.check_lower(invoice_description) - - _UniffiConverterString.check_lower(node_id) - - _UniffiConverterUInt32.check_lower(channel_expiry_weeks) + _UniffiConverterString.check_lower(address) - _UniffiConverterOptionalTypeCreateCjitOptions.check_lower(options) + _UniffiConverterUInt64.check_lower(amount_satoshis) return await _uniffi_rust_call_async( - _UniffiLib.uniffi_bitkitcore_fn_func_create_cjit_entry( - _UniffiConverterUInt64.lower(channel_size_sat), - _UniffiConverterUInt64.lower(invoice_sat), - _UniffiConverterString.lower(invoice_description), - _UniffiConverterString.lower(node_id), - _UniffiConverterUInt32.lower(channel_expiry_weeks), - _UniffiConverterOptionalTypeCreateCjitOptions.lower(options)), + _UniffiLib.uniffi_bitkitcore_fn_func_get_lnurl_invoice( + _UniffiConverterString.lower(address), + _UniffiConverterUInt64.lower(amount_satoshis)), _UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer, _UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer, _UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer, # lift function - _UniffiConverterTypeIcJitEntry.lift, + _UniffiConverterString.lift, # Error FFI converter -_UniffiConverterTypeBlocktankError, +_UniffiConverterTypeLnurlError, ) -async def create_order(lsp_balance_sat: "int",channel_expiry_weeks: "int",options: "typing.Optional[CreateOrderOptions]") -> "IBtOrder": +async def get_lnurl_invoice_for_pay_data(data: "LnurlPayData",amount_msats: "int",comment: "typing.Optional[str]") -> "str": - _UniffiConverterUInt64.check_lower(lsp_balance_sat) + _UniffiConverterTypeLnurlPayData.check_lower(data) - _UniffiConverterUInt32.check_lower(channel_expiry_weeks) + _UniffiConverterUInt64.check_lower(amount_msats) - _UniffiConverterOptionalTypeCreateOrderOptions.check_lower(options) + _UniffiConverterOptionalString.check_lower(comment) return await _uniffi_rust_call_async( - _UniffiLib.uniffi_bitkitcore_fn_func_create_order( - _UniffiConverterUInt64.lower(lsp_balance_sat), - _UniffiConverterUInt32.lower(channel_expiry_weeks), - _UniffiConverterOptionalTypeCreateOrderOptions.lower(options)), + _UniffiLib.uniffi_bitkitcore_fn_func_get_lnurl_invoice_for_pay_data( + _UniffiConverterTypeLnurlPayData.lower(data), + _UniffiConverterUInt64.lower(amount_msats), + _UniffiConverterOptionalString.lower(comment)), _UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer, _UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer, _UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer, # lift function - _UniffiConverterTypeIBtOrder.lift, + _UniffiConverterString.lift, # Error FFI converter -_UniffiConverterTypeBlocktankError, +_UniffiConverterTypeLnurlError, ) +async def get_min_zero_conf_tx_fee(order_id: "str") -> "IBt0ConfMinTxFeeWindow": -def create_withdraw_callback_url(k1: "str",callback: "str",payment_request: "str") -> "str": - _UniffiConverterString.check_lower(k1) - - _UniffiConverterString.check_lower(callback) - - _UniffiConverterString.check_lower(payment_request) - - return _UniffiConverterString.lift(_uniffi_rust_call_with_error(_UniffiConverterTypeLnurlError,_UniffiLib.uniffi_bitkitcore_fn_func_create_withdraw_callback_url, - _UniffiConverterString.lower(k1), - _UniffiConverterString.lower(callback), - _UniffiConverterString.lower(payment_request))) - -async def decode(invoice: "str") -> "Scanner": - - _UniffiConverterString.check_lower(invoice) + _UniffiConverterString.check_lower(order_id) return await _uniffi_rust_call_async( - _UniffiLib.uniffi_bitkitcore_fn_func_decode( - _UniffiConverterString.lower(invoice)), + _UniffiLib.uniffi_bitkitcore_fn_func_get_min_zero_conf_tx_fee( + _UniffiConverterString.lower(order_id)), _UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer, _UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer, _UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer, # lift function - _UniffiConverterTypeScanner.lift, + _UniffiConverterTypeIBt0ConfMinTxFeeWindow.lift, # Error FFI converter -_UniffiConverterTypeDecodingError, +_UniffiConverterTypeBlocktankError, ) +async def get_orders(order_ids: "typing.Optional[typing.List[str]]",filter: "typing.Optional[BtOrderState2]",refresh: "bool") -> "typing.List[IBtOrder]": -def delete_activities_by_wallet_id(wallet_id: "str") -> "int": - _UniffiConverterString.check_lower(wallet_id) - - return _UniffiConverterUInt32.lift(_uniffi_rust_call_with_error(_UniffiConverterTypeActivityError,_UniffiLib.uniffi_bitkitcore_fn_func_delete_activities_by_wallet_id, - _UniffiConverterString.lower(wallet_id))) - - -def delete_activity_by_id(wallet_id: "str",activity_id: "str") -> "bool": - _UniffiConverterString.check_lower(wallet_id) - - _UniffiConverterString.check_lower(activity_id) - - return _UniffiConverterBool.lift(_uniffi_rust_call_with_error(_UniffiConverterTypeActivityError,_UniffiLib.uniffi_bitkitcore_fn_func_delete_activity_by_id, - _UniffiConverterString.lower(wallet_id), - _UniffiConverterString.lower(activity_id))) - - -def delete_pre_activity_metadata(wallet_id: "str",payment_id: "str") -> None: - _UniffiConverterString.check_lower(wallet_id) - - _UniffiConverterString.check_lower(payment_id) - - _uniffi_rust_call_with_error(_UniffiConverterTypeActivityError,_UniffiLib.uniffi_bitkitcore_fn_func_delete_pre_activity_metadata, - _UniffiConverterString.lower(wallet_id), - _UniffiConverterString.lower(payment_id)) - - -def delete_transaction_details(wallet_id: "str",tx_id: "str") -> "bool": - _UniffiConverterString.check_lower(wallet_id) - - _UniffiConverterString.check_lower(tx_id) - - return _UniffiConverterBool.lift(_uniffi_rust_call_with_error(_UniffiConverterTypeActivityError,_UniffiLib.uniffi_bitkitcore_fn_func_delete_transaction_details, - _UniffiConverterString.lower(wallet_id), - _UniffiConverterString.lower(tx_id))) - - -def derive_bitcoin_address(mnemonic_phrase: "str",derivation_path_str: "typing.Optional[str]",network: "typing.Optional[Network]",bip39_passphrase: "typing.Optional[str]") -> "GetAddressResponse": - _UniffiConverterString.check_lower(mnemonic_phrase) - - _UniffiConverterOptionalString.check_lower(derivation_path_str) - - _UniffiConverterOptionalTypeNetwork.check_lower(network) - - _UniffiConverterOptionalString.check_lower(bip39_passphrase) - - return _UniffiConverterTypeGetAddressResponse.lift(_uniffi_rust_call_with_error(_UniffiConverterTypeAddressError,_UniffiLib.uniffi_bitkitcore_fn_func_derive_bitcoin_address, - _UniffiConverterString.lower(mnemonic_phrase), - _UniffiConverterOptionalString.lower(derivation_path_str), - _UniffiConverterOptionalTypeNetwork.lower(network), - _UniffiConverterOptionalString.lower(bip39_passphrase))) - - -def derive_bitcoin_addresses(mnemonic_phrase: "str",derivation_path_str: "typing.Optional[str]",network: "typing.Optional[Network]",bip39_passphrase: "typing.Optional[str]",is_change: "typing.Optional[bool]",start_index: "typing.Optional[int]",count: "typing.Optional[int]") -> "GetAddressesResponse": - _UniffiConverterString.check_lower(mnemonic_phrase) - - _UniffiConverterOptionalString.check_lower(derivation_path_str) - - _UniffiConverterOptionalTypeNetwork.check_lower(network) - - _UniffiConverterOptionalString.check_lower(bip39_passphrase) - - _UniffiConverterOptionalBool.check_lower(is_change) - - _UniffiConverterOptionalUInt32.check_lower(start_index) - - _UniffiConverterOptionalUInt32.check_lower(count) - - return _UniffiConverterTypeGetAddressesResponse.lift(_uniffi_rust_call_with_error(_UniffiConverterTypeAddressError,_UniffiLib.uniffi_bitkitcore_fn_func_derive_bitcoin_addresses, - _UniffiConverterString.lower(mnemonic_phrase), - _UniffiConverterOptionalString.lower(derivation_path_str), - _UniffiConverterOptionalTypeNetwork.lower(network), - _UniffiConverterOptionalString.lower(bip39_passphrase), - _UniffiConverterOptionalBool.lower(is_change), - _UniffiConverterOptionalUInt32.lower(start_index), - _UniffiConverterOptionalUInt32.lower(count))) - - -def derive_onchain_descriptor(mnemonic_phrase: "str",network: "Network",bip39_passphrase: "typing.Optional[str]",account_type: "AccountType",account_index: "int") -> "str": - _UniffiConverterString.check_lower(mnemonic_phrase) - - _UniffiConverterTypeNetwork.check_lower(network) - - _UniffiConverterOptionalString.check_lower(bip39_passphrase) - - _UniffiConverterTypeAccountType.check_lower(account_type) - - _UniffiConverterUInt32.check_lower(account_index) - - return _UniffiConverterString.lift(_uniffi_rust_call_with_error(_UniffiConverterTypeAddressError,_UniffiLib.uniffi_bitkitcore_fn_func_derive_onchain_descriptor, - _UniffiConverterString.lower(mnemonic_phrase), - _UniffiConverterTypeNetwork.lower(network), - _UniffiConverterOptionalString.lower(bip39_passphrase), - _UniffiConverterTypeAccountType.lower(account_type), - _UniffiConverterUInt32.lower(account_index))) - - -def derive_private_key(mnemonic_phrase: "str",derivation_path_str: "typing.Optional[str]",network: "typing.Optional[Network]",bip39_passphrase: "typing.Optional[str]") -> "str": - _UniffiConverterString.check_lower(mnemonic_phrase) - - _UniffiConverterOptionalString.check_lower(derivation_path_str) - - _UniffiConverterOptionalTypeNetwork.check_lower(network) - - _UniffiConverterOptionalString.check_lower(bip39_passphrase) - - return _UniffiConverterString.lift(_uniffi_rust_call_with_error(_UniffiConverterTypeAddressError,_UniffiLib.uniffi_bitkitcore_fn_func_derive_private_key, - _UniffiConverterString.lower(mnemonic_phrase), - _UniffiConverterOptionalString.lower(derivation_path_str), - _UniffiConverterOptionalTypeNetwork.lower(network), - _UniffiConverterOptionalString.lower(bip39_passphrase))) - - -def derive_pubky_secret_key(seed: "bytes") -> "str": - _UniffiConverterBytes.check_lower(seed) - - return _UniffiConverterString.lift(_uniffi_rust_call_with_error(_UniffiConverterTypePubkyError,_UniffiLib.uniffi_bitkitcore_fn_func_derive_pubky_secret_key, - _UniffiConverterBytes.lower(seed))) - - -def derive_wallet_id(device_type: "str",xpubs: "typing.List[str]") -> "str": - """ - Derive a stable, cross-platform `wallet_id` for a hardware (watch-only) wallet - from its account extended public keys. See `derive_wallet_id` in the activity - module for the exact derivation. Order of `xpubs` does not matter. Returns an - error if `device_type` is blank or `xpubs` is empty / has a blank entry. - """ - - _UniffiConverterString.check_lower(device_type) - - _UniffiConverterSequenceString.check_lower(xpubs) - - return _UniffiConverterString.lift(_uniffi_rust_call_with_error(_UniffiConverterTypeActivityError,_UniffiLib.uniffi_bitkitcore_fn_func_derive_wallet_id, - _UniffiConverterString.lower(device_type), - _UniffiConverterSequenceString.lower(xpubs))) - - -def entropy_to_mnemonic(entropy: "bytes") -> "str": - _UniffiConverterBytes.check_lower(entropy) - - return _UniffiConverterString.lift(_uniffi_rust_call_with_error(_UniffiConverterTypeAddressError,_UniffiLib.uniffi_bitkitcore_fn_func_entropy_to_mnemonic, - _UniffiConverterBytes.lower(entropy))) - -async def estimate_order_fee(lsp_balance_sat: "int",channel_expiry_weeks: "int",options: "typing.Optional[CreateOrderOptions]") -> "IBtEstimateFeeResponse": - - _UniffiConverterUInt64.check_lower(lsp_balance_sat) + _UniffiConverterOptionalSequenceString.check_lower(order_ids) - _UniffiConverterUInt32.check_lower(channel_expiry_weeks) + _UniffiConverterOptionalTypeBtOrderState2.check_lower(filter) - _UniffiConverterOptionalTypeCreateOrderOptions.check_lower(options) + _UniffiConverterBool.check_lower(refresh) return await _uniffi_rust_call_async( - _UniffiLib.uniffi_bitkitcore_fn_func_estimate_order_fee( - _UniffiConverterUInt64.lower(lsp_balance_sat), - _UniffiConverterUInt32.lower(channel_expiry_weeks), - _UniffiConverterOptionalTypeCreateOrderOptions.lower(options)), + _UniffiLib.uniffi_bitkitcore_fn_func_get_orders( + _UniffiConverterOptionalSequenceString.lower(order_ids), + _UniffiConverterOptionalTypeBtOrderState2.lower(filter), + _UniffiConverterBool.lower(refresh)), _UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer, _UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer, _UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer, # lift function - _UniffiConverterTypeIBtEstimateFeeResponse.lift, + _UniffiConverterSequenceTypeIBtOrder.lift, # Error FFI converter _UniffiConverterTypeBlocktankError, ) -async def estimate_order_fee_full(lsp_balance_sat: "int",channel_expiry_weeks: "int",options: "typing.Optional[CreateOrderOptions]") -> "IBtEstimateFeeResponse2": +async def get_payment(payment_id: "str") -> "IBtBolt11Invoice": - _UniffiConverterUInt64.check_lower(lsp_balance_sat) - - _UniffiConverterUInt32.check_lower(channel_expiry_weeks) - - _UniffiConverterOptionalTypeCreateOrderOptions.check_lower(options) + _UniffiConverterString.check_lower(payment_id) return await _uniffi_rust_call_async( - _UniffiLib.uniffi_bitkitcore_fn_func_estimate_order_fee_full( - _UniffiConverterUInt64.lower(lsp_balance_sat), - _UniffiConverterUInt32.lower(channel_expiry_weeks), - _UniffiConverterOptionalTypeCreateOrderOptions.lower(options)), + _UniffiLib.uniffi_bitkitcore_fn_func_get_payment( + _UniffiConverterString.lower(payment_id)), _UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer, _UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer, _UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer, # lift function - _UniffiConverterTypeIBtEstimateFeeResponse2.lift, + _UniffiConverterTypeIBtBolt11Invoice.lift, # Error FFI converter _UniffiConverterTypeBlocktankError, - ) -async def fetch_pubky_contacts(public_key: "str") -> "typing.List[str]": + ) + +def get_pre_activity_metadata(wallet_id: "str",search_key: "str",search_by_address: "bool") -> "typing.Optional[PreActivityMetadata]": + _UniffiConverterString.check_lower(wallet_id) + + _UniffiConverterString.check_lower(search_key) + + _UniffiConverterBool.check_lower(search_by_address) + + return _UniffiConverterOptionalTypePreActivityMetadata.lift(_uniffi_rust_call_with_error(_UniffiConverterTypeActivityError,_UniffiLib.uniffi_bitkitcore_fn_func_get_pre_activity_metadata, + _UniffiConverterString.lower(wallet_id), + _UniffiConverterString.lower(search_key), + _UniffiConverterBool.lower(search_by_address))) + + +def get_pre_activity_metadata_list(wallet_id: "typing.Optional[str]") -> "typing.List[PreActivityMetadata]": + """ + Pre-activity metadata for a single wallet scope, or every scope when `wallet_id` is `None`. + """ + + _UniffiConverterOptionalString.check_lower(wallet_id) + + return _UniffiConverterSequenceTypePreActivityMetadata.lift(_uniffi_rust_call_with_error(_UniffiConverterTypeActivityError,_UniffiLib.uniffi_bitkitcore_fn_func_get_pre_activity_metadata_list, + _UniffiConverterOptionalString.lower(wallet_id))) + + +def get_supported_hardware_wallets() -> "typing.List[SupportedHardwareWallet]": + """ + The hardware-wallet models supported by Bitkit and their available transports. + """ + + return _UniffiConverterSequenceTypeSupportedHardwareWallet.lift(_uniffi_rust_call(_UniffiLib.uniffi_bitkitcore_fn_func_get_supported_hardware_wallets,)) - _UniffiConverterString.check_lower(public_key) + +def get_tags(wallet_id: "str",activity_id: "str") -> "typing.List[str]": + _UniffiConverterString.check_lower(wallet_id) - return await _uniffi_rust_call_async( - _UniffiLib.uniffi_bitkitcore_fn_func_fetch_pubky_contacts( - _UniffiConverterString.lower(public_key)), - _UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer, - _UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer, - _UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer, - # lift function - _UniffiConverterSequenceString.lift, - - # Error FFI converter -_UniffiConverterTypePubkyError, + _UniffiConverterString.check_lower(activity_id) + + return _UniffiConverterSequenceString.lift(_uniffi_rust_call_with_error(_UniffiConverterTypeActivityError,_UniffiLib.uniffi_bitkitcore_fn_func_get_tags, + _UniffiConverterString.lower(wallet_id), + _UniffiConverterString.lower(activity_id))) - ) -async def fetch_pubky_file(uri: "str") -> "bytes": - _UniffiConverterString.check_lower(uri) +def get_transaction_details(wallet_id: "str",tx_id: "str") -> "typing.Optional[TransactionDetails]": + _UniffiConverterString.check_lower(wallet_id) - return await _uniffi_rust_call_async( - _UniffiLib.uniffi_bitkitcore_fn_func_fetch_pubky_file( - _UniffiConverterString.lower(uri)), - _UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer, - _UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer, - _UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer, - # lift function - _UniffiConverterBytes.lift, - - # Error FFI converter -_UniffiConverterTypePubkyError, + _UniffiConverterString.check_lower(tx_id) + + return _UniffiConverterOptionalTypeTransactionDetails.lift(_uniffi_rust_call_with_error(_UniffiConverterTypeActivityError,_UniffiLib.uniffi_bitkitcore_fn_func_get_transaction_details, + _UniffiConverterString.lower(wallet_id), + _UniffiConverterString.lower(tx_id))) - ) -async def fetch_pubky_file_string(uri: "str") -> "str": +async def gift_order(client_node_id: "str",code: "str") -> "IGift": - _UniffiConverterString.check_lower(uri) + _UniffiConverterString.check_lower(client_node_id) + + _UniffiConverterString.check_lower(code) return await _uniffi_rust_call_async( - _UniffiLib.uniffi_bitkitcore_fn_func_fetch_pubky_file_string( - _UniffiConverterString.lower(uri)), + _UniffiLib.uniffi_bitkitcore_fn_func_gift_order( + _UniffiConverterString.lower(client_node_id), + _UniffiConverterString.lower(code)), _UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer, _UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer, _UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer, # lift function - _UniffiConverterString.lift, + _UniffiConverterTypeIGift.lift, # Error FFI converter -_UniffiConverterTypePubkyError, +_UniffiConverterTypeBlocktankError, ) -async def fetch_pubky_profile(public_key: "str") -> "PubkyProfile": +async def gift_pay(invoice: "str") -> "IGift": - _UniffiConverterString.check_lower(public_key) + _UniffiConverterString.check_lower(invoice) return await _uniffi_rust_call_async( - _UniffiLib.uniffi_bitkitcore_fn_func_fetch_pubky_profile( - _UniffiConverterString.lower(public_key)), + _UniffiLib.uniffi_bitkitcore_fn_func_gift_pay( + _UniffiConverterString.lower(invoice)), _UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer, _UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer, _UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer, # lift function - _UniffiConverterTypePubkyProfile.lift, + _UniffiConverterTypeIGift.lift, # Error FFI converter -_UniffiConverterTypePubkyError, +_UniffiConverterTypeBlocktankError, ) -def finalize_psbt(original_psbt: "str",signed_psbt: "str") -> "CompletedTransaction": - """ - Combine and finalize a signed PSBT, then extract its broadcastable transaction. - """ - - _UniffiConverterString.check_lower(original_psbt) - - _UniffiConverterString.check_lower(signed_psbt) +def init_db(base_path: "str") -> "str": + _UniffiConverterString.check_lower(base_path) - return _UniffiConverterTypeCompletedTransaction.lift(_uniffi_rust_call_with_error(_UniffiConverterTypePsbtCompletionError,_UniffiLib.uniffi_bitkitcore_fn_func_finalize_psbt, - _UniffiConverterString.lower(original_psbt), - _UniffiConverterString.lower(signed_psbt))) + return _UniffiConverterString.lift(_uniffi_rust_call_with_error(_UniffiConverterTypeDbError,_UniffiLib.uniffi_bitkitcore_fn_func_init_db, + _UniffiConverterString.lower(base_path))) -def generate_mnemonic(word_count: "typing.Optional[WordCount]") -> "str": - _UniffiConverterOptionalTypeWordCount.check_lower(word_count) +def insert_activity(activity: "Activity") -> None: + _UniffiConverterTypeActivity.check_lower(activity) - return _UniffiConverterString.lift(_uniffi_rust_call_with_error(_UniffiConverterTypeAddressError,_UniffiLib.uniffi_bitkitcore_fn_func_generate_mnemonic, - _UniffiConverterOptionalTypeWordCount.lower(word_count))) + _uniffi_rust_call_with_error(_UniffiConverterTypeActivityError,_UniffiLib.uniffi_bitkitcore_fn_func_insert_activity, + _UniffiConverterTypeActivity.lower(activity)) -def get_activities(wallet_id: "typing.Optional[str]",filter: "typing.Optional[ActivityFilter]",tx_type: "typing.Optional[PaymentType]",tags: "typing.Optional[typing.List[str]]",search: "typing.Optional[str]",min_date: "typing.Optional[int]",max_date: "typing.Optional[int]",limit: "typing.Optional[int]",sort_direction: "typing.Optional[SortDirection]") -> "typing.List[Activity]": - _UniffiConverterOptionalString.check_lower(wallet_id) - - _UniffiConverterOptionalTypeActivityFilter.check_lower(filter) - - _UniffiConverterOptionalTypePaymentType.check_lower(tx_type) - - _UniffiConverterOptionalSequenceString.check_lower(tags) - - _UniffiConverterOptionalString.check_lower(search) - - _UniffiConverterOptionalUInt64.check_lower(min_date) - - _UniffiConverterOptionalUInt64.check_lower(max_date) - - _UniffiConverterOptionalUInt32.check_lower(limit) - - _UniffiConverterOptionalTypeSortDirection.check_lower(sort_direction) +def is_address_used(address: "str") -> "bool": + _UniffiConverterString.check_lower(address) - return _UniffiConverterSequenceTypeActivity.lift(_uniffi_rust_call_with_error(_UniffiConverterTypeActivityError,_UniffiLib.uniffi_bitkitcore_fn_func_get_activities, - _UniffiConverterOptionalString.lower(wallet_id), - _UniffiConverterOptionalTypeActivityFilter.lower(filter), - _UniffiConverterOptionalTypePaymentType.lower(tx_type), - _UniffiConverterOptionalSequenceString.lower(tags), - _UniffiConverterOptionalString.lower(search), - _UniffiConverterOptionalUInt64.lower(min_date), - _UniffiConverterOptionalUInt64.lower(max_date), - _UniffiConverterOptionalUInt32.lower(limit), - _UniffiConverterOptionalTypeSortDirection.lower(sort_direction))) + return _UniffiConverterBool.lift(_uniffi_rust_call_with_error(_UniffiConverterTypeActivityError,_UniffiLib.uniffi_bitkitcore_fn_func_is_address_used, + _UniffiConverterString.lower(address))) -def get_activities_by_tag(wallet_id: "typing.Optional[str]",tag: "str",limit: "typing.Optional[int]",sort_direction: "typing.Optional[SortDirection]") -> "typing.List[Activity]": - _UniffiConverterOptionalString.check_lower(wallet_id) - - _UniffiConverterString.check_lower(tag) - - _UniffiConverterOptionalUInt32.check_lower(limit) - - _UniffiConverterOptionalTypeSortDirection.check_lower(sort_direction) +def is_valid_bip39_word(word: "str") -> "bool": + _UniffiConverterString.check_lower(word) - return _UniffiConverterSequenceTypeActivity.lift(_uniffi_rust_call_with_error(_UniffiConverterTypeActivityError,_UniffiLib.uniffi_bitkitcore_fn_func_get_activities_by_tag, - _UniffiConverterOptionalString.lower(wallet_id), - _UniffiConverterString.lower(tag), - _UniffiConverterOptionalUInt32.lower(limit), - _UniffiConverterOptionalTypeSortDirection.lower(sort_direction))) + return _UniffiConverterBool.lift(_uniffi_rust_call(_UniffiLib.uniffi_bitkitcore_fn_func_is_valid_bip39_word, + _UniffiConverterString.lower(word))) -def get_activities_tags(wallet_id: "typing.Optional[str]") -> "typing.List[ActivityTags]": +def jade_account_type_to_variant(account_type: "AccountType") -> "JadeAddressVariant": """ - Activity tags for a single wallet scope, or every scope when `wallet_id` is `None`. + Map a generic account type onto Jade's descriptor variant. """ - _UniffiConverterOptionalString.check_lower(wallet_id) + _UniffiConverterTypeAccountType.check_lower(account_type) - return _UniffiConverterSequenceTypeActivityTags.lift(_uniffi_rust_call_with_error(_UniffiConverterTypeActivityError,_UniffiLib.uniffi_bitkitcore_fn_func_get_activities_tags, - _UniffiConverterOptionalString.lower(wallet_id))) + return _UniffiConverterTypeJadeAddressVariant.lift(_uniffi_rust_call(_UniffiLib.uniffi_bitkitcore_fn_func_jade_account_type_to_variant, + _UniffiConverterTypeAccountType.lower(account_type))) +async def jade_cancel() -> None: -def get_activity_by_id(wallet_id: "str",activity_id: "str") -> "typing.Optional[Activity]": - _UniffiConverterString.check_lower(wallet_id) - - _UniffiConverterString.check_lower(activity_id) - - return _UniffiConverterOptionalTypeActivity.lift(_uniffi_rust_call_with_error(_UniffiConverterTypeActivityError,_UniffiLib.uniffi_bitkitcore_fn_func_get_activity_by_id, - _UniffiConverterString.lower(wallet_id), - _UniffiConverterString.lower(activity_id))) + """ + Abort the operation in flight. + Jade has no cancel message, so this closes the link. The application should + reconnect afterwards. This is what backs a cancel button on a signing screen. + """ -def get_activity_by_tx_id(wallet_id: "str",tx_id: "str") -> "typing.Optional[OnchainActivity]": - _UniffiConverterString.check_lower(wallet_id) - - _UniffiConverterString.check_lower(tx_id) - - return _UniffiConverterOptionalTypeOnchainActivity.lift(_uniffi_rust_call_with_error(_UniffiConverterTypeActivityError,_UniffiLib.uniffi_bitkitcore_fn_func_get_activity_by_tx_id, - _UniffiConverterString.lower(wallet_id), - _UniffiConverterString.lower(tx_id))) + return await _uniffi_rust_call_async( + _UniffiLib.uniffi_bitkitcore_fn_func_jade_cancel(), + _UniffiLib.ffi_bitkitcore_rust_future_poll_void, + _UniffiLib.ffi_bitkitcore_rust_future_complete_void, + _UniffiLib.ffi_bitkitcore_rust_future_free_void, + # lift function + lambda val: None, + + + # Error FFI converter +_UniffiConverterTypeJadeError, + ) +async def jade_connect(transport: "JadeTransportKind",path: "str") -> "JadeVersionInfo": -def get_all_activities_tags() -> "typing.List[ActivityTags]": - return _UniffiConverterSequenceTypeActivityTags.lift(_uniffi_rust_call_with_error(_UniffiConverterTypeActivityError,_UniffiLib.uniffi_bitkitcore_fn_func_get_all_activities_tags,)) + """ + Open a device and read its firmware and state summary. + The path normally comes from the last `jade_scan`, but a known Bluetooth + address or serial path can be passed directly to reconnect without a scan. + Any previously open connection is closed first. The returned `jade_state` + tells the application what to do next: `Locked` means call `jade_unlock`, + `Ready` means the device is already usable, and `Uninit` means the user must + create or restore a wallet on the device itself. + """ -def get_all_closed_channels(sort_direction: "typing.Optional[SortDirection]") -> "typing.List[ClosedChannelDetails]": - _UniffiConverterOptionalTypeSortDirection.check_lower(sort_direction) + _UniffiConverterTypeJadeTransportKind.check_lower(transport) - return _UniffiConverterSequenceTypeClosedChannelDetails.lift(_uniffi_rust_call_with_error(_UniffiConverterTypeActivityError,_UniffiLib.uniffi_bitkitcore_fn_func_get_all_closed_channels, - _UniffiConverterOptionalTypeSortDirection.lower(sort_direction))) + _UniffiConverterString.check_lower(path) + + return await _uniffi_rust_call_async( + _UniffiLib.uniffi_bitkitcore_fn_func_jade_connect( + _UniffiConverterTypeJadeTransportKind.lower(transport), + _UniffiConverterString.lower(path)), + _UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer, + _UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer, + _UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer, + # lift function + _UniffiConverterTypeJadeVersionInfo.lift, + + # Error FFI converter +_UniffiConverterTypeJadeError, + ) +async def jade_disconnect() -> None: -def get_all_pre_activity_metadata() -> "typing.List[PreActivityMetadata]": - return _UniffiConverterSequenceTypePreActivityMetadata.lift(_uniffi_rust_call_with_error(_UniffiConverterTypeActivityError,_UniffiLib.uniffi_bitkitcore_fn_func_get_all_pre_activity_metadata,)) + """ + Close the device and clear session state. + Safe to call while an operation is waiting on a confirmation: the pending + request returns `UserCancelled` promptly rather than running out its deadline. + """ -def get_all_transaction_details() -> "typing.List[TransactionDetails]": - return _UniffiConverterSequenceTypeTransactionDetails.lift(_uniffi_rust_call_with_error(_UniffiConverterTypeActivityError,_UniffiLib.uniffi_bitkitcore_fn_func_get_all_transaction_details,)) + return await _uniffi_rust_call_async( + _UniffiLib.uniffi_bitkitcore_fn_func_jade_disconnect(), + _UniffiLib.ffi_bitkitcore_rust_future_poll_void, + _UniffiLib.ffi_bitkitcore_rust_future_complete_void, + _UniffiLib.ffi_bitkitcore_rust_future_free_void, + # lift function + lambda val: None, + + + # Error FFI converter +_UniffiConverterTypeJadeError, + ) +async def jade_get_account_export(network: "JadeNetwork",account_index: "int",account_types: "typing.List[AccountType]") -> "JadeAccountExport": -def get_all_unique_tags() -> "typing.List[str]": - return _UniffiConverterSequenceString.lift(_uniffi_rust_call_with_error(_UniffiConverterTypeActivityError,_UniffiLib.uniffi_bitkitcore_fn_func_get_all_unique_tags,)) + """ + Fetch the account keys an import needs in one call. + Shaped like `passport_parse_account_export` so applications have a single + import path across signers. Each key is fetched under one held connection, + which matters over Bluetooth where every round trip is slow. + """ -def get_bip39_suggestions(partial_word: "str",limit: "int") -> "typing.List[str]": - _UniffiConverterString.check_lower(partial_word) + _UniffiConverterTypeJadeNetwork.check_lower(network) - _UniffiConverterUInt32.check_lower(limit) + _UniffiConverterUInt32.check_lower(account_index) - return _UniffiConverterSequenceString.lift(_uniffi_rust_call(_UniffiLib.uniffi_bitkitcore_fn_func_get_bip39_suggestions, - _UniffiConverterString.lower(partial_word), - _UniffiConverterUInt32.lower(limit))) + _UniffiConverterSequenceTypeAccountType.check_lower(account_types) + + return await _uniffi_rust_call_async( + _UniffiLib.uniffi_bitkitcore_fn_func_jade_get_account_export( + _UniffiConverterTypeJadeNetwork.lower(network), + _UniffiConverterUInt32.lower(account_index), + _UniffiConverterSequenceTypeAccountType.lower(account_types)), + _UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer, + _UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer, + _UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer, + # lift function + _UniffiConverterTypeJadeAccountExport.lift, + + # Error FFI converter +_UniffiConverterTypeJadeError, + ) +async def jade_get_connected_device() -> "typing.Optional[JadeDeviceInfo]": -def get_bip39_wordlist() -> "typing.List[str]": - return _UniffiConverterSequenceString.lift(_uniffi_rust_call(_UniffiLib.uniffi_bitkitcore_fn_func_get_bip39_wordlist,)) + return await _uniffi_rust_call_async( + _UniffiLib.uniffi_bitkitcore_fn_func_jade_get_connected_device(), + _UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer, + _UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer, + _UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer, + # lift function + _UniffiConverterOptionalTypeJadeDeviceInfo.lift, + + # Error FFI converter -async def get_cjit_entries(entry_ids: "typing.Optional[typing.List[str]]",filter: "typing.Optional[CJitStateEnum]",refresh: "bool") -> "typing.List[IcJitEntry]": + None, - _UniffiConverterOptionalSequenceString.check_lower(entry_ids) - - _UniffiConverterOptionalTypeCJitStateEnum.check_lower(filter) - - _UniffiConverterBool.check_lower(refresh) + ) +async def jade_get_master_fingerprint(network: "JadeNetwork") -> "str": + + """ + The device's master fingerprint, eight lowercase hex characters. + + This must be supplied as `WalletParams.fingerprint` when composing, or the + resulting PSBT carries no BIP32 key origins and the device signs nothing. + """ + + _UniffiConverterTypeJadeNetwork.check_lower(network) return await _uniffi_rust_call_async( - _UniffiLib.uniffi_bitkitcore_fn_func_get_cjit_entries( - _UniffiConverterOptionalSequenceString.lower(entry_ids), - _UniffiConverterOptionalTypeCJitStateEnum.lower(filter), - _UniffiConverterBool.lower(refresh)), + _UniffiLib.uniffi_bitkitcore_fn_func_jade_get_master_fingerprint( + _UniffiConverterTypeJadeNetwork.lower(network)), _UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer, _UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer, _UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer, # lift function - _UniffiConverterSequenceTypeIcJitEntry.lift, + _UniffiConverterString.lift, # Error FFI converter -_UniffiConverterTypeBlocktankError, +_UniffiConverterTypeJadeError, ) +async def jade_get_version_info() -> "typing.Optional[JadeVersionInfo]": -def get_closed_channel_by_id(channel_id: "str") -> "typing.Optional[ClosedChannelDetails]": - _UniffiConverterString.check_lower(channel_id) - - return _UniffiConverterOptionalTypeClosedChannelDetails.lift(_uniffi_rust_call_with_error(_UniffiConverterTypeActivityError,_UniffiLib.uniffi_bitkitcore_fn_func_get_closed_channel_by_id, - _UniffiConverterString.lower(channel_id))) - - -def get_default_gap_limit() -> "int": """ - The default address gap limit used by account scanning and the xpub watcher. - Exposed so platforms reference one source of truth instead of hardcoding 20. + The version summary read at connect, without touching the device. """ - return _UniffiConverterUInt32.lift(_uniffi_rust_call(_UniffiLib.uniffi_bitkitcore_fn_func_get_default_gap_limit,)) - - -def get_default_lsp_balance(params: "DefaultLspBalanceParams") -> "int": - _UniffiConverterTypeDefaultLspBalanceParams.check_lower(params) - - return _UniffiConverterUInt64.lift(_uniffi_rust_call(_UniffiLib.uniffi_bitkitcore_fn_func_get_default_lsp_balance, - _UniffiConverterTypeDefaultLspBalanceParams.lower(params))) + return await _uniffi_rust_call_async( + _UniffiLib.uniffi_bitkitcore_fn_func_jade_get_version_info(), + _UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer, + _UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer, + _UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer, + # lift function + _UniffiConverterOptionalTypeJadeVersionInfo.lift, + + # Error FFI converter + None, -def get_default_wallet_id() -> "str": - return _UniffiConverterString.lift(_uniffi_rust_call(_UniffiLib.uniffi_bitkitcore_fn_func_get_default_wallet_id,)) + ) +async def jade_get_xpub(network: "JadeNetwork",derivation_path: "str") -> "JadeXpubResponse": -async def get_gift(gift_id: "str") -> "IGift": + """ + Fetch an extended public key, echoed back with the path and fingerprint. + """ - _UniffiConverterString.check_lower(gift_id) + _UniffiConverterTypeJadeNetwork.check_lower(network) + + _UniffiConverterString.check_lower(derivation_path) return await _uniffi_rust_call_async( - _UniffiLib.uniffi_bitkitcore_fn_func_get_gift( - _UniffiConverterString.lower(gift_id)), + _UniffiLib.uniffi_bitkitcore_fn_func_jade_get_xpub( + _UniffiConverterTypeJadeNetwork.lower(network), + _UniffiConverterString.lower(derivation_path)), _UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer, _UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer, _UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer, # lift function - _UniffiConverterTypeIGift.lift, + _UniffiConverterTypeJadeXpubResponse.lift, # Error FFI converter -_UniffiConverterTypeBlocktankError, +_UniffiConverterTypeJadeError, ) -async def get_info(refresh: "typing.Optional[bool]") -> "typing.Optional[IBtInfo]": - _UniffiConverterOptionalBool.check_lower(refresh) - +def jade_is_connected() -> "bool": + return _UniffiConverterBool.lift(_uniffi_rust_call(_UniffiLib.uniffi_bitkitcore_fn_func_jade_is_connected,)) + +async def jade_list_devices() -> "typing.List[JadeDeviceInfo]": + + """ + The devices found by the last scan, without starting a new one. + """ + return await _uniffi_rust_call_async( - _UniffiLib.uniffi_bitkitcore_fn_func_get_info( - _UniffiConverterOptionalBool.lower(refresh)), + _UniffiLib.uniffi_bitkitcore_fn_func_jade_list_devices(), _UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer, _UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer, _UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer, # lift function - _UniffiConverterOptionalTypeIBtInfo.lift, + _UniffiConverterSequenceTypeJadeDeviceInfo.lift, # Error FFI converter -_UniffiConverterTypeBlocktankError, + + None, ) -async def get_lnurl_invoice(address: "str",amount_satoshis: "int") -> "str": +async def jade_logout() -> None: + + """ + Lock the device and zero its in-memory key material. + """ - _UniffiConverterString.check_lower(address) - - _UniffiConverterUInt64.check_lower(amount_satoshis) - return await _uniffi_rust_call_async( - _UniffiLib.uniffi_bitkitcore_fn_func_get_lnurl_invoice( - _UniffiConverterString.lower(address), - _UniffiConverterUInt64.lower(amount_satoshis)), - _UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer, - _UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer, - _UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer, + _UniffiLib.uniffi_bitkitcore_fn_func_jade_logout(), + _UniffiLib.ffi_bitkitcore_rust_future_poll_void, + _UniffiLib.ffi_bitkitcore_rust_future_complete_void, + _UniffiLib.ffi_bitkitcore_rust_future_free_void, # lift function - _UniffiConverterString.lift, + lambda val: None, + # Error FFI converter -_UniffiConverterTypeLnurlError, +_UniffiConverterTypeJadeError, ) -async def get_lnurl_invoice_for_pay_data(data: "LnurlPayData",amount_msats: "int",comment: "typing.Optional[str]") -> "str": +async def jade_notify_disconnected(path: "str") -> None: - _UniffiConverterTypeLnurlPayData.check_lower(data) - - _UniffiConverterUInt64.check_lower(amount_msats) - - _UniffiConverterOptionalString.check_lower(comment) + """ + Tell the library that the native layer saw the device disconnect. + + Without this, an idle Bluetooth drop is invisible until the next request. + """ + + _UniffiConverterString.check_lower(path) return await _uniffi_rust_call_async( - _UniffiLib.uniffi_bitkitcore_fn_func_get_lnurl_invoice_for_pay_data( - _UniffiConverterTypeLnurlPayData.lower(data), - _UniffiConverterUInt64.lower(amount_msats), - _UniffiConverterOptionalString.lower(comment)), - _UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer, - _UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer, - _UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer, + _UniffiLib.uniffi_bitkitcore_fn_func_jade_notify_disconnected( + _UniffiConverterString.lower(path)), + _UniffiLib.ffi_bitkitcore_rust_future_poll_void, + _UniffiLib.ffi_bitkitcore_rust_future_complete_void, + _UniffiLib.ffi_bitkitcore_rust_future_free_void, # lift function - _UniffiConverterString.lift, + lambda val: None, + # Error FFI converter -_UniffiConverterTypeLnurlError, + + None, ) -async def get_min_zero_conf_tx_fee(order_id: "str") -> "IBt0ConfMinTxFeeWindow": +async def jade_ping() -> "JadePingStatus": + + """ + Check whether the device is idle, busy, or waiting on the user. + """ - _UniffiConverterString.check_lower(order_id) - return await _uniffi_rust_call_async( - _UniffiLib.uniffi_bitkitcore_fn_func_get_min_zero_conf_tx_fee( - _UniffiConverterString.lower(order_id)), + _UniffiLib.uniffi_bitkitcore_fn_func_jade_ping(), _UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer, _UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer, _UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer, # lift function - _UniffiConverterTypeIBt0ConfMinTxFeeWindow.lift, + _UniffiConverterTypeJadePingStatus.lift, # Error FFI converter -_UniffiConverterTypeBlocktankError, +_UniffiConverterTypeJadeError, ) -async def get_orders(order_ids: "typing.Optional[typing.List[str]]",filter: "typing.Optional[BtOrderState2]",refresh: "bool") -> "typing.List[IBtOrder]": +async def jade_refresh_version_info() -> "JadeVersionInfo": + + """ + Re-read the version summary from the device. + """ - _UniffiConverterOptionalSequenceString.check_lower(order_ids) - - _UniffiConverterOptionalTypeBtOrderState2.check_lower(filter) - - _UniffiConverterBool.check_lower(refresh) - return await _uniffi_rust_call_async( - _UniffiLib.uniffi_bitkitcore_fn_func_get_orders( - _UniffiConverterOptionalSequenceString.lower(order_ids), - _UniffiConverterOptionalTypeBtOrderState2.lower(filter), - _UniffiConverterBool.lower(refresh)), + _UniffiLib.uniffi_bitkitcore_fn_func_jade_refresh_version_info(), _UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer, _UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer, _UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer, # lift function - _UniffiConverterSequenceTypeIBtOrder.lift, + _UniffiConverterTypeJadeVersionInfo.lift, # Error FFI converter -_UniffiConverterTypeBlocktankError, +_UniffiConverterTypeJadeError, ) -async def get_payment(payment_id: "str") -> "IBtBolt11Invoice": +async def jade_scan(timeout_ms: "int") -> "typing.List[JadeDeviceInfo]": - _UniffiConverterString.check_lower(payment_id) + """ + Discover Jade devices. + + Bluetooth discovery is performed by the registered transport callback; on + desktop and Python builds, attached USB serial units are enumerated too. + Returns `DeviceBusy` while a connection is open, because starting a + Bluetooth scan during an active link drops it on Android. + """ + + _UniffiConverterUInt32.check_lower(timeout_ms) return await _uniffi_rust_call_async( - _UniffiLib.uniffi_bitkitcore_fn_func_get_payment( - _UniffiConverterString.lower(payment_id)), + _UniffiLib.uniffi_bitkitcore_fn_func_jade_scan( + _UniffiConverterUInt32.lower(timeout_ms)), _UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer, _UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer, _UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer, # lift function - _UniffiConverterTypeIBtBolt11Invoice.lift, + _UniffiConverterSequenceTypeJadeDeviceInfo.lift, # Error FFI converter -_UniffiConverterTypeBlocktankError, +_UniffiConverterTypeJadeError, ) -def get_pre_activity_metadata(wallet_id: "str",search_key: "str",search_by_address: "bool") -> "typing.Optional[PreActivityMetadata]": - _UniffiConverterString.check_lower(wallet_id) - - _UniffiConverterString.check_lower(search_key) - - _UniffiConverterBool.check_lower(search_by_address) - - return _UniffiConverterOptionalTypePreActivityMetadata.lift(_uniffi_rust_call_with_error(_UniffiConverterTypeActivityError,_UniffiLib.uniffi_bitkitcore_fn_func_get_pre_activity_metadata, - _UniffiConverterString.lower(wallet_id), - _UniffiConverterString.lower(search_key), - _UniffiConverterBool.lower(search_by_address))) - - -def get_pre_activity_metadata_list(wallet_id: "typing.Optional[str]") -> "typing.List[PreActivityMetadata]": +def jade_set_transport_callback(callback: "JadeTransportCallback") -> "bool": """ - Pre-activity metadata for a single wallet scope, or every scope when `wallet_id` is `None`. + Register the native transport. + + Returns `true` when this replaced a previously registered callback, which + lets the application tell a fresh registration from a re-registration. """ - _UniffiConverterOptionalString.check_lower(wallet_id) + _UniffiConverterTypeJadeTransportCallback.check_lower(callback) - return _UniffiConverterSequenceTypePreActivityMetadata.lift(_uniffi_rust_call_with_error(_UniffiConverterTypeActivityError,_UniffiLib.uniffi_bitkitcore_fn_func_get_pre_activity_metadata_list, - _UniffiConverterOptionalString.lower(wallet_id))) + return _UniffiConverterBool.lift(_uniffi_rust_call(_UniffiLib.uniffi_bitkitcore_fn_func_jade_set_transport_callback, + _UniffiConverterTypeJadeTransportCallback.lower(callback))) +async def jade_sign_message(network: "JadeNetwork",derivation_path: "str",message: "str") -> "JadeSignedMessage": -def get_supported_hardware_wallets() -> "typing.List[SupportedHardwareWallet]": """ - The hardware-wallet models supported by Bitkit and their available transports. + Sign a message, returning the signature with the address that verifies it. """ - return _UniffiConverterSequenceTypeSupportedHardwareWallet.lift(_uniffi_rust_call(_UniffiLib.uniffi_bitkitcore_fn_func_get_supported_hardware_wallets,)) - - -def get_tags(wallet_id: "str",activity_id: "str") -> "typing.List[str]": - _UniffiConverterString.check_lower(wallet_id) - - _UniffiConverterString.check_lower(activity_id) - - return _UniffiConverterSequenceString.lift(_uniffi_rust_call_with_error(_UniffiConverterTypeActivityError,_UniffiLib.uniffi_bitkitcore_fn_func_get_tags, - _UniffiConverterString.lower(wallet_id), - _UniffiConverterString.lower(activity_id))) - - -def get_transaction_details(wallet_id: "str",tx_id: "str") -> "typing.Optional[TransactionDetails]": - _UniffiConverterString.check_lower(wallet_id) - - _UniffiConverterString.check_lower(tx_id) + _UniffiConverterTypeJadeNetwork.check_lower(network) - return _UniffiConverterOptionalTypeTransactionDetails.lift(_uniffi_rust_call_with_error(_UniffiConverterTypeActivityError,_UniffiLib.uniffi_bitkitcore_fn_func_get_transaction_details, - _UniffiConverterString.lower(wallet_id), - _UniffiConverterString.lower(tx_id))) - -async def gift_order(client_node_id: "str",code: "str") -> "IGift": - - _UniffiConverterString.check_lower(client_node_id) + _UniffiConverterString.check_lower(derivation_path) - _UniffiConverterString.check_lower(code) + _UniffiConverterString.check_lower(message) return await _uniffi_rust_call_async( - _UniffiLib.uniffi_bitkitcore_fn_func_gift_order( - _UniffiConverterString.lower(client_node_id), - _UniffiConverterString.lower(code)), + _UniffiLib.uniffi_bitkitcore_fn_func_jade_sign_message( + _UniffiConverterTypeJadeNetwork.lower(network), + _UniffiConverterString.lower(derivation_path), + _UniffiConverterString.lower(message)), _UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer, _UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer, _UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer, # lift function - _UniffiConverterTypeIGift.lift, + _UniffiConverterTypeJadeSignedMessage.lift, # Error FFI converter -_UniffiConverterTypeBlocktankError, +_UniffiConverterTypeJadeError, ) -async def gift_pay(invoice: "str") -> "IGift": +async def jade_sign_psbt(network: "JadeNetwork",psbt: "str") -> "str": - _UniffiConverterString.check_lower(invoice) + """ + Sign a PSBT, returning the signed PSBT base64 encoded. + + The reply is checked against what was sent before it is returned. Feed the + result to `finalize_psbt` with the original PSBT, then broadcast with + `onchain_broadcast_raw_tx`. + """ + + _UniffiConverterTypeJadeNetwork.check_lower(network) + + _UniffiConverterString.check_lower(psbt) return await _uniffi_rust_call_async( - _UniffiLib.uniffi_bitkitcore_fn_func_gift_pay( - _UniffiConverterString.lower(invoice)), + _UniffiLib.uniffi_bitkitcore_fn_func_jade_sign_psbt( + _UniffiConverterTypeJadeNetwork.lower(network), + _UniffiConverterString.lower(psbt)), _UniffiLib.ffi_bitkitcore_rust_future_poll_rust_buffer, _UniffiLib.ffi_bitkitcore_rust_future_complete_rust_buffer, _UniffiLib.ffi_bitkitcore_rust_future_free_rust_buffer, # lift function - _UniffiConverterTypeIGift.lift, + _UniffiConverterString.lift, # Error FFI converter -_UniffiConverterTypeBlocktankError, +_UniffiConverterTypeJadeError, ) +async def jade_unlock(network: "JadeNetwork") -> None: -def init_db(base_path: "str") -> "str": - _UniffiConverterString.check_lower(base_path) - - return _UniffiConverterString.lift(_uniffi_rust_call_with_error(_UniffiConverterTypeDbError,_UniffiLib.uniffi_bitkitcore_fn_func_init_db, - _UniffiConverterString.lower(base_path))) + """ + Unlock the device for a network. + Runs the blind pinserver exchange when the device asks for it, which needs + network access. The PIN is entered on the device and never reaches the host. + """ -def insert_activity(activity: "Activity") -> None: - _UniffiConverterTypeActivity.check_lower(activity) + _UniffiConverterTypeJadeNetwork.check_lower(network) - _uniffi_rust_call_with_error(_UniffiConverterTypeActivityError,_UniffiLib.uniffi_bitkitcore_fn_func_insert_activity, - _UniffiConverterTypeActivity.lower(activity)) + return await _uniffi_rust_call_async( + _UniffiLib.uniffi_bitkitcore_fn_func_jade_unlock( + _UniffiConverterTypeJadeNetwork.lower(network)), + _UniffiLib.ffi_bitkitcore_rust_future_poll_void, + _UniffiLib.ffi_bitkitcore_rust_future_complete_void, + _UniffiLib.ffi_bitkitcore_rust_future_free_void, + # lift function + lambda val: None, + + + # Error FFI converter +_UniffiConverterTypeJadeError, + ) +async def jade_verify_address(network: "JadeNetwork",variant: "JadeAddressVariant",derivation_path: "str",expected_address: "str") -> None: -def is_address_used(address: "str") -> "bool": - _UniffiConverterString.check_lower(address) - - return _UniffiConverterBool.lift(_uniffi_rust_call_with_error(_UniffiConverterTypeActivityError,_UniffiLib.uniffi_bitkitcore_fn_func_is_address_used, - _UniffiConverterString.lower(address))) + """ + Display an address on the device and check it against the expected one. + This always prompts on the device screen, so it is a verification step + rather than a way to fetch an address. Returns `AddressMismatch` when the + device disagrees with `expected_address`. + """ -def is_valid_bip39_word(word: "str") -> "bool": - _UniffiConverterString.check_lower(word) + _UniffiConverterTypeJadeNetwork.check_lower(network) - return _UniffiConverterBool.lift(_uniffi_rust_call(_UniffiLib.uniffi_bitkitcore_fn_func_is_valid_bip39_word, - _UniffiConverterString.lower(word))) + _UniffiConverterTypeJadeAddressVariant.check_lower(variant) + + _UniffiConverterString.check_lower(derivation_path) + + _UniffiConverterString.check_lower(expected_address) + + return await _uniffi_rust_call_async( + _UniffiLib.uniffi_bitkitcore_fn_func_jade_verify_address( + _UniffiConverterTypeJadeNetwork.lower(network), + _UniffiConverterTypeJadeAddressVariant.lower(variant), + _UniffiConverterString.lower(derivation_path), + _UniffiConverterString.lower(expected_address)), + _UniffiLib.ffi_bitkitcore_rust_future_poll_void, + _UniffiLib.ffi_bitkitcore_rust_future_complete_void, + _UniffiLib.ffi_bitkitcore_rust_future_free_void, + # lift function + lambda val: None, + + + # Error FFI converter +_UniffiConverterTypeJadeError, + ) async def lnurl_auth(domain: "str",k1: "str",callback: "str",bip32_mnemonic: "str",network: "typing.Optional[Network]",bip39_passphrase: "typing.Optional[str]") -> "str": _UniffiConverterString.check_lower(domain) @@ -24755,6 +27473,13 @@ def wipe_all_transaction_details() -> None: "DecodingError", "HardwareWalletTransport", "HardwareWalletVendor", + "JadeAddressVariant", + "JadeError", + "JadeNetwork", + "JadePingStatus", + "JadeState", + "JadeTransportErrorCode", + "JadeTransportKind", "LnurlError", "ManualRefundStateEnum", "Network", @@ -24827,6 +27552,15 @@ def wipe_all_transaction_details() -> None: "ILspNode", "IManualRefund", "IcJitEntry", + "JadeAccount", + "JadeAccountExport", + "JadeDeviceInfo", + "JadeNativeDevice", + "JadeSignedMessage", + "JadeTransportReadResult", + "JadeTransportResult", + "JadeVersionInfo", + "JadeXpubResponse", "LegacyRnCloseRecoveryScanResult", "LegacyRnCloseRecoverySweepPreview", "LightningActivity", @@ -24973,6 +27707,27 @@ def wipe_all_transaction_details() -> None: "insert_activity", "is_address_used", "is_valid_bip39_word", + "jade_account_type_to_variant", + "jade_cancel", + "jade_connect", + "jade_disconnect", + "jade_get_account_export", + "jade_get_connected_device", + "jade_get_master_fingerprint", + "jade_get_version_info", + "jade_get_xpub", + "jade_is_connected", + "jade_list_devices", + "jade_logout", + "jade_notify_disconnected", + "jade_ping", + "jade_refresh_version_info", + "jade_scan", + "jade_set_transport_callback", + "jade_sign_message", + "jade_sign_psbt", + "jade_unlock", + "jade_verify_address", "lnurl_auth", "mark_activity_as_seen", "migrate_backup_activities_json", @@ -25067,6 +27822,7 @@ def wipe_all_transaction_details() -> None: "wipe_all_transaction_details", "BoltzEventListener", "EventListener", + "JadeTransportCallback", "TrezorTransportCallback", "TrezorUiCallback", "UrDecoder", diff --git a/bindings/python/bitkitcore/libbitkitcore.dylib b/bindings/python/bitkitcore/libbitkitcore.dylib index 36c8603..e0ef4b0 100755 Binary files a/bindings/python/bitkitcore/libbitkitcore.dylib and b/bindings/python/bitkitcore/libbitkitcore.dylib differ diff --git a/bindings/python/setup.py b/bindings/python/setup.py index c81001e..c1b0e2e 100644 --- a/bindings/python/setup.py +++ b/bindings/python/setup.py @@ -2,7 +2,7 @@ setup( name="bitkitcore", - version="0.5.14", + version="0.5.15", packages=find_packages(), package_data={ "bitkitcore": ["*.so", "*.dylib", "*.dll"], diff --git a/src/lib.rs b/src/lib.rs index 0b4cfab..9b79520 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -46,6 +46,13 @@ pub use crate::modules::hardware_wallet::{ get_supported_hardware_wallets, HardwareWalletTransport, HardwareWalletVendor, SupportedHardwareWallet, }; +use crate::modules::jade::JadeManager; +pub use crate::modules::jade::{ + jade_set_transport_callback, JadeAccount, JadeAccountExport, JadeAddressVariant, + JadeDeviceInfo, JadeError, JadeNativeDevice, JadeNetwork, JadePingStatus, JadeSignedMessage, + JadeState, JadeTransportCallback, JadeTransportErrorCode, JadeTransportKind, + JadeTransportReadResult, JadeTransportResult, JadeVersionInfo, JadeXpubResponse, +}; use crate::modules::pubky::{PubkyAuthDetails, PubkyAuthKind, PubkyError, PubkyProfile}; use crate::modules::trezor::account_type_to_script_type; pub use crate::modules::trezor::{ @@ -104,6 +111,7 @@ static DB: OnceCell> = OnceCell::new(); static ASYNC_DB: OnceCell> = OnceCell::new(); static RUNTIME: OnceCell = OnceCell::new(); static TREZOR_MANAGER: OnceCell = OnceCell::new(); +static JADE_MANAGER: OnceCell = OnceCell::new(); fn ensure_runtime() -> &'static Runtime { RUNTIME.get_or_init(|| Runtime::new().expect("Failed to create Tokio runtime")) @@ -2598,8 +2606,314 @@ pub async fn trezor_clear_credentials(device_id: String) -> Result<(), TrezorErr }) } +// ============================================================================ +// Jade Hardware Wallet Functions +// ============================================================================ + +fn get_jade_manager() -> &'static JadeManager { + JADE_MANAGER.get_or_init(JadeManager::new) +} + +/// Discover Jade devices. +/// +/// Bluetooth discovery is performed by the registered transport callback; on +/// desktop and Python builds, attached USB serial units are enumerated too. +/// Returns `DeviceBusy` while a connection is open, because starting a +/// Bluetooth scan during an active link drops it on Android. +#[uniffi::export] +pub async fn jade_scan(timeout_ms: u32) -> Result, JadeError> { + let rt = ensure_runtime(); + rt.spawn(async move { get_jade_manager().scan(timeout_ms).await }) + .await + .unwrap_or_else(|e| { + Err(JadeError::IoError { + error_details: format!("Runtime error: {}", e), + }) + }) +} + +/// The devices found by the last scan, without starting a new one. +#[uniffi::export] +pub async fn jade_list_devices() -> Vec { + let rt = ensure_runtime(); + rt.spawn(async move { get_jade_manager().list_devices().await }) + .await + .unwrap_or_default() +} + +/// Open a device and read its firmware and state summary. +/// +/// The path normally comes from the last `jade_scan`, but a known Bluetooth +/// address or serial path can be passed directly to reconnect without a scan. +/// Any previously open connection is closed first. The returned `jade_state` +/// tells the application what to do next: `Locked` means call `jade_unlock`, +/// `Ready` means the device is already usable, and `Uninit` means the user must +/// create or restore a wallet on the device itself. +#[uniffi::export] +pub async fn jade_connect( + transport: JadeTransportKind, + path: String, +) -> Result { + let rt = ensure_runtime(); + rt.spawn(async move { get_jade_manager().connect(transport, &path).await }) + .await + .unwrap_or_else(|e| { + Err(JadeError::IoError { + error_details: format!("Runtime error: {}", e), + }) + }) +} + +/// Close the device and clear session state. +/// +/// Safe to call while an operation is waiting on a confirmation: the pending +/// request returns `UserCancelled` promptly rather than running out its deadline. +#[uniffi::export] +pub async fn jade_disconnect() -> Result<(), JadeError> { + let rt = ensure_runtime(); + rt.spawn(async move { get_jade_manager().disconnect().await }) + .await + .unwrap_or_else(|e| { + Err(JadeError::IoError { + error_details: format!("Runtime error: {}", e), + }) + }) +} + +/// Abort the operation in flight. +/// +/// Jade has no cancel message, so this closes the link. The application should +/// reconnect afterwards. This is what backs a cancel button on a signing screen. +#[uniffi::export] +pub async fn jade_cancel() -> Result<(), JadeError> { + let rt = ensure_runtime(); + rt.spawn(async move { get_jade_manager().cancel().await }) + .await + .unwrap_or_else(|e| { + Err(JadeError::IoError { + error_details: format!("Runtime error: {}", e), + }) + }) +} + +/// Tell the library that the native layer saw the device disconnect. +/// +/// Without this, an idle Bluetooth drop is invisible until the next request. +#[uniffi::export] +pub async fn jade_notify_disconnected(path: String) { + let rt = ensure_runtime(); + let _ = rt + .spawn(async move { get_jade_manager().notify_disconnected(&path).await }) + .await; +} + +#[uniffi::export] +pub fn jade_is_connected() -> bool { + get_jade_manager().is_connected() +} + +#[uniffi::export] +pub async fn jade_get_connected_device() -> Option { + let rt = ensure_runtime(); + rt.spawn(async move { get_jade_manager().connected_device().await }) + .await + .unwrap_or(None) +} + +/// The version summary read at connect, without touching the device. +#[uniffi::export] +pub async fn jade_get_version_info() -> Option { + let rt = ensure_runtime(); + rt.spawn(async move { get_jade_manager().version_info().await }) + .await + .unwrap_or(None) +} + +/// Re-read the version summary from the device. +#[uniffi::export] +pub async fn jade_refresh_version_info() -> Result { + let rt = ensure_runtime(); + rt.spawn(async move { get_jade_manager().refresh_version_info().await }) + .await + .unwrap_or_else(|e| { + Err(JadeError::IoError { + error_details: format!("Runtime error: {}", e), + }) + }) +} + +/// Check whether the device is idle, busy, or waiting on the user. +#[uniffi::export] +pub async fn jade_ping() -> Result { + let rt = ensure_runtime(); + rt.spawn(async move { get_jade_manager().ping().await }) + .await + .unwrap_or_else(|e| { + Err(JadeError::IoError { + error_details: format!("Runtime error: {}", e), + }) + }) +} + +/// Unlock the device for a network. +/// +/// Runs the blind pinserver exchange when the device asks for it, which needs +/// network access. The PIN is entered on the device and never reaches the host. +#[uniffi::export] +pub async fn jade_unlock(network: JadeNetwork) -> Result<(), JadeError> { + let rt = ensure_runtime(); + rt.spawn(async move { get_jade_manager().unlock(network).await }) + .await + .unwrap_or_else(|e| { + Err(JadeError::IoError { + error_details: format!("Runtime error: {}", e), + }) + }) +} + +/// Lock the device and zero its in-memory key material. +#[uniffi::export] +pub async fn jade_logout() -> Result<(), JadeError> { + let rt = ensure_runtime(); + rt.spawn(async move { get_jade_manager().logout().await }) + .await + .unwrap_or_else(|e| { + Err(JadeError::IoError { + error_details: format!("Runtime error: {}", e), + }) + }) +} + +/// Fetch an extended public key, echoed back with the path and fingerprint. +#[uniffi::export] +pub async fn jade_get_xpub( + network: JadeNetwork, + derivation_path: String, +) -> Result { + let rt = ensure_runtime(); + rt.spawn(async move { get_jade_manager().get_xpub(network, derivation_path).await }) + .await + .unwrap_or_else(|e| { + Err(JadeError::IoError { + error_details: format!("Runtime error: {}", e), + }) + }) +} + +/// The device's master fingerprint, eight lowercase hex characters. +/// +/// This must be supplied as `WalletParams.fingerprint` when composing, or the +/// resulting PSBT carries no BIP32 key origins and the device signs nothing. +#[uniffi::export] +pub async fn jade_get_master_fingerprint(network: JadeNetwork) -> Result { + let rt = ensure_runtime(); + rt.spawn(async move { get_jade_manager().master_fingerprint(network).await }) + .await + .unwrap_or_else(|e| { + Err(JadeError::IoError { + error_details: format!("Runtime error: {}", e), + }) + }) +} + +/// Fetch the account keys an import needs in one call. +/// +/// Shaped like `passport_parse_account_export` so applications have a single +/// import path across signers. Each key is fetched under one held connection, +/// which matters over Bluetooth where every round trip is slow. +#[uniffi::export] +pub async fn jade_get_account_export( + network: JadeNetwork, + account_index: u32, + account_types: Vec, +) -> Result { + let rt = ensure_runtime(); + rt.spawn(async move { + get_jade_manager() + .account_export(network, account_index, account_types) + .await + }) + .await + .unwrap_or_else(|e| { + Err(JadeError::IoError { + error_details: format!("Runtime error: {}", e), + }) + }) +} + +/// Display an address on the device and check it against the expected one. +/// +/// This always prompts on the device screen, so it is a verification step +/// rather than a way to fetch an address. Returns `AddressMismatch` when the +/// device disagrees with `expected_address`. +#[uniffi::export] +pub async fn jade_verify_address( + network: JadeNetwork, + variant: JadeAddressVariant, + derivation_path: String, + expected_address: String, +) -> Result<(), JadeError> { + let rt = ensure_runtime(); + rt.spawn(async move { + get_jade_manager() + .verify_address(network, variant, derivation_path, expected_address) + .await + }) + .await + .unwrap_or_else(|e| { + Err(JadeError::IoError { + error_details: format!("Runtime error: {}", e), + }) + }) +} + +/// Sign a message, returning the signature with the address that verifies it. +#[uniffi::export] +pub async fn jade_sign_message( + network: JadeNetwork, + derivation_path: String, + message: String, +) -> Result { + let rt = ensure_runtime(); + rt.spawn(async move { + get_jade_manager() + .sign_message(network, derivation_path, message) + .await + }) + .await + .unwrap_or_else(|e| { + Err(JadeError::IoError { + error_details: format!("Runtime error: {}", e), + }) + }) +} + +/// Sign a PSBT, returning the signed PSBT base64 encoded. +/// +/// The reply is checked against what was sent before it is returned. Feed the +/// result to `finalize_psbt` with the original PSBT, then broadcast with +/// `onchain_broadcast_raw_tx`. +#[uniffi::export] +pub async fn jade_sign_psbt(network: JadeNetwork, psbt: String) -> Result { + let rt = ensure_runtime(); + rt.spawn(async move { get_jade_manager().sign_psbt(network, psbt).await }) + .await + .unwrap_or_else(|e| { + Err(JadeError::IoError { + error_details: format!("Runtime error: {}", e), + }) + }) +} + +/// Map a generic account type onto Jade's descriptor variant. +#[uniffi::export] +pub fn jade_account_type_to_variant(account_type: AccountType) -> JadeAddressVariant { + crate::modules::jade::account_type_to_variant(account_type) +} + // ============================================================================ // Account info FFI exports + // ============================================================================ /// Query account information for an extended public key via Electrum. diff --git a/src/modules/hardware_wallet/catalog.rs b/src/modules/hardware_wallet/catalog.rs index 6180ff1..a3ef820 100644 --- a/src/modules/hardware_wallet/catalog.rs +++ b/src/modules/hardware_wallet/catalog.rs @@ -13,6 +13,14 @@ pub fn get_supported_hardware_wallets() -> Vec { transports, }; + let jade = |model: &str, display_name: &str| SupportedHardwareWallet { + vendor: HardwareWalletVendor::Blockstream, + vendor_name: "Blockstream".to_string(), + model: model.to_string(), + display_name: display_name.to_string(), + transports: vec![Usb, Bluetooth], + }; + vec![ trezor("Model One", vec![Usb]), trezor("Model T", vec![Usb]), @@ -26,5 +34,9 @@ pub fn get_supported_hardware_wallets() -> Vec { display_name: "Foundation Passport".to_string(), transports: vec![Qr], }, + // Jade's USB link is CDC serial rather than HID, reported here as Usb + // because that is what a user plugs in. + jade("Jade", "Blockstream Jade"), + jade("Jade Plus", "Blockstream Jade Plus"), ] } diff --git a/src/modules/hardware_wallet/tests.rs b/src/modules/hardware_wallet/tests.rs index d13ca08..ace3d9c 100644 --- a/src/modules/hardware_wallet/tests.rs +++ b/src/modules/hardware_wallet/tests.rs @@ -4,7 +4,7 @@ use super::{get_supported_hardware_wallets, HardwareWalletTransport, HardwareWal fn catalog_lists_supported_models_and_transports() { let wallets = get_supported_hardware_wallets(); - assert_eq!(wallets.len(), 6); + assert_eq!(wallets.len(), 8); assert!(wallets .iter() .filter(|wallet| wallet.vendor == HardwareWalletVendor::Trezor) @@ -24,4 +24,17 @@ fn catalog_lists_supported_models_and_transports() { .unwrap(); assert_eq!(passport.vendor, HardwareWalletVendor::Foundation); assert_eq!(passport.transports, [HardwareWalletTransport::Qr]); + + let jades: Vec<_> = wallets + .iter() + .filter(|wallet| wallet.vendor == HardwareWalletVendor::Blockstream) + .collect(); + assert_eq!(jades.len(), 2); + assert!(jades.iter().all(|wallet| { + wallet.transports.contains(&HardwareWalletTransport::Usb) + && wallet + .transports + .contains(&HardwareWalletTransport::Bluetooth) + })); + assert!(jades.iter().any(|wallet| wallet.model == "Jade Plus")); } diff --git a/src/modules/hardware_wallet/types.rs b/src/modules/hardware_wallet/types.rs index f8ce601..325e69e 100644 --- a/src/modules/hardware_wallet/types.rs +++ b/src/modules/hardware_wallet/types.rs @@ -3,6 +3,7 @@ pub enum HardwareWalletVendor { Trezor, Foundation, + Blockstream, } /// How an application exchanges data with a hardware wallet. diff --git a/src/modules/jade/README.md b/src/modules/jade/README.md new file mode 100644 index 0000000..4ab201c --- /dev/null +++ b/src/modules/jade/README.md @@ -0,0 +1,118 @@ +# Jade Module - Technical Overview + +Blockstream Jade support for bitkit-core, over Bluetooth (all platforms) and USB +CDC serial (desktop and Python). Bitcoin single signature only. + +The protocol itself lives in +[`jade-client-rs`](https://github.com/coreyphillips/jade-client-rs). This module +is the FFI adapter. For the wire format, the pinserver exchange, PSBT checks and +the transport contract, read that crate's documentation; what follows is only +what is specific to bitkit-core. + +## Architecture + +``` +┌──────────────────────────────────────────────────────────────────────┐ +│ bitkit-android / bitkit-ios │ +│ implements JadeTransportCallback: BLE, and USB host on Android │ +└───────────────────────────────┬──────────────────────────────────────┘ + │ UniFFI +┌───────────────────────────────▼──────────────────────────────────────┐ +│ bitkit-core │ +│ lib.rs jade_* exports over a global JadeManager │ +│ implementation.rs session lock, device list, abort handle │ +│ callbacks.rs JadeTransportCallback + bridge to JadeTransport │ +│ types.rs #[uniffi::remote] scaffolding for crate types │ +└───────────────────────────────┬──────────────────────────────────────┘ + │ +┌───────────────────────────────▼──────────────────────────────────────┐ +│ jade-client-rs │ +│ CBOR protocol, pinserver, PSBT checks, serial transport │ +└──────────────────────────────────────────────────────────────────────┘ +``` + +## Why the types are declared with `#[uniffi::remote]` + +The crate's types carry no binding framework. `types.rs` attaches UniFFI +scaffolding to them from here, which generates the same code a +`#[derive(uniffi::…)]` would without a mirrored set of structs. + +This is the main way this module differs from `trezor`, which predates the +technique: that module maintains roughly 900 lines of parallel types and +hand-written `From` conversions in both directions against +`trezor-connect-rs`. The declarations here have to match upstream field for +field, and the compiler enforces it. + +One consequence worth knowing: `#[uniffi::remote(Error)]` needs to match every +variant, so `jade_client_rs::JadeError` deliberately is not `#[non_exhaustive]`. + +## Session state + +`jade_client_rs::Jade` takes `&mut self` per operation, so the one request at a +time rule is a compile time property there. A free-function FFI surface needs a +process global, so `JadeManager` supplies the lock that implies. + +The abort handle is kept outside that lock on purpose. Sharing one lock would +make `jade_disconnect` and every status read queue behind a five minute +confirmation, and UniFFI async exports are detached onto the runtime, so a +cancelled Swift or Kotlin task does not cancel the Rust future by itself. +`jade_cancel` and `jade_disconnect` therefore close the transport through a +`CancelHandle` without taking the session lock. + +## Transport bridge + +`JadeTransportCallback` is the `#[uniffi::export(with_foreign)]` trait the +application implements; `CallbackTransport` adapts it onto the crate's +`JadeTransport`. Every callback invocation runs on the tokio blocking pool, so a +slow implementation costs a blocking thread rather than a runtime worker. + +The full Bluetooth contract, including the two second inter-chunk deadline and +the write-with-response requirement, is documented on the trait and in the +crate's README. Read it before writing a native implementation; each of those +rules fails only against real hardware. + +Errors cross the boundary as a typed `JadeTransportErrorCode` rather than an +error string. The trezor adapter has to encode its code into a sentinel string +and parse it back out, because its upstream crate offers no typed channel. + +## Signing + +Jade returns a signed PSBT, so it follows the Passport path: + +``` +onchain_compose_transaction -> psbt (base64) +jade_sign_psbt -> signed psbt (base64) +finalize_psbt(original, signed) -> CompletedTransaction +onchain_broadcast_raw_tx +``` + +`WalletParams.fingerprint` must be set to the value from +`jade_get_master_fingerprint`, or the composed PSBT carries no BIP32 key origins +and the device signs nothing. The crate rejects that case before the round trip +with `FingerprintMismatch`. + +## Constraints + +- No `#[uniffi::export]` item here may be `cfg` gated. All three build scripts + generate bindings from the host library, so a host only export would appear in + the generated Swift and Kotlin while being absent from the device library. +- No `u8` or `u16` in the FFI surface. `ping` returns `JadePingStatus` and + `battery_status` is `u32`, keeping this module clear of the narrow unsigned + return path that needed a binding generator fix for Android ARM32. +- Registering a transport callback twice replaces the first, so an Android + activity restart can re-register. The replacement is logged. + +## Dependency + +Pinned by git revision until the crate is published to crates.io, so bitkit-core +never depends on an unreleased version. Bumping it means updating both target +tables in `Cargo.toml`. + +## Testing + +```bash +cargo test modules::jade # adapter only +``` + +Protocol level tests live in the crate and run with `cargo test` there, against +a scripted mock device and a fake pinserver. diff --git a/src/modules/jade/callbacks.rs b/src/modules/jade/callbacks.rs new file mode 100644 index 0000000..d05f08e --- /dev/null +++ b/src/modules/jade/callbacks.rs @@ -0,0 +1,230 @@ +//! The transport contract the native application implements, and the bridge +//! from it to the protocol crate's transport trait. +//! +//! Rust owns the Jade protocol; the application owns the bytes. On iOS that +//! means CoreBluetooth against the Nordic UART Service, and on Android the +//! Bluetooth API plus, optionally, the USB Host API for CDC serial. +//! +//! Methods are synchronous because that is the shape the trezor module already +//! established here. Every one of them is invoked on the blocking pool, so a +//! slow implementation costs a blocking thread rather than a runtime worker. + +use std::sync::{Arc, RwLock}; +use std::time::Duration; + +use async_trait::async_trait; +use jade_client_rs::{JadeError, JadeTransport, JadeTransportErrorCode, MAX_CHUNK_BYTES}; + +use super::types::JadeTransportKind; + +/// A device the native layer discovered. +#[derive(Debug, Clone, uniffi::Record)] +pub struct JadeNativeDevice { + /// Transport specific address: a BLE identifier or a serial device path. + pub path: String, + pub transport: JadeTransportKind, + /// Advertised or descriptor name, for example "Jade C0FFEE". + pub name: Option, + pub serial_number: Option, +} + +/// Outcome of an operation that returns no data. +#[derive(Debug, Clone, uniffi::Record)] +pub struct JadeTransportResult { + pub success: bool, + /// Empty on success. + pub error: String, + pub error_code: Option, +} + +/// Outcome of a read. +#[derive(Debug, Clone, uniffi::Record)] +pub struct JadeTransportReadResult { + pub success: bool, + /// Bytes read. Success with an empty vector means nothing has arrived yet, + /// which is the normal case while the user is deciding on the device. + pub data: Vec, + /// Empty on success. + pub error: String, + pub error_code: Option, +} + +/// Native transport for Jade. +/// +/// # Bluetooth contract +/// +/// Jade advertises the Nordic UART Service: +/// +/// - service `6e400001-b5a3-f393-e0a9-e50e24dcca9e` +/// - write `6e400002-b5a3-f393-e0a9-e50e24dcca9e` (host to Jade) +/// - notify `6e400003-b5a3-f393-e0a9-e50e24dcca9e` (Jade to host) +/// +/// Devices advertise as "Jade" or "Jade ". +/// +/// Three requirements that are easy to miss and break signing on real hardware: +/// +/// 1. **Write with response.** Write-without-response silently drops chunks on +/// the ESP32 GATT stack. +/// 2. **Do not pause between chunks.** Firmware discards a partially received +/// message after two seconds of silence, three on Jade v1, and answers with +/// an unattributed error. A 30 KB PSBT is roughly 60 writes, so any UI thread +/// stall in the middle of a send breaks the operation. +/// 3. **`read_chunk` must return promptly.** Honour `timeout_ms`, which this +/// crate keeps short. The long per-operation deadline is enforced in Rust so +/// the user can cancel. +#[uniffi::export(with_foreign)] +pub trait JadeTransportCallback: Send + Sync { + /// Discover devices, blocking up to `timeout_ms`. + fn scan_devices(&self, timeout_ms: u32) -> Vec; + + /// Open a connection and enable notifications. + fn open_device(&self, path: String) -> JadeTransportResult; + + /// Close the connection and release the device. + fn close_device(&self, path: String) -> JadeTransportResult; + + /// Write one chunk, no larger than `get_chunk_size`. + fn write_chunk(&self, path: String, data: Vec) -> JadeTransportResult; + + /// Read whatever has arrived, waiting at most `timeout_ms`. + /// + /// Returning success with an empty vector is normal and means "nothing yet". + fn read_chunk(&self, path: String, timeout_ms: u32) -> JadeTransportReadResult; + + /// Maximum bytes per write. + /// + /// For Bluetooth this is `min(negotiated_mtu - 3, 509)`. The value is + /// clamped into a usable range, so an unnegotiated `0` is not fatal. + fn get_chunk_size(&self, path: String) -> u32; +} + +/// The registered callback. +/// +/// A read-write cell rather than a write-once cell on purpose. An Android +/// activity restart rebuilds the Bluetooth manager and registers a fresh +/// implementation; silently keeping the first one would leave this crate calling +/// into a dead context with no recovery short of killing the process. +static TRANSPORT_CALLBACK: RwLock>> = RwLock::new(None); + +/// Register the native transport. +/// +/// Returns `true` when this replaced a previously registered callback, which +/// lets the application tell a fresh registration from a re-registration. +#[uniffi::export] +pub fn jade_set_transport_callback(callback: Arc) -> bool { + #[cfg(target_os = "android")] + crate::init_android_logger(); + + let mut guard = TRANSPORT_CALLBACK + .write() + .unwrap_or_else(std::sync::PoisonError::into_inner); + let replaced = guard.is_some(); + if replaced { + log::warn!("[jade] transport callback replaced"); + } + *guard = Some(callback); + replaced +} + +/// Fetch the registered transport, if any. +pub(crate) fn transport_callback() -> Option> { + TRANSPORT_CALLBACK + .read() + .unwrap_or_else(std::sync::PoisonError::into_inner) + .clone() +} + +fn to_error(code: Option, message: String) -> JadeError { + match code { + Some(code) => JadeError::from(code), + None => JadeError::TransportError { + error_details: message, + }, + } +} + +/// Bridges the foreign callback onto the protocol crate's transport trait. +/// +/// The error code travels as a typed value the whole way, so nothing has to be +/// encoded into an error string and parsed back out. The trezor adapter in this +/// repo does exactly that, because its upstream crate offers no typed channel. +pub(crate) struct CallbackTransport { + callback: Arc, + path: String, + chunk_size: usize, +} + +impl CallbackTransport { + pub(crate) fn new(callback: Arc, path: String) -> Self { + // Clamp whatever the native layer reports. A zero would make the write + // loop fail to advance, and anything above the Bluetooth cap would be + // rejected by the link layer. + let reported = callback.get_chunk_size(path.clone()); + let chunk_size = reported.clamp(1, MAX_CHUNK_BYTES) as usize; + Self { + callback, + path, + chunk_size, + } + } +} + +#[async_trait] +impl JadeTransport for CallbackTransport { + async fn write_all(&self, data: Vec) -> Result<(), JadeError> { + let callback = Arc::clone(&self.callback); + let path = self.path.clone(); + let chunk_size = self.chunk_size; + + // Foreign callbacks are synchronous and can block. Running them on a + // worker thread would park it for the duration; the blocking pool is + // sized for exactly this. + tokio::task::spawn_blocking(move || { + for chunk in data.chunks(chunk_size) { + let result = callback.write_chunk(path.clone(), chunk.to_vec()); + if !result.success { + return Err(to_error(result.error_code, result.error)); + } + } + Ok(()) + }) + .await + .map_err(|error| JadeError::IoError { + error_details: format!("write task failed: {error}"), + })? + } + + async fn read_some(&self, timeout: Duration) -> Result, JadeError> { + let callback = Arc::clone(&self.callback); + let path = self.path.clone(); + let timeout_ms = timeout.as_millis().min(u128::from(u32::MAX)) as u32; + + tokio::task::spawn_blocking(move || { + let result = callback.read_chunk(path, timeout_ms); + if !result.success { + return Err(to_error(result.error_code, result.error)); + } + Ok(result.data) + }) + .await + .map_err(|error| JadeError::IoError { + error_details: format!("read task failed: {error}"), + })? + } + + async fn close(&self) -> Result<(), JadeError> { + let callback = Arc::clone(&self.callback); + let path = self.path.clone(); + tokio::task::spawn_blocking(move || { + let result = callback.close_device(path); + if !result.success { + return Err(to_error(result.error_code, result.error)); + } + Ok(()) + }) + .await + .map_err(|error| JadeError::IoError { + error_details: format!("close task failed: {error}"), + })? + } +} diff --git a/src/modules/jade/implementation.rs b/src/modules/jade/implementation.rs new file mode 100644 index 0000000..9dc1dec --- /dev/null +++ b/src/modules/jade/implementation.rs @@ -0,0 +1,377 @@ +//! Session state for the FFI surface. +//! +//! `jade_client_rs::Jade` takes `&mut self` for every operation, which makes the +//! one-request-at-a-time rule a compile time property. The FFI surface here is a +//! set of free functions over a process global, so this adds the lock that shape +//! implies, plus the device list and the abort handle. +//! +//! The abort handle is deliberately kept outside the session lock. Holding one +//! lock for both would make `jade_disconnect` and every status read queue behind +//! a five minute confirmation, and UniFFI async exports are detached onto the +//! runtime, so a cancelled Swift or Kotlin task does not cancel the Rust future +//! by itself. + +use std::sync::atomic::{AtomicBool, Ordering}; +use std::sync::Arc; + +use base64::{engine::general_purpose::STANDARD, Engine as _}; +use bitcoin::psbt::Psbt; +use jade_client_rs::{CancelHandle, Jade, JadeTransport}; +use tokio::sync::{Mutex, RwLock}; + +use super::callbacks::{transport_callback, CallbackTransport}; +use super::types::*; +use crate::onchain::AccountType; + +/// A device seen by the last scan. +#[derive(Debug, Clone)] +struct CachedDevice { + info: JadeDeviceInfo, +} + +pub struct JadeManager { + device_list: Mutex>, + /// Held for exactly one operation. + session: Mutex>, + /// Cloned out by the abort path, which must not wait on `session`. + cancel: RwLock>, + /// Cheap status reads that never touch a lock held across device I/O. + connected: AtomicBool, + connected_device: RwLock>, +} + +impl Default for JadeManager { + fn default() -> Self { + Self::new() + } +} + +impl JadeManager { + pub fn new() -> Self { + Self { + device_list: Mutex::new(Vec::new()), + session: Mutex::new(None), + cancel: RwLock::new(None), + connected: AtomicBool::new(false), + connected_device: RwLock::new(None), + } + } + + // ------------------------------------------------------------------ + // Discovery + // ------------------------------------------------------------------ + + /// Discover devices on every transport this build supports. + pub async fn scan(&self, timeout_ms: u32) -> Result, JadeError> { + // Starting a Bluetooth scan while a GATT link is up reliably drops it on + // Android, so refuse rather than silently breaking the open session. + if self.connected.load(Ordering::SeqCst) { + return Err(JadeError::DeviceBusy); + } + + let mut discovered: Vec = Vec::new(); + + if let Some(callback) = transport_callback() { + let found = tokio::task::spawn_blocking(move || callback.scan_devices(timeout_ms)) + .await + .map_err(|error| JadeError::IoError { + error_details: format!("scan task failed: {error}"), + })?; + discovered.extend(found.into_iter().map(|device| JadeDeviceInfo { + path: device.path, + transport: device.transport, + name: device.name, + serial_number: device.serial_number, + })); + } + + #[cfg(not(any(target_os = "ios", target_os = "android")))] + discovered.extend(jade_client_rs::serial::enumerate_devices()); + + *self.device_list.lock().await = discovered + .iter() + .cloned() + .map(|info| CachedDevice { info }) + .collect(); + Ok(discovered) + } + + /// The devices found by the last scan. + pub async fn list_devices(&self) -> Vec { + self.device_list + .lock() + .await + .iter() + .map(|device| device.info.clone()) + .collect() + } + + // ------------------------------------------------------------------ + // Connection lifecycle + // ------------------------------------------------------------------ + + /// Open a device and read its version summary. + /// + /// A path the last scan did not report is accepted as well: a Bluetooth + /// address stays valid across scans, and a device that just stopped + /// advertising, or was reconnected before the next scan, would otherwise be + /// unreachable until a scan happens to see it again. The native transport + /// reports an unreachable path when it opens it. + pub async fn connect( + &self, + transport_kind: JadeTransportKind, + path: &str, + ) -> Result { + let device = { + let devices = self.device_list.lock().await; + devices + .iter() + .find(|candidate| { + candidate.info.transport == transport_kind && candidate.info.path == path + }) + .map(|candidate| candidate.info.clone()) + .unwrap_or_else(|| JadeDeviceInfo { + path: path.to_string(), + transport: transport_kind, + name: None, + serial_number: None, + }) + }; + + // Close anything already open first. Overwriting the session would + // strand the native handle with no path left to close it. + self.disconnect().await?; + + let transport = self.build_transport(transport_kind, path).await?; + let session = Jade::connect(transport).await?; + let version = session.version_info().clone(); + + *self.cancel.write().await = Some(session.cancel_handle()); + *self.connected_device.write().await = Some(device); + *self.session.lock().await = Some(session); + self.connected.store(true, Ordering::SeqCst); + + Ok(version) + } + + async fn build_transport( + &self, + transport_kind: JadeTransportKind, + path: &str, + ) -> Result, JadeError> { + // A serial device found by the crate's own enumeration is driven + // directly; anything the native layer reported goes back through it. + #[cfg(not(any(target_os = "ios", target_os = "android")))] + if transport_kind == JadeTransportKind::Serial + && jade_client_rs::serial::enumerate_devices() + .iter() + .any(|device| device.path == path) + { + return Ok(Arc::new(jade_client_rs::SerialTransport::open(path)?)); + } + + let callback = transport_callback().ok_or(JadeError::NotInitialized)?; + let open_path = path.to_string(); + let opener = Arc::clone(&callback); + let result = tokio::task::spawn_blocking(move || opener.open_device(open_path)) + .await + .map_err(|error| JadeError::IoError { + error_details: format!("open task failed: {error}"), + })?; + if !result.success { + return Err(JadeError::ConnectionError { + error_details: result.error, + }); + } + Ok(Arc::new(CallbackTransport::new(callback, path.to_string()))) + } + + /// Close the device and clear session state. + /// + /// Safe to call while an operation is in flight: the cancel handle closes + /// the transport without taking the session lock, so a blocked request + /// returns promptly instead of running out its deadline. + pub async fn disconnect(&self) -> Result<(), JadeError> { + self.connected.store(false, Ordering::SeqCst); + + if let Some(cancel) = self.cancel.write().await.take() { + if let Err(error) = cancel.cancel().await { + log::debug!("[jade] error closing the transport: {error}"); + } + } + *self.connected_device.write().await = None; + *self.session.lock().await = None; + Ok(()) + } + + /// Abort the operation in flight without tearing down session state. + /// + /// Jade has no cancel message, so closing the link is the only way to stop a + /// pending confirmation. The application is expected to reconnect. + pub async fn cancel(&self) -> Result<(), JadeError> { + let handle = self.cancel.read().await.clone(); + if let Some(handle) = handle { + handle.cancel().await?; + } + Ok(()) + } + + /// Record a disconnect the native layer noticed while nothing was in flight. + pub async fn notify_disconnected(&self, path: &str) { + let matches = self + .connected_device + .read() + .await + .as_ref() + .map(|device| device.path == path) + .unwrap_or(false); + if matches { + log::debug!("[jade] native layer reported a disconnect"); + let _ = self.disconnect().await; + } + } + + pub fn is_connected(&self) -> bool { + self.connected.load(Ordering::SeqCst) + } + + pub async fn connected_device(&self) -> Option { + self.connected_device.read().await.clone() + } + + /// The version summary read at connect, or refreshed since. + pub async fn version_info(&self) -> Option { + self.session + .lock() + .await + .as_ref() + .map(|session| session.version_info().clone()) + } + + /// Re-read the version summary from the device. + pub async fn refresh_version_info(&self) -> Result { + let mut guard = self.session.lock().await; + let session = guard.as_mut().ok_or(JadeError::NotConnected)?; + session.refresh_version_info().await.cloned() + } + + // ------------------------------------------------------------------ + // Operations + // ------------------------------------------------------------------ + + pub async fn ping(&self) -> Result { + let mut guard = self.session.lock().await; + guard.as_mut().ok_or(JadeError::NotConnected)?.ping().await + } + + pub async fn unlock(&self, network: JadeNetwork) -> Result<(), JadeError> { + let mut guard = self.session.lock().await; + guard + .as_mut() + .ok_or(JadeError::NotConnected)? + .unlock(network) + .await + } + + pub async fn logout(&self) -> Result<(), JadeError> { + let mut guard = self.session.lock().await; + guard + .as_mut() + .ok_or(JadeError::NotConnected)? + .logout() + .await + } + + pub async fn master_fingerprint(&self, network: JadeNetwork) -> Result { + let mut guard = self.session.lock().await; + guard + .as_mut() + .ok_or(JadeError::NotConnected)? + .master_fingerprint(network) + .await + } + + pub async fn get_xpub( + &self, + network: JadeNetwork, + derivation_path: String, + ) -> Result { + let mut guard = self.session.lock().await; + guard + .as_mut() + .ok_or(JadeError::NotConnected)? + .get_xpub(network, &derivation_path) + .await + } + + pub async fn account_export( + &self, + network: JadeNetwork, + account_index: u32, + account_types: Vec, + ) -> Result { + let variants: Vec = account_types + .into_iter() + .map(account_type_to_variant) + .collect(); + let mut guard = self.session.lock().await; + guard + .as_mut() + .ok_or(JadeError::NotConnected)? + .account_export(network, account_index, &variants) + .await + } + + pub async fn verify_address( + &self, + network: JadeNetwork, + variant: JadeAddressVariant, + derivation_path: String, + expected_address: String, + ) -> Result<(), JadeError> { + let mut guard = self.session.lock().await; + guard + .as_mut() + .ok_or(JadeError::NotConnected)? + .verify_address(network, variant, &derivation_path, &expected_address) + .await + } + + pub async fn sign_message( + &self, + network: JadeNetwork, + derivation_path: String, + message: String, + ) -> Result { + let mut guard = self.session.lock().await; + guard + .as_mut() + .ok_or(JadeError::NotConnected)? + .sign_message(network, &derivation_path, &message) + .await + } + + /// Sign a base64 PSBT and return the signed PSBT, base64 encoded. + /// + /// The FFI surface speaks base64 because that is what `compose_transaction` + /// emits and what `finalize_psbt` expects; the protocol crate works in typed + /// PSBTs, so the encoding boundary lives here. + pub async fn sign_psbt(&self, network: JadeNetwork, psbt: String) -> Result { + let bytes = STANDARD + .decode(psbt.trim()) + .map_err(|error| JadeError::InvalidPsbt { + error_details: format!("base64 decoding failed: {error}"), + })?; + let parsed = Psbt::deserialize(&bytes).map_err(|error| JadeError::InvalidPsbt { + error_details: format!("parsing failed: {error}"), + })?; + + let mut guard = self.session.lock().await; + let signed = guard + .as_mut() + .ok_or(JadeError::NotConnected)? + .sign_psbt(network, &parsed) + .await?; + Ok(STANDARD.encode(signed.serialize())) + } +} diff --git a/src/modules/jade/mod.rs b/src/modules/jade/mod.rs new file mode 100644 index 0000000..ce2800c --- /dev/null +++ b/src/modules/jade/mod.rs @@ -0,0 +1,29 @@ +//! Blockstream Jade hardware wallet integration. +//! +//! The protocol lives in the `jade-client-rs` crate. This module is the FFI +//! adapter: it attaches UniFFI scaffolding to that crate's types, exposes the +//! transport contract the native application implements, and owns the session +//! state a free-function FFI surface implies. +//! +//! One hard rule for anything added here: no `#[uniffi::export]` item may be +//! `cfg` gated. All three build scripts generate bindings from the host library +//! rather than the target one, so a host only export would appear in the +//! generated Swift and Kotlin while being absent from the device library. + +mod callbacks; +mod implementation; +#[cfg(test)] +mod tests; +mod types; + +pub use callbacks::{ + jade_set_transport_callback, JadeNativeDevice, JadeTransportCallback, JadeTransportReadResult, + JadeTransportResult, +}; +pub use implementation::JadeManager; +pub(crate) use types::account_type_to_variant; +pub use types::{ + JadeAccount, JadeAccountExport, JadeAddressVariant, JadeDeviceInfo, JadeError, JadeNetwork, + JadePingStatus, JadeSignedMessage, JadeState, JadeTransportErrorCode, JadeTransportKind, + JadeVersionInfo, JadeXpubResponse, +}; diff --git a/src/modules/jade/tests.rs b/src/modules/jade/tests.rs new file mode 100644 index 0000000..c955e96 --- /dev/null +++ b/src/modules/jade/tests.rs @@ -0,0 +1,188 @@ +//! Tests for the FFI adapter. +//! +//! Protocol level behaviour (framing, correlation, the unlock exchange, PSBT +//! checks) is tested in the `jade-client-rs` crate. What is left here is the +//! adapter: the account type mapping, and the bridge from the foreign callback +//! onto the crate's transport trait. + +use super::callbacks::{ + CallbackTransport, JadeNativeDevice, JadeTransportCallback, JadeTransportReadResult, + JadeTransportResult, +}; +use super::types::{account_type_to_variant, JadeAddressVariant, JadeTransportKind}; +use crate::onchain::AccountType; +use jade_client_rs::{JadeError, JadeTransport, MAX_CHUNK_BYTES}; +use std::sync::{Arc, Mutex}; +use std::time::Duration; + +#[test] +fn account_types_map_to_descriptor_variants() { + let cases = [ + (AccountType::Legacy, JadeAddressVariant::Pkh), + (AccountType::WrappedSegwit, JadeAddressVariant::ShWpkh), + (AccountType::NativeSegwit, JadeAddressVariant::Wpkh), + (AccountType::Taproot, JadeAddressVariant::Tr), + ]; + for (account_type, expected) in cases { + assert_eq!(account_type_to_variant(account_type), expected); + } +} + +/// A callback that records what it was asked to do. +struct MockCallback { + chunk_size: u32, + writes: Mutex>>, + reads: Mutex>>, + fail_write: bool, +} + +impl MockCallback { + fn with_chunk_size(chunk_size: u32) -> Arc { + Arc::new(Self { + chunk_size, + writes: Mutex::new(Vec::new()), + reads: Mutex::new(Vec::new()), + fail_write: false, + }) + } + + fn failing() -> Arc { + Arc::new(Self { + chunk_size: 64, + writes: Mutex::new(Vec::new()), + reads: Mutex::new(Vec::new()), + fail_write: true, + }) + } +} + +impl JadeTransportCallback for MockCallback { + fn scan_devices(&self, _timeout_ms: u32) -> Vec { + vec![JadeNativeDevice { + path: "AA:BB:CC:DD:EE:FF".to_string(), + transport: JadeTransportKind::Bluetooth, + name: Some("Jade C0FFEE".to_string()), + serial_number: Some("C0FFEE".to_string()), + }] + } + + fn open_device(&self, _path: String) -> JadeTransportResult { + JadeTransportResult { + success: true, + error: String::new(), + error_code: None, + } + } + + fn close_device(&self, _path: String) -> JadeTransportResult { + JadeTransportResult { + success: true, + error: String::new(), + error_code: None, + } + } + + fn write_chunk(&self, _path: String, data: Vec) -> JadeTransportResult { + if self.fail_write { + return JadeTransportResult { + success: false, + error: "device went away".to_string(), + error_code: Some(jade_client_rs::JadeTransportErrorCode::Disconnected), + }; + } + self.writes.lock().unwrap().push(data); + JadeTransportResult { + success: true, + error: String::new(), + error_code: None, + } + } + + fn read_chunk(&self, _path: String, _timeout_ms: u32) -> JadeTransportReadResult { + let data = self.reads.lock().unwrap().pop().unwrap_or_default(); + JadeTransportReadResult { + success: true, + data, + error: String::new(), + error_code: None, + } + } + + fn get_chunk_size(&self, _path: String) -> u32 { + self.chunk_size + } +} + +#[tokio::test] +async fn writes_are_split_at_the_reported_chunk_size() { + let callback = MockCallback::with_chunk_size(4); + let transport = CallbackTransport::new(Arc::clone(&callback) as Arc<_>, "path".to_string()); + + transport + .write_all(vec![1, 2, 3, 4, 5, 6, 7, 8, 9]) + .await + .unwrap(); + + let writes = callback.writes.lock().unwrap(); + assert_eq!(writes.len(), 3); + assert_eq!(writes[0], vec![1, 2, 3, 4]); + assert_eq!(writes[1], vec![5, 6, 7, 8]); + assert_eq!(writes[2], vec![9]); +} + +#[tokio::test] +async fn a_zero_chunk_size_does_not_stall_the_write_loop() { + // A native implementation can report 0 before the MTU is negotiated. + // Without clamping, chunks(0) panics and the loop never advances. + let callback = MockCallback::with_chunk_size(0); + let transport = CallbackTransport::new(Arc::clone(&callback) as Arc<_>, "path".to_string()); + + transport.write_all(vec![1, 2, 3]).await.unwrap(); + + let writes = callback.writes.lock().unwrap(); + assert_eq!( + writes.len(), + 3, + "a clamped size of 1 sends one byte per write" + ); +} + +#[tokio::test] +async fn an_oversized_chunk_size_is_capped_to_the_bluetooth_limit() { + let callback = MockCallback::with_chunk_size(100_000); + let transport = CallbackTransport::new(Arc::clone(&callback) as Arc<_>, "path".to_string()); + + let payload = vec![7u8; MAX_CHUNK_BYTES as usize + 10]; + transport.write_all(payload).await.unwrap(); + + let writes = callback.writes.lock().unwrap(); + assert_eq!(writes.len(), 2); + assert_eq!(writes[0].len(), MAX_CHUNK_BYTES as usize); + assert_eq!(writes[1].len(), 10); +} + +#[tokio::test] +async fn a_typed_transport_error_survives_the_bridge() { + // The trezor adapter has to encode its error code into a string and parse it + // back out, because its upstream crate offers no typed channel. This one + // carries the code the whole way, so the mapping is exact. + let callback = MockCallback::failing(); + let transport = CallbackTransport::new(callback as Arc<_>, "path".to_string()); + + let error = transport.write_all(vec![1]).await.unwrap_err(); + assert_eq!(error, JadeError::DeviceDisconnected); +} + +#[tokio::test] +async fn an_empty_read_is_not_an_error() { + // Success with no data means "nothing yet", which is the normal state while + // the user is deciding on the device. + let callback = MockCallback::with_chunk_size(64); + let transport = CallbackTransport::new(callback as Arc<_>, "path".to_string()); + + let data = transport + .read_some(Duration::from_millis(10)) + .await + .unwrap(); + assert!(data.is_empty()); +} diff --git a/src/modules/jade/types.rs b/src/modules/jade/types.rs new file mode 100644 index 0000000..fdac7f1 --- /dev/null +++ b/src/modules/jade/types.rs @@ -0,0 +1,156 @@ +//! UniFFI scaffolding for the `jade-client-rs` types. +//! +//! Every type here is defined in that crate, not this one. `#[uniffi::remote]` +//! attaches the same scaffolding `#[derive(uniffi::…)]` would, without a +//! mirrored set of structs and hand-written `From` conversions in both +//! directions. The trezor module predates this and pays that cost; this module +//! does not. +//! +//! The declarations below must match the upstream definitions variant for +//! variant and field for field. The compiler catches a mismatch, and the tests +//! in `tests.rs` exercise the round trip. + +pub use jade_client_rs::{ + JadeAccount, JadeAccountExport, JadeAddressVariant, JadeDeviceInfo, JadeError, JadeNetwork, + JadePingStatus, JadeSignedMessage, JadeState, JadeTransportErrorCode, JadeTransportKind, + JadeVersionInfo, JadeXpubResponse, +}; + +use crate::onchain::AccountType; + +#[uniffi::remote(Enum)] +pub enum JadeNetwork { + Mainnet, + Testnet, + Regtest, +} + +#[uniffi::remote(Enum)] +pub enum JadeTransportKind { + Bluetooth, + Serial, +} + +#[uniffi::remote(Enum)] +pub enum JadeAddressVariant { + Pkh, + Wpkh, + ShWpkh, + Tr, +} + +#[uniffi::remote(Enum)] +pub enum JadeState { + Uninit, + Unsaved, + Locked, + Ready, + Temp, + Unknown, +} + +#[uniffi::remote(Enum)] +pub enum JadePingStatus { + Idle, + Busy, + AwaitingUserInput, +} + +#[uniffi::remote(Enum)] +pub enum JadeTransportErrorCode { + DeviceBusy, + NotConnected, + Disconnected, + Timeout, + PermissionDenied, +} + +#[uniffi::remote(Record)] +pub struct JadeDeviceInfo { + pub path: String, + pub transport: JadeTransportKind, + pub name: Option, + pub serial_number: Option, +} + +#[uniffi::remote(Record)] +pub struct JadeVersionInfo { + pub jade_version: String, + pub jade_state: JadeState, + pub jade_networks: Option, + pub jade_has_pin: Option, + pub board_type: Option, + pub jade_config: Option, + pub jade_features: Option, + pub idf_version: Option, + pub chip_features: Option, + pub efuse_mac: Option, + pub battery_status: Option, + pub jade_ota_max_chunk: Option, +} + +#[uniffi::remote(Record)] +pub struct JadeXpubResponse { + pub xpub: String, + pub derivation_path: String, + pub master_fingerprint: String, +} + +#[uniffi::remote(Record)] +pub struct JadeAccount { + pub variant: JadeAddressVariant, + pub xpub: String, + pub derivation_path: String, +} + +#[uniffi::remote(Record)] +pub struct JadeAccountExport { + pub master_fingerprint: String, + pub account_index: u32, + pub accounts: Vec, +} + +#[uniffi::remote(Record)] +pub struct JadeSignedMessage { + pub signature: String, + pub address: String, + pub derivation_path: String, +} + +#[uniffi::remote(Error)] +pub enum JadeError { + TransportError { error_details: String }, + DeviceNotFound, + DeviceDisconnected, + DeviceBusy, + NotConnected, + NotInitialized, + ConnectionError { error_details: String }, + ProtocolError { error_details: String }, + Timeout, + UserCancelled, + DeviceLocked, + DeviceUninitialized, + InvalidPin, + NetworkMismatch { error_details: String }, + UnsupportedFirmware { installed: String, required: String }, + InvalidPath { error_details: String }, + InvalidPsbt { error_details: String }, + PsbtTooLarge { size: u64, max: u64 }, + FingerprintMismatch { device: String, psbt: String }, + NothingSigned, + AddressMismatch { expected: String, returned: String }, + PinServerError { error_details: String }, + DeviceError { error_details: String }, + IoError { error_details: String }, +} + +/// Map the signer-neutral account type onto Jade's descriptor variant. +pub(crate) fn account_type_to_variant(account_type: AccountType) -> JadeAddressVariant { + match account_type { + AccountType::Legacy => JadeAddressVariant::Pkh, + AccountType::WrappedSegwit => JadeAddressVariant::ShWpkh, + AccountType::NativeSegwit => JadeAddressVariant::Wpkh, + AccountType::Taproot => JadeAddressVariant::Tr, + } +} diff --git a/src/modules/mod.rs b/src/modules/mod.rs index 3872dc2..33dc643 100644 --- a/src/modules/mod.rs +++ b/src/modules/mod.rs @@ -2,6 +2,7 @@ pub mod activity; pub mod blocktank; pub mod boltz; pub mod hardware_wallet; +pub mod jade; pub mod lnurl; pub mod onchain; pub mod pubky;